Bug 1553828 - Compute intermediate bounds for transform items that do not extend 3D context. r=mattwoodrow, a=jcristau
authorMiko Mynttinen <mikokm@gmail.com>
Wed, 05 Jun 2019 20:04:08 +0000
changeset 536808 cce82ca49cbd9f555069adf61c3e4a8f565882cc
parent 536807 3bb7b46a7ca219a1eae632e4a2dff6e1659d29cc
child 536809 8a44e86052bb5439b6f71ee0c616ba2f6251a655
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, jcristau
bugs1553828
milestone68.0
Bug 1553828 - Compute intermediate bounds for transform items that do not extend 3D context. r=mattwoodrow, a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D33724
layout/painting/nsDisplayList.cpp
layout/reftests/display-list/1553828-1-ref.html
layout/reftests/display-list/1553828-1.html
layout/reftests/display-list/reftest.list
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -8546,32 +8546,36 @@ void nsDisplayTransform::UpdateBounds(ns
   UpdateUntransformedBounds(aBuilder);
 
   if (IsTransformSeparator()) {
     MOZ_ASSERT(GetTransform().IsIdentity());
     mBounds = mChildBounds;
     return;
   }
 
-  if (!Combines3DTransformWithAncestors()) {
-    if (mFrame->Extend3DContext()) {
+  if (mFrame->Extend3DContext()) {
+    if (!Combines3DTransformWithAncestors()) {
       // The transform establishes a 3D context. |UpdateBoundsFor3D()| will
       // collect the bounds from the child transforms.
       UpdateBoundsFor3D(aBuilder);
     } else {
-      // A stand-alone transform.
-      mBounds = TransformUntransformedBounds(aBuilder, GetTransform());
+      // With nested 3D transforms, the 2D bounds might not be useful.
+      mBounds = nsRect();
     }
 
     return;
   }
 
-  // With nested 3D transforms, the 2D bounds might not be useful.
-  MOZ_ASSERT(mFrame->Combines3DTransformWithAncestors());
-  mBounds = nsRect();
+  MOZ_ASSERT(!mFrame->Extend3DContext());
+
+  // We would like to avoid calculating 2D bounds here for nested 3D transforms,
+  // but mix-blend-mode relies on having bounds set. See bug 1556956.
+
+  // A stand-alone transform.
+  mBounds = TransformUntransformedBounds(aBuilder, GetTransform());
 }
 
 void nsDisplayTransform::UpdateBoundsFor3D(nsDisplayListBuilder* aBuilder) {
   MOZ_ASSERT(mFrame->Extend3DContext() &&
              !mFrame->Combines3DTransformWithAncestors() &&
              !IsTransformSeparator());
 
   // Always start updating from an establisher of a 3D rendering context.
new file mode 100644
--- /dev/null
+++ b/layout/reftests/display-list/1553828-1-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>Bug 1553828</title>
+    <style type="text/css">
+    .container {
+        transform-style: preserve-3d;
+        perspective: 1000px;
+        width: 500px;
+        background-color: white;
+    }
+
+    .child {
+        width: 500px;
+        height: 500px;
+        background-color: red;
+        transform: translateY(0px);
+        mix-blend-mode: difference;
+    }
+    </style>
+</head>
+
+<body>
+    <div class="container">
+        <div class="child"></div>
+    </div>
+</body>
+
+</html>
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/layout/reftests/display-list/1553828-1.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>Bug 1553828</title>
+    <style type="text/css">
+    .container {
+        transform-style: preserve-3d;
+        perspective: 1000px;
+        width: 500px;
+        background-color: white;
+    }
+
+    .child {
+        width: 500px;
+        height: 500px;
+        background-color: blue;
+        transform: translateY(0px);
+        mix-blend-mode: difference;
+    }
+    </style>
+</head>
+
+<body>
+    <div class="container">
+        <div class="child"></div>
+    </div>
+    <script type="text/javascript">
+    function doTest() {
+        document.querySelector(".child").style["background-color"] = "red";
+        document.documentElement.className = "";
+    }
+    window.addEventListener("MozReftestInvalidate", doTest);
+    // setTimeout(doTest, 5000);
+    </script>
+</body>
+
+</html>
\ No newline at end of file
--- a/layout/reftests/display-list/reftest.list
+++ b/layout/reftests/display-list/reftest.list
@@ -37,8 +37,9 @@ skip-if(!asyncPan) == 1437374-1.html 143
 == 1452805-1.html 1452805-ref.html
 == 1461231-1.html about:blank
 fuzzy(0-2,0-40000) skip-if(!asyncPan) == 1464288-1.html 1464288-ref.html
 == 1482403-1.html 1482403-1-ref.html
 == 1504233-1.html 1504233-1-ref.html
 == 1533317-1.html 1533317-1-ref.html
 == 1544948-1.html 1544948-1-ref.html
 == 1551053-1.html 1551053-1-ref.html
+== 1553828-1.html 1553828-1-ref.html