Bug 1470329 - Change ReflowInput to have unconstrained BSize for size-contained elements, add reftests r?dholbert draft
authorMorgan Rae Reschenberg <mreschenberg@mozilla.com>
Fri, 22 Jun 2018 11:37:11 -0700
changeset 812612 70a0568fe4a398f2686b5f0947622818185afc1a
parent 810397 128cac9f821688e94036477155fe4ed4f2f0aa48
push id114603
push userbmo:mreschenberg@berkeley.edu
push dateFri, 29 Jun 2018 17:19:49 +0000
reviewersdholbert
bugs1470329
milestone62.0a1
Bug 1470329 - Change ReflowInput to have unconstrained BSize for size-contained elements, add reftests r?dholbert MozReview-Commit-ID: AJnon1qkSGY
layout/generic/ReflowInput.cpp
layout/reftests/pagination/contain-size-break-002-ref.html
layout/reftests/pagination/contain-size-break-002.html
layout/reftests/pagination/contain-size-break-003-ref.html
layout/reftests/pagination/contain-size-break-003.html
layout/reftests/pagination/contain-size-break-004-ref.html
layout/reftests/pagination/contain-size-break-004.html
layout/reftests/pagination/reftest.list
layout/reftests/w3c-css/submitted/contain/contain-size-break-001-ref.html
layout/reftests/w3c-css/submitted/contain/contain-size-break-001.html
layout/reftests/w3c-css/submitted/contain/reftest.list
--- a/layout/generic/ReflowInput.cpp
+++ b/layout/generic/ReflowInput.cpp
@@ -480,16 +480,23 @@ ReflowInput::Init(nsPresContext*     aPr
     if (type == LayoutFrameType::ColumnSet &&
         eStyleUnit_Auto == mStylePosition->ISize(mWritingMode).GetUnit()) {
       ComputedISize() = NS_UNCONSTRAINEDSIZE;
     } else {
       AvailableBSize() = NS_UNCONSTRAINEDSIZE;
     }
   }
 
+  if (mStyleDisplay->IsContainSize()) {
+    // In the case that a box is size contained, we want to ensure
+    // that it is also monolithic. We do this by unsetting
+    // AvailableBSize() to avoid fragmentaiton.
+    AvailableBSize() = NS_UNCONSTRAINEDSIZE;
+  }
+
   LAYOUT_WARN_IF_FALSE((mFrameType == NS_CSS_FRAME_TYPE_INLINE &&
                         !mFrame->IsFrameOfType(nsIFrame::eReplaced)) ||
                        type == LayoutFrameType::Text ||
                        ComputedISize() != NS_UNCONSTRAINEDSIZE,
                        "have unconstrained inline-size; this should only "
                        "result from very large sizes, not attempts at "
                        "intrinsic inline-size calculation");
 }
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/contain-size-break-002-ref.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>CSS Reftest Reference</title>
+  <link rel="author" title="Morgan Rae Reschenberg" href="mailto:mreschenberg@berkeley.edu">
+<style>
+.cols {
+  column-count: 3;
+  column-rule: 1px dotted blue;
+  column-fill: auto;
+  border: 2px solid blue;
+  height: 50px;
+  width: 300px;
+}
+.innerObject {
+  height: 200px;
+  width: 100px;
+  background: orange;
+}
+</style>
+</head>
+  <body>
+    <div class="cols">
+      <canvas class="innerObject">
+      </canvas>
+    </div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/contain-size-break-002.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+  <title>CSS Test: 'contain: size' should force elements to be monolithic, i.e. to not fragment inside a multicol element.</title>
+  <link rel="author" title="Morgan Rae Reschenberg" href="mailto:mreschenberg@berkeley.edu">
+  <link rel="match" href="contain-size-break-002-ref.html">
+<style>
+.contain {
+  contain:size;
+}
+.cols {
+  column-count: 3;
+  column-rule: 1px dotted blue;
+  column-fill: auto;
+  border: 2px solid blue;
+  height: 50px;
+  width: 300px;
+}
+.innerObject {
+  height: 200px;
+  width: 100px;
+  background: orange;
+}
+</style>
+</head>
+  <body>
+    <div class="cols">
+      <div class="contain innerObject">
+      </div>
+    </div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/contain-size-break-003-ref.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html class="reftest-paged">
+<head>
+  <meta charset="utf-8">
+  <title>CSS Reftest Reference</title>
+  <link rel="author" title="Morgan Rae Reschenberg" href="mailto:mreschenberg@berkeley.edu">
+<style>
+.basicOuter {
+  height: 20px;
+  background: orange;
+}
+</style>
+</head>
+  <body>
+    <div class="basicOuter">
+      <table style="background:lightblue; height:5in;">
+        <tr>
+          <td></td>
+        </tr>
+      </table>
+    </div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/contain-size-break-003.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html class="reftest-paged">
+<head>
+<meta charset="utf-8">
+  <title>CSS Test: 'contain: size' should ignore breaks and force elements to be monolithic.</title>
+  <link rel="author" title="Morgan Rae Reschenberg" href="mailto:mreschenberg@berkeley.edu">
+  <link rel="match" href="contain-size-break-003-ref.html">
+<style>
+.contain {
+  contain:size;
+}
+.innerPageBreak {
+  page-break-before: always;
+  page-break-after: always;
+}
+.basicOuter {
+  height: 20px;
+  background: orange;
+}
+</style>
+</head>
+  <body>
+    <div class="contain basicOuter">
+      <table style="background:lightblue;height:5in;">
+        <tr class="innerPageBreak">
+          <td></td>
+        </tr>
+      </table>
+    </div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/contain-size-break-004-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html class="reftest-paged">
+<head>
+  <meta charset="utf-8">
+  <title>CSS Reftest Reference</title>
+  <link rel="author" title="Morgan Rae Reschenberg" href="mailto:mreschenberg@berkeley.edu">
+</head>
+  <body>
+    <table>
+      <tr>
+        <td style="height:4in; width: 50px; background:orange;">
+        </td>
+      </tr>
+    </table>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/contain-size-break-004.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html class="reftest-paged">
+<head>
+<meta charset="utf-8">
+  <title>CSS Test: 'contain: size' should not affect breaking in tables or table elements.</title>
+  <link rel="author" title="Morgan Rae Reschenberg" href="mailto:mreschenberg@berkeley.edu">
+  <link rel="match" href="contain-size-break-004-ref.html">
+<style>
+.contain {
+  contain:size;
+}
+</style>
+</head>
+  <body>
+    <table class="contain">
+      <tr>
+        <td style="height:4in; width: 50px; background:orange;">
+        </td>
+      </tr>
+    </table>
+  </body>
+</html>
--- a/layout/reftests/pagination/reftest.list
+++ b/layout/reftests/pagination/reftest.list
@@ -71,16 +71,19 @@ fuzzy-if(skiaContent,1,23) == resize-ref
 == table-caption-splitaftercaption-7.html table-caption-splitaftercaption-7-ref.html
 # == table-caption-splitaftercaption-8.html blank.html # bug 672654
 # == table-caption-splitaftercaption-9.html blank.html # bug 672654
 # == table-caption-splitaftercaption-10.html blank.html # bug 672654
 # == table-caption-splitaftercaption-11.html blank.html # bug 672654
 == column-balancing-break-inside-avoid-2.html column-balancing-break-inside-avoid-2-ref.html
 fuzzy-if(Android,1,2) == combobox-page-break-inside.html combobox-page-break-inside-ref.html
 == table-nested-1308876-1.xhtml table-nested-1308876-1-ref.html
+test-pref(layout.css.contain.enabled,true) == contain-size-break-002.html contain-size-break-002-ref.html
+test-pref(layout.css.contain.enabled,true) fails == contain-size-break-003.html contain-size-break-003-ref.html # bug 1467209
+test-pref(layout.css.contain.enabled,true) == contain-size-break-004.html contain-size-break-004-ref.html
 
 # Bugs
 == 272830-1.html 272830-1-ref.html
 == 318022-1.html 318022-1-ref.html
 == 403669-1.html 403669-1-ref.html
 == 381497-n.html 381497-f.html
 == test-async-paged.html 272830-1-ref.html
 == 129941-1a.html 129941-1-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/contain/contain-size-break-001-ref.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html class="reftest-paged">
+<head>
+  <meta charset="utf-8">
+  <title>CSS Reftest Reference</title>
+  <link rel="author" title="Morgan Rae Reschenberg" href="mailto:mreschenberg@berkeley.edu">
+<style>
+.basicOuter {
+  height: 20px;
+  background: orange;
+}
+</style>
+</head>
+  <body>
+    <div class="basicOuter">
+      <div></div>
+    </div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/contain/contain-size-break-001.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html class="reftest-paged">
+<head>
+<meta charset="utf-8">
+  <title>CSS Test: 'contain: size' should ignore breaks and force elements to be monolithic.</title>
+  <link rel="author" title="Morgan Rae Reschenberg" href="mailto:mreschenberg@berkeley.edu">
+  <link rel="match" href="contain-size-break-001-ref.html">
+<style>
+.contain {
+  contain:size;
+}
+.innerPageBreak {
+  page-break-before: always;
+  page-break-after: always;
+}
+.basicOuter {
+  height: 20px;
+  background: orange;
+}
+</style>
+</head>
+  <body>
+    <div class="contain basicOuter">
+      <div class="innerPageBreak">
+      </div>
+    </div>
+  </body>
+</html>
--- a/layout/reftests/w3c-css/submitted/contain/reftest.list
+++ b/layout/reftests/w3c-css/submitted/contain/reftest.list
@@ -7,8 +7,9 @@ default-preferences pref(layout.css.cont
 == contain-paint-clip-005.html contain-paint-clip-003-ref.html
 pref(layout.css.overflow-clip-box.enabled,true) == contain-paint-clip-006.html contain-paint-clip-006-ref.html
 == contain-paint-containing-block-absolute-001.html contain-paint-containing-block-absolute-001-ref.html
 == contain-paint-containing-block-fixed-001.html contain-paint-containing-block-fixed-001-ref.html
 == contain-paint-formatting-context-float-001.html contain-paint-formatting-context-float-001-ref.html
 == contain-paint-formatting-context-margin-001.html contain-paint-formatting-context-margin-001-ref.html
 == contain-paint-stacking-context-001a.html contain-paint-stacking-context-001-ref.html
 == contain-paint-stacking-context-001b.html contain-paint-stacking-context-001-ref.html
+== contain-size-break-001.html contain-size-break-001-ref.html