Skip to content

Truly independent web browser

Tests/LibWeb: Add tests for the edges of subgrids with box edges

Andreas Kling67789854f9dc
diff --git a/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-columns-rtl.txt b/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-columns-rtl.txt
new file mode 100644
index 00000000000..110637c06a1
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-columns-rtl.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 20 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [0,0] [0+0+0 800 0+0+0] [0+0+0 20 0+0+0] children: not-inline
+ Box <div.parent> at [0,0] [0+0+0 365.40625 0+0+434.59375] [0+0+0 20 0+0+0] [GFC] children: not-inline
+ BlockContainer <div> at [299.875,0] [0+0+0 65.53125 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [299.875,0 65.53125x20] baseline: 16
+ "Before"
+ TextNode <#text> (not painted)
+ Box <div.subgrid> at [97.390625,0] [7+4+30 154.484375 40+3+5] [0+0+0 20 0+0+0] [GFC] children: not-inline
+ BlockContainer <div> at [151.1875,0] [0+0+0 100.6875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [199.1875,0 52.6875x20] baseline: 16
+ "First"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [94.921875,0] [0+0+0 56.265625 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [94.921875,0 56.265625x20] baseline: 16
+ "Middle"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8.390625,0] [0+0+0 86.53125 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [49.390625,0 45.53125x20] baseline: 16
+ "Last"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [0,0] [0+0+0 56.390625 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [0,0 56.390625x20] baseline: 16
+ "After"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x20] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-columns.txt b/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-columns.txt
new file mode 100644
index 00000000000..7ebd878346b
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-columns.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 20 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [0,0] [0+0+0 800 0+0+0] [0+0+0 20 0+0+0] children: not-inline
+ Box <div.parent> at [0,0] [0+0+0 365.40625 0+0+434.59375] [0+0+0 20 0+0+0] [GFC] children: not-inline
+ BlockContainer <div> at [0,0] [0+0+0 65.53125 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [0,0 65.53125x20] baseline: 16
+ "Before"
+ TextNode <#text> (not painted)
+ Box <div.subgrid> at [113.53125,0] [5+3+40 154.484375 30+4+7] [0+0+0 20 0+0+0] [GFC] children: not-inline
+ BlockContainer <div> at [113.53125,0] [0+0+0 100.6875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [113.53125,0 52.6875x20] baseline: 16
+ "First"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [214.21875,0] [0+0+0 56.265625 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [214.21875,0 56.265625x20] baseline: 16
+ "Middle"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [270.484375,0] [0+0+0 86.53125 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [270.484375,0 45.53125x20] baseline: 16
+ "Last"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [309.015625,0] [0+0+0 56.390625 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [309.015625,0 56.390625x20] baseline: 16
+ "After"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x20] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-narrow-wrapped-text.txt b/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-narrow-wrapped-text.txt
new file mode 100644
index 00000000000..974c974e63a
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-narrow-wrapped-text.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 60 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [0,0] [0+0+0 800 0+0+0] [0+0+0 60 0+0+0] children: not-inline
+ Box <div.parent> at [0,0] [0+0+0 800 0+0+0] [0+0+0 60 0+0+0] [GFC] children: not-inline
+ Box <div.subgrid> at [70,0] [0+0+70 170 0+0+0] [0+0+0 40 0+0+0] [GFC] children: not-inline
+ BlockContainer <div> at [70,0] [0+0+0 120 0+0+0] [0+0+0 40 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [70,0 71.3125x20] baseline: 16
+ "AAAA"
+ frag 1 from TextNode start: 5, length: 4, rect: [70,20 71.3125x20] baseline: 16
+ "AAAA"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [190,0] [0+0+0 120 0+0+0] [0+0+0 40 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 9, rect: [190,0 103.5x20] baseline: 16
+ "BBBB BBBB"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [0,40] [0+0+0 120 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [0,40 56.390625x20] baseline: 16
+ "After"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x60] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-nested.txt b/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-nested.txt
new file mode 100644
index 00000000000..3ac9ff7c15d
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-nested.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 180 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [0,0] [0+0+0 800 0+0+0] [0+0+0 180 0+0+0] children: not-inline
+ Box <div.parent> at [0,0] [0+0+0 200 0+0+600] [0+0+0 180 0+0+0] [GFC] children: not-inline
+ Box <div.outer> at [0,10] [0+0+0 200 0+0+0] [0+0+10 150 20+0+0] [GFC] children: not-inline
+ BlockContainer <div> at [0,10] [0+0+0 200 0+0+0] [0+0+0 30 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 11, rect: [0,10 112.125x20] baseline: 16
+ "Outer first"
+ TextNode <#text> (not painted)
+ Box <div.inner> at [0,80] [0+0+0 200 0+0+0] [0+0+40 80 30+0+0] [GFC] children: not-inline
+ BlockContainer <div> at [0,80] [0+0+0 200 0+0+0] [0+0+0 60 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 11, rect: [0,80 106.765625x20] baseline: 16
+ "Inner first"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [0,140] [0+0+0 200 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 12, rect: [0,140 118.53125x20] baseline: 16
+ "Inner middle"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [0,160] [0+0+0 200 0+0+0] [0+0+0 70 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 10, rect: [0,160 98.96875x20] baseline: 16
+ "Inner last"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x180] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-rows.txt b/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-rows.txt
new file mode 100644
index 00000000000..4e75d2ac595
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-rows.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 189 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [0,0] [0+0+0 800 0+0+0] [0+0+0 189 0+0+0] children: not-inline
+ Box <div.parent> at [0,0] [0+0+0 200 0+0+600] [0+0+0 189 0+0+0] [GFC] children: not-inline
+ BlockContainer <div> at [0,0] [0+0+0 200 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [0,0 65.53125x20] baseline: 16
+ "Before"
+ TextNode <#text> (not painted)
+ Box <div.subgrid> at [0,68] [0+0+0 200 0+0+0] [5+3+40 60 30+4+7] [GFC] children: not-inline
+ BlockContainer <div> at [0,68] [0+0+0 200 0+0+0] [0+0+0 68 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [0,68 52.6875x20] baseline: 16
+ "First"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [0,136] [0+0+0 200 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 6, rect: [0,136 56.265625x20] baseline: 16
+ "Middle"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [0,156] [0+0+0 200 0+0+0] [0+0+0 61 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [0,156 45.53125x20] baseline: 16
+ "Last"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [0,169] [0+0+0 200 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [0,169 56.390625x20] baseline: 16
+ "After"
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x189] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-with-item-alignment.txt b/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-with-item-alignment.txt
new file mode 100644
index 00000000000..8738223f47f
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/grid/subgrid-edge-extra-margins-with-item-alignment.txt
@@ -0,0 +1,13 @@
+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 [0,0] [0+0+0 800 0+0+0] [0+0+0 120 0+0+0] children: not-inline
+ Box <div.parent> at [0,0] [0+0+0 800 0+0+0] [0+0+0 120 0+0+0] [GFC] children: not-inline
+ Box <div.subgrid> at [25,10] [0+0+25 255 20+0+0] [0+0+10 95 15+0+0] [GFC] children: not-inline
+ BlockContainer <div.item> at [95,50] [70+0+0 30 0+0+0] [40+0+0 20 0+0+0] [BFC] children: not-inline
+ BlockContainer <div.item> at [260,30] [35+0+0 30 0+0+35] [20+0+0 20 0+0+20] [BFC] children: not-inline
+ BlockContainer <div.item> at [60,90] [35+0+0 30 0+0+35] [20+0+0 20 0+0+20] [BFC] children: not-inline
+ BlockContainer <div.item> at [230,72] [5+0+0 30 0+0+65] [2+0+0 20 0+0+38] [BFC] children: not-inline
+ BlockContainer <div> at [126,71] [1+0+0 98 0+0+1] [1+0+0 58 0+0+1] [BFC] children: not-inline
+
+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/input/grid/subgrid-edge-extra-margins-columns-rtl.html b/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-columns-rtl.html
new file mode 100644
index 00000000000..aaaefd80331
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-columns-rtl.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<style>
+ body {
+ margin: 0;
+ font: 20px SerifPro;
+ }
+
+ .parent {
+ display: grid;
+ grid-template-columns: repeat(5, auto);
+ width: max-content;
+ direction: rtl;
+ }
+
+ .subgrid {
+ display: grid;
+ grid-column: 2 / 5;
+ grid-template-columns: subgrid;
+ margin-inline: 5px 7px;
+ border-style: solid;
+ border-width: 0;
+ border-inline-width: 3px 4px;
+ padding-inline: 40px 30px;
+ background: lightgray;
+ }
+</style>
+<div class="parent">
+ <div style="grid-column: 1">Before</div>
+ <div class="subgrid">
+ <div style="grid-column: 1">First</div>
+ <div style="grid-column: 2">Middle</div>
+ <div style="grid-column: 3">Last</div>
+ </div>
+ <div style="grid-column: 5">After</div>
+</div>
diff --git a/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-columns.html b/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-columns.html
new file mode 100644
index 00000000000..835a013efa4
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-columns.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<style>
+ body {
+ margin: 0;
+ font: 20px SerifPro;
+ }
+
+ .parent {
+ display: grid;
+ grid-template-columns: repeat(5, auto);
+ width: max-content;
+ }
+
+ .subgrid {
+ display: grid;
+ grid-column: 2 / 5;
+ grid-template-columns: subgrid;
+ margin: 0 7px 0 5px;
+ border-style: solid;
+ border-width: 0 4px 0 3px;
+ padding: 0 30px 0 40px;
+ background: lightgray;
+ }
+</style>
+<div class="parent">
+ <div style="grid-column: 1">Before</div>
+ <div class="subgrid">
+ <div style="grid-column: 1">First</div>
+ <div style="grid-column: 2">Middle</div>
+ <div style="grid-column: 3">Last</div>
+ </div>
+ <div style="grid-column: 5">After</div>
+</div>
diff --git a/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-narrow-wrapped-text.html b/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-narrow-wrapped-text.html
new file mode 100644
index 00000000000..a36823492ba
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-narrow-wrapped-text.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<style>
+ body {
+ margin: 0;
+ font: 20px SerifPro;
+ }
+
+ .parent {
+ display: grid;
+ grid-template-columns: 120px 120px;
+ }
+
+ .subgrid {
+ display: grid;
+ grid-column: 1 / -1;
+ grid-template-columns: subgrid;
+ padding-left: 70px;
+ background: lightgray;
+ }
+</style>
+<div class="parent">
+ <div class="subgrid">
+ <div>AAAA AAAA</div>
+ <div>BBBB BBBB</div>
+ </div>
+ <div>After</div>
+</div>
diff --git a/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-nested.html b/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-nested.html
new file mode 100644
index 00000000000..30fcbcbdb1d
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-nested.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<style>
+ body {
+ margin: 0;
+ font: 20px SerifPro;
+ }
+
+ .parent {
+ display: grid;
+ grid-template-rows: repeat(5, auto);
+ width: 200px;
+ }
+
+ .outer {
+ display: grid;
+ grid-row: 1 / -1;
+ grid-template-rows: subgrid;
+ padding: 10px 0 20px 0;
+ }
+
+ .inner {
+ display: grid;
+ grid-row: 2 / -1;
+ grid-template-rows: subgrid;
+ padding: 40px 0 30px 0;
+ background: lightgray;
+ }
+</style>
+<div class="parent">
+ <div class="outer">
+ <div style="grid-row: 1">Outer first</div>
+ <div class="inner">
+ <div style="grid-row: 1">Inner first</div>
+ <div style="grid-row: 2">Inner middle</div>
+ <div style="grid-row: 4">Inner last</div>
+ </div>
+ </div>
+</div>
diff --git a/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-rows.html b/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-rows.html
new file mode 100644
index 00000000000..1b56c9528df
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-rows.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<style>
+ body {
+ margin: 0;
+ font: 20px SerifPro;
+ }
+
+ .parent {
+ display: grid;
+ grid-template-rows: repeat(5, auto);
+ width: 200px;
+ }
+
+ .subgrid {
+ display: grid;
+ grid-row: 2 / 5;
+ grid-template-rows: subgrid;
+ margin: 5px 0 7px 0;
+ border-style: solid;
+ border-width: 3px 0 4px 0;
+ padding: 40px 0 30px 0;
+ background: lightgray;
+ }
+</style>
+<div class="parent">
+ <div style="grid-row: 1">Before</div>
+ <div class="subgrid">
+ <div style="grid-row: 1">First</div>
+ <div style="grid-row: 2">Middle</div>
+ <div style="grid-row: 3">Last</div>
+ </div>
+ <div style="grid-row: 5">After</div>
+</div>
diff --git a/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-with-item-alignment.html b/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-with-item-alignment.html
new file mode 100644
index 00000000000..e16b254e2b2
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/grid/subgrid-edge-extra-margins-with-item-alignment.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<style>
+ body {
+ margin: 0;
+ font: 20px SerifPro;
+ }
+
+ .parent {
+ display: grid;
+ grid-template-columns: 100px 100px 100px;
+ grid-template-rows: 60px 60px;
+ }
+
+ .subgrid {
+ display: grid;
+ grid-column: 1 / -1;
+ grid-row: 1 / -1;
+ grid-template-columns: subgrid;
+ grid-template-rows: subgrid;
+ padding: 10px 20px 15px 25px;
+ background: lightgray;
+ }
+
+ .item {
+ width: 30px;
+ height: 20px;
+ background: green;
+ }
+</style>
+<div class="parent">
+ <div class="subgrid">
+ <div class="item" style="grid-area: 1 / 1; align-self: end; justify-self: end"></div>
+ <div class="item" style="grid-area: 1 / 3; align-self: center; justify-self: center"></div>
+ <div class="item" style="grid-area: 2 / 1; margin: auto"></div>
+ <div class="item" style="grid-area: 2 / 3; margin: 2px 3px 4px 5px; align-self: start; justify-self: start"></div>
+ <div style="grid-area: 2 / 2; background: blue; margin: 1px"></div>
+ </div>
+</div>