diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSColor.cpp b/Libraries/LibWeb/CSS/StyleValues/CSSColor.cpp index be38c990316..873ba1583ff 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSColor.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CSSColor.cpp @@ -34,6 +34,27 @@ CSSColorValue::ColorType color_type_from_string_view(StringView color_space) VERIFY_NOT_REACHED(); } +StringView string_view_from_color_type(CSSColorValue::ColorType color_type) +{ + if (color_type == CSSColorValue::ColorType::A98RGB) + return "a98-rgb"sv; + if (color_type == CSSColorValue::ColorType::DisplayP3) + return "display-p3"sv; + if (color_type == CSSColorValue::ColorType::sRGB) + return "srgb"sv; + if (color_type == CSSColorValue::ColorType::sRGBLinear) + return "srgb-linear"sv; + if (color_type == CSSColorValue::ColorType::ProPhotoRGB) + return "prophoto-rgb"sv; + if (color_type == CSSColorValue::ColorType::Rec2020) + return "rec2020"sv; + if (color_type == CSSColorValue::ColorType::XYZD50) + return "xyz-d50"sv; + if (color_type == CSSColorValue::ColorType::XYZD65) + return "xyz"sv; + VERIFY_NOT_REACHED(); +} + } ValueComparingNonnullRefPtr CSSColor::create(StringView color_space, ValueComparingNonnullRefPtr c1, ValueComparingNonnullRefPtr c2, ValueComparingNonnullRefPtr c3, ValueComparingRefPtr alpha) @@ -59,19 +80,42 @@ bool CSSColor::equals(CSSStyleValue const& other) const return m_properties == other_lab_like.m_properties; } +CSSColor::Resolved CSSColor::resolve_properties() const +{ + float const c1 = resolve_with_reference_value(m_properties.channels[0], 1).value_or(0); + float const c2 = resolve_with_reference_value(m_properties.channels[1], 1).value_or(0); + float const c3 = resolve_with_reference_value(m_properties.channels[2], 1).value_or(0); + float const alpha_val = resolve_alpha(m_properties.alpha).value_or(1); + return { .channels = { c1, c2, c3 }, .alpha = alpha_val }; +} + // https://www.w3.org/TR/css-color-4/#serializing-color-function-values String CSSColor::to_string(SerializationMode) const { // FIXME: Do this properly, taking unresolved calculated values into account. - return serialize_a_srgb_value(to_color({})); + auto resolved = resolve_properties(); + if (resolved.alpha == 1) { + return MUST(String::formatted("color({} {} {} {})", + string_view_from_color_type(m_color_type), + resolved.channels[0], + resolved.channels[1], + resolved.channels[2])); + } + + return MUST(String::formatted("color({} {} {} {} / {})", + string_view_from_color_type(m_color_type), + resolved.channels[0], + resolved.channels[1], + resolved.channels[2], + resolved.alpha)); } Color CSSColor::to_color(Optional) const { - auto const c1 = resolve_with_reference_value(m_properties.channels[0], 1).value_or(0); - auto const c2 = resolve_with_reference_value(m_properties.channels[1], 1).value_or(0); - auto const c3 = resolve_with_reference_value(m_properties.channels[2], 1).value_or(0); - auto const alpha_val = resolve_alpha(m_properties.alpha).value_or(1); + auto [channels, alpha_val] = resolve_properties(); + auto c1 = channels[0]; + auto c2 = channels[1]; + auto c3 = channels[2]; if (color_type() == ColorType::A98RGB) return Color::from_a98rgb(c1, c2, c3, alpha_val); diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSColor.h b/Libraries/LibWeb/CSS/StyleValues/CSSColor.h index b46108abe3f..671f632b57c 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSColor.h +++ b/Libraries/LibWeb/CSS/StyleValues/CSSColor.h @@ -34,7 +34,16 @@ private: Array, 3> channels; ValueComparingNonnullRefPtr alpha; bool operator==(Properties const&) const = default; - } m_properties; + }; + + struct Resolved { + Array channels {}; + float alpha {}; + }; + + Resolved resolve_properties() const; + + Properties m_properties; }; } // Web::CSS diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSColorValue.h b/Libraries/LibWeb/CSS/StyleValues/CSSColorValue.h index c73d006e24e..225a4e8fb4d 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSColorValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/CSSColorValue.h @@ -53,7 +53,6 @@ protected: static Optional resolve_with_reference_value(CSSStyleValue const&, float one_hundred_percent_value); static Optional resolve_alpha(CSSStyleValue const&); -private: ColorType m_color_type; }; diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-color/parsing/color-valid-color-function.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-color/parsing/color-valid-color-function.txt new file mode 100644 index 00000000000..67026febdfd --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-color/parsing/color-valid-color-function.txt @@ -0,0 +1,312 @@ +Harness status: OK + +Found 306 tests + +140 Pass +166 Fail +Pass e.style['color'] = "color(srgb 0% 0% 0%)" should set the property value +Pass e.style['color'] = "color(srgb 10% 10% 10%)" should set the property value +Pass e.style['color'] = "color(srgb .2 .2 25%)" should set the property value +Pass e.style['color'] = "color(srgb 0 0 0 / 1)" should set the property value +Pass e.style['color'] = "color(srgb 0% 0 0 / 0.5)" should set the property value +Pass e.style['color'] = "color(srgb 20% 0 10/0.5)" should set the property value +Pass e.style['color'] = "color(srgb 20% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(srgb 400% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(srgb 50% -160 160)" should set the property value +Pass e.style['color'] = "color(srgb 50% -200 200)" should set the property value +Pass e.style['color'] = "color(srgb 0 0 0 / -10%)" should set the property value +Pass e.style['color'] = "color(srgb 0 0 0 / 110%)" should set the property value +Pass e.style['color'] = "color(srgb 0 0 0 / 300%)" should set the property value +Pass e.style['color'] = "color(srgb 200 200 200)" should set the property value +Pass e.style['color'] = "color(srgb 200 200 200 / 200)" should set the property value +Pass e.style['color'] = "color(srgb -200 -200 -200)" should set the property value +Pass e.style['color'] = "color(srgb -200 -200 -200 / -200)" should set the property value +Pass e.style['color'] = "color(srgb 200% 200% 200%)" should set the property value +Pass e.style['color'] = "color(srgb 200% 200% 200% / 200%)" should set the property value +Pass e.style['color'] = "color(srgb -200% -200% -200% / -200%)" should set the property value +Fail e.style['color'] = "color(srgb calc(0.5 + 1) calc(0.5 - 1) calc(0.5) / calc(-0.5 + 1))" should set the property value +Fail e.style['color'] = "color(srgb calc(50% * 3) calc(-150% / 3) calc(50%) / calc(-50% * 3))" should set the property value +Fail e.style['color'] = "color(srgb calc(50%) 50% 0.5)" should set the property value +Fail e.style['color'] = "color(srgb none none none / none)" should set the property value +Fail e.style['color'] = "color(srgb none none none)" should set the property value +Fail e.style['color'] = "color(srgb 10% none none / none)" should set the property value +Fail e.style['color'] = "color(srgb none none none / 0.5)" should set the property value +Fail e.style['color'] = "color(srgb 0 0 0 / none)" should set the property value +Fail e.style['color'] = "color(srgb 0 calc(infinity) 0)" should set the property value +Fail e.style['color'] = "color(srgb 0 calc(-infinity) 0)" should set the property value +Fail e.style['color'] = "color(srgb calc(NaN) 0 0)" should set the property value +Fail e.style['color'] = "color(srgb calc(0 / 0) 0 0)" should set the property value +Fail e.style['color'] = "color(srgb calc(50% + (sign(1em - 10px) * 10%)) 0 0 / 0.5)" should set the property value +Fail e.style['color'] = "color(srgb 0.5 0 0 / calc(50% + (sign(1em - 10px) * 10%)))" should set the property value +Pass e.style['color'] = "color(srgb-linear 0% 0% 0%)" should set the property value +Pass e.style['color'] = "color(srgb-linear 10% 10% 10%)" should set the property value +Pass e.style['color'] = "color(srgb-linear .2 .2 25%)" should set the property value +Pass e.style['color'] = "color(srgb-linear 0 0 0 / 1)" should set the property value +Pass e.style['color'] = "color(srgb-linear 0% 0 0 / 0.5)" should set the property value +Pass e.style['color'] = "color(srgb-linear 20% 0 10/0.5)" should set the property value +Pass e.style['color'] = "color(srgb-linear 20% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(srgb-linear 400% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(srgb-linear 50% -160 160)" should set the property value +Pass e.style['color'] = "color(srgb-linear 50% -200 200)" should set the property value +Pass e.style['color'] = "color(srgb-linear 0 0 0 / -10%)" should set the property value +Pass e.style['color'] = "color(srgb-linear 0 0 0 / 110%)" should set the property value +Pass e.style['color'] = "color(srgb-linear 0 0 0 / 300%)" should set the property value +Pass e.style['color'] = "color(srgb-linear 200 200 200)" should set the property value +Pass e.style['color'] = "color(srgb-linear 200 200 200 / 200)" should set the property value +Pass e.style['color'] = "color(srgb-linear -200 -200 -200)" should set the property value +Pass e.style['color'] = "color(srgb-linear -200 -200 -200 / -200)" should set the property value +Pass e.style['color'] = "color(srgb-linear 200% 200% 200%)" should set the property value +Pass e.style['color'] = "color(srgb-linear 200% 200% 200% / 200%)" should set the property value +Pass e.style['color'] = "color(srgb-linear -200% -200% -200% / -200%)" should set the property value +Fail e.style['color'] = "color(srgb-linear calc(0.5 + 1) calc(0.5 - 1) calc(0.5) / calc(-0.5 + 1))" should set the property value +Fail e.style['color'] = "color(srgb-linear calc(50% * 3) calc(-150% / 3) calc(50%) / calc(-50% * 3))" should set the property value +Fail e.style['color'] = "color(srgb-linear calc(50%) 50% 0.5)" should set the property value +Fail e.style['color'] = "color(srgb-linear none none none / none)" should set the property value +Fail e.style['color'] = "color(srgb-linear none none none)" should set the property value +Fail e.style['color'] = "color(srgb-linear 10% none none / none)" should set the property value +Fail e.style['color'] = "color(srgb-linear none none none / 0.5)" should set the property value +Fail e.style['color'] = "color(srgb-linear 0 0 0 / none)" should set the property value +Fail e.style['color'] = "color(srgb-linear 0 calc(infinity) 0)" should set the property value +Fail e.style['color'] = "color(srgb-linear 0 calc(-infinity) 0)" should set the property value +Fail e.style['color'] = "color(srgb-linear calc(NaN) 0 0)" should set the property value +Fail e.style['color'] = "color(srgb-linear calc(0 / 0) 0 0)" should set the property value +Fail e.style['color'] = "color(srgb-linear calc(50% + (sign(1em - 10px) * 10%)) 0 0 / 0.5)" should set the property value +Fail e.style['color'] = "color(srgb-linear 0.5 0 0 / calc(50% + (sign(1em - 10px) * 10%)))" should set the property value +Pass e.style['color'] = "color(a98-rgb 0% 0% 0%)" should set the property value +Pass e.style['color'] = "color(a98-rgb 10% 10% 10%)" should set the property value +Pass e.style['color'] = "color(a98-rgb .2 .2 25%)" should set the property value +Pass e.style['color'] = "color(a98-rgb 0 0 0 / 1)" should set the property value +Pass e.style['color'] = "color(a98-rgb 0% 0 0 / 0.5)" should set the property value +Pass e.style['color'] = "color(a98-rgb 20% 0 10/0.5)" should set the property value +Pass e.style['color'] = "color(a98-rgb 20% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(a98-rgb 400% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(a98-rgb 50% -160 160)" should set the property value +Pass e.style['color'] = "color(a98-rgb 50% -200 200)" should set the property value +Pass e.style['color'] = "color(a98-rgb 0 0 0 / -10%)" should set the property value +Pass e.style['color'] = "color(a98-rgb 0 0 0 / 110%)" should set the property value +Pass e.style['color'] = "color(a98-rgb 0 0 0 / 300%)" should set the property value +Pass e.style['color'] = "color(a98-rgb 200 200 200)" should set the property value +Pass e.style['color'] = "color(a98-rgb 200 200 200 / 200)" should set the property value +Pass e.style['color'] = "color(a98-rgb -200 -200 -200)" should set the property value +Pass e.style['color'] = "color(a98-rgb -200 -200 -200 / -200)" should set the property value +Pass e.style['color'] = "color(a98-rgb 200% 200% 200%)" should set the property value +Pass e.style['color'] = "color(a98-rgb 200% 200% 200% / 200%)" should set the property value +Pass e.style['color'] = "color(a98-rgb -200% -200% -200% / -200%)" should set the property value +Fail e.style['color'] = "color(a98-rgb calc(0.5 + 1) calc(0.5 - 1) calc(0.5) / calc(-0.5 + 1))" should set the property value +Fail e.style['color'] = "color(a98-rgb calc(50% * 3) calc(-150% / 3) calc(50%) / calc(-50% * 3))" should set the property value +Fail e.style['color'] = "color(a98-rgb calc(50%) 50% 0.5)" should set the property value +Fail e.style['color'] = "color(a98-rgb none none none / none)" should set the property value +Fail e.style['color'] = "color(a98-rgb none none none)" should set the property value +Fail e.style['color'] = "color(a98-rgb 10% none none / none)" should set the property value +Fail e.style['color'] = "color(a98-rgb none none none / 0.5)" should set the property value +Fail e.style['color'] = "color(a98-rgb 0 0 0 / none)" should set the property value +Fail e.style['color'] = "color(a98-rgb 0 calc(infinity) 0)" should set the property value +Fail e.style['color'] = "color(a98-rgb 0 calc(-infinity) 0)" should set the property value +Fail e.style['color'] = "color(a98-rgb calc(NaN) 0 0)" should set the property value +Fail e.style['color'] = "color(a98-rgb calc(0 / 0) 0 0)" should set the property value +Fail e.style['color'] = "color(a98-rgb calc(50% + (sign(1em - 10px) * 10%)) 0 0 / 0.5)" should set the property value +Fail e.style['color'] = "color(a98-rgb 0.5 0 0 / calc(50% + (sign(1em - 10px) * 10%)))" should set the property value +Pass e.style['color'] = "color(rec2020 0% 0% 0%)" should set the property value +Pass e.style['color'] = "color(rec2020 10% 10% 10%)" should set the property value +Pass e.style['color'] = "color(rec2020 .2 .2 25%)" should set the property value +Pass e.style['color'] = "color(rec2020 0 0 0 / 1)" should set the property value +Pass e.style['color'] = "color(rec2020 0% 0 0 / 0.5)" should set the property value +Pass e.style['color'] = "color(rec2020 20% 0 10/0.5)" should set the property value +Pass e.style['color'] = "color(rec2020 20% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(rec2020 400% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(rec2020 50% -160 160)" should set the property value +Pass e.style['color'] = "color(rec2020 50% -200 200)" should set the property value +Pass e.style['color'] = "color(rec2020 0 0 0 / -10%)" should set the property value +Pass e.style['color'] = "color(rec2020 0 0 0 / 110%)" should set the property value +Pass e.style['color'] = "color(rec2020 0 0 0 / 300%)" should set the property value +Pass e.style['color'] = "color(rec2020 200 200 200)" should set the property value +Pass e.style['color'] = "color(rec2020 200 200 200 / 200)" should set the property value +Pass e.style['color'] = "color(rec2020 -200 -200 -200)" should set the property value +Pass e.style['color'] = "color(rec2020 -200 -200 -200 / -200)" should set the property value +Pass e.style['color'] = "color(rec2020 200% 200% 200%)" should set the property value +Pass e.style['color'] = "color(rec2020 200% 200% 200% / 200%)" should set the property value +Pass e.style['color'] = "color(rec2020 -200% -200% -200% / -200%)" should set the property value +Fail e.style['color'] = "color(rec2020 calc(0.5 + 1) calc(0.5 - 1) calc(0.5) / calc(-0.5 + 1))" should set the property value +Fail e.style['color'] = "color(rec2020 calc(50% * 3) calc(-150% / 3) calc(50%) / calc(-50% * 3))" should set the property value +Fail e.style['color'] = "color(rec2020 calc(50%) 50% 0.5)" should set the property value +Fail e.style['color'] = "color(rec2020 none none none / none)" should set the property value +Fail e.style['color'] = "color(rec2020 none none none)" should set the property value +Fail e.style['color'] = "color(rec2020 10% none none / none)" should set the property value +Fail e.style['color'] = "color(rec2020 none none none / 0.5)" should set the property value +Fail e.style['color'] = "color(rec2020 0 0 0 / none)" should set the property value +Fail e.style['color'] = "color(rec2020 0 calc(infinity) 0)" should set the property value +Fail e.style['color'] = "color(rec2020 0 calc(-infinity) 0)" should set the property value +Fail e.style['color'] = "color(rec2020 calc(NaN) 0 0)" should set the property value +Fail e.style['color'] = "color(rec2020 calc(0 / 0) 0 0)" should set the property value +Fail e.style['color'] = "color(rec2020 calc(50% + (sign(1em - 10px) * 10%)) 0 0 / 0.5)" should set the property value +Fail e.style['color'] = "color(rec2020 0.5 0 0 / calc(50% + (sign(1em - 10px) * 10%)))" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 0% 0% 0%)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 10% 10% 10%)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb .2 .2 25%)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 0 0 0 / 1)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 0% 0 0 / 0.5)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 20% 0 10/0.5)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 20% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 400% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 50% -160 160)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 50% -200 200)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 0 0 0 / -10%)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 0 0 0 / 110%)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 0 0 0 / 300%)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 200 200 200)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 200 200 200 / 200)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb -200 -200 -200)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb -200 -200 -200 / -200)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 200% 200% 200%)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb 200% 200% 200% / 200%)" should set the property value +Pass e.style['color'] = "color(prophoto-rgb -200% -200% -200% / -200%)" should set the property value +Fail e.style['color'] = "color(prophoto-rgb calc(0.5 + 1) calc(0.5 - 1) calc(0.5) / calc(-0.5 + 1))" should set the property value +Fail e.style['color'] = "color(prophoto-rgb calc(50% * 3) calc(-150% / 3) calc(50%) / calc(-50% * 3))" should set the property value +Fail e.style['color'] = "color(prophoto-rgb calc(50%) 50% 0.5)" should set the property value +Fail e.style['color'] = "color(prophoto-rgb none none none / none)" should set the property value +Fail e.style['color'] = "color(prophoto-rgb none none none)" should set the property value +Fail e.style['color'] = "color(prophoto-rgb 10% none none / none)" should set the property value +Fail e.style['color'] = "color(prophoto-rgb none none none / 0.5)" should set the property value +Fail e.style['color'] = "color(prophoto-rgb 0 0 0 / none)" should set the property value +Fail e.style['color'] = "color(prophoto-rgb 0 calc(infinity) 0)" should set the property value +Fail e.style['color'] = "color(prophoto-rgb 0 calc(-infinity) 0)" should set the property value +Fail e.style['color'] = "color(prophoto-rgb calc(NaN) 0 0)" should set the property value +Fail e.style['color'] = "color(prophoto-rgb calc(0 / 0) 0 0)" should set the property value +Fail e.style['color'] = "color(prophoto-rgb calc(50% + (sign(1em - 10px) * 10%)) 0 0 / 0.5)" should set the property value +Fail e.style['color'] = "color(prophoto-rgb 0.5 0 0 / calc(50% + (sign(1em - 10px) * 10%)))" should set the property value +Pass e.style['color'] = "color(display-p3 0% 0% 0%)" should set the property value +Pass e.style['color'] = "color(display-p3 10% 10% 10%)" should set the property value +Pass e.style['color'] = "color(display-p3 .2 .2 25%)" should set the property value +Pass e.style['color'] = "color(display-p3 0 0 0 / 1)" should set the property value +Pass e.style['color'] = "color(display-p3 0% 0 0 / 0.5)" should set the property value +Pass e.style['color'] = "color(display-p3 20% 0 10/0.5)" should set the property value +Pass e.style['color'] = "color(display-p3 20% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(display-p3 400% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(display-p3 50% -160 160)" should set the property value +Pass e.style['color'] = "color(display-p3 50% -200 200)" should set the property value +Pass e.style['color'] = "color(display-p3 0 0 0 / -10%)" should set the property value +Pass e.style['color'] = "color(display-p3 0 0 0 / 110%)" should set the property value +Pass e.style['color'] = "color(display-p3 0 0 0 / 300%)" should set the property value +Pass e.style['color'] = "color(display-p3 200 200 200)" should set the property value +Pass e.style['color'] = "color(display-p3 200 200 200 / 200)" should set the property value +Pass e.style['color'] = "color(display-p3 -200 -200 -200)" should set the property value +Pass e.style['color'] = "color(display-p3 -200 -200 -200 / -200)" should set the property value +Pass e.style['color'] = "color(display-p3 200% 200% 200%)" should set the property value +Pass e.style['color'] = "color(display-p3 200% 200% 200% / 200%)" should set the property value +Pass e.style['color'] = "color(display-p3 -200% -200% -200% / -200%)" should set the property value +Fail e.style['color'] = "color(display-p3 calc(0.5 + 1) calc(0.5 - 1) calc(0.5) / calc(-0.5 + 1))" should set the property value +Fail e.style['color'] = "color(display-p3 calc(50% * 3) calc(-150% / 3) calc(50%) / calc(-50% * 3))" should set the property value +Fail e.style['color'] = "color(display-p3 calc(50%) 50% 0.5)" should set the property value +Fail e.style['color'] = "color(display-p3 none none none / none)" should set the property value +Fail e.style['color'] = "color(display-p3 none none none)" should set the property value +Fail e.style['color'] = "color(display-p3 10% none none / none)" should set the property value +Fail e.style['color'] = "color(display-p3 none none none / 0.5)" should set the property value +Fail e.style['color'] = "color(display-p3 0 0 0 / none)" should set the property value +Fail e.style['color'] = "color(display-p3 0 calc(infinity) 0)" should set the property value +Fail e.style['color'] = "color(display-p3 0 calc(-infinity) 0)" should set the property value +Fail e.style['color'] = "color(display-p3 calc(NaN) 0 0)" should set the property value +Fail e.style['color'] = "color(display-p3 calc(0 / 0) 0 0)" should set the property value +Fail e.style['color'] = "color(display-p3 calc(50% + (sign(1em - 10px) * 10%)) 0 0 / 0.5)" should set the property value +Fail e.style['color'] = "color(display-p3 0.5 0 0 / calc(50% + (sign(1em - 10px) * 10%)))" should set the property value +Fail e.style['color'] = "color(xyz 0% 0% 0%)" should set the property value +Fail e.style['color'] = "color(xyz 10% 10% 10%)" should set the property value +Fail e.style['color'] = "color(xyz .2 .2 25%)" should set the property value +Fail e.style['color'] = "color(xyz 0 0 0 / 1)" should set the property value +Fail e.style['color'] = "color(xyz 0% 0 0 / 0.5)" should set the property value +Fail e.style['color'] = "color(xyz 20% 0 10/0.5)" should set the property value +Fail e.style['color'] = "color(xyz 20% 0 10/50%)" should set the property value +Fail e.style['color'] = "color(xyz 400% 0 10/50%)" should set the property value +Fail e.style['color'] = "color(xyz 50% -160 160)" should set the property value +Fail e.style['color'] = "color(xyz 50% -200 200)" should set the property value +Fail e.style['color'] = "color(xyz 0 0 0 / -10%)" should set the property value +Fail e.style['color'] = "color(xyz 0 0 0 / 110%)" should set the property value +Fail e.style['color'] = "color(xyz 0 0 0 / 300%)" should set the property value +Fail e.style['color'] = "color(xyz 200 200 200)" should set the property value +Fail e.style['color'] = "color(xyz 200 200 200 / 200)" should set the property value +Fail e.style['color'] = "color(xyz -200 -200 -200)" should set the property value +Fail e.style['color'] = "color(xyz -200 -200 -200 / -200)" should set the property value +Fail e.style['color'] = "color(xyz 200% 200% 200%)" should set the property value +Fail e.style['color'] = "color(xyz 200% 200% 200% / 200%)" should set the property value +Fail e.style['color'] = "color(xyz -200% -200% -200% / -200%)" should set the property value +Fail e.style['color'] = "color(xyz calc(0.5 + 1) calc(0.5 - 1) calc(0.5) / calc(-0.5 + 1))" should set the property value +Fail e.style['color'] = "color(xyz calc(50% * 3) calc(-150% / 3) calc(50%) / calc(-50% * 3))" should set the property value +Fail e.style['color'] = "color(xyz calc(50%) 50% 0.5)" should set the property value +Fail e.style['color'] = "color(xyz none none none / none)" should set the property value +Fail e.style['color'] = "color(xyz none none none)" should set the property value +Fail e.style['color'] = "color(xyz 10% none none / none)" should set the property value +Fail e.style['color'] = "color(xyz none none none / 0.5)" should set the property value +Fail e.style['color'] = "color(xyz 0 0 0 / none)" should set the property value +Fail e.style['color'] = "color(xyz 0 calc(infinity) 0)" should set the property value +Fail e.style['color'] = "color(xyz 0 calc(-infinity) 0)" should set the property value +Fail e.style['color'] = "color(xyz calc(NaN) 0 0)" should set the property value +Fail e.style['color'] = "color(xyz calc(0 / 0) 0 0)" should set the property value +Fail e.style['color'] = "color(xyz calc(50% + (sign(1em - 10px) * 10%)) 0 0 / 0.5)" should set the property value +Fail e.style['color'] = "color(xyz 0.5 0 0 / calc(50% + (sign(1em - 10px) * 10%)))" should set the property value +Pass e.style['color'] = "color(xyz-d50 0% 0% 0%)" should set the property value +Pass e.style['color'] = "color(xyz-d50 10% 10% 10%)" should set the property value +Pass e.style['color'] = "color(xyz-d50 .2 .2 25%)" should set the property value +Pass e.style['color'] = "color(xyz-d50 0 0 0 / 1)" should set the property value +Pass e.style['color'] = "color(xyz-d50 0% 0 0 / 0.5)" should set the property value +Pass e.style['color'] = "color(xyz-d50 20% 0 10/0.5)" should set the property value +Pass e.style['color'] = "color(xyz-d50 20% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(xyz-d50 400% 0 10/50%)" should set the property value +Pass e.style['color'] = "color(xyz-d50 50% -160 160)" should set the property value +Pass e.style['color'] = "color(xyz-d50 50% -200 200)" should set the property value +Pass e.style['color'] = "color(xyz-d50 0 0 0 / -10%)" should set the property value +Pass e.style['color'] = "color(xyz-d50 0 0 0 / 110%)" should set the property value +Pass e.style['color'] = "color(xyz-d50 0 0 0 / 300%)" should set the property value +Pass e.style['color'] = "color(xyz-d50 200 200 200)" should set the property value +Pass e.style['color'] = "color(xyz-d50 200 200 200 / 200)" should set the property value +Pass e.style['color'] = "color(xyz-d50 -200 -200 -200)" should set the property value +Pass e.style['color'] = "color(xyz-d50 -200 -200 -200 / -200)" should set the property value +Pass e.style['color'] = "color(xyz-d50 200% 200% 200%)" should set the property value +Pass e.style['color'] = "color(xyz-d50 200% 200% 200% / 200%)" should set the property value +Pass e.style['color'] = "color(xyz-d50 -200% -200% -200% / -200%)" should set the property value +Fail e.style['color'] = "color(xyz-d50 calc(0.5 + 1) calc(0.5 - 1) calc(0.5) / calc(-0.5 + 1))" should set the property value +Fail e.style['color'] = "color(xyz-d50 calc(50% * 3) calc(-150% / 3) calc(50%) / calc(-50% * 3))" should set the property value +Fail e.style['color'] = "color(xyz-d50 calc(50%) 50% 0.5)" should set the property value +Fail e.style['color'] = "color(xyz-d50 none none none / none)" should set the property value +Fail e.style['color'] = "color(xyz-d50 none none none)" should set the property value +Fail e.style['color'] = "color(xyz-d50 10% none none / none)" should set the property value +Fail e.style['color'] = "color(xyz-d50 none none none / 0.5)" should set the property value +Fail e.style['color'] = "color(xyz-d50 0 0 0 / none)" should set the property value +Fail e.style['color'] = "color(xyz-d50 0 calc(infinity) 0)" should set the property value +Fail e.style['color'] = "color(xyz-d50 0 calc(-infinity) 0)" should set the property value +Fail e.style['color'] = "color(xyz-d50 calc(NaN) 0 0)" should set the property value +Fail e.style['color'] = "color(xyz-d50 calc(0 / 0) 0 0)" should set the property value +Fail e.style['color'] = "color(xyz-d50 calc(50% + (sign(1em - 10px) * 10%)) 0 0 / 0.5)" should set the property value +Fail e.style['color'] = "color(xyz-d50 0.5 0 0 / calc(50% + (sign(1em - 10px) * 10%)))" should set the property value +Fail e.style['color'] = "color(xyz-d65 0% 0% 0%)" should set the property value +Fail e.style['color'] = "color(xyz-d65 10% 10% 10%)" should set the property value +Fail e.style['color'] = "color(xyz-d65 .2 .2 25%)" should set the property value +Fail e.style['color'] = "color(xyz-d65 0 0 0 / 1)" should set the property value +Fail e.style['color'] = "color(xyz-d65 0% 0 0 / 0.5)" should set the property value +Fail e.style['color'] = "color(xyz-d65 20% 0 10/0.5)" should set the property value +Fail e.style['color'] = "color(xyz-d65 20% 0 10/50%)" should set the property value +Fail e.style['color'] = "color(xyz-d65 400% 0 10/50%)" should set the property value +Fail e.style['color'] = "color(xyz-d65 50% -160 160)" should set the property value +Fail e.style['color'] = "color(xyz-d65 50% -200 200)" should set the property value +Fail e.style['color'] = "color(xyz-d65 0 0 0 / -10%)" should set the property value +Fail e.style['color'] = "color(xyz-d65 0 0 0 / 110%)" should set the property value +Fail e.style['color'] = "color(xyz-d65 0 0 0 / 300%)" should set the property value +Fail e.style['color'] = "color(xyz-d65 200 200 200)" should set the property value +Fail e.style['color'] = "color(xyz-d65 200 200 200 / 200)" should set the property value +Fail e.style['color'] = "color(xyz-d65 -200 -200 -200)" should set the property value +Fail e.style['color'] = "color(xyz-d65 -200 -200 -200 / -200)" should set the property value +Fail e.style['color'] = "color(xyz-d65 200% 200% 200%)" should set the property value +Fail e.style['color'] = "color(xyz-d65 200% 200% 200% / 200%)" should set the property value +Fail e.style['color'] = "color(xyz-d65 -200% -200% -200% / -200%)" should set the property value +Fail e.style['color'] = "color(xyz-d65 calc(0.5 + 1) calc(0.5 - 1) calc(0.5) / calc(-0.5 + 1))" should set the property value +Fail e.style['color'] = "color(xyz-d65 calc(50% * 3) calc(-150% / 3) calc(50%) / calc(-50% * 3))" should set the property value +Fail e.style['color'] = "color(xyz-d65 calc(50%) 50% 0.5)" should set the property value +Fail e.style['color'] = "color(xyz-d65 none none none / none)" should set the property value +Fail e.style['color'] = "color(xyz-d65 none none none)" should set the property value +Fail e.style['color'] = "color(xyz-d65 10% none none / none)" should set the property value +Fail e.style['color'] = "color(xyz-d65 none none none / 0.5)" should set the property value +Fail e.style['color'] = "color(xyz-d65 0 0 0 / none)" should set the property value +Fail e.style['color'] = "color(xyz-d65 0 calc(infinity) 0)" should set the property value +Fail e.style['color'] = "color(xyz-d65 0 calc(-infinity) 0)" should set the property value +Fail e.style['color'] = "color(xyz-d65 calc(NaN) 0 0)" should set the property value +Fail e.style['color'] = "color(xyz-d65 calc(0 / 0) 0 0)" should set the property value +Fail e.style['color'] = "color(xyz-d65 calc(50% + (sign(1em - 10px) * 10%)) 0 0 / 0.5)" should set the property value +Fail e.style['color'] = "color(xyz-d65 0.5 0 0 / calc(50% + (sign(1em - 10px) * 10%)))" should set the property value \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-color/parsing/color-valid-color-function.html b/Tests/LibWeb/Text/input/wpt-import/css/css-color/parsing/color-valid-color-function.html new file mode 100644 index 00000000000..592066a78ad --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-color/parsing/color-valid-color-function.html @@ -0,0 +1,59 @@ + + + + +CSS Color Level 4: Parsing and serialization of colors using valid color() function syntax + + + + + + + + + + +