mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-01 20:07:38 +02:00
LibWeb: Introduce color-function-specific style values
Instead of CSSColorValue holding a Gfx::Color, make it an abstract class with subclasses for each different color function, to match the Typed-OM spec. This means moving the color calculations from the parsing code to the `to_color()` method on the style value. This lets us have calc() inside a color function, instead of having to fully resolve the color at parse time. The canvas fillStyle tests have been updated to reflect this. The other test change is Screenshot/css-color-functions.html: previously we produced slightly different colors for an alpha of 0.5 and one of 50%, and this incorrect behavior was baked into the test. So now it's more correct. :^) (cherry picked from commit 3af6a69f1e13803c64466a9b24b7bd7d75d459df; amended to: * resolve a minor conflict in Parser.cpp due to upstream not having https://github.com/LadybirdBrowser/ladybird/pull/385#issuecomment-2227130015 * rebaseline canvas-fillstyle-rgb.png since the diff didn't apply due to us not having https://github.com/LadybirdBrowser/ladybird/pull/999 * remove css-color-functions-ref.png and instead update css-color-functions-ref.html since that file is still a reftest due to us not having https://github.com/LadybirdBrowser/ladybird/pull/736 Makes it much easier to see what actually changed. )
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021, the SerenityOS developers.
|
||||
* Copyright (c) 2021-2024, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
@@ -244,12 +244,6 @@ private:
|
||||
Optional<TimeOrCalculated> parse_time(TokenStream<ComponentValue>&);
|
||||
Optional<TimePercentage> parse_time_percentage(TokenStream<ComponentValue>&);
|
||||
|
||||
Optional<Color> parse_rgb_color(Vector<ComponentValue> const&);
|
||||
Optional<Color> parse_hsl_color(Vector<ComponentValue> const&);
|
||||
Optional<Color> parse_hwb_color(Vector<ComponentValue> const&);
|
||||
Optional<Color> parse_oklab_color(Vector<ComponentValue> const&);
|
||||
Optional<Color> parse_oklch_color(Vector<ComponentValue> const&);
|
||||
Optional<Color> parse_color(TokenStream<ComponentValue>&);
|
||||
Optional<LengthOrCalculated> parse_source_size_value(TokenStream<ComponentValue>&);
|
||||
Optional<Ratio> parse_ratio(TokenStream<ComponentValue>&);
|
||||
Optional<Gfx::UnicodeRange> parse_unicode_range(TokenStream<ComponentValue>&);
|
||||
@@ -289,6 +283,13 @@ private:
|
||||
OwnPtr<CalculationNode> parse_math_function(PropertyID, Function const&);
|
||||
OwnPtr<CalculationNode> parse_a_calc_function_node(Function const&);
|
||||
RefPtr<CSSStyleValue> parse_keyword_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue> parse_hue_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue> parse_solidus_and_alpha_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue> parse_rgb_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue> parse_hsl_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue> parse_hwb_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue> parse_oklab_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue> parse_oklch_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue> parse_color_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue> parse_counter_value(TokenStream<ComponentValue>&);
|
||||
enum class AllowReversed {
|
||||
|
||||
Reference in New Issue
Block a user