Bug 1470329 - Change ReflowInput to have unconstrained BSize for size-contained elements, add reftests r=dholbert
☠☠ backed out by e7bd17818f9d ☠ ☠
authorMorgan Rae Reschenberg <mreschenberg@mozilla.com>
Mon, 02 Jul 2018 09:43:03 -0700
changeset 424962 3eed69f0be08c19fa9c62e4d55749501935ee6e4
parent 424961 8cd5cb7aebe27dd339772edd1127c6aa80f617a3
child 424963 e78128970a607dbca045c1e76e71fa7e4fdf1505
push id104946
push userrgurzau@mozilla.com
push dateWed, 04 Jul 2018 10:03:16 +0000
treeherdermozilla-inbound@796893f4d2f5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1470329
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1470329 - Change ReflowInput to have unconstrained BSize for size-contained elements, add reftests r=dholbert MozReview-Commit-ID: 6IRAi8iScwy
layout/generic/ReflowInput.cpp
layout/reftests/pagination/contain-size-break-001-ref.html
layout/reftests/pagination/contain-size-break-001.html
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/reftest.list
layout/reftests/w3c-css/submitted/contain/contain-size-multicol-001-ref.html
layout/reftests/w3c-css/submitted/contain/contain-size-multicol-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-001-ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html class="reftest-paged">
+<head>
+  <meta charset="utf-8">
+  <title>CSS Reftest Reference</title>
+  <style>
+    .basicOuter {
+      height: 20px;
+      background: orange;
+    }
+  </style>
+</head>
+  <body>
+    <div class="basicOuter">
+      before
+      <div>inside</div>
+      after
+    </div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/contain-size-break-001.html
@@ -0,0 +1,29 @@
+<!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>
+  <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">
+      before
+      <div class="innerPageBreak">
+      inside
+      </div>
+      after
+    </div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/contain-size-break-002-ref.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html class="reftest-paged">
+<head>
+  <meta charset="utf-8">
+  <title>CSS Reftest Reference</title>
+  <style>
+    table {
+      background: lightblue;
+      height: 1in;
+      width: 1in;
+    }
+    .basicOuter {
+      height: 20px;
+      background: orange;
+    }
+  </style>
+</head>
+  <body>
+    <div class="basicOuter">
+      <table border>
+        <tr><td></td></tr>
+        <tr><td></td></tr>
+      </table>
+    </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 class="reftest-paged">
+<head>
+<meta charset="utf-8">
+  <title>CSS Test: 'contain: size' should ignore breaks and force elements to be monolithic.</title>
+  <style>
+    table {
+      background: lightblue;
+      height: 1in;
+      width: 1in;
+    }
+    .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 border>
+        <tr class="innerPageBreak"><td></td></tr>
+        <tr class="innerPageBreak"><td></td></tr>
+      </table>
+    </div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/contain-size-break-003-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html class="reftest-paged">
+<head>
+  <meta charset="utf-8">
+  <title>CSS Reftest Reference</title>
+</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-003.html
@@ -0,0 +1,20 @@
+<!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>
+  <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-001.html contain-size-break-001-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) == contain-size-break-003.html contain-size-break-003-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-multicol-001-ref.html
@@ -0,0 +1,31 @@
+<!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">
+        <!-- Note: We use a canvas object here as a generic reference for
+             something monolithic/non-fragmentable. -->
+      </canvas>
+    </div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/contain/contain-size-multicol-001.html
@@ -0,0 +1,34 @@
+<!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="help" href="https://drafts.csswg.org/css-contain/#containment-size">
+  <link rel="match" href="contain-size-multicol-001-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>
--- a/layout/reftests/w3c-css/submitted/contain/reftest.list
+++ b/layout/reftests/w3c-css/submitted/contain/reftest.list
@@ -12,8 +12,9 @@ pref(layout.css.overflow-clip-box.enable
 == contain-paint-formatting-context-margin-001.html contain-paint-formatting-context-margin-001-ref.html
 == contain-paint-ignored-cases-internal-table-001a.html contain-paint-ignored-cases-internal-table-001-ref.html
 == contain-paint-ignored-cases-internal-table-001b.html contain-paint-ignored-cases-internal-table-001-ref.html
 == contain-paint-ignored-cases-no-principal-box-001.html contain-paint-ignored-cases-no-principal-box-001-ref.html
 == contain-paint-ignored-cases-ruby-containing-block-001.html contain-paint-ignored-cases-ruby-containing-block-001-ref.html
 == contain-paint-ignored-cases-ruby-stacking-and-clipping-001.html contain-paint-ignored-cases-ruby-stacking-and-clipping-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-multicol-001.html contain-size-multicol-001-ref.html