LibWeb: Parse and plumb the accent-color CSS property

This commit is contained in:
MacDue 2023-03-18 20:49:00 +01:00 committed by Sam Atkins
parent d005b1ad1b
commit 87b8a36e56
Notes: sideshowbarker 2024-07-18 02:13:10 +09:00
5 changed files with 26 additions and 0 deletions

View File

@ -168,6 +168,7 @@ public:
float flex_grow() const { return m_noninherited.flex_grow; }
float flex_shrink() const { return m_noninherited.flex_shrink; }
int order() const { return m_noninherited.order; }
Optional<Color> accent_color() const { return m_inherited.accent_color; }
CSS::AlignContent align_content() const { return m_noninherited.align_content; }
CSS::AlignItems align_items() const { return m_noninherited.align_items; }
CSS::AlignSelf align_self() const { return m_noninherited.align_self; }
@ -244,6 +245,7 @@ protected:
int font_weight { InitialValues::font_weight() };
CSS::FontVariant font_variant { InitialValues::font_variant() };
Color color { InitialValues::color() };
Optional<Color> accent_color {};
CSS::Cursor cursor { InitialValues::cursor() };
CSS::ImageRendering image_rendering { InitialValues::image_rendering() };
CSS::PointerEvents pointer_events { InitialValues::pointer_events() };
@ -382,6 +384,7 @@ public:
void set_flex_grow(float value) { m_noninherited.flex_grow = value; }
void set_flex_shrink(float value) { m_noninherited.flex_shrink = value; }
void set_order(int value) { m_noninherited.order = value; }
void set_accent_color(Color value) { m_inherited.accent_color = value; }
void set_align_content(CSS::AlignContent value) { m_noninherited.align_content = value; }
void set_align_items(CSS::AlignItems value) { m_noninherited.align_items = value; }
void set_align_self(CSS::AlignSelf value) { m_noninherited.align_self = value; }

View File

@ -1,4 +1,14 @@
{
"accent-color": {
"inherited": true,
"initial": "auto",
"valid-types": [
"color"
],
"valid-identifiers": [
"auto"
]
},
"align-content": {
"inherited": false,
"initial": "stretch",

View File

@ -375,6 +375,14 @@ CSS::TransformOrigin StyleProperties::transform_origin() const
return { x_value.value(), y_value.value() };
}
Optional<Color> StyleProperties::accent_color(Layout::NodeWithStyle const& node) const
{
auto value = property(CSS::PropertyID::AccentColor);
if (value->has_color())
return value->to_color(node);
return {};
}
Optional<CSS::AlignContent> StyleProperties::align_content() const
{
auto value = property(CSS::PropertyID::AlignContent);

View File

@ -68,6 +68,7 @@ public:
float flex_grow() const;
float flex_shrink() const;
int order() const;
Optional<Color> accent_color(Layout::NodeWithStyle const&) const;
Optional<CSS::AlignContent> align_content() const;
Optional<CSS::AlignItems> align_items() const;
Optional<CSS::AlignSelf> align_self() const;

View File

@ -462,6 +462,10 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
if (justify_content.has_value())
computed_values.set_justify_content(justify_content.value());
auto accent_color = computed_style.accent_color(*this);
if (accent_color.has_value())
computed_values.set_accent_color(accent_color.value());
auto align_content = computed_style.align_content();
if (align_content.has_value())
computed_values.set_align_content(align_content.value());