mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 22:24:08 +03:00
LibWeb: Parse and plumb the accent-color
CSS property
This commit is contained in:
parent
d005b1ad1b
commit
87b8a36e56
Notes:
sideshowbarker
2024-07-18 02:13:10 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/87b8a36e56 Pull-request: https://github.com/SerenityOS/serenity/pull/17933 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/gmta Reviewed-by: https://github.com/srikavin
@ -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; }
|
||||
|
@ -1,4 +1,14 @@
|
||||
{
|
||||
"accent-color": {
|
||||
"inherited": true,
|
||||
"initial": "auto",
|
||||
"valid-types": [
|
||||
"color"
|
||||
],
|
||||
"valid-identifiers": [
|
||||
"auto"
|
||||
]
|
||||
},
|
||||
"align-content": {
|
||||
"inherited": false,
|
||||
"initial": "stretch",
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user