Bug 1452805 - Make sure we rebuild contents infront and behind stacking contexts if their size might have changed. r?miko draft
authorMatt Woodrow <mwoodrow@mozilla.com>
Sun, 15 Apr 2018 16:38:45 +1200
changeset 786871 27c8e557687f80b3d76941f9a228a210e1b1a815
parent 784732 a0c804993efc599a95e97bea39fa1528fd0195d8
child 786872 c4c49b75c224b54b81c706e8b338903a40f957ac
push id107595
push usermwoodrow@mozilla.com
push dateTue, 24 Apr 2018 00:59:46 +0000
reviewersmiko
bugs1452805
milestone61.0a1
Bug 1452805 - Make sure we rebuild contents infront and behind stacking contexts if their size might have changed. r?miko The test invalidates the z-index element, so that we do a partial build with just that and the DAG no longer knows the relative ordering between it and the other blue elements. We then expand the size of the 'first' elements stacking context, and ensure that we provide enough intersecting items to know that we're on top of the z-index element. MozReview-Commit-ID: KP7c3bnwfBd * * * [mq]: fix MozReview-Commit-ID: EuraqvaUS35
layout/generic/nsFrame.cpp
layout/reftests/display-list/1452805-1.html
layout/reftests/display-list/1452805-ref.html
layout/reftests/display-list/reftest.list
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2900,16 +2900,22 @@ nsIFrame::BuildDisplayListForStackingCon
         nsDisplayTransform::UntransformRect(visibleRect, overflow, this, &visibleRect);
       } else {
         // This should only happen if the transform is singular, in which case nothing is visible anyway
         dirtyRect.SetEmpty();
         visibleRect.SetEmpty();
       }
     }
     inTransform = true;
+  } else if (IsFixedPosContainingBlock()) {
+    // Restict the building area to the overflow rect for these frames, since
+    // RetainedDisplayListBuilder uses it to know if the size of the stacking
+    // context changed.
+    visibleRect.IntersectRect(visibleRect, GetVisualOverflowRect());
+    dirtyRect.IntersectRect(dirtyRect, GetVisualOverflowRect());
   }
 
   bool hasOverrideDirtyRect = false;
   // If we have an override dirty region, and neither us nor our ancestors are
   // modified, then use it.
   if (HasOverrideDirtyRegion() && !aBuilder->InInvalidSubtree() && !IsFrameModified()) {
     nsDisplayListBuilder::DisplayListBuildingData* data =
       GetProperty(nsDisplayListBuilder::DisplayListBuildingRect());
new file mode 100644
--- /dev/null
+++ b/layout/reftests/display-list/1452805-1.html
@@ -0,0 +1,39 @@
+<html class="reftest-wait">
+  <head>
+    <style>
+    div {
+      width: 200px;
+      height: 200px;
+      background-color: blue;
+      filter: greyscale(50%);
+      position: relative;
+    }
+    #second {
+      width: 600px;
+      height: 500px;
+      display: none;
+      background-color: green;
+    }
+    </style>
+  </head>
+  <body>
+    <div id="top" style="z-index:-4;"></div>
+    <div style="top: 10px;"></div>
+    <div style="top: 20px;">
+        <div id="second" style="top: -400px;"></div>
+    </div>
+
+    <script>
+      function doTest2() {
+        document.getElementById("second").style.display = "block";
+        document.documentElement.removeAttribute("class");
+      }
+      function doTest() {
+        document.getElementById("top").style.zIndex = -5;
+        setTimeout(doTest2, 500);
+      }
+      document.addEventListener("MozReftestInvalidate", doTest);
+    </script>
+  </body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/layout/reftests/display-list/1452805-ref.html
@@ -0,0 +1,26 @@
+<html>
+  <head>
+    <style>
+    div {
+      width: 200px;
+      height: 200px;
+      background-color: blue;
+      filter: greyscale(50%);
+      position: relative;
+    }
+    #second {
+      width: 600px;
+      height: 500px;
+      background-color: green;
+    }
+    </style>
+  </head>
+  <body>
+    <div id="top" style="z-index:-4;"></div>
+    <div style="top: 10px;"></div>
+    <div style="top: 20px;">
+        <div id="second" style="top: -400px;"></div>
+    </div>
+  </body>
+</html>
+
--- a/layout/reftests/display-list/reftest.list
+++ b/layout/reftests/display-list/reftest.list
@@ -22,8 +22,9 @@ needs-focus == 1429027-1.html 1429027-1-
 == 1432553-2.html 1432553-2-ref.html
 == 1436189-1.html 1436189-1-ref.html
 skip-if(!asyncPan) == 1437374-1.html 1437374-1-ref.html
 == 1439809-1.html 1439809-1-ref.html
 == 1443027-1.html 1443027-ref.html
 == 1443027-2.html 1443027-ref.html
 == 1443027-3.html 1443027-3-ref.html
 == 1451971-1.html 1451971-ref.html
+== 1452805-1.html 1452805-ref.html