Bug 1091296 - When applying the APZ transform on a layer, make sure not to clobber any existing OMTA transform. r=mattwoodrow

--HG--
extra : rebase_source : 9662fbdea917d63a1205660979cbb5c6f861ba02
This commit is contained in:
Kartikaya Gupta 2014-11-11 10:54:02 -05:00
parent 86f9a0d9d3
commit 9559bab90f

View File

@ -544,7 +544,7 @@ SampleAPZAnimations(const LayerMetricsWrapper& aLayer, TimeStamp aSampleTime)
}
Matrix4x4
AdjustAndCombineWithCSSTransform(const Matrix4x4& asyncTransform, Layer* aLayer)
AdjustForClip(const Matrix4x4& asyncTransform, Layer* aLayer)
{
Matrix4x4 result = asyncTransform;
@ -559,9 +559,6 @@ AdjustAndCombineWithCSSTransform(const Matrix4x4& asyncTransform, Layer* aLayer)
result.ChangeBasis(shadowClipRect->x, shadowClipRect->y, 0);
}
}
// Combine the async transform with the layer's CSS transform.
result = aLayer->GetTransform() * result;
return result;
}
@ -622,10 +619,12 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer)
}
if (hasAsyncTransform) {
// Apply the APZ transform on top of GetLocalTransform() here (rather than
// GetTransform()) in case the OMTA code in SampleAnimations already set a
// shadow transform; in that case we want to apply ours on top of that one
// rather than clobber it.
SetShadowTransform(aLayer,
AdjustAndCombineWithCSSTransform(combinedAsyncTransform, aLayer));
NS_ASSERTION(!aLayer->AsLayerComposite()->GetShadowTransformSetByAnimation(),
"overwriting animated transform!");
aLayer->GetLocalTransform() * AdjustForClip(combinedAsyncTransform, aLayer));
const FrameMetrics& bottom = LayerMetricsWrapper::BottommostScrollableMetrics(aLayer);
MOZ_ASSERT(bottom.IsScrollable()); // must be true because hasAsyncTransform is true
@ -638,15 +637,18 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer)
oldTransform.PreScale(resolution.scale, resolution.scale, 1);
// For the purpose of aligning fixed and sticky layers, we disregard
// the overscroll transform when computing the 'aCurrentTransformForRoot'
// parameter. This ensures that the overscroll transform is not unapplied,
// and therefore that the visual effect applies to fixed and sticky layers.
Matrix4x4 transformWithoutOverscroll = AdjustAndCombineWithCSSTransform(
combinedAsyncTransformWithoutOverscroll, aLayer);
// the overscroll transform as well as any OMTA transform when computing the
// 'aCurrentTransformForRoot' parameter. This ensures that the overscroll
// and OMTA transforms are not unapplied, and therefore that the visual
// effects apply to fixed and sticky layers. We do this by using
// GetTransform() as the base transform rather than GetLocalTransform(),
// which would include those factors.
Matrix4x4 transformWithoutOverscrollOrOmta = aLayer->GetTransform() *
AdjustForClip(combinedAsyncTransformWithoutOverscroll, aLayer);
// Since fixed/sticky layers are relative to their nearest scrolling ancestor,
// we use the ViewID from the bottommost scrollable metrics here.
AlignFixedAndStickyLayers(aLayer, aLayer, bottom.GetScrollId(), oldTransform,
transformWithoutOverscroll, fixedLayerMargins);
transformWithoutOverscrollOrOmta, fixedLayerMargins);
appliedTransform = true;
}