From 84cb2c35293caa4a1ece3b0f6c5cdab489f9a41e Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Wed, 26 Sep 2012 10:47:41 +1200 Subject: [PATCH] Bug 793132 - Make sure that only display lists get the reference frame adjusted transform. r=roc --- layout/base/nsDisplayList.cpp | 36 ++++++++++++++------------ layout/base/nsDisplayList.h | 3 +-- layout/reftests/bugs/586683-1-ref.html | 6 +++-- layout/reftests/bugs/586683-1.html | 16 +++++------- 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 02e2bdf6756c..5df3cf10dc00 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -3341,7 +3341,7 @@ nsDisplayTransform::GetResultingTransformMatrix(const nsIFrame* aFrame, return GetResultingTransformMatrixInternal(aFrame, aOrigin, aAppUnitsPerPixel, aBoundsOverride, aTransformOverride, aToMozOrigin, aToPerspectiveOrigin, - aChildPerspective, aOutAncestor, false); + aChildPerspective, aOutAncestor); } gfx3DMatrix @@ -3353,8 +3353,7 @@ nsDisplayTransform::GetResultingTransformMatrixInternal(const nsIFrame* aFrame, gfxPoint3D* aToMozOrigin, gfxPoint3D* aToPerspectiveOrigin, nscoord* aChildPerspective, - nsIFrame** aOutAncestor, - bool aRecursing) + nsIFrame** aOutAncestor) { NS_PRECONDITION(aFrame || (aToMozOrigin && aBoundsOverride && aToPerspectiveOrigin && aTransformOverride && aChildPerspective), @@ -3448,15 +3447,7 @@ nsDisplayTransform::GetResultingTransformMatrixInternal(const nsIFrame* aFrame, gfxPoint3D rounded(hasSVGTransforms ? newOrigin.x : NS_round(newOrigin.x), hasSVGTransforms ? newOrigin.y : NS_round(newOrigin.y), 0); - - /** - * Shift the coorindates 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. - */ - if (!aRecursing) { - result.Translate(rounded); - } + if (aFrame && aFrame->Preserves3D() && nsLayoutUtils::Are3DTransformsEnabled()) { // Include the transform set on our parent NS_ASSERTION(aFrame->GetParent() && @@ -3467,7 +3458,7 @@ nsDisplayTransform::GetResultingTransformMatrixInternal(const nsIFrame* aFrame, GetResultingTransformMatrixInternal(aFrame->GetParent(), aOrigin - aFrame->GetPosition(), aAppUnitsPerPixel, nullptr, nullptr, nullptr, - nullptr, nullptr, aOutAncestor, true); + nullptr, nullptr, aOutAncestor); return nsLayoutUtils::ChangeMatrixBasis(rounded + toMozOrigin, result) * parent; } @@ -3563,17 +3554,28 @@ const gfx3DMatrix& nsDisplayTransform::GetTransform(float aAppUnitsPerPixel) { if (mTransform.IsIdentity() || mCachedAppUnitsPerPixel != aAppUnitsPerPixel) { + gfxPoint3D newOrigin = + gfxPoint3D(NSAppUnitsToFloatPixels(mToReferenceFrame.x, aAppUnitsPerPixel), + NSAppUnitsToFloatPixels(mToReferenceFrame.y, aAppUnitsPerPixel), + 0.0f); if (mTransformGetter) { - gfxPoint3D newOrigin = - gfxPoint3D(NSAppUnitsToFloatPixels(mToReferenceFrame.x, aAppUnitsPerPixel), - NSAppUnitsToFloatPixels(mToReferenceFrame.y, aAppUnitsPerPixel), - 0.0f); mTransform = mTransformGetter(mFrame, aAppUnitsPerPixel); mTransform = nsLayoutUtils::ChangeMatrixBasis(newOrigin, mTransform); } else { mTransform = GetResultingTransformMatrix(mFrame, ToReferenceFrame(), aAppUnitsPerPixel); + + /** + * Shift the coorindates 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. + */ + bool hasSVGTransforms = mFrame->IsSVGTransformed(); + gfxPoint3D rounded(hasSVGTransforms ? newOrigin.x : NS_round(newOrigin.x), + hasSVGTransforms ? newOrigin.y : NS_round(newOrigin.y), + 0); + mTransform.Translate(rounded); mCachedAppUnitsPerPixel = aAppUnitsPerPixel; } } diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index 34045bdc0f77..6261ab91d7f7 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -2517,8 +2517,7 @@ private: gfxPoint3D* aToMozOrigin, gfxPoint3D* aToPerspectiveOrigin, nscoord* aChildPerspective, - nsIFrame** aOutAncestor, - bool aRecursing); + nsIFrame** aOutAncestor); nsDisplayWrapList mStoredList; gfx3DMatrix mTransform; diff --git a/layout/reftests/bugs/586683-1-ref.html b/layout/reftests/bugs/586683-1-ref.html index 84c180efcc3b..f194e07351b7 100644 --- a/layout/reftests/bugs/586683-1-ref.html +++ b/layout/reftests/bugs/586683-1-ref.html @@ -7,12 +7,14 @@ body,html { width: 100%; height: 100%; padding: 0; } position: absolute; left: 300px; top: 300px; + width: 100px; + height: 100px; -moz-transform: scale(4); - border: 1px solid #888; + border: 1px solid #888; } -
Hello
+
diff --git a/layout/reftests/bugs/586683-1.html b/layout/reftests/bugs/586683-1.html index 66fd3055c392..03502fcfe67a 100644 --- a/layout/reftests/bugs/586683-1.html +++ b/layout/reftests/bugs/586683-1.html @@ -6,19 +6,15 @@ body,html { width: 100%; height: 100%; padding: 0; } div { position: absolute; left: 300px; - top: 300px; - -moz-transform: scale(4); - border: 1px solid #888; + top: 300px; + width: 100px; + height: 100px; + -moz-transform: scale(4) perspective(1px); + border: 1px solid #888; } -
Hello
- +