mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:17:34 +00:00
LibWeb: Add stop-color as a CSS property
(This is to set the color of a stop for an SVG gradient)
This commit is contained in:
parent
f099ee3d47
commit
297d8eebcd
7 changed files with 86 additions and 2 deletions
|
@ -41,6 +41,7 @@ public:
|
|||
static CSS::TextTransform text_transform() { return CSS::TextTransform::None; }
|
||||
static CSS::Display display() { return CSS::Display { CSS::Display::Outside::Inline, CSS::Display::Inside::Flow }; }
|
||||
static Color color() { return Color::Black; }
|
||||
static Color stop_color() { return Color::Black; }
|
||||
static CSS::BackdropFilter backdrop_filter() { return BackdropFilter::make_none(); }
|
||||
static Color background_color() { return Color::Transparent; }
|
||||
static CSS::ListStyleType list_style_type() { return CSS::ListStyleType::Disc; }
|
||||
|
@ -259,6 +260,7 @@ public:
|
|||
Optional<Color> const& fill() const { return m_inherited.fill; }
|
||||
Optional<Color> const& stroke() const { return m_inherited.stroke; }
|
||||
Optional<LengthPercentage> const& stroke_width() const { return m_inherited.stroke_width; }
|
||||
Color stop_color() const { return m_noninherited.stop_color; }
|
||||
|
||||
Vector<CSS::Transformation> const& transformations() const { return m_noninherited.transformations; }
|
||||
CSS::TransformOrigin const& transform_origin() const { return m_noninherited.transform_origin; }
|
||||
|
@ -359,6 +361,7 @@ protected:
|
|||
CSS::Size row_gap { InitialValues::row_gap() };
|
||||
CSS::BorderCollapse border_collapse { InitialValues::border_collapse() };
|
||||
Vector<Vector<String>> grid_template_areas { InitialValues::grid_template_areas() };
|
||||
Gfx::Color stop_color { InitialValues::stop_color() };
|
||||
} m_noninherited;
|
||||
};
|
||||
|
||||
|
@ -446,6 +449,7 @@ public:
|
|||
void set_fill(Color value) { m_inherited.fill = value; }
|
||||
void set_stroke(Color value) { m_inherited.stroke = value; }
|
||||
void set_stroke_width(LengthPercentage value) { m_inherited.stroke_width = value; }
|
||||
void set_stop_color(Color value) { m_noninherited.stop_color = value; }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1411,6 +1411,14 @@
|
|||
"none"
|
||||
]
|
||||
},
|
||||
"stop-color": {
|
||||
"affects-layout": false,
|
||||
"inherited": false,
|
||||
"initial": "black",
|
||||
"valid-types": [
|
||||
"color"
|
||||
]
|
||||
},
|
||||
"stroke-width": {
|
||||
"affects-layout": false,
|
||||
"inherited": true,
|
||||
|
|
|
@ -818,4 +818,15 @@ String StyleProperties::grid_area() const
|
|||
return value->as_string().to_string().release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Color StyleProperties::stop_color() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::StopColor);
|
||||
if (value->has_color()) {
|
||||
// FIXME: This is used by the SVGStopElement, which does not participate in layout,
|
||||
// so can't pass a layout node (so can't resolve some colors, e.g. palette ones or currentColor)
|
||||
return value->to_color({});
|
||||
}
|
||||
return Color::Black;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -98,6 +98,8 @@ public:
|
|||
Vector<CSS::Transformation> transformations() const;
|
||||
CSS::TransformOrigin transform_origin() const;
|
||||
|
||||
Color stop_color() const;
|
||||
|
||||
Gfx::Font const& computed_font() const
|
||||
{
|
||||
VERIFY(m_font);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue