diff --git a/Tests/LibWeb/Screenshot/css-color-functions.html b/Tests/LibWeb/Screenshot/css-color-functions.html index bb42acaf997..df4f0bf4927 100644 --- a/Tests/LibWeb/Screenshot/css-color-functions.html +++ b/Tests/LibWeb/Screenshot/css-color-functions.html @@ -36,6 +36,9 @@

legacy rgba with out-of-range percentages (should be clamped)

+
+

modern rgb with percentages (round away from 0)

+

modern rgb with mixed types

diff --git a/Tests/LibWeb/Screenshot/images/css-color-functions-ref.png b/Tests/LibWeb/Screenshot/images/css-color-functions-ref.png index 464bcb783fb..d89575b176d 100644 Binary files a/Tests/LibWeb/Screenshot/images/css-color-functions-ref.png and b/Tests/LibWeb/Screenshot/images/css-color-functions-ref.png differ diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/CSSRGB.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/CSSRGB.cpp index 6f3d4f96305..85f1531a17e 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/CSSRGB.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/CSSRGB.cpp @@ -25,14 +25,14 @@ Color CSSRGB::to_color(Optional) const return normalized(style_value.as_number().number()); if (style_value.is_percentage()) - return normalized(style_value.as_percentage().value() * 2.55); + return normalized(style_value.as_percentage().value() * 255 / 100); if (style_value.is_math()) { auto const& calculated = style_value.as_math(); if (calculated.resolves_to_number()) return normalized(calculated.resolve_number().value()); if (calculated.resolves_to_percentage()) - return normalized(calculated.resolve_percentage().value().value() * 2.55); + return normalized(calculated.resolve_percentage().value().value() * 255 / 100); } if (style_value.is_keyword() && style_value.to_keyword() == Keyword::None)