1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 07:28:11 +00:00

LibWeb: Add for CSS fill/stroke/stroke-color properties for SVG

In the spec, `fill` and `stroke` are supposed to be a shorthands for
various properties. But since the spec is still a working draft, and
neither Firefox or Chrome support the `fill-color` or `stroke-color`
properties, we'll stick with `fill` and `stroke` as simple colors for
now.

Also, note that SVG expects things in "user units", and we are assuming
that 1px = 1 user unit for now.
This commit is contained in:
Sam Atkins 2021-09-16 12:28:14 +01:00 committed by Andreas Kling
parent 2c8c56684b
commit 3964b81d2b
5 changed files with 75 additions and 5 deletions

View file

@ -104,6 +104,10 @@ public:
CSS::ListStyleType list_style_type() const { return m_inherited.list_style_type; }
Optional<Color> fill() const { return m_inherited.fill; }
Optional<Color> stroke() const { return m_inherited.stroke; }
Optional<Length> stroke_width() const { return m_inherited.stroke_width; }
ComputedValues clone_inherited_values() const
{
ComputedValues clone;
@ -119,6 +123,10 @@ protected:
CSS::TextTransform text_transform { InitialValues::text_transform() };
CSS::WhiteSpace white_space { InitialValues::white_space() };
CSS::ListStyleType list_style_type { InitialValues::list_style_type() };
Optional<Color> fill;
Optional<Color> stroke;
Optional<Length> stroke_width;
} m_inherited;
struct {
@ -210,6 +218,10 @@ public:
void set_opacity(Optional<float> value) { m_noninherited.opacity = value; }
void set_justify_content(CSS::JustifyContent value) { m_noninherited.justify_content = value; }
void set_box_shadow(Optional<BoxShadowData> value) { m_noninherited.box_shadow = move(value); }
void set_fill(Color value) { m_inherited.fill = value; }
void set_stroke(Color value) { m_inherited.stroke = value; }
void set_stroke_width(Length value) { m_inherited.stroke_width = value; }
};
}