зеркало из https://github.com/mozilla/pjs.git
Bug 505115 - Part 11b - Layout changes to use a z component for -moz-transform-origin. r=roc
This commit is contained in:
Родитель
56aa33be88
Коммит
0c80aaf5d0
|
@ -147,6 +147,17 @@ gfx3DMatrix::Translation(float aX, float aY, float aZ)
|
|||
return matrix;
|
||||
}
|
||||
|
||||
gfx3DMatrix
|
||||
gfx3DMatrix::Translation(const gfxPoint3D& aPoint)
|
||||
{
|
||||
gfx3DMatrix matrix;
|
||||
|
||||
matrix._41 = aPoint.x;
|
||||
matrix._42 = aPoint.y;
|
||||
matrix._43 = aPoint.z;
|
||||
return matrix;
|
||||
}
|
||||
|
||||
gfx3DMatrix
|
||||
gfx3DMatrix::Scale(float aFactor)
|
||||
{
|
||||
|
|
|
@ -153,6 +153,7 @@ public:
|
|||
* \param aZ Translation on Z-axis.
|
||||
*/
|
||||
static gfx3DMatrix Translation(float aX, float aY, float aZ);
|
||||
static gfx3DMatrix Translation(const gfxPoint3D& aPoint);
|
||||
|
||||
/**
|
||||
* Create a scale matrix. Scales uniformly along all axes.
|
||||
|
|
|
@ -2298,9 +2298,9 @@ nsDisplayTransform::GetFrameBoundsForTransform(const nsIFrame* aFrame)
|
|||
* to get from (0, 0) of the frame to the transform origin.
|
||||
*/
|
||||
static
|
||||
gfxPoint GetDeltaToMozTransformOrigin(const nsIFrame* aFrame,
|
||||
float aFactor,
|
||||
const nsRect* aBoundsOverride)
|
||||
gfxPoint3D GetDeltaToMozTransformOrigin(const nsIFrame* aFrame,
|
||||
float aFactor,
|
||||
const nsRect* aBoundsOverride)
|
||||
{
|
||||
NS_PRECONDITION(aFrame, "Can't get delta for a null frame!");
|
||||
NS_PRECONDITION(aFrame->GetStyleDisplay()->HasTransform(),
|
||||
|
@ -2315,8 +2315,8 @@ gfxPoint GetDeltaToMozTransformOrigin(const nsIFrame* aFrame,
|
|||
nsDisplayTransform::GetFrameBoundsForTransform(aFrame));
|
||||
|
||||
/* Allows us to access named variables by index. */
|
||||
gfxPoint result;
|
||||
gfxFloat* coords[2] = {&result.x, &result.y};
|
||||
gfxPoint3D result;
|
||||
gfxFloat* coords[3] = {&result.x, &result.y, &result.z};
|
||||
const nscoord* dimensions[2] =
|
||||
{&boundingRect.width, &boundingRect.height};
|
||||
|
||||
|
@ -2338,6 +2338,8 @@ gfxPoint GetDeltaToMozTransformOrigin(const nsIFrame* aFrame,
|
|||
*coords[index] = NSAppUnitsToFloatPixels(coord.GetCoordValue(), aFactor);
|
||||
}
|
||||
}
|
||||
|
||||
*coords[2] = NSAppUnitsToFloatPixels(display->mTransformOrigin[2].GetCoordValue(), aFactor);
|
||||
|
||||
/* Adjust based on the origin of the rectangle. */
|
||||
result.x += NSAppUnitsToFloatPixels(boundingRect.x, aFactor);
|
||||
|
@ -2363,9 +2365,10 @@ nsDisplayTransform::GetResultingTransformMatrix(const nsIFrame* aFrame,
|
|||
/* Account for the -moz-transform-origin property by translating the
|
||||
* coordinate space to the new origin.
|
||||
*/
|
||||
gfxPoint toMozOrigin = GetDeltaToMozTransformOrigin(aFrame, aFactor, aBoundsOverride);
|
||||
gfxPoint newOrigin = gfxPoint(NSAppUnitsToFloatPixels(aOrigin.x, aFactor),
|
||||
NSAppUnitsToFloatPixels(aOrigin.y, aFactor));
|
||||
gfxPoint3D toMozOrigin = GetDeltaToMozTransformOrigin(aFrame, aFactor, aBoundsOverride);
|
||||
gfxPoint3D newOrigin = gfxPoint3D(NSAppUnitsToFloatPixels(aOrigin.x, aFactor),
|
||||
NSAppUnitsToFloatPixels(aOrigin.y, aFactor),
|
||||
0.0f);
|
||||
|
||||
/* Get the underlying transform matrix. This requires us to get the
|
||||
* bounds of the frame.
|
||||
|
|
|
@ -1002,16 +1002,14 @@ nsLayoutUtils::GetPopupFrameForEventCoordinates(nsPresContext* aPresContext,
|
|||
}
|
||||
|
||||
gfx3DMatrix
|
||||
nsLayoutUtils::ChangeMatrixBasis(const gfxPoint &aOrigin,
|
||||
nsLayoutUtils::ChangeMatrixBasis(const gfxPoint3D &aOrigin,
|
||||
const gfx3DMatrix &aMatrix)
|
||||
{
|
||||
/* These are translation matrices from world-to-origin of relative frame and
|
||||
* vice-versa. Although I could use the gfxMatrix::Translate function to
|
||||
* accomplish this, I'm hoping to reduce the overall number of matrix
|
||||
* operations by hardcoding as many of the matrices as possible.
|
||||
* vice-versa.
|
||||
*/
|
||||
gfx3DMatrix worldToOrigin = gfx3DMatrix::From2D(gfxMatrix(1.0, 0.0, 0.0, 1.0, -aOrigin.x, -aOrigin.y));
|
||||
gfx3DMatrix originToWorld = gfx3DMatrix::From2D(gfxMatrix(1.0, 0.0, 0.0, 1.0, aOrigin.x, aOrigin.y));
|
||||
gfx3DMatrix worldToOrigin = gfx3DMatrix::Translation(-aOrigin);
|
||||
gfx3DMatrix originToWorld = gfx3DMatrix::Translation(aOrigin);
|
||||
|
||||
/* Multiply all three to get the transform! */
|
||||
return worldToOrigin * aMatrix * originToWorld;
|
||||
|
|
|
@ -461,7 +461,7 @@ public:
|
|||
* @return A matrix equivalent to aMatrix, but operating in the coordinate system with
|
||||
* origin aOrigin.
|
||||
*/
|
||||
static gfx3DMatrix ChangeMatrixBasis(const gfxPoint &aOrigin, const gfx3DMatrix &aMatrix);
|
||||
static gfx3DMatrix ChangeMatrixBasis(const gfxPoint3D &aOrigin, const gfx3DMatrix &aMatrix);
|
||||
|
||||
/**
|
||||
* Find IDs corresponding to a scrollable content element in the child process.
|
||||
|
|
Загрузка…
Ссылка в новой задаче