diff --git a/Libraries/LibWeb/Layout/SVGFormattingContext.cpp b/Libraries/LibWeb/Layout/SVGFormattingContext.cpp index 40ae393ce50..bc17ba48410 100644 --- a/Libraries/LibWeb/Layout/SVGFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/SVGFormattingContext.cpp @@ -295,10 +295,11 @@ void SVGFormattingContext::layout_svg_element(Box const& child) child_state.set_content_offset(transformed_rect.location()); child_state.set_content_width(transformed_rect.width()); child_state.set_content_height(transformed_rect.height()); - child.for_each_child_of_type([&](SVGMaskBox const& child) { - layout_svg_element(child); - return IterationDecision::Continue; - }); + if (auto* mask_box = child.first_child_of_type()) + layout_mask_or_clip(*mask_box); + + if (auto* clip_box = child.first_child_of_type()) + layout_mask_or_clip(*clip_box); } else if (is(child)) { layout_graphics_element(static_cast(child)); } diff --git a/Tests/LibWeb/Layout/expected/svg/foreignObject-and-mask-with-different-viewbox.txt b/Tests/LibWeb/Layout/expected/svg/foreignObject-and-mask-with-different-viewbox.txt new file mode 100644 index 00000000000..4fcf077dbda --- /dev/null +++ b/Tests/LibWeb/Layout/expected/svg/foreignObject-and-mask-with-different-viewbox.txt @@ -0,0 +1,22 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x116 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x100 children: inline + frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 100x100] baseline: 100 + SVGSVGBox at (8,8) content-size 800x800 positioned [SVG] children: not-inline + SVGSVGBox at (8,8) content-size 100x100 [SVG] children: not-inline + SVGForeignObjectBox at (8,8) content-size 40x40 [BFC] children: not-inline + BlockContainer at (8,8) content-size 100x100 children: not-inline + SVGMaskBox at (8,8) content-size 40x40 children: not-inline + SVGGeometryBox at (8,8) content-size 40x40 children: not-inline + +ViewportPaintable (Viewport<#document>) [0,0 800x600] overflow: [0,0 808x808] + PaintableWithLines (BlockContainer) [0,0 800x116] + PaintableWithLines (BlockContainer) [8,8 784x100] + SVGSVGPaintable (SVGSVGBox) [8,8 800x800] + SVGSVGPaintable (SVGSVGBox) [8,8 100x100] + SVGForeignObjectPaintable (SVGForeignObjectBox) [8,8 40x40] overflow: [8,8 100x100] + PaintableWithLines (BlockContainer
#lol) [8,8 100x100] + +SC for Viewport<#document> [0,0 800x600] [children: 1] (z-index: auto) + SC for BlockContainer [0,0 800x116] [children: 1] (z-index: auto) + SC for SVGForeignObjectBox [8,8 40x40] [children: 0] (z-index: auto) diff --git a/Tests/LibWeb/Layout/input/svg/foreignObject-and-mask-with-different-viewbox.html b/Tests/LibWeb/Layout/input/svg/foreignObject-and-mask-with-different-viewbox.html new file mode 100644 index 00000000000..f1b387abecd --- /dev/null +++ b/Tests/LibWeb/Layout/input/svg/foreignObject-and-mask-with-different-viewbox.html @@ -0,0 +1,8 @@ +
\ No newline at end of file