LibWeb: Make layout code aware that we create BFC for foreignObject

We were already always doing this, but through an unusual mechanism:
SVG layout creates a BFC on the stack when laying out foreignObject
subtrees.

This change makes the rest of the layout system aware of this, and
also allows it to be reflected in layout dumps.
This commit is contained in:
Andreas Kling 2025-07-06 15:02:51 +02:00 committed by Andreas Kling
commit 07838016c8
Notes: github-actions[bot] 2025-07-09 12:38:13 +00:00
2 changed files with 5 additions and 1 deletions

View file

@ -37,6 +37,10 @@ bool FormattingContext::creates_block_formatting_context(Box const& box)
if (box.is_replaced_box()) if (box.is_replaced_box())
return false; return false;
// AD-HOC: We create a BFC for SVG foreignObject.
if (box.is_svg_foreign_object_box())
return true;
// display: table // display: table
if (box.display().is_table_inside()) { if (box.display().is_table_inside()) {
return false; return false;

View file

@ -3,7 +3,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <body> at (8,8) content-size 784x100 children: inline BlockContainer <body> at (8,8) content-size 784x100 children: inline
frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 100x100] baseline: 100 frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 100x100] baseline: 100
SVGSVGBox <svg> at (8,8) content-size 100x100 [SVG] children: inline SVGSVGBox <svg> at (8,8) content-size 100x100 [SVG] children: inline
SVGForeignObjectBox <foreignObject> at (8,8) content-size 100x100 children: not-inline SVGForeignObjectBox <foreignObject> at (8,8) content-size 100x100 [BFC] children: not-inline
BlockContainer <div> at (8,8) content-size 100x18 children: inline BlockContainer <div> at (8,8) content-size 100x18 children: inline
frag 0 from TextNode start: 0, length: 3, rect: [8,8 27.15625x18] baseline: 13.796875 frag 0 from TextNode start: 0, length: 3, rect: [8,8 27.15625x18] baseline: 13.796875
"foo" "foo"