LibWeb: Do not render SVG <symbol> elements unless part of <use>

We were always rendering <symbol> SVG elements, but we should only
render them if they are a child of a <use>'s shadow root. This caused
practically all instances of <symbol> to be drawn at least one time too
many.
This commit is contained in:
Jelle Raaijmakers 2025-11-26 13:04:20 +01:00 committed by Jelle Raaijmakers
parent 632854d870
commit 39ad7833f0
Notes: github-actions[bot] 2025-11-27 06:56:50 +00:00
5 changed files with 36 additions and 7 deletions

View file

@ -62,7 +62,12 @@ bool SVGSymbolElement::is_direct_child_of_use_shadow_tree() const
GC::Ptr<Layout::Node> SVGSymbolElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
{
return heap().allocate<Layout::SVGGraphicsBox>(document(), *this, move(style));
// https://svgwg.org/svg2-draft/render.html#TermNeverRenderedElement
// [..] it also includes a symbol element that is not the instance root of a use-element shadow tree.
if (!is_direct_child_of_use_shadow_tree())
return {};
return heap().allocate<Layout::SVGGraphicsBox>(document(), *this, style);
}
}