mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Plumbing for svg stroke-dasharray
This commit is contained in:
parent
c0e90a2a68
commit
94b97aa365
Notes:
github-actions[bot]
2024-11-21 17:57:47 +00:00
Author: https://github.com/nico
Commit: 94b97aa365
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2472
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/gmta
10 changed files with 277 additions and 172 deletions
|
@ -855,6 +855,24 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
|
||||
computed_values.set_fill_opacity(computed_style.fill_opacity());
|
||||
|
||||
if (auto const& stroke_dasharray_or_none = computed_style.property(CSS::PropertyID::StrokeDasharray); !stroke_dasharray_or_none.is_keyword()) {
|
||||
auto const& stroke_dasharray = stroke_dasharray_or_none.as_value_list();
|
||||
Vector<Variant<CSS::LengthPercentage, CSS::NumberOrCalculated>> dashes;
|
||||
|
||||
for (auto const& value : stroke_dasharray.values()) {
|
||||
if (value->is_length())
|
||||
dashes.append(CSS::LengthPercentage { value->as_length().length() });
|
||||
else if (value->is_percentage())
|
||||
dashes.append(CSS::LengthPercentage { value->as_percentage().percentage() });
|
||||
else if (value->is_math())
|
||||
dashes.append(CSS::LengthPercentage { value->as_math() });
|
||||
else if (value->is_number())
|
||||
dashes.append(CSS::NumberOrCalculated { value->as_number().number() });
|
||||
}
|
||||
|
||||
computed_values.set_stroke_dasharray(move(dashes));
|
||||
}
|
||||
|
||||
auto const& stroke_dashoffset = computed_style.property(CSS::PropertyID::StrokeDashoffset);
|
||||
// FIXME: Converting to pixels isn't really correct - values should be in "user units"
|
||||
// https://svgwg.org/svg2-draft/coords.html#TermUserUnits
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue