Bug 1503616 - Use the zoom animation instead of the PinchZoom API to implement async zooming. r=botond

This allows us to apply a zoom on a subset of the WR display list (the part
that is inside the stacking context with the animation property), rather
than applying globally to everything. Since the semantics of APZ zooming
is that it applies to the root content document, this results in more
correct behaviour, particularly with respect to clips from the
chrome-process document which now don't get zoomed but did before.

Depends on D11181

Differential Revision: https://phabricator.services.mozilla.com/D11182

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kartikaya Gupta 2018-11-09 21:13:28 +00:00
Родитель 9a0b69bfb3
Коммит 13567d6f63
1 изменённых файлов: 10 добавлений и 5 удалений

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

@ -614,6 +614,8 @@ APZCTreeManager::SampleForWebRender(wr::TransactionWrapper& aTxn,
AssertOnSamplerThread();
MutexAutoLock lock(mMapLock);
nsTArray<wr::WrTransformProperty> transforms;
// Sample async transforms on scrollable layers.
for (const auto& mapping : mApzcMap) {
AsyncPanZoomController* apzc = mapping.second;
@ -625,9 +627,13 @@ APZCTreeManager::SampleForWebRender(wr::TransactionWrapper& aTxn,
ParentLayerPoint layerTranslation = apzc->GetCurrentAsyncTransform(
AsyncPanZoomController::eForCompositing).mTranslation;
LayoutDeviceToParentLayerScale zoom;
if (apzc->Metrics().IsRootContent()) {
if (Maybe<uint64_t> zoomAnimationId = apzc->GetZoomAnimationId()) {
// for now we only support zooming on root content APZCs
MOZ_ASSERT(apzc->Metrics().IsRootContent());
zoom = apzc->GetCurrentPinchZoomScale(AsyncPanZoomController::eForCompositing);
aTxn.UpdatePinchZoom(zoom.scale);
transforms.AppendElement(wr::ToWrTransformProperty(
*zoomAnimationId,
Matrix4x4::Scaling(zoom.scale, zoom.scale, 1.0f)));
}
// The positive translation means the painted content is supposed to
@ -644,7 +650,6 @@ APZCTreeManager::SampleForWebRender(wr::TransactionWrapper& aTxn,
}
// Now collect all the async transforms needed for the scrollthumbs.
nsTArray<wr::WrTransformProperty> scrollbarTransforms;
for (const ScrollThumbInfo& info : mScrollThumbInfo) {
auto it = mApzcMap.find(info.mTargetGuid);
if (it == mApzcMap.end()) {
@ -667,11 +672,11 @@ APZCTreeManager::SampleForWebRender(wr::TransactionWrapper& aTxn,
info.mTargetIsAncestor,
nullptr);
});
scrollbarTransforms.AppendElement(wr::ToWrTransformProperty(
transforms.AppendElement(wr::ToWrTransformProperty(
info.mThumbAnimationId,
transform));
}
aTxn.AppendTransformProperties(scrollbarTransforms);
aTxn.AppendTransformProperties(transforms);
// Advance animations. It's important that this happens after
// sampling all async transforms, because AdvanceAnimations() updates