Bug 1030124 - If the nsDisplayTransform frame isn't actually transformed (and not a reference frame), then apply the coordinate space change offset when we compute the transform for the preserve-3d parent. r=roc, a=sledru
☠☠ backed out by 1682007ce4bf ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 20 Aug 2014 17:43:26 +1200
changeset 217752 56bd998462222a6e5650c298be9e0a756b31e9b6
parent 217751 073eb01d99b754cb417d581183c7ce3ae32c23f4
child 217753 44c39420827398f41aaf030b6a7829d1f63c1cbf
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, sledru
bugs1030124
milestone33.0a2
Bug 1030124 - If the nsDisplayTransform frame isn't actually transformed (and not a reference frame), then apply the coordinate space change offset when we compute the transform for the preserve-3d parent. r=roc, a=sledru
layout/base/nsDisplayList.cpp
layout/reftests/transform-3d/backface-visibility-3-ref.html
layout/reftests/transform-3d/backface-visibility-3.html
layout/reftests/transform-3d/reftest.list
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -4644,21 +4644,26 @@ nsDisplayTransform::GetResultingTransfor
     // Include the transform set on our parent
     NS_ASSERTION(frame->GetParent() &&
                  frame->GetParent()->IsTransformed() &&
                  frame->GetParent()->Preserves3DChildren(),
                  "Preserve3D mismatch!");
     FrameTransformProperties props(frame->GetParent(),
                                    aAppUnitsPerPixel,
                                    nullptr);
+
+    // If this frame isn't transformed (but we exist for backface-visibility),
+    // then we're not a reference frame so no offset to origin will be added. Our
+    // parent transform however *is* the reference frame, so we pass true for
+    // aOffsetByOrigin to convert into the correct coordinate space.
     gfx3DMatrix parent =
       GetResultingTransformMatrixInternal(props,
                                           aOrigin - frame->GetPosition(),
                                           aAppUnitsPerPixel, nullptr,
-                                          aOutAncestor, false);
+                                          aOutAncestor, !frame->IsTransformed());
 
     result = nsLayoutUtils::ChangeMatrixBasis(offsetBetweenOrigins, result) * parent;
     if (aOffsetByOrigin) {
       result.Translate(roundedOrigin);
     }
     return result;
   }
 
@@ -4783,17 +4788,17 @@ nsDisplayTransform::GetTransform()
        * coordinates to be relative to our reference frame instead of relative
        * to this frame.
        * When we have preserve-3d, our reference frame is already guaranteed
        * to be an ancestor of the preserve-3d chain, so we only need to do
        * this once.
        */
       mTransform =
         GetResultingTransformMatrix(mFrame, ToReferenceFrame(), scale,
-                                    nullptr, nullptr, true);
+                                    nullptr, nullptr, mFrame->IsTransformed()));
     }
   }
   return mTransform;
 }
 
 bool
 nsDisplayTransform::ShouldBuildLayerEvenIfInvisible(nsDisplayListBuilder* aBuilder)
 {
new file mode 100644
--- /dev/null
+++ b/layout/reftests/transform-3d/backface-visibility-3-ref.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <style type='text/css'>
+    div {
+      position: absolute;
+      display: block;
+      width: 160px;
+      height: 160px;
+      background: red;
+      top:108px;
+      left:308px;
+    }
+  </style>
+</head>
+<body>
+    <div></div>
+</body>
+</html>
+
+
new file mode 100644
--- /dev/null
+++ b/layout/reftests/transform-3d/backface-visibility-3.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <style type='text/css'>
+    body {
+      overflow: hidden;
+    }
+    #test {
+      transform-origin: 0 0;
+      transform: scale(2) translateX(100px);
+      transform-style: preserve-3d;
+    }
+    #test div {
+      position: absolute;
+      display: block;
+      width: 80px;
+      height: 80px;
+      background: red;
+      top:50px;
+      left:50px;
+
+     backface-visibility: hidden;
+    }
+  </style>
+</head>
+<body>
+  <div id="test">
+    <div></div>
+  </div>
+</body>
+</html>
+
+
--- a/layout/reftests/transform-3d/reftest.list
+++ b/layout/reftests/transform-3d/reftest.list
@@ -31,16 +31,17 @@ fuzzy-if(winWidget,102,580) fuzzy-if(d2d
 == matrix3d-1a.html matrix3d-1-ref.html
 == matrix3d-2a.html matrix3d-2-ref.html
 == rotate3d-1a.html rotatex-1-ref.html
 == rotate3d-2a.html rotatey-1-ref.html
 != backface-visibility-1a.html about:blank
 == backface-visibility-1b.html about:blank
 == backface-visibility-1c.html about:blank
 == backface-visibility-2.html backface-visibility-2-ref.html
+== backface-visibility-3.html backface-visibility-3-ref.html
 != perspective-origin-1a.html rotatex-perspective-1a.html
 random-if(Android&&AndroidVersion==17) == perspective-origin-1b.html perspective-origin-1a.html
 random-if(Android&&!browserIsRemote) == perspective-origin-2a.html perspective-origin-2-ref.html # bug 732568
 == perspective-origin-3a.html perspective-origin-3-ref.html
 == perspective-origin-4a.html perspective-origin-4-ref.html
 != sorting-1a.html sorting-1-ref.html
 # Parallel planes, different z depth
 == sorting-2a.html sorting-2-ref.html