Bug 607417 - Part 2: Reverse translation for fixed shadow layers. r=stechz

--HG--
extra : rebase_source : d390fd6440ccb93b3652cbd431e5f6484643114e
This commit is contained in:
Oleg Romashin 2011-04-08 09:35:13 -07:00
Родитель 7739083216
Коммит 24f8411f3d
1 изменённых файлов: 27 добавлений и 7 удалений

Просмотреть файл

@ -60,7 +60,7 @@ typedef RenderFrameParent::ViewMap ViewMap;
// Represents (affine) transforms that are calculated from a content view.
struct ViewTransform {
ViewTransform(nsIntPoint aTranslation, float aXScale, float aYScale)
ViewTransform(nsIntPoint aTranslation = nsIntPoint(0, 0), float aXScale = 1, float aYScale = 1)
: mTranslation(aTranslation)
, mXScale(aXScale)
, mYScale(aYScale)
@ -100,6 +100,13 @@ static void Scale(gfx3DMatrix& aTransform, double aXScale, double aYScale)
aTransform._22 *= aYScale;
}
static void ReverseTranslate(gfx3DMatrix& aTransform, ViewTransform& aViewTransform)
{
aTransform._41 -= aViewTransform.mTranslation.x / aViewTransform.mXScale;
aTransform._42 -= aViewTransform.mTranslation.y / aViewTransform.mYScale;
}
static void ApplyTransform(nsRect& aRect,
gfx3DMatrix& aTransform,
nscoord auPerDevPixel)
@ -256,7 +263,7 @@ BuildListForLayer(Layer* aLayer,
static void
TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader,
nsIFrame* aFrame, Layer* aLayer,
float aXScale = 1, float aYScale = 1)
ViewTransform& aTransform)
{
ShadowLayer* shadow = aLayer->AsShadowLayer();
shadow->SetShadowClipRect(aLayer->GetClipRect());
@ -274,10 +281,11 @@ TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader,
ViewTransform viewTransform = ComputeShadowTreeTransform(
aFrame, aFrameLoader, metrics, view->GetViewConfig(),
1 / aXScale, 1 / aYScale
1 / aTransform.mXScale, 1 / aTransform.mYScale
);
if (metrics->IsRootScrollable()) {
aTransform.mTranslation = viewTransform.mTranslation;
viewTransform.mTranslation += GetRootFrameOffset(aFrame, aBuilder);
}
@ -287,13 +295,24 @@ TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader,
shadowTransform = aLayer->GetTransform();
}
if (aLayer->GetIsFixedPosition() &&
!aLayer->GetParent()->GetIsFixedPosition()) {
ReverseTranslate(shadowTransform, aTransform);
const nsIntRect* clipRect = shadow->GetShadowClipRect();
if (clipRect) {
nsIntRect transformedClipRect(*clipRect);
transformedClipRect.MoveBy(shadowTransform._41, shadowTransform._42);
shadow->SetShadowClipRect(&transformedClipRect);
}
}
shadow->SetShadowTransform(shadowTransform);
aXScale *= GetXScale(shadowTransform);
aYScale *= GetYScale(shadowTransform);
aTransform.mXScale *= GetXScale(shadowTransform);
aTransform.mYScale *= GetYScale(shadowTransform);
for (Layer* child = aLayer->GetFirstChild();
child; child = child->GetNextSibling()) {
TransformShadowTree(aBuilder, aFrameLoader, aFrame, child, aXScale, aYScale);
TransformShadowTree(aBuilder, aFrameLoader, aFrame, child, aTransform);
}
}
@ -643,7 +662,8 @@ RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder,
mContainer->InsertAfter(shadowRoot, nsnull);
AssertInTopLevelChromeDoc(mContainer, aFrame);
TransformShadowTree(aBuilder, mFrameLoader, aFrame, shadowRoot);
ViewTransform transform;
TransformShadowTree(aBuilder, mFrameLoader, aFrame, shadowRoot, transform);
mContainer->SetClipRect(nsnull);
if (mFrameLoader->AsyncScrollEnabled()) {