Bug 1397671 - Don't treat SVG transformed frames as being transformed for the purposes of computing Combines3DTransformWithAncestors. r=dbaron, a=sledru
authorMatt Woodrow <mwoodrow@mozilla.com>
Tue, 26 Sep 2017 15:57:56 +1300
changeset 432013 54a5c274f8a49ce12cf560e3d715ab9e922dec52
parent 432012 dd4bcf227b95d5a8767b3873f85b16c4c7eafd09
child 432014 75e965089708d0937fad036eff7e3fce01994e0e
push id7870
push userryanvm@gmail.com
push dateMon, 02 Oct 2017 13:47:52 +0000
treeherdermozilla-beta@b7b894f5fad8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron, sledru
bugs1397671
milestone57.0
Bug 1397671 - Don't treat SVG transformed frames as being transformed for the purposes of computing Combines3DTransformWithAncestors. r=dbaron, a=sledru
layout/generic/nsFrame.cpp
layout/generic/nsIFrame.h
layout/reftests/transform-3d/preserve3d-8-ref.html
layout/reftests/transform-3d/preserve3d-8.html
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -1322,20 +1322,27 @@ nsIFrame::GetMarginRectRelativeToSelf() 
   r.Inflate(m);
   return r;
 }
 
 bool
 nsIFrame::IsTransformed(const nsStyleDisplay* aStyleDisplay,
                         EffectSet* aEffectSet) const
 {
+  return IsCSSTransformed(aStyleDisplay, aEffectSet) ||
+         IsSVGTransformed();
+}
+
+bool
+nsIFrame::IsCSSTransformed(const nsStyleDisplay* aStyleDisplay,
+                           EffectSet* aEffectSet) const
+{
   MOZ_ASSERT(aStyleDisplay == StyleDisplay());
   return ((mState & NS_FRAME_MAY_BE_TRANSFORMED) &&
           (aStyleDisplay->HasTransform(this) ||
-           IsSVGTransformed() ||
            HasAnimationOfTransform(aEffectSet)));
 }
 
 bool
 nsIFrame::HasAnimationOfTransform(EffectSet* aEffectSet) const
 {
   EffectSet* effects =
     aEffectSet ? aEffectSet : EffectSet::GetEffectSet(this);
@@ -1397,17 +1404,17 @@ bool
 nsIFrame::Combines3DTransformWithAncestors(const nsStyleDisplay* aStyleDisplay,
                                            EffectSet* aEffectSet) const
 {
   MOZ_ASSERT(aStyleDisplay == StyleDisplay());
   nsIFrame* parent = GetFlattenedTreeParentPrimaryFrame();
   if (!parent || !parent->Extend3DContext()) {
     return false;
   }
-  return IsTransformed(aStyleDisplay,aEffectSet) ||
+  return IsCSSTransformed(aStyleDisplay, aEffectSet) ||
          BackfaceIsHidden(aStyleDisplay);
 }
 
 bool
 nsIFrame::In3DContextAndBackfaceIsHidden(EffectSet* aEffectSet) const
 {
   // While both tests fail most of the time, test BackfaceIsHidden()
   // first since it's likely to fail faster.
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -1720,16 +1720,22 @@ public:
    *   time; otherwise, just left it as nullptr.
    */
   bool IsTransformed(const nsStyleDisplay* aStyleDisplay, mozilla::EffectSet* aEffectSet = nullptr) const;
   bool IsTransformed(mozilla::EffectSet* aEffectSet = nullptr) const {
     return IsTransformed(StyleDisplay(), aEffectSet);
   }
 
   /**
+   * Same as IsTransformed, except that it doesn't take SVG transforms
+   * into account.
+   */
+  bool IsCSSTransformed(const nsStyleDisplay* aStyleDisplay, mozilla::EffectSet* aEffectSet = nullptr) const;
+
+  /**
    * True if this frame has any animation of transform in effect.
    *
    * @param aEffectSet: This function may need to look up EffectSet property.
    *   If a caller already have one, pass it in can save property look up
    *   time; otherwise, just left it as nullptr.
    */
   bool HasAnimationOfTransform(mozilla::EffectSet* aEffectSet = nullptr) const;
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/transform-3d/preserve3d-8-ref.html
@@ -0,0 +1,11 @@
+<html>
+<head>
+</head>
+<body style="width:100px">
+  <svg xmlns="http://www.w3.org/2000/svg" version="1.1" id="js" viewBox="0 0 200 200" style="transform: rotateX(180deg)">
+    <g>
+      <rect width="100" height="100" style="fill:rgb(0,0,255)"></rect>
+    </g>
+  </svg>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/transform-3d/preserve3d-8.html
@@ -0,0 +1,17 @@
+<html>
+<head>
+</head>
+<body>
+  <div style="transform: rotatex(45deg); transform-style: preserve-3d; width: 100px;">
+    <div style="transform: rotatex(45deg); transform-style: preserve-3d; width: 100px;">
+      <div style="transform: rotatex(45deg); transform-style: preserve-3d; width: 100px;">
+        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" id="js" viewBox="0 0 200 200" style="transform: rotateX(45deg)">
+          <g>
+            <rect width="100" height="100" style="fill:rgb(0,0,255)"></rect>
+          </g>
+        </svg>
+      </div>
+    </div>
+  </div>
+</body>
+</html>