mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:38:10 +00:00
LibWeb: Parse and apply fill-opacity
attribute to SVG paths
This is needed to fix the rendering of the Street View directional controls (which have paths with various levels of opacity set by this attribute).
This commit is contained in:
parent
62f087bd56
commit
6482c306f1
2 changed files with 16 additions and 1 deletions
|
@ -26,6 +26,14 @@ JS::ThrowCompletionOr<void> SVGGraphicsElement::initialize(JS::Realm& realm)
|
|||
return {};
|
||||
}
|
||||
|
||||
void SVGGraphicsElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value)
|
||||
{
|
||||
SVGElement::parse_attribute(name, value);
|
||||
if (name == "fill-opacity"sv) {
|
||||
m_fill_opacity = AttributeParser::parse_length(value);
|
||||
}
|
||||
}
|
||||
|
||||
void SVGGraphicsElement::apply_presentational_hints(CSS::StyleProperties& style) const
|
||||
{
|
||||
CSS::Parser::ParsingContext parsing_context { document() };
|
||||
|
@ -54,7 +62,9 @@ Optional<Gfx::Color> SVGGraphicsElement::fill_color() const
|
|||
return {};
|
||||
// FIXME: In the working-draft spec, `fill` is intended to be a shorthand, with `fill-color`
|
||||
// being what we actually want to use. But that's not final or widely supported yet.
|
||||
return layout_node()->computed_values().fill();
|
||||
return layout_node()->computed_values().fill().map([&](Gfx::Color color) {
|
||||
return color.with_alpha(m_fill_opacity.value_or(1) * 255);
|
||||
});
|
||||
}
|
||||
|
||||
Optional<Gfx::Color> SVGGraphicsElement::stroke_color() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue