From 1b38ebcc7f9a28d4f5460804b1ebdc5ff7cb3311 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Wed, 13 Nov 2024 21:33:03 -0500 Subject: [PATCH] LibWeb/CSS: Resolve percentage values against 1 in CSSColor This was a silly mistake on my end and percentages values are not covered by device-independent color space, so I had to add support for srgb to run a WPT test that made me realize the mistake. This makes the following test pass: - css/css-color/predefined-002.html --- Libraries/LibWeb/CSS/StyleValues/CSSColor.cpp | 6 +++--- .../css/css-color/predefined-002.html | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 Tests/LibWeb/Ref/input/wpt-import/css/css-color/predefined-002.html diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSColor.cpp b/Libraries/LibWeb/CSS/StyleValues/CSSColor.cpp index 52b949d0f59..d77727a6840 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSColor.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CSSColor.cpp @@ -58,9 +58,9 @@ String CSSColor::to_string() const Color CSSColor::to_color(Optional) const { - auto const c1 = resolve_with_reference_value(m_properties.channels[0], 100).value_or(0); - auto const c2 = resolve_with_reference_value(m_properties.channels[1], 100).value_or(0); - auto const c3 = resolve_with_reference_value(m_properties.channels[2], 100).value_or(0); + 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); if (color_type() == ColorType::sRGB) { diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-color/predefined-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-color/predefined-002.html new file mode 100644 index 00000000000..521ad00ae0c --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-color/predefined-002.html @@ -0,0 +1,17 @@ + + +CSS Color 4: predefined colorspaces, srgb, percent values + + + + + + +

Test passes if you see a green square, and no red.

+

+

+