[GridFragmentation] Propagate break-before/break-after from container.

...when unfragmented). This patch captures the break-before/break-after
values for grid row(s) when unfragmented. We pass in a break-between
vector into |PlaceItems| which will then use this to set the
break-before/break-after on the fragment.

We also use these values to add the correct break-before/break-after
on the grid container.

Bug: 614667
Change-Id: Ie529efe0e5bfe53262d10d874149ffc5c6e67100
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453286
Reviewed-by: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: Alison Maher <almaher@microsoft.com>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#972206}
diff --git a/css/css-break/grid/grid-container-fragmentation-010.html b/css/css-break/grid/grid-container-fragmentation-010.html
new file mode 100644
index 0000000..d3e87d0
--- /dev/null
+++ b/css/css-break/grid/grid-container-fragmentation-010.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<link rel="help" href="https://drafts.csswg.org/css-grid-1/#pagination">
+<link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+<div style="background: red; position: relative; width: 100px; height: 100px; column-fill: auto; columns: 2; gap: 0;">
+  <div style="background: green; height: 50px;"></div>
+  <div style="background: green; display: grid; grid-template-columns: auto auto; height: 50px;">
+    <div></div>
+    <div style="break-before: column;"></div> <!-- Should result in a column break before the grid container. -->
+  </div>
+  <div style="background: green; height: 50px;"></div>
+  <div style="background: green; position: absolute; width: 50px; height: 50px; bottom: 0; left: 0;"></div>
+</div>
diff --git a/css/css-break/grid/grid-container-fragmentation-011.html b/css/css-break/grid/grid-container-fragmentation-011.html
new file mode 100644
index 0000000..8615244
--- /dev/null
+++ b/css/css-break/grid/grid-container-fragmentation-011.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<link rel="help" href="https://drafts.csswg.org/css-grid-1/#pagination">
+<link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+<div style="background: red; position: relative; width: 100px; height: 100px; column-fill: auto; columns: 2; gap: 0;">
+  <div style="background: green; display: grid; grid-template-columns: auto auto; height: 50px;">
+    <div style="break-after: column;"></div> <!-- Should result in a column break after the grid container. -->
+    <div></div>
+  </div>
+  <div style="background: green; height: 50px;"></div>
+  <div style="background: green; height: 50px;"></div>
+  <div style="background: green; position: absolute; width: 50px; height: 50px; bottom: 0; left: 0;"></div>
+</div>
diff --git a/css/css-break/grid/grid-item-fragmentation-046.html b/css/css-break/grid/grid-item-fragmentation-046.html
new file mode 100644
index 0000000..ffdc94e
--- /dev/null
+++ b/css/css-break/grid/grid-item-fragmentation-046.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<link rel="help" href="https://drafts.csswg.org/css-grid-1/#pagination">
+<link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
+<title>Tests that break precedence for a grid row is correctly calculated.</title>
+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+<div style="position: relative; width: 100px; height: 100px; columns: 2; column-gap: 0; column-fill: auto; background: red;">
+  <div style="display: grid; grid-template-rows: 50px 100px;">
+    <div style="background: green;"></div>
+    <div style="background: green; break-before: avoid; display: grid; grid-template-columns: auto auto;">
+      <div></div>
+      <div style="break-before: column;"></div> <!-- This break-before should be propagated to the outermost grid row. -->
+    </div>
+  </div>
+  <div style="background: green; position: absolute; width: 50px; height: 50px; left: 0; bottom: 0;"></div>
+</div>
diff --git a/css/css-break/grid/grid-item-fragmentation-047.html b/css/css-break/grid/grid-item-fragmentation-047.html
new file mode 100644
index 0000000..ac6d137
--- /dev/null
+++ b/css/css-break/grid/grid-item-fragmentation-047.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<link rel="help" href="https://drafts.csswg.org/css-grid-1/#pagination">
+<link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
+<title>Tests that break precedence for a grid row is correctly calculated.</title>
+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+<div style="position: relative; width: 100px; height: 100px; columns: 2; column-gap: 0; column-fill: auto; background: red;">
+  <div style="display: grid; grid-template-rows: 50px 100px;">
+    <div style="background: green; break-after: avoid; display: grid; grid-template-columns: auto auto;">
+      <div style="break-after: column;"></div> <!-- This break-after should be propagated to the outermost grid row. -->
+      <div></div>
+    </div>
+    <div style="background: green;"></div>
+  </div>
+  <div style="background: green; position: absolute; width: 50px; height: 50px; left: 0; bottom: 0;"></div>
+</div>
diff --git a/css/css-break/grid/grid-item-fragmentation-048.html b/css/css-break/grid/grid-item-fragmentation-048.html
new file mode 100644
index 0000000..5eed6b9
--- /dev/null
+++ b/css/css-break/grid/grid-item-fragmentation-048.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<link rel="help" href="https://drafts.csswg.org/css-grid-1/#pagination">
+<link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
+<title>Tests that break precedence for a grid row is correctly calculated.</title>
+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+<div style="position: relative; width: 100px; height: 100px; columns: 4; column-gap: 0; column-fill: auto; background: red;">
+  <div style="display: grid; grid-template-rows: 50px 50px 200px;">
+    <div style="background: green;"></div>
+    <div style="background: green; break-before: avoid; break-after: avoid; display: grid; grid-template-columns: auto auto;">
+      <div style="break-before: column; break-after: column;"></div> <!-- The break values should be propagated to the outermost rows. -->
+      <div></div>
+    </div>
+    <div style="background: green;"></div>
+  </div>
+  <div style="background: green; position: absolute; width: 50px; height: 50px; left: 0; bottom: 0;"></div>
+</div>