mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-11 03:56:16 +00:00
LibWeb/CSS: Add support for the srgb-linear
color space in color()
That makes us pass the following WPT tests: - css/css-color/srgb-linear-001.html - css/css-color/srgb-linear-002.html - css/css-color/srgb-linear-003.html
This commit is contained in:
parent
6319dedbcd
commit
7c2601f315
Notes:
github-actions[bot]
2024-11-15 19:35:12 +00:00
Author: https://github.com/LucasChollet
Commit: 7c2601f315
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2338
11 changed files with 104 additions and 1 deletions
|
@ -17,6 +17,8 @@ CSSColorValue::ColorType color_type_from_string_view(StringView color_space)
|
|||
{
|
||||
if (color_space == "srgb"sv)
|
||||
return CSSColorValue::ColorType::sRGB;
|
||||
if (color_space == "srgb-linear"sv)
|
||||
return CSSColorValue::ColorType::sRGBLinear;
|
||||
if (color_space == "xyz-d50"sv)
|
||||
return CSSColorValue::ColorType::XYZD50;
|
||||
if (color_space == "xyz"sv || color_space == "xyz-d65")
|
||||
|
@ -68,6 +70,9 @@ Color CSSColor::to_color(Optional<Layout::NodeWithStyle const&>) const
|
|||
return Color(to_u8(c1), to_u8(c2), to_u8(c3), to_u8(alpha_val));
|
||||
}
|
||||
|
||||
if (color_type() == ColorType::sRGBLinear)
|
||||
return Color::from_linear_srgb(c1, c2, c3, alpha_val);
|
||||
|
||||
if (color_type() == ColorType::XYZD50)
|
||||
return Color::from_xyz50(c1, c2, c3, alpha_val);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
virtual Color to_color(Optional<Layout::NodeWithStyle const&>) const override;
|
||||
virtual String to_string() const override;
|
||||
|
||||
static constexpr Array s_supported_color_space = { "srgb"sv, "xyz"sv, "xyz-d50"sv, "xyz-d65"sv };
|
||||
static constexpr Array s_supported_color_space = { "srgb"sv, "srgb-linear"sv, "xyz"sv, "xyz-d50"sv, "xyz-d65"sv };
|
||||
|
||||
private:
|
||||
CSSColor(ColorType color_type, ValueComparingNonnullRefPtr<CSSStyleValue> c1, ValueComparingNonnullRefPtr<CSSStyleValue> c2, ValueComparingNonnullRefPtr<CSSStyleValue> c3, ValueComparingNonnullRefPtr<CSSStyleValue> alpha)
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
OKLab,
|
||||
OKLCH,
|
||||
sRGB, // This is used by CSSColor for color(srgb ...).
|
||||
sRGBLinear,
|
||||
XYZD50,
|
||||
XYZD65,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue