Bug 793132 - Make sure that only display lists get the reference frame adjusted transform. r=roc

This commit is contained in:
Matt Woodrow 2012-09-26 10:47:41 +12:00
parent 1cfc227122
commit 84cb2c3529
4 changed files with 30 additions and 31 deletions

View File

@ -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;
}
}

View File

@ -2517,8 +2517,7 @@ private:
gfxPoint3D* aToMozOrigin,
gfxPoint3D* aToPerspectiveOrigin,
nscoord* aChildPerspective,
nsIFrame** aOutAncestor,
bool aRecursing);
nsIFrame** aOutAncestor);
nsDisplayWrapList mStoredList;
gfx3DMatrix mTransform;

View File

@ -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;
}
</style>
</head>
<body>
<div id="scale">Hello<div style="width:1px; height:1px; background:white;"></div></div>
<div id="scale"></div>
</body>
</html>

View File

@ -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;
}
</style>
</head>
<body>
<div>Hello<canvas width="1" height="1" id="c" style="display:block"></canvas></div>
<script>
var c = document.getElementById("c");
var ctx = c.getContext("2d");
ctx.fillStyle = "white";
ctx.fillRect(0, 0, 1, 1);
</script>
<div></div>
</body></html>