LibWeb/SVG: Use adjust_computed_style() to change <symbol> display

...Instead of misusing the presentational hint mechanism.
This commit is contained in:
Sam Atkins 2025-11-13 12:52:46 +00:00
parent 88e19ebc11
commit d61791e6e8
Notes: github-actions[bot] 2025-11-14 09:56:54 +00:00
2 changed files with 3 additions and 20 deletions

View file

@ -39,27 +39,11 @@ void SVGSymbolElement::visit_edges(Cell::Visitor& visitor)
SVGFitToViewBox::visit_edges(visitor);
}
bool SVGSymbolElement::is_presentational_hint(FlyString const& name) const
void SVGSymbolElement::adjust_computed_style(CSS::ComputedProperties& computed_properties)
{
if (Base::is_presentational_hint(name))
return true;
// FIXME: This is not a correct use of the presentational hint mechanism.
if (is_direct_child_of_use_shadow_tree())
return true;
return false;
}
// https://svgwg.org/svg2-draft/struct.html#SymbolNotes
void SVGSymbolElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperties> cascaded_properties) const
{
Base::apply_presentational_hints(cascaded_properties);
// FIXME: This is not a correct use of the presentational hint mechanism.
if (is_direct_child_of_use_shadow_tree()) {
// The generated instance of a symbol that is the direct referenced element of a use element must always have a computed value of inline for the display property.
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Inline)));
computed_properties.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Inline)));
}
}

View file

@ -19,8 +19,7 @@ class SVGSymbolElement final : public SVGGraphicsElement
public:
virtual ~SVGSymbolElement() override = default;
virtual bool is_presentational_hint(FlyString const&) const override;
virtual void apply_presentational_hints(GC::Ref<CSS::CascadedProperties>) const override;
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
private:
virtual bool is_svg_symbol_element() const final { return true; }