mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +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:
parent
2c8c56684b
commit
3964b81d2b
5 changed files with 75 additions and 5 deletions
|
@ -360,6 +360,19 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
|||
do_border_style(computed_values.border_top(), CSS::PropertyID::BorderTopWidth, CSS::PropertyID::BorderTopColor, CSS::PropertyID::BorderTopStyle);
|
||||
do_border_style(computed_values.border_right(), CSS::PropertyID::BorderRightWidth, CSS::PropertyID::BorderRightColor, CSS::PropertyID::BorderRightStyle);
|
||||
do_border_style(computed_values.border_bottom(), CSS::PropertyID::BorderBottomWidth, CSS::PropertyID::BorderBottomColor, CSS::PropertyID::BorderBottomStyle);
|
||||
|
||||
if (auto fill = specified_style.property(CSS::PropertyID::Fill); fill.has_value())
|
||||
computed_values.set_fill(fill.value()->to_color(document()));
|
||||
if (auto stroke = specified_style.property(CSS::PropertyID::Stroke); stroke.has_value())
|
||||
computed_values.set_stroke(stroke.value()->to_color(document()));
|
||||
if (auto stroke_width = specified_style.property(CSS::PropertyID::StrokeWidth); stroke_width.has_value()) {
|
||||
// FIXME: Converting to pixels isn't really correct - values should be in "user units"
|
||||
// https://svgwg.org/svg2-draft/coords.html#TermUserUnits
|
||||
if (stroke_width.value()->is_numeric())
|
||||
computed_values.set_stroke_width(CSS::Length::make_px(static_cast<CSS::NumericStyleValue const&>(*stroke_width.value()).value()));
|
||||
else
|
||||
computed_values.set_stroke_width(stroke_width.value()->to_length());
|
||||
}
|
||||
}
|
||||
|
||||
void Node::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned, unsigned)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue