1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

LibWeb/SVG: Support url() in the stroke attribute

This allows you to draw gradients in strokes, for example.
This commit is contained in:
Luke Wilde 2023-06-06 20:40:10 +01:00 committed by Andreas Kling
parent 8993a710f8
commit 42a183720b
8 changed files with 51 additions and 12 deletions

View file

@ -681,9 +681,11 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
computed_values.set_fill(fill->to_color(*this));
else if (fill->is_url())
computed_values.set_fill(fill->as_url().url());
// TODO: Allow url()s for strokes
if (auto stroke = computed_style.property(CSS::PropertyID::Stroke); stroke->has_color())
auto stroke = computed_style.property(CSS::PropertyID::Stroke);
if (stroke->has_color())
computed_values.set_stroke(stroke->to_color(*this));
else if (stroke->is_url())
computed_values.set_stroke(stroke->as_url().url());
if (auto stop_color = computed_style.property(CSS::PropertyID::StopColor); stop_color->has_color())
computed_values.set_stop_color(stop_color->to_color(*this));
auto stroke_width = computed_style.property(CSS::PropertyID::StrokeWidth);