Honor 'break-inside: avoid' also when 'min-block-size' causes the overflow.

Differential Revision: https://phabricator.services.mozilla.com/D115604

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1711630
gecko-commit: 1fafda061dceb0cedece654f909dfeb9bf3b0a01
gecko-reviewers: TYLin
diff --git a/css/css-break/break-inside-avoid-min-block-size-1-ref.html b/css/css-break/break-inside-avoid-min-block-size-1-ref.html
new file mode 100644
index 0000000..56789f6
--- /dev/null
+++ b/css/css-break/break-inside-avoid-min-block-size-1-ref.html
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>CSS Test: break-inside:avoid min-block-size block</title>
+  <link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com">
+  <style>
+html,body {
+    color:black; background-color:white; font:10px/1 monospace; padding:0; margin:0;
+}
+.columns {
+  columns: 3;
+  background: grey;
+  margin-block-end: 1px;
+  inline-size: 500px;
+}
+.fill {
+  column-fill: auto;
+}
+.short {
+  block-size: 30px;
+}
+.tall {
+  block-size: 60px;
+}
+.columns > div {
+  block-size: 40px;
+  background: blue;
+}
+.columns > div:nth-child(2n) { background: lightblue; }
+  </style>
+</head>
+<body>
+<div class="columns fill" style="block-size:40px">
+  <div></div>
+  <div></div>
+</div>
+<div class="columns fill" style="block-size:40px">
+  <div>&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns short">
+  <div style="margin-block-end:20px"></div>
+  <div></div>
+</div>
+<div class="columns short">
+  <div style="margin-block-end:20px">&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns tall">
+  <div style="margin-block-end:40px"></div>
+  <div></div>
+</div>
+<div class="columns tall">
+  <div style="margin-block-end:40px">&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns fill short">
+  <div style="margin-block-end:20px"></div>
+  <div></div>
+</div>
+<div class="columns fill short">
+  <div style="margin-block-end:20px">&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns fill tall">
+  <div style="margin-block-end:40px"></div>
+  <div></div>
+</div>
+<div class="columns fill tall">
+  <div style="margin-block-end:40px">&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+</body>
+</html>
diff --git a/css/css-break/break-inside-avoid-min-block-size-1.html b/css/css-break/break-inside-avoid-min-block-size-1.html
new file mode 100644
index 0000000..733aae5
--- /dev/null
+++ b/css/css-break/break-inside-avoid-min-block-size-1.html
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>CSS Test: break-inside:avoid min-block-size block</title>
+  <link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com">
+  <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1711630">
+  <link rel="help" href="https://drafts.csswg.org/css-break">
+  <link rel="match" href="break-inside-avoid-min-block-size-1-ref.html">
+  <style>
+html,body {
+    color:black; background-color:white; font:10px/1 monospace; padding:0; margin:0;
+}
+.columns {
+  columns: 3;
+  background: grey;
+  margin-block-end: 1px;
+  inline-size: 500px;
+}
+.fill {
+  column-fill: auto;
+}
+.short {
+  block-size: 30px;
+}
+.tall {
+  block-size: 60px;
+}
+.columns > div {
+  break-inside: avoid;
+  min-block-size: 40px;
+  background: blue;
+}
+.columns > div:nth-child(2n) { background: lightblue; }
+  </style>
+</head>
+<body>
+<div class="columns">
+  <div></div>
+  <div></div>
+</div>
+<div class="columns">
+  <div>&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns short">
+  <div></div>
+  <div></div>
+</div>
+<div class="columns short">
+  <div>&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns tall">
+  <div></div>
+  <div></div>
+</div>
+<div class="columns tall">
+  <div>&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns fill short">
+  <div></div>
+  <div></div>
+</div>
+<div class="columns fill short">
+  <div>&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns fill tall">
+  <div></div>
+  <div></div>
+</div>
+<div class="columns fill tall">
+  <div>&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+</body>
+</html>
diff --git a/css/css-break/break-inside-avoid-min-block-size-2-ref.html b/css/css-break/break-inside-avoid-min-block-size-2-ref.html
new file mode 100644
index 0000000..70c4049
--- /dev/null
+++ b/css/css-break/break-inside-avoid-min-block-size-2-ref.html
@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>CSS Test: break-inside:avoid min-block-size block</title>
+  <link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com">
+  <style>
+html,body {
+    color:black; background-color:white; font:10px/1 monospace; padding:0; margin:0;
+    writing-mode: vertical-rl;
+}
+.columns {
+  columns: 3;
+  background: grey;
+  margin-block-end: 1px;
+  inline-size: 500px;
+}
+.fill {
+  column-fill: auto;
+}
+.short {
+  block-size: 30px;
+}
+.tall {
+  block-size: 60px;
+}
+.columns > div {
+  block-size: 40px;
+  background: blue;
+}
+.columns > div:nth-child(2n) { background: lightblue; }
+  </style>
+</head>
+<body>
+<div class="columns fill" style="block-size:40px">
+  <div></div>
+  <div></div>
+</div>
+<div class="columns fill" style="block-size:40px">
+  <div>&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns short">
+  <div style="margin-block-end:20px"></div>
+  <div></div>
+</div>
+<div class="columns short">
+  <div style="margin-block-end:20px">&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns tall">
+  <div style="margin-block-end:40px"></div>
+  <div></div>
+</div>
+<div class="columns tall">
+  <div style="margin-block-end:40px">&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns fill short">
+  <div style="margin-block-end:20px"></div>
+  <div></div>
+</div>
+<div class="columns fill short">
+  <div style="margin-block-end:20px">&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns fill tall">
+  <div style="margin-block-end:40px"></div>
+  <div></div>
+</div>
+<div class="columns fill tall">
+  <div style="margin-block-end:40px">&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+</body>
+</html>
diff --git a/css/css-break/break-inside-avoid-min-block-size-2.html b/css/css-break/break-inside-avoid-min-block-size-2.html
new file mode 100644
index 0000000..e7669d8
--- /dev/null
+++ b/css/css-break/break-inside-avoid-min-block-size-2.html
@@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>CSS Test: break-inside:avoid min-block-size block</title>
+  <link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com">
+  <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1711630">
+  <link rel="help" href="https://drafts.csswg.org/css-break">
+  <link rel="match" href="break-inside-avoid-min-block-size-2-ref.html">
+  <style>
+html,body {
+    color:black; background-color:white; font:10px/1 monospace; padding:0; margin:0;
+    writing-mode: vertical-rl;
+}
+.columns {
+  columns: 3;
+  background: grey;
+  margin-block-end: 1px;
+  inline-size: 500px;
+}
+.fill {
+  column-fill: auto;
+}
+.short {
+  block-size: 30px;
+}
+.tall {
+  block-size: 60px;
+}
+.columns > div {
+  break-inside: avoid;
+  min-block-size: 40px;
+  background: blue;
+}
+.columns > div:nth-child(2n) { background: lightblue; }
+  </style>
+</head>
+<body>
+<div class="columns">
+  <div></div>
+  <div></div>
+</div>
+<div class="columns">
+  <div>&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns short">
+  <div></div>
+  <div></div>
+</div>
+<div class="columns short">
+  <div>&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns tall">
+  <div></div>
+  <div></div>
+</div>
+<div class="columns tall">
+  <div>&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns fill short">
+  <div></div>
+  <div></div>
+</div>
+<div class="columns fill short">
+  <div>&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+<div class="columns fill tall">
+  <div></div>
+  <div></div>
+</div>
+<div class="columns fill tall">
+  <div>&nbsp;<br>&nbsp;</div>
+  <div>&nbsp;<br>&nbsp;</div>
+</div>
+</body>
+</html>