Skip to content

Truly independent web browser

Tests/LibWeb: Add layout tree tests for incremental builds

Andreas Klingd9086e44efe1
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/block-generated-image-in-inline.txt b/Tests/LibWeb/Layout/expected/tree-builder/block-generated-image-in-inline.txt
new file mode 100644
index 00000000000..77c8ac24e90
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/block-generated-image-in-inline.txt
@@ -0,0 +1,41 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 414 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 398 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 136 0+0+0] children: not-inline
+ ImageBox <(anonymous)> at [8,8] [0+0+0 120 0+0+664] [0+0+0 120 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,128] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span.block-image> at [8,128] [0+0+0 94.421875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 12, rect: [8,128 94.421875x16] baseline: 13
+ "single image"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,144] [0+0+0 784 0+0+0] [0+0+0 123 0+0+0] children: inline
+ InlineNode <span.image-list> at [8,251] [0+0+0 334.203125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 10, rect: [266.8125,251 75.390625x16] baseline: 13
+ "image list"
+ InlineNode <(anonymous)> at [8,251] [0+0+0 258.8125 0+0+0] [0+0+0 120 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,251 9.34375x16] baseline: 13
+ "a"
+ frag 1 from ImageBox start: 0, length: 0, rect: [17.34375,144 120x120] baseline: 120
+ frag 2 from GeneratedTextNode start: 0, length: 1, rect: [137.34375,251 9.46875x16] baseline: 13
+ "b"
+ frag 3 from ImageBox start: 0, length: 0, rect: [146.8125,144 120x120] baseline: 120
+ GeneratedTextNode <(anonymous)> (not painted)
+ ImageBox <(anonymous)> at [17.34375,144] [0+0+0 120 0+0+0] [0+0+0 120 0+0+0] children: not-inline
+ GeneratedTextNode <(anonymous)> (not painted)
+ ImageBox <(anonymous)> at [146.8125,144] [0+0+0 120 0+0+0] [0+0+0 120 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,267] [0+0+0 784 0+0+0] [0+0+0 139 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,267] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span.block-image-list> at [8,267] [0+0+0 124.0625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 16, rect: [8,267 124.0625x16] baseline: 13
+ "block image list"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,283] [0+0+0 784 0+0+0] [0+0+0 123 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,390 8.890625x16] baseline: 13
+ "c"
+ frag 1 from ImageBox start: 0, length: 0, rect: [16.890625,283 120x120] baseline: 120
+ GeneratedTextNode <(anonymous)> (not painted)
+ ImageBox <(anonymous)> at [16.890625,283] [0+0+0 120 0+0+0] [0+0+0 120 0+0+0] children: not-inline
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x414] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/block-pseudo-escapes-nested-inlines.txt b/Tests/LibWeb/Layout/expected/tree-builder/block-pseudo-escapes-nested-inlines.txt
new file mode 100644
index 00000000000..2409bfb43d3
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/block-pseudo-escapes-nested-inlines.txt
@@ -0,0 +1,92 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 208 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 192 0+0+8] children: not-inline
+ BlockContainer <div#before-at-start> at [8,8] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [8,8 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [33.46875,24 33x16] baseline: 13
+ " tail"
+ InlineNode <span> at [8,24] [0+0+0 25.46875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [24.75,24 8.71875x16] baseline: 13
+ "e"
+ InlineNode <b> at [8,24] [0+0+0 16.75 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [16.890625,24 7.859375x16] baseline: 13
+ "d"
+ InlineNode <i.before> at [8,24] [0+0+0 8.890625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,24 8.890625x16] baseline: 13
+ "c"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div#after-at-end> at [8,40] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,40 43.21875x16] baseline: 13
+ "head "
+ TextNode <#text> (not painted)
+ InlineNode <span> at [51.21875,40] [0+0+0 27.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [51.21875,40 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ InlineNode <b.after> at [60.5625,40] [0+0+0 18.359375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [60.5625,40 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ InlineNode <i> at [70.03125,40] [0+0+0 8.890625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [70.03125,40 8.890625x16] baseline: 13
+ "c"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [8,56 40.1875x16] baseline: 13
+ "after"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <div#before-and-after> at [8,72] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [8,72 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,88] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span.before.after> at [8,88] [0+0+0 32.140625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [8,88 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,104] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [8,104 40.1875x16] baseline: 13
+ "after"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <div#list-item-pseudo> at [8,120] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ ListItemBox <(anonymous)> at [8,120] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 9, rect: [8,120 65.34375x16] baseline: 13
+ "list item"
+ ListItemMarkerBox <(anonymous)> at [-6,120] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [-6,120 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,136] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span.list-item> at [8,136] [0+0+0 32.140625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [8,136 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ BlockContainer <div#flex-pseudo> at [8,152] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,152] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span.flex> at [8,152] [0+0+0 32.140625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [8,152 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ Box <(anonymous)> at [8,168] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,168] flex-item [0+0+0 29.09375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 4, rect: [8,168 29.09375x16] baseline: 13
+ "flex"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,184] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 1, length: 4, rect: [8,184 25x16] baseline: 13
+ "tail"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x208] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/block-pseudo-in-inline-keeps-its-place.txt b/Tests/LibWeb/Layout/expected/tree-builder/block-pseudo-in-inline-keeps-its-place.txt
new file mode 100644
index 00000000000..525e0226f29
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/block-pseudo-in-inline-keeps-its-place.txt
@@ -0,0 +1,40 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 80 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 64 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [8,8 70.78125x16] baseline: 13
+ "BEFORE"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [8,24] [0+0+0 27.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,24 9.34375x16] baseline: 13
+ "a"
+ frag 1 from TextNode start: 0, length: 1, rect: [26.8125,24 8.890625x16] baseline: 13
+ "c"
+ TextNode <#text> (not painted)
+ InlineNode <b.before> at [17.34375,24] [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,24 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,40] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [8,40] [0+0+0 27.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,40 9.34375x16] baseline: 13
+ "a"
+ frag 1 from TextNode start: 0, length: 1, rect: [26.8125,40 8.890625x16] baseline: 13
+ "c"
+ TextNode <#text> (not painted)
+ InlineNode <b.after> at [17.34375,40] [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,40 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [8,56 64.65625x16] baseline: 13
+ "AFTER"
+ GeneratedTextNode <(anonymous)> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x80] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/button-display-flex-and-grid.txt b/Tests/LibWeb/Layout/expected/tree-builder/button-display-flex-and-grid.txt
new file mode 100644
index 00000000000..d9deef0de8f
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/button-display-flex-and-grid.txt
@@ -0,0 +1,38 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 110 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 94 0+0+8] children: not-inline
+ Box <button> at [17,11] flex-container(row) [0+2+7 55.640625 7+2+710.359375] [0+2+1 14 1+2+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,11] flex-item [0+0+0 24.234375 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [17,11 24.234375x14] baseline: 11
+ "flex"
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [41.234375,11] flex-item [0+0+0 31.40625 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [41.234375,11 31.40625x14] baseline: 11
+ "span"
+ TextNode <#text> (not painted)
+ Box <button> at [17,31] [0+2+7 31.40625 7+2+734.59375] [0+2+1 28 1+2+0] [GFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,31] [0+0+0 31.40625 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [20.703125,31 24x14] baseline: 11
+ "grid"
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [17,45] [0+0+0 31.40625 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [17,45 31.40625x14] baseline: 11
+ "span"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,62] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
+ frag 0 from Box start: 0, length: 0, rect: [17,65 64.03125x14] baseline: 14
+ Box <button> at [17,65] flex-container(row) [0+2+7 64.03125 7+2+0] [0+2+1 14 1+2+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,65] flex-item [0+0+0 64.03125 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 11, rect: [17,65 64.03125x14] baseline: 11
+ "inline-flex"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <button> at [17,85] [0+2+7 33.890625 7+2+732.109375] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,85] flex-container(column) [0+0+0 33.890625 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,85] flex-item [0+0+0 33.890625 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [17,85 33.890625x14] baseline: 11
+ "block"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x110] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/button-display-list-item.txt b/Tests/LibWeb/Layout/expected/tree-builder/button-display-list-item.txt
new file mode 100644
index 00000000000..d24dd984b94
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/button-display-list-item.txt
@@ -0,0 +1,18 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 56 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 40 0+0+8] children: not-inline
+ BlockContainer <button> at [17,11] [0+2+7 105.21875 7+2+660.78125] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,11] flex-container(column) [0+0+0 105.21875 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,11] flex-item [0+0+0 105.21875 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 16, rect: [17,11 105.21875x14] baseline: 11
+ "list item button"
+ TextNode <#text> (not painted)
+ BlockContainer <button> at [17,31] [0+2+7 149.078125 7+2+616.921875] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,31] flex-container(column) [0+0+0 149.078125 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,31] flex-item [0+0+0 149.078125 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 23, rect: [17,31 149.078125x14] baseline: 11
+ "inside list item button"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x56] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/canvas-children-not-rendered.txt b/Tests/LibWeb/Layout/expected/tree-builder/canvas-children-not-rendered.txt
new file mode 100644
index 00000000000..b598ba77ef6
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/canvas-children-not-rendered.txt
@@ -0,0 +1,9 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 36 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 20 0+0+8] children: inline
+ frag 0 from CanvasBox start: 0, length: 0, rect: [8,8 20x20] baseline: 20
+ CanvasBox <canvas> at [8,8] [0+0+0 20 0+0+0] [0+0+0 20 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x36] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/children-inline-flag-after-oof-only.txt b/Tests/LibWeb/Layout/expected/tree-builder/children-inline-flag-after-oof-only.txt
new file mode 100644
index 00000000000..54094c50038
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/children-inline-flag-after-oof-only.txt
@@ -0,0 +1,31 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 24 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 0 0+0+8] children: not-inline
+ BlockContainer <div#only-float> at [8,8] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <div> at [8,8] floating [0+0+0 37.234375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,8 37.234375x16] baseline: 13
+ "float"
+ TextNode <#text> (not painted)
+ BlockContainer <div#only-abspos> at [8,8] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <div> at [8,8] positioned [0+0+0 57.28125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,8 57.28125x16] baseline: 13
+ "abspos"
+ TextNode <#text> (not painted)
+ BlockContainer <div#float-and-whitespace> at [8,8] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <div> at [45.234375,8] floating [0+0+0 37.234375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [45.234375,8 37.234375x16] baseline: 13
+ "float"
+ TextNode <#text> (not painted)
+ BlockContainer <div#inline-floats> at [8,8] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <span> at [82.46875,8] floating [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [82.46875,8 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [91.8125,8] floating [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [91.8125,8 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <div#empty> at [8,8] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x24] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/content-alt-text.txt b/Tests/LibWeb/Layout/expected/tree-builder/content-alt-text.txt
new file mode 100644
index 00000000000..bb9714441e1
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/content-alt-text.txt
@@ -0,0 +1,21 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 275 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 259 0+0+8] children: not-inline
+ BlockContainer <div.image-alt> at [8,8] [0+0+0 784 0+0+0] [0+0+0 123 0+0+0] children: inline
+ frag 0 from ImageBox start: 0, length: 0, rect: [8,8 120x120] baseline: 120
+ frag 1 from TextNode start: 0, length: 5, rect: [128,115 42.390625x16] baseline: 13
+ "image"
+ ImageBox <(anonymous)> at [8,8] [0+0+0 120 0+0+0] [0+0+0 120 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+ BlockContainer <div.text-alt> at [8,131] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [17.34375,131 32.140625x16] baseline: 13
+ "text"
+ InlineNode <(anonymous)> at [8,131] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,131 9.34375x16] baseline: 13
+ "a"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ImageBox <div.element-alt> at [8,147] [0+0+0 120 0+0+664] [0+0+0 120 0+0+0] children: not-inline
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x275] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/content-list-mixed-items.txt b/Tests/LibWeb/Layout/expected/tree-builder/content-list-mixed-items.txt
new file mode 100644
index 00000000000..a2bd0d00d6b
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/content-list-mixed-items.txt
@@ -0,0 +1,51 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 310 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 294 0+0+8] children: not-inline
+ BlockContainer <div.inline> at [8,8] [0+0+0 784 0+0+0] [0+0+0 123 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [164.90625,115 41.296875x16] baseline: 13
+ "inline"
+ InlineNode <(anonymous)> at [8,115] [0+0+0 156.90625 0+0+0] [0+0+0 120 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,115 9.34375x16] baseline: 13
+ "a"
+ frag 1 from ImageBox start: 0, length: 0, rect: [17.34375,8 120x120] baseline: 120
+ frag 2 from GeneratedTextNode start: 0, length: 1, rect: [137.34375,115 11.5625x16] baseline: 13
+ "X"
+ frag 3 from GeneratedTextNode start: 0, length: 1, rect: [148.90625,115 8.71875x16] baseline: 13
+ "7"
+ frag 4 from GeneratedTextNode start: 0, length: 1, rect: [157.625,115 7.28125x16] baseline: 13
+ "<"
+ GeneratedTextNode <(anonymous)> (not painted)
+ ImageBox <(anonymous)> at [17.34375,8] [0+0+0 120 0+0+0] [0+0+0 120 0+0+0] children: not-inline
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.block> at [8,131] [0+0+0 784 0+0+0] [0+0+0 139 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,131] [0+0+0 784 0+0+0] [0+0+0 123 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,238 9.34375x16] baseline: 13
+ "a"
+ frag 1 from ImageBox start: 0, length: 0, rect: [17.34375,131 120x120] baseline: 120
+ frag 2 from GeneratedTextNode start: 0, length: 1, rect: [137.34375,238 11.09375x16] baseline: 13
+ "Y"
+ GeneratedTextNode <(anonymous)> (not painted)
+ ImageBox <(anonymous)> at [17.34375,131] [0+0+0 120 0+0+0] [0+0+0 120 0+0+0] children: not-inline
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,254] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,254 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+ BlockContainer <div.empty-only> at [8,270] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,270] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,270] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 10, rect: [8,270 83.75x16] baseline: 13
+ "empty only"
+ TextNode <#text> (not painted)
+ BlockContainer <div.empty-attr> at [8,286] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 10, rect: [8,286 84.265625x16] baseline: 13
+ "empty attr"
+ InlineNode <(anonymous)> at [8,286] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x310] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/content-visibility-hidden-variants.txt b/Tests/LibWeb/Layout/expected/tree-builder/content-visibility-hidden-variants.txt
new file mode 100644
index 00000000000..c091c90769a
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/content-visibility-hidden-variants.txt
@@ -0,0 +1,18 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 50 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 34 0+0+8] children: not-inline
+ BlockContainer <div.cv> at [8,8] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ BlockContainer <ul> at [48,24] [0+0+40 744 0+0+0] [16+0+0 0 0+0+16] children: not-inline
+ ListItemBox <li.cv> at [48,24] [0+0+0 744 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ BlockContainer <div.cv.pseudo> at [8,40] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ TableWrapper <(anonymous)> at [8,40] [0+0+0 2 0+0+782] [0+0+0 2 0+0+0] [BFC] children: not-inline
+ Box <table.cv> at [8,40] table-box [0+0+0 2 0+0+0] [0+0+0 2 0+0+0] [TFC] children: not-inline
+ Box <div.cv> at [8,42] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] [FFC] children: not-inline
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x50] (z-index: auto)
+ SC for BlockContainer<DIV>.cv [8,8 784x0] (z-index: auto)
+ SC for ListItemBox<LI>.cv [48,24 744x0] (z-index: auto)
+ SC for BlockContainer<DIV>.cv.pseudo [8,40 784x0] (z-index: auto)
+ SC for Box<TABLE>.cv [8,40 2x2] (z-index: auto)
+ SC for Box<DIV>.cv [8,42 784x0] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/counter-instantiated-by-use.txt b/Tests/LibWeb/Layout/expected/tree-builder/counter-instantiated-by-use.txt
new file mode 100644
index 00000000000..89d2fb3ea0a
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/counter-instantiated-by-use.txt
@@ -0,0 +1,63 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 176 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 144 0+0+8] children: not-inline
+ BlockContainer <div> at [8,16] [0+0+0 784 0+0+0] [0+0+0 80 0+0+0] children: not-inline
+ BlockContainer <p.use> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 24, rect: [25.59375,16 206.390625x16] baseline: 13
+ "uses x without any reset"
+ InlineNode <(anonymous)> at [8,16] [0+0+0 17.59375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,16 9.59375x16] baseline: 13
+ "0"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [17.59375,16 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.inc> at [8,48] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [22.34375,48 9.34375x16] baseline: 13
+ "a"
+ InlineNode <(anonymous)> at [8,48] [0+0+0 14.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,48 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [14.34375,48 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.inc> at [8,80] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [24.8125,80 9.46875x16] baseline: 13
+ "b"
+ InlineNode <(anonymous)> at [8,80] [0+0+0 16.8125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,80 8.8125x16] baseline: 13
+ "2"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [16.8125,80 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,112] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <p.inc> at [8,112] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [22.34375,112 8.890625x16] baseline: 13
+ "c"
+ InlineNode <(anonymous)> at [8,112] [0+0+0 14.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,112 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [14.34375,112 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.inc> at [8,144] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [24.8125,144 7.859375x16] baseline: 13
+ "d"
+ InlineNode <(anonymous)> at [8,144] [0+0+0 16.8125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,144 8.8125x16] baseline: 13
+ "2"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [16.8125,144 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x176] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/counter-list-item-in-content.txt b/Tests/LibWeb/Layout/expected/tree-builder/counter-list-item-in-content.txt
new file mode 100644
index 00000000000..c608dfb2b68
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/counter-list-item-in-content.txt
@@ -0,0 +1,94 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 112 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 80 0+0+8] children: not-inline
+ BlockContainer <ol> at [48,16] [0+0+40 744 0+0+0] [16+0+0 80 0+0+16] children: not-inline
+ ListItemBox <li> at [48,16] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [92.78125,16 9.34375x16] baseline: 13
+ "a"
+ InlineNode <(anonymous)> at [48,16] [0+0+0 44.78125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [48,16 8.453125x16] baseline: 13
+ "5"
+ frag 1 from GeneratedTextNode start: 0, length: 3, rect: [56.453125,16 19.875x16] baseline: 13
+ " | "
+ frag 2 from GeneratedTextNode start: 0, length: 1, rect: [76.328125,16 8.453125x16] baseline: 13
+ "5"
+ frag 3 from GeneratedTextNode start: 0, length: 1, rect: [84.78125,16 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,32] [0+0+0 744 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [48,32] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [93.34375,32 9.46875x16] baseline: 13
+ "b"
+ InlineNode <(anonymous)> at [48,32] [0+0+0 45.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [48,32 8.734375x16] baseline: 13
+ "6"
+ frag 1 from GeneratedTextNode start: 0, length: 3, rect: [56.734375,32 19.875x16] baseline: 13
+ " | "
+ frag 2 from GeneratedTextNode start: 0, length: 1, rect: [76.609375,32 8.734375x16] baseline: 13
+ "6"
+ frag 3 from GeneratedTextNode start: 0, length: 1, rect: [85.34375,32 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <ol> at [88,48] [0+0+40 704 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ ListItemBox <li> at [88,48] [0+0+0 704 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 2, rect: [141.640625,48 15.8125x16] baseline: 13
+ "b1"
+ InlineNode <(anonymous)> at [88,48] [0+0+0 53.640625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [88,48 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 3, rect: [94.34375,48 19.875x16] baseline: 13
+ " | "
+ frag 2 from GeneratedTextNode start: 0, length: 3, rect: [114.21875,48 19.421875x16] baseline: 13
+ "6.1"
+ frag 3 from GeneratedTextNode start: 0, length: 1, rect: [133.640625,48 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [88,64] [0+0+0 704 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 2, rect: [146.390625,64 18.28125x16] baseline: 13
+ "b2"
+ InlineNode <(anonymous)> at [88,64] [0+0+0 58.390625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [88,64 8.71875x16] baseline: 13
+ "7"
+ frag 1 from GeneratedTextNode start: 0, length: 3, rect: [96.71875,64 19.875x16] baseline: 13
+ " | "
+ frag 2 from GeneratedTextNode start: 0, length: 3, rect: [116.59375,64 21.796875x16] baseline: 13
+ "6.7"
+ frag 3 from GeneratedTextNode start: 0, length: 1, rect: [138.390625,64 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,80] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [93.3125,80 8.890625x16] baseline: 13
+ "c"
+ InlineNode <(anonymous)> at [48,80] [0+0+0 45.3125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [48,80 8.71875x16] baseline: 13
+ "7"
+ frag 1 from GeneratedTextNode start: 0, length: 3, rect: [56.71875,80 19.875x16] baseline: 13
+ " | "
+ frag 2 from GeneratedTextNode start: 0, length: 1, rect: [76.59375,80 8.71875x16] baseline: 13
+ "7"
+ frag 3 from GeneratedTextNode start: 0, length: 1, rect: [85.3125,80 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x112] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/counter-reversed-css.txt b/Tests/LibWeb/Layout/expected/tree-builder/counter-reversed-css.txt
new file mode 100644
index 00000000000..b2f81248a8b
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/counter-reversed-css.txt
@@ -0,0 +1,62 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 80 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 64 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 64 0+0+0] children: not-inline
+ BlockContainer <p> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [24.453125,8 9.34375x16] baseline: 13
+ "a"
+ InlineNode <(anonymous)> at [8,8] [0+0+0 16.453125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,8 8.453125x16] baseline: 13
+ "5"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [16.453125,8 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.two> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [25.09375,24 9.46875x16] baseline: 13
+ "b"
+ InlineNode <(anonymous)> at [8,24] [0+0+0 17.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,24 9.09375x16] baseline: 13
+ "3"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [17.09375,24 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [24.8125,40 8.890625x16] baseline: 13
+ "c"
+ InlineNode <(anonymous)> at [8,40] [0+0+0 16.8125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,40 8.8125x16] baseline: 13
+ "2"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [16.8125,40 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <span> at [33.703125,40] [0+0+0 22.203125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [48.046875,40 7.859375x16] baseline: 13
+ "d"
+ InlineNode <(anonymous)> at [33.703125,40] [0+0+0 14.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [33.703125,40 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [40.046875,40 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [25.59375,56 8.71875x16] baseline: 13
+ "e"
+ InlineNode <(anonymous)> at [8,56] [0+0+0 17.59375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,56 9.59375x16] baseline: 13
+ "0"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [17.59375,56 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x80] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/counter-reversed-ol.txt b/Tests/LibWeb/Layout/expected/tree-builder/counter-reversed-ol.txt
new file mode 100644
index 00000000000..21d0d9d85ba
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/counter-reversed-ol.txt
@@ -0,0 +1,65 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 144 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 112 0+0+8] children: not-inline
+ BlockContainer <ol> at [48,16] [0+0+40 744 0+0+0] [16+0+0 112 0+0+16] children: not-inline
+ ListItemBox <li> at [48,16] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [48,16 9.34375x16] baseline: 13
+ "a"
+ ListItemMarkerBox <(anonymous)> at [27,16] [0+0+0 20.796875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [27,16 20.796875x16] baseline: 13
+ "5. "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,32] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [48,32 9.46875x16] baseline: 13
+ "b"
+ ListItemMarkerBox <(anonymous)> at [28,32] [0+0+0 20.09375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [28,32 20.09375x16] baseline: 13
+ "4. "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,48] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [48,48 8.890625x16] baseline: 13
+ "c"
+ ListItemMarkerBox <(anonymous)> at [27,48] [0+0+0 21.4375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [27,48 21.4375x16] baseline: 13
+ "3. "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,64] [0+0+0 744 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ ListItemMarkerBox <(anonymous)> at [27,64] [0+0+0 21.15625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [27,64 21.15625x16] baseline: 13
+ "2. "
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [48,64] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [48,64 7.859375x16] baseline: 13
+ "d"
+ TextNode <#text> (not painted)
+ BlockContainer <ol> at [88,80] [0+0+40 704 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ ListItemBox <li> at [88,80] [0+0+0 704 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [88,80 9.703125x16] baseline: 13
+ "x"
+ ListItemMarkerBox <(anonymous)> at [67,80] [0+0+0 21.15625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [67,80 21.15625x16] baseline: 13
+ "2. "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [88,96] [0+0+0 704 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [88,96 7.171875x16] baseline: 13
+ "y"
+ ListItemMarkerBox <(anonymous)> at [69,96] [0+0+0 18.6875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [69,96 18.6875x16] baseline: 13
+ "1. "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,112] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [48,112 8.71875x16] baseline: 13
+ "e"
+ ListItemMarkerBox <(anonymous)> at [29,112] [0+0+0 18.6875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [29,112 18.6875x16] baseline: 13
+ "1. "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x144] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/counter-scope-display-contents-siblings.txt b/Tests/LibWeb/Layout/expected/tree-builder/counter-scope-display-contents-siblings.txt
new file mode 100644
index 00000000000..5466180bf0e
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/counter-scope-display-contents-siblings.txt
@@ -0,0 +1,73 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 208 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 176 0+0+8] children: not-inline
+ BlockContainer <div> at [8,16] [0+0+0 784 0+0+0] [0+0+0 176 0+0+0] children: not-inline
+ BlockContainer <p> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [22.34375,16 9.34375x16] baseline: 13
+ "a"
+ InlineNode <(anonymous)> at [8,16] [0+0+0 14.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,16 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [14.34375,16 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,48] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [31.15625,48 9.46875x16] baseline: 13
+ "b"
+ InlineNode <(anonymous)> at [8,48] [0+0+0 23.15625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,48 15.15625x16] baseline: 13
+ "21"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [23.15625,48 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,80] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [33.625,80 8.890625x16] baseline: 13
+ "c"
+ InlineNode <(anonymous)> at [8,80] [0+0+0 25.625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,80 17.625x16] baseline: 13
+ "22"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [25.625,80 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,112] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [33.90625,112 7.859375x16] baseline: 13
+ "d"
+ InlineNode <(anonymous)> at [8,112] [0+0+0 25.90625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,112 17.90625x16] baseline: 13
+ "23"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [25.90625,112 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,144] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [23.75,144 8.71875x16] baseline: 13
+ "e"
+ InlineNode <(anonymous)> at [8,144] [0+0+0 15.75 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,144 7.75x16] baseline: 13
+ "4"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [15.75,144 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,176] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [24.453125,176 6.4375x16] baseline: 13
+ "f"
+ InlineNode <(anonymous)> at [8,176] [0+0+0 16.453125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,176 8.453125x16] baseline: 13
+ "5"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [16.453125,176 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x208] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/counter-scope-previous-sibling.txt b/Tests/LibWeb/Layout/expected/tree-builder/counter-scope-previous-sibling.txt
new file mode 100644
index 00000000000..b53a282a390
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/counter-scope-previous-sibling.txt
@@ -0,0 +1,68 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 112 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 96 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 80 0+0+0] children: not-inline
+ BlockContainer <div.reset> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,8 42.46875x16] baseline: 13
+ "reset"
+ TextNode <#text> (not painted)
+ BlockContainer <div.use> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [24.734375,24 9.34375x16] baseline: 13
+ "a"
+ InlineNode <(anonymous)> at [8,24] [0+0+0 16.734375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,24 8.734375x16] baseline: 13
+ "6"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [16.734375,24 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.use> at [8,40] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [24.71875,40 9.46875x16] baseline: 13
+ "b"
+ InlineNode <(anonymous)> at [8,40] [0+0+0 16.71875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,40 8.71875x16] baseline: 13
+ "7"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [16.71875,40 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.use> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [25.484375,56 51.109375x16] baseline: 13
+ "nested"
+ InlineNode <(anonymous)> at [8,56] [0+0+0 17.484375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,56 9.484375x16] baseline: 13
+ "8"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [17.484375,56 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.use> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [24.828125,72 8.890625x16] baseline: 13
+ "c"
+ InlineNode <(anonymous)> at [8,72] [0+0+0 16.828125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,72 8.828125x16] baseline: 13
+ "9"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [16.828125,72 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div.use> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 9, rect: [22.34375,88 84.28125x16] baseline: 13
+ "new scope"
+ InlineNode <(anonymous)> at [8,88] [0+0+0 14.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,88 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [14.34375,88 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x112] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/counter-scope-shadow-tree.txt b/Tests/LibWeb/Layout/expected/tree-builder/counter-scope-shadow-tree.txt
new file mode 100644
index 00000000000..3c01ef714ad
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/counter-scope-shadow-tree.txt
@@ -0,0 +1,62 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 176 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 144 0+0+8] children: not-inline
+ BlockContainer <div#host> at [8,16] [0+0+0 784 0+0+0] [0+0+0 112 0+0+0] children: not-inline
+ BlockContainer <p> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [22.34375,16 9.34375x16] baseline: 13
+ "a"
+ InlineNode <(anonymous)> at [8,16] [0+0+0 14.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,16 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [14.34375,16 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.slotted> at [8,48] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 3, rect: [38.28125,48 28.6875x16] baseline: 13
+ "one"
+ InlineNode <(anonymous)> at [8,48] [0+0+0 30.28125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [8,48 22.28125x16] baseline: 13
+ "110"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [30.28125,48 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.slotted> at [8,80] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 3, rect: [40.75,80 28.4375x16] baseline: 13
+ "two"
+ InlineNode <(anonymous)> at [8,80] [0+0+0 32.75 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [8,80 24.75x16] baseline: 13
+ "120"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [32.75,80 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,112] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [22.34375,112 9.46875x16] baseline: 13
+ "b"
+ InlineNode <(anonymous)> at [8,112] [0+0+0 14.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,112 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [14.34375,112 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.slotted> at [8,144] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 10, rect: [38.28125,144 84.046875x16] baseline: 13
+ "after host"
+ InlineNode <(anonymous)> at [8,144] [0+0+0 30.28125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [8,144 22.28125x16] baseline: 13
+ "110"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [30.28125,144 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x176] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/counter-scope-sibling-in-anonymous-wrapper.txt b/Tests/LibWeb/Layout/expected/tree-builder/counter-scope-sibling-in-anonymous-wrapper.txt
new file mode 100644
index 00000000000..bca27ffe808
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/counter-scope-sibling-in-anonymous-wrapper.txt
@@ -0,0 +1,53 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 64 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 48 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,8 40.140625x16] baseline: 13
+ "text "
+ frag 1 from TextNode start: 0, length: 1, rect: [90.609375,8 8x16] baseline: 13
+ " "
+ TextNode <#text> (not painted)
+ InlineNode <span.reset> at [48.140625,8] [0+0+0 42.46875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 5, rect: [48.140625,8 42.46875x16] baseline: 13
+ "reset"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <span.use> at [98.609375,8] [0+0+0 26.078125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [115.34375,8 9.34375x16] baseline: 13
+ "a"
+ InlineNode <(anonymous)> at [98.609375,8] [0+0+0 16.734375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [98.609375,8 8.734375x16] baseline: 13
+ "6"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [107.34375,8 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.use> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 13, rect: [22.34375,24 98.015625x16] baseline: 13
+ "block sibling"
+ InlineNode <(anonymous)> at [8,24] [0+0+0 14.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,24 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [14.34375,24 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span.use> at [8,40] [0+0+0 54.53125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 5, rect: [22.34375,40 40.1875x16] baseline: 13
+ "after"
+ InlineNode <(anonymous)> at [8,40] [0+0+0 14.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,40 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [14.34375,40 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x64] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/counter-set-basic.txt b/Tests/LibWeb/Layout/expected/tree-builder/counter-set-basic.txt
new file mode 100644
index 00000000000..76b4363a0b2
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/counter-set-basic.txt
@@ -0,0 +1,93 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 128 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 112 0+0+8] children: not-inline
+ BlockContainer <p> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [22.34375,8 9.34375x16] baseline: 13
+ "a"
+ InlineNode <(anonymous)> at [8,8] [0+0+0 14.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,8 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [14.34375,8 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.set> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [31.9375,24 9.46875x16] baseline: 13
+ "b"
+ InlineNode <(anonymous)> at [8,24] [0+0+0 23.9375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,24 15.9375x16] baseline: 13
+ "10"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [23.9375,24 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [28.6875,40 8.890625x16] baseline: 13
+ "c"
+ InlineNode <(anonymous)> at [8,40] [0+0+0 20.6875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,40 12.6875x16] baseline: 13
+ "11"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [20.6875,40 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.increment-set> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [34.40625,56 7.859375x16] baseline: 13
+ "d"
+ InlineNode <(anonymous)> at [8,56] [0+0+0 26.40625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,56 18.40625x16] baseline: 13
+ "20"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [26.40625,56 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [31.15625,72 8.71875x16] baseline: 13
+ "e"
+ InlineNode <(anonymous)> at [8,72] [0+0+0 23.15625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,72 15.15625x16] baseline: 13
+ "21"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [23.15625,72 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.pseudo-set> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [33.625,88 6.4375x16] baseline: 13
+ "f"
+ InlineNode <(anonymous)> at [8,88] [0+0+0 25.625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,88 17.625x16] baseline: 13
+ "22"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [25.625,88 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [40.0625,88] [0+0+0 39.515625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [40.0625,88 14.953125x16] baseline: 13
+ " ["
+ frag 1 from GeneratedTextNode start: 0, length: 2, rect: [55.015625,88 17.34375x16] baseline: 13
+ "40"
+ frag 2 from GeneratedTextNode start: 0, length: 1, rect: [72.359375,88 7.21875x16] baseline: 13
+ "]"
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <p> at [8,104] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [30.09375,104 7.5625x16] baseline: 13
+ "g"
+ InlineNode <(anonymous)> at [8,104] [0+0+0 22.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,104 14.09375x16] baseline: 13
+ "41"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [22.09375,104 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x128] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/counters-and-display-none-and-cv-hidden.txt b/Tests/LibWeb/Layout/expected/tree-builder/counters-and-display-none-and-cv-hidden.txt
new file mode 100644
index 00000000000..d41b09a46c8
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/counters-and-display-none-and-cv-hidden.txt
@@ -0,0 +1,41 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 64 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 48 0+0+8] children: not-inline
+ BlockContainer <p> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [22.34375,8 9.34375x16] baseline: 13
+ "a"
+ InlineNode <(anonymous)> at [8,8] [0+0+0 14.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,8 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [14.34375,8 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [24.8125,24 9.46875x16] baseline: 13
+ "b"
+ InlineNode <(anonymous)> at [8,24] [0+0+0 16.8125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,24 8.8125x16] baseline: 13
+ "2"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [16.8125,24 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.cv> at [8,40] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ BlockContainer <p> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [25.09375,40 8.890625x16] baseline: 13
+ "c"
+ InlineNode <(anonymous)> at [8,40] [0+0+0 17.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,40 9.09375x16] baseline: 13
+ "3"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [17.09375,40 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x64] (z-index: auto)
+ SC for BlockContainer<DIV>.cv [8,40 784x0] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/counters-function-nested-scopes.txt b/Tests/LibWeb/Layout/expected/tree-builder/counters-function-nested-scopes.txt
new file mode 100644
index 00000000000..0f2d528cb63
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/counters-function-nested-scopes.txt
@@ -0,0 +1,77 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 112 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 96 0+0+8] children: not-inline
+ BlockContainer <div.scope> at [18,8] [10+0+0 774 0+0+0] [0+0+0 96 0+0+0] children: not-inline
+ BlockContainer <div.item> at [18,8] [0+0+0 774 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [32.34375,8 9.34375x16] baseline: 13
+ "a"
+ InlineNode <(anonymous)> at [18,8] [0+0+0 14.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [18,8 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [24.34375,8 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.item> at [18,24] [0+0+0 774 0+0+0] [0+0+0 64 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [18,24] [0+0+0 774 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [34.8125,24 9.46875x16] baseline: 13
+ "b"
+ InlineNode <(anonymous)> at [18,24] [0+0+0 16.8125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [18,24 8.8125x16] baseline: 13
+ "2"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [26.8125,24 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.scope> at [28,40] [10+0+0 764 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <div.item> at [28,40] [0+0+0 764 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 2, rect: [55.5,40 15.8125x16] baseline: 13
+ "b1"
+ InlineNode <(anonymous)> at [28,40] [0+0+0 27.5 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [28,40 19.5x16] baseline: 13
+ "2.1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [47.5,40 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.item> at [28,56] [0+0+0 764 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [28,56] [0+0+0 764 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 2, rect: [57.96875,56 18.28125x16] baseline: 13
+ "b2"
+ InlineNode <(anonymous)> at [28,56] [0+0+0 29.96875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [28,56 21.96875x16] baseline: 13
+ "2.2"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [49.96875,56 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.scope> at [38,72] [10+0+0 754 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div.item> at [38,72] [0+0+0 754 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 3, rect: [78.65625,72 27.625x16] baseline: 13
+ "b2a"
+ InlineNode <(anonymous)> at [38,72] [0+0+0 40.65625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [38,72 32.65625x16] baseline: 13
+ "2.2.1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [70.65625,72 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.item> at [18,88] [0+0+0 774 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [35.09375,88 8.890625x16] baseline: 13
+ "c"
+ InlineNode <(anonymous)> at [18,88] [0+0+0 17.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [18,88 9.09375x16] baseline: 13
+ "3"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [27.09375,88 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x112] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/display-contents-counters.txt b/Tests/LibWeb/Layout/expected/tree-builder/display-contents-counters.txt
new file mode 100644
index 00000000000..210a47a2334
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/display-contents-counters.txt
@@ -0,0 +1,51 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 80 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 64 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 64 0+0+0] children: not-inline
+ BlockContainer <p> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [22.34375,8 9.34375x16] baseline: 13
+ "a"
+ InlineNode <(anonymous)> at [8,8] [0+0+0 14.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,8 6.34375x16] baseline: 13
+ "1"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [14.34375,8 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [31.15625,24 9.46875x16] baseline: 13
+ "b"
+ InlineNode <(anonymous)> at [8,24] [0+0+0 23.15625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,24 15.15625x16] baseline: 13
+ "21"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [23.15625,24 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [33.625,40 8.890625x16] baseline: 13
+ "c"
+ InlineNode <(anonymous)> at [8,40] [0+0+0 25.625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,40 17.625x16] baseline: 13
+ "22"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [25.625,40 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [33.90625,56 7.859375x16] baseline: 13
+ "d"
+ InlineNode <(anonymous)> at [8,56] [0+0+0 25.90625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,56 17.90625x16] baseline: 13
+ "23"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [25.90625,56 8x16] baseline: 13
+ " "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x80] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/display-contents-nested-with-pseudos.txt b/Tests/LibWeb/Layout/expected/tree-builder/display-contents-nested-with-pseudos.txt
new file mode 100644
index 00000000000..8dae8c8eabd
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/display-contents-nested-with-pseudos.txt
@@ -0,0 +1,65 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 160 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 144 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <(anonymous)> at [8,8] [0+0+0 103.546875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 12, rect: [8,8 103.546875x16] baseline: 13
+ "before-outer"
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <(anonymous)> at [111.546875,8] [0+0+0 100.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 12, rect: [111.546875,8 100.34375x16] baseline: 13
+ "before-inner"
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <(anonymous)> at [211.890625,8] [0+0+0 29.484375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [211.890625,8 29.484375x16] baseline: 13
+ "kids"
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [241.375,8] [0+0+0 88 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 11, rect: [241.375,8 88x16] baseline: 13
+ "after-inner"
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <(anonymous)> at [329.375,8] [0+0+0 91.203125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 11, rect: [329.375,8 91.203125x16] baseline: 13
+ "after-outer"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <div> at [8,24] [0+0+0 784 0+0+0] [0+0+0 80 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <(anonymous)> at [8,24] [0+0+0 103.546875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 12, rect: [8,24 103.546875x16] baseline: 13
+ "before-outer"
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <(anonymous)> at [111.546875,24] [0+0+0 100.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 12, rect: [111.546875,24 100.34375x16] baseline: 13
+ "before-inner"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <p> at [8,56] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 9, rect: [8,56 68.8125x16] baseline: 13
+ "block kid"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <(anonymous)> at [8,88] [0+0+0 88 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 11, rect: [8,88 88x16] baseline: 13
+ "after-inner"
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <(anonymous)> at [96,88] [0+0+0 91.203125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 11, rect: [96,88 91.203125x16] baseline: 13
+ "after-outer"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <div> at [8,104] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,104] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [8,104] [0+0+0 35.171875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [8,104 35.171875x16] baseline: 13
+ "prev"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,120] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 12, rect: [8,120 99.6875x16] baseline: 13
+ "block-before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,136] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <(anonymous)> at [8,136] [0+0+0 29.484375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [8,136 29.484375x16] baseline: 13
+ "kids"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x160] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/display-contents-on-list-item-and-table-parts.txt b/Tests/LibWeb/Layout/expected/tree-builder/display-contents-on-list-item-and-table-parts.txt
new file mode 100644
index 00000000000..0542c21dd5c
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/display-contents-on-list-item-and-table-parts.txt
@@ -0,0 +1,63 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 164 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 140 0+0+8] children: not-inline
+ BlockContainer <ul> at [48,16] [0+0+40 744 0+0+0] [16+0+0 48 0+0+16] children: not-inline
+ ListItemBox <li> at [48,16] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [48,16 54.578125x16] baseline: 13
+ "normal"
+ ListItemMarkerBox <(anonymous)> at [34,16] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [34,16 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [48,32] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <(anonymous)> at [48,32] [0+0+0 110.59375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 13, rect: [48,32 110.59375x16] baseline: 13
+ "contents item"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,48] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [48,48 40.1875x16] baseline: 13
+ "after"
+ ListItemMarkerBox <(anonymous)> at [34,48] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [34,48 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ TableWrapper <(anonymous)> at [8,80] [0+0+0 229.6875 0+0+554.3125] [0+0+0 42 0+0+0] [BFC] children: not-inline
+ Box <table> at [8,80] table-box [0+0+0 229.6875 0+0+0] [0+0+0 42 0+0+0] [TFC] children: not-inline
+ Box <tbody> at [10,82] table-row-group [0+0+0 225.6875 0+0+0] [0+0+0 38 0+0+0] children: not-inline
+ Box <(anonymous)> at [10,82] table-row [0+0+0 225.6875 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ BlockContainer <td> at [11,83] table-cell [0+0+1 164.90625 1+0+0] [0+0+1 16 1+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 20, rect: [11,83 164.90625x16] baseline: 13
+ "cell in contents row"
+ TextNode <#text> (not painted)
+ BlockContainer <td> at [179.90625,83] table-cell [0+0+1 54.78125 1+0+0] [0+0+1 16 1+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [179.90625,83 54.78125x16] baseline: 13
+ "second"
+ TextNode <#text> (not painted)
+ Box <tr> at [10,102] table-row [0+0+0 225.6875 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ BlockContainer <td> at [11,103] table-cell [0+0+1 164.90625 1+0+0] [0+0+1 16 1+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 10, rect: [11,103 92.984375x16] baseline: 13
+ "normal row"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [178.90625,102] table-cell [0+0+0 56.78125 0+0+0] [0+0+0 18 0+0+0] [BFC] children: not-inline
+ BlockContainer <div> at [8,122] [0+0+0 784 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ TableWrapper <(anonymous)> at [8,122] [0+0+0 175.125 0+0+608.875] [0+0+0 18 0+0+0] [BFC] children: not-inline
+ Box <(anonymous)> at [8,122] table-box [0+0+0 175.125 0+0+0] [0+0+0 18 0+0+0] [TFC] children: not-inline
+ Box <tbody> at [8,122] table-row-group [0+0+0 175.125 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ Box <tr> at [8,122] table-row [0+0+0 175.125 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ BlockContainer <td> at [9,123] table-cell [0+0+1 173.125 1+0+0] [0+0+1 16 1+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 22, rect: [9,123 173.125x16] baseline: 13
+ "cell in contents table"
+ TextNode <#text> (not painted)
+ TableWrapper <(anonymous)> at [8,140] [0+0+0 157.109375 0+0+626.890625] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <div> at [8,140] table-box [0+0+0 157.109375 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,140] table-row [0+0+0 157.109375 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div> at [8,140] table-cell [0+0+0 157.109375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 19, rect: [8,140 157.109375x16] baseline: 13
+ "cell under contents"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x164] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/display-contents-text-style-wrapper.txt b/Tests/LibWeb/Layout/expected/tree-builder/display-contents-text-style-wrapper.txt
new file mode 100644
index 00000000000..8af75fba69a
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/display-contents-text-style-wrapper.txt
@@ -0,0 +1,29 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 72 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 56 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 24 0+0+0] children: inline
+ InlineNode <(anonymous)> at [8,8] [0+0+0 126.546875 0+0+0] [0+0+0 24 0+0+0]
+ frag 0 from TextNode start: 0, length: 11, rect: [8,8 126.546875x24] baseline: 19
+ "styled text"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,32] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <(anonymous)> at [8,32] [0+0+0 24 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 3, rect: [8,32 24x16] baseline: 13
+ " "
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,48] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <(anonymous)> at [8,48] [0+0+0 17.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 2, rect: [8,48 17.34375x16] baseline: 13
+ "a "
+ TextNode <#text> (not painted)
+ InlineNode <b> at [25.34375,48] [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [25.34375,48 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [34.8125,48] [0+0+0 16.890625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 2, rect: [34.8125,48 16.890625x16] baseline: 13
+ " c"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x72] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/display-contents-top-layer-member.txt b/Tests/LibWeb/Layout/expected/tree-builder/display-contents-top-layer-member.txt
new file mode 100644
index 00000000000..aecb3848e01
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/display-contents-top-layer-member.txt
@@ -0,0 +1,26 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 48 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 16 0+0+8] children: not-inline
+ BlockContainer <p> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [8,16 60.90625x16] baseline: 13
+ "content"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [0,0] positioned [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <dialog#dialog.contents> at [0,0] positioned [0+0+0 86.765625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ InlineNode <span> at [0,0] [0+0+0 86.765625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 12, rect: [0,0 86.765625x16] baseline: 13
+ "dialog child"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [0,0] positioned [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <div#popover.contents> at [0,0] positioned [0+0+0 108.15625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ InlineNode <span> at [0,0] [0+0+0 108.15625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 13, rect: [0,0 108.15625x16] baseline: 13
+ "popover child"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x48] (z-index: auto)
+ SC for BlockContainer(anonymous) [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<DIALOG>#dialog.contents [0,0 86.765625x16] (z-index: auto)
+ SC for BlockContainer(anonymous) [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<DIV>#popover.contents [0,0 108.15625x16] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/display-math-on-html-element.txt b/Tests/LibWeb/Layout/expected/tree-builder/display-math-on-html-element.txt
new file mode 100644
index 00000000000..41c8c6a9edc
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/display-math-on-html-element.txt
@@ -0,0 +1,49 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 120 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 96 0+0+8] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: inline
+ InlineNode <div> at [8,8] [0+0+0 87.015625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 7, rect: [8,8 49.296875x16] baseline: 13
+ "inline "
+ frag 0 from BlockContainer start: 0, length: 0, rect: [8,24 784x16] baseline: 0
+ TextNode <#text> (not painted)
+ InlineNode <span> at [57.296875,8] [0+0+0 37.71875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [57.296875,8 37.71875x16] baseline: 13
+ "span"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,24 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,40] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [8,40 49.296875x16] baseline: 13
+ "inline "
+ TextNode <#text> (not painted)
+ InlineNode <span> at [57.296875,40] [0+0+0 37.71875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [57.296875,40 37.71875x16] baseline: 13
+ "span"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,56 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,88] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [8,88 60.53125x16] baseline: 13
+ "before "
+ frag 1 from TextNode start: 0, length: 6, rect: [191.875,88 48.1875x16] baseline: 13
+ " after"
+ TextNode <#text> (not painted)
+ InlineNode <span> at [68.53125,88] [0+0+0 123.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 10, rect: [68.53125,88 91.421875x16] baseline: 13
+ "math span "
+ TextNode <#text> (not painted)
+ InlineNode <b> at [159.953125,88] [0+0+0 31.921875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [159.953125,88 31.921875x16] baseline: 13
+ "bold"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x120] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/display-run-in-and-webkit-box.txt b/Tests/LibWeb/Layout/expected/tree-builder/display-run-in-and-webkit-box.txt
new file mode 100644
index 00000000000..b416d0b222a
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/display-run-in-and-webkit-box.txt
@@ -0,0 +1,35 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 80 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 64 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,8 48.859375x16] baseline: 13
+ "run-in"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,24 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+ Box <div> at [8,40] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,40] flex-item [0+0+0 84.5625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 10, rect: [8,40 84.5625x16] baseline: 13
+ "webkit-box"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [92.5625,40] flex-item [0+0+0 40.671875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [92.5625,40 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from Box start: 0, length: 0, rect: [8,56 173.015625x16] baseline: 13
+ Box <span> at [8,56] flex-container(row) [0+0+0 173.015625 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,56] flex-item [0+0+0 132.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 17, rect: [8,56 132.34375x16] baseline: 13
+ "webkit-inline-box"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [140.34375,56] flex-item [0+0+0 40.671875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [140.34375,56 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x80] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/editable-and-input-empty-text-fragments.txt b/Tests/LibWeb/Layout/expected/tree-builder/editable-and-input-empty-text-fragments.txt
new file mode 100644
index 00000000000..aadb4df1e9c
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/editable-and-input-empty-text-fragments.txt
@@ -0,0 +1,37 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 88 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 72 0+0+8] children: not-inline
+ BlockContainer <div#empty-editable> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div#empty-text-editable> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span#span> at [8,24] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,40] [0+0+0 784 0+0+0] [0+0+0 40 0+0+0] children: inline
+ frag 0 from TextInputBox start: 0, length: 0, rect: [13,63 159.6875x14] baseline: 14
+ frag 1 from TextNode start: 0, length: 1, rect: [177.6875,61 8x16] baseline: 13
+ " "
+ frag 2 from TextInputBox start: 0, length: 0, rect: [190.6875,63 159.6875x14] baseline: 14
+ frag 3 from TextNode start: 0, length: 1, rect: [355.375,61 8x16] baseline: 13
+ " "
+ frag 4 from TextAreaBox start: 0, length: 0, rect: [366.375,43 159.6875x28] baseline: 34
+ TextInputBox <input> at [13,63] inline-block [0+2+3 159.6875 3+2+0] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ Box <div> at [13,63] flex-container(row) [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <div> at [13,63] flex-item [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 0, rect: [13,63 0x14] baseline: 11
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ TextInputBox <input> at [190.6875,63] inline-block [0+2+3 159.6875 3+2+0] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ Box <div> at [190.6875,63] flex-container(row) [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <div> at [190.6875,63] flex-item [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [190.6875,63 26.78125x14] baseline: 11
+ "text"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ TextAreaBox <textarea> at [366.375,43] inline-block [0+1+2 159.6875 2+1+0] [0+1+2 28 2+1+0] [BFC] children: not-inline
+ Box <div> at [366.375,43] flex-container(row) [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <div> at [366.375,43] flex-item [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 0, rect: [366.375,43 0x14] baseline: 11
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x88] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/fieldset-display-variants.txt b/Tests/LibWeb/Layout/expected/tree-builder/fieldset-display-variants.txt
new file mode 100644
index 00000000000..acdc5636508
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/fieldset-display-variants.txt
@@ -0,0 +1,104 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 436.75 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 420.75 0+0+8] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 49.59375 0+0+0] children: inline
+ frag 0 from FieldSetBox start: 0, length: 0, rect: [24,15 45.296875x30] baseline: 34.59375
+ FieldSetBox <fieldset> at [24,15] inline-block [2+2+12 45.296875 12+2+2] [0+2+5.59375 30 10+2+0] [BFC] children: not-inline
+ LegendBox <legend> at [26,7.40625] [0+0+2 41.296875 2+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [26,7.40625 41.296875x16] baseline: 13
+ "inline"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [24,29] [0+0+0 45.296875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [24,29] [0+0+0 45.296875 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [24,29 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ FieldSetBox <fieldset> at [24,65.1875] flex-container(row) [2+2+12 752 12+2+2] [0+2+5.59375 30 10+2+0] [BFC] children: not-inline
+ LegendBox <legend> at [26,57.59375] [0+0+2 29.09375 2+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [26,57.59375 29.09375x16] baseline: 13
+ "flex"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [24,79.1875] flex-container(row) [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <div> at [24,79.1875] flex-item [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [24,79.1875 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [33.34375,79.1875] flex-item [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [33.34375,79.1875 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ FieldSetBox <fieldset> at [24,114.78125] [2+2+12 752 12+2+2] [0+2+5.59375 48 10+2+0] [GFC] children: not-inline
+ LegendBox <legend> at [26,114.78125] [0+0+2 748 2+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [26,114.78125 28.8125x16] baseline: 13
+ "grid"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [24,130.78125] [0+0+0 752 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline
+ BlockContainer <div> at [24,130.78125] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [24,130.78125 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [24,146.78125] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [24,146.78125 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ LegendBox <legend> at [10,174.78125] [0+0+2 780 2+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 8, rect: [10,174.78125 70.25x16] baseline: 13
+ "contents"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,190.78125] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <(anonymous)> at [24,190.78125] [2+2+12 32.140625 12+2+2] [0+2+5.59375 16 10+2+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [24,190.78125 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ FieldSetBox <fieldset> at [24,214.375] [2+2+12 752 12+2+2] [0+2+5.59375 16 10+2+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [24,214.375] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [24,214.375 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ FieldSetBox <fieldset> at [24,249.96875] [2+2+12 752 12+2+2] [0+2+5.59375 16 10+2+0] [BFC] children: not-inline
+ LegendBox <legend> at [26,249.96875] floating [0+0+2 108.515625 2+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 14, rect: [26,249.96875 108.515625x16] baseline: 13
+ "floated legend"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [24,249.96875] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [136.515625,249.96875 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ FieldSetBox <fieldset> at [24,285.5625] [2+2+12 752 12+2+2] [0+2+5.59375 16 10+2+0] [BFC] children: not-inline
+ LegendBox <legend> at [26,285.5625] positioned [0+0+2 111.984375 2+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 13, rect: [26,285.5625 111.984375x16] baseline: 13
+ "abspos legend"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [24,285.5625] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [24,285.5625 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ FieldSetBox <fieldset> at [24,321.15625] [2+2+12 752 12+2+2] [0+2+5.59375 46 10+2+0] [BFC] children: not-inline
+ LegendBox <legend> at [26,313.5625] [0+0+2 90.734375 2+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 12, rect: [26,313.5625 90.734375x16] baseline: 13
+ "first legend"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [24,335.15625] [0+0+0 752 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline
+ LegendBox <legend> at [26,335.15625] [0+0+2 748 2+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 13, rect: [26,335.15625 109.484375x16] baseline: 13
+ "second legend"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [24,351.15625] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [24,351.15625 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ FieldSetBox <fieldset> at [24,386.75] [2+2+12 752 12+2+2] [0+2+5.59375 30 10+2+0] [BFC] children: not-inline
+ LegendBox <legend> at [26,379.15625] [0+0+2 135.03125 2+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 17, rect: [26,379.15625 135.03125x16] baseline: 13
+ "legend after text"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [24,400.75] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [24,400.75] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [24,400.75 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x436.75] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/first-letter-basic.txt b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-basic.txt
new file mode 100644
index 00000000000..10db24e6673
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-basic.txt
@@ -0,0 +1,14 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 64 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 32 0+0+8] children: not-inline
+ BlockContainer <p> at [8,16] [0+0+0 784 0+0+0] [16+0+0 32 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 10, rect: [32.46875,29 78.046875x16] baseline: 13
+ "ello world"
+ InlineNode <(anonymous)> at [8,16] [0+0+0 24.46875 0+0+0] [0+0+0 32 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,16 24.46875x32] baseline: 26
+ "H"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x64] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/first-letter-block-chain.txt b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-block-chain.txt
new file mode 100644
index 00000000000..4f0519f9dfb
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-block-chain.txt
@@ -0,0 +1,30 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 64 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 48 0+0+8] children: not-inline
+ BlockContainer <div.outer> at [8,8] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <p> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [20.234375,8 27.546875x16] baseline: 13
+ "ello"
+ InlineNode <(anonymous)> at [8,8] [0+0+0 12.234375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,8 12.234375x16] baseline: 13
+ "H"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,24 57.40625x16] baseline: 13
+ "Second"
+ TextNode <#text> (not painted)
+ BlockContainer <div.outer> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div.inner> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <p> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [12.59375,40 36.765625x16] baseline: 13
+ "nner"
+ InlineNode <(anonymous)> at [8,40] [0+0+0 4.59375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,40 4.59375x16] baseline: 13
+ "I"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x64] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/first-letter-blocked.txt b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-blocked.txt
new file mode 100644
index 00000000000..62eba26f7dd
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-blocked.txt
@@ -0,0 +1,26 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 80 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 64 0+0+8] children: not-inline
+ BlockContainer <p> at [8,8] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 11, rect: [8,24 97.1875x16] baseline: 13
+ "After break"
+ BreakNode <br> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [8,40 9.703125x16] baseline: 13
+ frag 1 from TextNode start: 0, length: 18, rect: [17.703125,40 141.5625x16] baseline: 13
+ "After inline-block"
+ BlockContainer <span.ib> at [8,40] inline-block [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,40 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ImageBox start: 0, length: 0, rect: [8,59 10x10] baseline: 10
+ frag 1 from TextNode start: 0, length: 11, rect: [18,56 95.5x16] baseline: 13
+ "After image"
+ ImageBox <img> at [8,59] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x80] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/first-letter-float-and-display-none.txt b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-float-and-display-none.txt
new file mode 100644
index 00000000000..93b691698f1
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-float-and-display-none.txt
@@ -0,0 +1,30 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 64 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 48 0+0+8] children: not-inline
+ BlockContainer <p.float> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [33.09375,8 47.375x16] baseline: 13
+ "loated"
+ BlockContainer <(anonymous)> at [8,8] floating [0+0+0 25.09375 0+0+0] [0+0+0 32 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,8 25.09375x32] baseline: 26
+ "F"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.none> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [45.328125,24 38.609375x16] baseline: 13
+ "idden"
+ InlineNode <(anonymous)> at [33.09375,24] [0+0+0 12.234375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [33.09375,24 12.234375x16] baseline: 13
+ "H"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.block> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [17.34375,40 31.203125x16] baseline: 13
+ "lock"
+ InlineNode <(anonymous)> at [8,40] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,40 9.34375x16] baseline: 13
+ "B"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x64] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/first-letter-generated-content.txt b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-generated-content.txt
new file mode 100644
index 00000000000..7c842cf1fcd
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-generated-content.txt
@@ -0,0 +1,28 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 80 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 48 0+0+8] children: not-inline
+ BlockContainer <p.before> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [31.734375,16 32.140625x16] baseline: 13
+ "text"
+ InlineNode <(anonymous)> at [8,16] [0+0+0 23.734375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [22.265625,16 9.46875x16] baseline: 13
+ "b"
+ InlineNode <(anonymous)> at [8,16] [0+0+0 14.265625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,16 14.265625x16] baseline: 13
+ "A"
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.empty-before> at [8,48] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 3, rect: [20.296875,48 25.28125x16] baseline: 13
+ "ext"
+ InlineNode <(anonymous)> at [8,48] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <(anonymous)> at [8,48] [0+0+0 12.296875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,48 12.296875x16] baseline: 13
+ "T"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x80] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/first-letter-nested-inline.txt b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-nested-inline.txt
new file mode 100644
index 00000000000..d3d3984dff7
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-nested-inline.txt
@@ -0,0 +1,32 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 80 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 48 0+0+8] children: not-inline
+ BlockContainer <p> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ InlineNode <span> at [8,16] [0+0+0 90.28125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [47.78125,16 50.5x16] baseline: 13
+ " world"
+ InlineNode <b> at [8,16] [0+0+0 39.78125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [20.234375,16 27.546875x16] baseline: 13
+ "ello"
+ InlineNode <(anonymous)> at [8,16] [0+0+0 12.234375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,16 12.234375x16] baseline: 13
+ "H"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,48] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [55.515625,48 60.53125x16] baseline: 13
+ " before"
+ InlineNode <span> at [8,48] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]
+ InlineNode <i> at [8,48] [0+0+0 47.515625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [19.859375,48 35.65625x16] baseline: 13
+ "mpty"
+ InlineNode <(anonymous)> at [8,48] [0+0+0 11.859375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,48 11.859375x16] baseline: 13
+ "E"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x80] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/first-letter-on-various-containers.txt b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-on-various-containers.txt
new file mode 100644
index 00000000000..3058fe0218f
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-on-various-containers.txt
@@ -0,0 +1,78 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 132 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 116 0+0+8] children: not-inline
+ TableWrapper <(anonymous)> at [8,8] [0+0+0 27.5 0+0+756.5] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <(anonymous)> at [8,8] table-box [0+0+0 27.5 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,8] table-row [0+0+0 27.5 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div.fl.cell> at [8,8] table-cell [0+0+0 27.5 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 3, rect: [18.3125,8 17.1875x16] baseline: 13
+ "ell"
+ InlineNode <(anonymous)> at [8,8] [0+0+0 10.3125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,8 10.3125x16] baseline: 13
+ "C"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,24] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: inline
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [8,24 88.484375x16] baseline: 13
+ BlockContainer <span.fl.ib> at [8,24] inline-block [0+0+0 88.484375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 11, rect: [12.59375,24 83.890625x16] baseline: 13
+ "nline-block"
+ InlineNode <(anonymous)> at [8,24] [0+0+0 4.59375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,24 4.59375x16] baseline: 13
+ "I"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <div.fl.li> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ListItemMarkerBox start: 0, length: 0, rect: [8,40 13.84375x16] baseline: 13
+ frag 1 from TextNode start: 0, length: 8, rect: [32.703125,40 61.109375x16] baseline: 13
+ "ist item"
+ ListItemMarkerBox <(anonymous)> at [8,40] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,40 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <(anonymous)> at [21.84375,40] [0+0+0 10.859375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [21.84375,40 10.859375x16] baseline: 13
+ "L"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.fl.fr> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 8, rect: [20.546875,56 70.21875x16] baseline: 13
+ "low root"
+ InlineNode <(anonymous)> at [8,56] [0+0+0 12.546875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,56 12.546875x16] baseline: 13
+ "F"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,72] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [17,75 43.984375x14] baseline: 14
+ BlockContainer <button.fl> at [17,75] inline-block [0+2+7 43.984375 7+2+0] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,75] flex-container(column) [0+0+0 43.984375 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,75] flex-item [0+0+0 43.984375 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [24.78125,75 36.203125x14] baseline: 11
+ "utton"
+ InlineNode <(anonymous)> at [17,75] [0+0+0 7.78125 0+0+0] [0+0+0 14 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [17,75 7.78125x14] baseline: 11
+ "B"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.fl> at [8,92] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <(anonymous)> at [8,92] [0+0+0 71.671875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 7, rect: [18.3125,92 61.359375x16] baseline: 13
+ "ontents"
+ InlineNode <(anonymous)> at [8,92] [0+0+0 10.3125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,92 10.3125x16] baseline: 13
+ "C"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,108] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span.fl> at [8,108] [0+0+0 128.734375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 17, rect: [8,108 128.734375x16] baseline: 13
+ "Inline is ignored"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x132] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/first-letter-punctuation.txt b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-punctuation.txt
new file mode 100644
index 00000000000..ff1adeb643b
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-punctuation.txt
@@ -0,0 +1,54 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 112 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 96 0+0+8] children: not-inline
+ BlockContainer <p> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [31.359375,8 43.5625x16] baseline: 13
+ "uoted"
+ InlineNode <(anonymous)> at [8,8] [0+0+0 23.359375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 3, rect: [8,8 23.359375x16] baseline: 13
+ ""(Q"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 3, rect: [21.203125,24 26.515625x16] baseline: 13
+ "ang"
+ InlineNode <(anonymous)> at [8,24] [0+0+0 13.203125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 2, rect: [8,24 13.203125x16] baseline: 13
+ "!B"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 9, rect: [14.34375,40 66.65625x16] baseline: 13
+ "23 digits"
+ InlineNode <(anonymous)> at [8,40] [0+0+0 6.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,40 6.34375x16] baseline: 13
+ "1"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 15, rect: [21.40625,56 114.625x16] baseline: 13
+ "uillemets» text"
+ InlineNode <(anonymous)> at [8,56] [0+0+0 13.40625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 2, rect: [8,56 13.40625x16] baseline: 13
+ "«g"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 13, rect: [12.234375,72 110.71875x16] baseline: 13
+ "eading spaces"
+ InlineNode <(anonymous)> at [8,72] [0+0+0 4.234375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 3, length: 1, rect: [8,72 4.234375x16] baseline: 13
+ "l"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [30.828125,88 44.234375x16] baseline: 13
+ "paced"
+ InlineNode <(anonymous)> at [8,88] [0+0+0 22.828125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 3, rect: [8,88 22.828125x16] baseline: 13
+ "" s"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x112] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/first-letter-skips-marker.txt b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-skips-marker.txt
new file mode 100644
index 00000000000..97ea9c2d7df
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-skips-marker.txt
@@ -0,0 +1,32 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 64 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 32 0+0+8] children: not-inline
+ BlockContainer <ul> at [48,16] [0+0+40 744 0+0+0] [16+0+0 32 0+0+16] children: not-inline
+ ListItemBox <li> at [48,16] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 13, rect: [59.484375,16 110.75x16] baseline: 13
+ "utside marker"
+ ListItemMarkerBox <(anonymous)> at [34,16] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [34,16 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <(anonymous)> at [48,16] [0+0+0 11.484375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [48,16 11.484375x16] baseline: 13
+ "O"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,32] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ListItemMarkerBox start: 0, length: 0, rect: [48,32 13.84375x16] baseline: 13
+ frag 1 from TextNode start: 0, length: 12, rect: [66.4375,32 103.734375x16] baseline: 13
+ "nside marker"
+ ListItemMarkerBox <(anonymous)> at [48,32] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [48,32 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <(anonymous)> at [61.84375,32] [0+0+0 4.59375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [61.84375,32 4.59375x16] baseline: 13
+ "I"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x64] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/first-letter-with-writing-suggestion.txt b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-with-writing-suggestion.txt
new file mode 100644
index 00000000000..98e6eaffa6e
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-with-writing-suggestion.txt
@@ -0,0 +1,14 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 16 0+0+8] children: not-inline
+ BlockContainer <div#editable> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 8, rect: [17.421875,8 61.71875x16] baseline: 13
+ "redi-xyz"
+ InlineNode <(anonymous)> at [8,8] [0+0+0 9.421875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,8 9.421875x16] baseline: 13
+ "p"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x32] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/flex-runs-split-by-oof.txt b/Tests/LibWeb/Layout/expected/tree-builder/flex-runs-split-by-oof.txt
new file mode 100644
index 00000000000..2b7e4250a6f
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/flex-runs-split-by-oof.txt
@@ -0,0 +1,44 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 48 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 32 0+0+8] children: not-inline
+ Box <div> at [8,8] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] flex-item [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,8 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [17.34375,8] flex-item [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,8 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,8] positioned [0+0+0 57.28125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,8 57.28125x16] baseline: 13
+ "abspos"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [26.8125,8] flex-item [0+0+0 8.890625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 1, length: 1, rect: [26.8125,8 8.890625x16] baseline: 13
+ "c"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [35.703125,8] flex-item [0+0+0 37.234375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [35.703125,8 37.234375x16] baseline: 13
+ "float"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [72.9375,8] flex-item [0+0+0 7.859375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 1, length: 1, rect: [72.9375,8 7.859375x16] baseline: 13
+ "d"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from Box start: 0, length: 0, rect: [8,24 18.8125x16] baseline: 13
+ Box <div> at [8,24] flex-container(row) [0+0+0 18.8125 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,24] flex-item [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,24 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,24] positioned [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [17.34375,24] flex-item [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,24 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x48] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/frameset-refuses-non-frame-children.txt b/Tests/LibWeb/Layout/expected/tree-builder/frameset-refuses-non-frame-children.txt
new file mode 100644
index 00000000000..6aac3cff9be
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/frameset-refuses-non-frame-children.txt
@@ -0,0 +1,22 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ FrameSetBox <frameset#outer> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] children: not-inline
+ NavigableContainerViewport <frame> at [0,0] [0+0+0 397 0+0+0] [0+0+0 600 0+0+0] children: not-inline (url: about:blank)
+ Viewport <#document> at [0,0] [0+0+0 397 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 397 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 381 0+0+8] [8+0+0 584 0+0+8] children: not-inline
+
+ FrameSetBox <frameset> at [403,0] [0+0+0 397 0+0+0] [0+0+0 600 0+0+0] children: not-inline
+ NavigableContainerViewport <frame> at [403,0] [0+0+0 397 0+0+0] [0+0+0 297 0+0+0] children: not-inline (url: about:blank)
+ Viewport <#document> at [0,0] [0+0+0 397 0+0+0] [0+0+0 297 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 397 0+0+0] [0+0+0 297 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 381 0+0+8] [8+0+0 281 0+0+8] children: not-inline
+
+ NavigableContainerViewport <frame> at [403,303] [0+0+0 397 0+0+0] [0+0+0 297 0+0+0] children: not-inline (url: about:blank)
+ Viewport <#document> at [0,0] [0+0+0 397 0+0+0] [0+0+0 297 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 397 0+0+0] [0+0+0 297 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 381 0+0+8] [8+0+0 281 0+0+8] children: not-inline
+
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x600] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/fullscreen-element.txt b/Tests/LibWeb/Layout/expected/tree-builder/fullscreen-element.txt
new file mode 100644
index 00000000000..4e12c78c025
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/fullscreen-element.txt
@@ -0,0 +1,22 @@
+Viewport <#document> at [0,0] [0+0+0 1920 0+0+0] [0+0+0 1080 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 1920 0+0+0] [0+0+0 80 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 1904 0+0+8] [8+0+0 48 0+0+8] children: not-inline
+ BlockContainer <p> at [8,16] [0+0+0 1904 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,16 52.53125x16] baseline: 13
+ "before"
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,48] [0+0+0 1904 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,48 40.1875x16] baseline: 13
+ "after"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [0,0] positioned [0+0+0 1920 0+0+0] [0+0+0 1080 0+0+0] [BFC] children: not-inline
+ BlockContainer <div#target> at [0,0] positioned [0+0+0 1920 0+0+0] [0+0+0 1080 0+0+0] [BFC] children: inline
+ InlineNode <span> at [0,0] [0+0+0 147.6875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 18, rect: [0,0 147.6875x16] baseline: 13
+ "fullscreen content"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 1920x1080] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 1920x80] (z-index: auto)
+ SC for BlockContainer(anonymous) [0,0 1920x1080] (z-index: auto)
+ SC for BlockContainer<DIV>#target [0,0 1920x1080] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/generated-content-item-shapes.txt b/Tests/LibWeb/Layout/expected/tree-builder/generated-content-item-shapes.txt
new file mode 100644
index 00000000000..c2747b479a5
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/generated-content-item-shapes.txt
@@ -0,0 +1,141 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline overflow: [0,0 800x640]
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 640 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 608 0+0+8] children: not-inline
+ BlockContainer <p.inline-close> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 26, rect: [8,16 209.5x16] baseline: 13
+ "inline close at depth zero"
+ InlineNode <(anonymous)> at [8,16] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]
+ TextNode <#text> (not painted)
+ BlockContainer <p.block-close> at [8,48] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: not-inline
+ BlockContainer <(anonymous)> at [8,48] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,48] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 25, rect: [8,48 208.875x16] baseline: 13
+ "block close at depth zero"
+ TextNode <#text> (not painted)
+ BlockContainer <p.flex-close> at [8,80] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: not-inline
+ Box <(anonymous)> at [8,80] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,80] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 24, rect: [8,80 197.296875x16] baseline: 13
+ "flex close at depth zero"
+ TextNode <#text> (not painted)
+ BlockContainer <p.open> at [8,112] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [21.625,112 38.109375x16] baseline: 13
+ "open"
+ InlineNode <(anonymous)> at [8,112] [0+0+0 13.625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,112 13.625x16] baseline: 13
+ "<1"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.inline-close> at [8,144] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 25, rect: [22.890625,144 201.890625x16] baseline: 13
+ "inline close at depth one"
+ InlineNode <(anonymous)> at [8,144] [0+0+0 14.890625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,144 14.890625x16] baseline: 13
+ "1>"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.open> at [8,176] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [21.625,176 38.109375x16] baseline: 13
+ "open"
+ InlineNode <(anonymous)> at [8,176] [0+0+0 13.625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,176 13.625x16] baseline: 13
+ "<1"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.block-close> at [8,208] [0+0+0 784 0+0+0] [16+0+0 32 0+0+16] children: not-inline
+ BlockContainer <(anonymous)> at [8,208] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,208 14.890625x16] baseline: 13
+ "1>"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,224] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 24, rect: [8,224 201.265625x16] baseline: 13
+ "block close at depth one"
+ TextNode <#text> (not painted)
+ BlockContainer <p.open> at [8,256] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [21.625,256 38.109375x16] baseline: 13
+ "open"
+ InlineNode <(anonymous)> at [8,256] [0+0+0 13.625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,256 13.625x16] baseline: 13
+ "<1"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.flex-close> at [8,288] [0+0+0 784 0+0+0] [16+0+0 32 0+0+16] children: not-inline
+ Box <(anonymous)> at [8,288] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,288] flex-item [0+0+0 14.890625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,288 14.890625x16] baseline: 13
+ "1>"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,304] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 23, rect: [8,304 189.6875x16] baseline: 13
+ "flex close at depth one"
+ TextNode <#text> (not painted)
+ BlockContainer <p.block-none-quotes> at [8,336] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: not-inline
+ BlockContainer <(anonymous)> at [8,336] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,336] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 27, rect: [8,336 237.125x16] baseline: 13
+ "block open with quotes none"
+ TextNode <#text> (not painted)
+ BlockContainer <p.open.inline-none-quotes> at [8,368] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 29, rect: [24.09375,368 241.1875x16] baseline: 13
+ "inline close with quotes none"
+ InlineNode <(anonymous)> at [8,368] [0+0+0 16.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,368 16.09375x16] baseline: 13
+ "<2"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [8,368] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <p.inline-blank> at [8,400] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 20, rect: [8,400 160.703125x16] baseline: 13
+ "inline blank counter"
+ InlineNode <(anonymous)> at [8,400] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.block-blank> at [8,432] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: not-inline
+ BlockContainer <(anonymous)> at [8,432] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,432] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 19, rect: [8,432 160.078125x16] baseline: 13
+ "block blank counter"
+ TextNode <#text> (not painted)
+ BlockContainer <p.flex-blank> at [8,464] [0+0+0 784 0+0+0] [16+0+0 32 0+0+16] children: not-inline
+ Box <(anonymous)> at [8,464] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,464] flex-item [0+0+0 17.453125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,464 9.703125x16] baseline: 13
+ "x"
+ frag 1 from GeneratedTextNode start: 0, length: 1, rect: [17.703125,464 7.75x16] baseline: 13
+ "4"
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,480] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 18, rect: [8,480 148.5x16] baseline: 13
+ "flex blank counter"
+ TextNode <#text> (not painted)
+ BlockContainer <ol> at [48,512] [0+0+40 744 0+0+0] [16+0+0 16 0+0+16] children: not-inline
+ ListItemBox <li.marker-blank> at [48,512] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 12, rect: [48,512 104.015625x16] baseline: 13
+ "blank marker"
+ ListItemMarkerBox <(anonymous)> at [48,520] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [BFC] children: inline
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.block-blank-alt> at [8,544] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: not-inline
+ BlockContainer <(anonymous)> at [8,544] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 33, rect: [8,544 268.59375x16] baseline: 13
+ "block blank counter with alt text"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,560] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <p.white-space> at [8,576] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: not-inline
+ BlockContainer <(anonymous)> at [8,576] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: inline
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,576] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 11, rect: [8,576 94.375x16] baseline: 13
+ "white space"
+ TextNode <#text> (not painted)
+ BlockContainer <p.empty> at [8,608] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: not-inline
+ BlockContainer <(anonymous)> at [8,608] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,608] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,608 44.375x16] baseline: 13
+ "empty"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x640] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/grid-runs-split-by-oof.txt b/Tests/LibWeb/Layout/expected/tree-builder/grid-runs-split-by-oof.txt
new file mode 100644
index 00000000000..c72c261b56e
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/grid-runs-split-by-oof.txt
@@ -0,0 +1,36 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 96 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 80 0+0+8] children: not-inline
+ Box <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] [GFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,8 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,24 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,8] positioned [0+0+0 57.28125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,8 57.28125x16] baseline: 13
+ "abspos"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 1, length: 1, rect: [8,40 8.890625x16] baseline: 13
+ "c"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,56] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: inline
+ frag 0 from Box start: 0, length: 0, rect: [8,56 9.46875x32] baseline: 13
+ Box <div> at [8,56] [0+0+0 9.46875 0+0+0] [0+0+0 32 0+0+0] [GFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,56] [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,56 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,56] positioned [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,72] [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,72 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x96] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/html-inside-svg-is-skipped.txt b/Tests/LibWeb/Layout/expected/tree-builder/html-inside-svg-is-skipped.txt
new file mode 100644
index 00000000000..ec6f5decf4f
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/html-inside-svg-is-skipped.txt
@@ -0,0 +1,27 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 116 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 100 0+0+8] children: inline
+ frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 200x100] baseline: 100
+ SVGSVGBox <svg#svg> at [8,8] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: inline
+ TextNode <#text> (not painted)
+ SVGGeometryBox <rect> at [0,0] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ SVGGraphicsBox <g#g> at [0,0] [0+0+0 5 0+0+0] [0+0+0 5 0+0+0] children: not-inline
+ SVGGeometryBox <rect> at [0,0] [0+0+0 5 0+0+0] [0+0+0 5 0+0+0] children: not-inline
+ SVGForeignObjectBox <foreignObject> at [0,0] [0+0+0 100 0+0+0] [0+0+0 50 0+0+0] [BFC] children: not-inline overflow: [0,0 107.953125x50]
+ BlockContainer <div> at [0,0] [0+0+0 100 0+0+0] [0+0+0 48 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [52.53125,16 44.65625x16] baseline: 13
+ "inside"
+ frag 1 from TextNode start: 7, length: 13, rect: [0,32 107.953125x16] baseline: 13
+ "foreignObject"
+ InlineNode <(anonymous)> at [0,0] [0+0+0 52.53125 0+0+0] [0+0+0 32 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 4, rect: [0,0 32.59375x16] baseline: 13
+ "html"
+ frag 0 from GeneratedTextNode start: 5, length: 6, rect: [0,16 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x116] (z-index: auto)
+ SC for SVGForeignObjectBox<foreignObject> [0,0 100x50] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/inline-children-of-fieldset-and-foreignobject.txt b/Tests/LibWeb/Layout/expected/tree-builder/inline-children-of-fieldset-and-foreignobject.txt
new file mode 100644
index 00000000000..d2195fc8964
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/inline-children-of-fieldset-and-foreignobject.txt
@@ -0,0 +1,29 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 151.59375 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 135.59375 0+0+8] children: not-inline
+ FieldSetBox <fieldset> at [24,15.59375] [2+2+12 752 12+2+2] [0+2+5.59375 16 10+2+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [24,15.59375] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [24,15.59375 40.140625x16] baseline: 13
+ "text "
+ TextNode <#text> (not painted)
+ InlineNode <span> at [64.140625,15.59375] [0+0+0 41.296875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [64.140625,15.59375 41.296875x16] baseline: 13
+ "inline"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,43.59375] [0+0+0 784 0+0+0] [0+0+0 100 0+0+0] children: inline
+ frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,43.59375 200x100] baseline: 100
+ SVGSVGBox <svg> at [8,43.59375] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline
+ SVGForeignObjectBox <foreignObject> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [0,0] [0+0+0 200 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [0,0 40.140625x16] baseline: 13
+ "text "
+ TextNode <#text> (not painted)
+ InlineNode <span> at [40.140625,0] [0+0+0 41.296875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [40.140625,0 41.296875x16] baseline: 13
+ "inline"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x151.59375] (z-index: auto)
+ SC for SVGForeignObjectBox<foreignObject> [0,0 200x100] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/inline-run-then-block-wraps-everything-including-floats.txt b/Tests/LibWeb/Layout/expected/tree-builder/inline-run-then-block-wraps-everything-including-floats.txt
new file mode 100644
index 00000000000..31ffe748b4f
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/inline-run-then-block-wraps-everything-including-floats.txt
@@ -0,0 +1,49 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 112 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 96 0+0+8] children: not-inline
+ BlockContainer <div#float-before-block> at [8,8] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [45.234375,8 40.140625x16] baseline: 13
+ "text "
+ TextNode <#text> (not painted)
+ InlineNode <span> at [85.375,8] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [85.375,8 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,8] floating [0+0+0 37.234375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,8 37.234375x16] baseline: 13
+ "float"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,24 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+ BlockContainer <div#abspos-before-block> at [8,40] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [8,40 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,56] positioned [0+0+0 57.28125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,56 57.28125x16] baseline: 13
+ "abspos"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,56 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+ BlockContainer <div#float-first> at [8,72] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [45.234375,72 32.140625x16] baseline: 13
+ "text"
+ BlockContainer <div> at [8,72] floating [0+0+0 37.234375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,72 37.234375x16] baseline: 13
+ "float"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,88 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x112] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/input-button-types-box-kinds.txt b/Tests/LibWeb/Layout/expected/tree-builder/input-button-types-box-kinds.txt
new file mode 100644
index 00000000000..aee9e0196c6
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/input-button-types-box-kinds.txt
@@ -0,0 +1,120 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 107 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 91 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 27 0+0+0] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [17,18 44.09375x14] baseline: 14
+ frag 1 from BlockContainer start: 0, length: 0, rect: [79.09375,18 45.6875x14] baseline: 14
+ frag 2 from BlockContainer start: 0, length: 0, rect: [142.78125,18 39.4375x14] baseline: 14
+ frag 3 from BlockContainer start: 0, length: 0, rect: [194.21875,10 44x23] baseline: 21
+ frag 4 from BlockContainer start: 0, length: 0, rect: [241.21875,15 207.546875x20] baseline: 14
+ BlockContainer <input> at [17,18] inline-block [0+2+7 44.09375 7+2+0] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,18] flex-container(column) [0+0+0 44.09375 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,18] flex-item [0+0+0 44.09375 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [17,18 44.09375x14] baseline: 11
+ BlockContainer <span> at [17,18] inline-block [0+0+0 44.09375 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [17,18 44.09375x14] baseline: 11
+ "button"
+ TextNode <#text> (not painted)
+ BlockContainer <input> at [79.09375,18] inline-block [0+2+7 45.6875 7+2+0] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [79.09375,18] flex-container(column) [0+0+0 45.6875 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [79.09375,18] flex-item [0+0+0 45.6875 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [79.09375,18 45.6875x14] baseline: 11
+ BlockContainer <span> at [79.09375,18] inline-block [0+0+0 45.6875 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [79.09375,18 45.6875x14] baseline: 11
+ "Submit"
+ TextNode <#text> (not painted)
+ BlockContainer <input> at [142.78125,18] inline-block [0+2+7 39.4375 7+2+0] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [142.78125,18] flex-container(column) [0+0+0 39.4375 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [142.78125,18] flex-item [0+0+0 39.4375 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [142.78125,18 39.4375x14] baseline: 11
+ BlockContainer <span> at [142.78125,18] inline-block [0+0+0 39.4375 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [142.78125,18 39.4375x14] baseline: 11
+ "Reset"
+ TextNode <#text> (not painted)
+ BlockContainer <input> at [194.21875,10] inline-block [0+1+2 44 2+1+0] [0+1+1 23 1+1+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [194.21875,10] flex-container(column) [0+0+0 44 0+0+0] [0+0+0 23 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [194.21875,10] flex-item [0+0+0 44 0+0+0] [0+0+0 23 0+0+0] [BFC] children: not-inline
+ Box <div> at [196.21875,14] flex-container(row) [0+0+2 40 2+0+0] [0+0+4 15 4+0+0] [FFC] children: not-inline
+ BlockContainer <div> at [197.21875,15] flex-item [0+1+0 38 0+1+0] [0+1+0 13 0+1+0] [BFC] children: not-inline
+ BlockContainer <input> at [241.21875,15] inline-block [0+0+0 207.546875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [241.21875,15] flex-container(column) [0+0+0 207.546875 0+0+0] [0+0+0 20 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [241.21875,15] flex-item [0+0+0 207.546875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [250.21875,18 78.65625x14] baseline: 14
+ BlockContainer <button> at [250.21875,18] inline-block [0+2+7 78.65625 7+2+0] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [250.21875,18] flex-container(column) [0+0+0 78.65625 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [250.21875,18] flex-item [0+0+0 78.65625 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 14, rect: [250.21875,18 78.65625x14] baseline: 11
+ "Select file..."
+ TextNode <#text> (not painted)
+ InlineNode <label> at [341.875,18] [0+0+4 106.890625 0+0+0] [0+0+0 14 0+0+0]
+ frag 0 from TextNode start: 0, length: 17, rect: [341.875,18 106.890625x14] baseline: 11
+ "No file selected."
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,35] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [8,37 35.3125x14] baseline: 11
+ BlockContainer <input> at [8,37] inline-block [0+0+0 35.3125 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ InlineNode <div> at [8,37] [0+0+0 35.3125 0+0+0] [0+0+0 14 0+0+0]
+ frag 0 from TextNode start: 0, length: 5, rect: [8,37 35.3125x14] baseline: 11
+ "image"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,51] [0+0+0 784 0+0+0] [0+0+0 24 0+0+0] children: inline
+ frag 0 from CheckBox start: 0, length: 0, rect: [12,56 13x13] baseline: 16
+ frag 1 from RadioButton start: 0, length: 0, rect: [33,57 12x12] baseline: 15
+ frag 2 from RangeInputBox start: 0, length: 0, rect: [50,53 129x16] baseline: 18
+ frag 3 from TextInputBox start: 0, length: 0, rect: [186,58 159.6875x14] baseline: 14
+ CheckBox <input> at [12,56] inline-block [4+0+0 13 0+0+3] [3+0+0 13 0+0+3] children: not-inline
+ RadioButton <input> at [33,57] inline-block [5+0+0 12 0+0+3] [3+0+0 12 0+0+0] children: not-inline
+ RangeInputBox <input> at [50,53] inline-block [2+0+0 129 0+0+2] [2+0+0 16 0+0+2] [BFC] children: not-inline
+ Box <div> at [50,53] flex-container(row) [0+0+0 129 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <div> at [50,59] positioned flex-item [0+0+0 129 0+0+0] [0+0+0 4 0+0+0] [BFC] children: not-inline
+ BlockContainer <div> at [50,59] positioned [0+0+0 64.5 0+0+0] [0+0+0 4 0+0+0] [BFC] children: not-inline
+ BlockContainer <div> at [114.5,61] positioned [64.5+0+0 16 0+0+48.5] [0+0+0 16 0+0+0] children: not-inline
+ TextInputBox <input> at [186,58] inline-block [0+2+3 159.6875 3+2+0] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ Box <div> at [186,58] flex-container(row) [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <div> at [186,58] flex-item [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 0, rect: [186,58 0x14] baseline: 11
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,75] [0+0+0 784 0+0+0] [0+0+0 24 0+0+0] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [12,90 0x0] baseline: 6
+ frag 1 from TextNode start: 0, length: 1, rect: [15,80 8x16] baseline: 13
+ " "
+ frag 2 from BlockContainer start: 0, length: 0, rect: [28,93 0x0] baseline: 3
+ frag 3 from TextNode start: 0, length: 1, rect: [31,80 8x16] baseline: 13
+ " "
+ frag 4 from BlockContainer start: 0, length: 0, rect: [41,77 129x16] baseline: 18
+ frag 5 from TextNode start: 0, length: 1, rect: [172,80 8x16] baseline: 13
+ " "
+ frag 6 from BlockContainer start: 0, length: 0, rect: [185,82 159.6875x14] baseline: 14
+ frag 7 from TextNode start: 0, length: 1, rect: [349.6875,80 8x16] baseline: 13
+ " "
+ frag 8 from BlockContainer start: 0, length: 0, rect: [366.6875,82 44.09375x14] baseline: 14
+ BlockContainer <input> at [12,90] inline-block [4+0+0 0 0+0+3] [3+0+0 0 0+0+3] [BFC] children: not-inline
+ TextNode <#text> (not painted)
+ BlockContainer <input> at [28,93] inline-block [5+0+0 0 0+0+3] [3+0+0 0 0+0+0] [BFC] children: not-inline
+ TextNode <#text> (not painted)
+ BlockContainer <input> at [41,77] inline-block [2+0+0 129 0+0+2] [2+0+0 16 0+0+2] [BFC] children: not-inline
+ Box <div> at [41,77] flex-container(row) [0+0+0 129 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <div> at [41,77] positioned flex-item [0+0+0 129 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ BlockContainer <div> at [41,77] positioned [0+0+0 64.5 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ BlockContainer <div> at [105.5,77] positioned [64.5+0+0 16 0+0+48.5] [0+0+0 16 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+ BlockContainer <input> at [185,82] inline-block [0+2+3 159.6875 3+2+0] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ Box <div> at [185,82] flex-container(row) [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <div> at [185,82] flex-item [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 0, rect: [185,82 0x14] baseline: 11
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <input> at [366.6875,82] inline-block [0+2+7 44.09375 7+2+0] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [366.6875,82] flex-container(column) [0+0+0 44.09375 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [366.6875,82] flex-item [0+0+0 44.09375 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [366.6875,82 44.09375x14] baseline: 11
+ BlockContainer <span> at [366.6875,82] inline-block [0+0+0 44.09375 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [366.6875,82 44.09375x14] baseline: 11
+ "button"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x107] (z-index: auto)
+ SC for BlockContainer<DIV> [114.5,61 16x16] (z-index: auto), has_transform
+ SC for BlockContainer<DIV> [105.5,77 16x16] (z-index: auto), has_transform
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/list-unit-mutation-shapes.txt b/Tests/LibWeb/Layout/expected/tree-builder/list-unit-mutation-shapes.txt
new file mode 100644
index 00000000000..c22b6807844
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/list-unit-mutation-shapes.txt
@@ -0,0 +1,118 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 273.59375 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 257.59375 0+0+8] children: not-inline
+ BlockContainer <div#split> at [8,8] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [8,8 36.6875x16] baseline: 13
+ "one "
+ TextNode <#text> (not painted)
+ InlineNode <span> at [44.6875,8] [0+0+0 28.4375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 3, rect: [44.6875,8 28.4375x16] baseline: 13
+ "two"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,24 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 1, length: 5, rect: [8,40 42.421875x16] baseline: 13
+ "three"
+ TextNode <#text> (not painted)
+ BlockContainer <div#trailing> at [8,56] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <div> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,56 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 1, length: 3, rect: [8,72 28.203125x16] baseline: 13
+ "run"
+ frag 1 from TextNode start: 0, length: 6, rect: [36.203125,72 56.109375x16] baseline: 13
+ " more "
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <i> at [92.3125,72] [0+0+0 38.453125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [92.3125,72 38.453125x16] baseline: 13
+ "italic"
+ TextNode <#text> (not painted)
+ BlockContainer <div#clearfix.clearfix> at [8,88] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <div> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,88 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,104] floating [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,104 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ TableWrapper <(anonymous)> at [8,120] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ Box <(anonymous)> at [8,120] table-box [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [TFC] children: not-inline
+ BlockContainer <div> at [8,120] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [17,123 71.0625x42] baseline: 42
+ BlockContainer <button#button> at [17,123] inline-block [0+2+7 71.0625 7+2+0] [0+2+1 42 1+2+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,123] flex-container(column) [0+0+0 71.0625 0+0+0] [0+0+0 42 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,123] flex-item [0+0+0 71.0625 0+0+0] [0+0+0 42 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [17,123] [0+0+0 71.0625 0+0+0] [0+0+0 14 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [17,123 36.671875x14] baseline: 11
+ "label "
+ TextNode <#text> (not painted)
+ InlineNode <span> at [53.671875,123] [0+0+0 34.390625 0+0+0] [0+0+0 14 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [53.671875,123 34.390625x14] baseline: 11
+ "inline"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [17,137] [0+0+0 71.0625 0+0+0] [0+0+0 14 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [35.578125,137 33.890625x14] baseline: 11
+ "block"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [17,151] [0+0+0 71.0625 0+0+0] [0+0+0 14 0+0+0] children: inline
+ frag 0 from TextNode start: 1, length: 4, rect: [42.109375,151 20.828125x14] baseline: 11
+ "tail"
+ TextNode <#text> (not painted)
+ FieldSetBox <fieldset#fieldset> at [24,175.59375] [2+2+12 752 12+2+2] [0+2+5.59375 46 10+2+0] [BFC] children: not-inline
+ LegendBox <legend> at [26,168] [0+0+2 46.703125 2+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [26,168 46.703125x16] baseline: 13
+ "legend"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [24,189.59375] [0+0+0 752 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [24,189.59375] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [24,189.59375 60.90625x16] baseline: 13
+ "content"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [24,205.59375] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [24,205.59375 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+ BlockContainer <div#cells> at [8,233.59375] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ TableWrapper <(anonymous)> at [8,233.59375] [0+0+0 27.703125 0+0+756.296875] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <(anonymous)> at [8,233.59375] table-box [0+0+0 27.703125 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,233.59375] table-row [0+0+0 27.703125 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div> at [8,233.59375] table-cell [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,233.59375 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [17.34375,233.59375] table-cell [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,233.59375 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [26.8125,233.59375] table-cell [0+0+0 8.890625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [26.8125,233.59375 8.890625x16] baseline: 13
+ "c"
+ TextNode <#text> (not painted)
+ Box <div#flex> at [8,249.59375] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,249.59375] flex-item [0+0+0 32.140625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [8,249.59375 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [40.140625,249.59375] flex-item [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [40.140625,249.59375 9.34375x16] baseline: 13
+ "s"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [49.484375,249.59375] flex-item [0+0+0 80.25 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 1, length: 9, rect: [49.484375,249.59375 80.25x16] baseline: 13
+ "more text"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [129.734375,249.59375] flex-item [0+0+0 32.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [129.734375,249.59375 32.34375x16] baseline: 13
+ "item"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x273.59375] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/marker-before-after-order.txt b/Tests/LibWeb/Layout/expected/tree-builder/marker-before-after-order.txt
new file mode 100644
index 00000000000..889fe1a59d9
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/marker-before-after-order.txt
@@ -0,0 +1,76 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 144 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 112 0+0+8] children: not-inline
+ BlockContainer <ul> at [48,16] [0+0+40 744 0+0+0] [16+0+0 112 0+0+16] children: not-inline
+ ListItemBox <li> at [48,16] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [100.53125,16 57.46875x16] baseline: 13
+ "outside"
+ ListItemMarkerBox <(anonymous)> at [34,16] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [34,16 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <(anonymous)> at [48,16] [0+0+0 52.53125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [48,16 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [158,16] [0+0+0 40.1875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [158,16 40.1875x16] baseline: 13
+ "after"
+ GeneratedTextNode <(anonymous)> (not painted)
+ ListItemBox <li> at [48,32] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ListItemMarkerBox start: 0, length: 0, rect: [48,32 13.84375x16] baseline: 13
+ frag 1 from TextNode start: 0, length: 6, rect: [114.375,32 44.65625x16] baseline: 13
+ "inside"
+ ListItemMarkerBox <(anonymous)> at [48,32] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [48,32 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <(anonymous)> at [61.84375,32] [0+0+0 52.53125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [61.84375,32 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [159.03125,32] [0+0+0 40.1875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [159.03125,32 40.1875x16] baseline: 13
+ "after"
+ GeneratedTextNode <(anonymous)> (not painted)
+ ListItemBox <li.block> at [48,48] [0+0+0 744 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ ListItemMarkerBox <(anonymous)> at [34,48] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [34,48 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [48,48] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [48,48 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [48,64] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 25, rect: [48,64 206.609375x16] baseline: 13
+ "outside with block before"
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [254.609375,64] [0+0+0 40.1875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [254.609375,64 40.1875x16] baseline: 13
+ "after"
+ GeneratedTextNode <(anonymous)> (not painted)
+ ListItemBox <li.block> at [48,80] [0+0+0 744 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [48,80] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ListItemMarkerBox start: 0, length: 0, rect: [48,80 13.84375x16] baseline: 13
+ ListItemMarkerBox <(anonymous)> at [48,80] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [48,80 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [48,96] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [48,96 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [48,112] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 24, rect: [48,112 193.796875x16] baseline: 13
+ "inside with block before"
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [241.796875,112] [0+0+0 40.1875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [241.796875,112 40.1875x16] baseline: 13
+ "after"
+ GeneratedTextNode <(anonymous)> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x144] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/marker-list-style-image.txt b/Tests/LibWeb/Layout/expected/tree-builder/marker-list-style-image.txt
new file mode 100644
index 00000000000..05e01d9ef4a
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/marker-list-style-image.txt
@@ -0,0 +1,29 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 401 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 369 0+0+8] children: not-inline
+ BlockContainer <ul> at [48,16] [0+0+40 744 0+0+0] [16+0+0 369 0+0+16] children: not-inline
+ ListItemBox <li.image> at [48,16] [0+0+0 744 0+0+0] [0+0+0 123 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 13, rect: [48,123 107.859375x16] baseline: 13
+ "outside image"
+ ListItemMarkerBox <(anonymous)> at [-72,16] [0+0+0 120 0+0+0] [0+0+0 120 0+0+0] [BFC] children: inline
+ frag 0 from ImageBox start: 0, length: 0, rect: [-72,16 120x120] baseline: 120
+ ImageBox <(anonymous)> at [-72,16] [0+0+0 120 0+0+0] [0+0+0 120 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+ ListItemBox <li.image> at [48,139] [0+0+0 744 0+0+0] [0+0+0 123 0+0+0] children: inline
+ frag 0 from ListItemMarkerBox start: 0, length: 0, rect: [48,139 120x120] baseline: 120
+ frag 1 from TextNode start: 0, length: 12, rect: [168,246 95.046875x16] baseline: 13
+ "inside image"
+ ListItemMarkerBox <(anonymous)> at [48,139] [0+0+0 120 0+0+0] [0+0+0 120 0+0+0] [BFC] children: inline
+ frag 0 from ImageBox start: 0, length: 0, rect: [48,139 120x120] baseline: 120
+ ImageBox <(anonymous)> at [48,139] [0+0+0 120 0+0+0] [0+0+0 120 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+ ListItemBox <li.image> at [48,262] [0+0+0 744 0+0+0] [0+0+0 123 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 20, rect: [48,369 168.796875x16] baseline: 13
+ "image with type none"
+ ListItemMarkerBox <(anonymous)> at [-72,262] [0+0+0 120 0+0+0] [0+0+0 120 0+0+0] [BFC] children: inline
+ frag 0 from ImageBox start: 0, length: 0, rect: [-72,262 120x120] baseline: 120
+ ImageBox <(anonymous)> at [-72,262] [0+0+0 120 0+0+0] [0+0+0 120 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x401] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/marker-on-flex-grid-table-list-items.txt b/Tests/LibWeb/Layout/expected/tree-builder/marker-on-flex-grid-table-list-items.txt
new file mode 100644
index 00000000000..a374c605cd3
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/marker-on-flex-grid-table-list-items.txt
@@ -0,0 +1,54 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 126 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 102 0+0+8] children: not-inline
+ TableWrapper <(anonymous)> at [8,8] [0+0+0 105.421875 0+0+678.578125] [0+0+0 22 0+0+0] [BFC] children: not-inline
+ Box <table> at [8,8] table-box [0+0+0 105.421875 0+0+0] [0+0+0 22 0+0+0] [TFC] children: not-inline
+ Box <tbody> at [10,10] table-row-group [0+0+0 101.421875 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ Box <tr> at [10,10] table-row [0+0+0 101.421875 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [10,10] table-cell [0+0+0 101.421875 0+0+0] [0+0+0 18 0+0+0] [BFC] children: not-inline
+ ListItemBox <td.li> at [11,11] [0+0+1 99.421875 1+0+0] [0+0+1 16 1+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 14, rect: [11,11 99.421875x16] baseline: 13
+ "cell list item"
+ ListItemMarkerBox <(anonymous)> at [-4,11] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [-4,11 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ Box <div> at [8,30] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ ListItemBox <div.li> at [8,30] flex-item [0+0+0 142.78125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 19, rect: [8,30 142.78125x16] baseline: 13
+ "flex item list item"
+ ListItemMarkerBox <(anonymous)> at [-6,30] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [-6,30 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <span.li> at [150.78125,30] flex-item [0+0+0 111.0625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 14, rect: [150.78125,30 111.0625x16] baseline: 13
+ "span list item"
+ ListItemMarkerBox <(anonymous)> at [136.78125,30] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [136.78125,30 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <ul> at [48,62] [0+0+40 744 0+0+0] [16+0+0 48 0+0+16] children: not-inline
+ Box <li> at [48,62] flex-container(row) [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [48,62] flex-item [0+0+0 45.890625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [48,62 45.890625x16] baseline: 13
+ "flex li"
+ TextNode <#text> (not painted)
+ Box <li> at [48,78] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] [GFC] children: not-inline
+ BlockContainer <(anonymous)> at [48,78] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [48,78 45.609375x16] baseline: 13
+ "grid li"
+ TextNode <#text> (not painted)
+ TableWrapper <(anonymous)> at [48,94] [0+0+0 55.421875 0+0+688.578125] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <li> at [48,94] table-box [0+0+0 55.421875 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [48,94] table-row [0+0+0 55.421875 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [48,94] table-cell [0+0+0 55.421875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 8, rect: [48,94 55.421875x16] baseline: 13
+ "table li"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x126] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/math-runs-split-by-oof.txt b/Tests/LibWeb/Layout/expected/tree-builder/math-runs-split-by-oof.txt
new file mode 100644
index 00000000000..83a0d7f4308
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/math-runs-split-by-oof.txt
@@ -0,0 +1,52 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 48 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 32 0+0+8] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [8,8 27.375x16] baseline: 13
+ BlockContainer <math> at [8,8] [0+0+0 27.375 0+0+0] [0+0+0 16 0+0+0] [MathFC] children: not-inline
+ BlockContainer <mrow> at [8,8] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,8 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <mi> at [8,8] positioned [0+0+0 5.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 2, rect: [8,8 5.84375x16] baseline: 13
+ "𝑥"
+ TextNode <#text> (not painted)
+ BlockContainer <mi> at [17.34375,8] [0+0+0 5.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 2, rect: [17.34375,8 5.84375x16] baseline: 13
+ "𝑦"
+ TextNode <#text> (not painted)
+ BlockContainer <mi> at [23.1875,8] floating [0+0+0 5.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 2, rect: [23.1875,8 5.84375x16] baseline: 13
+ "𝑧"
+ TextNode <#text> (not painted)
+ BlockContainer <mn> at [29.03125,8] [0+0+0 6.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [29.03125,8 6.34375x16] baseline: 13
+ "1"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 2, rect: [45.234375,24 17.34375x16] baseline: 13
+ "a "
+ frag 1 from TextNode start: 0, length: 1, rect: [72.046875,24 8.890625x16] baseline: 13
+ "c"
+ frag 2 from TextNode start: 0, length: 1, rect: [80.9375,24 7.859375x16] baseline: 13
+ "d"
+ TextNode <#text> (not painted)
+ InlineNode <span> at [62.578125,24] [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [62.578125,24 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,40] positioned [0+0+0 57.28125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,40 57.28125x16] baseline: 13
+ "abspos"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,24] floating [0+0+0 37.234375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,24 37.234375x16] baseline: 13
+ "float"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x48] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/mathml-mspace-has-no-children.txt b/Tests/LibWeb/Layout/expected/tree-builder/mathml-mspace-has-no-children.txt
new file mode 100644
index 00000000000..6879d2cc0ea
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/mathml-mspace-has-no-children.txt
@@ -0,0 +1,14 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 16 0+0+8] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [8,8 15.84375x16] baseline: 13
+ BlockContainer <math> at [8,8] [0+0+0 15.84375 0+0+0] [0+0+0 16 0+0+0] [MathFC] children: not-inline
+ BlockContainer <mspace> at [8,11] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] [MathFC] children: not-inline
+ BlockContainer <mi> at [18,8] [0+0+0 5.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 2, rect: [18,8 5.84375x16] baseline: 13
+ "𝑦"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x32] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/nested-slots.txt b/Tests/LibWeb/Layout/expected/tree-builder/nested-slots.txt
new file mode 100644
index 00000000000..f0edd87014c
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/nested-slots.txt
@@ -0,0 +1,21 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 72 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 48 0+0+8] children: not-inline
+ BlockContainer <div#outer-host> at [8,16] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <div#inner-host> at [8,16] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <p> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 12, rect: [8,16 106.75x16] baseline: 13
+ "inner shadow"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,48] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span#light> at [8,48] [0+0+0 101.421875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 13, rect: [8,48 101.421875x16] baseline: 13
+ "light content"
+ TextNode <#text> (not painted)
+ InlineNode <b> at [109.421875,48] [0+0+0 109.953125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 12, rect: [109.421875,48 109.953125x16] baseline: 13
+ "outer shadow"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x72] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/oof-joins-trailing-inline-wrapper.txt b/Tests/LibWeb/Layout/expected/tree-builder/oof-joins-trailing-inline-wrapper.txt
new file mode 100644
index 00000000000..cad5a3a7a8a
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/oof-joins-trailing-inline-wrapper.txt
@@ -0,0 +1,52 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 104 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 80 0+0+8] children: not-inline
+ BlockContainer <div#after-inline-only> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [45.234375,8 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,24] positioned [0+0+0 57.28125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,24 57.28125x16] baseline: 13
+ "abspos"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,8] floating [0+0+0 37.234375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,8 37.234375x16] baseline: 13
+ "float"
+ TextNode <#text> (not painted)
+ BlockContainer <div#after-wrapper> at [8,24] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [8,24 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,40 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 9, rect: [45.234375,56 80.25x16] baseline: 13
+ "more text"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,72] positioned [0+0+0 57.28125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,72 57.28125x16] baseline: 13
+ "abspos"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,56] floating [0+0+0 37.234375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,56 37.234375x16] baseline: 13
+ "float"
+ TextNode <#text> (not painted)
+ BlockContainer <div#after-block> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,72 40.671875x16] baseline: 13
+ "block"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,88] positioned [0+0+0 57.28125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,88 57.28125x16] baseline: 13
+ "abspos"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,88] floating [0+0+0 37.234375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,88 37.234375x16] baseline: 13
+ "float"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x104] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/popover-backdrop.txt b/Tests/LibWeb/Layout/expected/tree-builder/popover-backdrop.txt
new file mode 100644
index 00000000000..281217cebda
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/popover-backdrop.txt
@@ -0,0 +1,18 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 0 0+0+8] children: not-inline
+ BlockContainer <(anonymous)> at [0,0] positioned [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <div#block> at [0,0] positioned [0+0+0 120.5625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 14, rect: [0,0 120.5625x16] baseline: 13
+ "block backdrop"
+ TextNode <#text> (not painted)
+ BlockContainer <div#none> at [0,0] positioned [0+0+0 99.859375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 11, rect: [0,0 99.859375x16] baseline: 13
+ "no backdrop"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x16] (z-index: auto)
+ SC for BlockContainer(anonymous) [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<DIV>#block [0,0 120.5625x16] (z-index: auto)
+ SC for BlockContainer<DIV>#none [0,0 99.859375x16] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/pseudo-display-contents.txt b/Tests/LibWeb/Layout/expected/tree-builder/pseudo-display-contents.txt
new file mode 100644
index 00000000000..2e412b8542e
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/pseudo-display-contents.txt
@@ -0,0 +1,41 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 104 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 80 0+0+8] children: not-inline
+ BlockContainer <div.contents> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [60.53125,8 32.140625x16] baseline: 13
+ "text"
+ InlineNode <(anonymous)> at [8,8] [0+0+0 52.53125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [8,8 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [92.671875,8] [0+0+0 40.1875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [92.671875,8 40.1875x16] baseline: 13
+ "after"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <div> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span.contents> at [8,24] [0+0+0 130.4375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [60.53125,24 37.71875x16] baseline: 13
+ "span"
+ InlineNode <(anonymous)> at [8,24] [0+0+0 52.53125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [8,24 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [98.25,24] [0+0+0 40.1875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [98.25,24 40.1875x16] baseline: 13
+ "after"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <div.block-parent> at [8,40] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <(anonymous)> at [8,40] [0+0+0 52.53125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [8,40 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <p> at [8,72] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 11, rect: [8,72 83.515625x16] baseline: 13
+ "block child"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x104] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/pseudo-display-list-item-nested-marker-variants.txt b/Tests/LibWeb/Layout/expected/tree-builder/pseudo-display-list-item-nested-marker-variants.txt
new file mode 100644
index 00000000000..6c240b0273e
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/pseudo-display-list-item-nested-marker-variants.txt
@@ -0,0 +1,55 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 144 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 128 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ ListItemBox <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 4, rect: [8,8 32.34375x16] baseline: 13
+ "item"
+ ListItemMarkerBox <(anonymous)> at [-6,8] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [-6,8 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [8,24 53.21875x16] baseline: 13
+ "default"
+ TextNode <#text> (not painted)
+ BlockContainer <div.none> at [8,40] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ ListItemBox <(anonymous)> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 4, rect: [8,40 32.34375x16] baseline: 13
+ "item"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [8,56 38.296875x16] baseline: 13
+ "none"
+ TextNode <#text> (not painted)
+ BlockContainer <div.inside> at [8,72] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ ListItemBox <(anonymous)> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ListItemMarkerBox start: 0, length: 0, rect: [8,72 13.84375x16] baseline: 13
+ frag 1 from GeneratedTextNode start: 0, length: 4, rect: [21.84375,72 32.34375x16] baseline: 13
+ "item"
+ ListItemMarkerBox <(anonymous)> at [8,72] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,72 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,88 44.65625x16] baseline: 13
+ "inside"
+ TextNode <#text> (not painted)
+ BlockContainer <div.counter-style> at [8,104] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ ListItemBox <(anonymous)> at [8,104] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 4, rect: [8,104 32.34375x16] baseline: 13
+ "item"
+ ListItemMarkerBox <(anonymous)> at [-18,104] [0+0+0 26.125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [-18,104 26.125x16] baseline: 13
+ "III. "
+ GeneratedTextNode <(anonymous)> (not painted)
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,120] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 13, rect: [8,120 107.359375x16] baseline: 13
+ "counter style"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x144] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/pseudo-elements-of-table-column-displays.txt b/Tests/LibWeb/Layout/expected/tree-builder/pseudo-elements-of-table-column-displays.txt
new file mode 100644
index 00000000000..5e1860f7e89
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/pseudo-elements-of-table-column-displays.txt
@@ -0,0 +1,42 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 96 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 80 0+0+8] children: not-inline
+ BlockContainer <div.column-group> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ TableWrapper <(anonymous)> at [8,8] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ Box <(anonymous)> at [8,8] table-box [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [TFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] table-column-group [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,8 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div.column> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ TableWrapper <(anonymous)> at [8,24] [0+0+0 0 0+0+784] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ Box <(anonymous)> at [8,24] table-box [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [TFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,24] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,24 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ TableWrapper <(anonymous)> at [8,40] [0+0+0 8.890625 0+0+775.109375] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <div.column-group-in-table> at [8,40] table-box [0+0+0 8.890625 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,40] table-row [0+0+0 8.890625 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div> at [8,40] table-cell [0+0+0 8.890625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,40 8.890625x16] baseline: 13
+ "c"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,40] table-column-group [0+0+0 8.890625 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div.table-pseudo> at [8,56] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ TableWrapper <(anonymous)> at [8,56] [0+0+0 11.21875 0+0+772.78125] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <(anonymous)> at [8,56] table-box [0+0+0 11.21875 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,56] table-row [0+0+0 11.21875 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,56] table-cell [0+0+0 11.21875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,56 11.21875x16] baseline: 13
+ "w"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,72 7.859375x16] baseline: 13
+ "d"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x96] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/pseudo-elements-on-void-and-replaced.txt b/Tests/LibWeb/Layout/expected/tree-builder/pseudo-elements-on-void-and-replaced.txt
new file mode 100644
index 00000000000..13018e4b763
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/pseudo-elements-on-void-and-replaced.txt
@@ -0,0 +1,101 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 258 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 242 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ImageBox start: 0, length: 0, rect: [8,11 10x10] baseline: 10
+ ImageBox <img.p> at [8,11] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <img.p> at [8,24] [0+0+0 147.421875 0+0+0] [0+0+0 16 0+0+0]
+ InlineNode <(anonymous)> at [8,24] [0+0+0 52.53125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [8,24 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <div> at [60.53125,24] [0+0+0 54.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [60.53125,24 54.703125x16] baseline: 13
+ "broken"
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [115.234375,24] [0+0+0 40.1875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [115.234375,24 40.1875x16] baseline: 13
+ "after"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <div> at [8,40] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
+ frag 0 from TextInputBox start: 0, length: 0, rect: [13,43 159.6875x14] baseline: 14
+ TextInputBox <input.p> at [13,43] inline-block [0+2+3 159.6875 3+2+0] [0+2+1 14 1+2+0] [BFC] children: not-inline
+ Box <div> at [13,43] flex-container(row) [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <div> at [13,43] flex-item [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 0, rect: [13,43 0x14] baseline: 11
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,60] [0+0+0 784 0+0+0] [0+0+0 19 0+0+0] children: inline
+ frag 0 from CheckBox start: 0, length: 0, rect: [12,63 13x13] baseline: 16
+ CheckBox <input.p> at [12,63] inline-block [4+0+0 13 0+0+3] [3+0+0 13 0+0+3] children: not-inline
+ BlockContainer <div> at [8,79] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,79 9.34375x16] baseline: 13
+ "a"
+ frag 1 from TextNode start: 0, length: 1, rect: [8,95 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BreakNode <br.p> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <hr.p> at [9,120] [0+1+0 782 0+1+0] [8+1+0 16 0+1+8] [BFC] children: inline
+ InlineNode <(anonymous)> at [9,120] [0+0+0 52.53125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [9,120 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <(anonymous)> at [61.53125,120] [0+0+0 40.1875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [61.53125,120 40.1875x16] baseline: 13
+ "after"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <div> at [8,145] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from VideoBox start: 0, length: 0, rect: [8,148 20x10] baseline: 10
+ VideoBox <video.p> at [8,148] inline-block [0+0+0 20 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,161] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from NavigableContainerViewport start: 0, length: 0, rect: [10,163 20x10] baseline: 14
+ NavigableContainerViewport <iframe.p> at [10,163] [0+2+0 20 0+2+0] [0+2+0 10 0+2+0] children: not-inline (url: about:blank)
+ Viewport <#document> at [0,0] [0+0+0 20 0+0+0] [0+0+0 10 0+0+0] [BFC] children: not-inline overflow: [0,0 20x16]
+ BlockContainer <html> at [0,0] [0+0+0 20 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 4 0+0+8] [8+0+0 0 0+0+8] children: not-inline
+
+ BlockContainer <div> at [8,177] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [17,180 28.078125x14] baseline: 14
+ BlockContainer <select.p> at [17,180] inline-block [0+1+8 28.078125 8+1+0] [0+1+2 14 2+1+0] [BFC] children: not-inline
+ Box <div> at [17,180] positioned flex-container(row) [0+0+0 28.078125 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <div> at [17,180] flex-item [0+0+0 8.078125 0+0+20] [0+0+0 14 0+0+0] [BFC] children: not-inline
+ BlockContainer <div> at [17,180] [0+0+0 8.078125 0+0+0] [0+0+0 14 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17,180 8.078125x14] baseline: 11
+ "x"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [17,194] floating [0+0+0 8.078125 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ BlockContainer <div> at [17,194] [0+0+0 8.078125 0+0+0] [0+0+0 14 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17,194 8.078125x14] baseline: 11
+ "x"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [29.078125,179] positioned [0+0+0 16 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from SVGSVGBox start: 0, length: 0, rect: [29.078125,179 16x16] baseline: 16
+ SVGSVGBox <svg> at [29.078125,179] [0+0+0 16 0+0+0] [0+0+0 16 0+0+0] viewport-transform=[0.6666667 0 0 0.6666667 0 0] [SVG] children: not-inline
+ SVGGeometryBox <path> at [6,8.578125] [0+0+0 12 0+0+0] [0+0+0 7.421875 0+0+0] children: not-inline
+ BlockContainer <div> at [8,197] [0+0+0 784 0+0+0] [0+0+0 37 0+0+0] children: inline
+ frag 0 from TextAreaBox start: 0, length: 0, rect: [11,200 159.6875x28] baseline: 34
+ TextAreaBox <textarea.p> at [11,200] inline-block [0+1+2 159.6875 2+1+0] [0+1+2 28 2+1+0] [BFC] children: not-inline
+ Box <div> at [11,200] flex-container(row) [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inline
+ BlockContainer <div> at [11,200] flex-item [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 0, rect: [11,200 0x14] baseline: 11
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,234] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [8,234 160x16] baseline: 41
+ BlockContainer <progress.p> at [8,234] inline-block [0+0+0 160 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,234] [0+0+0 160 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <(anonymous)> at [8,234] [0+0+0 52.53125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [8,234 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <div> at [8,254] [0+0+0 160 0+0+0] [4+0+0 8 0+0+0] [BFC] children: not-inline
+ BlockContainer <div> at [8,254] [0+0+0 32 0+0+128] [0+0+0 8 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,262] [0+0+0 160 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <(anonymous)> at [8,262] [0+0+0 40.1875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [8,262 40.1875x16] baseline: 13
+ "after"
+ GeneratedTextNode <(anonymous)> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x258] (z-index: auto)
+ SC for BlockContainer<DIV> [8,254 32x8] (z-index: auto), has_transform
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/quotes-across-block-siblings.txt b/Tests/LibWeb/Layout/expected/tree-builder/quotes-across-block-siblings.txt
new file mode 100644
index 00000000000..ec6d09f549e
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/quotes-across-block-siblings.txt
@@ -0,0 +1,60 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 208 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 176 0+0+8] children: not-inline
+ BlockContainer <p.open> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 13, rect: [21.625,16 119.5625x16] baseline: 13
+ "opens a quote"
+ InlineNode <(anonymous)> at [8,16] [0+0+0 13.625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,16 13.625x16] baseline: 13
+ "<1"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.open> at [8,48] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 20, rect: [24.09375,48 178.671875x16] baseline: 13
+ "opens a nested quote"
+ InlineNode <(anonymous)> at [8,48] [0+0+0 16.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,48 16.09375x16] baseline: 13
+ "<2"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,80] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div> at [8,80] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <p.open> at [8,80] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 11, rect: [24.375,80 79.515625x16] baseline: 13
+ "third level"
+ InlineNode <(anonymous)> at [8,80] [0+0+0 16.375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,80 16.375x16] baseline: 13
+ "<3"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.close> at [8,112] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 12, rect: [8,112 96.296875x16] baseline: 13
+ "closes third"
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [104.296875,112] [0+0+0 17.640625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [104.296875,112 17.640625x16] baseline: 13
+ "3>"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <p.close> at [8,144] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 13, rect: [8,144 113.671875x16] baseline: 13
+ "closes second"
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [121.671875,144] [0+0+0 17.359375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [121.671875,144 17.359375x16] baseline: 13
+ "2>"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <p.open.close> at [8,176] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 21, rect: [24.09375,176 170.21875x16] baseline: 13
+ "balanced at level two"
+ InlineNode <(anonymous)> at [8,176] [0+0+0 16.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,176 16.09375x16] baseline: 13
+ "<2"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [194.3125,176] [0+0+0 17.359375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [194.3125,176 17.359375x16] baseline: 13
+ "2>"
+ GeneratedTextNode <(anonymous)> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x208] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/quotes-in-marker-before-children.txt b/Tests/LibWeb/Layout/expected/tree-builder/quotes-in-marker-before-children.txt
new file mode 100644
index 00000000000..dd3e32d7cf9
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/quotes-in-marker-before-children.txt
@@ -0,0 +1,61 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 112 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 80 0+0+8] children: not-inline
+ BlockContainer <ul> at [48,16] [0+0+40 744 0+0+0] [16+0+0 48 0+0+16] children: not-inline
+ ListItemBox <li.open> at [48,16] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ ListItemMarkerBox <(anonymous)> at [33,16] [0+0+0 14.5625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [33,16 14.5625x16] baseline: 13
+ "<<"
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <(anonymous)> at [48,16] [0+0+0 7.28125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [48,16 7.28125x16] baseline: 13
+ "<"
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <q> at [55.28125,16] [0+0+0 66.5 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 5, rect: [69.84375,16 34.84375x16] baseline: 13
+ "child"
+ InlineNode <(anonymous)> at [55.28125,16] [0+0+0 14.5625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [55.28125,16 14.5625x16] baseline: 13
+ "<<"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [104.6875,16] [0+0+0 17.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [104.6875,16 17.09375x16] baseline: 13
+ ">>"
+ GeneratedTextNode <(anonymous)> (not painted)
+ ListItemBox <li.close> at [48,32] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [48,32 32.140625x16] baseline: 13
+ "text"
+ ListItemMarkerBox <(anonymous)> at [26,32] [0+0+0 21.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [26,32 21.84375x16] baseline: 13
+ "<<<"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [80.140625,32] [0+0+0 25.640625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [80.140625,32 25.640625x16] baseline: 13
+ ">>>"
+ GeneratedTextNode <(anonymous)> (not painted)
+ ListItemBox <li> at [48,48] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ ListItemMarkerBox <(anonymous)> at [19,48] [0+0+0 29.125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 4, rect: [19,48 29.125x16] baseline: 13
+ "<<<<"
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <span.open> at [48,48] [0+0+0 59.5625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [69.84375,48 37.71875x16] baseline: 13
+ "span"
+ InlineNode <(anonymous)> at [48,48] [0+0+0 21.84375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [48,48 21.84375x16] baseline: 13
+ "<<<"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.open> at [8,80] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [37.125,80 40.1875x16] baseline: 13
+ "after"
+ InlineNode <(anonymous)> at [8,80] [0+0+0 29.125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 4, rect: [8,80 29.125x16] baseline: 13
+ "<<<<"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x112] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/quotes-in-markers-and-top-layer.txt b/Tests/LibWeb/Layout/expected/tree-builder/quotes-in-markers-and-top-layer.txt
new file mode 100644
index 00000000000..1ae885434e1
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/quotes-in-markers-and-top-layer.txt
@@ -0,0 +1,64 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 144 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 112 0+0+8] children: not-inline
+ BlockContainer <ul> at [48,16] [0+0+40 744 0+0+0] [16+0+0 48 0+0+16] children: not-inline
+ ListItemBox <li> at [48,16] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [48,16 36.03125x16] baseline: 13
+ "first"
+ ListItemMarkerBox <(anonymous)> at [34,16] [0+0+0 13.625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [34,16 13.625x16] baseline: 13
+ "<1"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,32] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ ListItemMarkerBox <(anonymous)> at [32,32] [0+0+0 16.375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [32,32 16.375x16] baseline: 13
+ "<3"
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <span.open> at [48,32] [0+0+0 70.875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [64.09375,32 54.78125x16] baseline: 13
+ "second"
+ InlineNode <(anonymous)> at [48,32] [0+0+0 16.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [48,32 16.09375x16] baseline: 13
+ "<2"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li.close> at [48,48] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [48,48 37.40625x16] baseline: 13
+ "third"
+ ListItemMarkerBox <(anonymous)> at [30,48] [0+0+0 17.640625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [30,48 17.640625x16] baseline: 13
+ "3>"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.open> at [8,80] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 10, rect: [24.375,80 73.1875x16] baseline: 13
+ "after list"
+ InlineNode <(anonymous)> at [8,80] [0+0+0 16.375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,80 16.375x16] baseline: 13
+ "<3"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.open> at [8,112] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 12, rect: [23.03125,112 92.109375x16] baseline: 13
+ "after dialog"
+ InlineNode <(anonymous)> at [8,112] [0+0+0 15.03125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,112 15.03125x16] baseline: 13
+ "<4"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [0,0] positioned [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <dialog#dialog> at [19,19] positioned [0+3+16 81.828125 16+3+0] [0+3+16 16 16+3+0] [BFC] children: inline
+ InlineNode <span.open> at [19,19] [0+0+0 81.828125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 9, rect: [34.734375,19 66.09375x16] baseline: 13
+ "in dialog"
+ InlineNode <(anonymous)> at [19,19] [0+0+0 15.734375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [19,19 15.734375x16] baseline: 13
+ "<5"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x144] (z-index: auto)
+ SC for BlockContainer(anonymous) [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<DIALOG>#dialog [19,19 81.828125x16] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/quotes-in-shadow-and-slots.txt b/Tests/LibWeb/Layout/expected/tree-builder/quotes-in-shadow-and-slots.txt
new file mode 100644
index 00000000000..0eec3b27a6c
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/quotes-in-shadow-and-slots.txt
@@ -0,0 +1,45 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 72 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 48 0+0+8] children: not-inline
+ BlockContainer <div#host> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [79.046875,8 8x16] baseline: 13
+ " "
+ frag 1 from TextNode start: 0, length: 1, rect: [156.171875,8 8x16] baseline: 13
+ " "
+ InlineNode <span.open> at [8,8] [0+0+0 71.046875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [21.625,8 57.421875x16] baseline: 13
+ "shadow"
+ InlineNode <(anonymous)> at [8,8] [0+0+0 13.625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,8 13.625x16] baseline: 13
+ "<1"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <span.close> at [87.046875,8] [0+0+0 69.125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 7, rect: [87.046875,8 54.234375x16] baseline: 13
+ "slotted"
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [141.28125,8] [0+0+0 14.890625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [141.28125,8 14.890625x16] baseline: 13
+ "1>"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <span.open> at [164.171875,8] [0+0+0 158.03125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 17, rect: [177.796875,8 144.40625x16] baseline: 13
+ "shadow after slot"
+ InlineNode <(anonymous)> at [164.171875,8] [0+0+0 13.625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [164.171875,8 13.625x16] baseline: 13
+ "<1"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.open> at [8,40] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 10, rect: [24.09375,40 84.046875x16] baseline: 13
+ "after host"
+ InlineNode <(anonymous)> at [8,40] [0+0+0 16.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,40 16.09375x16] baseline: 13
+ "<2"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x72] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/quotes-no-open-no-close.txt b/Tests/LibWeb/Layout/expected/tree-builder/quotes-no-open-no-close.txt
new file mode 100644
index 00000000000..aff676f93df
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/quotes-no-open-no-close.txt
@@ -0,0 +1,40 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 176 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 144 0+0+8] children: not-inline
+ BlockContainer <p.close-at-zero> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 19, rect: [17.703125,16 160.203125x16] baseline: 13
+ "close at depth zero"
+ InlineNode <(anonymous)> at [8,16] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 1, rect: [8,16 9.703125x16] baseline: 13
+ "x"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.no-open> at [8,48] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 13, rect: [8,48 117.8125x16] baseline: 13
+ "no-open-quote"
+ InlineNode <(anonymous)> at [8,48] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]
+ TextNode <#text> (not painted)
+ BlockContainer <p.open> at [8,80] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 18, rect: [24.09375,80 158.859375x16] baseline: 13
+ "open after no-open"
+ InlineNode <(anonymous)> at [8,80] [0+0+0 16.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,80 16.09375x16] baseline: 13
+ "<2"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.no-close> at [8,112] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 14, rect: [8,112 121.25x16] baseline: 13
+ "no-close-quote"
+ InlineNode <(anonymous)> at [8,112] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]
+ TextNode <#text> (not painted)
+ BlockContainer <p.open> at [8,144] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 19, rect: [24.09375,144 162.296875x16] baseline: 13
+ "open after no-close"
+ InlineNode <(anonymous)> at [8,144] [0+0+0 16.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,144 16.09375x16] baseline: 13
+ "<2"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x176] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/quotes-style-containment.txt b/Tests/LibWeb/Layout/expected/tree-builder/quotes-style-containment.txt
new file mode 100644
index 00000000000..39932239525
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/quotes-style-containment.txt
@@ -0,0 +1,47 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 176 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 144 0+0+8] children: not-inline
+ BlockContainer <p.open> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [21.625,16 44.53125x16] baseline: 13
+ "outer"
+ InlineNode <(anonymous)> at [8,16] [0+0+0 13.625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,16 13.625x16] baseline: 13
+ "<1"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.contained> at [8,48] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <p.open> at [8,48] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 16, rect: [24.09375,48 128.46875x16] baseline: 13
+ "inside contained"
+ InlineNode <(anonymous)> at [8,48] [0+0+0 16.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,48 16.09375x16] baseline: 13
+ "<2"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.open> at [8,80] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 22, rect: [24.375,80 176.890625x16] baseline: 13
+ "inside contained again"
+ InlineNode <(anonymous)> at [8,80] [0+0+0 16.375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,80 16.375x16] baseline: 13
+ "<3"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.open> at [8,112] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 15, rect: [24.09375,112 124x16] baseline: 13
+ "after contained"
+ InlineNode <(anonymous)> at [8,112] [0+0+0 16.09375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,112 16.09375x16] baseline: 13
+ "<2"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <p.close> at [8,144] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,144 41.546875x16] baseline: 13
+ "close"
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [49.546875,144] [0+0+0 17.359375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [49.546875,144 17.359375x16] baseline: 13
+ "2>"
+ GeneratedTextNode <(anonymous)> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x176] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/replaced-element-with-table-display-out-of-flow.txt b/Tests/LibWeb/Layout/expected/tree-builder/replaced-element-with-table-display-out-of-flow.txt
new file mode 100644
index 00000000000..76f707c381b
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/replaced-element-with-table-display-out-of-flow.txt
@@ -0,0 +1,45 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 76 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 58 0+0+8] children: not-inline
+ TableWrapper <(anonymous)> at [8,8] [0+0+0 42.140625 0+0+741.859375] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <div.table> at [8,8] table-box [0+0+0 42.140625 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,8] table-row [0+0+0 42.140625 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] table-cell [0+0+0 42.140625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [18,8 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ CanvasBox <canvas.float> at [8,8] floating [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ TableWrapper <(anonymous)> at [8,24] [0+0+0 32.140625 0+0+751.859375] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <div.table> at [8,24] table-box [0+0+0 32.140625 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,24] table-row [0+0+0 32.140625 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,24] table-cell [0+0+0 32.140625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [8,24 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ CanvasBox <canvas.abspos> at [40.140625,24] positioned [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ TableWrapper <(anonymous)> at [8,40] [0+0+0 10 0+0+774] [0+0+0 10 0+0+0] [BFC] children: not-inline
+ Box <div.table> at [8,40] table-box [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,40] table-row [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,40] table-cell [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] [BFC] children: not-inline
+ CanvasBox <canvas.float> at [8,40] floating [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ TableWrapper <(anonymous)> at [8,50] [0+0+0 10 0+0+774] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <div.table> at [8,50] table-box [0+0+0 10 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,50] table-row [0+0+0 10 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,50] table-cell [0+0+0 10 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from CanvasBox start: 0, length: 0, rect: [8,53 10x10] baseline: 10
+ CanvasBox <canvas> at [8,53] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,66] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ CanvasBox <canvas.abspos> at [8,66] positioned [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,66] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ CanvasBox <canvas.abspos> at [8,66] positioned [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,66] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ CanvasBox <canvas.abspos> at [8,66] positioned [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,66] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ CanvasBox <canvas.abspos> at [8,66] positioned [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,66] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ CanvasBox <canvas.float> at [8,66] floating [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,66] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ CanvasBox <canvas.float> at [18,66] floating [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x76] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/replaced-element-with-table-display.txt b/Tests/LibWeb/Layout/expected/tree-builder/replaced-element-with-table-display.txt
new file mode 100644
index 00000000000..efebe6925b2
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/replaced-element-with-table-display.txt
@@ -0,0 +1,26 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 122 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 106 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ ImageBox <img> at [8,8] [0+0+0 10 0+0+774] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,18] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ImageBox start: 0, length: 0, rect: [8,21 10x10] baseline: 10
+ ImageBox <img> at [8,21] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,34] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ImageBox start: 0, length: 0, rect: [8,37 10x10] baseline: 10
+ ImageBox <img> at [8,37] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,50] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ImageBox start: 0, length: 0, rect: [8,53 10x10] baseline: 10
+ ImageBox <img> at [8,53] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,66] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from CanvasBox start: 0, length: 0, rect: [8,69 10x10] baseline: 10
+ CanvasBox <canvas> at [8,69] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,82] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from CanvasBox start: 0, length: 0, rect: [8,85 10x10] baseline: 10
+ CanvasBox <canvas> at [8,85] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ BlockContainer <div> at [8,98] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from CanvasBox start: 0, length: 0, rect: [8,101 10x10] baseline: 10
+ CanvasBox <canvas> at [8,101] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x122] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/scroll-container-pseudo-and-marker.txt b/Tests/LibWeb/Layout/expected/tree-builder/scroll-container-pseudo-and-marker.txt
new file mode 100644
index 00000000000..55987172cd3
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/scroll-container-pseudo-and-marker.txt
@@ -0,0 +1,48 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 116 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 92 0+0+8] children: not-inline
+ BlockContainer <div.scroller> at [8,8] [0+0+0 784 0+0+0] [0+0+0 36 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 16, rect: [8,8 128.15625x16] baseline: 13
+ "scrolling before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,28] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [8,28 60.90625x16] baseline: 13
+ "content"
+ TextNode <#text> (not painted)
+ BlockContainer <ul> at [48,60] [0+0+40 744 0+0+0] [16+0+0 40 0+0+16] [BFC] children: not-inline overflow: [8,60 784x64]
+ ListItemBox <li> at [48,60] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [48,60 32.34375x16] baseline: 13
+ "item"
+ ListItemMarkerBox <(anonymous)> at [34,60] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [34,60 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,76] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [48,76 32.34375x16] baseline: 13
+ "item"
+ ListItemMarkerBox <(anonymous)> at [34,76] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [34,76 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,92] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [48,92 32.34375x16] baseline: 13
+ "item"
+ ListItemMarkerBox <(anonymous)> at [34,92] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [34,92 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,108] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [48,108 32.34375x16] baseline: 13
+ "item"
+ ListItemMarkerBox <(anonymous)> at [34,108] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [34,108 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x116] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/shadow-host-display-contents.txt b/Tests/LibWeb/Layout/expected/tree-builder/shadow-host-display-contents.txt
new file mode 100644
index 00000000000..6af4fbc5cbb
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/shadow-host-display-contents.txt
@@ -0,0 +1,34 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 128 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 112 0+0+8] children: not-inline
+ BlockContainer <div#parent> at [8,8] [0+0+0 784 0+0+0] [0+0+0 112 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [8,8] [0+0+0 52.53125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [8,8 52.53125x16] baseline: 13
+ "before"
+ TextNode <#text> (not painted)
+ InlineNode <span> at [60.53125,8] [0+0+0 106.71875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 13, rect: [60.53125,8 106.71875x16] baseline: 13
+ "shadow inline"
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,40] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 13, rect: [8,40 102.90625x16] baseline: 13
+ "slotted block"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [8,72] [0+0+0 103.53125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 14, rect: [8,72 103.53125x16] baseline: 13
+ "slotted inline"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 12, rect: [8,88 106.09375x16] baseline: 13
+ "shadow block"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,104] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [8,104] [0+0+0 40.1875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 5, rect: [8,104 40.1875x16] baseline: 13
+ "after"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x128] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/shadow-light-children-not-rendered.txt b/Tests/LibWeb/Layout/expected/tree-builder/shadow-light-children-not-rendered.txt
new file mode 100644
index 00000000000..752fcc68094
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/shadow-light-children-not-rendered.txt
@@ -0,0 +1,11 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 16 0+0+8] children: not-inline
+ BlockContainer <div#host> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [8,8] [0+0+0 96.796875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 11, rect: [8,8 96.796875x16] baseline: 13
+ "shadow only"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x32] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/slot-fallback-vs-assigned.txt b/Tests/LibWeb/Layout/expected/tree-builder/slot-fallback-vs-assigned.txt
new file mode 100644
index 00000000000..cba099604d6
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/slot-fallback-vs-assigned.txt
@@ -0,0 +1,17 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 48 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 32 0+0+8] children: not-inline
+ BlockContainer <div#host> at [8,8] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <i> at [8,8] [0+0+0 115.40625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 14, rect: [8,8 115.40625x16] baseline: 13
+ "named fallback"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [8,24] [0+0+0 127.5625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 16, rect: [8,24 127.5625x16] baseline: 13
+ "default assigned"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x48] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/slot-with-box.txt b/Tests/LibWeb/Layout/expected/tree-builder/slot-with-box.txt
new file mode 100644
index 00000000000..33bd0ffac6b
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/slot-with-box.txt
@@ -0,0 +1,46 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 130 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 114 0+0+8] children: not-inline
+ BlockContainer <div#block-slot> at [8,8] [0+0+0 784 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,8 52.53125x16] baseline: 13
+ "before"
+ TextNode <#text> (not painted)
+ BlockContainer <slot> at [9,25] [0+1+0 782 0+1+0] [0+1+0 16 0+1+0] children: inline
+ InlineNode <span> at [9,25] [0+0+0 66.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 8, rect: [9,25 66.34375x16] baseline: 13
+ "assigned"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,42] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,42 40.1875x16] baseline: 13
+ "after"
+ TextNode <#text> (not painted)
+ BlockContainer <div#inline-slot> at [8,58] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,58 52.53125x16] baseline: 13
+ "before"
+ frag 1 from TextNode start: 0, length: 5, rect: [126.875,58 40.1875x16] baseline: 13
+ "after"
+ TextNode <#text> (not painted)
+ InlineNode <slot> at [60.53125,58] [0+0+0 66.34375 0+0+0] [0+0+0 16 0+0+0]
+ InlineNode <span> at [60.53125,58] [0+0+0 66.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 8, rect: [60.53125,58 66.34375x16] baseline: 13
+ "assigned"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div#block-slot-fallback> at [8,74] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,74] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,74 52.53125x16] baseline: 13
+ "before"
+ TextNode <#text> (not painted)
+ BlockContainer <slot> at [8,90] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <i> at [8,90] [0+0+0 59.671875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 8, rect: [8,90 59.671875x16] baseline: 13
+ "fallback"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,106] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,106 40.1875x16] baseline: 13
+ "after"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x130] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/svg-clip-path-resource.txt b/Tests/LibWeb/Layout/expected/tree-builder/svg-clip-path-resource.txt
new file mode 100644
index 00000000000..fee2b1d21fa
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/svg-clip-path-resource.txt
@@ -0,0 +1,19 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 116 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 100 0+0+8] children: inline
+ frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 200x100] baseline: 100
+ SVGSVGBox <svg> at [8,8] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline
+ SVGGeometryBox <rect#by-attribute> at [0,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGClipBox <clipPath#c> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] children: not-inline
+ SVGGeometryBox <circle> at [5,5] [0+0+0 40 0+0+0] [0+0+0 40 0+0+0] children: not-inline
+ SVGGeometryBox <rect#by-css> at [60,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGClipBox <clipPath#c> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] children: not-inline
+ SVGGeometryBox <circle> at [5,5] [0+0+0 40 0+0+0] [0+0+0 40 0+0+0] children: not-inline
+ SVGGraphicsBox <g#group> at [120,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGGeometryBox <rect> at [120,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGClipBox <clipPath#c> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] children: not-inline
+ SVGGeometryBox <circle> at [5,5] [0+0+0 40 0+0+0] [0+0+0 40 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x116] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/svg-mask-shared-by-two-shapes.txt b/Tests/LibWeb/Layout/expected/tree-builder/svg-mask-shared-by-two-shapes.txt
new file mode 100644
index 00000000000..bec5d7e8307
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/svg-mask-shared-by-two-shapes.txt
@@ -0,0 +1,15 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 116 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 100 0+0+8] children: inline
+ frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 200x100] baseline: 100
+ SVGSVGBox <svg> at [8,8] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline
+ SVGGeometryBox <rect#first> at [0,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGMaskBox <mask#m> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] children: not-inline
+ SVGGeometryBox <rect> at [0,0] [0+0+0 40 0+0+0] [0+0+0 40 0+0+0] children: not-inline
+ SVGGeometryBox <rect#second> at [60,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGMaskBox <mask#m> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] children: not-inline
+ SVGGeometryBox <rect> at [0,0] [0+0+0 40 0+0+0] [0+0+0 40 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x116] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/svg-pattern-resource-and-href.txt b/Tests/LibWeb/Layout/expected/tree-builder/svg-pattern-resource-and-href.txt
new file mode 100644
index 00000000000..60711e1fae8
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/svg-pattern-resource-and-href.txt
@@ -0,0 +1,18 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 116 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 100 0+0+8] children: inline
+ frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 200x100] baseline: 100
+ SVGSVGBox <svg> at [8,8] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline
+ SVGGeometryBox <rect#fill> at [0,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGPatternBox <pattern#p> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [BFC] children: not-inline
+ SVGGeometryBox <rect> at [0,0] [0+0+0 5 0+0+0] [0+0+0 5 0+0+0] children: not-inline
+ SVGGeometryBox <rect#stroke> at [60,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGPatternBox <pattern#p> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [BFC] children: not-inline
+ SVGGeometryBox <rect> at [0,0] [0+0+0 5 0+0+0] [0+0+0 5 0+0+0] children: not-inline
+ SVGGeometryBox <rect#fill-and-stroke> at [120,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGPatternBox <pattern#p> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [BFC] children: not-inline
+ SVGGeometryBox <rect> at [0,0] [0+0+0 5 0+0+0] [0+0+0 5 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x116] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/svg-resource-cycles.txt b/Tests/LibWeb/Layout/expected/tree-builder/svg-resource-cycles.txt
new file mode 100644
index 00000000000..ed9ee714fb2
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/svg-resource-cycles.txt
@@ -0,0 +1,16 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 116 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 100 0+0+8] children: inline
+ frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 200x100] baseline: 100
+ SVGSVGBox <svg> at [8,8] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline
+ SVGGeometryBox <rect#mask-user> at [0,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGMaskBox <mask#m> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] children: not-inline
+ SVGGeometryBox <rect#self-referencing> at [0,0] [0+0+0 40 0+0+0] [0+0+0 40 0+0+0] children: not-inline
+ SVGGeometryBox <rect#pattern-user> at [60,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGGeometryBox <rect#clip-user> at [120,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGClipBox <clipPath#c> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] children: not-inline
+ SVGGeometryBox <rect> at [0,0] [0+0+0 30 0+0+0] [0+0+0 30 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x116] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/svg-resource-in-other-scope.txt b/Tests/LibWeb/Layout/expected/tree-builder/svg-resource-in-other-scope.txt
new file mode 100644
index 00000000000..c5bc5fd120c
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/svg-resource-in-other-scope.txt
@@ -0,0 +1,24 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 219 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 203 0+0+8] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 103 0+0+0] children: inline
+ frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 200x100] baseline: 100
+ frag 1 from TextNode start: 0, length: 1, rect: [208,95 8x16] baseline: 13
+ " "
+ frag 2 from SVGSVGBox start: 0, length: 0, rect: [216,108 0x0] baseline: 0
+ SVGSVGBox <svg> at [8,8] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline
+ SVGGeometryBox <rect#other-svg-user> at [0,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGMaskBox <mask#m> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] children: not-inline
+ SVGGeometryBox <rect> at [0,0] [0+0+0 40 0+0+0] [0+0+0 40 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+ SVGSVGBox <svg> at [216,108] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline
+ TextNode <#text> (not painted)
+ BlockContainer <div#host> at [8,111] [0+0+0 784 0+0+0] [0+0+0 100 0+0+0] children: inline
+ frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,111 200x100] baseline: 100
+ SVGSVGBox <svg> at [8,111] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline
+ SVGGeometryBox <rect#shadow-user> at [0,0] [0+0+0 50 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ SVGMaskBox <mask#shadow-mask> at [0,0] [0+0+0 200 0+0+0] [0+0+0 100 0+0+0] children: not-inline
+ SVGGeometryBox <circle> at [0,0] [0+0+0 40 0+0+0] [0+0+0 40 0+0+0] children: not-inline
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x219] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/svg-switch-first-renderable.txt b/Tests/LibWeb/Layout/expected/tree-builder/svg-switch-first-renderable.txt
new file mode 100644
index 00000000000..ccab99e666c
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/svg-switch-first-renderable.txt
@@ -0,0 +1,18 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 116 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 100 0+0+8] children: inline
+ frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 100x100] baseline: 100
+ SVGSVGBox <svg#svg> at [8,8] [0+0+0 100 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline
+ SVGGraphicsBox <switch#non-svg-first> at [0,0] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ SVGGeometryBox <rect#chosen-1> at [0,0] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0] children: not-inline
+ SVGGraphicsBox <switch#hidden-first> at [0,0] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ SVGGraphicsBox <switch#conditional-attributes> at [0,0] [0+0+0 5 0+0+0] [0+0+0 5 0+0+0] children: not-inline
+ SVGGraphicsBox <g#chosen-3> at [0,0] [0+0+0 5 0+0+0] [0+0+0 5 0+0+0] children: not-inline
+ SVGGeometryBox <rect> at [0,0] [0+0+0 5 0+0+0] [0+0+0 5 0+0+0] children: not-inline
+ SVGGraphicsBox <switch#text-and-comments> at [0,7.203125] [0+0+0 65.25 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ SVGTextBox <text#chosen-4> at [0,7.203125] [0+0+0 65.25 0+0+0] [0+0+0 16 0+0+0] children: inline
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x116] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/svg-text-tspan-textpath.txt b/Tests/LibWeb/Layout/expected/tree-builder/svg-text-tspan-textpath.txt
new file mode 100644
index 00000000000..2312571aaa5
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/svg-text-tspan-textpath.txt
@@ -0,0 +1,22 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 116 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 100 0+0+8] children: inline
+ frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 300x100] baseline: 100
+ SVGSVGBox <svg> at [8,8] [0+0+0 300 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline
+ SVGTextBox <text> at [10,7.203125] [0+0+0 117.359375 0+0+0] [0+0+0 16 0+0+0] children: inline
+ TextNode <#text> (not painted)
+ SVGTextBox <tspan> at [82.78125,7.203125] [0+0+0 44.578125 0+0+0] [0+0+0 16 0+0+0] children: inline
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ SVGGraphicsBox <a> (not painted) children: inline
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ SVGTextBox <text> at [10.921875,67.6875] [0+0+0 79.453125 0+0+0] [0+0+0 13.0625 0+0+0] children: not-inline
+ SVGTextPathBox <textPath> at [10.921875,67.6875] [0+0+0 79.453125 0+0+0] [0+0+0 13.0625 0+0+0] children: inline
+ TextNode <#text> (not painted)
+ SVGTextBox <tspan> (not painted) children: inline
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x116] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/table-caption-and-colgroup-order.txt b/Tests/LibWeb/Layout/expected/tree-builder/table-caption-and-colgroup-order.txt
new file mode 100644
index 00000000000..ab52ead895a
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/table-caption-and-colgroup-order.txt
@@ -0,0 +1,46 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 162 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 146 0+0+8] children: not-inline
+ TableWrapper <(anonymous)> at [8,8] [0+0+0 59.046875 0+0+724.953125] [0+0+0 146 0+0+0] [BFC] children: not-inline
+ Box <table> at [8,40] table-box [0+0+0 59.046875 0+0+0] [0+0+0 82 0+0+0] [TFC] children: not-inline
+ Box <tfoot> at [10,102] table-footer-group [0+0+0 55.046875 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ Box <tr> at [10,102] table-row [0+0+0 55.046875 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ BlockContainer <td> at [11,103] table-cell [0+0+1 53.046875 1+0+0] [0+0+1 16 1+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [11,103 34.015625x16] baseline: 13
+ "foot"
+ TextNode <#text> (not painted)
+ Box <tbody> at [10,62] table-row-group [0+0+0 55.046875 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ Box <tr> at [10,62] table-row [0+0+0 55.046875 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ BlockContainer <td> at [11,63] table-cell [0+0+1 53.046875 1+0+0] [0+0+1 16 1+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [11,63 49.203125x16] baseline: 13
+ "body 1"
+ TextNode <#text> (not painted)
+ BlockContainer <caption> at [8,8] [0+0+0 59.046875 0+0+0] [0+0+0 32 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [19.5,8 36.03125x16] baseline: 13
+ "first"
+ frag 1 from TextNode start: 6, length: 7, rect: [8,24 59.046875x16] baseline: 13
+ "caption"
+ TextNode <#text> (not painted)
+ Box <thead> at [10,42] table-header-group [0+0+0 55.046875 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ Box <tr> at [10,42] table-row [0+0+0 55.046875 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ BlockContainer <td> at [11,43] table-cell [0+0+1 53.046875 1+0+0] [0+0+1 16 1+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [11,43 35.21875x16] baseline: 13
+ "head"
+ TextNode <#text> (not painted)
+ BlockContainer <colgroup> at [10,42] table-column-group [0+0+0 55.046875 0+0+0] [0+0+0 78 0+0+0] children: not-inline
+ BlockContainer <col> at [10,42] [0+0+0 55.046875 0+0+0] [0+0+0 78 0+0+0] children: not-inline
+ Box <tbody> at [10,82] table-row-group [0+0+0 55.046875 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ Box <tr> at [10,82] table-row [0+0+0 55.046875 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ BlockContainer <td> at [11,83] table-cell [0+0+1 53.046875 1+0+0] [0+0+1 16 1+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [11,83 51.671875x16] baseline: 13
+ "body 2"
+ TextNode <#text> (not painted)
+ BlockContainer <caption> at [8,122] [0+0+0 59.046875 0+0+0] [0+0+0 32 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [9.46875,122 56.109375x16] baseline: 13
+ "bottom"
+ frag 1 from TextNode start: 7, length: 7, rect: [8,138 59.046875x16] baseline: 13
+ "caption"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x162] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/table-column-children-removed.txt b/Tests/LibWeb/Layout/expected/tree-builder/table-column-children-removed.txt
new file mode 100644
index 00000000000..8cca59fec07
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/table-column-children-removed.txt
@@ -0,0 +1,37 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 70 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 54 0+0+8] children: not-inline
+ TableWrapper <(anonymous)> at [8,8] [0+0+0 26.078125 0+0+757.921875] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <div> at [8,8] table-box [0+0+0 26.078125 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 26.078125 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div> at [34.078125,8] table-column-group [0+0+0 0 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div> at [34.078125,8] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ Box <(anonymous)> at [8,8] table-row [0+0+0 26.078125 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div> at [8,8] table-cell [0+0+0 26.078125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [8,8 26.078125x16] baseline: 13
+ "cell"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [34.078125,8] table-cell [0+0+0 0 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 1, length: 4, rect: [8,24 32.140625x16] baseline: 13
+ "text"
+ TextNode <#text> (not painted)
+ InlineNode <span> at [40.140625,24] [0+0+0 137.3125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 16, rect: [40.140625,24 137.3125x16] baseline: 13
+ "span in colgroup"
+ TextNode <#text> (not painted)
+ TableWrapper <(anonymous)> at [8,40] [0+0+0 34.078125 0+0+749.921875] [0+0+0 22 0+0+0] [BFC] children: not-inline
+ Box <table> at [8,40] table-box [0+0+0 34.078125 0+0+0] [0+0+0 22 0+0+0] [TFC] children: not-inline
+ BlockContainer <colgroup> at [10,42] table-column-group [0+0+0 28.078125 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ BlockContainer <colgroup> at [40.078125,42] table-column-group [0+0+0 0 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ BlockContainer <col> at [40.078125,42] [0+0+0 0 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ Box <tbody> at [10,42] table-row-group [0+0+0 30.078125 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ Box <tr> at [10,42] table-row [0+0+0 30.078125 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ BlockContainer <td> at [11,43] table-cell [0+0+1 26.078125 1+0+0] [0+0+1 16 1+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [11,43 26.078125x16] baseline: 13
+ "cell"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [40.078125,42] table-cell [0+0+0 0 0+0+0] [0+0+0 18 0+0+0] [BFC] children: not-inline
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x70] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/table-loose-cells-in-inline.txt b/Tests/LibWeb/Layout/expected/tree-builder/table-loose-cells-in-inline.txt
new file mode 100644
index 00000000000..52ea7b36d6c
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/table-loose-cells-in-inline.txt
@@ -0,0 +1,64 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 112 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 96 0+0+8] children: not-inline
+ BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [8,8] [0+0+0 27.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,8 9.34375x16] baseline: 13
+ "a"
+ frag 1 from TableWrapper start: 0, length: 0, rect: [17.34375,8 9.46875x16] baseline: 13
+ frag 2 from TextNode start: 0, length: 1, rect: [26.8125,8 8.890625x16] baseline: 13
+ "c"
+ TextNode <#text> (not painted)
+ TableWrapper <(anonymous)> at [17.34375,8] inline-block [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <(anonymous)> at [17.34375,8] inline-table table-box [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [17.34375,8] table-row [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <span.c> at [17.34375,8] table-cell [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,8 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,24] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,24 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ TableWrapper <(anonymous)> at [8,40] [0+0+0 9.46875 0+0+774.53125] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <(anonymous)> at [8,40] table-box [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,40] table-row [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div.c> at [8,40] table-cell [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,40 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,56 8.890625x16] baseline: 13
+ "c"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,72] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: inline
+ InlineNode <span> at [8,72] [0+0+0 36.421875 0+0+0] [0+0+0 32 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,72 9.34375x16] baseline: 13
+ "a"
+ frag 1 from TableWrapper start: 0, length: 0, rect: [17.34375,72 18.359375x32] baseline: 13
+ frag 2 from TextNode start: 0, length: 1, rect: [35.703125,72 8.71875x16] baseline: 13
+ "e"
+ TextNode <#text> (not painted)
+ TableWrapper <(anonymous)> at [17.34375,72] inline-block [0+0+0 18.359375 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline
+ Box <(anonymous)> at [17.34375,72] inline-table table-box [0+0+0 18.359375 0+0+0] [0+0+0 32 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [17.34375,72] table-row [0+0+0 18.359375 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <span.c> at [17.34375,72] table-cell [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,72 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <span.c> at [26.8125,72] table-cell [0+0+0 8.890625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [26.8125,72 8.890625x16] baseline: 13
+ "c"
+ TextNode <#text> (not painted)
+ Box <span> at [17.34375,88] table-row [0+0+0 18.359375 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [17.34375,88] table-cell [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,88 7.859375x16] baseline: 13
+ "d"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [26.8125,88] table-cell [0+0+0 8.890625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x112] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/table-parts-in-flex-and-grid.txt b/Tests/LibWeb/Layout/expected/tree-builder/table-parts-in-flex-and-grid.txt
new file mode 100644
index 00000000000..3b50e392e1e
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/table-parts-in-flex-and-grid.txt
@@ -0,0 +1,33 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 80 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 64 0+0+8] children: not-inline
+ Box <div> at [8,8] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <div> at [8,8] flex-item [0+0+0 30.40625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 3, rect: [8,8 30.40625x16] baseline: 13
+ "row"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [38.40625,8] flex-item [0+0+0 26.078125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [38.40625,8 26.078125x16] baseline: 13
+ "cell"
+ TextNode <#text> (not painted)
+ Box <div> at [8,24] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] [GFC] children: not-inline
+ BlockContainer <div> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,24 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,40 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ Box <div> at [8,56] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <span> at [8,56] flex-item [0+0+0 174.984375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ TableWrapper <(anonymous)> at [8,56] [0+0+0 174.984375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <(anonymous)> at [8,56] table-box [0+0+0 174.984375 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,56] table-row [0+0+0 174.984375 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <span> at [8,56] table-cell [0+0+0 174.984375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 24, rect: [8,56 174.984375x16] baseline: 13
+ "cell in inline flex item"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x80] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/table-parts-through-display-contents-and-slots.txt b/Tests/LibWeb/Layout/expected/tree-builder/table-parts-through-display-contents-and-slots.txt
new file mode 100644
index 00000000000..fccb0be799b
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/table-parts-through-display-contents-and-slots.txt
@@ -0,0 +1,39 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 70 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 54 0+0+8] children: not-inline
+ TableWrapper <(anonymous)> at [8,8] [0+0+0 217.265625 0+0+566.734375] [0+0+0 22 0+0+0] [BFC] children: not-inline
+ Box <table> at [8,8] table-box [0+0+0 217.265625 0+0+0] [0+0+0 22 0+0+0] [TFC] children: not-inline
+ Box <tbody> at [10,10] table-row-group [0+0+0 213.265625 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ Box <tr> at [10,10] table-row [0+0+0 213.265625 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ BlockContainer <td> at [11,11] table-cell [0+0+1 36.03125 1+0+0] [0+0+1 16 1+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [11,11 36.03125x16] baseline: 13
+ "first"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [50.03125,10] table-cell [0+0+0 173.234375 0+0+0] [0+0+0 18 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [50.03125,10] [0+0+0 173.234375 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [50.03125,10] [0+0+0 173.234375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 21, rect: [50.03125,10 173.234375x16] baseline: 13
+ "contents cell content"
+ TextNode <#text> (not painted)
+ TableWrapper <(anonymous)> at [8,30] [0+0+0 18.8125 0+0+765.1875] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <div> at [8,30] table-box [0+0+0 18.8125 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <div> at [8,30] table-row [0+0+0 18.8125 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div> at [8,30] table-cell [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,30 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [17.34375,30] table-cell [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,30 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <div#host> at [8,46] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ TableWrapper <(anonymous)> at [8,46] [0+0+0 92.640625 0+0+691.359375] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <div> at [8,46] table-box [0+0+0 92.640625 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <div> at [8,46] table-row [0+0+0 92.640625 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div> at [8,46] table-cell [0+0+0 92.640625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 11, rect: [8,46 92.640625x16] baseline: 13
+ "slotted row"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x70] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/table-pseudo-elements-as-parts.txt b/Tests/LibWeb/Layout/expected/tree-builder/table-pseudo-elements-as-parts.txt
new file mode 100644
index 00000000000..771bd563e26
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/table-pseudo-elements-as-parts.txt
@@ -0,0 +1,36 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 74 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 58 0+0+8] children: not-inline
+ TableWrapper <(anonymous)> at [8,8] [0+0+0 230.03125 0+0+553.96875] [0+0+0 58 0+0+0] [BFC] children: not-inline
+ Box <table> at [8,8] table-box [0+0+0 230.03125 0+0+0] [0+0+0 58 0+0+0] [TFC] children: not-inline
+ Box <tbody> at [10,10] table-row-group [0+0+0 226.03125 0+0+0] [0+0+0 36 0+0+0] children: not-inline
+ Box <(anonymous)> at [10,10] table-row [0+0+0 226.03125 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [10,10] table-cell [0+0+0 106.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [10,10] [0+0+0 106.46875 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <(anonymous)> at [10,10] [0+0+0 106.46875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 12, rect: [10,10 106.46875x16] baseline: 13
+ "group before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [118.46875,10] table-cell [0+0+0 117.5625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <tr> at [10,28] table-row [0+0+0 226.03125 0+0+0] [0+0+0 18 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [10,28] table-cell [0+0+0 106.46875 0+0+0] [0+0+0 18 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 11, rect: [10,28 86.609375x16] baseline: 13
+ "cell before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <td> at [119.46875,29] table-cell [0+0+1 115.5625 1+0+0] [0+0+1 16 1+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [119.46875,29 26.078125x16] baseline: 13
+ "cell"
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [145.546875,29] [0+0+0 89.484375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 12, rect: [145.546875,29 89.484375x16] baseline: 13
+ "inline after"
+ GeneratedTextNode <(anonymous)> (not painted)
+ Box <(anonymous)> at [10,48] table-row [0+0+0 226.03125 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [10,48] table-cell [0+0+0 106.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 9, rect: [10,48 78.59375x16] baseline: 13
+ "row after"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [118.46875,48] table-cell [0+0+0 117.5625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x74] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/table-whitespace-between-parts.txt b/Tests/LibWeb/Layout/expected/tree-builder/table-whitespace-between-parts.txt
new file mode 100644
index 00000000000..d709122a0fa
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/table-whitespace-between-parts.txt
@@ -0,0 +1,53 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 96 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 80 0+0+8] children: not-inline
+ TableWrapper <(anonymous)> at [8,8] [0+0+0 18.8125 0+0+765.1875] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <div.t> at [8,8] table-box [0+0+0 18.8125 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <div.rg> at [8,8] table-row-group [0+0+0 18.8125 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ Box <div.r> at [8,8] table-row [0+0+0 18.8125 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div.c> at [8,8] table-cell [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,8 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div.c> at [17.34375,8] table-cell [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,8 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ TableWrapper <(anonymous)> at [8,24] [0+0+0 78.4375 0+0+705.5625] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <div.t> at [8,24] table-box [0+0+0 78.4375 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,24] table-row [0+0+0 78.4375 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div.c> at [8,24] table-cell [0+0+0 43.015625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,24 43.015625x16] baseline: 13
+ "loose"
+ TextNode <#text> (not painted)
+ BlockContainer <div.c> at [51.015625,24] table-cell [0+0+0 35.421875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [51.015625,24 35.421875x16] baseline: 13
+ "cells"
+ TextNode <#text> (not painted)
+ TableWrapper <(anonymous)> at [8,40] [0+0+0 41.296875 0+0+742.703125] [0+0+0 32 0+0+0] [BFC] children: not-inline
+ Box <div.t> at [8,40] table-box [0+0+0 41.296875 0+0+0] [0+0+0 32 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,40] table-row [0+0+0 41.296875 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,40] table-cell [0+0+0 41.296875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,40] [0+0+0 41.296875 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [8,40] [0+0+0 41.296875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [8,40 41.296875x16] baseline: 13
+ "inline"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ Box <div.r> at [8,56] table-row [0+0+0 41.296875 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div.c> at [8,56] table-cell [0+0+0 41.296875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [8,56 26.078125x16] baseline: 13
+ "cell"
+ TextNode <#text> (not painted)
+ TableWrapper <(anonymous)> at [8,72] [0+0+0 134.390625 0+0+649.609375] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <(anonymous)> at [8,72] table-box [0+0+0 134.390625 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <div.r> at [8,72] table-row [0+0+0 134.390625 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div.c> at [8,72] table-cell [0+0+0 134.390625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 15, rect: [8,72 134.390625x16] baseline: 13
+ "anonymous table"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,88] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: inline
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x96] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/top-layer-member-in-shadow-tree.txt b/Tests/LibWeb/Layout/expected/tree-builder/top-layer-member-in-shadow-tree.txt
new file mode 100644
index 00000000000..997db80f0c4
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/top-layer-member-in-shadow-tree.txt
@@ -0,0 +1,26 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 48 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 16 0+0+8] children: not-inline
+ BlockContainer <div#host> at [8,16] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <div> at [8,16] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline
+ BlockContainer <p> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [8,16 60.90625x16] baseline: 13
+ "content"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [0,0] positioned [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <dialog#shadow-dialog> at [19,19] positioned [0+3+16 109.34375 16+3+0] [0+3+16 16 16+3+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 13, rect: [19,19 109.34375x16] baseline: 13
+ "shadow dialog"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [0,0] positioned [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <dialog#slotted-dialog> at [19,19] positioned [0+3+16 106.15625 16+3+0] [0+3+16 16 16+3+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 14, rect: [19,19 106.15625x16] baseline: 13
+ "slotted dialog"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x48] (z-index: auto)
+ SC for BlockContainer(anonymous) [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<DIALOG>#shadow-dialog [19,19 109.34375x16] (z-index: auto)
+ SC for BlockContainer(anonymous) [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<DIALOG>#slotted-dialog [19,19 106.15625x16] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/top-layer-member-inside-display-none.txt b/Tests/LibWeb/Layout/expected/tree-builder/top-layer-member-inside-display-none.txt
new file mode 100644
index 00000000000..84cdd49b4ba
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/top-layer-member-inside-display-none.txt
@@ -0,0 +1,17 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 48 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 16 0+0+8] children: not-inline
+ BlockContainer <p> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [8,16 60.90625x16] baseline: 13
+ "content"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [0,0] positioned [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <dialog#visible-dialog> at [19,19] positioned [0+3+16 49.09375 16+3+0] [0+3+16 16 16+3+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [19,19 49.09375x16] baseline: 13
+ "visible"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x48] (z-index: auto)
+ SC for BlockContainer(anonymous) [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<DIALOG>#visible-dialog [19,19 49.09375x16] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/top-layer-order-dialog-popover.txt b/Tests/LibWeb/Layout/expected/tree-builder/top-layer-order-dialog-popover.txt
new file mode 100644
index 00000000000..e9bbe0ef70e
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/top-layer-order-dialog-popover.txt
@@ -0,0 +1,31 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 48 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 16 0+0+8] children: not-inline
+ BlockContainer <p> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [8,16 60.90625x16] baseline: 13
+ "content"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [0,0] positioned [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <dialog#second> at [0,0] positioned [0+0+0 106.703125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 13, rect: [0,0 106.703125x16] baseline: 13
+ "second dialog"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [0,0] positioned [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <div#popover> at [0,0] positioned [0+0+0 65.3125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [0,0 65.3125x16] baseline: 13
+ "popover"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [0,0] positioned [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <dialog#first> at [0,0] positioned [0+0+0 87.953125 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 12, rect: [0,0 87.953125x16] baseline: 13
+ "first dialog"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x48] (z-index: auto)
+ SC for BlockContainer(anonymous) [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<DIALOG>#second [0,0 106.703125x16] (z-index: auto)
+ SC for BlockContainer(anonymous) [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<DIV>#popover [0,0 65.3125x16] (z-index: auto)
+ SC for BlockContainer(anonymous) [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<DIALOG>#first [0,0 87.953125x16] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/ua-shadow-details-content.txt b/Tests/LibWeb/Layout/expected/tree-builder/ua-shadow-details-content.txt
new file mode 100644
index 00000000000..2ddeaf25a70
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/ua-shadow-details-content.txt
@@ -0,0 +1,37 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 64 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 48 0+0+8] children: not-inline
+ BlockContainer <details> at [8,8] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ ListItemBox <summary> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ListItemMarkerBox start: 0, length: 0, rect: [8,8 13.84375x16] baseline: 13
+ frag 1 from TextNode start: 0, length: 12, rect: [21.84375,8 114.96875x16] baseline: 13
+ "open summary"
+ ListItemMarkerBox <(anonymous)> at [8,8] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,8 13.84375x16] baseline: 13
+ "▼ "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ Box <slot> at [8,24] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <span> at [8,24] flex-item [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,24 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [17.34375,24] flex-item [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,24 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <details.closed> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ ListItemBox <summary> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ListItemMarkerBox start: 0, length: 0, rect: [8,40 13.84375x16] baseline: 13
+ frag 1 from TextNode start: 0, length: 14, rect: [21.84375,40 126.265625x16] baseline: 13
+ "closed summary"
+ ListItemMarkerBox <(anonymous)> at [8,40] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [8,40 13.84375x16] baseline: 13
+ "► "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ Box <slot> at [8,56] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] [FFC] children: not-inline
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x64] (z-index: auto)
+ SC for Box<SLOT> [8,56 784x0] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/video-audio-light-children-not-rendered.txt b/Tests/LibWeb/Layout/expected/tree-builder/video-audio-light-children-not-rendered.txt
new file mode 100644
index 00000000000..77e726703a1
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/video-audio-light-children-not-rendered.txt
@@ -0,0 +1,9 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 69 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 53 0+0+8] children: inline
+ frag 0 from VideoBox start: 0, length: 0, rect: [8,8 100x50] baseline: 50
+ VideoBox <video> at [8,8] inline-block [0+0+0 100 0+0+0] [0+0+0 50 0+0+0] children: not-inline
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x69] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/whitespace-after-br-and-oof.txt b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-after-br-and-oof.txt
new file mode 100644
index 00000000000..ba2a02c089f
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-after-br-and-oof.txt
@@ -0,0 +1,49 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 112 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 96 0+0+8] children: not-inline
+ BlockContainer <div#after-br> at [8,8] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,8 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BreakNode <br> (not painted)
+ InlineNode <b> at [8,24] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,24 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+ BlockContainer <div#after-abspos> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,40 8x16] baseline: 13
+ " "
+ InlineNode <span> at [8,40] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,40 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,56] positioned [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ TextNode <#text> (not painted)
+ InlineNode <b> at [25.34375,40] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [25.34375,40 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+ BlockContainer <div#after-float> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 2, rect: [17.34375,56 17.46875x16] baseline: 13
+ " b"
+ InlineNode <span> at [8,56] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,56 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,56] floating [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ TextNode <#text> (not painted)
+ BlockContainer <div#abspos-at-start> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ BlockContainer <div> at [8,72] positioned [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ InlineNode <b> at [8,72] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,72 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+ BlockContainer <div#float-at-start> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ BlockContainer <div> at [8,88] floating [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline
+ InlineNode <b> at [8,88] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,88 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x112] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/whitespace-after-contents-pseudo.txt b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-after-contents-pseudo.txt
new file mode 100644
index 00000000000..4467ee554b2
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-after-contents-pseudo.txt
@@ -0,0 +1,40 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 80 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 64 0+0+8] children: not-inline
+ BlockContainer <div#after-pseudo> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [48.1875,8 8x16] baseline: 13
+ " "
+ InlineNode <(anonymous)> at [8,8] [0+0+0 40.1875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [8,8 40.1875x16] baseline: 13
+ "after"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <b> at [56.1875,8] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [56.1875,8 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+ BlockContainer <div#before-pseudo-leading-whitespace> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [60.53125,24 8x16] baseline: 13
+ " "
+ InlineNode <(anonymous)> at [8,24] [0+0+0 52.53125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 6, rect: [8,24 52.53125x16] baseline: 13
+ "before"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <b> at [68.53125,24] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [68.53125,24 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+ BlockContainer <div#block-after-pseudo> at [8,40] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [8,40 40.1875x16] baseline: 13
+ "after"
+ GeneratedTextNode <(anonymous)> (not painted)
+ BlockContainer <(anonymous)> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <b> at [8,56] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,56 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x80] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/whitespace-after-display-contents-at-start.txt b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-after-display-contents-at-start.txt
new file mode 100644
index 00000000000..f9c8b10c552
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-after-display-contents-at-start.txt
@@ -0,0 +1,74 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 208 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 192 0+0+8] children: not-inline
+ BlockContainer <div#after-inline> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,8 8x16] baseline: 13
+ " "
+ InlineNode <span> at [8,8] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,8 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <b> at [25.34375,8] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [25.34375,8 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+ BlockContainer <div#after-block> at [8,40] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <p> at [8,40] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,40 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <b> at [8,72] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,72 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+ BlockContainer <div#nested-contents> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,88 8x16] baseline: 13
+ " "
+ InlineNode <span> at [8,88] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,88 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <b> at [25.34375,88] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [25.34375,88 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+ BlockContainer <div#contents-ends-with-inline> at [8,104] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,104 8x16] baseline: 13
+ " "
+ InlineNode <span> at [8,104] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,104 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <b> at [25.34375,104] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [25.34375,104 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+ BlockContainer <div#contents-ends-with-block> at [8,136] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <p> at [8,136] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,136 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,168] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <b> at [8,168] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,168 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+ BlockContainer <div#empty-contents> at [8,184] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,184 8x16] baseline: 13
+ " "
+ InlineNode <span> at [8,184] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,184 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <b> at [25.34375,184] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [25.34375,184 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x208] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/whitespace-after-top-layer-member.txt b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-after-top-layer-member.txt
new file mode 100644
index 00000000000..1473c84e1e8
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-after-top-layer-member.txt
@@ -0,0 +1,41 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 104 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 80 0+0+8] children: not-inline
+ BlockContainer <div#between-blocks> at [8,16] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <p> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,16 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,48] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,48 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <div#after-inline> at [8,80] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,80 8x16] baseline: 13
+ " "
+ InlineNode <span> at [8,80] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,80 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <b> at [25.34375,80] [0+0+0 9.703125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [25.34375,80 9.703125x16] baseline: 13
+ "x"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [0,0] positioned [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <dialog#first> at [19,19] positioned [0+3+16 43.921875 16+3+0] [0+3+16 16 16+3+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [19,19 43.921875x16] baseline: 13
+ "dialog"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [0,0] positioned [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <dialog#second> at [19,19] positioned [0+3+16 43.921875 16+3+0] [0+3+16 16 16+3+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [19,19 43.921875x16] baseline: 13
+ "dialog"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x104] (z-index: auto)
+ SC for BlockContainer(anonymous) [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<DIALOG>#first [19,19 43.921875x16] (z-index: auto)
+ SC for BlockContainer(anonymous) [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<DIALOG>#second [19,19 43.921875x16] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/whitespace-in-flex-grid-math.txt b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-in-flex-grid-math.txt
new file mode 100644
index 00000000000..c7f80bea875
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-in-flex-grid-math.txt
@@ -0,0 +1,67 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 128 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 112 0+0+8] children: not-inline
+ Box <div> at [8,8] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <span> at [8,8] flex-item [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,8 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [17.34375,8] flex-item [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,8 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ Box <div> at [8,24] flex-container(row) [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,24] flex-item [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,24 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [17.34375,24] flex-item [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,24 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ Box <div> at [8,40] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] [GFC] children: not-inline
+ BlockContainer <span> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,40 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,56 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ Box <div> at [8,72] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] [GFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,72 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,88 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,104] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [34.8125,104 8x16] baseline: 13
+ " "
+ InlineNode <div> at [8,104] [0+0+0 26.8125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,104 8x16] baseline: 13
+ " "
+ InlineNode <span> at [8,104] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,104 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <span> at [25.34375,104] [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [25.34375,104 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <div> at [42.8125,104] [0+0+0 26.8125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 2, rect: [42.8125,104 17.34375x16] baseline: 13
+ "a "
+ TextNode <#text> (not painted)
+ InlineNode <span> at [60.15625,104] [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [60.15625,104 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x128] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/whitespace-in-slot-assigned-nodes.txt b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-in-slot-assigned-nodes.txt
new file mode 100644
index 00000000000..cc27536d540
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-in-slot-assigned-nodes.txt
@@ -0,0 +1,68 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 160 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 144 0+0+8] children: not-inline
+ BlockContainer <div#between-assigned> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [74.765625,8 8x16] baseline: 13
+ " "
+ InlineNode <span> at [8,8] [0+0+0 57.421875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [8,8 57.421875x16] baseline: 13
+ "shadow"
+ TextNode <#text> (not painted)
+ InlineNode <span> at [65.421875,8] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [65.421875,8 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <span> at [82.765625,8] [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [82.765625,8 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <div#before-first-assigned> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [65.421875,24 8x16] baseline: 13
+ " "
+ InlineNode <span> at [8,24] [0+0+0 57.421875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [8,24 57.421875x16] baseline: 13
+ "shadow"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <span> at [73.421875,24] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [73.421875,24 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <div#slot-with-box> at [8,40] [0+0+0 784 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,40] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [8,40] [0+0+0 57.421875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [8,40 57.421875x16] baseline: 13
+ "shadow"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <slot> at [8,56] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [17.34375,56 8x16] baseline: 13
+ " "
+ InlineNode <span> at [8,56] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,56 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <span> at [25.34375,56] [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [25.34375,56 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <div#after-block-assigned> at [8,72] [0+0+0 784 0+0+0] [0+0+0 80 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [8,72] [0+0+0 57.421875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [8,72 57.421875x16] baseline: 13
+ "shadow"
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,104] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,104 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,136] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <span> at [8,136] [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,136 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x160] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/whitespace-in-slot-fallback.txt b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-in-slot-fallback.txt
new file mode 100644
index 00000000000..b843745c4e4
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-in-slot-fallback.txt
@@ -0,0 +1,47 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 112 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 96 0+0+8] children: not-inline
+ BlockContainer <div#fallback-after-inline> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [65.421875,8 8x16] baseline: 13
+ " "
+ frag 1 from TextNode start: 0, length: 1, rect: [133.09375,8 8x16] baseline: 13
+ " "
+ InlineNode <span> at [8,8] [0+0+0 57.421875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [8,8 57.421875x16] baseline: 13
+ "shadow"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <b> at [73.421875,8] [0+0+0 59.671875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 8, rect: [73.421875,8 59.671875x16] baseline: 13
+ "fallback"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <i> at [141.09375,8] [0+0+0 40.109375 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 4, rect: [141.09375,8 40.109375x16] baseline: 13
+ "more"
+ TextNode <#text> (not painted)
+ BlockContainer <div#fallback-after-block> at [8,40] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <p> at [8,40] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [8,40 57.421875x16] baseline: 13
+ "shadow"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,72] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ InlineNode <b> at [8,72] [0+0+0 59.671875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 8, rect: [8,72 59.671875x16] baseline: 13
+ "fallback"
+ TextNode <#text> (not painted)
+ BlockContainer <div#whitespace-around-slot> at [8,88] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [65.421875,88 8x16] baseline: 13
+ " "
+ InlineNode <span> at [8,88] [0+0+0 57.421875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [8,88 57.421875x16] baseline: 13
+ "shadow"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <span> at [73.421875,88] [0+0+0 26.1875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 3, rect: [73.421875,88 26.1875x16] baseline: 13
+ "end"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x112] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/whitespace-in-svg-text-and-textpath.txt b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-in-svg-text-and-textpath.txt
new file mode 100644
index 00000000000..408abe7f8db
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-in-svg-text-and-textpath.txt
@@ -0,0 +1,25 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 116 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 100 0+0+8] children: inline
+ frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 300x100] baseline: 100
+ SVGSVGBox <svg> at [8,8] [0+0+0 300 0+0+0] [0+0+0 100 0+0+0] viewport-transform=[1 0 0 1 0 0] [SVG] children: not-inline
+ SVGGraphicsBox <g> at [0,0] [0+0+0 5 0+0+0] [0+0+0 5 0+0+0] children: not-inline
+ SVGGeometryBox <rect> at [0,0] [0+0+0 5 0+0+0] [0+0+0 5 0+0+0] children: not-inline
+ SVGTextBox <text> at [10,7.203125] [0+0+0 18.8125 0+0+0] [0+0+0 16 0+0+0] children: inline
+ TextNode <#text> (not painted)
+ SVGTextBox <tspan> at [10,7.203125] [0+0+0 9.34375 0+0+0] [0+0+0 16 0+0+0] children: inline
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ SVGTextBox <tspan> at [19.34375,7.203125] [0+0+0 9.46875 0+0+0] [0+0+0 16 0+0+0] children: inline
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ SVGTextBox <text> at [10.8125,72.125] [0+0+0 7 0+0+0] [0+0+0 7.28125 0+0+0] children: not-inline
+ SVGTextPathBox <textPath> at [10.8125,72.125] [0+0+0 7 0+0+0] [0+0+0 7.28125 0+0+0] children: inline
+ TextNode <#text> (not painted)
+ SVGTextBox <tspan> (not painted) children: inline
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x116] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/whitespace-list-item-inside-at-start.txt b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-list-item-inside-at-start.txt
new file mode 100644
index 00000000000..822fba223b7
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-list-item-inside-at-start.txt
@@ -0,0 +1,41 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 96 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 64 0+0+8] children: not-inline
+ BlockContainer <ul> at [48,16] [0+0+40 744 0+0+0] [16+0+0 64 0+0+16] children: not-inline
+ ListItemBox <li> at [48,16] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ListItemMarkerBox start: 0, length: 0, rect: [48,16 13.84375x16] baseline: 13
+ frag 1 from TextNode start: 0, length: 1, rect: [61.84375,16 8x16] baseline: 13
+ " "
+ ListItemMarkerBox <(anonymous)> at [48,16] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [48,16 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ InlineNode <b> at [69.84375,16] [0+0+0 44.65625 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 6, rect: [69.84375,16 44.65625x16] baseline: 13
+ "inside"
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,32] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ ListItemMarkerBox <(anonymous)> at [34,32] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [34,32 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ InlineNode <b> at [48,32] [0+0+0 57.46875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 7, rect: [48,32 57.46875x16] baseline: 13
+ "outside"
+ TextNode <#text> (not painted)
+ ListItemBox <li> at [48,48] [0+0+0 744 0+0+0] [0+0+0 32 0+0+0] children: not-inline
+ BlockContainer <(anonymous)> at [48,48] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from ListItemMarkerBox start: 0, length: 0, rect: [48,48 13.84375x16] baseline: 13
+ ListItemMarkerBox <(anonymous)> at [48,48] [0+0+0 13.84375 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 2, rect: [48,48 13.84375x16] baseline: 13
+ "• "
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [48,64] [0+0+0 744 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 12, rect: [48,64 93.328125x16] baseline: 13
+ "inside block"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x96] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/whitespace-pre-line-pre-wrap-break-spaces.txt b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-pre-line-pre-wrap-break-spaces.txt
new file mode 100644
index 00000000000..4e78a84d9c3
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/whitespace-pre-line-pre-wrap-break-spaces.txt
@@ -0,0 +1,71 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 496 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 464 0+0+8] children: not-inline
+ BlockContainer <div> at [8,16] [0+0+0 784 0+0+0] [0+0+0 80 0+0+0] children: not-inline
+ BlockContainer <p> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,16 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,48] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,48 8x16] baseline: 13
+ " "
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,80] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,80 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,112] [0+0+0 784 0+0+0] [0+0+0 112 0+0+0] children: not-inline
+ BlockContainer <p> at [8,112] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,112 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,144] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,176] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,176 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,208] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: inline
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,208] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,208 8.890625x16] baseline: 13
+ "c"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,240] [0+0+0 784 0+0+0] [0+0+0 80 0+0+0] children: not-inline
+ BlockContainer <p> at [8,240] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,240 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,272] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,272 8x16] baseline: 13
+ " "
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,304] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,304 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,336] [0+0+0 784 0+0+0] [0+0+0 80 0+0+0] children: not-inline
+ BlockContainer <p> at [8,336] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,336 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,368] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,368 8x16] baseline: 13
+ " "
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,400] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,400 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,432] [0+0+0 784 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ BlockContainer <p> at [8,432] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,432 9.34375x16] baseline: 13
+ "a"
+ TextNode <#text> (not painted)
+ BlockContainer <p> at [8,464] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,464 9.46875x16] baseline: 13
+ "b"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x496] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/writing-suggestion-in-nested-inline.txt b/Tests/LibWeb/Layout/expected/tree-builder/writing-suggestion-in-nested-inline.txt
new file mode 100644
index 00000000000..056cc6e4a80
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/writing-suggestion-in-nested-inline.txt
@@ -0,0 +1,25 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 16 0+0+8] children: not-inline
+ BlockContainer <div#editable> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 7, rect: [8,8 60.53125x16] baseline: 13
+ "before "
+ frag 1 from TextNode start: 0, length: 6, rect: [179.953125,8 48.1875x16] baseline: 13
+ " after"
+ TextNode <#text> (not painted)
+ InlineNode <span> at [68.53125,8] [0+0+0 111.421875 0+0+0] [0+0+0 16 0+0+0]
+ InlineNode <b#target> at [68.53125,8] [0+0+0 111.421875 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from TextNode start: 0, length: 5, rect: [68.53125,8 39.390625x16] baseline: 13
+ "predi"
+ frag 1 from TextNode start: 0, length: 4, rect: [148.203125,8 31.75x16] baseline: 13
+ "-xyz"
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [107.921875,8] [0+0+0 40.28125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [107.921875,8 40.28125x16] baseline: 13
+ "ction"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x32] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/tree-builder/writing-suggestion-split.txt b/Tests/LibWeb/Layout/expected/tree-builder/writing-suggestion-split.txt
new file mode 100644
index 00000000000..eac85f13277
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/tree-builder/writing-suggestion-split.txt
@@ -0,0 +1,17 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 16 0+0+8] children: not-inline
+ BlockContainer <div#editable> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,8 39.390625x16] baseline: 13
+ "predi"
+ frag 1 from TextNode start: 0, length: 4, rect: [87.671875,8 31.75x16] baseline: 13
+ "-xyz"
+ TextNode <#text> (not painted)
+ InlineNode <(anonymous)> at [47.390625,8] [0+0+0 40.28125 0+0+0] [0+0+0 16 0+0+0]
+ frag 0 from GeneratedTextNode start: 0, length: 5, rect: [47.390625,8 40.28125x16] baseline: 13
+ "ction"
+ GeneratedTextNode <(anonymous)> (not painted)
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x32] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/input/tree-builder/block-generated-image-in-inline.html b/Tests/LibWeb/Layout/input/tree-builder/block-generated-image-in-inline.html
new file mode 100644
index 00000000000..3d65c6e0c46
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/block-generated-image-in-inline.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<style>
+ .block-image::before { content: url(../../../Assets/120.png); display: block; }
+ .image-list::before { content: "a" url(../../../Assets/120.png) "b" url(../../../Assets/120.png); }
+ .block-image-list::after { content: "c" url(../../../Assets/120.png); display: block; }
+</style>
+<div><span class="block-image">single image</span></div>
+<div><span class="image-list">image list</span></div>
+<div><span class="block-image-list">block image list</span></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/block-pseudo-escapes-nested-inlines.html b/Tests/LibWeb/Layout/input/tree-builder/block-pseudo-escapes-nested-inlines.html
new file mode 100644
index 00000000000..f70b7fa39a4
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/block-pseudo-escapes-nested-inlines.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<style>
+ .before::before { content: "before"; display: block; }
+ .after::after { content: "after"; display: block; }
+ .list-item::before { content: "list item"; display: list-item; }
+ .flex::after { content: "flex"; display: flex; }
+</style>
+<div id="before-at-start"><span><b><i class="before">c</i>d</b>e</span> tail</div>
+<div id="after-at-end">head <span>a<b class="after">b<i>c</i></b></span></div>
+<div id="before-and-after"><span class="before after">text</span></div>
+<div id="list-item-pseudo"><span class="list-item">text</span></div>
+<div id="flex-pseudo"><span class="flex">text</span> tail</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/block-pseudo-in-inline-keeps-its-place.html b/Tests/LibWeb/Layout/input/tree-builder/block-pseudo-in-inline-keeps-its-place.html
new file mode 100644
index 00000000000..cd1a93c467c
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/block-pseudo-in-inline-keeps-its-place.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<!-- A block-level ::before or ::after of an element inside an inline box interrupts the inline where it is generated. -->
+<style>
+ .before::before { content: "BEFORE"; display: block; }
+ .after::after { content: "AFTER"; display: block; }
+</style>
+<div><span>a<b class="before">b</b>c</span></div>
+<div><span>a<b class="after">b</b>c</span></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/button-display-flex-and-grid.html b/Tests/LibWeb/Layout/input/tree-builder/button-display-flex-and-grid.html
new file mode 100644
index 00000000000..ccd0836a459
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/button-display-flex-and-grid.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<button style="display: flex">flex <span>span</span></button>
+<button style="display: grid">grid <span>span</span></button>
+<button style="display: inline-flex">inline-flex</button>
+<button style="display: block">block</button>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/button-display-list-item.html b/Tests/LibWeb/Layout/input/tree-builder/button-display-list-item.html
new file mode 100644
index 00000000000..6e6fbe6be08
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/button-display-list-item.html
@@ -0,0 +1,3 @@
+<!DOCTYPE html>
+<button style="display: list-item">list item button</button>
+<button style="display: list-item; list-style-position: inside">inside list item button</button>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/canvas-children-not-rendered.html b/Tests/LibWeb/Layout/input/tree-builder/canvas-children-not-rendered.html
new file mode 100644
index 00000000000..1ce048883e7
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/canvas-children-not-rendered.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<style>
+ canvas::before { content: "before"; }
+ canvas::after { content: "after"; display: block; }
+</style>
+<canvas width="20" height="20"><div>fallback</div>text</canvas>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/children-inline-flag-after-oof-only.html b/Tests/LibWeb/Layout/input/tree-builder/children-inline-flag-after-oof-only.html
new file mode 100644
index 00000000000..cd1ed2fa6b6
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/children-inline-flag-after-oof-only.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<div id="only-float"><div style="float: left">float</div></div>
+<div id="only-abspos"><div style="position: absolute">abspos</div></div>
+<div id="float-and-whitespace"> <div style="float: left">float</div> </div>
+<div id="inline-floats"><span style="float: left">a</span><span style="float: left">b</span></div>
+<div id="empty"></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/content-alt-text.html b/Tests/LibWeb/Layout/input/tree-builder/content-alt-text.html
new file mode 100644
index 00000000000..5181960539a
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/content-alt-text.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<style>
+ .image-alt::before { content: url(../../../Assets/120.png) / "alt"; }
+ .text-alt::before { content: "a" / "b"; }
+ .element-alt { content: url(../../../Assets/120.png) / "element alt"; }
+</style>
+<div class="image-alt">image</div>
+<div class="text-alt">text</div>
+<div class="element-alt">replaced</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/content-list-mixed-items.html b/Tests/LibWeb/Layout/input/tree-builder/content-list-mixed-items.html
new file mode 100644
index 00000000000..b1d42042ae6
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/content-list-mixed-items.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<style>
+ body { quotes: "<" ">"; counter-reset: c 7; }
+ .inline::before { content: "a" url(../../../Assets/120.png) attr(data-x) counter(c) "" open-quote; }
+ .block::before { content: "a" "" url(../../../Assets/120.png) "" attr(data-x); display: block; }
+ .empty-only::before { content: ""; display: block; }
+ .empty-attr::before { content: attr(data-missing); }
+</style>
+<div class="inline" data-x="X">inline</div>
+<div class="block" data-x="Y">block</div>
+<div class="empty-only">empty only</div>
+<div class="empty-attr">empty attr</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/content-visibility-hidden-variants.html b/Tests/LibWeb/Layout/input/tree-builder/content-visibility-hidden-variants.html
new file mode 100644
index 00000000000..9536c666fa0
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/content-visibility-hidden-variants.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<style>
+ .cv { content-visibility: hidden; }
+ .pseudo::before { content: "before"; }
+ .pseudo::after { content: "after"; }
+</style>
+<div class="cv">block <span>children</span></div>
+<ul><li class="cv">list item</li></ul>
+<div class="cv pseudo">pseudo-elements</div>
+<table class="cv"><tr><td>table</td></tr></table>
+<div class="cv" style="display: flex"><div>flex</div></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/counter-instantiated-by-use.html b/Tests/LibWeb/Layout/input/tree-builder/counter-instantiated-by-use.html
new file mode 100644
index 00000000000..24f85d9d61e
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/counter-instantiated-by-use.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<style>
+ .use::before { content: counter(x) " "; }
+ .inc { counter-increment: x; }
+ .inc::before { content: counter(x) " "; }
+</style>
+<div>
+ <p class="use">uses x without any reset</p>
+ <p class="inc">a</p>
+ <p class="inc">b</p>
+</div>
+<div>
+ <p class="inc">c</p>
+ <p class="inc">d</p>
+</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/counter-list-item-in-content.html b/Tests/LibWeb/Layout/input/tree-builder/counter-list-item-in-content.html
new file mode 100644
index 00000000000..e2b4aa4e598
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/counter-list-item-in-content.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<style>
+ li { list-style: none; }
+ li::before { content: counter(list-item) " | " counters(list-item, ".") " "; }
+</style>
+<ol start="5">
+ <li>a</li>
+ <li>b
+ <ol>
+ <li>b1</li>
+ <li value="7">b2</li>
+ </ol>
+ </li>
+ <li>c</li>
+</ol>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/counter-reversed-css.html b/Tests/LibWeb/Layout/input/tree-builder/counter-reversed-css.html
new file mode 100644
index 00000000000..66a7cac646f
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/counter-reversed-css.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<style>
+ div { counter-reset: reversed(c); }
+ p { counter-increment: c -1; margin: 0; }
+ p.two { counter-increment: c -2; }
+ p::before { content: counter(c) " "; }
+ span::before { content: counter(c) " "; counter-increment: c -1; }
+</style>
+<div>
+ <p>a</p>
+ <p class="two">b</p>
+ <p>c<span>d</span></p>
+ <p>e</p>
+</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/counter-reversed-ol.html b/Tests/LibWeb/Layout/input/tree-builder/counter-reversed-ol.html
new file mode 100644
index 00000000000..f2a395ca7bb
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/counter-reversed-ol.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<ol reversed>
+ <li>a</li>
+ <li>b</li>
+ <li>c</li>
+ <li>d
+ <ol reversed>
+ <li>x</li>
+ <li>y</li>
+ </ol>
+ </li>
+ <li>e</li>
+</ol>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/counter-scope-display-contents-siblings.html b/Tests/LibWeb/Layout/input/tree-builder/counter-scope-display-contents-siblings.html
new file mode 100644
index 00000000000..4d2c20a18ac
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/counter-scope-display-contents-siblings.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<!-- A display: contents element inherits counters from its previous sibling, as any element does. -->
+<style>
+ .contents { display: contents; }
+ .reset { counter-reset: c 20; }
+ .increment { counter-increment: c 3; }
+ p { counter-increment: c; }
+ p::before { content: counter(c) " "; }
+</style>
+<div><p>a</p><div class="contents reset"><p>b</p><p>c</p></div><p>d</p>
+<div class="contents increment"><p>e</p></div><p>f</p></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/counter-scope-previous-sibling.html b/Tests/LibWeb/Layout/input/tree-builder/counter-scope-previous-sibling.html
new file mode 100644
index 00000000000..27ab1fce693
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/counter-scope-previous-sibling.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<style>
+ .reset { counter-reset: c 5; }
+ .use::before { content: counter(c) " "; counter-increment: c; }
+ div { margin: 0; }
+</style>
+<div>
+ <div class="reset">reset</div>
+ <div class="use">a</div>
+ <div class="use">b
+ <div class="use">nested</div>
+ </div>
+ <div class="use">c</div>
+</div>
+<div>
+ <div class="use">new scope</div>
+</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/counter-scope-shadow-tree.html b/Tests/LibWeb/Layout/input/tree-builder/counter-scope-shadow-tree.html
new file mode 100644
index 00000000000..14ea6448fab
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/counter-scope-shadow-tree.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<!-- Counters follow the flat tree: the shadow tree's children inherit the host's, and slotted elements the slot's. -->
+<style>
+ #host { counter-reset: c 100; }
+ .slotted { counter-increment: c 10; }
+ .slotted::before { content: counter(c) " "; }
+</style>
+<div id="host"><p class="slotted">one</p><p class="slotted">two</p></div>
+<p class="slotted">after host</p>
+<script>
+ const shadowRoot = document.getElementById("host").attachShadow({ mode: "open" });
+ shadowRoot.innerHTML = `<style>p { counter-increment: c; } p::before { content: counter(c) " "; }</style><p>a</p><slot></slot><p>b</p>`;
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/counter-scope-sibling-in-anonymous-wrapper.html b/Tests/LibWeb/Layout/input/tree-builder/counter-scope-sibling-in-anonymous-wrapper.html
new file mode 100644
index 00000000000..877730c334e
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/counter-scope-sibling-in-anonymous-wrapper.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<!-- A counter reset by an inline element scopes its following siblings, whatever anonymous boxes wrap them. -->
+<style>
+ .reset { counter-reset: c 5; }
+ .use::before { content: counter(c) " "; counter-increment: c; }
+</style>
+<div>text <span class="reset">reset</span> <span class="use">a</span>
+<div class="use">block sibling</div><span class="use">after</span></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/counter-set-basic.html b/Tests/LibWeb/Layout/input/tree-builder/counter-set-basic.html
new file mode 100644
index 00000000000..b8d2a909ddd
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/counter-set-basic.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<style>
+ body { counter-reset: c; }
+ p { counter-increment: c; margin: 0; }
+ p::before { content: counter(c) " "; }
+ .set { counter-set: c 10; }
+ .increment-set { counter-increment: c 5; counter-set: c 20; }
+ .pseudo-set::after { content: " [" counter(c) "]"; counter-set: c 40; }
+</style>
+<p>a</p>
+<p class="set">b</p>
+<p>c</p>
+<p class="increment-set">d</p>
+<p>e</p>
+<p class="pseudo-set">f</p>
+<p>g</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/counters-and-display-none-and-cv-hidden.html b/Tests/LibWeb/Layout/input/tree-builder/counters-and-display-none-and-cv-hidden.html
new file mode 100644
index 00000000000..750668738ca
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/counters-and-display-none-and-cv-hidden.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<style>
+ body { counter-reset: c; }
+ p { counter-increment: c; margin: 0; }
+ p::before { content: counter(c) " "; }
+ .hidden { display: none; }
+ .cv { content-visibility: hidden; }
+ .cv > p { counter-increment: c 100; }
+</style>
+<p>a</p>
+<p class="hidden">hidden</p>
+<p>b</p>
+<div class="cv"><p>inside cv hidden</p></div>
+<p>c</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/counters-function-nested-scopes.html b/Tests/LibWeb/Layout/input/tree-builder/counters-function-nested-scopes.html
new file mode 100644
index 00000000000..bd76bbef9e3
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/counters-function-nested-scopes.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<style>
+ .scope { counter-reset: c; margin-left: 10px; }
+ .item { counter-increment: c; }
+ .item::before { content: counters(c, ".") " "; }
+</style>
+<div class="scope">
+ <div class="item">a</div>
+ <div class="item">b
+ <div class="scope">
+ <div class="item">b1</div>
+ <div class="item">b2
+ <div class="scope">
+ <div class="item">b2a</div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="item">c</div>
+</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/display-contents-counters.html b/Tests/LibWeb/Layout/input/tree-builder/display-contents-counters.html
new file mode 100644
index 00000000000..d7704175112
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/display-contents-counters.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<style>
+ .contents { display: contents; }
+ .reset { counter-reset: c 20; }
+ p { counter-increment: c; margin: 0; }
+ p::before { content: counter(c) " "; }
+</style>
+<div>
+ <p>a</p>
+ <div class="contents reset"><p>b</p><p>c</p></div>
+ <p>d</p>
+</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/display-contents-nested-with-pseudos.html b/Tests/LibWeb/Layout/input/tree-builder/display-contents-nested-with-pseudos.html
new file mode 100644
index 00000000000..41780c8049a
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/display-contents-nested-with-pseudos.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<style>
+ .contents { display: contents; }
+ .outer::before { content: "before-outer"; }
+ .outer::after { content: "after-outer"; }
+ .inner::before { content: "before-inner"; }
+ .inner::after { content: "after-inner"; }
+ .block-pseudo::before { content: "block-before"; display: block; }
+</style>
+<div><span class="contents outer"><span class="contents inner">kids</span></span></div>
+<div><span class="contents outer"><span class="contents inner"><p>block kid</p></span></span></div>
+<div><span>prev</span><span class="contents block-pseudo">kids</span></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/display-contents-on-list-item-and-table-parts.html b/Tests/LibWeb/Layout/input/tree-builder/display-contents-on-list-item-and-table-parts.html
new file mode 100644
index 00000000000..6a6b8f039b2
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/display-contents-on-list-item-and-table-parts.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<ul>
+ <li>normal</li>
+ <li style="display: contents">contents item</li>
+ <li>after</li>
+</ul>
+<table>
+ <tr style="display: contents"><td>cell in contents row</td><td>second</td></tr>
+ <tr><td>normal row</td></tr>
+</table>
+<div><table style="display: contents"><tr><td>cell in contents table</td></tr></table></div>
+<div style="display: table"><div style="display: contents"><div style="display: table-cell">cell under contents</div></div></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/display-contents-text-style-wrapper.html b/Tests/LibWeb/Layout/input/tree-builder/display-contents-text-style-wrapper.html
new file mode 100644
index 00000000000..ee70f319619
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/display-contents-text-style-wrapper.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<style>
+ .contents { display: contents; }
+</style>
+<div><span class="contents" style="font-size: 24px; color: green">styled text</span></div>
+<div><span class="contents" style="white-space: pre"> </span></div>
+<div><span class="contents" style="font-weight: bold">a <b>b</b> c</span></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/display-contents-top-layer-member.html b/Tests/LibWeb/Layout/input/tree-builder/display-contents-top-layer-member.html
new file mode 100644
index 00000000000..02e5a15f12e
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/display-contents-top-layer-member.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<style>
+ dialog, [popover] { margin: 0; padding: 0; border: none; }
+ .contents { display: contents; }
+</style>
+<dialog id="dialog" class="contents"><span>dialog child</span></dialog>
+<div id="popover" class="contents" popover="manual"><span>popover child</span></div>
+<p>content</p>
+<script>
+ dialog.showModal();
+ popover.showPopover();
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/display-math-on-html-element.html b/Tests/LibWeb/Layout/input/tree-builder/display-math-on-html-element.html
new file mode 100644
index 00000000000..7dfbe3ef780
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/display-math-on-html-element.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<div style="display: math">inline <span>span</span><div>block</div></div>
+<div style="display: block math">inline <span>span</span><div>block</div></div>
+<p>before <span style="display: inline math">math span <b>bold</b></span> after</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/display-run-in-and-webkit-box.html b/Tests/LibWeb/Layout/input/tree-builder/display-run-in-and-webkit-box.html
new file mode 100644
index 00000000000..2ce5a801439
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/display-run-in-and-webkit-box.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<div style="display: run-in">run-in <div>block</div></div>
+<div style="display: -webkit-box">webkit-box <div>block</div></div>
+<div><span style="display: -webkit-inline-box">webkit-inline-box <div>block</div></span></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/editable-and-input-empty-text-fragments.html b/Tests/LibWeb/Layout/input/tree-builder/editable-and-input-empty-text-fragments.html
new file mode 100644
index 00000000000..c953c509d07
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/editable-and-input-empty-text-fragments.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<div contenteditable id="empty-editable"></div>
+<div contenteditable id="empty-text-editable"><span id="span"></span></div>
+<input value="">
+<input value="text">
+<textarea></textarea>
+<script>
+ document.getElementById("span").append(document.createTextNode(""));
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/fieldset-display-variants.html b/Tests/LibWeb/Layout/input/tree-builder/fieldset-display-variants.html
new file mode 100644
index 00000000000..62a4ba759ac
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/fieldset-display-variants.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<fieldset style="display: inline"><legend>inline</legend>text</fieldset>
+<fieldset style="display: flex"><legend>flex</legend><div>a</div><div>b</div></fieldset>
+<fieldset style="display: grid"><legend>grid</legend><div>a</div><div>b</div></fieldset>
+<fieldset style="display: contents"><legend>contents</legend>text</fieldset>
+<fieldset><legend style="display: none">hidden legend</legend>text</fieldset>
+<fieldset><legend style="float: left">floated legend</legend>text</fieldset>
+<fieldset><legend style="position: absolute">abspos legend</legend>text</fieldset>
+<fieldset><legend>first legend</legend><legend>second legend</legend>text</fieldset>
+<fieldset>text<legend>legend after text</legend></fieldset>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/first-letter-basic.html b/Tests/LibWeb/Layout/input/tree-builder/first-letter-basic.html
new file mode 100644
index 00000000000..8c7ec9319c9
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/first-letter-basic.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<style>
+ p::first-letter { color: green; font-size: 32px; }
+</style>
+<p>Hello world</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/first-letter-block-chain.html b/Tests/LibWeb/Layout/input/tree-builder/first-letter-block-chain.html
new file mode 100644
index 00000000000..a8f7a8f5f9a
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/first-letter-block-chain.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<style>
+ .outer::first-letter { color: green; }
+ .inner::first-letter { color: blue; }
+ p { margin: 0; }
+</style>
+<div class="outer"><div><p>Hello</p></div><p>Second</p></div>
+<div class="outer"><div class="inner"><p>Inner</p></div></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/first-letter-blocked.html b/Tests/LibWeb/Layout/input/tree-builder/first-letter-blocked.html
new file mode 100644
index 00000000000..296a5ac2c07
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/first-letter-blocked.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<style>
+ p { margin: 0; }
+ p::first-letter { color: green; }
+ .ib { display: inline-block; }
+</style>
+<p><br>After break</p>
+<p><span class="ib">x</span>After inline-block</p>
+<p><img src="../../../Assets/120.png" width="10" height="10">After image</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/first-letter-float-and-display-none.html b/Tests/LibWeb/Layout/input/tree-builder/first-letter-float-and-display-none.html
new file mode 100644
index 00000000000..d7bf71e7270
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/first-letter-float-and-display-none.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<style>
+ p { margin: 0; }
+ .float::first-letter { float: left; font-size: 32px; }
+ .none::first-letter { display: none; }
+ .block::first-letter { display: block; }
+</style>
+<p class="float">Floated</p>
+<p class="none">Hidden</p>
+<p class="block">Block</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/first-letter-generated-content.html b/Tests/LibWeb/Layout/input/tree-builder/first-letter-generated-content.html
new file mode 100644
index 00000000000..fa3ab5b1f2a
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/first-letter-generated-content.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<style>
+ p::first-letter { color: green; }
+ .before::before { content: "Ab"; }
+ .empty-before::before { content: ""; }
+</style>
+<p class="before">text</p>
+<p class="empty-before">Text</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/first-letter-nested-inline.html b/Tests/LibWeb/Layout/input/tree-builder/first-letter-nested-inline.html
new file mode 100644
index 00000000000..5c4f76b08ad
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/first-letter-nested-inline.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<style>
+ p::first-letter { color: green; }
+</style>
+<p><span><b>Hello</b> world</span></p>
+<p><span></span><i>Empty</i> before</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/first-letter-on-various-containers.html b/Tests/LibWeb/Layout/input/tree-builder/first-letter-on-various-containers.html
new file mode 100644
index 00000000000..015b0de2784
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/first-letter-on-various-containers.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<style>
+ .fl::first-letter { color: green; }
+ .cell { display: table-cell; }
+ .ib { display: inline-block; }
+ .fr { display: flow-root; }
+ .li { display: list-item; list-style-position: inside; }
+ .contents { display: contents; }
+</style>
+<div class="fl cell">Cell</div>
+<div><span class="fl ib">Inline-block</span></div>
+<div class="fl li">List item</div>
+<div class="fl fr">Flow root</div>
+<button class="fl">Button</button>
+<div class="fl"><span class="contents">Contents</span></div>
+<span class="fl">Inline is ignored</span>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/first-letter-punctuation.html b/Tests/LibWeb/Layout/input/tree-builder/first-letter-punctuation.html
new file mode 100644
index 00000000000..ae9c48366e3
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/first-letter-punctuation.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<style>
+ p { margin: 0; }
+ p::first-letter { color: green; }
+</style>
+<p>"(Quoted</p>
+<p>!Bang</p>
+<p>123 digits</p>
+<p>«guillemets» text</p>
+<p> leading spaces</p>
+<p>" spaced</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/first-letter-skips-marker.html b/Tests/LibWeb/Layout/input/tree-builder/first-letter-skips-marker.html
new file mode 100644
index 00000000000..5dfeb61c6b9
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/first-letter-skips-marker.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<style>
+ li::first-letter { color: green; }
+</style>
+<ul>
+ <li>Outside marker</li>
+ <li style="list-style-position: inside">Inside marker</li>
+</ul>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/first-letter-with-writing-suggestion.html b/Tests/LibWeb/Layout/input/tree-builder/first-letter-with-writing-suggestion.html
new file mode 100644
index 00000000000..94bc8a6f8c2
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/first-letter-with-writing-suggestion.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html class="test-wait">
+<style>
+ #editable::first-letter { color: green; }
+</style>
+<div id="editable" contenteditable>-xyz</div>
+<script>
+ const editable = document.getElementById("editable");
+ editable.focus();
+ getSelection().collapse(editable.firstChild, 0);
+ internals.sendText(editable, "predi");
+ internals.writingSuggestionSettled().then(() => document.documentElement.classList.remove("test-wait"));
+</script>
+</html>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/flex-runs-split-by-oof.html b/Tests/LibWeb/Layout/input/tree-builder/flex-runs-split-by-oof.html
new file mode 100644
index 00000000000..2587996137f
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/flex-runs-split-by-oof.html
@@ -0,0 +1,3 @@
+<!DOCTYPE html>
+<div style="display: flex">a <span>b</span> <div style="position: absolute">abspos</div> c <div style="float: left">float</div> d</div>
+<div style="display: inline-flex">a<div style="position: absolute"></div>b</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/frameset-refuses-non-frame-children.html b/Tests/LibWeb/Layout/input/tree-builder/frameset-refuses-non-frame-children.html
new file mode 100644
index 00000000000..2e6c572b37e
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/frameset-refuses-non-frame-children.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<style>
+ frameset::before { content: "before"; }
+ frameset::after { content: "after"; }
+</style>
+<frameset id="outer" cols="50%,50%">
+ <frame>
+ <frameset rows="50%,50%">
+ <frame>
+ <frame>
+ </frameset>
+</frameset>
+<script>
+ const outer = document.getElementById("outer");
+ outer.append(document.createElement("div"), document.createTextNode("text"));
+ const span = document.createElement("span");
+ span.textContent = "span";
+ outer.firstElementChild.after(span);
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/fullscreen-element.html b/Tests/LibWeb/Layout/input/tree-builder/fullscreen-element.html
new file mode 100644
index 00000000000..564196cbd82
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/fullscreen-element.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html class="test-wait">
+<style>
+ #target::backdrop { background: green; }
+</style>
+<p>before</p>
+<div id="target"><span>fullscreen content</span></div>
+<p>after</p>
+<script>
+ document.addEventListener("click", () => {
+ document.onfullscreenchange = () => document.documentElement.classList.remove("test-wait");
+ document.getElementById("target").requestFullscreen();
+ }, { once: true });
+ window.onload = () => internals.click(5, 5);
+</script>
+</html>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/generated-content-item-shapes.html b/Tests/LibWeb/Layout/input/tree-builder/generated-content-item-shapes.html
new file mode 100644
index 00000000000..1455a729e92
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/generated-content-item-shapes.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<style>
+ @counter-style blank { system: cyclic; symbols: ""; }
+ body { quotes: "<1" "1>" "<2" "2>"; counter-reset: c 4; }
+ .inline-close::before { content: close-quote; }
+ .block-close::before { display: block; content: close-quote; }
+ .flex-close::before { display: flex; content: close-quote; }
+ .open::before { content: open-quote; }
+ .block-none-quotes::before { display: block; quotes: none; content: open-quote; }
+ .inline-none-quotes::after { quotes: none; content: close-quote; }
+ .inline-blank::before { content: counter(c, blank); }
+ .block-blank::before { display: block; content: counter(c, blank); }
+ .flex-blank::before { display: flex; content: counter(c, blank) "x" counter(c); }
+ .marker-blank::marker { content: counter(list-item, blank); }
+ .block-blank-alt::after { display: block; content: counter(c, blank) / "alt " counter(c); }
+ .white-space::before { display: block; content: " "; }
+ .empty::before { display: block; content: ""; }
+</style>
+<p class="inline-close">inline close at depth zero</p>
+<p class="block-close">block close at depth zero</p>
+<p class="flex-close">flex close at depth zero</p>
+<p class="open">open</p>
+<p class="inline-close">inline close at depth one</p>
+<p class="open">open</p>
+<p class="block-close">block close at depth one</p>
+<p class="open">open</p>
+<p class="flex-close">flex close at depth one</p>
+<p class="block-none-quotes">block open with quotes none</p>
+<p class="open inline-none-quotes">inline close with quotes none</p>
+<p class="inline-blank">inline blank counter</p>
+<p class="block-blank">block blank counter</p>
+<p class="flex-blank">flex blank counter</p>
+<ol><li class="marker-blank">blank marker</li></ol>
+<p class="block-blank-alt">block blank counter with alt text</p>
+<p class="white-space">white space</p>
+<p class="empty">empty</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/grid-runs-split-by-oof.html b/Tests/LibWeb/Layout/input/tree-builder/grid-runs-split-by-oof.html
new file mode 100644
index 00000000000..939208c23db
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/grid-runs-split-by-oof.html
@@ -0,0 +1,3 @@
+<!DOCTYPE html>
+<div style="display: grid">a <span>b</span> <div style="position: absolute">abspos</div> c</div>
+<div style="display: inline-grid">a<div style="position: absolute"></div>b</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/html-inside-svg-is-skipped.html b/Tests/LibWeb/Layout/input/tree-builder/html-inside-svg-is-skipped.html
new file mode 100644
index 00000000000..6391854f2fb
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/html-inside-svg-is-skipped.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<style>
+ svg::before { content: "svg before"; }
+ rect::before { content: "rect before"; }
+ g::after { content: "g after"; }
+ foreignObject > div::before { content: "html before"; }
+</style>
+<svg id="svg" width="200" height="100">
+ text
+ <rect width="10" height="10"/>
+ <g id="g"><rect width="5" height="5"/></g>
+ <foreignObject width="100" height="50"><div>inside foreignObject</div></foreignObject>
+</svg>
+<script>
+ // NB: The HTML parser cannot put HTML elements inside <svg>, so insert them from script.
+ const div = document.createElement("div");
+ div.textContent = "div";
+ const span = document.createElement("span");
+ span.textContent = "span";
+ document.getElementById("svg").prepend(div, span);
+ const nestedDiv = document.createElement("div");
+ nestedDiv.textContent = "div in g";
+ document.getElementById("g").append(nestedDiv);
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/inline-children-of-fieldset-and-foreignobject.html b/Tests/LibWeb/Layout/input/tree-builder/inline-children-of-fieldset-and-foreignobject.html
new file mode 100644
index 00000000000..7b2cc083306
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/inline-children-of-fieldset-and-foreignobject.html
@@ -0,0 +1,3 @@
+<!DOCTYPE html>
+<fieldset>text <span>inline</span></fieldset>
+<svg width="200" height="100"><foreignObject width="200" height="100">text <span>inline</span></foreignObject></svg>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/inline-run-then-block-wraps-everything-including-floats.html b/Tests/LibWeb/Layout/input/tree-builder/inline-run-then-block-wraps-everything-including-floats.html
new file mode 100644
index 00000000000..c8cfdb52da3
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/inline-run-then-block-wraps-everything-including-floats.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<div id="float-before-block">text <span>a</span><div style="float: left">float</div><div>block</div></div>
+<div id="abspos-before-block">text<div style="position: absolute">abspos</div><div>block</div></div>
+<div id="float-first">
+ <div style="float: left">float</div>text<div>block</div>
+</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/input-button-types-box-kinds.html b/Tests/LibWeb/Layout/input/tree-builder/input-button-types-box-kinds.html
new file mode 100644
index 00000000000..f65388cd420
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/input-button-types-box-kinds.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<div><input type="button" value="button"><input type="submit"><input type="reset"><input type="color"><input type="file"></div>
+<div><input type="image" alt="image"></div>
+<div><input type="checkbox"><input type="radio"><input type="range"><input type="text"></div>
+<div style="appearance: none">
+ <input type="checkbox" style="appearance: none">
+ <input type="radio" style="appearance: none">
+ <input type="range" style="appearance: none">
+ <input type="text" style="appearance: none">
+ <input type="button" value="button" style="appearance: none">
+</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/list-unit-mutation-shapes.html b/Tests/LibWeb/Layout/input/tree-builder/list-unit-mutation-shapes.html
new file mode 100644
index 00000000000..9d639e33e14
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/list-unit-mutation-shapes.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<style>
+ .clearfix::after { content: ""; display: table; clear: both; }
+</style>
+<div id="split">one <span>two</span> three</div>
+<div id="trailing"><div>block</div> run</div>
+<div id="clearfix" class="clearfix"><div>a</div></div>
+<div><button id="button">label <span>inline</span></button></div>
+<fieldset id="fieldset">content <div>block</div></fieldset>
+<div id="cells"><div style="display: table-cell">a</div></div>
+<div id="flex" style="display: flex">text <span>s</span></div>
+<script>
+ // The shapes the child lists take once children are inserted into them after the first build: a block that splits
+ // an inline run, inline content that joins a trailing anonymous wrapper, a box appended before a container's
+ // ::after, a block and inline content in a button, a legend in a fieldset, loose table cells, and flex items.
+ document.body.offsetHeight;
+ const make = (tag, text, style) => Object.assign(document.createElement(tag), { textContent: text, style: style ?? "" });
+ document.querySelector("#split span").after(make("div", "block"));
+ document.querySelector("#trailing").append(" more ", make("i", "italic"));
+ document.querySelector("#clearfix").append(make("div", "b", "float: left"));
+ document.querySelector("#button").append(make("div", "block"), " tail");
+ document.querySelector("#fieldset").prepend(make("legend", "legend"));
+ document.querySelector("#cells").append(make("div", "b", "display: table-cell"), " ", make("div", "c", "display: table-cell"));
+ document.querySelector("#flex").append(" more text ", make("div", "item"));
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/marker-before-after-order.html b/Tests/LibWeb/Layout/input/tree-builder/marker-before-after-order.html
new file mode 100644
index 00000000000..1ea33c10841
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/marker-before-after-order.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<style>
+ li::before { content: "before"; }
+ li::after { content: "after"; }
+ .block::before { display: block; }
+</style>
+<ul>
+ <li>outside</li>
+ <li style="list-style-position: inside">inside</li>
+ <li class="block">outside with block before</li>
+ <li class="block" style="list-style-position: inside">inside with block before</li>
+</ul>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/marker-list-style-image.html b/Tests/LibWeb/Layout/input/tree-builder/marker-list-style-image.html
new file mode 100644
index 00000000000..10c5789c55c
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/marker-list-style-image.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<style>
+ .image { list-style-image: url(../../../Assets/120.png); }
+</style>
+<ul>
+ <li class="image">outside image</li>
+ <li class="image" style="list-style-position: inside">inside image</li>
+ <li class="image" style="list-style-type: none">image with type none</li>
+</ul>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/marker-on-flex-grid-table-list-items.html b/Tests/LibWeb/Layout/input/tree-builder/marker-on-flex-grid-table-list-items.html
new file mode 100644
index 00000000000..1cb3e64bb8c
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/marker-on-flex-grid-table-list-items.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<style>
+ .li { display: list-item; }
+</style>
+<table><tr><td class="li">cell list item</td></tr></table>
+<div style="display: flex"><div class="li">flex item list item</div><span class="li">span list item</span></div>
+<ul><li style="display: flex">flex li</li><li style="display: grid">grid li</li><li style="display: table">table li</li></ul>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/math-runs-split-by-oof.html b/Tests/LibWeb/Layout/input/tree-builder/math-runs-split-by-oof.html
new file mode 100644
index 00000000000..94367b44584
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/math-runs-split-by-oof.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<math>
+ <mrow>a</mrow>
+ <mi style="position: absolute">x</mi>
+ <mi>y</mi>
+ <mi style="float: left">z</mi>
+ <mn>1</mn>
+</math>
+<div style="display: block math">a <span>b</span><div style="position: absolute">abspos</div>c<div style="float: left">float</div>d</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/mathml-mspace-has-no-children.html b/Tests/LibWeb/Layout/input/tree-builder/mathml-mspace-has-no-children.html
new file mode 100644
index 00000000000..0228f665700
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/mathml-mspace-has-no-children.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<math><mspace width="10px" height="10px">text<mi>x</mi></mspace><mi>y</mi></math>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/nested-slots.html b/Tests/LibWeb/Layout/input/tree-builder/nested-slots.html
new file mode 100644
index 00000000000..fbad350bee1
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/nested-slots.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<div id="outer-host"><span id="light">light content</span></div>
+<script>
+ const outerShadow = document.getElementById("outer-host").attachShadow({ mode: "open" });
+ outerShadow.innerHTML = `<div id="inner-host"><slot></slot><b>outer shadow</b></div>`;
+ outerShadow.getElementById("inner-host").attachShadow({ mode: "open" }).innerHTML = `<p>inner shadow</p><div><slot></slot></div>`;
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/oof-joins-trailing-inline-wrapper.html b/Tests/LibWeb/Layout/input/tree-builder/oof-joins-trailing-inline-wrapper.html
new file mode 100644
index 00000000000..d38ac111362
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/oof-joins-trailing-inline-wrapper.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<div id="after-inline-only">text<div style="position: absolute">abspos</div><div style="float: left">float</div></div>
+<div id="after-wrapper">text<div>block</div>more text<div style="position: absolute">abspos</div><div style="float: left">float</div></div>
+<div id="after-block"><div>block</div><div style="position: absolute">abspos</div><div style="float: left">float</div></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/popover-backdrop.html b/Tests/LibWeb/Layout/input/tree-builder/popover-backdrop.html
new file mode 100644
index 00000000000..9c8d79668d9
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/popover-backdrop.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<style>
+ [popover] { margin: 0; padding: 0; border: none; }
+ #block::backdrop { display: block; background: green; }
+ #none::backdrop { display: none; }
+</style>
+<div id="block" popover="manual">block backdrop</div>
+<div id="none" popover="manual">no backdrop</div>
+<script>
+ for (const id of ["block", "none"])
+ document.getElementById(id).showPopover();
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/pseudo-display-contents.html b/Tests/LibWeb/Layout/input/tree-builder/pseudo-display-contents.html
new file mode 100644
index 00000000000..bed4b7495b9
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/pseudo-display-contents.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<style>
+ .contents::before { content: "before"; display: contents; }
+ .contents::after { content: "after"; display: contents; }
+ .block-parent::before { content: "before"; display: contents; }
+</style>
+<div class="contents">text</div>
+<div><span class="contents">span</span></div>
+<div class="block-parent"><p>block child</p></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/pseudo-display-list-item-nested-marker-variants.html b/Tests/LibWeb/Layout/input/tree-builder/pseudo-display-list-item-nested-marker-variants.html
new file mode 100644
index 00000000000..e1004cb4b5f
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/pseudo-display-list-item-nested-marker-variants.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<style>
+ div::before { content: "item"; display: list-item; }
+ .none::before { list-style-type: none; }
+ .inside::before { list-style-position: inside; }
+ .counter-style::before { list-style-type: upper-roman; counter-increment: list-item 3; }
+</style>
+<div>default</div>
+<div class="none">none</div>
+<div class="inside">inside</div>
+<div class="counter-style">counter style</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/pseudo-elements-of-table-column-displays.html b/Tests/LibWeb/Layout/input/tree-builder/pseudo-elements-of-table-column-displays.html
new file mode 100644
index 00000000000..3d3c41522e3
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/pseudo-elements-of-table-column-displays.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<style>
+ .column-group::before { display: table-column-group; content: "x"; }
+ .column::before { display: table-column; content: "y" counter(c) url(../../../Assets/120.png); }
+ .column-group-in-table::after { display: table-column-group; content: "z"; }
+ .table-pseudo::before { display: table; content: "w"; }
+</style>
+<div class="column-group">a</div>
+<div class="column">b</div>
+<div class="column-group-in-table" style="display: table"><div style="display: table-cell">c</div></div>
+<div class="table-pseudo">d</div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/pseudo-elements-on-void-and-replaced.html b/Tests/LibWeb/Layout/input/tree-builder/pseudo-elements-on-void-and-replaced.html
new file mode 100644
index 00000000000..1d3895c2039
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/pseudo-elements-on-void-and-replaced.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<style>
+ .p::before { content: "before"; }
+ .p::after { content: "after"; }
+</style>
+<div><img class="p" src="../../../Assets/120.png" width="10" height="10"></div>
+<div><img class="p" alt="broken"></div>
+<div><input class="p"></div>
+<div><input class="p" type="checkbox"></div>
+<div>a<br class="p">b</div>
+<hr class="p">
+<div><video class="p" width="20" height="10"></video></div>
+<div><iframe class="p" width="20" height="10"></iframe></div>
+<div><select class="p"><option>x</option></select></div>
+<div><textarea class="p"></textarea></div>
+<div><progress class="p"></progress></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/quotes-across-block-siblings.html b/Tests/LibWeb/Layout/input/tree-builder/quotes-across-block-siblings.html
new file mode 100644
index 00000000000..1c01a3ebcdb
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/quotes-across-block-siblings.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<style>
+ body { quotes: "<1" "1>" "<2" "2>" "<3" "3>"; }
+ .open::before { content: open-quote; }
+ .close::after { content: close-quote; }
+</style>
+<p class="open">opens a quote</p>
+<p class="open">opens a nested quote</p>
+<div><div><p class="open">third level</p></div></div>
+<p class="close">closes third</p>
+<p class="close">closes second</p>
+<p class="open close">balanced at level two</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/quotes-in-marker-before-children.html b/Tests/LibWeb/Layout/input/tree-builder/quotes-in-marker-before-children.html
new file mode 100644
index 00000000000..d0610f9a478
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/quotes-in-marker-before-children.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<style>
+ body { font: 16px monospace; quotes: "<" ">" "<<" ">>" "<<<" ">>>" "<<<<" ">>>>"; }
+ li::marker { content: open-quote; }
+ .open::before { content: open-quote; }
+ .close::after { content: close-quote; }
+</style>
+<ul>
+ <li class="open"><q>child</q></li>
+ <li class="close">text</li>
+ <li><span class="open">span</span></li>
+</ul>
+<p class="open">after</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/quotes-in-markers-and-top-layer.html b/Tests/LibWeb/Layout/input/tree-builder/quotes-in-markers-and-top-layer.html
new file mode 100644
index 00000000000..ed0c1279b08
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/quotes-in-markers-and-top-layer.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<style>
+ body { quotes: "<1" "1>" "<2" "2>" "<3" "3>" "<4" "4>" "<5" "5>" "<6" "6>"; }
+ li::marker { content: open-quote; }
+ li.close::marker { content: close-quote; }
+ .open::before { content: open-quote; }
+ dialog { margin: 0; }
+</style>
+<ul>
+ <li>first</li>
+ <li><span class="open">second</span></li>
+ <li class="close">third</li>
+</ul>
+<p class="open">after list</p>
+<dialog id="dialog"><span class="open">in dialog</span></dialog>
+<p class="open">after dialog</p>
+<script>
+ dialog.showModal();
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/quotes-in-shadow-and-slots.html b/Tests/LibWeb/Layout/input/tree-builder/quotes-in-shadow-and-slots.html
new file mode 100644
index 00000000000..6d7bc75995f
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/quotes-in-shadow-and-slots.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<style>
+ body { quotes: "<1" "1>" "<2" "2>" "<3" "3>"; }
+ .close::after { content: close-quote; }
+ .open::before { content: open-quote; }
+</style>
+<div id="host"><span class="close">slotted</span></div>
+<p class="open">after host</p>
+<script>
+ const shadow = host.attachShadow({ mode: "open" });
+ shadow.innerHTML = `<style>.open::before { content: open-quote; }</style><span class="open">shadow</span> <slot></slot> <span class="open">shadow after slot</span>`;
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/quotes-no-open-no-close.html b/Tests/LibWeb/Layout/input/tree-builder/quotes-no-open-no-close.html
new file mode 100644
index 00000000000..c9eee794a91
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/quotes-no-open-no-close.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<style>
+ body { quotes: "<1" "1>" "<2" "2>" "<3" "3>"; }
+ .close-at-zero::before { content: close-quote "x"; }
+ .open::before { content: open-quote; }
+ .no-open::before { content: no-open-quote; }
+ .no-close::before { content: no-close-quote; }
+</style>
+<p class="close-at-zero">close at depth zero</p>
+<p class="no-open">no-open-quote</p>
+<p class="open">open after no-open</p>
+<p class="no-close">no-close-quote</p>
+<p class="open">open after no-close</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/quotes-style-containment.html b/Tests/LibWeb/Layout/input/tree-builder/quotes-style-containment.html
new file mode 100644
index 00000000000..97ecb215a0b
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/quotes-style-containment.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<style>
+ body { quotes: "<1" "1>" "<2" "2>" "<3" "3>"; }
+ .open::before { content: open-quote; }
+ .close::after { content: close-quote; }
+ .contained { contain: style; }
+</style>
+<p class="open">outer</p>
+<div class="contained">
+ <p class="open">inside contained</p>
+ <p class="open">inside contained again</p>
+</div>
+<p class="open">after contained</p>
+<p class="close">close</p>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/replaced-element-with-table-display-out-of-flow.html b/Tests/LibWeb/Layout/input/tree-builder/replaced-element-with-table-display-out-of-flow.html
new file mode 100644
index 00000000000..d14357d62d9
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/replaced-element-with-table-display-out-of-flow.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<style>
+ canvas { width: 10px; height: 10px; }
+ .table { display: table; }
+ .float { float: left; }
+ .abspos { position: absolute; }
+</style>
+<div class="table">text<canvas class="float" style="display: table-cell"></canvas></div>
+<div class="table">text<canvas class="abspos" style="display: table-row"></canvas></div>
+<div class="table"><canvas class="float" style="display: table-caption"></canvas></div>
+<div class="table"><canvas style="display: table-cell"></canvas></div>
+<div><canvas class="abspos" style="display: table-caption"></canvas></div>
+<div><canvas class="abspos" style="display: table-row-group"></canvas></div>
+<div><canvas class="abspos" style="display: table-header-group"></canvas></div>
+<div><canvas class="abspos" style="display: table-column-group"></canvas></div>
+<div><canvas class="float" style="display: table-caption"></canvas></div>
+<div><canvas class="float" style="display: table-row"></canvas></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/replaced-element-with-table-display.html b/Tests/LibWeb/Layout/input/tree-builder/replaced-element-with-table-display.html
new file mode 100644
index 00000000000..869f227608c
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/replaced-element-with-table-display.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<style>
+ img, canvas { width: 10px; height: 10px; }
+</style>
+<div><img src="../../../Assets/120.png" style="display: table"></div>
+<div><img src="../../../Assets/120.png" style="display: inline-table"></div>
+<div><img src="../../../Assets/120.png" style="display: table-cell"></div>
+<div><img src="../../../Assets/120.png" style="display: table-row"></div>
+<div><canvas style="display: table-caption"></canvas></div>
+<div><canvas style="display: table-row-group"></canvas></div>
+<div><canvas style="display: table-column"></canvas></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/scroll-container-pseudo-and-marker.html b/Tests/LibWeb/Layout/input/tree-builder/scroll-container-pseudo-and-marker.html
new file mode 100644
index 00000000000..e69a62d559d
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/scroll-container-pseudo-and-marker.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<style>
+ .scroller::before { content: "scrolling before"; display: block; overflow: auto; height: 20px; }
+ ul { overflow: auto; height: 40px; }
+</style>
+<div class="scroller">content</div>
+<ul><li>item</li><li>item</li><li>item</li><li>item</li></ul>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/shadow-host-display-contents.html b/Tests/LibWeb/Layout/input/tree-builder/shadow-host-display-contents.html
new file mode 100644
index 00000000000..a89fe17961c
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/shadow-host-display-contents.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<div id="parent"><span>before</span><div id="host" style="display: contents"><p>slotted block</p><span>slotted inline</span></div><span>after</span></div>
+<script>
+ host.attachShadow({ mode: "open" }).innerHTML = `<span>shadow inline</span><slot></slot><div>shadow block</div>`;
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/shadow-light-children-not-rendered.html b/Tests/LibWeb/Layout/input/tree-builder/shadow-light-children-not-rendered.html
new file mode 100644
index 00000000000..9618f9f1602
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/shadow-light-children-not-rendered.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<div id="host"><p>light block</p>light text</div>
+<script>
+ host.attachShadow({ mode: "open" }).innerHTML = "<span>shadow only</span>";
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/slot-fallback-vs-assigned.html b/Tests/LibWeb/Layout/input/tree-builder/slot-fallback-vs-assigned.html
new file mode 100644
index 00000000000..9b2f335de49
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/slot-fallback-vs-assigned.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<div id="host"><span>default assigned</span><span slot="unused">unused name</span></div>
+<script>
+ host.attachShadow({ mode: "open" }).innerHTML = `
+ <div><slot name="named"><i>named fallback</i></slot></div>
+ <div><slot><i>default fallback</i></slot></div>`;
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/slot-with-box.html b/Tests/LibWeb/Layout/input/tree-builder/slot-with-box.html
new file mode 100644
index 00000000000..9a10999bac3
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/slot-with-box.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<div id="block-slot"><span>assigned</span></div>
+<div id="inline-slot"><span>assigned</span></div>
+<div id="block-slot-fallback"></div>
+<script>
+ document.getElementById("block-slot").attachShadow({ mode: "open" }).innerHTML = `<style>slot { display: block; border: 1px solid; }</style>before<slot></slot>after`;
+ document.getElementById("inline-slot").attachShadow({ mode: "open" }).innerHTML = `<style>slot { display: inline; }</style>before<slot></slot>after`;
+ document.getElementById("block-slot-fallback").attachShadow({ mode: "open" }).innerHTML = `<style>slot { display: block; }</style>before<slot><i>fallback</i></slot>after`;
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/svg-clip-path-resource.html b/Tests/LibWeb/Layout/input/tree-builder/svg-clip-path-resource.html
new file mode 100644
index 00000000000..b232eee5914
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/svg-clip-path-resource.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<svg width="200" height="100">
+ <defs>
+ <clipPath id="c"><circle cx="25" cy="25" r="20"/></clipPath>
+ </defs>
+ <rect id="by-attribute" width="50" height="50" clip-path="url(#c)"/>
+ <rect id="by-css" x="60" width="50" height="50" style="clip-path: url(#c)"/>
+ <g id="group" clip-path="url(#c)"><rect x="120" width="50" height="50"/></g>
+</svg>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/svg-mask-shared-by-two-shapes.html b/Tests/LibWeb/Layout/input/tree-builder/svg-mask-shared-by-two-shapes.html
new file mode 100644
index 00000000000..25f8efa0834
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/svg-mask-shared-by-two-shapes.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<svg width="200" height="100">
+ <defs>
+ <mask id="m"><rect width="40" height="40" fill="white"/></mask>
+ </defs>
+ <rect id="first" width="50" height="50" mask="url(#m)"/>
+ <rect id="second" x="60" width="50" height="50" mask="url(#m)"/>
+</svg>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/svg-pattern-resource-and-href.html b/Tests/LibWeb/Layout/input/tree-builder/svg-pattern-resource-and-href.html
new file mode 100644
index 00000000000..b968cd78ef4
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/svg-pattern-resource-and-href.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<svg width="200" height="100">
+ <defs>
+ <pattern id="p" width="10" height="10" patternUnits="userSpaceOnUse"><rect width="5" height="5" fill="green"/></pattern>
+ <pattern id="p2" href="#p" patternTransform="scale(2)"/>
+ </defs>
+ <rect id="fill" width="50" height="50" fill="url(#p)"/>
+ <rect id="stroke" x="60" width="50" height="50" fill="none" stroke-width="10" stroke="url(#p2)"/>
+ <rect id="fill-and-stroke" x="120" width="50" height="50" fill="url(#p)" stroke="url(#p)"/>
+</svg>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/svg-resource-cycles.html b/Tests/LibWeb/Layout/input/tree-builder/svg-resource-cycles.html
new file mode 100644
index 00000000000..391b32428ca
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/svg-resource-cycles.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<svg width="200" height="100">
+ <defs>
+ <mask id="m"><rect id="self-referencing" width="40" height="40" fill="white" mask="url(#m)"/></mask>
+ <pattern id="a" href="#b" width="10" height="10"/>
+ <pattern id="b" href="#a" width="10" height="10"/>
+ <clipPath id="c" clip-path="url(#c)"><rect width="30" height="30"/></clipPath>
+ </defs>
+ <rect id="mask-user" width="50" height="50" mask="url(#m)"/>
+ <rect id="pattern-user" x="60" width="50" height="50" fill="url(#a)"/>
+ <rect id="clip-user" x="120" width="50" height="50" clip-path="url(#c)"/>
+</svg>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/svg-resource-in-other-scope.html b/Tests/LibWeb/Layout/input/tree-builder/svg-resource-in-other-scope.html
new file mode 100644
index 00000000000..f44f1d4578c
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/svg-resource-in-other-scope.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<svg width="200" height="100">
+ <rect id="other-svg-user" width="50" height="50" mask="url(#m)"/>
+</svg>
+<svg width="0" height="0">
+ <mask id="m"><rect width="40" height="40" fill="white"/></mask>
+</svg>
+<div id="host"></div>
+<script>
+ host.attachShadow({ mode: "open" }).innerHTML = `
+ <svg width="200" height="100">
+ <mask id="shadow-mask"><circle cx="20" cy="20" r="20" fill="white"/></mask>
+ <rect id="shadow-user" width="50" height="50" mask="url(#shadow-mask)"/>
+ </svg>`;
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/svg-switch-first-renderable.html b/Tests/LibWeb/Layout/input/tree-builder/svg-switch-first-renderable.html
new file mode 100644
index 00000000000..0bc71ce84ea
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/svg-switch-first-renderable.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<svg id="svg" width="100" height="100">
+ <switch id="non-svg-first">
+ <rect id="chosen-1" width="10" height="10"/>
+ <circle r="5"/>
+ </switch>
+ <switch id="hidden-first">
+ <rect style="display: none" width="10" height="10"/>
+ <circle id="chosen-2" r="5"/>
+ <rect width="10" height="10"/>
+ </switch>
+ <switch id="conditional-attributes">
+ <rect systemLanguage="xx-unknown" width="10" height="10"/>
+ <g id="chosen-3"><rect width="5" height="5"/></g>
+ <rect width="10" height="10"/>
+ </switch>
+ <switch id="text-and-comments">
+ text<!-- comment --><text id="chosen-4" y="20">svg text</text>
+ <rect width="10" height="10"/>
+ </switch>
+</svg>
+<script>
+ // NB: The HTML parser cannot put an HTML element inside <svg>, so insert one from script.
+ const div = document.createElement("div");
+ div.textContent = "html";
+ document.getElementById("non-svg-first").prepend(div);
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/svg-text-tspan-textpath.html b/Tests/LibWeb/Layout/input/tree-builder/svg-text-tspan-textpath.html
new file mode 100644
index 00000000000..40386ab8b71
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/svg-text-tspan-textpath.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<svg width="300" height="100">
+ <defs><path id="path" d="M 10 80 L 290 80"/></defs>
+ <text x="10" y="20">Hello <tspan fill="green">tspan</tspan> <a href="#">link</a>
+ tail</text>
+ <text><textPath href="#path">On a <tspan>path</tspan></textPath></text>
+</svg>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/table-caption-and-colgroup-order.html b/Tests/LibWeb/Layout/input/tree-builder/table-caption-and-colgroup-order.html
new file mode 100644
index 00000000000..e750f5e0a88
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/table-caption-and-colgroup-order.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<table>
+ <tfoot><tr><td>foot</td></tr></tfoot>
+ <tbody><tr><td>body 1</td></tr></tbody>
+ <caption>first caption</caption>
+ <thead><tr><td>head</td></tr></thead>
+ <colgroup><col></colgroup>
+ <tbody><tr><td>body 2</td></tr></tbody>
+ <caption style="caption-side: bottom">bottom caption</caption>
+</table>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/table-column-children-removed.html b/Tests/LibWeb/Layout/input/tree-builder/table-column-children-removed.html
new file mode 100644
index 00000000000..aa6f68905c6
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/table-column-children-removed.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<div style="display: table">
+ <div style="display: table-column"><span>column child</span></div>
+ <div style="display: table-column-group">text<div style="display: table-column"></div><span>group child</span></div>
+ <div style="display: table-cell">cell</div>
+</div>
+<table>
+ <colgroup>text<col><span>span in colgroup</span></colgroup>
+ <tr><td>cell</td></tr>
+</table>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/table-loose-cells-in-inline.html b/Tests/LibWeb/Layout/input/tree-builder/table-loose-cells-in-inline.html
new file mode 100644
index 00000000000..01de5e474ec
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/table-loose-cells-in-inline.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<style>
+ .c { display: table-cell; }
+</style>
+<div><span>a<span class="c">b</span>c</span></div>
+<div>a<div class="c">b</div>c</div>
+<div><span>a<span class="c">b</span><span class="c">c</span> <span style="display: table-row">d</span>e</span></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/table-parts-in-flex-and-grid.html b/Tests/LibWeb/Layout/input/tree-builder/table-parts-in-flex-and-grid.html
new file mode 100644
index 00000000000..1434deed94b
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/table-parts-in-flex-and-grid.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<div style="display: flex"><div style="display: table-row">row</div><div style="display: table-cell">cell</div></div>
+<div style="display: grid"><div style="display: table-cell">a</div><div style="display: table-cell">b</div></div>
+<div style="display: flex"><span><span style="display: table-cell">cell in inline flex item</span></span></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/table-parts-through-display-contents-and-slots.html b/Tests/LibWeb/Layout/input/tree-builder/table-parts-through-display-contents-and-slots.html
new file mode 100644
index 00000000000..532a4aebba5
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/table-parts-through-display-contents-and-slots.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<table><tr><td>first</td><td style="display: contents"><span>contents cell content</span></td></tr></table>
+<div style="display: table"><div style="display: table-row"><div style="display: contents"><div style="display: table-cell">a</div><div style="display: table-cell">b</div></div></div></div>
+<div id="host"><div style="display: table-row"><div style="display: table-cell">slotted row</div></div></div>
+<script>
+ host.attachShadow({ mode: "open" }).innerHTML = `<div style="display: table"><slot></slot></div>`;
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/table-pseudo-elements-as-parts.html b/Tests/LibWeb/Layout/input/tree-builder/table-pseudo-elements-as-parts.html
new file mode 100644
index 00000000000..996a01a72f6
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/table-pseudo-elements-as-parts.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<style>
+ tr::before { content: "cell before"; display: table-cell; }
+ table::after { content: "row after"; display: table-row; }
+ td::after { content: "inline after"; }
+ tbody::before { content: "group before"; }
+</style>
+<table><tr><td>cell</td></tr></table>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/table-whitespace-between-parts.html b/Tests/LibWeb/Layout/input/tree-builder/table-whitespace-between-parts.html
new file mode 100644
index 00000000000..a09b913e8b6
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/table-whitespace-between-parts.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<style>
+ .t { display: table; } .rg { display: table-row-group; } .r { display: table-row; } .c { display: table-cell; }
+</style>
+<div class="t"> <div class="rg"> <div class="r"> <div class="c">a</div> <div class="c">b</div> </div> </div> </div>
+<div class="t"> <div class="c">loose</div> <div class="c">cells</div> </div>
+<div class="t"> <span>inline</span> <div class="r"><div class="c">cell</div></div> </div>
+<div class="r"> <div class="c">anonymous table</div> </div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/top-layer-member-in-shadow-tree.html b/Tests/LibWeb/Layout/input/tree-builder/top-layer-member-in-shadow-tree.html
new file mode 100644
index 00000000000..398c2865041
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/top-layer-member-in-shadow-tree.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<style>
+ dialog { margin: 0; }
+</style>
+<div id="host"><dialog id="slotted-dialog">slotted dialog</dialog></div>
+<p>content</p>
+<script>
+ const shadow = host.attachShadow({ mode: "open" });
+ shadow.innerHTML = `<style>dialog { margin: 0; }</style><dialog id="shadow-dialog">shadow dialog</dialog><div><slot></slot></div>`;
+ shadow.getElementById("shadow-dialog").showModal();
+ document.getElementById("slotted-dialog").showModal();
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/top-layer-member-inside-display-none.html b/Tests/LibWeb/Layout/input/tree-builder/top-layer-member-inside-display-none.html
new file mode 100644
index 00000000000..1fc74ae537e
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/top-layer-member-inside-display-none.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<style>
+ dialog { margin: 0; }
+</style>
+<div style="display: none">
+ <dialog id="hidden-ancestor-dialog">inside display none</dialog>
+</div>
+<dialog id="visible-dialog">visible</dialog>
+<p>content</p>
+<script>
+ document.getElementById("hidden-ancestor-dialog").showModal();
+ document.getElementById("visible-dialog").showModal();
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/top-layer-order-dialog-popover.html b/Tests/LibWeb/Layout/input/tree-builder/top-layer-order-dialog-popover.html
new file mode 100644
index 00000000000..1b1b41d0f91
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/top-layer-order-dialog-popover.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<style>
+ dialog, [popover] { margin: 0; padding: 0; border: none; }
+ ::backdrop { background: rgba(0, 0, 0, 0.1); }
+</style>
+<div id="popover" popover="manual">popover</div>
+<dialog id="first">first dialog</dialog>
+<dialog id="second">second dialog</dialog>
+<p>content</p>
+<script>
+ second.showModal();
+ popover.showPopover();
+ first.showModal();
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/ua-shadow-details-content.html b/Tests/LibWeb/Layout/input/tree-builder/ua-shadow-details-content.html
new file mode 100644
index 00000000000..8489068684e
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/ua-shadow-details-content.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<style>
+ details::details-content { display: flex; color: green; }
+ .closed::details-content { background: red; }
+</style>
+<details open><summary>open summary</summary><span>a</span><span>b</span></details>
+<details class="closed"><summary>closed summary</summary><span>hidden</span></details>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/video-audio-light-children-not-rendered.html b/Tests/LibWeb/Layout/input/tree-builder/video-audio-light-children-not-rendered.html
new file mode 100644
index 00000000000..4c75fd232a5
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/video-audio-light-children-not-rendered.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<style>
+ video::before { content: "before"; }
+</style>
+<video width="100" height="50"><div>fallback</div>text</video>
+<audio><div>fallback</div></audio>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/whitespace-after-br-and-oof.html b/Tests/LibWeb/Layout/input/tree-builder/whitespace-after-br-and-oof.html
new file mode 100644
index 00000000000..bfe4f6c09cd
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/whitespace-after-br-and-oof.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<div id="after-br">a<br> <b>x</b></div>
+<div id="after-abspos"><span>a</span><div style="position: absolute"></div> <b>x</b></div>
+<div id="after-float"><span>a</span><div style="float: left"></div> b</div>
+<div id="abspos-at-start"><div style="position: absolute"></div> <b>x</b></div>
+<div id="float-at-start"><div style="float: left"></div> <b>x</b></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/whitespace-after-contents-pseudo.html b/Tests/LibWeb/Layout/input/tree-builder/whitespace-after-contents-pseudo.html
new file mode 100644
index 00000000000..252f0b8cd3c
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/whitespace-after-contents-pseudo.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<style>
+ .contents { display: contents; }
+ .after::after { content: "after"; }
+ .before::before { content: "before"; }
+ .block-after::after { content: "after"; display: block; }
+</style>
+<div id="after-pseudo"><em class="contents after"></em> <b>x</b></div>
+<div id="before-pseudo-leading-whitespace"><em class="contents before"> <b>x</b></em></div>
+<div id="block-after-pseudo"><em class="contents block-after"></em> <b>x</b></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/whitespace-after-display-contents-at-start.html b/Tests/LibWeb/Layout/input/tree-builder/whitespace-after-display-contents-at-start.html
new file mode 100644
index 00000000000..7082971f918
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/whitespace-after-display-contents-at-start.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<!-- Whether a whitespace-only text node gets a box depends on what precedes it, looking through display:contents. -->
+<div id="after-inline"><span>a</span><em style="display: contents"> <b>x</b></em></div>
+<div id="after-block"><p>a</p><em style="display: contents"> <b>x</b></em></div>
+<div id="nested-contents"><span>a</span><em style="display: contents"><i style="display: contents"> <b>x</b></i></em></div>
+<div id="contents-ends-with-inline"><em style="display: contents"><span>a</span></em> <b>x</b></div>
+<div id="contents-ends-with-block"><em style="display: contents"><p>a</p></em> <b>x</b></div>
+<div id="empty-contents"><span>a</span><em style="display: contents"></em> <b>x</b></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/whitespace-after-top-layer-member.html b/Tests/LibWeb/Layout/input/tree-builder/whitespace-after-top-layer-member.html
new file mode 100644
index 00000000000..6286664acf3
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/whitespace-after-top-layer-member.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<style>
+ dialog { margin: 0; }
+</style>
+<div id="between-blocks"><p>a</p> <dialog id="first">dialog</dialog> <p>b</p></div>
+<div id="after-inline"><span>a</span><dialog id="second">dialog</dialog> <b>x</b></div>
+<script>
+ first.showModal();
+ second.showModal();
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/whitespace-in-flex-grid-math.html b/Tests/LibWeb/Layout/input/tree-builder/whitespace-in-flex-grid-math.html
new file mode 100644
index 00000000000..24d5bb38de2
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/whitespace-in-flex-grid-math.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<div style="display: flex"><span>a</span> <span>b</span></div>
+<div style="display: flex">a <span>b</span></div>
+<div style="display: grid"><span>a</span> <span>b</span></div>
+<div style="display: grid">a <span>b</span></div>
+<div style="display: math"><span>a</span> <span>b</span></div>
+<div style="display: math">a <span>b</span></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/whitespace-in-slot-assigned-nodes.html b/Tests/LibWeb/Layout/input/tree-builder/whitespace-in-slot-assigned-nodes.html
new file mode 100644
index 00000000000..8f8c3009f25
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/whitespace-in-slot-assigned-nodes.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<div id="between-assigned"><span>a</span> <span>b</span></div>
+<div id="before-first-assigned"> <span>a</span></div>
+<div id="slot-with-box"><span>a</span> <span>b</span></div>
+<div id="after-block-assigned"><p>a</p> <span>b</span></div>
+<script>
+ for (const id of ["between-assigned", "before-first-assigned", "after-block-assigned"])
+ document.getElementById(id).attachShadow({ mode: "open" }).innerHTML = "<span>shadow</span><slot></slot>";
+ document.getElementById("slot-with-box").attachShadow({ mode: "open" }).innerHTML = `<style>slot { display: block; }</style><span>shadow</span> <slot></slot>`;
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/whitespace-in-slot-fallback.html b/Tests/LibWeb/Layout/input/tree-builder/whitespace-in-slot-fallback.html
new file mode 100644
index 00000000000..6e63e344a09
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/whitespace-in-slot-fallback.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<div id="fallback-after-inline"></div>
+<div id="fallback-after-block"></div>
+<div id="whitespace-around-slot"></div>
+<script>
+ document.getElementById("fallback-after-inline").attachShadow({ mode: "open" }).innerHTML = "<span>shadow</span><slot> <b>fallback</b> <i>more</i></slot>";
+ document.getElementById("fallback-after-block").attachShadow({ mode: "open" }).innerHTML = "<p>shadow</p><slot> <b>fallback</b></slot>";
+ document.getElementById("whitespace-around-slot").attachShadow({ mode: "open" }).innerHTML = "<span>shadow</span> <slot></slot> <span>end</span>";
+</script>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/whitespace-in-svg-text-and-textpath.html b/Tests/LibWeb/Layout/input/tree-builder/whitespace-in-svg-text-and-textpath.html
new file mode 100644
index 00000000000..79b7fcd7470
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/whitespace-in-svg-text-and-textpath.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<svg width="300" height="100">
+ <defs><path id="path" d="M 10 80 L 290 80"/></defs>
+ <g> <rect width="5" height="5"/> </g>
+ <text x="10" y="20"> <tspan>a</tspan> <tspan>b</tspan> </text>
+ <text><textPath href="#path"> <tspan>c</tspan> </textPath></text>
+</svg>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/whitespace-list-item-inside-at-start.html b/Tests/LibWeb/Layout/input/tree-builder/whitespace-list-item-inside-at-start.html
new file mode 100644
index 00000000000..97f6e497048
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/whitespace-list-item-inside-at-start.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<ul>
+ <li style="list-style-position: inside"> <b>inside</b></li>
+ <li style="list-style-position: outside"> <b>outside</b></li>
+ <li style="list-style-position: inside"> <div>inside block</div></li>
+</ul>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/whitespace-pre-line-pre-wrap-break-spaces.html b/Tests/LibWeb/Layout/input/tree-builder/whitespace-pre-line-pre-wrap-break-spaces.html
new file mode 100644
index 00000000000..031843d47c0
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/whitespace-pre-line-pre-wrap-break-spaces.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<div style="white-space: pre"><p>a</p> <p>b</p></div>
+<div style="white-space: pre-line"><p>a</p>
+<p>b</p> <p>c</p></div>
+<div style="white-space: pre-wrap"><p>a</p> <p>b</p></div>
+<div style="white-space: break-spaces"><p>a</p> <p>b</p></div>
+<div style="white-space: nowrap"><p>a</p> <p>b</p></div>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/writing-suggestion-in-nested-inline.html b/Tests/LibWeb/Layout/input/tree-builder/writing-suggestion-in-nested-inline.html
new file mode 100644
index 00000000000..a0d2f20cc5e
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/writing-suggestion-in-nested-inline.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html class="test-wait">
+<div id="editable" contenteditable>before <span><b id="target">-xyz</b></span> after</div>
+<script>
+ const target = document.getElementById("target");
+ document.getElementById("editable").focus();
+ getSelection().collapse(target.firstChild, 0);
+ internals.sendText(target, "predi");
+ internals.writingSuggestionSettled().then(() => document.documentElement.classList.remove("test-wait"));
+</script>
+</html>
diff --git a/Tests/LibWeb/Layout/input/tree-builder/writing-suggestion-split.html b/Tests/LibWeb/Layout/input/tree-builder/writing-suggestion-split.html
new file mode 100644
index 00000000000..e7274b80f20
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/tree-builder/writing-suggestion-split.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html class="test-wait">
+<div id="editable" contenteditable>-xyz</div>
+<script>
+ const editable = document.getElementById("editable");
+ editable.focus();
+ getSelection().collapse(editable.firstChild, 0);
+ internals.sendText(editable, "predi");
+ internals.writingSuggestionSettled().then(() => document.documentElement.classList.remove("test-wait"));
+</script>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/selection-on-text-under-display-contents-ref.html b/Tests/LibWeb/Ref/expected/selection-on-text-under-display-contents-ref.html
new file mode 100644
index 00000000000..d16de00a427
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/selection-on-text-under-display-contents-ref.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<style>
+ #target::selection { background: lime; color: black; }
+</style>
+<div id="target">selected text</div>
+<script>
+ getSelection().selectAllChildren(document.getElementById("target"));
+</script>
diff --git a/Tests/LibWeb/Ref/input/selection-on-text-under-display-contents.html b/Tests/LibWeb/Ref/input/selection-on-text-under-display-contents.html
new file mode 100644
index 00000000000..5d32e64893e
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/selection-on-text-under-display-contents.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<link rel="match" href="../expected/selection-on-text-under-display-contents-ref.html">
+<style>
+ .contents { display: contents; }
+ .contents::selection { background: lime; color: black; }
+</style>
+<div id="target"><span class="contents">selected text</span></div>
+<script>
+ getSelection().selectAllChildren(document.getElementById("target"));
+</script>
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/append-into-trailing-inline-run.txt b/Tests/LibWeb/Text/expected/layout-tree-update/append-into-trailing-inline-run.txt
new file mode 100644
index 00000000000..7f1f9388d18
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/append-into-trailing-inline-run.txt
@@ -0,0 +1,110 @@
+text run, append text: kept KKKKKK, tree matches=true
+text run, append a span: kept KKKKKK, tree matches=true
+text run, append a block: kept KKKKKK, tree matches=true
+text run, append a span and a block: kept KKKKKK, tree matches=true
+text run, append a float: kept KKKKKK, tree matches=true
+text run, insert a span inside the run: kept KKKKKK, tree matches=true
+text run, append and restyle the first block: kept KKKKKK, tree matches=true
+text run, append and hide the first block: kept ------, tree matches=true
+text run, append and restyle the last span: kept KKKKKK, tree matches=true
+text run, append and remove the last span: kept ------, tree matches=true
+run after two blocks, append text: kept KKKKKK, tree matches=true
+run after two blocks, append a span: kept KKKKKK, tree matches=true
+run after two blocks, append a block: kept KKKKKK, tree matches=true
+run after two blocks, append a span and a block: kept KKKKKK, tree matches=true
+run after two blocks, append a float: kept KKKKKK, tree matches=true
+run after two blocks, insert a span inside the run: kept KKKKKK, tree matches=true
+run after two blocks, append and restyle the first block: kept KKKKKK, tree matches=true
+run after two blocks, append and hide the first block: kept K-KKKK, tree matches=true
+run after two blocks, append and restyle the last span: kept KKKKKK, tree matches=true
+run after two blocks, append and remove the last span: kept ------, tree matches=true
+run with whitespace, append text: kept KK.KK, tree matches=true
+run with whitespace, append a span: kept KK.KK, tree matches=true
+run with whitespace, append a block: kept KK.KK, tree matches=true
+run with whitespace, append a span and a block: kept KK.KK, tree matches=true
+run with whitespace, append a float: kept KK.KK, tree matches=true
+run with whitespace, insert a span inside the run: kept KK.KK, tree matches=true
+run with whitespace, append and restyle the first block: kept KK.KK, tree matches=true
+run with whitespace, append and hide the first block: kept --.--, tree matches=true
+run with whitespace, append and restyle the last span: kept KK.KK, tree matches=true
+run with whitespace, append and remove the last span: kept --.--, tree matches=true
+run starting with a span, append text: kept KKKK, tree matches=true
+run starting with a span, append a span: kept KKKK, tree matches=true
+run starting with a span, append a block: kept KKKK, tree matches=true
+run starting with a span, append a span and a block: kept KKKK, tree matches=true
+run starting with a span, append a float: kept KKKK, tree matches=true
+run starting with a span, insert a span inside the run: kept KKKK, tree matches=true
+run starting with a span, append and restyle the first block: kept KKKK, tree matches=true
+run starting with a span, append and hide the first block: kept ----, tree matches=true
+run starting with a span, append and restyle the last span: kept KKKK, tree matches=true
+run starting with a span, append and remove the last span: kept ----, tree matches=true
+run with a float, append text: kept KKKKK, tree matches=true
+run with a float, append a span: kept KKKKK, tree matches=true
+run with a float, append a block: kept KKKKK, tree matches=true
+run with a float, append a span and a block: kept KKKKK, tree matches=true
+run with a float, append a float: kept KKKKK, tree matches=true
+run with a float, insert a span inside the run: kept KKKKK, tree matches=true
+run with a float, append and restyle the first block: kept KKKKK, tree matches=true
+run with a float, append and hide the first block: kept -----, tree matches=true
+run with a float, append and restyle the last span: kept KKKKK, tree matches=true
+run with a float, append and remove the last span: kept -----, tree matches=true
+run with an absolute box, append text: kept KKKK, tree matches=true
+run with an absolute box, append a span: kept KKKK, tree matches=true
+run with an absolute box, append a block: kept KKKK, tree matches=true
+run with an absolute box, append a span and a block: kept KKKK, tree matches=true
+run with an absolute box, append a float: kept KKKK, tree matches=true
+run with an absolute box, insert a span inside the run: kept KKKK, tree matches=true
+run with an absolute box, append and restyle the first block: kept KKKK, tree matches=true
+run with an absolute box, append and hide the first block: kept ----, tree matches=true
+run with an absolute box, append and restyle the last span: kept KKKK, tree matches=true
+run with an absolute box, append and remove the last span: kept ----, tree matches=true
+run with a hidden child, append text: kept KKK.K, tree matches=true
+run with a hidden child, append a span: kept KKK.K, tree matches=true
+run with a hidden child, append a block: kept KKK.K, tree matches=true
+run with a hidden child, append a span and a block: kept KKK.K, tree matches=true
+run with a hidden child, append a float: kept KKK.K, tree matches=true
+run with a hidden child, insert a span inside the run: kept KKK.K, tree matches=true
+run with a hidden child, append and restyle the first block: kept KKK.K, tree matches=true
+run with a hidden child, append and hide the first block: kept ---.-, tree matches=true
+run with a hidden child, append and restyle the last span: kept KKK.K, tree matches=true
+run with a hidden child, append and remove the last span: kept KKK.K, tree matches=true
+run with contents, append text: kept --., tree matches=true
+run with contents, append a span: kept --., tree matches=true
+run with contents, append a block: kept --., tree matches=true
+run with contents, append a span and a block: kept --., tree matches=true
+run with contents, append a float: kept --., tree matches=true
+run with contents, insert a span inside the run: kept --., tree matches=true
+run with contents, append and restyle the first block: kept --., tree matches=true
+run with contents, append and hide the first block: kept --., tree matches=true
+run with contents, append and restyle the last span: kept --., tree matches=true
+run with contents, append and remove the last span: kept --., tree matches=true
+run with a block in an inline, append text: kept KKK, tree matches=true
+run with a block in an inline, append a span: kept KKK, tree matches=true
+run with a block in an inline, append a block: kept KKK, tree matches=true
+run with a block in an inline, append a span and a block: kept KKK, tree matches=true
+run with a block in an inline, append a float: kept KKK, tree matches=true
+run with a block in an inline, insert a span inside the run: kept KKK, tree matches=true
+run with a block in an inline, append and restyle the first block: kept KKK, tree matches=true
+run with a block in an inline, append and hide the first block: kept ---, tree matches=true
+run with a block in an inline, append and restyle the last span: kept KKK, tree matches=true
+run with a block in an inline, append and remove the last span: kept ---, tree matches=true
+run after a float, append text: kept KKKK, tree matches=true
+run after a float, append a span: kept KKKK, tree matches=true
+run after a float, append a block: kept KKKK, tree matches=true
+run after a float, append a span and a block: kept KKKK, tree matches=true
+run after a float, append a float: kept KKKK, tree matches=true
+run after a float, insert a span inside the run: kept KKKK, tree matches=true
+run after a float, append and restyle the first block: kept KKKK, tree matches=true
+run after a float, append and hide the first block: kept ----, tree matches=true
+run after a float, append and restyle the last span: kept KKKK, tree matches=true
+run after a float, append and remove the last span: kept ----, tree matches=true
+only a run, append text: kept KKK, tree matches=true
+only a run, append a span: kept KKK, tree matches=true
+only a run, append a block: kept KKK, tree matches=true
+only a run, append a span and a block: kept KKK, tree matches=true
+only a run, append a float: kept KKK, tree matches=true
+only a run, insert a span inside the run: kept KKK, tree matches=true
+only a run, append and restyle the first block: kept KKK, tree matches=true
+only a run, append and hide the first block: kept ---, tree matches=true
+only a run, append and restyle the last span: kept KKK, tree matches=true
+only a run, append and remove the last span: kept ---, tree matches=true
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/append-leaves-other-anonymous-wrappers-clean.txt b/Tests/LibWeb/Text/expected/layout-tree-update/append-leaves-other-anonymous-wrappers-clean.txt
new file mode 100644
index 00000000000..183314787ac
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/append-leaves-other-anonymous-wrappers-clean.txt
@@ -0,0 +1,6 @@
+BlockContainer<DIV> REUSE IN-FLOW SUBTREE
+BlockContainer<DIV> REUSE IN-FLOW SUBTREE
+BlockContainer<DIV> REUSE IN-FLOW SUBTREE
+BlockContainer<DIV> REUSE IN-FLOW SUBTREE
+geometry matches a fresh layout: true
+tree matches a full rebuild: true
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/append-with-change-inside-display-contents-child.txt b/Tests/LibWeb/Text/expected/layout-tree-update/append-with-change-inside-display-contents-child.txt
new file mode 100644
index 00000000000..36c4f8f7fa7
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/append-with-change-inside-display-contents-child.txt
@@ -0,0 +1,20 @@
+PASS: display: contents: make the flattened element flex
+PASS: display: contents: make the flattened element inline
+PASS: display: contents: hide the flattened element
+PASS: display: contents: make the flattened element float
+PASS: display: contents: change the font size of the flattened element
+PASS: display: contents: set the text content of the flattened element
+PASS: display: contents: change a flattened text
+PASS: display: contents: remove a flattened text
+PASS: display: contents: insert a block next to the flattened element
+PASS: slot: make the flattened element flex
+PASS: slot: make the flattened element inline
+PASS: slot: hide the flattened element
+PASS: slot: make the flattened element float
+PASS: slot: change the font size of the flattened element
+PASS: slot: set the text content of the flattened element
+PASS: slot: change a flattened text
+PASS: slot: remove a flattened text
+PASS: slot: insert a block next to the flattened element
+PASS: display: contents: make the display: contents child a block
+19 cases; 19 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/append-with-earlier-sibling-change.txt b/Tests/LibWeb/Text/expected/layout-tree-update/append-with-earlier-sibling-change.txt
new file mode 100644
index 00000000000..75e98b189b8
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/append-with-earlier-sibling-change.txt
@@ -0,0 +1,24 @@
+nothing, append block: kept KKKK-K, tree matches=true
+nothing, append text: kept KKKK-K, tree matches=true
+restyle keeping the box kind, append block: kept KKKK-K, tree matches=true
+restyle keeping the box kind, append text: kept KKKK-K, tree matches=true
+restyle to inline, append block: kept ------, tree matches=true
+restyle to inline, append text: kept ------, tree matches=true
+restyle to display none, append block: kept KK-K-K, tree matches=true
+restyle to display none, append text: kept KK-K-K, tree matches=true
+restyle to float, append block: kept ------, tree matches=true
+restyle to float, append text: kept ------, tree matches=true
+show a hidden child, append block: kept KKKK-K, tree matches=true
+show a hidden child, append text: kept KKKK-K, tree matches=true
+insert before the second child, append block: kept KKKK-K, tree matches=true
+insert before the second child, append text: kept KKKK-K, tree matches=true
+append to the second child, append block: kept KKKK-K, tree matches=true
+append to the second child, append text: kept KKKK-K, tree matches=true
+change the first text, append block: kept KKKK-K, tree matches=true
+change the first text, append text: kept KKKK-K, tree matches=true
+remove the first child, append block: kept ------, tree matches=true
+remove the first child, append text: kept ------, tree matches=true
+restyle the last child, append block: kept KKKK-K, tree matches=true
+restyle the last child, append text: kept KKKK-K, tree matches=true
+restyle the last child to inline, append block: kept ------, tree matches=true
+restyle the last child to inline, append text: kept ------, tree matches=true
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/box-unit-cases.txt b/Tests/LibWeb/Text/expected/layout-tree-update/box-unit-cases.txt
new file mode 100644
index 00000000000..7ed6149e22b
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/box-unit-cases.txt
@@ -0,0 +1,40 @@
+PASS: remove a block from a long block list
+PASS: remove the last block among inline content
+PASS: remove an inline from an inline run
+PASS: remove a text between two inline-blocks
+PASS: remove the first counted child
+PASS: remove a list item
+PASS: remove a table row
+PASS: remove a loose cell from a block
+PASS: remove the block that holds the first letter
+PASS: remove a child of a display: contents child
+PASS: move a block to the front of its list
+PASS: move a block between two lists
+PASS: move an inline into a block list
+PASS: hide a block
+PASS: show a hidden block
+PASS: turn a block into an inline among blocks
+PASS: turn an inline into a block among inlines
+PASS: turn a block into a flex container
+PASS: turn a flex container into a grid
+FAIL: turn a list item into a block
+PASS: turn a block into a table cell
+PASS: turn a block into display: contents
+PASS: turn display: contents into a block
+PASS: make a flex item absolutely positioned
+PASS: float an inline in an inline run
+PASS: change the style of a block that keeps its kind
+PASS: change the white space of a block with white space children
+PASS: add a ::before
+PASS: remove an ::after
+PASS: add a block ::before to an inline list
+PASS: add a ::before to a flex container
+PASS: change the ::marker of a list item
+PASS: add a ::before to a block with a first letter
+PASS: remove and hide in several lists in one update
+34 cases; 33 matched; 1 mismatched
+remove a block: kept children preserved: true, matches full rebuild: true
+hide a block: kept children preserved: true, matches full rebuild: true
+turn a block inline: kept children preserved: false, matches full rebuild: true
+add a ::before: kept children preserved: false, matches full rebuild: true
+move a block: kept children preserved: true, matches full rebuild: true
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/button-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/button-mutations.txt
new file mode 100644
index 00000000000..3fc09a30101
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/button-mutations.txt
@@ -0,0 +1,52 @@
+PASS: default: insert text
+PASS: default: remove all text
+PASS: default: insert an inline
+FAIL: default: insert a block
+PASS: default: remove the inline
+PASS: default: add ::before
+PASS: default: add a block ::after
+PASS: default: make it display flex
+PASS: default: make it display grid
+PASS: default: make it display block
+PASS: default: make it display list-item
+PASS: default: make it display contents
+PASS: default: make it display none
+PASS: default: set appearance none
+PASS: default: make it absolutely positioned
+PASS: flex: insert text
+PASS: flex: remove all text
+PASS: flex: insert an inline
+PASS: flex: insert a block
+PASS: flex: remove the inline
+PASS: flex: add ::before
+PASS: flex: add a block ::after
+PASS: flex: make it display flex
+PASS: flex: make it display grid
+PASS: flex: make it display block
+PASS: flex: make it display list-item
+PASS: flex: make it display contents
+PASS: flex: make it display none
+PASS: flex: set appearance none
+PASS: flex: make it absolutely positioned
+PASS: block: insert text
+PASS: block: remove all text
+PASS: block: insert an inline
+FAIL: block: insert a block
+PASS: block: remove the inline
+PASS: block: add ::before
+PASS: block: add a block ::after
+PASS: block: make it display flex
+PASS: block: make it display grid
+PASS: block: make it display block
+PASS: block: make it display list-item
+PASS: block: make it display contents
+PASS: block: make it display none
+PASS: block: set appearance none
+PASS: block: make it absolutely positioned
+PASS: input type button: toggle appearance none
+PASS: input type submit: toggle appearance none
+PASS: input type reset: toggle appearance none
+PASS: input type checkbox: toggle appearance none
+PASS: input type color: toggle appearance none
+PASS: input type range: toggle appearance none
+51 cases; 49 matched; 2 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/content-image-pseudo-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/content-image-pseudo-mutations.txt
new file mode 100644
index 00000000000..d612f3543db
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/content-image-pseudo-mutations.txt
@@ -0,0 +1,55 @@
+PASS: text -> single image
+PASS: text -> image in a list
+PASS: text -> image with alt text
+PASS: text -> empty string
+PASS: text -> none
+PASS: single image -> text
+PASS: single image -> image in a list
+PASS: single image -> image with alt text
+PASS: single image -> empty string
+PASS: single image -> none
+PASS: image in a list -> text
+PASS: image in a list -> single image
+PASS: image in a list -> image with alt text
+PASS: image in a list -> empty string
+PASS: image in a list -> none
+PASS: image with alt text -> text
+PASS: image with alt text -> single image
+PASS: image with alt text -> image in a list
+PASS: image with alt text -> empty string
+PASS: image with alt text -> none
+PASS: empty string -> text
+PASS: empty string -> single image
+PASS: empty string -> image in a list
+PASS: empty string -> image with alt text
+PASS: empty string -> none
+PASS: none -> text
+PASS: none -> single image
+PASS: none -> image in a list
+PASS: none -> image with alt text
+PASS: none -> empty string
+PASS: text: display inline -> block
+PASS: text: display inline -> list-item
+PASS: text: display inline -> inline-block
+PASS: text: display block -> inline
+PASS: text: display list-item -> inline
+PASS: text: display inline-block -> inline
+PASS: single image: display inline -> block
+PASS: single image: display inline -> list-item
+PASS: single image: display inline -> inline-block
+PASS: single image: display block -> inline
+PASS: single image: display list-item -> inline
+PASS: single image: display inline-block -> inline
+PASS: image in a list: display inline -> block
+PASS: image in a list: display inline -> list-item
+PASS: image in a list: display inline -> inline-block
+PASS: image in a list: display block -> inline
+PASS: image in a list: display list-item -> inline
+PASS: image in a list: display inline-block -> inline
+PASS: image with alt text: display inline -> block
+PASS: image with alt text: display inline -> list-item
+PASS: image with alt text: display inline -> inline-block
+PASS: image with alt text: display block -> inline
+PASS: image with alt text: display list-item -> inline
+PASS: image with alt text: display inline-block -> inline
+54 cases; 54 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/counter-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/counter-mutations.txt
new file mode 100644
index 00000000000..51fea22132f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/counter-mutations.txt
@@ -0,0 +1,43 @@
+PASS: reset: insert an element carrying it before the list
+PASS: reset: insert an element carrying it in a nested block
+PASS: reset: toggle it on an earlier sibling
+PASS: reset: toggle it on an ancestor
+PASS: reset: toggle it on a list item
+PASS: reset: remove the element carrying it
+PASS: reset: hide the element carrying it
+PASS: reset: remove it from the element
+PASS: increment: insert an element carrying it before the list
+PASS: increment: toggle it on an earlier sibling
+PASS: increment: toggle it on an ancestor
+PASS: increment: remove the element carrying it
+PASS: increment: hide the element carrying it
+PASS: increment: remove it from the element
+PASS: set: insert an element carrying it before the list
+PASS: set: toggle it on an earlier sibling
+PASS: set: toggle it on an ancestor
+PASS: set: remove the element carrying it
+PASS: set: hide the element carrying it
+PASS: set: remove it from the element
+PASS: reversed: insert an element carrying it before the list
+PASS: reversed: insert an element carrying it in a nested block
+PASS: reversed: toggle it on an earlier sibling
+PASS: reversed: toggle it on an ancestor
+PASS: reversed: toggle it on a list item
+PASS: reversed: remove the element carrying it
+PASS: reversed: hide the element carrying it
+PASS: reversed: remove it from the element
+PASS: before-reset: insert an element carrying it before the list
+PASS: before-reset: toggle it on an earlier sibling
+PASS: before-reset: toggle it on an ancestor
+PASS: before-reset: toggle it on a list item
+PASS: before-reset: remove the element carrying it
+PASS: before-reset: hide the element carrying it
+PASS: before-reset: remove it from the element
+PASS: before-set: insert an element carrying it before the list
+PASS: before-set: toggle it on an earlier sibling
+PASS: before-set: toggle it on an ancestor
+PASS: before-set: toggle it on a list item
+PASS: before-set: remove the element carrying it
+PASS: before-set: hide the element carrying it
+PASS: before-set: remove it from the element
+42 cases; 42 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/display-contents-counter-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/display-contents-counter-mutations.txt
new file mode 100644
index 00000000000..74d2719e1a1
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/display-contents-counter-mutations.txt
@@ -0,0 +1,6 @@
+PASS: toggle counter-reset on a display contents element
+PASS: toggle display contents on an element carrying counter-reset
+PASS: toggle counter-increment on a display contents element
+PASS: toggle display contents on an element carrying counter-increment
+PASS: insert a counter user into a display contents element with counter-reset
+5 cases; 5 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/display-contents-restyle-with-child-list-change.txt b/Tests/LibWeb/Text/expected/layout-tree-update/display-contents-restyle-with-child-list-change.txt
new file mode 100644
index 00000000000..5eade1dd9be
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/display-contents-restyle-with-child-list-change.txt
@@ -0,0 +1,18 @@
+PASS: append a child, change the font size
+PASS: insert a text, change the font size
+PASS: remove a child, change the font size
+PASS: append a child, add a ::before
+PASS: append a child, add a ::before and change the font size
+PASS: append a child, change the font size and a property a box is built again for
+PASS: insert a text, add a ::before
+PASS: insert a text, add a ::before and change the font size
+PASS: insert a text, change the font size and a property a box is built again for
+PASS: remove a child, add a ::before
+PASS: remove a child, add a ::before and change the font size
+PASS: remove a child, change the font size and a property a box is built again for
+PASS: change the font size and a property a box is built again for
+PASS: add a ::before and change the font size
+PASS: add a ::before, then change the font size in a later style update
+PASS: SVG mask content: append a child, change the font size
+PASS: SVG mask content: change the font size, then append a child
+17 cases; 17 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/escaping-pseudo-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/escaping-pseudo-mutations.txt
new file mode 100644
index 00000000000..076c8cd35e5
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/escaping-pseudo-mutations.txt
@@ -0,0 +1,13 @@
+PASS: add a block ::before to the innermost inline
+PASS: add a block ::after to the middle inline
+PASS: remove a block ::after from the middle inline
+FAIL: remove a block ::before from the innermost inline
+PASS: add a list-item ::before to the outer inline
+PASS: insert a block sibling after the inline
+PASS: insert a block sibling before the inline
+PASS: make the outer inline an inline-block
+PASS: make the middle inline a block
+PASS: hide the outer inline
+PASS: make the outer inline display contents
+PASS: change the escaped pseudo-element content
+12 cases; 11 matched; 1 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/fieldset-legend-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/fieldset-legend-mutations.txt
new file mode 100644
index 00000000000..6a2d10e4c76
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/fieldset-legend-mutations.txt
@@ -0,0 +1,40 @@
+PASS: with legend: insert a legend first
+PASS: with legend: insert a legend last
+PASS: with legend: remove the legend
+PASS: with legend: move the legend to the end
+PASS: with legend: hide the legend
+PASS: with legend: float the legend
+PASS: with legend: make the fieldset flex
+PASS: with legend: make the fieldset grid
+PASS: with legend: make the fieldset inline
+PASS: with legend: make the fieldset display contents
+PASS: with legend: insert text before the legend
+PASS: with legend: insert a block before the legend
+PASS: with legend: remove all content
+PASS: without legend: insert a legend first
+PASS: without legend: insert a legend last
+PASS: without legend: remove the legend
+PASS: without legend: move the legend to the end
+PASS: without legend: hide the legend
+PASS: without legend: float the legend
+PASS: without legend: make the fieldset flex
+PASS: without legend: make the fieldset grid
+PASS: without legend: make the fieldset inline
+PASS: without legend: make the fieldset display contents
+PASS: without legend: insert text before the legend
+PASS: without legend: insert a block before the legend
+PASS: without legend: remove all content
+PASS: two legends: insert a legend first
+PASS: two legends: insert a legend last
+PASS: two legends: remove the legend
+PASS: two legends: move the legend to the end
+PASS: two legends: hide the legend
+PASS: two legends: float the legend
+PASS: two legends: make the fieldset flex
+PASS: two legends: make the fieldset grid
+PASS: two legends: make the fieldset inline
+PASS: two legends: make the fieldset display contents
+PASS: two legends: insert text before the legend
+PASS: two legends: insert a block before the legend
+PASS: two legends: remove all content
+39 cases; 39 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/first-letter-kept-across-later-changes.txt b/Tests/LibWeb/Text/expected/layout-tree-update/first-letter-kept-across-later-changes.txt
new file mode 100644
index 00000000000..309b269b528
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/first-letter-kept-across-later-changes.txt
@@ -0,0 +1,6 @@
+append a block to the owner: letter boxes kept: false, block of the letter reused: false, matches full rebuild: true
+append text to the last block: letter boxes kept: true, block of the letter reused: true, matches full rebuild: true
+remove the last block: letter boxes kept: true, block of the letter reused: true, matches full rebuild: true
+append text after the letter in its block: letter boxes kept: false, block of the letter reused: false, matches full rebuild: true
+insert a block before the letter: letter boxes kept: false, block of the letter reused: false, matches full rebuild: true
+insert text before the letter: letter boxes kept: false, block of the letter reused: false, matches full rebuild: true
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/first-letter-structure-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/first-letter-structure-mutations.txt
new file mode 100644
index 00000000000..810acda3d59
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/first-letter-structure-mutations.txt
@@ -0,0 +1,37 @@
+PASS: text: insert a block before the first child
+PASS: text: insert an inline before the text
+PASS: text: insert an empty inline before the text
+PASS: text: insert a line break before the text
+PASS: text: remove the first child
+PASS: text: make the first child inline-block
+PASS: text: add a ::before to the first child
+PASS: text: replace the first text
+PASS: text: move the first child to the end
+PASS: nested inline: insert a block before the first child
+PASS: nested inline: insert an inline before the text
+PASS: nested inline: insert an empty inline before the text
+PASS: nested inline: insert a line break before the text
+PASS: nested inline: remove the first child
+PASS: nested inline: make the first child inline-block
+PASS: nested inline: add a ::before to the first child
+PASS: nested inline: replace the first text
+PASS: nested inline: move the first child to the end
+PASS: block chain: insert a block before the first child
+PASS: block chain: insert an inline before the text
+PASS: block chain: insert an empty inline before the text
+PASS: block chain: insert a line break before the text
+PASS: block chain: remove the first child
+PASS: block chain: make the first child inline-block
+PASS: block chain: add a ::before to the first child
+PASS: block chain: replace the first text
+PASS: block chain: move the first child to the end
+PASS: list item: insert a block before the first child
+PASS: list item: insert an inline before the text
+PASS: list item: insert an empty inline before the text
+PASS: list item: insert a line break before the text
+PASS: list item: remove the first child
+PASS: list item: make the first child inline-block
+PASS: list item: add a ::before to the first child
+PASS: list item: replace the first text
+PASS: list item: move the first child to the end
+36 cases; 36 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/first-letter-whole-text-node-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/first-letter-whole-text-node-mutations.txt
new file mode 100644
index 00000000000..4155f037679
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/first-letter-whole-text-node-mutations.txt
@@ -0,0 +1,41 @@
+PASS: letter alone: insert a text before
+PASS: letter alone: insert an inline before
+PASS: letter alone: insert an empty inline before
+PASS: letter alone: remove the letter's text
+PASS: letter alone: empty the letter's text
+PASS: letter alone: append at the end
+PASS: letter alone: remove the ::before
+PASS: letter alone: remove the ::before of the target
+PASS: letter with punctuation: insert a text before
+PASS: letter with punctuation: insert an inline before
+PASS: letter with punctuation: insert an empty inline before
+PASS: letter with punctuation: remove the letter's text
+PASS: letter with punctuation: empty the letter's text
+PASS: letter with punctuation: append at the end
+PASS: letter with punctuation: remove the ::before
+PASS: letter with punctuation: remove the ::before of the target
+PASS: letter in an inline: insert a text before
+PASS: letter in an inline: insert an inline before
+PASS: letter in an inline: insert an empty inline before
+PASS: letter in an inline: remove the letter's text
+PASS: letter in an inline: empty the letter's text
+PASS: letter in an inline: append at the end
+PASS: letter in an inline: remove the ::before
+PASS: letter in an inline: remove the ::before of the target
+PASS: letter in a ::before: insert a text before
+PASS: letter in a ::before: insert an inline before
+PASS: letter in a ::before: insert an empty inline before
+PASS: letter in a ::before: remove the letter's text
+PASS: letter in a ::before: empty the letter's text
+PASS: letter in a ::before: append at the end
+PASS: letter in a ::before: remove the ::before
+PASS: letter in a ::before: remove the ::before of the target
+PASS: letter in the ::before of a child: insert a text before
+PASS: letter in the ::before of a child: insert an inline before
+PASS: letter in the ::before of a child: insert an empty inline before
+PASS: letter in the ::before of a child: remove the letter's text
+PASS: letter in the ::before of a child: empty the letter's text
+PASS: letter in the ::before of a child: append at the end
+PASS: letter in the ::before of a child: remove the ::before
+PASS: letter in the ::before of a child: remove the ::before of the target
+40 cases; 40 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/frameset-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/frameset-mutations.txt
new file mode 100644
index 00000000000..305f2502891
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/frameset-mutations.txt
@@ -0,0 +1,9 @@
+PASS: append a div
+PASS: append text
+PASS: append a frame
+PASS: insert a nested frameset
+PASS: remove a frame
+PASS: change cols
+PASS: hide a frame
+PASS: add a ::before rule
+8 cases; 8 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/image-element-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/image-element-mutations.txt
new file mode 100644
index 00000000000..73e7fbdf192
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/image-element-mutations.txt
@@ -0,0 +1,28 @@
+PASS: block: insert an image
+PASS: block: remove the image
+PASS: block: hide the image
+PASS: block: make the image a block
+PASS: block: make the image display contents
+PASS: block: change the alt of a broken image
+PASS: block: remove the alt of a broken image
+PASS: block: replace the image content with content url
+PASS: block: give the image a ::before
+PASS: inline: insert an image
+PASS: inline: remove the image
+PASS: inline: hide the image
+PASS: inline: make the image a block
+PASS: inline: make the image display contents
+PASS: inline: change the alt of a broken image
+PASS: inline: remove the alt of a broken image
+PASS: inline: replace the image content with content url
+PASS: inline: give the image a ::before
+PASS: flex: insert an image
+PASS: flex: remove the image
+PASS: flex: hide the image
+PASS: flex: make the image a block
+PASS: flex: make the image display contents
+PASS: flex: change the alt of a broken image
+PASS: flex: remove the alt of a broken image
+PASS: flex: replace the image content with content url
+PASS: flex: give the image a ::before
+27 cases; 27 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/list-style-image-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/list-style-image-mutations.txt
new file mode 100644
index 00000000000..dff07c2e79b
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/list-style-image-mutations.txt
@@ -0,0 +1,8 @@
+PASS: set list-style-image
+PASS: clear list-style-image
+PASS: switch an image marker inside
+PASS: switch an image marker outside
+PASS: set list-style-type none under an image
+PASS: set an image on a list item with a block child
+PASS: make an image list item a block
+7 cases; 7 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/list-unit-cases.txt b/Tests/LibWeb/Text/expected/layout-tree-update/list-unit-cases.txt
new file mode 100644
index 00000000000..dcfb9719c62
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/list-unit-cases.txt
@@ -0,0 +1,44 @@
+PASS: append blocks to a long block list
+PASS: prepend blocks to a long block list
+PASS: insert blocks in the middle of a long block list
+PASS: remove blocks from the middle of a long block list
+PASS: append inline content to a long inline list
+PASS: insert a block among inline children
+PASS: insert inline content into the trailing anonymous wrapper
+PASS: insert inline content into a wrapper between blocks
+PASS: insert a block that splits an anonymous wrapper
+PASS: insert white space between two kept inline-blocks
+PASS: insert a text next to collapsible white space
+PASS: append to a block with a clearfix ::after
+PASS: insert before a kept sibling whose ::before counts
+PASS: append after siblings whose ::before counts
+PASS: insert an open quote before kept quotes
+PASS: insert text before the first letter
+PASS: insert a block before the first letter's block
+PASS: append out-of-flow boxes among inline content
+PASS: append to a long flex list
+PASS: insert in the middle of a grid list
+PASS: append rows to a table body
+PASS: append loose cells after kept cells
+PASS: insert a block before a kept table
+PASS: insert inline content into a button
+FAIL: insert a block into a button
+PASS: insert a legend into a fieldset
+PASS: append content to a fieldset with a legend
+PASS: insert under a display: contents child
+PASS: insert into a shadow root
+PASS: move a node between two lists that also gain children
+PASS: append to a list item with an inside marker
+PASS: append a block after inline content
+PASS: append inline content after a block
+PASS: append after trailing white space
+PASS: append inline content after an absolutely positioned box
+PASS: append to several parents in one update
+36 cases; 35 matched; 1 mismatched
+append a block: kept children preserved: true, matches full rebuild: true
+insert a block in the middle: kept children preserved: true, matches full rebuild: true
+append inline content: kept children preserved: true, matches full rebuild: true
+insert a block among inlines: kept children preserved: true, matches full rebuild: true
+append to a clearfix container: kept children preserved: true, matches full rebuild: true
+append to a flex list: kept children preserved: true, matches full rebuild: true
+append a row: kept children preserved: true, matches full rebuild: true
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/list-unit-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/list-unit-mutations.txt
new file mode 100644
index 00000000000..3d834889400
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/list-unit-mutations.txt
@@ -0,0 +1,8 @@
+PASS: reorder slotted nodes that keep their boxes
+PASS: move a node from one changed list to another
+PASS: remove the last block child of a block with inline children
+PASS: insert an inline-block between two kept inline-blocks
+PASS: remove an inline-block between two kept inline-blocks
+5 cases; 5 matched; 0 mismatched
+following block preserved after an inline insertion: true
+incremental tree matches full rebuild: true
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/marker-quote-order-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/marker-quote-order-mutations.txt
new file mode 100644
index 00000000000..501839d3a5c
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/marker-quote-order-mutations.txt
@@ -0,0 +1,6 @@
+open-quote in a marker: tree matches=false
+close-quote in a marker: tree matches=false
+open-quote in an item's ::before: tree matches=false
+q appended to an item: tree matches=true
+item inserted with a quoting marker: tree matches=false
+item with a quoting marker removed: tree matches=true
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/media-element-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/media-element-mutations.txt
new file mode 100644
index 00000000000..cfc1b1ff4b8
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/media-element-mutations.txt
@@ -0,0 +1,25 @@
+PASS: video: toggle controls
+PASS: video: add a light DOM child
+PASS: video: add light DOM text
+PASS: video: hide the element
+PASS: video: make the element display contents
+PASS: video: make the element a block
+PASS: video with controls: toggle controls
+PASS: video with controls: add a light DOM child
+PASS: video with controls: add light DOM text
+PASS: video with controls: hide the element
+PASS: video with controls: make the element display contents
+PASS: video with controls: make the element a block
+PASS: audio: toggle controls
+PASS: audio: add a light DOM child
+PASS: audio: add light DOM text
+PASS: audio: hide the element
+PASS: audio: make the element display contents
+PASS: audio: make the element a block
+PASS: audio with controls: toggle controls
+PASS: audio with controls: add a light DOM child
+PASS: audio with controls: add light DOM text
+PASS: audio with controls: hide the element
+PASS: audio with controls: make the element display contents
+PASS: audio with controls: make the element a block
+24 cases; 24 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/ol-attribute-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/ol-attribute-mutations.txt
new file mode 100644
index 00000000000..d3b915ffd57
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/ol-attribute-mutations.txt
@@ -0,0 +1,13 @@
+PASS: set start
+PASS: remove start
+PASS: set reversed
+PASS: remove reversed
+PASS: set reversed on the nested list
+PASS: set li value
+PASS: remove li value
+PASS: change type
+PASS: insert an item into a reversed list
+PASS: remove an item from a reversed list
+PASS: hide an item
+FAIL: make an item a block
+12 cases; 11 matched; 1 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/out-of-flow-replaced-element-table-display-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/out-of-flow-replaced-element-table-display-mutations.txt
new file mode 100644
index 00000000000..ee51185d525
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/out-of-flow-replaced-element-table-display-mutations.txt
@@ -0,0 +1,49 @@
+PASS: table-row-group, float: left: insert into table
+PASS: table-row-group, float: left: make in flow in table
+PASS: table-row-group, float: left: insert into block
+PASS: table-row-group, float: left: make in flow in block
+PASS: table-header-group, float: left: insert into table
+PASS: table-header-group, float: left: make in flow in table
+PASS: table-header-group, float: left: insert into block
+PASS: table-header-group, float: left: make in flow in block
+PASS: table-column-group, float: left: insert into table
+PASS: table-column-group, float: left: make in flow in table
+PASS: table-column-group, float: left: insert into block
+PASS: table-column-group, float: left: make in flow in block
+PASS: table-row, float: left: insert into table
+PASS: table-row, float: left: make in flow in table
+PASS: table-row, float: left: insert into block
+PASS: table-row, float: left: make in flow in block
+PASS: table-cell, float: left: insert into table
+PASS: table-cell, float: left: make in flow in table
+PASS: table-cell, float: left: insert into block
+PASS: table-cell, float: left: make in flow in block
+PASS: table-caption, float: left: insert into table
+PASS: table-caption, float: left: make in flow in table
+PASS: table-caption, float: left: insert into block
+PASS: table-caption, float: left: make in flow in block
+PASS: table-row-group, position: absolute: insert into table
+PASS: table-row-group, position: absolute: make in flow in table
+PASS: table-row-group, position: absolute: insert into block
+PASS: table-row-group, position: absolute: make in flow in block
+PASS: table-header-group, position: absolute: insert into table
+PASS: table-header-group, position: absolute: make in flow in table
+PASS: table-header-group, position: absolute: insert into block
+PASS: table-header-group, position: absolute: make in flow in block
+PASS: table-column-group, position: absolute: insert into table
+PASS: table-column-group, position: absolute: make in flow in table
+PASS: table-column-group, position: absolute: insert into block
+PASS: table-column-group, position: absolute: make in flow in block
+PASS: table-row, position: absolute: insert into table
+PASS: table-row, position: absolute: make in flow in table
+PASS: table-row, position: absolute: insert into block
+PASS: table-row, position: absolute: make in flow in block
+PASS: table-cell, position: absolute: insert into table
+PASS: table-cell, position: absolute: make in flow in table
+PASS: table-cell, position: absolute: insert into block
+PASS: table-cell, position: absolute: make in flow in block
+PASS: table-caption, position: absolute: insert into table
+PASS: table-caption, position: absolute: make in flow in table
+PASS: table-caption, position: absolute: insert into block
+PASS: table-caption, position: absolute: make in flow in block
+48 cases; 48 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/replaced-element-table-display-transitions.txt b/Tests/LibWeb/Text/expected/layout-tree-update/replaced-element-table-display-transitions.txt
new file mode 100644
index 00000000000..91c087f8ba6
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/replaced-element-table-display-transitions.txt
@@ -0,0 +1,31 @@
+PASS: img: inline -> block
+PASS: img: inline -> table
+PASS: img: inline -> inline-table
+PASS: img: inline -> table-row-group
+PASS: img: inline -> table-row
+PASS: img: inline -> table-cell
+PASS: img: inline -> table-caption
+PASS: img: inline -> table-column
+PASS: img: table -> inline
+PASS: img: inline-table -> inline
+PASS: img: table-row-group -> inline
+PASS: img: table-row -> inline
+PASS: img: table-cell -> inline
+PASS: img: table-caption -> inline
+PASS: img: table-column -> inline
+PASS: canvas: inline -> block
+PASS: canvas: inline -> table
+PASS: canvas: inline -> inline-table
+PASS: canvas: inline -> table-row-group
+PASS: canvas: inline -> table-row
+PASS: canvas: inline -> table-cell
+PASS: canvas: inline -> table-caption
+PASS: canvas: inline -> table-column
+PASS: canvas: table -> inline
+PASS: canvas: inline-table -> inline
+PASS: canvas: table-row-group -> inline
+PASS: canvas: table-row -> inline
+PASS: canvas: table-cell -> inline
+PASS: canvas: table-caption -> inline
+PASS: canvas: table-column -> inline
+30 cases; 30 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/restyle-dropping-box-flags.txt b/Tests/LibWeb/Text/expected/layout-tree-update/restyle-dropping-box-flags.txt
new file mode 100644
index 00000000000..dc7be6e6ef2
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/restyle-dropping-box-flags.txt
@@ -0,0 +1,15 @@
+PASS: stop being a containing block for absolute boxes
+PASS: stop being a containing block for absolute boxes, append a child
+PASS: stop being a containing block for fixed boxes
+PASS: stop being a containing block for fixed boxes, append a child
+PASS: stop being a scroll container
+PASS: stop being a scroll container, append a child
+PASS: stop being any of these
+PASS: stop being any of these, append a child
+PASS: stop being an editing host
+PASS: stop being an editing host, append a child
+PASS: stop being a flex container
+PASS: stop being a flex container, append a child
+PASS: become a containing block again
+PASS: become a containing block again, append a child
+14 cases; 14 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/restyle-with-child-list-change-of-same-element.txt b/Tests/LibWeb/Text/expected/layout-tree-update/restyle-with-child-list-change-of-same-element.txt
new file mode 100644
index 00000000000..a87f20b6a94
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/restyle-with-child-list-change-of-same-element.txt
@@ -0,0 +1,43 @@
+PASS: increment a counter, append a child
+PASS: increment a counter, remove a child
+PASS: increment a counter after a color change in an earlier style update
+PASS: increment a counter after a change of position in an earlier style update
+PASS: increment a counter after a change of float in an earlier style update
+PASS: increment a counter after a change of overflow in an earlier style update
+PASS: reset a counter, append a child
+PASS: reset a counter, remove a child
+PASS: reset a counter after a color change in an earlier style update
+PASS: reset a counter after a change of position in an earlier style update
+PASS: reset a counter after a change of float in an earlier style update
+PASS: reset a counter after a change of overflow in an earlier style update
+PASS: set a counter, append a child
+PASS: set a counter, remove a child
+PASS: set a counter after a color change in an earlier style update
+PASS: set a counter after a change of position in an earlier style update
+PASS: set a counter after a change of float in an earlier style update
+PASS: set a counter after a change of overflow in an earlier style update
+PASS: open a quote in the ::before, append a child
+PASS: open a quote in the ::before, remove a child
+PASS: open a quote in the ::before after a color change in an earlier style update
+PASS: open a quote in the ::before after a change of position in an earlier style update
+PASS: open a quote in the ::before after a change of float in an earlier style update
+PASS: open a quote in the ::before after a change of overflow in an earlier style update
+PASS: drop the quote of the ::before, append a child
+PASS: drop the quote of the ::before, remove a child
+PASS: drop the quote of the ::before after a color change in an earlier style update
+PASS: drop the quote of the ::before after a change of position in an earlier style update
+PASS: drop the quote of the ::before after a change of float in an earlier style update
+PASS: drop the quote of the ::before after a change of overflow in an earlier style update
+FAIL: stop being a list item, append a child
+FAIL: stop being a list item, remove a child
+FAIL: stop being a list item after a color change in an earlier style update
+FAIL: stop being a list item after a change of position in an earlier style update
+PASS: stop being a list item after a change of float in an earlier style update
+FAIL: stop being a list item after a change of overflow in an earlier style update
+PASS: become a list item, append a child
+PASS: become a list item, remove a child
+PASS: become a list item after a color change in an earlier style update
+PASS: become a list item after a change of position in an earlier style update
+PASS: become a list item after a change of float in an earlier style update
+PASS: become a list item after a change of overflow in an earlier style update
+42 cases; 37 matched; 5 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/scroll-container-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/scroll-container-mutations.txt
new file mode 100644
index 00000000000..dacb4487d5f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/scroll-container-mutations.txt
@@ -0,0 +1,20 @@
+PASS: make a block ::before scrollable
+PASS: make a scrollable ::before visible
+PASS: make a list scrollable
+PASS: make a list item scrollable
+PASS: make an inline scrollable
+PASS: make the target clip
+PASS: set overflow hidden on html
+PASS: set overflow scroll on html
+PASS: set overflow clip on html
+PASS: set overflow hidden on body
+PASS: set overflow scroll on body
+PASS: set overflow clip on body
+PASS: set overflowX hidden on html
+PASS: set overflowX scroll on html
+PASS: set overflowX clip on html
+PASS: set overflowY hidden on body
+PASS: set overflowY scroll on body
+PASS: set overflowY clip on body
+PASS: move overflow from body to html
+19 cases; 19 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/svg-resource-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/svg-resource-mutations.txt
new file mode 100644
index 00000000000..d5cbdab190e
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/svg-resource-mutations.txt
@@ -0,0 +1,17 @@
+PASS: point mask at another mask
+PASS: point clip-path at another clipPath
+PASS: point fill at a pattern with href
+PASS: set clip-path from CSS
+PASS: remove the mask attribute
+PASS: remove the mask element
+PASS: remove the clipPath element
+PASS: remove the pattern element
+PASS: append a child to the mask
+PASS: remove the mask content
+PASS: add a second referrer
+PASS: add a referrer on a group
+PASS: hide the referrer
+PASS: insert a referrer before the existing one
+PASS: make the mask reference itself
+PASS: move the mask element to the end
+16 cases; 16 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/svg-switch-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/svg-switch-mutations.txt
new file mode 100644
index 00000000000..b15f9dcfa71
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/svg-switch-mutations.txt
@@ -0,0 +1,9 @@
+PASS: insert an eligible child before the chosen one
+PASS: insert an eligible child first
+PASS: remove the chosen child
+PASS: hide the chosen child
+PASS: make the unsupported child supported
+PASS: append a child to the chosen child
+PASS: insert an HTML element first
+PASS: hide the switch
+8 cases; 8 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/svg-text-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/svg-text-mutations.txt
new file mode 100644
index 00000000000..1b7f840f0fb
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/svg-text-mutations.txt
@@ -0,0 +1,9 @@
+PASS: insert a tspan
+PASS: remove a tspan
+PASS: insert whitespace
+PASS: remove all text
+PASS: change text data
+PASS: hide a tspan
+PASS: insert a tspan into a textPath
+PASS: remove the textPath
+8 cases; 8 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/table-column-children-not-counted.txt b/Tests/LibWeb/Text/expected/layout-tree-update/table-column-children-not-counted.txt
new file mode 100644
index 00000000000..73335ddceff
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/table-column-children-not-counted.txt
@@ -0,0 +1,3 @@
+root: 18 boxes: BlockContainer=6 BlockContainer(anonymous)=1 Box=2 GeneratedTextNode(anonymous)=5 InlineNode(anonymous)=2 TableWrapper(anonymous)=1 TextNode=1
+ text: cell [ 5 ] c= 5
+total: 18 boxes
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/table-whitespace-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/table-whitespace-mutations.txt
new file mode 100644
index 00000000000..fe96d6f1ed5
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/table-whitespace-mutations.txt
@@ -0,0 +1,26 @@
+PASS: semantic table: insert whitespace between rows
+PASS: semantic table: insert whitespace before the first row
+PASS: semantic table: insert whitespace between cells
+PASS: semantic table: insert whitespace at the start of the table
+PASS: semantic table: insert text between cells
+PASS: semantic table: change cell text to whitespace
+PASS: semantic table: change inter-cell text to whitespace
+PASS: semantic table: change inter-cell whitespace to text
+PASS: semantic table: remove the whitespace between cells
+PASS: display table: insert whitespace between rows
+PASS: display table: insert whitespace before the first row
+PASS: display table: insert whitespace between cells
+PASS: display table: insert whitespace at the start of the table
+PASS: display table: insert text between cells
+PASS: display table: change cell text to whitespace
+PASS: display table: change inter-cell text to whitespace
+PASS: display table: change inter-cell whitespace to text
+PASS: display table: remove the whitespace between cells
+PASS: loose cells: insert whitespace between cells
+PASS: loose cells: insert whitespace at the start of the table
+PASS: loose cells: insert text between cells
+PASS: loose cells: change cell text to whitespace
+PASS: loose cells: change inter-cell text to whitespace
+PASS: loose cells: change inter-cell whitespace to text
+PASS: loose cells: remove the whitespace between cells
+25 cases; 25 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/top-layer-member-counters-at-dom-position.txt b/Tests/LibWeb/Text/expected/layout-tree-update/top-layer-member-counters-at-dom-position.txt
new file mode 100644
index 00000000000..f1872a3cd8d
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/top-layer-member-counters-at-dom-position.txt
@@ -0,0 +1,16 @@
+root: 27 boxes: BlockContainer=7 GeneratedTextNode(anonymous)=10 InlineNode(anonymous)=5 TextNode=5
+ text: a 11 b 12 c 501 d 502 e 13
+plain: 6 boxes: BlockContainer=2 GeneratedTextNode(anonymous)=2 InlineNode(anonymous)=1 TextNode=1
+ text: in plain 14
+with-backdrop: 6 boxes: BlockContainer=2 GeneratedTextNode(anonymous)=2 InlineNode(anonymous)=1 TextNode=1
+ text: in backdrop member 501
+total: 39 boxes
+PASS: first build
+FAIL: insert a paragraph before the first member
+root: 32 boxes: BlockContainer=8 GeneratedTextNode(anonymous)=12 InlineNode(anonymous)=6 TextNode=6
+ text: a 11 new 12 b 13 c 501 d 502 e 14
+plain: 6 boxes: BlockContainer=2 GeneratedTextNode(anonymous)=2 InlineNode(anonymous)=1 TextNode=1
+ text: in plain 15
+with-backdrop: 6 boxes: BlockContainer=2 GeneratedTextNode(anonymous)=2 InlineNode(anonymous)=1 TextNode=1
+ text: in backdrop member 501
+total: 44 boxes
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/top-layer-ordering-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/top-layer-ordering-mutations.txt
new file mode 100644
index 00000000000..55892c0962d
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/top-layer-ordering-mutations.txt
@@ -0,0 +1,10 @@
+PASS: re-show the first member
+PASS: close the middle member
+PASS: move an open member in the DOM
+PASS: remove an open member
+PASS: remove the parent of an open member
+PASS: hide the parent of an open member
+PASS: open a modal dialog over the members
+PASS: insert content before the members
+PASS: change the content of an open member
+9 cases; 9 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/unit-driver-sources.txt b/Tests/LibWeb/Text/expected/layout-tree-update/unit-driver-sources.txt
new file mode 100644
index 00000000000..732191b51d5
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/unit-driver-sources.txt
@@ -0,0 +1,22 @@
+PASS: open a modal dialog
+PASS: show two popovers
+PASS: close the first of three members
+PASS: hide and show a member again, which moves it last
+PASS: change the display of a member
+PASS: make a member display: contents
+PASS: hide the parent of a member
+PASS: show the parent of a member again
+PASS: insert into a member
+PASS: remove a member from the document
+FAIL: change the content of a mask
+PASS: insert into a clip path
+PASS: remove the content of a pattern
+PASS: hide the content of a mask
+PASS: change an element inside a hidden subtree
+PASS: insert into a hidden subtree, then show it
+PASS: change the display of the document element
+PASS: change the document element and a top layer member at once
+PASS: request a full update and change the tree in the same build
+19 cases; 18 matched; 1 mismatched
+clean sibling of a member that entered the top layer: PRESERVED
+clean sibling of a member that left the top layer: PRESERVED
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/whitespace-flat-tree-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/whitespace-flat-tree-mutations.txt
new file mode 100644
index 00000000000..05c5cfa6b89
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/whitespace-flat-tree-mutations.txt
@@ -0,0 +1,11 @@
+PASS: insert a slotted inline before whitespace
+PASS: remove a slotted inline before whitespace
+PASS: reassign a named slot before whitespace
+PASS: assign content to an empty slot before whitespace
+PASS: replace slot fallback with assigned content before whitespace
+PASS: toggle display contents on the element before whitespace
+PASS: toggle display contents off on the element before whitespace
+PASS: make the element inside a display contents element a block
+PASS: insert a top layer member before whitespace
+PASS: close a top layer member before whitespace
+10 cases; 10 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/expected/layout-tree-update/writing-suggestion-mutations.txt b/Tests/LibWeb/Text/expected/layout-tree-update/writing-suggestion-mutations.txt
new file mode 100644
index 00000000000..c5879b1bbe6
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/layout-tree-update/writing-suggestion-mutations.txt
@@ -0,0 +1,6 @@
+PASS: insert an element before the text
+PASS: insert a block before the text
+PASS: change the style of the editing host
+PASS: wrap the editing host in display contents
+PASS: add a ::before to the editing host
+5 cases; 5 matched; 0 mismatched
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/append-into-trailing-inline-run.html b/Tests/LibWeb/Text/input/layout-tree-update/append-into-trailing-inline-run.html
new file mode 100644
index 00000000000..aadde6ef5a4
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/append-into-trailing-inline-run.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="../work-test.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<style>
+ .float { float: left; width: 10px; height: 10px; }
+ .absolute { position: absolute; }
+ .hidden { display: none; }
+ .contents { display: contents; }
+ .red { color: red; }
+</style>
+<div id="fixture"></div>
+<script>
+ // A list whose last boxes are inline content in an anonymous wrapper after a block gains children, at its end or
+ // inside that run, while other children change in the same update: the tree matches a full build, and the boxes
+ // nothing changed stay.
+ test(() => {
+ const span = text => Object.assign(document.createElement("span"), { textContent: text });
+ const block = text => Object.assign(document.createElement("div"), { textContent: text });
+ const fixtures = [
+ ["text run", '<div>block</div>text <span>one</span> <b>two</b>'],
+ ["run after two blocks", '<div>first</div>lead<div>second</div>text <span>one</span>'],
+ ["run with whitespace", '<div>block</div> <span>one</span> '],
+ ["run starting with a span", '<div>block</div><span>one</span>text'],
+ ["run with a float", '<div>block</div><span>one</span><span class="float"></span>text'],
+ ["run with an absolute box", '<div>block</div><span>one</span><span class="absolute">abs</span>'],
+ ["run with a hidden child", '<div>block</div><span>one</span><span class="hidden">h</span>text'],
+ ["run with contents", '<div>block</div><span class="contents"><span>one</span>two</span>'],
+ ["run with a block in an inline", '<div>block</div><span>one<div>inner</div>two</span>'],
+ ["run after a float", '<div class="float"></div>text <span>one</span>'],
+ ["only a run", 'text <span>one</span>'],
+ ];
+ const changes = [
+ ["append text", list => list.append("appended")],
+ ["append a span", list => list.append(span("appended"))],
+ ["append a block", list => list.append(block("appended"))],
+ ["append a span and a block", list => list.append(span("appended"), block("block"))],
+ ["append a float", list => list.append(Object.assign(span(""), { className: "float" }))],
+ ["insert a span inside the run", list => list.lastElementChild.before(span("inserted"))],
+ ["append and restyle the first block", list => { list.firstElementChild.classList.add("red"); list.append(span("appended")); }],
+ ["append and hide the first block", list => { list.firstElementChild.classList.add("hidden"); list.append(span("appended")); }],
+ ["append and restyle the last span", list => { list.lastElementChild.classList.add("red"); list.append(span("appended")); }],
+ ["append and remove the last span", list => { list.lastElementChild.remove(); list.append(span("appended")); }],
+ ];
+ for (const [fixtureName, markup] of fixtures) {
+ for (const [changeName, change] of changes) {
+ fixture.innerHTML = `<div>${markup}</div>`;
+ const list = fixture.firstElementChild;
+ const tracked = [list, ...list.childNodes];
+ const kept = layoutBoxTransitions(() => change(list), tracked).transitions
+ .map(transition => (["ABSENT", "CREATED"].includes(transition) ? "." : transition === "PRESERVED" ? "K" : "-"))
+ .join("");
+ const comparison = internals.compareLayoutTreeWithFullRebuild();
+ println(`${fixtureName}, ${changeName}: kept ${kept}, tree matches=${comparison.matches}`);
+ }
+ }
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/append-leaves-other-anonymous-wrappers-clean.html b/Tests/LibWeb/Text/input/layout-tree-update/append-leaves-other-anonymous-wrappers-clean.html
new file mode 100644
index 00000000000..7847fd0ce79
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/append-leaves-other-anonymous-wrappers-clean.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ body { margin: 0; font: 16px/20px monospace; }
+ #list { width: 400px; }
+</style>
+<div id="list"></div>
+<script>
+ // Appending a block to a list whose inline runs sit in anonymous wrappers changes none of the wrappers before it,
+ // so the layout that follows reuses each of them as it does the blocks between them.
+ test(() => {
+ let markup = "";
+ for (let index = 0; index < 4; ++index)
+ markup += `text ${index}<div>block ${index}</div>`;
+ list.innerHTML = markup;
+ document.body.offsetHeight;
+
+ internals.beginLayoutTrace();
+ const appended = document.createElement("div");
+ appended.textContent = "appended";
+ list.append(appended);
+ document.body.offsetHeight;
+ for (const line of internals.takeLayoutTrace().split("\n")) {
+ if (line.includes("REUSE"))
+ println(line.trim());
+ }
+
+ const fresh = list.cloneNode(true);
+ fresh.id = "";
+ fresh.style.width = "400px";
+ document.body.appendChild(fresh);
+ const geometry = root => {
+ const rootRect = root.getBoundingClientRect();
+ const range = document.createRange();
+ range.selectNodeContents(root);
+ return [...range.getClientRects()].map(rect => `${rect.left - rootRect.left},${rect.top - rootRect.top},${rect.width},${rect.height}`).join(" ");
+ };
+ println(`geometry matches a fresh layout: ${geometry(list) === geometry(fresh)}`);
+ println(`tree matches a full rebuild: ${internals.compareLayoutTreeWithFullRebuild().matches}`);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/append-with-change-inside-display-contents-child.html b/Tests/LibWeb/Text/input/layout-tree-update/append-with-change-inside-display-contents-child.html
new file mode 100644
index 00000000000..e1714f2afe7
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/append-with-change-inside-display-contents-child.html
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ // A block gains a child at its end while, in the same update, a node flattened into its list before the appended
+ // one, from a `display: contents` child or a slot, changes.
+ const shapes = [
+ [
+ "display: contents",
+ (fixture) => {
+ fixture.innerHTML = `<div id="parent"><div id="contents" style="display: contents">before <div id="inner"><span>inner</span> text</div> after</div><div id="last">last</div></div>`;
+ return {
+ parent: fixture.querySelector("#parent"),
+ contents: fixture.querySelector("#contents"),
+ inner: fixture.querySelector("#inner"),
+ };
+ },
+ ],
+ [
+ "slot",
+ (fixture) => {
+ fixture.innerHTML = `<div id="host">before <div id="inner"><span>inner</span> text</div> after</div>`;
+ const host = fixture.querySelector("#host");
+ const shadow = host.attachShadow({ mode: "open" });
+ shadow.innerHTML = `<div id="parent"><slot id="contents"></slot><div id="last">last</div></div>`;
+ return {
+ parent: shadow.querySelector("#parent"),
+ contents: host,
+ inner: host.querySelector("#inner"),
+ };
+ },
+ ],
+ ];
+
+ const changes = [
+ ["make the flattened element flex", ({ inner }) => (inner.style.display = "flex")],
+ ["make the flattened element inline", ({ inner }) => (inner.style.display = "inline")],
+ ["hide the flattened element", ({ inner }) => (inner.style.display = "none")],
+ ["make the flattened element float", ({ inner }) => (inner.style.float = "left")],
+ ["change the font size of the flattened element", ({ inner }) => (inner.style.fontSize = "30px")],
+ ["set the text content of the flattened element", ({ inner }) => (inner.textContent = "replaced")],
+ ["change a flattened text", ({ contents }) => (contents.firstChild.data = "changed before ")],
+ ["remove a flattened text", ({ contents }) => contents.firstChild.remove()],
+ ["insert a block next to the flattened element", ({ inner }) => inner.before(Object.assign(document.createElement("p"), { textContent: "new block" }))],
+ ];
+
+ const cases = [];
+ for (const [shapeName, build] of shapes) {
+ for (const [changeName, change] of changes) {
+ cases.push({
+ name: `${shapeName}: ${changeName}`,
+ setup(fixture) {
+ const nodes = build(fixture);
+ return () => {
+ nodes.parent.append(Object.assign(document.createElement("div"), { textContent: "appended" }));
+ change(nodes);
+ };
+ },
+ });
+ }
+ }
+ cases.push({
+ name: "display: contents: make the display: contents child a block",
+ setup(fixture) {
+ const nodes = shapes[0][1](fixture);
+ return () => {
+ nodes.parent.append(Object.assign(document.createElement("div"), { textContent: "appended" }));
+ nodes.contents.style.display = "block";
+ };
+ },
+ });
+
+ test(() => {
+ runLayoutTreeFullRebuildComparisonCases(cases);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/append-with-earlier-sibling-change.html b/Tests/LibWeb/Text/input/layout-tree-update/append-with-earlier-sibling-change.html
new file mode 100644
index 00000000000..dafdfa5ba3b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/append-with-earlier-sibling-change.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="../work-test.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<style>
+ .red { color: red; }
+ .inline { display: inline; }
+ .hidden { display: none; }
+ .float { float: left; }
+</style>
+<div id="fixture"></div>
+<script>
+ // A list that gains a child at its end while an earlier child changes in the same update: what the earlier
+ // change asks for is built, and the boxes nothing changed stay.
+ test(() => {
+ const changes = [
+ ["nothing", () => {}],
+ ["restyle keeping the box kind", list => list.children[1].classList.add("red")],
+ ["restyle to inline", list => list.children[1].classList.add("inline")],
+ ["restyle to display none", list => list.children[1].classList.add("hidden")],
+ ["restyle to float", list => list.children[1].classList.add("float")],
+ ["show a hidden child", list => list.children[3].classList.remove("hidden")],
+ ["insert before the second child", list => list.children[1].before(Object.assign(document.createElement("div"), { textContent: "inserted" }))],
+ ["append to the second child", list => list.children[1].append(Object.assign(document.createElement("span"), { textContent: "inner" }))],
+ ["change the first text", list => { list.firstChild.data = "changed text"; }],
+ ["remove the first child", list => list.firstChild.remove()],
+ ["restyle the last child", list => list.lastElementChild.classList.add("red")],
+ ["restyle the last child to inline", list => list.lastElementChild.classList.add("inline")],
+ ];
+ for (const [name, change] of changes) {
+ for (const appendText of [false, true]) {
+ fixture.innerHTML = '<div>text<div>first</div><div>second</div><div>third</div><div class="hidden">hidden</div><div>last</div></div>';
+ const list = fixture.firstElementChild;
+ const tracked = [list, ...list.children];
+ const kept = layoutBoxTransitions(() => {
+ change(list);
+ if (appendText)
+ list.append("appended text");
+ else
+ list.append(Object.assign(document.createElement("div"), { textContent: "appended" }));
+ }, tracked).transitions.map(transition => (transition === "PRESERVED" ? "K" : "-")).join("");
+ const comparison = internals.compareLayoutTreeWithFullRebuild();
+ println(`${name}, append ${appendText ? "text" : "block"}: kept ${kept}, tree matches=${comparison.matches}`);
+ }
+ }
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/box-unit-cases.html b/Tests/LibWeb/Text/input/layout-tree-update/box-unit-cases.html
new file mode 100644
index 00000000000..01de99427ef
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/box-unit-cases.html
@@ -0,0 +1,306 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="../work-test.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<style>
+ .flex { display: flex; }
+ .grid { display: grid; }
+ .counted { counter-reset: c; }
+ .counted > * { counter-increment: c; }
+ .counted > *::before { content: counter(c) ". "; }
+ .first-letter::first-letter { color: green; }
+ .before::before { content: "before "; }
+ .after::after { content: " after"; }
+ .block-before::before { content: "block before"; display: block; }
+ .hidden { display: none; }
+</style>
+<div id="fixture"></div>
+<script>
+ // Changes to the box of a child, or to the pseudo-elements of a box, in a list whose box stays: removals, moves,
+ // display, position and float changes, and changes of ::before, ::after and ::marker alone, in block, inline, flex,
+ // grid, list, table and display: contents parents. Each is compared with a full rebuild, and some also say whether
+ // the boxes of the children that stay kept their identity.
+ function blocks(count, prefix = "b") {
+ let markup = "";
+ for (let i = 0; i < count; ++i) markup += `<div>${prefix}${i}</div>`;
+ return markup;
+ }
+ function inlines(count) {
+ let markup = "";
+ for (let i = 0; i < count; ++i) markup += `<span>s${i}</span> `;
+ return markup;
+ }
+ function element(tag, text, style) {
+ const result = document.createElement(tag);
+ result.textContent = text;
+ if (style) result.style.cssText = style;
+ return result;
+ }
+ const list = fixture => fixture.querySelector("#list");
+
+ const cases = [
+ {
+ name: "remove a block from a long block list",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(200)}</div>`;
+ return () => list(fixture).children[100].remove();
+ },
+ },
+ {
+ name: "remove the last block among inline content",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">one <span>two</span><div>block</div> three</div>`;
+ return () => list(fixture).querySelector("div").remove();
+ },
+ },
+ {
+ name: "remove an inline from an inline run",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${inlines(20)}</div>`;
+ return () => list(fixture).children[7].remove();
+ },
+ },
+ {
+ name: "remove a text between two inline-blocks",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list"><span style="display: inline-block">a</span> <span style="display: inline-block">b</span></div>`;
+ return () => list(fixture).childNodes[1].remove();
+ },
+ },
+ {
+ name: "remove the first counted child",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="counted">${blocks(10)}</div>`;
+ return () => list(fixture).firstElementChild.remove();
+ },
+ },
+ {
+ name: "remove a list item",
+ setup(fixture) {
+ fixture.innerHTML = `<ol id="list"><li>a</li><li>b</li><li>c</li><li>d</li></ol>`;
+ return () => list(fixture).children[1].remove();
+ },
+ },
+ {
+ name: "remove a table row",
+ setup(fixture) {
+ fixture.innerHTML = `<table><tbody id="list"><tr><td>a</td></tr><tr><td>b</td></tr><tr><td>c</td></tr></tbody></table>`;
+ return () => list(fixture).children[1].remove();
+ },
+ },
+ {
+ name: "remove a loose cell from a block",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list"><div>x</div><div style="display: table-cell">cell</div><div>y</div></div>`;
+ return () => list(fixture).children[1].remove();
+ },
+ },
+ {
+ name: "remove the block that holds the first letter",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="first-letter"><div>first</div><div>second</div></div>`;
+ return () => list(fixture).firstElementChild.remove();
+ },
+ },
+ {
+ name: "remove a child of a display: contents child",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list"><span style="display: contents"><div>a</div><div>b</div></span><div>c</div></div>`;
+ return () => list(fixture).querySelector("div").remove();
+ },
+ },
+ {
+ name: "move a block to the front of its list",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(20)}</div>`;
+ return () => list(fixture).prepend(list(fixture).children[12]);
+ },
+ },
+ {
+ name: "move a block between two lists",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(10)}</div><div id="other" class="flex">${blocks(5, "o")}</div>`;
+ return () => fixture.querySelector("#other").append(list(fixture).children[3]);
+ },
+ },
+ {
+ name: "move an inline into a block list",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(4)}</div><p id="other">${inlines(5)}</p>`;
+ return () => list(fixture).children[2].after(fixture.querySelector("#other span"));
+ },
+ },
+ {
+ name: "hide a block",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(50)}</div>`;
+ return () => list(fixture).children[25].classList.add("hidden");
+ },
+ },
+ {
+ name: "show a hidden block",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(10)}<div class="hidden">shown</div>${blocks(10, "c")}</div>`;
+ return () => list(fixture).querySelector(".hidden").classList.remove("hidden");
+ },
+ },
+ {
+ name: "turn a block into an inline among blocks",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(6)}</div>`;
+ return () => (list(fixture).children[3].style.display = "inline");
+ },
+ },
+ {
+ name: "turn an inline into a block among inlines",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${inlines(10)}</div>`;
+ return () => (list(fixture).children[4].style.display = "block");
+ },
+ },
+ {
+ name: "turn a block into a flex container",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(3)}<div id="target">a <span>b</span> c</div>${blocks(3, "c")}</div>`;
+ return () => (fixture.querySelector("#target").style.display = "flex");
+ },
+ },
+ {
+ name: "turn a flex container into a grid",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list"><div id="target" class="flex">${blocks(4)}</div></div>`;
+ return () => (fixture.querySelector("#target").style.display = "grid");
+ },
+ },
+ {
+ name: "turn a list item into a block",
+ setup(fixture) {
+ fixture.innerHTML = `<ol id="list"><li>a</li><li>b</li><li>c</li></ol>`;
+ return () => (list(fixture).children[0].style.display = "block");
+ },
+ },
+ {
+ name: "turn a block into a table cell",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(4)}</div>`;
+ return () => (list(fixture).children[1].style.display = "table-cell");
+ },
+ },
+ {
+ name: "turn a block into display: contents",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list"><div>a</div><div id="target"><p>b</p> text</div><div>c</div></div>`;
+ return () => (fixture.querySelector("#target").style.display = "contents");
+ },
+ },
+ {
+ name: "turn display: contents into a block",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list"><div>a</div><div id="target" style="display: contents"><p>b</p> text</div><div>c</div></div>`;
+ return () => (fixture.querySelector("#target").style.display = "block");
+ },
+ },
+ {
+ name: "make a flex item absolutely positioned",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="flex" style="position: relative">${blocks(5)}</div>`;
+ return () => (list(fixture).children[2].style.position = "absolute");
+ },
+ },
+ {
+ name: "float an inline in an inline run",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${inlines(8)}</div>`;
+ return () => (list(fixture).children[3].style.float = "left");
+ },
+ },
+ {
+ name: "change the style of a block that keeps its kind",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(5)}<div id="target"><p>deep <b>text</b></p></div>${blocks(5, "c")}</div>`;
+ return () => (fixture.querySelector("#target").style.display = "flow-root");
+ },
+ },
+ {
+ name: "change the white space of a block with white space children",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list"><div id="target"><span>a</span> <span>b</span> <span>c</span></div></div>`;
+ return () => (fixture.querySelector("#target").style.whiteSpace = "pre");
+ },
+ },
+ {
+ name: "add a ::before",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${inlines(5)}</div>`;
+ return () => list(fixture).classList.add("before");
+ },
+ },
+ {
+ name: "remove an ::after",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="after">${inlines(5)}</div>`;
+ return () => list(fixture).classList.remove("after");
+ },
+ },
+ {
+ name: "add a block ::before to an inline list",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${inlines(5)}</div>`;
+ return () => list(fixture).classList.add("block-before");
+ },
+ },
+ {
+ name: "add a ::before to a flex container",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="flex">${blocks(5)}</div>`;
+ return () => list(fixture).classList.add("before");
+ },
+ },
+ {
+ name: "change the ::marker of a list item",
+ setup(fixture) {
+ fixture.innerHTML = `<style>#list.custom > li::marker { content: "* "; }</style><ul id="list"><li>a</li><li>b</li></ul>`;
+ return () => list(fixture).classList.add("custom");
+ },
+ },
+ {
+ name: "add a ::before to a block with a first letter",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="first-letter">letter text</div>`;
+ return () => list(fixture).classList.add("before");
+ },
+ },
+ {
+ name: "remove and hide in several lists in one update",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(10)}</div><div id="other" class="grid">${blocks(10, "o")}</div>`;
+ return () => {
+ list(fixture).children[2].remove();
+ fixture.querySelector("#other").children[5].classList.add("hidden");
+ list(fixture).children[6].style.display = "inline";
+ };
+ },
+ },
+ ];
+
+ test(() => {
+ runLayoutTreeFullRebuildComparisonCases(cases);
+
+ // The boxes of the children a list keeps stay the same boxes.
+ const fixture = document.getElementById("fixture");
+ const identityCases = [
+ ["remove a block", `<div id="list">${blocks(50)}</div>`, list => list.children[20].remove()],
+ ["hide a block", `<div id="list">${blocks(50)}</div>`, list => list.children[20].classList.add("hidden")],
+ ["turn a block inline", `<div id="list">${blocks(50)}</div>`, list => (list.children[20].style.display = "inline-block")],
+ ["add a ::before", `<div id="list">${blocks(50)}</div>`, list => list.classList.add("before")],
+ ["move a block", `<div id="list">${blocks(50)}</div>`, list => list.children[40].before(list.children[3])],
+ ];
+ for (const [name, markup, mutate] of identityCases) {
+ fixture.innerHTML = markup;
+ const list = fixture.querySelector("#list");
+ const kept = [...list.children].filter((_, index) => index % 7 === 0);
+ const preserved = layoutBoxTransitions(() => mutate(list), kept).transitions.every(transition => transition === "PRESERVED");
+ println(`${name}: kept children preserved: ${preserved}, matches full rebuild: ${internals.compareLayoutTreeWithFullRebuild().matches}`);
+ }
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/button-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/button-mutations.html
new file mode 100644
index 00000000000..55fbacfd04f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/button-mutations.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const buttonStyle = `<style>
+ .before::before { content: "before"; }
+ .after::after { content: "after"; display: block; }
+ </style>`;
+
+ const buttonMutations = [
+ ["insert text", (button) => button.append("more")],
+ ["remove all text", (button) => button.textContent = ""],
+ ["insert an inline", (button) => button.insertAdjacentHTML("beforeend", "<span>inline</span>")],
+ ["insert a block", (button) => button.insertAdjacentHTML("beforeend", "<div>block</div>")],
+ ["remove the inline", (button) => button.querySelector("span").remove()],
+ ["add ::before", (button) => button.classList.add("before")],
+ ["add a block ::after", (button) => button.classList.add("after")],
+ ["make it display flex", (button) => button.style.display = "flex"],
+ ["make it display grid", (button) => button.style.display = "grid"],
+ ["make it display block", (button) => button.style.display = "block"],
+ ["make it display list-item", (button) => button.style.display = "list-item"],
+ ["make it display contents", (button) => button.style.display = "contents"],
+ ["make it display none", (button) => button.style.display = "none"],
+ ["set appearance none", (button) => button.style.appearance = "none"],
+ ["make it absolutely positioned", (button) => button.style.position = "absolute"],
+ ];
+
+ const cases = [];
+ for (const initialDisplay of ["", "flex", "block"]) {
+ for (const [name, mutate] of buttonMutations) {
+ cases.push({
+ name: `${initialDisplay || "default"}: ${name}`,
+ setup(fixture) {
+ fixture.innerHTML = buttonStyle + `<div>a <button id="button" style="display: ${initialDisplay}">label <span>inline</span></button> b</div>`;
+ return () => mutate(fixture.querySelector("#button"));
+ },
+ });
+ }
+ }
+ for (const type of ["button", "submit", "reset", "checkbox", "color", "range"]) {
+ cases.push({
+ name: `input type ${type}: toggle appearance none`,
+ setup(fixture) {
+ fixture.innerHTML = `<div>a <input id="input" type="${type}" value="value"> b</div>`;
+ return () => fixture.querySelector("#input").style.appearance = "none";
+ },
+ });
+ }
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/content-image-pseudo-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/content-image-pseudo-mutations.html
new file mode 100644
index 00000000000..24e956a8eaf
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/content-image-pseudo-mutations.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const image = "url(../../../Assets/120.png)";
+ const contentValues = [
+ ["text", `"text"`],
+ ["single image", image],
+ ["image in a list", `"a" ${image} "b"`],
+ ["image with alt text", `${image} / "alt"`],
+ ["empty string", `""`],
+ ["none", "none"],
+ ];
+ const displays = ["inline", "block", "list-item", "inline-block"];
+
+ const cases = [];
+ for (const [fromName, fromContent] of contentValues) {
+ for (const [toName, toContent] of contentValues) {
+ if (fromName === toName) continue;
+ cases.push({
+ name: `${fromName} -> ${toName}`,
+ setup(fixture) {
+ fixture.innerHTML = `<style id="rule">#target::before { content: ${fromContent}; }</style><div id="target">text</div>`;
+ return () => fixture.querySelector("#rule").textContent = `#target::before { content: ${toContent}; }`;
+ },
+ });
+ }
+ }
+ for (const [contentName, content] of contentValues.slice(0, 4)) {
+ for (const fromDisplay of displays) {
+ for (const toDisplay of displays) {
+ // NB: Each display is changed to and from inline, so that every display is both where the box comes from
+ // and where it goes.
+ if (fromDisplay === toDisplay || (fromDisplay !== "inline" && toDisplay !== "inline")) continue;
+ cases.push({
+ name: `${contentName}: display ${fromDisplay} -> ${toDisplay}`,
+ setup(fixture) {
+ fixture.innerHTML = `<style id="rule">#target::before { content: ${content}; display: ${fromDisplay}; }</style><div id="target"><span>text</span></div>`;
+ return () => fixture.querySelector("#rule").textContent = `#target::before { content: ${content}; display: ${toDisplay}; }`;
+ },
+ });
+ }
+ }
+ }
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/counter-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/counter-mutations.html
new file mode 100644
index 00000000000..23cd5472313
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/counter-mutations.html
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const counterStyle = `<style>
+ .list { counter-reset: c; }
+ .list p { counter-increment: c; margin: 0; }
+ .list p::before { content: counter(c) " "; }
+ .list li::marker { content: counter(c) ". "; }
+ .reset { counter-reset: c 10; }
+ .increment { counter-increment: c 5; }
+ .set { counter-set: c 20; }
+ .reversed { counter-reset: reversed(c); }
+ .before-reset::before { counter-reset: c 30; }
+ .before-set::before { counter-set: c 40; }
+ .hidden { display: none; }
+ </style>`;
+
+ const counterMarkup = `<div class="list" id="list">
+ <p id="first">a</p>
+ <div id="middle"><p>b</p><p id="nested">c</p></div>
+ <ul><li id="item">d</li><li>e</li></ul>
+ <p id="last">f</p>
+ </div>`;
+
+ const counterProperties = ["reset", "increment", "set", "reversed", "before-reset", "before-set"];
+
+ const counterMutations = [
+ ["insert an element carrying it before the list", (fixture, cls) => fixture.querySelector("#first").insertAdjacentHTML("beforebegin", `<p class="${cls}">new</p>`)],
+ ["insert an element carrying it in a nested block", (fixture, cls) => fixture.querySelector("#nested").insertAdjacentHTML("beforebegin", `<p class="${cls}">new</p>`)],
+ ["toggle it on an earlier sibling", (fixture, cls) => fixture.querySelector("#first").classList.toggle(cls)],
+ ["toggle it on an ancestor", (fixture, cls) => fixture.querySelector("#middle").classList.toggle(cls)],
+ ["toggle it on a list item", (fixture, cls) => fixture.querySelector("#item").classList.toggle(cls)],
+ ];
+
+ const counterRemovalMutations = [
+ ["remove the element carrying it", (fixture) => fixture.querySelector("#carrier").remove()],
+ ["hide the element carrying it", (fixture) => fixture.querySelector("#carrier").classList.add("hidden")],
+ ["remove it from the element", (fixture, cls) => fixture.querySelector("#carrier").classList.remove(cls)],
+ ];
+
+ // FIXME: These combinations do not update later counter values incrementally yet.
+ const knownMismatches = new Set([
+ "increment: insert an element carrying it in a nested block",
+ "increment: toggle it on a list item",
+ "set: insert an element carrying it in a nested block",
+ "set: toggle it on a list item",
+ "before-reset: insert an element carrying it in a nested block",
+ "before-set: insert an element carrying it in a nested block",
+ ]);
+
+ const cases = [];
+ for (const cls of counterProperties) {
+ for (const [mutationName, mutate] of counterMutations) {
+ if (knownMismatches.has(`${cls}: ${mutationName}`)) continue;
+ cases.push({
+ name: `${cls}: ${mutationName}`,
+ setup(fixture) {
+ fixture.innerHTML = counterStyle + counterMarkup;
+ return () => mutate(fixture, cls);
+ },
+ });
+ }
+ for (const [mutationName, mutate] of counterRemovalMutations) {
+ cases.push({
+ name: `${cls}: ${mutationName}`,
+ setup(fixture) {
+ fixture.innerHTML = counterStyle + counterMarkup;
+ fixture.querySelector("#first").insertAdjacentHTML("afterend", `<p id="carrier" class="${cls}">carrier</p>`);
+ return () => mutate(fixture, cls);
+ },
+ });
+ }
+ }
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/display-contents-counter-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/display-contents-counter-mutations.html
new file mode 100644
index 00000000000..da0095daed0
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/display-contents-counter-mutations.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const contentsStyle = `<style>
+ .list p { counter-increment: c; margin: 0; }
+ .list p::before { content: counter(c) " "; }
+ .contents { display: contents; }
+ .reset { counter-reset: c 10; }
+ .increment { counter-increment: c 5; }
+ </style>`;
+
+ const contentsMarkup = `<div class="list"><p>a</p><div id="wrapper"><p>b</p><p>c</p></div><p>d</p></div>`;
+
+ const cases = [
+ ["toggle counter-reset on a display contents element", "contents", (wrapper) => wrapper.classList.toggle("reset")],
+ ["toggle display contents on an element carrying counter-reset", "reset", (wrapper) => wrapper.classList.toggle("contents")],
+ ["toggle counter-increment on a display contents element", "contents", (wrapper) => wrapper.classList.toggle("increment")],
+ ["toggle display contents on an element carrying counter-increment", "increment", (wrapper) => wrapper.classList.toggle("contents")],
+ ["insert a counter user into a display contents element with counter-reset", "contents reset", (wrapper) => wrapper.insertAdjacentHTML("afterbegin", "<p>new</p>")],
+ ].map(([name, initialClasses, mutate]) => ({
+ name,
+ setup(fixture) {
+ fixture.innerHTML = contentsStyle + contentsMarkup;
+ const wrapper = fixture.querySelector("#wrapper");
+ wrapper.className = initialClasses;
+ return () => mutate(wrapper);
+ },
+ }));
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/display-contents-restyle-with-child-list-change.html b/Tests/LibWeb/Text/input/layout-tree-update/display-contents-restyle-with-child-list-change.html
new file mode 100644
index 00000000000..47d992eeec5
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/display-contents-restyle-with-child-list-change.html
@@ -0,0 +1,137 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ // A `display: contents` element's child list or pseudo-elements change, and in the same update an inherited text
+ // style of it changes, which the texts it flattens into its parent's box show. The same for an element in the
+ // content of an SVG mask, whose boxes are built below the elements that reference the mask.
+ const style = `<style>
+ .big { font-size: 30px; }
+ .big-with-before { font-size: 30px; }
+ .big-with-before::before { content: "before "; }
+ .with-before::before { content: "before "; }
+ </style>`;
+
+ const markup = `<div id="parent">start <span id="contents" style="display: contents">first <b id="child">child</b> second</span> end</div>`;
+
+ const childListChanges = [
+ ["append a child", (contents) => contents.append(Object.assign(document.createElement("i"), { textContent: "appended" }))],
+ ["insert a text", (contents) => contents.prepend("inserted ")],
+ ["remove a child", (contents) => contents.querySelector("#child").remove()],
+ ];
+
+ const cases = [];
+ for (const [name, changeChildList] of childListChanges) {
+ cases.push({
+ name: `${name}, change the font size`,
+ setup(fixture) {
+ fixture.innerHTML = style + markup;
+ return () => {
+ const contents = fixture.querySelector("#contents");
+ changeChildList(contents);
+ contents.classList.add("big");
+ };
+ },
+ });
+ }
+ for (const [name, changeChildList] of childListChanges) {
+ cases.push({
+ name: `${name}, add a ::before`,
+ setup(fixture) {
+ fixture.innerHTML = style + markup;
+ return () => {
+ const contents = fixture.querySelector("#contents");
+ changeChildList(contents);
+ contents.classList.add("with-before");
+ };
+ },
+ });
+ cases.push({
+ name: `${name}, add a ::before and change the font size`,
+ setup(fixture) {
+ fixture.innerHTML = style + markup;
+ return () => {
+ const contents = fixture.querySelector("#contents");
+ changeChildList(contents);
+ contents.classList.add("big-with-before");
+ };
+ },
+ });
+ cases.push({
+ name: `${name}, change the font size and a property a box is built again for`,
+ setup(fixture) {
+ fixture.innerHTML = style + markup;
+ return () => {
+ const contents = fixture.querySelector("#contents");
+ changeChildList(contents);
+ contents.style.position = "absolute";
+ contents.style.fontSize = "30px";
+ };
+ },
+ });
+ }
+ cases.push({
+ name: "change the font size and a property a box is built again for",
+ setup(fixture) {
+ fixture.innerHTML = style + markup;
+ return () => {
+ const contents = fixture.querySelector("#contents");
+ contents.style.position = "absolute";
+ contents.style.fontSize = "30px";
+ };
+ },
+ });
+ cases.push({
+ name: "add a ::before and change the font size",
+ setup(fixture) {
+ fixture.innerHTML = style + markup;
+ return () => fixture.querySelector("#contents").classList.add("big-with-before");
+ },
+ });
+ cases.push({
+ name: "add a ::before, then change the font size in a later style update",
+ setup(fixture) {
+ fixture.innerHTML = style + markup;
+ return () => {
+ const contents = fixture.querySelector("#contents");
+ contents.classList.add("big-with-before");
+ getComputedStyle(contents).fontSize;
+ contents.style.fontSize = "40px";
+ };
+ },
+ });
+
+ const svgMarkup = `<svg width="200" height="100">
+ <defs><mask id="mask"><g id="group"><text id="text" x="0" y="20">mask text</text></g></mask></defs>
+ <rect id="masked" width="200" height="100" fill="green" mask="url(#mask)"/>
+ </svg>`;
+
+ cases.push({
+ name: "SVG mask content: append a child, change the font size",
+ setup(fixture) {
+ fixture.innerHTML = svgMarkup;
+ return () => {
+ const group = fixture.querySelector("#group");
+ group.append(document.createElementNS("http://www.w3.org/2000/svg", "rect"));
+ group.style.fontSize = "30px";
+ };
+ },
+ });
+ cases.push({
+ name: "SVG mask content: change the font size, then append a child",
+ setup(fixture) {
+ fixture.innerHTML = svgMarkup;
+ return () => {
+ const group = fixture.querySelector("#group");
+ group.style.fontSize = "30px";
+ getComputedStyle(group).fontSize;
+ group.append(document.createElementNS("http://www.w3.org/2000/svg", "rect"));
+ };
+ },
+ });
+
+ test(() => {
+ runLayoutTreeFullRebuildComparisonCases(cases);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/escaping-pseudo-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/escaping-pseudo-mutations.html
new file mode 100644
index 00000000000..59fce0c829b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/escaping-pseudo-mutations.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const escapingStyle = `<style>
+ .before::before { content: "before"; display: block; }
+ .after::after { content: "after"; display: block; }
+ .list-item::before { content: "item"; display: list-item; }
+ </style>`;
+
+ const escapingMarkup = `<div id="container"><span id="outer"><b id="inner"><i id="innermost">x</i></b></span> tail</div>`;
+
+ const escapingMutations = [
+ ["add a block ::before to the innermost inline", (fixture) => fixture.querySelector("#innermost").classList.add("before")],
+ ["add a block ::after to the middle inline", (fixture) => fixture.querySelector("#inner").classList.add("after")],
+ ["remove a block ::after from the middle inline", (fixture) => fixture.querySelector("#inner").classList.remove("after"), "#inner", "after"],
+ ["remove a block ::before from the innermost inline", (fixture) => fixture.querySelector("#innermost").classList.remove("before"), "#innermost", "before"],
+ ["add a list-item ::before to the outer inline", (fixture) => fixture.querySelector("#outer").classList.add("list-item")],
+ ["insert a block sibling after the inline", (fixture) => fixture.querySelector("#outer").after(Object.assign(document.createElement("div"), { textContent: "block" })), "#innermost", "before"],
+ ["insert a block sibling before the inline", (fixture) => fixture.querySelector("#outer").before(Object.assign(document.createElement("div"), { textContent: "block" })), "#inner", "after"],
+ ["make the outer inline an inline-block", (fixture) => fixture.querySelector("#outer").style.display = "inline-block", "#innermost", "before"],
+ ["make the middle inline a block", (fixture) => fixture.querySelector("#inner").style.display = "block", "#inner", "after"],
+ ["hide the outer inline", (fixture) => fixture.querySelector("#outer").style.display = "none", "#innermost", "before"],
+ ["make the outer inline display contents", (fixture) => fixture.querySelector("#outer").style.display = "contents", "#innermost", "before"],
+ ["change the escaped pseudo-element content", (fixture) => fixture.querySelector("#container").insertAdjacentHTML("afterbegin", `<style>.before::before { content: "changed"; }</style>`), "#innermost", "before"],
+ ];
+
+ const cases = escapingMutations.map(([name, mutate, initialSelector, initialClass]) => ({
+ name,
+ setup(fixture) {
+ fixture.innerHTML = escapingStyle + escapingMarkup;
+ if (initialSelector)
+ fixture.querySelector(initialSelector).classList.add(initialClass);
+ return () => mutate(fixture);
+ },
+ }));
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/fieldset-legend-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/fieldset-legend-mutations.html
new file mode 100644
index 00000000000..e9b6b50022f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/fieldset-legend-mutations.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const legendMutations = [
+ ["insert a legend first", (fieldset) => fieldset.insertAdjacentHTML("afterbegin", "<legend>new</legend>")],
+ ["insert a legend last", (fieldset) => fieldset.insertAdjacentHTML("beforeend", "<legend>new</legend>")],
+ ["remove the legend", (fieldset) => fieldset.querySelector("legend")?.remove()],
+ ["move the legend to the end", (fieldset) => { const legend = fieldset.querySelector("legend"); if (legend) fieldset.append(legend); }],
+ ["hide the legend", (fieldset) => { const legend = fieldset.querySelector("legend"); if (legend) legend.style.display = "none"; }],
+ ["float the legend", (fieldset) => { const legend = fieldset.querySelector("legend"); if (legend) legend.style.float = "left"; }],
+ ["make the fieldset flex", (fieldset) => fieldset.style.display = "flex"],
+ ["make the fieldset grid", (fieldset) => fieldset.style.display = "grid"],
+ ["make the fieldset inline", (fieldset) => fieldset.style.display = "inline"],
+ ["make the fieldset display contents", (fieldset) => fieldset.style.display = "contents"],
+ ["insert text before the legend", (fieldset) => fieldset.prepend("text")],
+ ["insert a block before the legend", (fieldset) => fieldset.insertAdjacentHTML("afterbegin", "<div>block</div>")],
+ ["remove all content", (fieldset) => fieldset.replaceChildren()],
+ ];
+
+ const cases = [];
+ for (const [shapeName, markup] of [
+ ["with legend", "<legend>legend</legend>text <span>inline</span><div>block</div>"],
+ ["without legend", "text <span>inline</span>"],
+ ["two legends", "<legend>first</legend><legend>second</legend><div>block</div>"],
+ ]) {
+ for (const [name, mutate] of legendMutations) {
+ cases.push({
+ name: `${shapeName}: ${name}`,
+ setup(fixture) {
+ fixture.innerHTML = `<fieldset id="fieldset">${markup}</fieldset>`;
+ return () => mutate(fixture.querySelector("#fieldset"));
+ },
+ });
+ }
+ }
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/first-letter-kept-across-later-changes.html b/Tests/LibWeb/Text/input/layout-tree-update/first-letter-kept-across-later-changes.html
new file mode 100644
index 00000000000..5416b7deece
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/first-letter-kept-across-later-changes.html
@@ -0,0 +1,51 @@
+<!doctype html>
+<script src="../include.js"></script>
+<script src="../work-test.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<style>
+ .owner::first-letter {
+ color: green;
+ font-size: 2em;
+ }
+</style>
+<div id="fixture"></div>
+<script>
+ // A change of a child list after the ::first-letter of a block leaves the letter's boxes as they are, and leaves
+ // the layout of the block that holds the letter as it was. A change before the letter splits it out again.
+ function build() {
+ const fixture = document.getElementById("fixture");
+ let markup = `<div class="owner" id="owner"><p id="first">Hello world</p>`;
+ for (let i = 0; i < 20; ++i) markup += `<p>paragraph ${i}</p>`;
+ markup += `<p id="last">last</p></div>`;
+ fixture.innerHTML = markup;
+ document.body.offsetHeight;
+ return fixture;
+ }
+
+ function run(name, mutate) {
+ const fixture = build();
+ const text = fixture.querySelector("#first").firstChild;
+ const { work, transitions } = layoutBoxTransitions(() => mutate(fixture), [text]);
+ const letterBlockReused = work.text.includes("BlockContainer<P>#first REUSE");
+ println(
+ `${name}: letter boxes kept: ${transitions[0] === "PRESERVED"}, block of the letter reused: ${letterBlockReused}, matches full rebuild: ${internals.compareLayoutTreeWithFullRebuild().matches}`
+ );
+ }
+
+ test(() => {
+ run("append a block to the owner", fixture =>
+ fixture
+ .querySelector("#owner")
+ .append(Object.assign(document.createElement("p"), { textContent: "appended" }))
+ );
+ run("append text to the last block", fixture => fixture.querySelector("#last").append(" more"));
+ run("remove the last block", fixture => fixture.querySelector("#last").remove());
+ run("append text after the letter in its block", fixture => fixture.querySelector("#first").append(" more"));
+ run("insert a block before the letter", fixture =>
+ fixture
+ .querySelector("#owner")
+ .prepend(Object.assign(document.createElement("p"), { textContent: "Before" }))
+ );
+ run("insert text before the letter", fixture => fixture.querySelector("#first").prepend("Zed "));
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/first-letter-structure-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/first-letter-structure-mutations.html
new file mode 100644
index 00000000000..d0662ea69da
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/first-letter-structure-mutations.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const firstLetterStyle = `<style>
+ .target::first-letter { color: green; font-size: 2em; }
+ .ib { display: inline-block; }
+ .before::before { content: "Gen"; }
+ </style>`;
+
+ const firstLetterShapes = [
+ ["text", `<p id="first">Hello</p><p>World</p>`],
+ ["nested inline", `<p id="first"><span id="inline"><b>Hello</b></span> world</p>`],
+ ["block chain", `<div id="first"><p id="inner">Hello</p></div><p>World</p>`],
+ ["list item", `<ul><li id="first">Hello</li></ul>`],
+ ];
+
+ const firstLetterMutations = [
+ ["insert a block before the first child", (target) => target.insertAdjacentHTML("afterbegin", "<p>Inserted</p>")],
+ ["insert an inline before the text", (target) => target.querySelector("#first").insertAdjacentHTML("afterbegin", "<span>Zed </span>")],
+ ["insert an empty inline before the text", (target) => target.querySelector("#first").insertAdjacentHTML("afterbegin", "<span></span>")],
+ ["insert a line break before the text", (target) => target.querySelector("#first").insertAdjacentHTML("afterbegin", "<br>")],
+ ["remove the first child", (target) => target.firstElementChild.remove()],
+ ["make the first child inline-block", (target) => target.querySelector("#first").classList.add("ib")],
+ ["add a ::before to the first child", (target) => target.querySelector("#first").classList.add("before")],
+ ["replace the first text", (target) => {
+ const walker = document.createTreeWalker(target, NodeFilter.SHOW_TEXT);
+ walker.nextNode().data = "(Changed";
+ }],
+ ["move the first child to the end", (target) => target.append(target.firstElementChild)],
+ ];
+
+ const cases = [];
+ for (const [shapeName, markup] of firstLetterShapes) {
+ for (const [mutationName, mutate] of firstLetterMutations) {
+ cases.push({
+ name: `${shapeName}: ${mutationName}`,
+ setup(fixture) {
+ fixture.innerHTML = firstLetterStyle + `<div class="target" id="target">${markup}</div>`;
+ return () => mutate(fixture.querySelector("#target"));
+ },
+ });
+ }
+ }
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/first-letter-whole-text-node-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/first-letter-whole-text-node-mutations.html
new file mode 100644
index 00000000000..7e0d8082ab8
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/first-letter-whole-text-node-mutations.html
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ // The ::first-letter of a block takes all of a text node, or is in generated content, which leaves no text of a
+ // DOM node after it in its own box, and then the content before or around that text changes.
+ const style = `<style>
+ .target::first-letter { color: green; font-size: 2em; }
+ .generated::before { content: "Gen"; }
+ </style>`;
+
+ const shapes = [
+ ["letter alone", () => {
+ const target = document.createElement("p");
+ target.append("A");
+ const span = document.createElement("span");
+ span.textContent = "bc def";
+ target.append(span);
+ return target;
+ }],
+ ["letter with punctuation", () => {
+ const target = document.createElement("p");
+ target.append("\"A\"");
+ target.append(" bc def");
+ return target;
+ }],
+ ["letter in an inline", () => {
+ const target = document.createElement("p");
+ const b = document.createElement("b");
+ b.textContent = "A";
+ target.append(b, " bc def");
+ return target;
+ }],
+ ["letter in a ::before", () => {
+ const target = document.createElement("p");
+ target.classList.add("generated");
+ target.append("A bc def");
+ return target;
+ }],
+ ["letter in the ::before of a child", () => {
+ const target = document.createElement("div");
+ const child = document.createElement("p");
+ child.classList.add("generated");
+ child.append("A bc def");
+ target.append(child);
+ return target;
+ }],
+ ];
+
+ const mutations = [
+ ["insert a text before", (target) => target.prepend("Zed ")],
+ ["insert an inline before", (target) => target.prepend(Object.assign(document.createElement("i"), { textContent: "Yes " }))],
+ ["insert an empty inline before", (target) => target.prepend(document.createElement("i"))],
+ ["remove the letter's text", (target) => {
+ const walker = document.createTreeWalker(target, NodeFilter.SHOW_TEXT);
+ walker.nextNode().remove();
+ }],
+ ["empty the letter's text", (target) => {
+ const walker = document.createTreeWalker(target, NodeFilter.SHOW_TEXT);
+ walker.nextNode().data = "";
+ }],
+ ["append at the end", (target) => target.append(" appended")],
+ ["remove the ::before", (target) => target.querySelectorAll(".generated").forEach(element => element.classList.remove("generated"))],
+ ["remove the ::before of the target", (target) => target.classList.remove("generated")],
+ ];
+
+ const cases = [];
+ for (const [shapeName, build] of shapes) {
+ for (const [mutationName, mutate] of mutations) {
+ cases.push({
+ name: `${shapeName}: ${mutationName}`,
+ setup(fixture) {
+ fixture.innerHTML = style;
+ const target = build();
+ target.className = "target";
+ fixture.append(target);
+ return () => mutate(target);
+ },
+ });
+ }
+ }
+
+ test(() => {
+ runLayoutTreeFullRebuildComparisonCases(cases);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/frameset-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/frameset-mutations.html
new file mode 100644
index 00000000000..6beb6a9e4e7
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/frameset-mutations.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const framesetMutations = [
+ ["append a div", (frameset, doc) => frameset.append(doc.createElement("div"))],
+ ["append text", (frameset, doc) => frameset.append("text")],
+ ["append a frame", (frameset, doc) => frameset.append(doc.createElement("frame"))],
+ ["insert a nested frameset", (frameset, doc) => frameset.prepend(Object.assign(doc.createElement("frameset"), { rows: "50%,50%" }))],
+ ["remove a frame", (frameset) => frameset.querySelector("frame").remove()],
+ ["change cols", (frameset) => frameset.cols = "30%,70%"],
+ ["hide a frame", (frameset) => frameset.querySelector("frame").style.display = "none"],
+ ["add a ::before rule", (frameset, doc) => doc.head.append(Object.assign(doc.createElement("style"), { textContent: "frameset::before { content: 'x'; }" }))],
+ ];
+
+ let iframe;
+ const cases = framesetMutations.map(([name, mutate]) => ({
+ name,
+ setup(fixture) {
+ iframe = document.createElement("iframe");
+ fixture.append(iframe);
+ const doc = iframe.contentDocument;
+ doc.open();
+ doc.write(`<!DOCTYPE html><head></head><frameset id="frameset" cols="50%,50%"><frame><frame></frameset>`);
+ doc.close();
+ return () => mutate(doc.getElementById("frameset"), doc);
+ },
+ comparisonDocuments() {
+ return [document, iframe.contentDocument];
+ },
+ }));
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/image-element-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/image-element-mutations.html
new file mode 100644
index 00000000000..88f4a7e33ea
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/image-element-mutations.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const imageMutations = [
+ ["insert an image", (container) => container.insertAdjacentHTML("afterbegin", '<img src="../../../Assets/120.png" width="10" height="10">')],
+ ["remove the image", (container) => container.querySelector("img").remove()],
+ ["hide the image", (container) => container.querySelector("img").style.display = "none"],
+ ["make the image a block", (container) => container.querySelector("img").style.display = "block"],
+ ["make the image display contents", (container) => container.querySelector("img").style.display = "contents"],
+ ["change the alt of a broken image", (container) => container.querySelector("#broken").alt = "changed alt"],
+ ["remove the alt of a broken image", (container) => container.querySelector("#broken").removeAttribute("alt")],
+ ["replace the image content with content url", (container) => container.querySelector("img").style.content = "url(../../../Assets/120.png)"],
+ ["give the image a ::before", (container) => container.querySelector("img").insertAdjacentHTML("beforebegin", "<style>img::before { content: 'before'; }</style>")],
+ ];
+
+ const cases = [];
+ for (const containerDisplay of ["block", "inline", "flex"]) {
+ for (const [name, mutate] of imageMutations) {
+ cases.push({
+ name: `${containerDisplay}: ${name}`,
+ setup(fixture) {
+ fixture.innerHTML = `<div id="container" style="display: ${containerDisplay}">a <img src="../../../Assets/120.png" width="10" height="10"> b <img id="broken" alt="alt text"> c</div>`;
+ return () => mutate(fixture.querySelector("#container"));
+ },
+ });
+ }
+ }
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/list-style-image-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/list-style-image-mutations.html
new file mode 100644
index 00000000000..60656491ea4
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/list-style-image-mutations.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const image = "url(../../../Assets/120.png)";
+ const listMutations = [
+ ["set list-style-image", (item) => item.style.listStyleImage = image],
+ ["clear list-style-image", (item) => item.style.listStyleImage = "none", image],
+ ["switch an image marker inside", (item) => item.style.listStylePosition = "inside", image],
+ ["switch an image marker outside", (item) => item.style.listStylePosition = "outside", image, "inside"],
+ ["set list-style-type none under an image", (item) => item.style.listStyleType = "none", image],
+ ["set an image on a list item with a block child", (item) => { item.insertAdjacentHTML("afterbegin", "<div>block</div>"); item.style.listStyleImage = image; }],
+ ["make an image list item a block", (item) => item.style.display = "block", image],
+ ];
+
+ const cases = listMutations.map(([name, mutate, initialImage, initialPosition]) => ({
+ name,
+ setup(fixture) {
+ fixture.innerHTML = `<ul><li>first</li><li id="item">item</li><li>last</li></ul>`;
+ const item = fixture.querySelector("#item");
+ if (initialImage) item.style.listStyleImage = initialImage;
+ if (initialPosition) item.style.listStylePosition = initialPosition;
+ return () => mutate(item);
+ },
+ }));
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/list-unit-cases.html b/Tests/LibWeb/Text/input/layout-tree-update/list-unit-cases.html
new file mode 100644
index 00000000000..85eeb3c9832
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/list-unit-cases.html
@@ -0,0 +1,346 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="../work-test.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<style>
+ .flex { display: flex; }
+ .grid { display: grid; }
+ .clearfix::after { content: ""; display: table; clear: both; }
+ .counted { counter-reset: c; }
+ .counted > * { counter-increment: c; }
+ .counted > *::before { content: counter(c) ". "; }
+ .quoted > q::before { content: open-quote; }
+ .first-letter::first-letter { color: green; }
+ .abspos { position: absolute; }
+ .float { float: left; }
+</style>
+<div id="fixture"></div>
+<script>
+ // Mutations of the child list of a box that keeps its box: appends, prepends and insertions in the middle of long
+ // lists, removals, moves between two lists in one update, and insertions next to anonymous wrappers, white space
+ // and generated content, in block, inline, flex, grid, table, button and fieldset parents. Each is compared with a
+ // full rebuild, and some also say whether the box of a child that stays kept its identity.
+ function blocks(count, prefix = "b") {
+ let markup = "";
+ for (let i = 0; i < count; ++i) markup += `<div>${prefix}${i}</div>`;
+ return markup;
+ }
+ function inlines(count) {
+ let markup = "";
+ for (let i = 0; i < count; ++i) markup += `<span>s${i}</span> `;
+ return markup;
+ }
+ function element(tag, text, style) {
+ const result = document.createElement(tag);
+ result.textContent = text;
+ if (style) result.style.cssText = style;
+ return result;
+ }
+
+ const cases = [
+ {
+ name: "append blocks to a long block list",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(300)}</div>`;
+ return () => {
+ const list = fixture.querySelector("#list");
+ for (let i = 0; i < 30; ++i) list.append(element("div", `new${i}`));
+ };
+ },
+ },
+ {
+ name: "prepend blocks to a long block list",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(300)}</div>`;
+ return () => fixture.querySelector("#list").prepend(element("div", "first"), element("p", "second"));
+ },
+ },
+ {
+ name: "insert blocks in the middle of a long block list",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(300)}</div>`;
+ return () => {
+ const list = fixture.querySelector("#list");
+ list.children[150].before(element("div", "middle"), " text ", element("span", "inline"));
+ };
+ },
+ },
+ {
+ name: "remove blocks from the middle of a long block list",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(300)}</div>`;
+ return () => {
+ const list = fixture.querySelector("#list");
+ for (let i = 0; i < 10; ++i) list.children[100].remove();
+ };
+ },
+ },
+ {
+ name: "append inline content to a long inline list",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${inlines(300)}</div>`;
+ return () => fixture.querySelector("#list").append("tail ", element("b", "bold"), " ");
+ },
+ },
+ {
+ name: "insert a block among inline children",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${inlines(20)}</div>`;
+ return () => fixture.querySelector("#list").children[10].after(element("div", "block"));
+ },
+ },
+ {
+ name: "insert inline content into the trailing anonymous wrapper",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(5)} trailing <span>run</span></div>`;
+ return () => fixture.querySelector("#list").append(" more ", element("i", "italic"));
+ },
+ },
+ {
+ name: "insert inline content into a wrapper between blocks",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(3)} middle <span>run</span>${blocks(3, "c")}</div>`;
+ return () => fixture.querySelector("#list span").after(" added ", element("em", "em"));
+ },
+ },
+ {
+ name: "insert a block that splits an anonymous wrapper",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(2)} one <span>two</span> three ${blocks(2, "c")}</div>`;
+ return () => fixture.querySelector("#list span").after(element("div", "splitter"));
+ },
+ },
+ {
+ name: "insert white space between two kept inline-blocks",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list"><span style="display: inline-block">a</span><span style="display: inline-block">b</span></div>`;
+ return () => fixture.querySelector("#list span").after(" ");
+ },
+ },
+ {
+ name: "insert a text next to collapsible white space",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list"><div>block</div> <span>inline</span> </div>`;
+ return () => fixture.querySelector("#list").prepend("start ");
+ },
+ },
+ {
+ name: "append to a block with a clearfix ::after",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="clearfix">${blocks(20)}</div>`;
+ return () => fixture.querySelector("#list").append(element("div", "new", "float: left"));
+ },
+ },
+ {
+ name: "insert before a kept sibling whose ::before counts",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="counted">${blocks(10)}</div>`;
+ return () => fixture.querySelector("#list").children[3].before(element("div", "inserted"));
+ },
+ },
+ {
+ name: "append after siblings whose ::before counts",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="counted">${blocks(10)}</div>`;
+ return () => fixture.querySelector("#list").append(element("div", "appended"));
+ },
+ },
+ {
+ name: "insert an open quote before kept quotes",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="quoted"><q>a</q><q>b</q></div>`;
+ return () => {
+ const q = document.createElement("q");
+ q.style.cssText = "display: inline";
+ fixture.querySelector("#list").prepend(q);
+ };
+ },
+ },
+ {
+ name: "insert text before the first letter",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="first-letter"><span>hello</span> world<div>block</div></div>`;
+ return () => fixture.querySelector("#list").prepend("Xyz ");
+ },
+ },
+ {
+ name: "insert a block before the first letter's block",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="first-letter"><p>hello</p><p>world</p></div>`;
+ return () => fixture.querySelector("#list").prepend(element("p", "Before"));
+ },
+ },
+ {
+ name: "append out-of-flow boxes among inline content",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" style="position: relative">a <span>b</span> c</div>`;
+ return () => fixture.querySelector("#list").append(element("div", "abs", "position: absolute"), element("div", "float", "float: left"), " d");
+ },
+ },
+ {
+ name: "append to a long flex list",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="flex">${blocks(200)} text <span>s</span></div>`;
+ return () => fixture.querySelector("#list").append(" more ", element("div", "item"));
+ },
+ },
+ {
+ name: "insert in the middle of a grid list",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list" class="grid">${blocks(50)}</div>`;
+ return () => fixture.querySelector("#list").children[25].before("loose text", element("span", "inline"));
+ },
+ },
+ {
+ name: "append rows to a table body",
+ setup(fixture) {
+ let rows = "";
+ for (let i = 0; i < 40; ++i) rows += `<tr><td>${i}</td><td>x</td></tr>`;
+ fixture.innerHTML = `<table><tbody id="list">${rows}</tbody></table>`;
+ return () => {
+ const row = document.createElement("tr");
+ row.innerHTML = "<td>new</td>";
+ fixture.querySelector("#list").append(row, " ");
+ };
+ },
+ },
+ {
+ name: "append loose cells after kept cells",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list"><div style="display: table-cell">a</div><div style="display: table-cell">b</div></div>`;
+ return () => fixture.querySelector("#list").append(element("div", "c", "display: table-cell"));
+ },
+ },
+ {
+ name: "insert a block before a kept table",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list"><table style="margin: 5px"><tr><td>cell</td></tr></table> text</div>`;
+ return () => fixture.querySelector("#list").prepend(element("div", "block"));
+ },
+ },
+ {
+ name: "insert inline content into a button",
+ setup(fixture) {
+ fixture.innerHTML = `<div>a <button id="list">label <span>inline</span></button> b</div>`;
+ return () => fixture.querySelector("#list").append(" more", element("b", "bold"));
+ },
+ },
+ {
+ name: "insert a block into a button",
+ setup(fixture) {
+ fixture.innerHTML = `<div>a <button id="list">label <span>inline</span></button> b</div>`;
+ return () => fixture.querySelector("#list").append(element("div", "block"));
+ },
+ },
+ {
+ name: "insert a legend into a fieldset",
+ setup(fixture) {
+ fixture.innerHTML = `<fieldset id="list">content <div>block</div></fieldset>`;
+ return () => fixture.querySelector("#list").prepend(element("legend", "legend"));
+ },
+ },
+ {
+ name: "append content to a fieldset with a legend",
+ setup(fixture) {
+ fixture.innerHTML = `<fieldset id="list"><legend>legend</legend>content <div>block</div></fieldset>`;
+ return () => fixture.querySelector("#list").append(" text", element("div", "another"));
+ },
+ },
+ {
+ name: "insert under a display: contents child",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">a <span style="display: contents">b <i>c</i></span> d</div>`;
+ return () => fixture.querySelector("#list span").append(element("div", "block in contents"), " e");
+ },
+ },
+ {
+ name: "insert into a shadow root",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="host"><span>light</span></div>`;
+ const shadow = fixture.querySelector("#host").attachShadow({ mode: "open" });
+ shadow.innerHTML = `<p>one</p><slot></slot><p>two</p>`;
+ return () => shadow.querySelector("slot").after(element("div", "inserted"), " text");
+ },
+ },
+ {
+ name: "move a node between two lists that also gain children",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="first">${blocks(20)}</div><div id="second">${blocks(20, "c")}</div>`;
+ return () => {
+ const first = fixture.querySelector("#first");
+ const second = fixture.querySelector("#second");
+ first.append(element("div", "first new"));
+ second.append(element("div", "second new"));
+ second.children[5].after(first.children[10]);
+ };
+ },
+ },
+ {
+ name: "append to a list item with an inside marker",
+ setup(fixture) {
+ fixture.innerHTML = `<ul><li id="list" style="list-style-position: inside">item <span>s</span></li></ul>`;
+ return () => fixture.querySelector("#list").append(element("div", "block"), " tail");
+ },
+ },
+ {
+ name: "append a block after inline content",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${inlines(30)}</div>`;
+ return () => fixture.querySelector("#list").append(element("div", "block"), " after");
+ },
+ },
+ {
+ name: "append inline content after a block",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(30)}</div>`;
+ return () => fixture.querySelector("#list").append("text ", element("b", "bold"));
+ },
+ },
+ {
+ name: "append after trailing white space",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list"><span>a</span> <span>b</span> </div>`;
+ return () => fixture.querySelector("#list").append(" ", element("span", "c"), " ");
+ },
+ },
+ {
+ name: "append inline content after an absolutely positioned box",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="list">${blocks(5)}<div class="abspos">abs</div></div>`;
+ return () => fixture.querySelector("#list").append("text ", element("div", "abs again", "position: absolute"));
+ },
+ },
+ {
+ name: "append to several parents in one update",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="a">${blocks(10)}</div><div id="b">${inlines(10)}</div><div id="c" class="flex">${blocks(10)}</div>`;
+ return () => {
+ for (const id of ["a", "b", "c"]) fixture.querySelector(`#${id}`).append(element("div", `new in ${id}`), " text");
+ };
+ },
+ },
+ ];
+
+ test(() => {
+ runLayoutTreeFullRebuildComparisonCases(cases);
+
+ // The boxes of the children a list keeps stay the same boxes.
+ const fixture = document.getElementById("fixture");
+ const identityCases = [
+ ["append a block", `<div id="list">${blocks(50)}</div>`, list => list.append(element("div", "new"))],
+ ["insert a block in the middle", `<div id="list">${blocks(50)}</div>`, list => list.children[25].before(element("div", "new"))],
+ ["append inline content", `<div id="list">${inlines(20)}</div>`, list => list.append(" tail ", element("b", "b"))],
+ ["insert a block among inlines", `<div id="list">${inlines(20)}</div>`, list => list.children[10].after(element("div", "new"))],
+ ["append to a clearfix container", `<div id="list" class="clearfix">${blocks(20)}</div>`, list => list.append(element("div", "new"))],
+ ["append to a flex list", `<div id="list" class="flex">${blocks(20)}</div>`, list => list.append(element("div", "new"))],
+ ["append a row", `<table><tbody id="list"><tr><td>a</td></tr><tr><td>b</td></tr></tbody></table>`, list => list.append(Object.assign(document.createElement("tr"), { innerHTML: "<td>c</td>" }))],
+ ];
+ for (const [name, markup, mutate] of identityCases) {
+ fixture.innerHTML = markup;
+ const list = fixture.querySelector("#list");
+ const kept = [...list.children].filter((_, index) => index % 7 === 0);
+ const preserved = layoutBoxTransitions(() => mutate(list), kept).transitions.every(transition => transition === "PRESERVED");
+ println(`${name}: kept children preserved: ${preserved}, matches full rebuild: ${internals.compareLayoutTreeWithFullRebuild().matches}`);
+ }
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/list-unit-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/list-unit-mutations.html
new file mode 100644
index 00000000000..1755e1c4d46
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/list-unit-mutations.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="../work-test.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ // Mutations of one parent's child list that keep most of its children: the shapes a build that plans the list
+ // again with its kept children has to get right.
+ const cases = [
+ {
+ name: "reorder slotted nodes that keep their boxes",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="host"><span slot="a">a</span><span slot="b">b</span><div slot="a">block a</div></div>`;
+ const shadow = fixture.querySelector("#host").attachShadow({ mode: "open" });
+ shadow.innerHTML = `<slot name="a"></slot><p>between</p><slot name="b"></slot>`;
+ return () => {
+ const host = fixture.querySelector("#host");
+ host.querySelector("[slot=b]").slot = "a";
+ host.querySelector("div").slot = "b";
+ };
+ },
+ },
+ {
+ name: "move a node from one changed list to another",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="first">one <b id="moved">moved</b> two</div><div id="second">three</div>`;
+ return () => {
+ fixture.querySelector("#first").append(" appended");
+ fixture.querySelector("#second").prepend(fixture.querySelector("#moved"));
+ };
+ },
+ },
+ {
+ name: "remove the last block child of a block with inline children",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="parent">inline <span>text</span><div id="block">block</div>more inline</div>`;
+ return () => fixture.querySelector("#block").remove();
+ },
+ },
+ {
+ name: "insert an inline-block between two kept inline-blocks",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="parent"><span id="a" style="display: inline-block">a</span> <span id="b" style="display: inline-block">b</span></div>`;
+ return () => fixture.querySelector("#a").after(Object.assign(document.createElement("span"), { textContent: "c", style: "display: inline-block" }), " ");
+ },
+ },
+ {
+ name: "remove an inline-block between two kept inline-blocks",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="parent"><span style="display: inline-block">a</span> <span id="middle" style="display: inline-block">m</span> <span style="display: inline-block">b</span></div>`;
+ return () => fixture.querySelector("#middle").remove();
+ },
+ },
+ ];
+
+ test(() => {
+ runLayoutTreeFullRebuildComparisonCases(cases);
+
+ // The block after an inline run keeps its box when an inline is inserted into the run before it.
+ const fixture = document.getElementById("fixture");
+ fixture.innerHTML = `<div id="parent">inline <span>run</span><div id="following">following block</div></div>`;
+ const following = fixture.querySelector("#following");
+ const [transition] = layoutBoxTransitions(
+ () => fixture.querySelector("span").after(Object.assign(document.createElement("i"), { textContent: "inserted" })),
+ [following]
+ ).transitions;
+ println(`following block preserved after an inline insertion: ${transition === "PRESERVED"}`);
+ println(`incremental tree matches full rebuild: ${internals.compareLayoutTreeWithFullRebuild().matches}`);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/marker-quote-order-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/marker-quote-order-mutations.html
new file mode 100644
index 00000000000..999242e6f27
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/marker-quote-order-mutations.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ #list { quotes: "<" ">" "<<" ">>" "<<<" ">>>" "<<<<" ">>>>"; }
+ .marker-open::marker { content: open-quote; }
+ .marker-close::marker { content: close-quote; }
+ .open::before { content: open-quote; }
+ .close::after { content: close-quote; }
+</style>
+<div id="fixture"></div>
+<script>
+ // The quotes of a list item's ::marker come before those of its ::before and children: changes to either keep the
+ // tree a full build makes.
+ test(() => {
+ const changes = [
+ ["open-quote in a marker", list => list.children[1].classList.add("marker-open")],
+ ["close-quote in a marker", list => list.children[1].classList.add("marker-close")],
+ ["open-quote in an item's ::before", list => list.children[0].classList.add("open")],
+ ["q appended to an item", list => list.children[1].append(Object.assign(document.createElement("q"), { textContent: "q" }))],
+ ["item inserted with a quoting marker", list => list.children[1].before(Object.assign(document.createElement("li"), { className: "marker-open open", textContent: "new" }))],
+ ["item with a quoting marker removed", list => list.children[0].remove()],
+ ];
+ for (const [name, change] of changes) {
+ fixture.innerHTML = '<ul id="list"><li class="marker-open"><q>a</q></li><li><span class="open close">b</span></li><li class="marker-close">c</li></ul><p class="open">after</p>';
+ const list = fixture.firstElementChild;
+ list.getBoundingClientRect();
+ change(list);
+ list.getBoundingClientRect();
+ println(`${name}: tree matches=${internals.compareLayoutTreeWithFullRebuild().matches}`);
+ }
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/media-element-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/media-element-mutations.html
new file mode 100644
index 00000000000..2dc12c526cd
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/media-element-mutations.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const mediaMutations = [
+ ["toggle controls", (media) => media.toggleAttribute("controls")],
+ ["add a light DOM child", (media) => media.insertAdjacentHTML("beforeend", "<div>fallback</div>")],
+ ["add light DOM text", (media) => media.append("text")],
+ ["hide the element", (media) => media.style.display = "none"],
+ ["make the element display contents", (media) => media.style.display = "contents"],
+ ["make the element a block", (media) => media.style.display = "block"],
+ ];
+
+ const cases = [];
+ for (const tag of ["video", "audio"]) {
+ for (const controls of [false, true]) {
+ for (const [name, mutate] of mediaMutations) {
+ cases.push({
+ name: `${tag}${controls ? " with controls" : ""}: ${name}`,
+ setup(fixture) {
+ fixture.innerHTML = `<div>a <${tag} id="media"${controls ? " controls" : ""}></${tag}> b</div>`;
+ return () => mutate(fixture.querySelector("#media"));
+ },
+ });
+ }
+ }
+ }
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/ol-attribute-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/ol-attribute-mutations.html
new file mode 100644
index 00000000000..10b9695c26f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/ol-attribute-mutations.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const listMarkup = `<ol id="list"><li>a</li><li id="second">b</li><li>c<ol id="nested"><li>c1</li><li>c2</li></ol></li><li>d</li></ol><ol id="after"><li>x</li></ol>`;
+
+ const listMutations = [
+ ["set start", (fixture) => fixture.querySelector("#list").setAttribute("start", "7")],
+ ["remove start", (fixture) => fixture.querySelector("#list").removeAttribute("start"), "start"],
+ ["set reversed", (fixture) => fixture.querySelector("#list").setAttribute("reversed", "")],
+ ["remove reversed", (fixture) => fixture.querySelector("#list").removeAttribute("reversed"), "reversed"],
+ ["set reversed on the nested list", (fixture) => fixture.querySelector("#nested").setAttribute("reversed", "")],
+ ["set li value", (fixture) => fixture.querySelector("#second").setAttribute("value", "20")],
+ ["remove li value", (fixture) => fixture.querySelector("#second").removeAttribute("value"), "value"],
+ ["change type", (fixture) => fixture.querySelector("#list").setAttribute("type", "A")],
+ ["insert an item into a reversed list", (fixture) => fixture.querySelector("#second").insertAdjacentHTML("beforebegin", "<li>new</li>"), "reversed"],
+ ["remove an item from a reversed list", (fixture) => fixture.querySelector("#second").remove(), "reversed"],
+ ["hide an item", (fixture) => fixture.querySelector("#second").style.display = "none"],
+ ["make an item a block", (fixture) => fixture.querySelector("#second").style.display = "block"],
+ ];
+
+ const cases = listMutations.map(([name, mutate, initialAttribute]) => ({
+ name,
+ setup(fixture) {
+ fixture.innerHTML = listMarkup;
+ const list = fixture.querySelector("#list");
+ if (initialAttribute === "start") list.setAttribute("start", "7");
+ if (initialAttribute === "reversed") list.setAttribute("reversed", "");
+ if (initialAttribute === "value") fixture.querySelector("#second").setAttribute("value", "20");
+ return () => mutate(fixture);
+ },
+ }));
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/out-of-flow-replaced-element-table-display-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/out-of-flow-replaced-element-table-display-mutations.html
new file mode 100644
index 00000000000..7c52ed6f7f4
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/out-of-flow-replaced-element-table-display-mutations.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ // Out-of-flow replaced elements of table displays, inserted into and moved out of the child lists of tables and
+ // blocks, whose table fixup must treat them as the block boxes they are.
+ const displays = ["table-row-group", "table-header-group", "table-column-group", "table-row", "table-cell", "table-caption"];
+ const cases = [];
+ for (const placement of ["float: left", "position: absolute"]) {
+ for (const display of displays) {
+ const canvas = `<canvas width="10" height="10" style="display: ${display}; ${placement}"></canvas>`;
+ for (const [parentName, parent] of [["table", `<div id="parent" style="display: table">text</div>`], ["block", `<div id="parent">text</div>`]]) {
+ cases.push({
+ name: `${display}, ${placement}: insert into ${parentName}`,
+ setup(fixture) {
+ fixture.innerHTML = parent;
+ return () => fixture.querySelector("#parent").insertAdjacentHTML("beforeend", canvas);
+ },
+ });
+ cases.push({
+ name: `${display}, ${placement}: make in flow in ${parentName}`,
+ setup(fixture) {
+ fixture.innerHTML = parent;
+ fixture.querySelector("#parent").insertAdjacentHTML("beforeend", canvas);
+ return () => {
+ const target = fixture.querySelector("canvas");
+ target.style.float = "none";
+ target.style.position = "static";
+ };
+ },
+ });
+ }
+ }
+ }
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/replaced-element-table-display-transitions.html b/Tests/LibWeb/Text/input/layout-tree-update/replaced-element-table-display-transitions.html
new file mode 100644
index 00000000000..f7e1161be49
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/replaced-element-table-display-transitions.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const tableDisplays = ["table", "inline-table", "table-row-group", "table-row", "table-cell", "table-caption", "table-column"];
+ const cases = [];
+ for (const tag of ["img", "canvas"]) {
+ for (const from of ["inline", ...tableDisplays]) {
+ for (const to of ["inline", "block", ...tableDisplays]) {
+ // NB: Each display is changed to and from inline, so that every display is both where a box comes from
+ // and where it goes.
+ if (from === to || (from !== "inline" && to !== "inline")) continue;
+ cases.push({
+ name: `${tag}: ${from} -> ${to}`,
+ setup(fixture) {
+ fixture.innerHTML = `<div>a <${tag} id="target" width="10" height="10" style="display: ${from}"${tag === "img" ? ' src="../../../Assets/120.png"' : ""}></${tag}> b</div>`;
+ return () => fixture.querySelector("#target").style.display = to;
+ },
+ });
+ }
+ }
+ }
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/resources/full-rebuild-comparison.js b/Tests/LibWeb/Text/input/layout-tree-update/resources/full-rebuild-comparison.js
index 363dfea545e..e83a504d3ec 100644
--- a/Tests/LibWeb/Text/input/layout-tree-update/resources/full-rebuild-comparison.js
+++ b/Tests/LibWeb/Text/input/layout-tree-update/resources/full-rebuild-comparison.js
@@ -2467,3 +2467,45 @@ function printFullUpdateOverLiveTreeComparison(name) {
println(` after: ${after[line]}`);
}
}
+
+// Runs `mutate` with the layout tree builds traced, and answers the work, as layoutTreeBuildWork() does, with
+// `transitions`: for each node of `nodes`, how its box fared, as layoutTreeBuildWork() answers it for elements: "PRESERVED", "RECREATED", "CREATED", "REMOVED" or "ABSENT". An element
+// without an id is given one first, as a created box is known by the id of its element. A text node has no name of its
+// own, so the box of one counts as recreated where the builds created more text boxes than there are text nodes in the
+// document that had no box before and have one now.
+function layoutBoxTransitions(mutate, nodes) {
+ const isElement = node => node.nodeType === Node.ELEMENT_NODE;
+ nodes.forEach((node, index) => {
+ if (isElement(node) && !node.id) node.id = `tracked-box-${index}`;
+ });
+ const hasBox = node => internals.dumpLayoutTree(node) !== "(no layout node)";
+ const tracksText = nodes.some(node => !isElement(node));
+ const textNodes = () => {
+ const walker = document.createTreeWalker(document, NodeFilter.SHOW_TEXT);
+ const texts = [];
+ while (walker.nextNode()) texts.push(walker.currentNode);
+ return texts;
+ };
+ internals.updateLayoutForTesting();
+ const textsWithBoxes = tracksText ? new Set(textNodes().filter(hasBox)) : new Set();
+ const hadBox = nodes.map(hasBox);
+ const elements = nodes.filter(isElement);
+ const work = layoutTreeBuildWork(mutate, { tracked: elements });
+ const elementTransitions = work.transitions();
+ let textBoxesRecreated = work.rebuiltWholeTree();
+ if (tracksText && !textBoxesRecreated) {
+ const textsGainingBoxes = textNodes().filter(text => !textsWithBoxes.has(text) && hasBox(text)).length;
+ const createdTextBoxes = work.events.filter(
+ event => event.event === "create" && event.box.startsWith("TextNode<#text>")
+ ).length;
+ textBoxesRecreated = createdTextBoxes > textsGainingBoxes;
+ }
+ const transitions = nodes.map((node, index) => {
+ if (isElement(node)) return elementTransitions[elements.indexOf(node)];
+ const has = hasBox(node);
+ if (!hadBox[index]) return has ? "CREATED" : "ABSENT";
+ if (!has) return "REMOVED";
+ return textBoxesRecreated ? "RECREATED" : "PRESERVED";
+ });
+ return { work, transitions };
+}
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/resources/layout-summaries.js b/Tests/LibWeb/Text/input/layout-tree-update/resources/layout-summaries.js
new file mode 100644
index 00000000000..970f65382cf
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/resources/layout-summaries.js
@@ -0,0 +1,77 @@
+// Helpers that summarize layout subtrees and compare the incrementally updated layout tree with a full rebuild.
+
+function repeatMarkup(count, makeMarkup) {
+ let markup = "";
+ for (let i = 0; i < count; ++i) markup += makeMarkup(i);
+ return markup;
+}
+
+// Summarizes the layout subtree of a node as box counts per kind plus the text of all line box fragments in tree
+// order, which shows generated text such as counter values and quotes.
+function summarizeLayoutSubtree(node) {
+ const kinds = new Map();
+ const texts = [];
+ let boxes = 0;
+ for (const line of internals.dumpLayoutTree(node).split("\n")) {
+ const trimmed = line.trim();
+ if (trimmed.startsWith('"')) {
+ texts.push(trimmed.slice(1, -1));
+ continue;
+ }
+ const match = trimmed.match(/^(\w+) <([^>]*)>/);
+ if (!match) continue;
+ const kind = match[2] === "(anonymous)" ? `${match[1]}(anonymous)` : match[1];
+ kinds.set(kind, (kinds.get(kind) ?? 0) + 1);
+ ++boxes;
+ }
+ const kindList = [...kinds.entries()]
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
+ .map(([kind, count]) => `${kind}=${count}`)
+ .join(" ");
+ return { boxes, kinds: kindList, text: texts.join(" ") };
+}
+
+// The text of all line box fragments below the box of each child of `parent`, in tree order, from one dump of the
+// subtree of `parent`, whose box has one box per child of `parent` as its children, besides anonymous ones such as
+// those of its pseudo-elements, whose text is left out.
+function childLayoutTexts(parent) {
+ const texts = [];
+ let inChild = false;
+ for (const line of internals.dumpLayoutTree(parent).split("\n")) {
+ const trimmed = line.trim();
+ if (/^ \w+ </.test(line)) {
+ inChild = !line.includes("<(anonymous)>");
+ if (inChild) texts.push([]);
+ } else if (inChild && trimmed.startsWith('"')) texts[texts.length - 1].push(trimmed.slice(1, -1));
+ }
+ if (texts.length !== parent.children.length)
+ throw new Error(`${texts.length} child boxes for ${parent.children.length} children`);
+ return texts.map(childTexts => childTexts.join(" "));
+}
+
+function printLayoutSummaries(nodes) {
+ let total = 0;
+ for (const node of nodes) {
+ const summary = summarizeLayoutSubtree(node);
+ total += summary.boxes;
+ println(`${node.id || node.nodeName}: ${summary.boxes} boxes: ${summary.kinds}`);
+ if (summary.text) println(` text: ${summary.text}`);
+ }
+ println(`total: ${total} boxes`);
+}
+
+function printFullRebuildComparison(name) {
+ document.body.offsetHeight;
+ const comparison = internals.compareLayoutTreeWithFullRebuild();
+ println(`${comparison.matches ? "PASS" : "FAIL"}: ${name}`);
+}
+
+// Applies each mutation in turn to the same document and compares the incrementally updated tree with a full
+// rebuild after each one.
+function runSequentialFullRebuildComparisons(mutations) {
+ printFullRebuildComparison("first build");
+ for (const [name, mutate] of mutations) {
+ mutate();
+ printFullRebuildComparison(name);
+ }
+}
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/restyle-dropping-box-flags.html b/Tests/LibWeb/Text/input/layout-tree-update/restyle-dropping-box-flags.html
new file mode 100644
index 00000000000..3da9cc49d82
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/restyle-dropping-box-flags.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ // A style change of an element whose box a fresh build makes of the same kind takes away something its box was
+ // flagged for: being a containing block, an editing host, a scroll container, an item container.
+ const markup = `<div id="outer" style="width: 300px">
+ <div id="target" style="position: relative; transform: translateX(5px); overflow: hidden; height: 50px; margin: 10px">
+ target <span id="empty"></span>
+ <div style="position: absolute; left: 20px; top: 20px">absolute</div>
+ <div style="position: fixed; left: 30px; top: 30px">fixed</div>
+ </div>
+ <p>after</p>
+ </div>`;
+
+ const changes = [
+ ["stop being a containing block for absolute boxes", (target) => (target.style.position = "static")],
+ ["stop being a containing block for fixed boxes", (target) => (target.style.transform = "none")],
+ ["stop being a scroll container", (target) => (target.style.overflow = "visible")],
+ ["stop being any of these", (target) => {
+ target.style.position = "static";
+ target.style.transform = "none";
+ target.style.overflow = "visible";
+ }],
+ ["stop being an editing host", (target) => target.removeAttribute("contenteditable"), (target) => target.setAttribute("contenteditable", "")],
+ ["stop being a flex container", (target) => (target.style.display = "block"), (target) => (target.style.display = "flex")],
+ ["become a containing block again", (target) => (target.style.position = "relative"), (target) => (target.style.position = "static")],
+ ];
+
+ const cases = [];
+ for (const [name, change, prepare] of changes) {
+ for (const appends of [false, true]) {
+ cases.push({
+ name: appends ? `${name}, append a child` : name,
+ setup(fixture) {
+ fixture.innerHTML = markup;
+ const target = fixture.querySelector("#target");
+ if (prepare) prepare(target);
+ return () => {
+ if (appends) target.append(Object.assign(document.createElement("div"), { textContent: "appended" }));
+ change(target);
+ };
+ },
+ });
+ }
+ }
+
+ test(() => {
+ runLayoutTreeFullRebuildComparisonCases(cases);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/restyle-with-child-list-change-of-same-element.html b/Tests/LibWeb/Text/input/layout-tree-update/restyle-with-child-list-change-of-same-element.html
new file mode 100644
index 00000000000..1f6be50e920
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/restyle-with-child-list-change-of-same-element.html
@@ -0,0 +1,83 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ // An element gains or loses a child, and in the same update its style changes what it does to the counters, the
+ // quote depth or the list item count that the boxes after it read. The style may also change in an earlier style
+ // update that the same layout tree update follows.
+ const style = `<style>
+ .list { counter-reset: c; quotes: "<" ">" "[" "]"; }
+ .list > p { margin: 0; }
+ .list > p::before { content: counter(c) " " open-quote; }
+ .list > p::after { content: close-quote; }
+ .increment { counter-increment: c 5; }
+ .reset { counter-reset: c 10; }
+ .set { counter-set: c 20; }
+ .open::before { content: open-quote; }
+ .no-quote::before { content: "x"; }
+ ol > li::marker { content: counter(list-item) ". "; }
+ .block { display: block; }
+ .list-item { display: list-item; }
+ </style>`;
+
+ const markup = `<div class="list"><p id="target">target <span>child</span></p><p>a</p><p>b</p></div>
+ <ol><li>one</li><li id="item">two <span>child</span></li><li>three</li><li>four</li></ol>`;
+
+ const changes = [
+ ["increment a counter", "#target", "increment"],
+ ["reset a counter", "#target", "reset"],
+ ["set a counter", "#target", "set"],
+ ["open a quote in the ::before", "#target", "open"],
+ ["drop the quote of the ::before", "#target", "no-quote"],
+ ["stop being a list item", "#item", "block"],
+ ["become a list item", "#target", "list-item"],
+ ];
+
+ const childListChanges = [
+ ["append a child", (element) => element.append(Object.assign(document.createElement("b"), { textContent: "appended" }))],
+ ["remove a child", (element) => element.querySelector("span").remove()],
+ ];
+
+ const earlierStyleChanges = [
+ ["a color change", (element) => (element.style.color = "green")],
+ ["a change of position", (element) => (element.style.position = "relative")],
+ ["a change of float", (element) => (element.style.float = "left")],
+ ["a change of overflow", (element) => (element.style.overflow = "hidden")],
+ ];
+
+ const cases = [];
+ for (const [changeName, selector, className] of changes) {
+ for (const [childListChangeName, changeChildList] of childListChanges) {
+ cases.push({
+ name: `${changeName}, ${childListChangeName}`,
+ setup(fixture) {
+ fixture.innerHTML = style + markup;
+ return () => {
+ const element = fixture.querySelector(selector);
+ changeChildList(element);
+ element.classList.add(className);
+ };
+ },
+ });
+ }
+ for (const [earlierName, earlierChange] of earlierStyleChanges) {
+ cases.push({
+ name: `${changeName} after ${earlierName} in an earlier style update`,
+ setup(fixture) {
+ fixture.innerHTML = style + markup;
+ return () => {
+ const element = fixture.querySelector(selector);
+ earlierChange(element);
+ getComputedStyle(element).color;
+ element.classList.add(className);
+ };
+ },
+ });
+ }
+ }
+
+ test(() => {
+ runLayoutTreeFullRebuildComparisonCases(cases);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/scroll-container-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/scroll-container-mutations.html
new file mode 100644
index 00000000000..c91dbca7774
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/scroll-container-mutations.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const scrollMutations = [
+ ["make a block ::before scrollable", (fixture) => fixture.querySelector("#rule").textContent = "#target::before { content: 'before'; display: block; overflow: auto; height: 10px; }"],
+ ["make a scrollable ::before visible", (fixture) => fixture.querySelector("#rule").textContent = "#target::before { content: 'before'; display: block; }", "#target::before { content: 'before'; display: block; overflow: auto; height: 10px; }"],
+ ["make a list scrollable", (fixture) => fixture.querySelector("ul").style.overflow = "auto"],
+ ["make a list item scrollable", (fixture) => fixture.querySelector("li").style.overflow = "scroll"],
+ ["make an inline scrollable", (fixture) => fixture.querySelector("span").style.overflow = "auto"],
+ ["make the target clip", (fixture) => fixture.querySelector("#target").style.overflow = "clip"],
+ ];
+
+ const cases = scrollMutations.map(([name, mutate, initialRule]) => ({
+ name,
+ setup(fixture) {
+ fixture.innerHTML = `<style id="rule">${initialRule ?? ""}</style><div id="target">text <span>inline</span></div><ul><li>a</li><li>b</li></ul>`;
+ return () => mutate(fixture);
+ },
+ }));
+
+ for (const [element, property] of [["html", "overflow"], ["body", "overflow"], ["html", "overflowX"], ["body", "overflowY"]]) {
+ for (const value of ["hidden", "scroll", "clip"]) {
+ cases.push({
+ name: `set ${property} ${value} on ${element}`,
+ setup() {
+ return () => (element === "html" ? document.documentElement : document.body).style[property] = value;
+ },
+ cleanup() {
+ document.documentElement.removeAttribute("style");
+ document.body.removeAttribute("style");
+ },
+ });
+ }
+ }
+ cases.push({
+ name: "move overflow from body to html",
+ setup() {
+ document.body.style.overflow = "hidden";
+ return () => {
+ document.body.style.overflow = "";
+ document.documentElement.style.overflow = "scroll";
+ };
+ },
+ cleanup() {
+ document.documentElement.removeAttribute("style");
+ document.body.removeAttribute("style");
+ },
+ });
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/svg-resource-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/svg-resource-mutations.html
new file mode 100644
index 00000000000..590b25f241e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/svg-resource-mutations.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const svgResourceMarkup = `<svg width="200" height="100">
+ <defs>
+ <mask id="m1"><rect width="40" height="40" fill="white"/></mask>
+ <mask id="m2"><circle cx="20" cy="20" r="20" fill="white"/></mask>
+ <clipPath id="c1"><rect width="30" height="30"/></clipPath>
+ <clipPath id="c2"><circle cx="15" cy="15" r="15"/></clipPath>
+ <pattern id="p1" width="10" height="10" patternUnits="userSpaceOnUse"><rect width="5" height="5"/></pattern>
+ <pattern id="p2" href="#p1"/>
+ </defs>
+ <rect id="first" width="50" height="50" mask="url(#m1)" clip-path="url(#c1)" fill="url(#p1)"/>
+ <g id="group"><rect id="second" x="60" width="50" height="50"/></g>
+ </svg>`;
+
+ const svgResourceMutations = [
+ ["point mask at another mask", (fixture) => fixture.querySelector("#first").setAttribute("mask", "url(#m2)")],
+ ["point clip-path at another clipPath", (fixture) => fixture.querySelector("#first").setAttribute("clip-path", "url(#c2)")],
+ ["point fill at a pattern with href", (fixture) => fixture.querySelector("#first").setAttribute("fill", "url(#p2)")],
+ ["set clip-path from CSS", (fixture) => fixture.querySelector("#first").style.clipPath = "url(#c2)"],
+ ["remove the mask attribute", (fixture) => fixture.querySelector("#first").removeAttribute("mask")],
+ ["remove the mask element", (fixture) => fixture.querySelector("#m1").remove()],
+ ["remove the clipPath element", (fixture) => fixture.querySelector("#c1").remove()],
+ ["remove the pattern element", (fixture) => fixture.querySelector("#p1").remove()],
+ ["append a child to the mask", (fixture) => fixture.querySelector("#m1").insertAdjacentHTML("beforeend", `<circle r="5" fill="black"/>`)],
+ ["remove the mask content", (fixture) => fixture.querySelector("#m1").firstElementChild.remove()],
+ ["add a second referrer", (fixture) => fixture.querySelector("#second").setAttribute("mask", "url(#m1)")],
+ ["add a referrer on a group", (fixture) => fixture.querySelector("#group").setAttribute("clip-path", "url(#c1)")],
+ ["hide the referrer", (fixture) => fixture.querySelector("#first").style.display = "none"],
+ ["insert a referrer before the existing one", (fixture) => fixture.querySelector("#first").insertAdjacentHTML("beforebegin", `<rect id="new" width="10" height="10" mask="url(#m1)" fill="url(#p2)"/>`)],
+ ["make the mask reference itself", (fixture) => fixture.querySelector("#m1").firstElementChild.setAttribute("mask", "url(#m1)")],
+ ["move the mask element to the end", (fixture) => fixture.querySelector("svg").append(fixture.querySelector("#m1"))],
+ ];
+
+ const cases = svgResourceMutations.map(([name, mutate]) => ({
+ name,
+ setup(fixture) {
+ fixture.innerHTML = svgResourceMarkup;
+ return () => mutate(fixture);
+ },
+ }));
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/svg-switch-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/svg-switch-mutations.html
new file mode 100644
index 00000000000..ba924fa465d
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/svg-switch-mutations.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const switchMarkup = `<svg width="100" height="100"><switch id="switch">
+ <rect id="unsupported" systemLanguage="xx-unknown" width="10" height="10"/>
+ <circle id="chosen" r="5"/>
+ <rect id="later" width="20" height="20"/>
+ </switch></svg>`;
+
+ const switchMutations = [
+ ["insert an eligible child before the chosen one", (fixture) => fixture.querySelector("#chosen").insertAdjacentHTML("beforebegin", `<ellipse rx="5" ry="3"/>`)],
+ ["insert an eligible child first", (fixture) => fixture.querySelector("#switch").insertAdjacentHTML("afterbegin", `<ellipse rx="5" ry="3"/>`)],
+ ["remove the chosen child", (fixture) => fixture.querySelector("#chosen").remove()],
+ ["hide the chosen child", (fixture) => fixture.querySelector("#chosen").style.display = "none"],
+ ["make the unsupported child supported", (fixture) => fixture.querySelector("#unsupported").removeAttribute("systemLanguage")],
+ ["append a child to the chosen child", (fixture) => fixture.querySelector("#chosen").replaceWith(Object.assign(document.createElementNS("http://www.w3.org/2000/svg", "g"), { innerHTML: `<rect width="5" height="5"/>` }))],
+ ["insert an HTML element first", (fixture) => fixture.querySelector("#switch").prepend(document.createElement("div"))],
+ ["hide the switch", (fixture) => fixture.querySelector("#switch").style.display = "none"],
+ ];
+
+ const cases = switchMutations.map(([name, mutate]) => ({
+ name,
+ setup(fixture) {
+ fixture.innerHTML = switchMarkup;
+ return () => mutate(fixture);
+ },
+ }));
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/svg-text-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/svg-text-mutations.html
new file mode 100644
index 00000000000..63ee61a6557
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/svg-text-mutations.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const svgTextMarkup = `<svg width="300" height="100">
+ <defs><path id="path" d="M 10 80 L 290 80"/></defs>
+ <text id="text" x="10" y="20">Hello <tspan id="tspan">tspan</tspan> tail</text>
+ <text id="path-text"><textPath id="text-path" href="#path">On a path</textPath></text>
+ </svg>`;
+
+ const svgTextMutations = [
+ ["insert a tspan", (fixture) => fixture.querySelector("#tspan").insertAdjacentHTML("afterend", `<tspan>new</tspan>`)],
+ ["remove a tspan", (fixture) => fixture.querySelector("#tspan").remove()],
+ ["insert whitespace", (fixture) => fixture.querySelector("#tspan").before(" ")],
+ ["remove all text", (fixture) => fixture.querySelector("#text").textContent = ""],
+ ["change text data", (fixture) => fixture.querySelector("#text").firstChild.data = "Changed "],
+ ["hide a tspan", (fixture) => fixture.querySelector("#tspan").style.display = "none"],
+ ["insert a tspan into a textPath", (fixture) => fixture.querySelector("#text-path").insertAdjacentHTML("beforeend", `<tspan> more</tspan>`)],
+ ["remove the textPath", (fixture) => fixture.querySelector("#text-path").remove()],
+ ];
+
+ const cases = svgTextMutations.map(([name, mutate]) => ({
+ name,
+ setup(fixture) {
+ fixture.innerHTML = svgTextMarkup;
+ return () => mutate(fixture);
+ },
+ }));
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/table-column-children-not-counted.html b/Tests/LibWeb/Text/input/layout-tree-update/table-column-children-not-counted.html
new file mode 100644
index 00000000000..475855b7aed
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/table-column-children-not-counted.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<style>
+ .table { display: table; }
+ .column-group { display: table-column-group; }
+ .column { display: table-column; }
+ .row { display: table-row; }
+ .cell { display: table-cell; }
+ #root { counter-reset: c; }
+ .count { counter-increment: c; }
+ .count::before { content: "[" counter(c) "]"; }
+ #show::before { content: "c=" counter(c); }
+</style>
+<div id="root">
+ <div class="table">
+ <div class="column-group">
+ <div class="count">child of a column group</div>
+ <div class="column count"><div class="count">child of a column in a group</div></div>
+ text in a column group
+ </div>
+ <div class="column"><span class="count">child of a column</span></div>
+ <div class="row"><div class="cell count">cell</div></div>
+ </div>
+ <div id="show"></div>
+</div>
+<script src="../include.js"></script>
+<script src="resources/layout-summaries.js"></script>
+<script>
+ // https://drafts.csswg.org/css-tables-3/#fixup-algorithm
+ // The children of a table-column, and the children of a table-column-group which are not a table-column, are
+ // discarded as if they were display:none, so they set no counter.
+ test(() => {
+ printLayoutSummaries([document.getElementById("root")]);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/table-whitespace-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/table-whitespace-mutations.html
new file mode 100644
index 00000000000..ff736172558
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/table-whitespace-mutations.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const tableStyle = `<style>.t { display: table; } .r { display: table-row; } .c { display: table-cell; }</style>`;
+ const tableShapes = [
+ ["semantic table", `<table id="table"><tbody id="group"><tr id="row"><td id="cell">a</td><td>b</td></tr><tr><td>c</td></tr></tbody></table>`],
+ ["display table", `<div class="t" id="table"><div class="r" id="row"><div class="c" id="cell">a</div><div class="c">b</div></div><div class="r"><div class="c">c</div></div></div>`],
+ ["loose cells", `<div id="table"><div class="c" id="cell">a</div><div class="c">b</div></div>`],
+ ];
+ const whitespaceMutations = [
+ ["insert whitespace between rows", (fixture) => fixture.querySelector("#row").after(" ")],
+ ["insert whitespace before the first row", (fixture) => fixture.querySelector("#row").before(" ")],
+ ["insert whitespace between cells", (fixture) => fixture.querySelector("#cell").after(" ")],
+ ["insert whitespace at the start of the table", (fixture) => fixture.querySelector("#table").prepend(" ")],
+ ["insert text between cells", (fixture) => fixture.querySelector("#cell").after("text")],
+ ["change cell text to whitespace", (fixture) => fixture.querySelector("#cell").firstChild.data = " "],
+ ["change inter-cell text to whitespace", (fixture) => { const text = document.createTextNode("text"); fixture.querySelector("#cell").after(text); document.body.offsetHeight; text.data = " "; }],
+ ["change inter-cell whitespace to text", (fixture) => { const text = document.createTextNode(" "); fixture.querySelector("#cell").after(text); document.body.offsetHeight; text.data = "text"; }],
+ ["remove the whitespace between cells", (fixture) => { const text = document.createTextNode(" "); fixture.querySelector("#cell").after(text); document.body.offsetHeight; text.remove(); }],
+ ];
+
+ const cases = [];
+ for (const [shapeName, markup] of tableShapes) {
+ for (const [name, mutate] of whitespaceMutations) {
+ if (shapeName === "loose cells" && name.includes("row")) continue;
+ cases.push({
+ name: `${shapeName}: ${name}`,
+ setup(fixture) {
+ fixture.innerHTML = tableStyle + markup;
+ return () => mutate(fixture);
+ },
+ });
+ }
+ }
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/top-layer-member-counters-at-dom-position.html b/Tests/LibWeb/Text/input/layout-tree-update/top-layer-member-counters-at-dom-position.html
new file mode 100644
index 00000000000..b62d10deb72
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/top-layer-member-counters-at-dom-position.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<style>
+ #root { counter-reset: c 10; }
+ p { counter-increment: c; margin: 0; }
+ p::before { content: counter(c) " "; }
+ [popover] { margin: 0; padding: 0; border: none; }
+ #with-backdrop::backdrop { display: block; }
+ .reset { counter-reset: c 500; }
+</style>
+<div id="root"><p>a</p><div id="plain" popover="manual"><p>in plain</p></div><p>b</p><section class="reset"><p>c</p><div id="with-backdrop" popover="manual"><p>in backdrop member</p></div><p>d</p></section><p>e</p></div>
+<script src="../include.js"></script>
+<script src="resources/layout-summaries.js"></script>
+<script>
+ // Top layer members whose content reads a counter of the document, one with a ::backdrop and one without.
+ test(() => {
+ document.getElementById("plain").showPopover();
+ document.getElementById("with-backdrop").showPopover();
+ const root = document.getElementById("root");
+ printLayoutSummaries([root, document.getElementById("plain"), document.getElementById("with-backdrop")]);
+ runSequentialFullRebuildComparisons([
+ // FIXME: A change before the place of a top layer member in the document does not reach the counter values in
+ // the member incrementally.
+ ["insert a paragraph before the first member", () => root.firstElementChild.insertAdjacentHTML("afterend", "<p>new</p>")],
+ ]);
+ printLayoutSummaries([root, document.getElementById("plain"), document.getElementById("with-backdrop")]);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/top-layer-ordering-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/top-layer-ordering-mutations.html
new file mode 100644
index 00000000000..0641eef6bf2
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/top-layer-ordering-mutations.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const topLayerMarkup = `<style>
+ dialog, [popover] { margin: 0; padding: 0; border: none; }
+ </style>
+ <div id="a" popover="manual">a</div>
+ <div id="container"><div id="b" popover="manual">b</div></div>
+ <div id="c" popover="manual">c</div>
+ <dialog id="d">d</dialog>
+ <p id="content">content</p>`;
+
+ function openAll(fixture) {
+ for (const id of ["a", "b", "c"])
+ fixture.querySelector(`#${id}`).showPopover();
+ }
+
+ const topLayerMutations = [
+ ["re-show the first member", (fixture) => { const a = fixture.querySelector("#a"); a.hidePopover(); a.showPopover(); }],
+ ["close the middle member", (fixture) => fixture.querySelector("#b").hidePopover()],
+ ["move an open member in the DOM", (fixture) => fixture.querySelector("#content").append(fixture.querySelector("#b"))],
+ ["remove an open member", (fixture) => fixture.querySelector("#b").remove()],
+ ["remove the parent of an open member", (fixture) => fixture.querySelector("#container").remove()],
+ ["hide the parent of an open member", (fixture) => fixture.querySelector("#container").style.display = "none"],
+ ["open a modal dialog over the members", (fixture) => fixture.querySelector("#d").showModal()],
+ ["insert content before the members", (fixture) => fixture.querySelector("#a").insertAdjacentHTML("beforebegin", "<p>inserted</p>")],
+ ["change the content of an open member", (fixture) => fixture.querySelector("#c").textContent = "changed"],
+ ];
+
+ const cases = topLayerMutations.map(([name, mutate]) => ({
+ name,
+ setup(fixture) {
+ fixture.innerHTML = topLayerMarkup;
+ openAll(fixture);
+ return () => mutate(fixture);
+ },
+ cleanup() {
+ for (const element of document.querySelectorAll(":popover-open"))
+ element.hidePopover();
+ for (const element of document.querySelectorAll("dialog[open]"))
+ element.close();
+ },
+ }));
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/unit-driver-sources.html b/Tests/LibWeb/Text/input/layout-tree-update/unit-driver-sources.html
new file mode 100644
index 00000000000..bd04a538951
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/unit-driver-sources.html
@@ -0,0 +1,166 @@
+<!DOCTYPE html>
+<style>
+ dialog, [popover] { margin: 0; padding: 0; border: none; }
+ dialog::backdrop { background: rgba(0, 0, 0, 0.1); }
+ .hidden { display: none; }
+</style>
+<div id="fixture"></div>
+<script src="../include.js"></script>
+<script src="../work-test.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<script>
+ // Each case changes what a layout tree build finds from its marks alone: the top layer, whose boxes are children of
+ // the viewport, the content of SVG resources, whose boxes hang below the boxes that reference them, nodes that have
+ // no box to lay them out in, and a full update together with a change of the tree.
+ function topLayerCase(name, markup, mutate) {
+ return {
+ name,
+ setup(fixture) {
+ fixture.innerHTML = markup;
+ fixture.querySelectorAll("[data-modal]").forEach(dialog => dialog.showModal());
+ fixture.querySelectorAll("[data-show]").forEach(popover => popover.showPopover());
+ return () => mutate(fixture);
+ },
+ cleanup() {
+ document.querySelectorAll(":modal").forEach(dialog => dialog.close());
+ document.querySelectorAll(":popover-open").forEach(popover => popover.hidePopover());
+ },
+ };
+ }
+
+ const topLayerMarkup = `<p id="before">before</p><dialog id="dialog">dialog <b>bold</b></dialog>
+ <div id="a" popover="manual">popover a</div><div id="b" popover="manual">popover <i>b</i></div><p>after</p>`;
+
+ const cases = [
+ topLayerCase("open a modal dialog", topLayerMarkup, fixture => fixture.querySelector("#dialog").showModal()),
+ topLayerCase("show two popovers", topLayerMarkup, fixture => {
+ fixture.querySelector("#a").showPopover();
+ fixture.querySelector("#b").showPopover();
+ }),
+ topLayerCase("close the first of three members", topLayerMarkup.replace('id="dialog"', 'id="dialog" data-modal')
+ .replace('id="a"', 'id="a" data-show').replace('id="b"', 'id="b" data-show'),
+ fixture => fixture.querySelector("#dialog").close()),
+ topLayerCase("hide and show a member again, which moves it last", topLayerMarkup.replace('id="a"', 'id="a" data-show')
+ .replace('id="b"', 'id="b" data-show'), fixture => {
+ fixture.querySelector("#a").hidePopover();
+ fixture.querySelector("#a").showPopover();
+ }),
+ topLayerCase("change the display of a member", topLayerMarkup.replace('id="dialog"', 'id="dialog" data-modal'),
+ fixture => fixture.querySelector("#dialog").style.display = "flex"),
+ topLayerCase("make a member display: contents", topLayerMarkup.replace('id="a"', 'id="a" data-show'),
+ fixture => fixture.querySelector("#a").style.display = "contents"),
+ topLayerCase("hide the parent of a member", `<div id="parent"><div id="a" popover="manual" data-show>a</div></div>
+ <div id="b" popover="manual" data-show>b</div>`, fixture => fixture.querySelector("#parent").className = "hidden"),
+ topLayerCase("show the parent of a member again", `<div id="parent" class="hidden"><div id="a" popover="manual" data-show>a</div></div>
+ <div id="b" popover="manual" data-show>b</div>`, fixture => fixture.querySelector("#parent").className = ""),
+ topLayerCase("insert into a member", topLayerMarkup.replace('id="dialog"', 'id="dialog" data-modal'),
+ fixture => fixture.querySelector("#dialog").insertAdjacentHTML("beforeend", "<div>inserted <span>block</span></div>")),
+ topLayerCase("remove a member from the document", topLayerMarkup.replace('id="a"', 'id="a" data-show')
+ .replace('id="b"', 'id="b" data-show'), fixture => fixture.querySelector("#a").remove()),
+ {
+ name: "change the content of a mask",
+ setup(fixture) {
+ fixture.innerHTML = `<svg width="40" height="40"><defs><mask id="mask"><rect id="masked" width="20" height="20" fill="white"/></mask></defs>
+ <rect width="40" height="40" mask="url(#mask)"/><rect width="10" height="10" mask="url(#mask)"/></svg>`;
+ return () => fixture.querySelector("#masked").setAttribute("width", "30");
+ },
+ },
+ {
+ name: "insert into a clip path",
+ setup(fixture) {
+ fixture.innerHTML = `<svg width="40" height="40"><defs><clipPath id="clip"><rect width="20" height="20"/></clipPath></defs>
+ <rect width="40" height="40" clip-path="url(#clip)"/></svg>`;
+ return () => fixture.querySelector("#clip").insertAdjacentHTML("beforeend", "<circle cx='30' cy='30' r='5'/>");
+ },
+ },
+ {
+ name: "remove the content of a pattern",
+ setup(fixture) {
+ fixture.innerHTML = `<svg width="40" height="40"><defs><pattern id="pattern" width="10" height="10" patternUnits="userSpaceOnUse">
+ <rect id="tile" width="5" height="5" fill="red"/><rect width="2" height="2" fill="blue"/></pattern></defs>
+ <rect width="40" height="40" fill="url(#pattern)"/></svg>`;
+ return () => fixture.querySelector("#tile").remove();
+ },
+ },
+ {
+ name: "hide the content of a mask",
+ setup(fixture) {
+ fixture.innerHTML = `<svg width="40" height="40"><defs><mask id="mask"><g id="group"><rect width="20" height="20" fill="white"/></g></mask></defs>
+ <rect width="40" height="40" mask="url(#mask)"/></svg>`;
+ return () => fixture.querySelector("#group").style.display = "none";
+ },
+ },
+ {
+ name: "change an element inside a hidden subtree",
+ setup(fixture) {
+ fixture.innerHTML = `<div class="hidden"><p id="inside">inside <span>text</span></p></div><p id="sibling">sibling</p>`;
+ return () => {
+ fixture.querySelector("#inside").style.display = "flex";
+ fixture.querySelector("#inside").append(document.createElement("div"));
+ };
+ },
+ },
+ {
+ name: "insert into a hidden subtree, then show it",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="hidden" class="hidden"><p>inside</p></div><p>sibling</p>`;
+ return () => {
+ const hidden = fixture.querySelector("#hidden");
+ hidden.insertAdjacentHTML("beforeend", "<div>inserted <b>while hidden</b></div>");
+ hidden.offsetHeight;
+ hidden.className = "";
+ };
+ },
+ },
+ {
+ name: "change the display of the document element",
+ setup(fixture) {
+ fixture.innerHTML = `<p>a</p><p>b</p>`;
+ return () => document.documentElement.style.display = "flex";
+ },
+ cleanup() {
+ document.documentElement.style.display = "";
+ },
+ },
+ {
+ name: "change the document element and a top layer member at once",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="a" popover="manual">a</div>`;
+ fixture.querySelector("#a").showPopover();
+ return () => {
+ document.documentElement.style.display = "grid";
+ fixture.querySelector("#a").style.display = "inline-block";
+ };
+ },
+ cleanup() {
+ document.documentElement.style.display = "";
+ document.querySelectorAll(":popover-open").forEach(popover => popover.hidePopover());
+ },
+ },
+ {
+ name: "request a full update and change the tree in the same build",
+ setup(fixture) {
+ fixture.innerHTML = `<p id="first">first <b>bold</b></p><dialog id="dialog">dialog</dialog><p>last</p>`;
+ fixture.querySelector("#dialog").showModal();
+ return () => {
+ internals.requestFullLayoutTreeUpdate();
+ fixture.querySelector("#first").insertAdjacentHTML("afterend", "<div>inserted</div>");
+ fixture.querySelector("#dialog").close();
+ };
+ },
+ },
+ ];
+
+ test(() => {
+ runLayoutTreeFullRebuildComparisonCases(cases);
+
+ // A clean sibling of a box whose top layer state changes keeps its box.
+ const fixture = document.getElementById("fixture");
+ fixture.innerHTML = topLayerMarkup;
+ const before = fixture.querySelector("#before");
+ const [entered] = layoutBoxTransitions(() => fixture.querySelector("#a").showPopover(), [before]).transitions;
+ println(`clean sibling of a member that entered the top layer: ${entered}`);
+ const [left] = layoutBoxTransitions(() => fixture.querySelector("#a").hidePopover(), [before]).transitions;
+ println(`clean sibling of a member that left the top layer: ${left}`);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/whitespace-flat-tree-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/whitespace-flat-tree-mutations.html
new file mode 100644
index 00000000000..80fbb183355
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/whitespace-flat-tree-mutations.html
@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ function attachSlottingShadow(host, shadowMarkup) {
+ host.attachShadow({ mode: "open" }).innerHTML = shadowMarkup;
+ return host.shadowRoot;
+ }
+
+ const cases = [
+ {
+ name: "insert a slotted inline before whitespace",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="host"><p id="block">a</p> <b>x</b></div>`;
+ attachSlottingShadow(fixture.querySelector("#host"), "<slot></slot>");
+ return () => fixture.querySelector("#block").after(Object.assign(document.createElement("span"), { textContent: "new" }));
+ },
+ },
+ {
+ name: "remove a slotted inline before whitespace",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="host"><p>a</p><span id="inline">a</span> <b>x</b></div>`;
+ attachSlottingShadow(fixture.querySelector("#host"), "<slot></slot>");
+ return () => fixture.querySelector("#inline").remove();
+ },
+ },
+ {
+ name: "reassign a named slot before whitespace",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="host"><span id="slotted" slot="first">a</span><b slot="second">x</b></div>`;
+ attachSlottingShadow(fixture.querySelector("#host"), `<p>start</p><slot name="first"></slot> <slot name="second"></slot>`);
+ return () => fixture.querySelector("#slotted").slot = "none";
+ },
+ },
+ {
+ name: "assign content to an empty slot before whitespace",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="host"><b slot="second">x</b></div>`;
+ attachSlottingShadow(fixture.querySelector("#host"), `<p>start</p><slot name="first"></slot> <slot name="second"></slot>`);
+ return () => fixture.querySelector("#host").prepend(Object.assign(document.createElement("span"), { textContent: "a", slot: "first" }));
+ },
+ },
+ {
+ name: "replace slot fallback with assigned content before whitespace",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="host"></div>`;
+ attachSlottingShadow(fixture.querySelector("#host"), `<p>start</p><slot><span>fallback</span></slot> <b>x</b>`);
+ return () => fixture.querySelector("#host").append(Object.assign(document.createElement("div"), { textContent: "block" }));
+ },
+ },
+ {
+ name: "toggle display contents on the element before whitespace",
+ setup(fixture) {
+ fixture.innerHTML = `<div><p>a</p><em id="em"><span>b</span></em> <b>x</b></div>`;
+ return () => fixture.querySelector("#em").style.display = "contents";
+ },
+ },
+ {
+ name: "toggle display contents off on the element before whitespace",
+ setup(fixture) {
+ fixture.innerHTML = `<div><p>a</p><em id="em" style="display: contents"><p>b</p></em> <b>x</b></div>`;
+ return () => fixture.querySelector("#em").style.display = "inline";
+ },
+ },
+ {
+ name: "make the element inside a display contents element a block",
+ setup(fixture) {
+ fixture.innerHTML = `<div><span>a</span><em style="display: contents"><span id="inner">b</span></em> <b>x</b></div>`;
+ return () => fixture.querySelector("#inner").style.display = "block";
+ },
+ },
+ {
+ name: "insert a top layer member before whitespace",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="parent"><p>a</p><span id="before">b</span> <b>x</b></div>`;
+ return () => {
+ const popover = Object.assign(document.createElement("div"), { popover: "manual", textContent: "popover" });
+ fixture.querySelector("#before").replaceWith(popover);
+ popover.showPopover();
+ };
+ },
+ cleanup() {
+ for (const element of document.querySelectorAll(":popover-open"))
+ element.hidePopover();
+ },
+ },
+ {
+ name: "close a top layer member before whitespace",
+ setup(fixture) {
+ fixture.innerHTML = `<div id="parent"><p>a</p><div id="popover" popover="manual">popover</div> <b>x</b></div>`;
+ fixture.querySelector("#popover").showPopover();
+ return () => fixture.querySelector("#popover").hidePopover();
+ },
+ },
+ ];
+
+ test(() => runLayoutTreeFullRebuildComparisonCases(cases));
+</script>
diff --git a/Tests/LibWeb/Text/input/layout-tree-update/writing-suggestion-mutations.html b/Tests/LibWeb/Text/input/layout-tree-update/writing-suggestion-mutations.html
new file mode 100644
index 00000000000..395211f191f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/layout-tree-update/writing-suggestion-mutations.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<script src="resources/full-rebuild-comparison.js"></script>
+<div id="fixture"></div>
+<script>
+ const suggestionMutations = [
+ ["insert an element before the text", (editable) => editable.prepend(Object.assign(document.createElement("span"), { textContent: "new " }))],
+ ["insert a block before the text", (editable) => editable.prepend(Object.assign(document.createElement("div"), { textContent: "block" }))],
+ ["change the style of the editing host", (editable) => editable.style.color = "green"],
+ ["wrap the editing host in display contents", (editable) => editable.style.display = "contents"],
+ ["add a ::before to the editing host", (editable) => editable.insertAdjacentHTML("beforebegin", "<style>#editable::before { content: 'before'; }</style>")],
+ ];
+
+ const cases = suggestionMutations.map(([name, mutate]) => ({
+ name,
+ setup(fixture) {
+ fixture.innerHTML = `<div id="editable" contenteditable>-xyz</div>`;
+ const editable = fixture.querySelector("#editable");
+ editable.focus();
+ getSelection().collapse(editable.firstChild, 0);
+ internals.sendText(editable, "predi");
+ return () => mutate(editable);
+ },
+ settleBeforeMutation: () => internals.writingSuggestionSettled(),
+ cleanup() {
+ document.activeElement?.blur();
+ },
+ }));
+
+ asyncTest(async done => {
+ await runAsyncLayoutTreeFullRebuildComparisonCases(cases);
+ done();
+ });
+</script>