From 3783cb10b6c7f55d32b26bed51a2fb61c5ae9d21 Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Mon, 6 Feb 2023 23:16:58 +0000 Subject: [PATCH] Bug 1554795 - Expose the currently effective visual viewport rect. r=hiro Similar to the other GetCurrentAsync*() functions, GetCurrentAsyncVisualViewport() takes into account the async test attributes as well as the frame delay. It supersedes GetCurrentAsyncScrollOffsetInCSSPixels() which can be obtained as the the TopLeft() of the visual viewport rect. Differential Revision: https://phabricator.services.mozilla.com/D163148 --- gfx/layers/apz/src/APZCTreeManager.cpp | 5 +++-- gfx/layers/apz/src/APZSampler.cpp | 5 +++-- gfx/layers/apz/src/AsyncPanZoomController.cpp | 7 +++++-- gfx/layers/apz/src/AsyncPanZoomController.h | 9 ++++----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index 8ca8810f298a..04d232bfebea 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -760,8 +760,9 @@ void APZCTreeManager::SampleForWebRender(const Maybe& aVsyncId, auto it = mTestData.find(guid.mLayersId); if (it != mTestData.end()) { it->second->RecordSampledResult( - apzc->GetCurrentAsyncScrollOffsetInCssPixels( - AsyncPanZoomController::eForCompositing), + apzc->GetCurrentAsyncVisualViewport( + AsyncPanZoomController::eForCompositing) + .TopLeft(), (aSampleTime.Time() - TimeStamp::ProcessCreation()) .ToMicroseconds(), guid.mLayersId, guid.mScrollId); diff --git a/gfx/layers/apz/src/APZSampler.cpp b/gfx/layers/apz/src/APZSampler.cpp index 2f9bb0f0eee2..088fb6f7a09b 100644 --- a/gfx/layers/apz/src/APZSampler.cpp +++ b/gfx/layers/apz/src/APZSampler.cpp @@ -161,8 +161,9 @@ APZSampler::GetCurrentScrollOffsetAndRange( // FIXME: Use the one-frame delayed offset now. This doesn't take // scroll-linked effets into accounts, so we have to fix this in the // future. - apzc->GetCurrentAsyncScrollOffsetInCssPixels( - AsyncPanZoomController::AsyncTransformConsumer::eForCompositing), + apzc->GetCurrentAsyncVisualViewport( + AsyncPanZoomController::AsyncTransformConsumer::eForCompositing) + .TopLeft(), apzc->GetCurrentScrollRangeInCssPixels()}); } diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index f44629a3ba33..83f9451eb838 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -4767,12 +4767,15 @@ ParentLayerPoint AsyncPanZoomController::GetCurrentAsyncScrollOffset( return GetEffectiveScrollOffset(aMode, lock) * GetEffectiveZoom(aMode, lock); } -CSSPoint AsyncPanZoomController::GetCurrentAsyncScrollOffsetInCssPixels( +CSSRect AsyncPanZoomController::GetCurrentAsyncVisualViewport( AsyncTransformConsumer aMode) const { RecursiveMutexAutoLock lock(mRecursiveMutex); AutoApplyAsyncTestAttributes testAttributeApplier(this, lock); - return GetEffectiveScrollOffset(aMode, lock); + return CSSRect( + GetEffectiveScrollOffset(aMode, lock), + FrameMetrics::CalculateCompositedSizeInCssPixels( + Metrics().GetCompositionBounds(), GetEffectiveZoom(aMode, lock))); } AsyncTransform AsyncPanZoomController::GetCurrentAsyncTransform( diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index ead0f8956e9c..0812df299293 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -1184,12 +1184,11 @@ class AsyncPanZoomController { AsyncTransformConsumer aMode) const; /** - * Get the current scroll offset of the scrollable frame corresponding - * to this APZC, including the effects of any asynchronous panning, in - * CSS pixels. + * Get the current visual viewport of the scrollable frame corresponding + * to this APZC, including the effects of any asynchronous panning and + * zooming, in CSS pixels. */ - CSSPoint GetCurrentAsyncScrollOffsetInCssPixels( - AsyncTransformConsumer aMode) const; + CSSRect GetCurrentAsyncVisualViewport(AsyncTransformConsumer aMode) const; /** * Return a visual effect that reflects this apzc's