LibWeb: Use SVGGraphicsBox for <symbol> and <use> elements

This allows various SVG properties (like masking) to be applied to these
elements.
This commit is contained in:
MacDue 2024-03-10 14:41:00 +01:00 committed by Andreas Kling
parent 05f42efc06
commit 15e3b0ebde
Notes: sideshowbarker 2024-07-17 10:16:43 +09:00
5 changed files with 15 additions and 14 deletions

View file

@ -2,9 +2,9 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x116 [BFC] children: not-inline
Box <body> at (8,8) content-size 784x100 flex-container(row) [FFC] children: not-inline
Box <div> at (8,8) content-size 100x100 flex-container(row) flex-item [FFC] children: not-inline
SVGSVGBox <svg.c-ico> at (8,8) content-size 100x100 flex-item [SVG] children: inline
Box <use> at (8,8) content-size 100x100 children: inline
Box <symbol#icon-cart> at (8,8) content-size 100x100 [BFC] children: not-inline
SVGSVGBox <svg.c-ico> at (8,8) content-size 100x100 flex-item [SVG] children: not-inline
SVGGraphicsBox <use> at (8,8) content-size 100x100 children: not-inline
SVGGraphicsBox <symbol#icon-cart> at (8,8) content-size 100x100 [BFC] children: not-inline
SVGGeometryBox <rect> at (8,8) content-size 100x100 children: not-inline
ViewportPaintable (Viewport<#document>) [0,0 800x600]
@ -12,6 +12,6 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableBox (Box<BODY>) [8,8 784x100]
PaintableBox (Box<DIV>) [8,8 100x100]
SVGSVGPaintable (SVGSVGBox<svg>.c-ico) [8,8 100x100]
PaintableBox (Box<use>) [8,8 100x100]
PaintableBox (Box<symbol>#icon-cart) [8,8 100x100]
SVGGraphicsPaintable (SVGGraphicsBox<use>) [8,8 100x100]
SVGGraphicsPaintable (SVGGraphicsBox<symbol>#icon-cart) [8,8 100x100]
SVGPathPaintable (SVGGeometryBox<rect>) [8,8 100x100]

View file

@ -9,8 +9,8 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
TextNode <#text>
SVGSVGBox <svg> at (8,8) content-size 300x150 [SVG] children: inline
TextNode <#text>
Box <use> at (8,8) content-size 300x150 children: inline
Box <symbol#braces> at (92.375,26.75) content-size 131.25x112.15625 [BFC] children: inline
SVGGraphicsBox <use> at (92.375,26.75) content-size 131.25x112.15625 children: not-inline
SVGGraphicsBox <symbol#braces> at (92.375,26.75) content-size 131.25x112.15625 [BFC] children: inline
TextNode <#text>
SVGGeometryBox <path> at (92.375,26.75) content-size 131.25x112.15625 children: inline
TextNode <#text>
@ -24,6 +24,6 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer(anonymous)) [8,8 784x0]
PaintableWithLines (BlockContainer<DIV>) [8,8 784x150]
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 300x150]
PaintableBox (Box<use>) [8,8 300x150]
PaintableBox (Box<symbol>#braces) [92.375,26.75 131.25x112.15625]
SVGGraphicsPaintable (SVGGraphicsBox<use>) [92.375,26.75 131.25x112.15625]
SVGGraphicsPaintable (SVGGraphicsBox<symbol>#braces) [92.375,26.75 131.25x112.15625]
SVGPathPaintable (SVGGeometryBox<path>) [92.375,26.75 131.25x112.15625]

View file

@ -4,7 +4,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
frag 0 from SVGSVGBox start: 0, length: 0, rect: [9,9 100x100] baseline: 102
SVGSVGBox <svg#outer> at (9,9) content-size 100x100 [SVG] children: inline
TextNode <#text>
Box <use> at (9,9) content-size 100x100 children: inline
SVGGraphicsBox <use> at (9,9) content-size 50x50 children: inline
SVGSVGBox <svg#whee> at (9,9) content-size 100x100 [SVG] children: inline
TextNode <#text>
SVGGeometryBox <rect> at (9,9) content-size 50x50 children: inline
@ -16,6 +16,6 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x118]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x102]
SVGSVGPaintable (SVGSVGBox<svg>#outer) [8,8 102x102]
PaintableBox (Box<use>) [9,9 100x100]
SVGGraphicsPaintable (SVGGraphicsBox<use>) [9,9 50x50]
SVGSVGPaintable (SVGSVGBox<svg>#whee) [9,9 100x100]
SVGPathPaintable (SVGGeometryBox<rect>) [9,9 50x50]

View file

@ -10,7 +10,7 @@
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
#include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/SVGGraphicsBox.h>
#include <LibWeb/SVG/AttributeNames.h>
#include <LibWeb/SVG/SVGSymbolElement.h>
#include <LibWeb/SVG/SVGUseElement.h>
@ -61,7 +61,7 @@ bool SVGSymbolElement::is_direct_child_of_use_shadow_tree() const
JS::GCPtr<Layout::Node> SVGSymbolElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
{
return heap().allocate_without_realm<Layout::Box>(document(), this, move(style));
return heap().allocate_without_realm<Layout::SVGGraphicsBox>(document(), *this, move(style));
}
}

View file

@ -10,6 +10,7 @@
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/SVGGraphicsBox.h>
#include <LibWeb/Namespace.h>
#include <LibWeb/SVG/AttributeNames.h>
#include <LibWeb/SVG/SVGSVGElement.h>
@ -186,7 +187,7 @@ JS::GCPtr<SVGElement> SVGUseElement::animated_instance_root() const
JS::GCPtr<Layout::Node> SVGUseElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
{
return heap().allocate_without_realm<Layout::Box>(document(), this, move(style));
return heap().allocate_without_realm<Layout::SVGGraphicsBox>(document(), *this, move(style));
}
}