From 15e3b0ebde0faf9d3a3275432c6abe4f8ed21a64 Mon Sep 17 00:00:00 2001 From: MacDue Date: Sun, 10 Mar 2024 14:41:00 +0100 Subject: [PATCH] LibWeb: Use SVGGraphicsBox for `` and `` elements This allows various SVG properties (like masking) to be applied to these elements. --- .../flex/svg-flex-item-with-percentage-max-size.txt | 10 +++++----- .../Layout/expected/svg/svg-symbol-with-viewbox.txt | 8 ++++---- .../Layout/expected/svg/use-honor-outer-viewBox.txt | 4 ++-- Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp | 4 ++-- Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp | 3 ++- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Tests/LibWeb/Layout/expected/flex/svg-flex-item-with-percentage-max-size.txt b/Tests/LibWeb/Layout/expected/flex/svg-flex-item-with-percentage-max-size.txt index ddfeec9e39..f01ad35975 100644 --- a/Tests/LibWeb/Layout/expected/flex/svg-flex-item-with-percentage-max-size.txt +++ b/Tests/LibWeb/Layout/expected/flex/svg-flex-item-with-percentage-max-size.txt @@ -2,9 +2,9 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline BlockContainer at (0,0) content-size 800x116 [BFC] children: not-inline Box at (8,8) content-size 784x100 flex-container(row) [FFC] children: not-inline Box
at (8,8) content-size 100x100 flex-container(row) flex-item [FFC] children: not-inline - SVGSVGBox at (8,8) content-size 100x100 flex-item [SVG] children: inline - Box at (8,8) content-size 100x100 children: inline - Box at (8,8) content-size 100x100 [BFC] children: not-inline + SVGSVGBox at (8,8) content-size 100x100 flex-item [SVG] children: not-inline + SVGGraphicsBox at (8,8) content-size 100x100 children: not-inline + SVGGraphicsBox at (8,8) content-size 100x100 [BFC] children: not-inline SVGGeometryBox 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) [8,8 784x100] PaintableBox (Box
) [8,8 100x100] SVGSVGPaintable (SVGSVGBox.c-ico) [8,8 100x100] - PaintableBox (Box) [8,8 100x100] - PaintableBox (Box#icon-cart) [8,8 100x100] + SVGGraphicsPaintable (SVGGraphicsBox) [8,8 100x100] + SVGGraphicsPaintable (SVGGraphicsBox#icon-cart) [8,8 100x100] SVGPathPaintable (SVGGeometryBox) [8,8 100x100] diff --git a/Tests/LibWeb/Layout/expected/svg/svg-symbol-with-viewbox.txt b/Tests/LibWeb/Layout/expected/svg/svg-symbol-with-viewbox.txt index b4ad41f15f..b97eda9569 100644 --- a/Tests/LibWeb/Layout/expected/svg/svg-symbol-with-viewbox.txt +++ b/Tests/LibWeb/Layout/expected/svg/svg-symbol-with-viewbox.txt @@ -9,8 +9,8 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline TextNode <#text> SVGSVGBox at (8,8) content-size 300x150 [SVG] children: inline TextNode <#text> - Box at (8,8) content-size 300x150 children: inline - Box at (92.375,26.75) content-size 131.25x112.15625 [BFC] children: inline + SVGGraphicsBox at (92.375,26.75) content-size 131.25x112.15625 children: not-inline + SVGGraphicsBox at (92.375,26.75) content-size 131.25x112.15625 [BFC] children: inline TextNode <#text> SVGGeometryBox 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
) [8,8 784x150] SVGSVGPaintable (SVGSVGBox) [8,8 300x150] - PaintableBox (Box) [8,8 300x150] - PaintableBox (Box#braces) [92.375,26.75 131.25x112.15625] + SVGGraphicsPaintable (SVGGraphicsBox) [92.375,26.75 131.25x112.15625] + SVGGraphicsPaintable (SVGGraphicsBox#braces) [92.375,26.75 131.25x112.15625] SVGPathPaintable (SVGGeometryBox) [92.375,26.75 131.25x112.15625] diff --git a/Tests/LibWeb/Layout/expected/svg/use-honor-outer-viewBox.txt b/Tests/LibWeb/Layout/expected/svg/use-honor-outer-viewBox.txt index b7d1fea940..7f3143fdd3 100644 --- a/Tests/LibWeb/Layout/expected/svg/use-honor-outer-viewBox.txt +++ b/Tests/LibWeb/Layout/expected/svg/use-honor-outer-viewBox.txt @@ -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 at (9,9) content-size 100x100 [SVG] children: inline TextNode <#text> - Box at (9,9) content-size 100x100 children: inline + SVGGraphicsBox at (9,9) content-size 50x50 children: inline SVGSVGBox at (9,9) content-size 100x100 [SVG] children: inline TextNode <#text> SVGGeometryBox at (9,9) content-size 50x50 children: inline @@ -16,6 +16,6 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600] PaintableWithLines (BlockContainer) [0,0 800x118] PaintableWithLines (BlockContainer) [8,8 784x102] SVGSVGPaintable (SVGSVGBox#outer) [8,8 102x102] - PaintableBox (Box) [9,9 100x100] + SVGGraphicsPaintable (SVGGraphicsBox) [9,9 50x50] SVGSVGPaintable (SVGSVGBox#whee) [9,9 100x100] SVGPathPaintable (SVGGeometryBox) [9,9 50x50] diff --git a/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp index f9c5ae9c1a..d21da704b7 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -61,7 +61,7 @@ bool SVGSymbolElement::is_direct_child_of_use_shadow_tree() const JS::GCPtr SVGSymbolElement::create_layout_node(NonnullRefPtr style) { - return heap().allocate_without_realm(document(), this, move(style)); + return heap().allocate_without_realm(document(), *this, move(style)); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp index e52f82c068..9aa31151f6 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -186,7 +187,7 @@ JS::GCPtr SVGUseElement::animated_instance_root() const JS::GCPtr SVGUseElement::create_layout_node(NonnullRefPtr style) { - return heap().allocate_without_realm(document(), this, move(style)); + return heap().allocate_without_realm(document(), *this, move(style)); } }