Bug 1470329 - Change ReflowInput to have unconstrained BSize for size-contained elements, add reftests r?dholbert draft
authorMorgan Rae Reschenberg <mreschenberg@mozilla.com>
Mon, 02 Jul 2018 09:43:03 -0700
changeset 814635 87ea1a145eb48c2cfd06e584cb2cd090a76a95fd
parent 814584 e8b7331398910233e3adaaed01cad6b75bb562a2
push id115290
push userbmo:mreschenberg@berkeley.edu
push dateThu, 05 Jul 2018 20:28:46 +0000
reviewersdholbert
bugs1470329
milestone63.0a1
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
testing/web-platform/meta/css/css-contain/contain-size-breaks-001.html.ini
--- 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
deleted file mode 100644
--- a/testing/web-platform/meta/css/css-contain/contain-size-breaks-001.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[contain-size-breaks-001.html]
-  expected: FAIL