mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:18:12 +00:00
LibWeb: Implement SVG fill-rule
attribute
Previously, we did an evenodd fill for everything which while for most SVGs works, it is not correct default (it should be nonzero), and broke some SVGs. This fixes a few of the icons on https://shopify.com/.
This commit is contained in:
parent
ead56e88db
commit
377ff0ac26
13 changed files with 74 additions and 3 deletions
|
@ -129,6 +129,9 @@ void SVGGraphicsElement::apply_presentational_hints(CSS::StyleProperties& style)
|
|||
} else if (name.equals_ignoring_ascii_case("stroke-width"sv)) {
|
||||
if (auto stroke_width_value = parse_css_value(parsing_context, value, CSS::PropertyID::StrokeWidth).release_value_but_fixme_should_propagate_errors())
|
||||
style.set_property(CSS::PropertyID::StrokeWidth, stroke_width_value.release_nonnull());
|
||||
} else if (name.equals_ignoring_ascii_case("fill-rule"sv)) {
|
||||
if (auto fill_rule_value = parse_css_value(parsing_context, value, CSS::PropertyID::FillRule).release_value_but_fixme_should_propagate_errors())
|
||||
style.set_property(CSS::PropertyID::FillRule, fill_rule_value.release_nonnull());
|
||||
} else if (name.equals_ignoring_ascii_case("fill-opacity"sv)) {
|
||||
if (auto fill_opacity_value = parse_css_value(parsing_context, value, CSS::PropertyID::FillOpacity).release_value_but_fixme_should_propagate_errors())
|
||||
style.set_property(CSS::PropertyID::FillOpacity, fill_opacity_value.release_nonnull());
|
||||
|
@ -139,6 +142,20 @@ void SVGGraphicsElement::apply_presentational_hints(CSS::StyleProperties& style)
|
|||
});
|
||||
}
|
||||
|
||||
Optional<FillRule> SVGGraphicsElement::fill_rule() const
|
||||
{
|
||||
if (!layout_node())
|
||||
return {};
|
||||
switch (layout_node()->computed_values().fill_rule()) {
|
||||
case CSS::FillRule::Nonzero:
|
||||
return FillRule::Nonzero;
|
||||
case CSS::FillRule::Evenodd:
|
||||
return FillRule::Evenodd;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
Optional<Gfx::Color> SVGGraphicsElement::fill_color() const
|
||||
{
|
||||
if (!layout_node())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue