LibWeb: Never split <svg> for inline continuations

This fixes an issue where we'd make an absolute mess from nested SVG
roots with display:block. Before this fix, the inner SVG root would
trigger the inline continuation logic and try to split the tree.
This commit is contained in:
Andreas Kling 2025-07-12 13:54:24 +02:00 committed by Jelle Raaijmakers
commit 8e49b69f42
Notes: github-actions[bot] 2025-07-12 12:12:47 +00:00
3 changed files with 25 additions and 6 deletions

View file

@ -1444,12 +1444,8 @@ bool NodeWithStyleAndBoxModelMetrics::should_create_inline_continuation() const
if (is<SVG::SVGForeignObjectElement>(parent()->dom_node()))
return false;
// SVGBoxes are appended directly to their layout parent without changing the parent's (non-)inline behavior.
if (is_svg_box())
return false;
// SVGForeignObjectBoxes should never be split.
if (is_svg_foreign_object_box())
// SVG related boxes should never be split.
if (is_svg_box() || is_svg_svg_box() || is_svg_foreign_object_box())
return false;
return true;

View file

@ -0,0 +1,18 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x66 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x50 children: not-inline
SVGSVGBox <svg#outer> at (8,8) content-size 50x50 [SVG] children: not-inline
SVGGraphicsBox <g> at (8,8) content-size 25x25 children: not-inline
SVGSVGBox <svg#inner> at (8,8) content-size 25x25 [SVG] children: not-inline
SVGGeometryBox <rect> at (8,13) content-size 25x15 children: not-inline
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x66]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x50]
SVGSVGPaintable (SVGSVGBox<svg>#outer) [8,8 50x50]
SVGGraphicsPaintable (SVGGraphicsBox<g>) [8,8 25x25]
SVGSVGPaintable (SVGSVGBox<svg>#inner) [8,8 25x25]
SVGPathPaintable (SVGGeometryBox<rect>) [8,13 25x15]
SC for Viewport<#document> [0,0 800x600] [children: 1] (z-index: auto)
SC for BlockContainer<HTML> [0,0 800x66] [children: 0] (z-index: auto)

View file

@ -0,0 +1,5 @@
<!DOCTYPE html>
<style type="text/css">
* { outline: 1px solid black; }
svg { display: block; }
</style><svg id="outer" width="50" height="50" viewBox="0 0 50 50"><g><svg id="inner" width="25" height="25" viewBox="0 0 25 15"><rect fill="green" width="25" height="15" /></svg></g></svg>