From c65a7204c6b99423197f29e201b09de65693aea8 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Wed, 26 Oct 2011 16:20:08 +1300 Subject: [PATCH] Bug 695832 - Perpsective origin offset should be relative to the transform origin. r=roc --- layout/base/nsDisplayList.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 7caf4ee9f41..a37f65f4254 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -2466,13 +2466,6 @@ gfxPoint3D GetDeltaToMozPerspectiveOrigin(const nsIFrame* aFrame, *coords[index] = NSAppUnitsToFloatPixels(coord.GetCoordValue(), aFactor); } } - - /** - * An offset of (0,0) results in the perspective-origin being at the centre of the element, - * so include a shift of the centre point to (0,0). - */ - result.x -= NSAppUnitsToFloatPixels(boundingRect.width, aFactor)/2; - result.y -= NSAppUnitsToFloatPixels(boundingRect.height, aFactor)/2; return result; } @@ -2535,7 +2528,10 @@ nsDisplayTransform::GetResultingTransformMatrix(const nsIFrame* aFrame, perspective._34 = -1.0 / NSAppUnitsToFloatPixels(parentDisp->mChildPerspective.GetCoordValue(), aFactor); - result = result * nsLayoutUtils::ChangeMatrixBasis(toPerspectiveOrigin, perspective); + /* At the point when perspective is applied, we have been translated to the transform origin. + * The translation to the perspective origin is the difference between these values. + */ + result = result * nsLayoutUtils::ChangeMatrixBasis(toPerspectiveOrigin - toMozOrigin, perspective); } if (aFrame->Preserves3D() && nsLayoutUtils::Are3DTransformsEnabled()) {