Bug 1678997 - [css-break] Only scrollable overflow should create new pages, not ink overflow. r=layout-reviewers,jfkthame
authorMats Palmgren <mats@mozilla.com>
Mon, 30 Nov 2020 15:58:19 +0000
changeset 558721 dff86c7857d7666baa7ef59d9c0e516d9e075e22
parent 558720 ef0dabb6cb6603bc3816faea6a414f97e78da4d2
child 558722 93d5ff059b93dbe843ee4e5d7104d0bad49b6991
push id131738
push usermpalmgren@mozilla.com
push dateMon, 30 Nov 2020 16:35:31 +0000
treeherderautoland@dff86c7857d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslayout-reviewers, jfkthame
bugs1678997
milestone85.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 1678997 - [css-break] Only scrollable overflow should create new pages, not ink overflow. r=layout-reviewers,jfkthame Per https://github.com/w3c/csswg-drafts/issues/4099 Differential Revision: https://phabricator.services.mozilla.com/D97875
layout/generic/nsPageContentFrame.cpp
layout/generic/nsPageFrame.cpp
testing/web-platform/tests/css/css-break/ink-overflow-001-print.html
testing/web-platform/tests/css/css-break/ink-overflow-002.html
--- a/layout/generic/nsPageContentFrame.cpp
+++ b/layout/generic/nsPageContentFrame.cpp
@@ -134,26 +134,25 @@ void nsPageContentFrame::Reflow(nsPresCo
       mFrames.NotEmpty()) {
     auto* previous = static_cast<nsPageContentFrame*>(GetPrevContinuation());
     const nscoord previousPageOverflow =
         previous ? previous->mRemainingOverflow : 0;
     const nsSize containerSize(aReflowInput.AvailableWidth(),
                                aReflowInput.AvailableHeight());
     const nscoord pageBSize = GetLogicalRect(containerSize).BSize(wm);
     const nscoord overflowBSize =
-        LogicalRect(wm, InkOverflowRect(), GetSize()).BEnd(wm);
+        LogicalRect(wm, ScrollableOverflowRect(), GetSize()).BEnd(wm);
     const nscoord currentPageOverflow = overflowBSize - pageBSize;
     nscoord remainingOverflow =
         std::max(currentPageOverflow, previousPageOverflow - pageBSize);
 
     if (aStatus.IsFullyComplete() && remainingOverflow > 0) {
-      // If we have InkOverflow off the end of our page, then we report
+      // If we have ScrollableOverflow off the end of our page, then we report
       // ourselves as overflow-incomplete in order to produce an additional
-      // content-less page, which we expect to draw our InkOverflow on our
-      // behalf.
+      // content-less page, which we expect to draw our overflow on our behalf.
       aStatus.SetOverflowIncomplete();
     }
 
     mRemainingOverflow = std::max(remainingOverflow, 0);
   }
 
   NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aReflowOutput);
 }
--- a/layout/generic/nsPageFrame.cpp
+++ b/layout/generic/nsPageFrame.cpp
@@ -570,27 +570,32 @@ static void BuildPreviousPageOverflow(ns
                                       const nsDisplayListSet& aLists) {
   const auto previousPagesAndOffsets =
       GetPreviousPagesWithOverflow(aCurrentPageCF);
 
   const auto wm = aCurrentPageCF->GetWritingMode();
   for (const PageAndOffset& pair : Reversed(previousPagesAndOffsets)) {
     auto* prevPageCF = pair.first;
     const nscoord offsetToCurrentPageBStart = pair.second;
-    const LogicalRect inkOverflow(
-        wm, prevPageCF->InkOverflowRectRelativeToSelf(), prevPageCF->GetSize());
+    // Only scrollable overflow create new pages, not ink overflow.
+    const LogicalRect scrollableOverflow(
+        wm, prevPageCF->ScrollableOverflowRectRelativeToSelf(),
+        prevPageCF->GetSize());
     const auto remainingOverflow =
-        inkOverflow.BEnd(wm) - offsetToCurrentPageBStart;
+        scrollableOverflow.BEnd(wm) - offsetToCurrentPageBStart;
     if (remainingOverflow <= 0) {
       continue;
     }
 
     // This rect represents the piece of prevPageCF's overflow that ends up on
     // the current pageContentFrame (in prevPageCF's coordinate system).
-    LogicalRect overflowRect(inkOverflow);
+    // Note that we use InkOverflow here since this is for painting.
+    LogicalRect overflowRect(
+        wm, prevPageCF->InkOverflowRectRelativeToSelf(),
+        prevPageCF->GetSize());
     overflowRect.BStart(wm) = offsetToCurrentPageBStart;
     overflowRect.BSize(wm) = std::min(remainingOverflow, prevPageCF->BSize(wm));
 
     {
       // Convert the overflowRect to the coordinate system of aPageFrame, and
       // set it as the visible rect for display list building.
       const nsRect visibleRect =
           overflowRect.GetPhysicalRect(wm, aPageFrame->GetSize()) +
@@ -660,19 +665,20 @@ void nsPageFrame::BuildDisplayList(nsDis
     auto* currentPageCF = static_cast<nsPageContentFrame*>(child);
 
     if (StaticPrefs::layout_display_list_improve_fragmentation() &&
         mPageNum <= 255) {
       nsDisplayListBuilder::AutoPageNumberSetter p(aBuilder, mPageNum);
       BuildPreviousPageOverflow(aBuilder, this, currentPageCF, set);
     }
 
-    // Set the visible rect to ink overflow rect of the child nsPageContentFrame
-    // in parent nsPageFrame coordinate space.
-    const nsRect childOverflowRect = child->InkOverflowRectRelativeToSelf();
+    // Set the visible rect to scrollable overflow rect of the child
+    // nsPageContentFrame in parent nsPageFrame coordinate space.
+    const nsRect childOverflowRect =
+        child->ScrollableOverflowRectRelativeToSelf();
     const nsRect visibleRect = childOverflowRect + child->GetOffsetTo(this);
 
     nsDisplayListBuilder::AutoBuildingDisplayList buildingForChild(
         aBuilder, this, visibleRect, visibleRect);
     BuildDisplayListForChild(aBuilder, child, set);
 
     set.SerializeWithCorrectZOrder(&content, child->GetContent());
 
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-break/ink-overflow-001-print.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com">
+<link rel="help" href="https://www.w3.org/TR/css-break-3/">
+<link rel="match" href="about:blank">
+<meta name="flags" content="paged">
+<style>
+@page {
+  size: 5in 3in;
+  margin: 0.5in;
+}
+
+html,body {
+  color:black; background-color:white; font:20px/1 monospace; padding:0; margin:0;
+}
+
+body {
+  width: 100vw;
+  height: 100vh;
+  outline: 100px solid red;
+  box-shadow: 100px 100px 0 #F00;
+}
+</style>
+<body></body>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-break/ink-overflow-002.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com">
+<link rel="help" href="https://www.w3.org/TR/css-break-3/">
+<link rel="match" href="../reference/ref-filled-green-100px-square.xht">
+<style>
+.col {
+  column-width: 100px;
+  column-rule: 100px solid red;
+  height: 100px;
+  column-fill: auto;
+  gap: 0;
+  overflow: hidden;
+}
+
+.col > div {
+  display: flow-root;
+  width: 100px;
+  height: 100px;
+  background: green;
+}
+
+.col > div > div {
+  width: 10px;
+  height: 10px;
+  margin-top: 80px;
+  margin-left: 50px;
+  outline: 30px solid green;
+  box-shadow: 0 30px 0 30px green;
+}
+</style>
+<body>
+  <p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+  <div class="col"><div><div></div></div></div>
+</body>