tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 3dc4f49e5398403b28b9eaf89d6ae85d71384e16
parent a59f4a3ef71e320c22843bc9643d7669d28857cb
Author: Hiroyuki Ikezoe <hikezoe.birchill@mozilla.com>
Date:   Sun, 30 Nov 2025 22:07:18 +0000

Bug 2000114 - Pack two boolean arguments for NotifyLayersUpdated into a single struct. r=botond

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

Diffstat:
Mgfx/layers/apz/src/APZCTreeManager.cpp | 7+++++--
Mgfx/layers/apz/src/AsyncPanZoomController.cpp | 26++++++++++++++------------
Mgfx/layers/apz/src/AsyncPanZoomController.h | 19++++++++++++-------
Mgfx/layers/apz/test/gtest/TestBasic.cpp | 73++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------
Mgfx/layers/apz/test/gtest/TestEventResult.cpp | 7+++++--
Mgfx/layers/apz/test/gtest/TestOverscroll.cpp | 40++++++++++++++++++++++++++--------------
6 files changed, 112 insertions(+), 60 deletions(-)

diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -1332,8 +1332,11 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer( apzc.get(), aLayer.GetLayer(), uint64_t(aLayersId), aMetrics.GetScrollId()); - apzc->NotifyLayersUpdated(aLayer.Metadata(), aLayer.IsFirstPaint(), - aLayersId == aState.mOriginatingLayersId); + apzc->NotifyLayersUpdated( + aLayer.Metadata(), AsyncPanZoomController::LayersUpdateFlags{ + .mIsFirstPaint = aLayer.IsFirstPaint(), + .mThisLayerTreeUpdated = + (aLayersId == aState.mOriginatingLayersId)}); // Since this is the first time we are encountering an APZC with this guid, // the node holding it must be the primary holder. It may be newly-created diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -5522,8 +5522,8 @@ void AsyncPanZoomController::FlushActiveCheckerboardReport() { } void AsyncPanZoomController::NotifyLayersUpdated( - const ScrollMetadata& aScrollMetadata, bool aIsFirstPaint, - bool aThisLayerTreeUpdated) { + const ScrollMetadata& aScrollMetadata, + LayersUpdateFlags aLayersUpdateFlags) { AssertOnUpdaterThread(); RecursiveMutexAutoLock lock(mRecursiveMutex); @@ -5566,20 +5566,21 @@ void AsyncPanZoomController::NotifyLayersUpdated( mScrollMetadata.SetScrollParentId(aScrollMetadata.GetScrollParentId()); APZC_LOGV_FM(aLayerMetrics, - "%p got a NotifyLayersUpdated with aIsFirstPaint=%d, " - "aThisLayerTreeUpdated=%d", - this, aIsFirstPaint, aThisLayerTreeUpdated); + "%p got a NotifyLayersUpdated with mIsFirstPaint=%d, " + "mThisLayerTreeUpdated=%d", + this, aLayersUpdateFlags.mIsFirstPaint, + aLayersUpdateFlags.mThisLayerTreeUpdated); { // scope lock MutexAutoLock lock(mCheckerboardEventLock); if (mCheckerboardEvent && mCheckerboardEvent->IsRecordingTrace()) { std::string str; - if (aThisLayerTreeUpdated) { + if (aLayersUpdateFlags.mThisLayerTreeUpdated) { if (!aLayerMetrics.GetPaintRequestTime().IsNull()) { // Note that we might get the paint request time as non-null, but with - // aThisLayerTreeUpdated false. That can happen if we get a layer + // mThisLayerTreeUpdated false. That can happen if we get a layer // transaction from a different process right after we get the layer - // transaction with aThisLayerTreeUpdated == true. In this case we + // transaction with mThisLayerTreeUpdated == true. In this case we // want to ignore the paint request time because it was already dumped // in the previous layer transaction. TimeDuration paintTime = @@ -5618,8 +5619,9 @@ void AsyncPanZoomController::NotifyLayersUpdated( bool viewportSizeUpdated = false; bool needToReclampScroll = false; - if ((aIsFirstPaint && aThisLayerTreeUpdated) || isDefault || - Metrics().IsRootContent() != aLayerMetrics.IsRootContent()) { + if ((aLayersUpdateFlags.mIsFirstPaint && + aLayersUpdateFlags.mThisLayerTreeUpdated) || + isDefault || Metrics().IsRootContent() != aLayerMetrics.IsRootContent()) { if (Metrics().IsRootContent() && !aLayerMetrics.IsRootContent()) { // We only support zooming on root content APZCs SetZoomAnimationId(Nothing()); @@ -6009,7 +6011,7 @@ void AsyncPanZoomController::NotifyLayersUpdated( } } - if (aIsFirstPaint || needToReclampScroll) { + if (aLayersUpdateFlags.mIsFirstPaint || needToReclampScroll) { // The scrollable rect or composition bounds may have changed in a way that // makes our local scroll offset out of bounds, so clamp it. ClampAndSetVisualScrollOffset(Metrics().GetVisualScrollOffset()); @@ -6148,7 +6150,7 @@ void AsyncPanZoomController::NotifyLayersUpdated( } } } - if (aIsFirstPaint || needToReclampScroll) { + if (aLayersUpdateFlags.mIsFirstPaint || needToReclampScroll) { for (auto& sampledState : mSampledState) { sampledState.ClampVisualScrollOffset(Metrics()); } diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -283,16 +283,21 @@ class AsyncPanZoomController { // These methods must only be called on the updater thread. // + struct LayersUpdateFlags { + // Passed from the WebRender scroll data code indicating that the scroll + // metadata being sent with this call are the initial metadata and the + // initial paint of the frame has just happened. + bool mIsFirstPaint : 1; + // Whether this update was triggered by a paint for the LayersId (tab) + // containing this scroll frame. + bool mThisLayerTreeUpdated : 1; + }; /** - * A shadow layer update has arrived. |aScrollMetdata| is the new - * ScrollMetadata for the container layer corresponding to this APZC. - * |aIsFirstPaint| is a flag passed from the shadow - * layers code indicating that the scroll metadata being sent with this call - * are the initial metadata and the initial paint of the frame has just - * happened. + * A WebRender scroll data has arrived. |aScrollMetdata| is the new + * ScrollMetadata for the scroll container corresponding to this APZC. */ void NotifyLayersUpdated(const ScrollMetadata& aScrollMetadata, - bool aIsFirstPaint, bool aThisLayerTreeUpdated); + LayersUpdateFlags aLayersUpdateFlags); /** * The platform implementation must set the compositor controller so that we diff --git a/gfx/layers/apz/test/gtest/TestBasic.cpp b/gfx/layers/apz/test/gtest/TestBasic.cpp @@ -11,6 +11,8 @@ #include "mozilla/ScrollPositionUpdate.h" #include "mozilla/layers/ScrollableLayerGuid.h" +using LayersUpdateFlags = AsyncPanZoomController::LayersUpdateFlags; + TEST_F(APZCBasicTester, Overzoom) { // the visible area of the document in CSS pixels is x=10 y=0 w=100 h=100 FrameMetrics fm; @@ -139,14 +141,18 @@ TEST_F(APZCBasicTester, ComplexTransform) { // initial transform apzc->SetFrameMetrics(metrics); - apzc->NotifyLayersUpdated(metadata, true, true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = true, .mThisLayerTreeUpdated = true}); apzc->SampleContentTransformForFrame(&viewTransformOut, pointOut); EXPECT_EQ(AsyncTransform(LayerToParentLayerScale(1), ParentLayerPoint()), viewTransformOut); EXPECT_EQ(ParentLayerPoint(60, 60), pointOut); childApzc->SetFrameMetrics(childMetrics); - childApzc->NotifyLayersUpdated(childMetadata, true, true); + childApzc->NotifyLayersUpdated( + childMetadata, + LayersUpdateFlags{.mIsFirstPaint = true, .mThisLayerTreeUpdated = true}); childApzc->SampleContentTransformForFrame(&viewTransformOut, pointOut); EXPECT_EQ(AsyncTransform(LayerToParentLayerScale(1), ParentLayerPoint()), viewTransformOut); @@ -238,7 +244,9 @@ TEST_F(APZCBasicTester, ResumeInterruptedTouchDrag_Bug1592435) { metadata.SetScrollUpdates(scrollUpdates); metadata.GetMetrics().SetScrollGeneration( scrollUpdates.LastElement().GetGeneration()); - apzc->NotifyLayersUpdated(metadata, false, true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); // Continue and finish the touch-drag gesture. for (int i = 0; i < 20; ++i) { @@ -264,7 +272,9 @@ TEST_F(APZCBasicTester, ResumeInterruptedTouchDrag_Bug1592435) { metadata.GetMetrics().SetVisualScrollUpdateType(FrameMetrics::eMainThread); scrollUpdates.Clear(); metadata.SetScrollUpdates(scrollUpdates); - apzc->NotifyLayersUpdated(metadata, false, true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); for (int i = 0; i < 20; ++i) { touchPos.y -= 1; mcc->AdvanceByMillis(1); @@ -302,8 +312,9 @@ TEST_F(APZCBasicTester, RelativeScrollOffset) { mainThreadMetadata.SetScrollUpdates(scrollUpdates); mainThreadMetrics.SetScrollGeneration( scrollUpdates.LastElement().GetGeneration()); - apzc->NotifyLayersUpdated(mainThreadMetadata, /*isFirstPaint=*/false, - /*thisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated( + mainThreadMetadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); // Check that the relative offset has been preserved. metrics = apzc->GetFrameMetrics(); @@ -344,8 +355,9 @@ TEST_F(APZCBasicTester, MultipleSmoothScrollsSmooth) { metadata2.SetScrollUpdates(scrollUpdates2); metadata2.GetMetrics().SetScrollGeneration( scrollUpdates2.LastElement().GetGeneration()); - apzc->NotifyLayersUpdated(metadata2, /*isFirstPaint=*/false, - /*thisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated( + metadata2, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); // Get the animation going for (uint32_t i = 0; i < 3; i++) { @@ -376,8 +388,9 @@ TEST_F(APZCBasicTester, MultipleSmoothScrollsSmooth) { metadata3.SetScrollUpdates(scrollUpdates3); metadata3.GetMetrics().SetScrollGeneration( scrollUpdates3.LastElement().GetGeneration()); - apzc->NotifyLayersUpdated(metadata3, /*isFirstPaint=*/false, - /*thisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated(metadata3, + LayersUpdateFlags{.mIsFirstPaint = false, + .mThisLayerTreeUpdated = true}); } for (uint32_t j = 0; j < 7; j++) { @@ -421,8 +434,9 @@ TEST_F(APZCBasicTester, NotifyLayersUpdate_WithScrollUpdate) { metrics.SetLayoutViewport(CSSRect(15, 15, 10, 10)); // It's not first-paint when switching tab. - apzc->NotifyLayersUpdated(metadata, /*isFirstPaint=*/false, - /*thisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); // The layout/visual scroll ofsets and the relative scroll update need to be // reflected. @@ -462,8 +476,9 @@ TEST_F(APZCBasicTester, NotifyLayersUpdate_WithMultipleScrollUpdates) { metrics.SetLayoutViewport(CSSRect(20, 20, 10, 10)); // It's not first-paint when switching tab. - apzc->NotifyLayersUpdated(metadata, /*isFirstPaint=*/false, - /*thisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); // The layout/visual scroll ofsets and the relative scroll update need to be // reflected. @@ -495,7 +510,9 @@ class APZCSmoothScrollTester : public APZCBasicTester { CSSPoint::ToAppUnits(CSSPoint(0, 1000)))); metadata.SetScrollUpdates(scrollUpdates); metrics.SetScrollGeneration(scrollUpdates.LastElement().GetGeneration()); - apzc->NotifyLayersUpdated(metadata, false, true); + apzc->NotifyLayersUpdated(metadata, + LayersUpdateFlags{.mIsFirstPaint = false, + .mThisLayerTreeUpdated = true}); // Sample the smooth scroll animation until we get past y=500. apzc->AssertInSmoothScroll(); @@ -512,7 +529,9 @@ class APZCSmoothScrollTester : public APZCBasicTester { CSSPoint::ToAppUnits(CSSPoint(0, 100)))); metadata.SetScrollUpdates(scrollUpdates); metrics.SetScrollGeneration(scrollUpdates.LastElement().GetGeneration()); - apzc->NotifyLayersUpdated(metadata, false, false); + apzc->NotifyLayersUpdated( + metadata, LayersUpdateFlags{.mIsFirstPaint = false, + .mThisLayerTreeUpdated = false}); // Verify the relative scroll was applied but didn't cancel the animation. float y2 = apzc->GetFrameMetrics().GetVisualScrollOffset().y; @@ -572,7 +591,9 @@ class APZCSmoothScrollTester : public APZCBasicTester { CSSPoint::ToAppUnits(CSSPoint(0, 300)))); metadata.SetScrollUpdates(scrollUpdates); metrics.SetScrollGeneration(scrollUpdates.LastElement().GetGeneration()); - apzc->NotifyLayersUpdated(metadata, false, true); + apzc->NotifyLayersUpdated(metadata, + LayersUpdateFlags{.mIsFirstPaint = false, + .mThisLayerTreeUpdated = true}); // Check that the content shift was applied but didn't cancel the animation. // At this point, the animation's internal state should be targeting a @@ -634,7 +655,9 @@ class APZCSmoothScrollTester : public APZCBasicTester { CSSPoint::ToAppUnits(CSSPoint(0, 1200)))); metadata.SetScrollUpdates(scrollUpdates); metrics.SetScrollGeneration(scrollUpdates.LastElement().GetGeneration()); - apzc->NotifyLayersUpdated(metadata, false, true); + apzc->NotifyLayersUpdated(metadata, + LayersUpdateFlags{.mIsFirstPaint = false, + .mThisLayerTreeUpdated = true}); float y2 = apzc->GetFrameMetrics().GetVisualScrollOffset().y; ASSERT_EQ(y2, y + 1000); apzc->AssertInWheelScroll(); @@ -883,8 +906,9 @@ TEST_F(APZCBasicTester, ZoomAndScrollableRectChangeAfterZoomChange) { // Change the scrollable rect slightly to trigger a reclamp. ScrollMetadata metadata2 = metadata; metadata2.GetMetrics().SetScrollableRect(CSSRect(0, 0, 100, 1000.2)); - apzc->NotifyLayersUpdated(metadata2, /*isFirstPaint=*/false, - /*thisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated( + metadata2, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); float newOffset = apzc->GetCurrentAsyncScrollOffset(AsyncPanZoomController::eForCompositing) @@ -936,8 +960,9 @@ TEST_F(APZCBasicTester, ZoomToRectAndCompositionBoundsChange) { // mCompositionBoundsWidthIgnoringScrollbars unchanged. ScrollMetadata metadata2 = metadata; metadata2.GetMetrics().SetCompositionBounds(ParentLayerRect(0, 0, 90, 100)); - apzc->NotifyLayersUpdated(metadata2, /*isFirstPaint=*/false, - /*thisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated( + metadata2, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); float scale = apzc->GetCurrentPinchZoomScale(AsyncPanZoomController::eForCompositing) @@ -1049,7 +1074,9 @@ TEST_F(APZCFrameTimeTester, ImmediatelyInterruptedSmoothScroll_Bug1984589) { nullptr, ViewportType::Layout)); metadata.SetScrollUpdates(scrollUpdates); metrics.SetScrollGeneration(scrollUpdates.LastElement().GetGeneration()); - apzc->NotifyLayersUpdated(metadata, false, true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); // Sample smooth scroll animations until they complete, // and assert that at no point does the scroll position leave (0, 900). diff --git a/gfx/layers/apz/test/gtest/TestEventResult.cpp b/gfx/layers/apz/test/gtest/TestEventResult.cpp @@ -11,6 +11,8 @@ #include "mozilla/layers/LayersTypes.h" #include <tuple> +using LayersUpdateFlags = AsyncPanZoomController::LayersUpdateFlags; + class APZEventResultTester : public APZCTreeManagerTester { protected: UniquePtr<ScopedLayerTreeRegistration> registration; @@ -36,8 +38,9 @@ class APZEventResultTester : public APZCTreeManagerTester { metadata.SetScrollUpdates(scrollUpdates); metadata.GetMetrics().SetScrollGeneration( scrollUpdates.LastElement().GetGeneration()); - apzc->NotifyLayersUpdated(metadata, /*aIsFirstPaint=*/false, - /*aThisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated(metadata, + LayersUpdateFlags{.mIsFirstPaint = false, + .mThisLayerTreeUpdated = true}); } void CreateScrollableRootLayer() { diff --git a/gfx/layers/apz/test/gtest/TestOverscroll.cpp b/gfx/layers/apz/test/gtest/TestOverscroll.cpp @@ -14,6 +14,8 @@ #include "InputUtils.h" +using LayersUpdateFlags = AsyncPanZoomController::LayersUpdateFlags; + class APZCOverscrollTester : public APZCBasicTester { public: explicit APZCOverscrollTester( @@ -672,8 +674,9 @@ TEST_F(APZCOverscrollTester, DisallowOverscrollInSingleLineTextControl) { metrics.SetScrollableRect(CSSRect(0, 0, 1000, 10)); apzc->SetFrameMetrics(metrics); metadata.SetDisregardedDirection(Some(ScrollDirection::eVertical)); - apzc->NotifyLayersUpdated(metadata, /*aIsFirstPaint=*/false, - /*aThisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); // Try to overscroll up and left with pan gestures. PanGesture(PanGestureInput::PANGESTURE_START, apzc, ScreenIntPoint(50, 5), @@ -1514,7 +1517,9 @@ TEST_F(APZCOverscrollTester, DynamicallyLoadingContent) { CSSRect scrollableRect = metrics.GetScrollableRect(); scrollableRect.height += 500; metrics.SetScrollableRect(scrollableRect); - apzc->NotifyLayersUpdated(metadata, false, true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); // Check that the modified scrollable rect cleared the overscroll. EXPECT_FALSE(apzc->IsOverscrolled()); @@ -1535,7 +1540,9 @@ TEST_F(APZCOverscrollTester, DynamicallyLoadingContent) { scrollableRect = metrics.GetScrollableRect(); scrollableRect.height += 500; metrics.SetScrollableRect(scrollableRect); - apzc->NotifyLayersUpdated(metadata, false, true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); // Check that the modified scrollable rect did NOT clear overscroll at the // top. @@ -2169,8 +2176,9 @@ TEST_F(APZCOverscrollTester, FillOutGutterWhilePanning) { metadata.SetScrollUpdates(scrollUpdates); metadata.GetMetrics().SetScrollGeneration( scrollUpdates.LastElement().GetGeneration()); - apzc->NotifyLayersUpdated(metadata, /*aIsFirstPaint=*/false, - /*aThisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); CSSPoint scrollOffset = metadata.GetMetrics().GetLayoutScrollOffset(); @@ -2186,8 +2194,9 @@ TEST_F(APZCOverscrollTester, FillOutGutterWhilePanning) { const CSSRect& scrollableRect = metrics.GetScrollableRect(); metrics.SetScrollableRect(scrollableRect + CSSSize(0, scrollableRect.height + 10)); - apzc->NotifyLayersUpdated(metadata, /*aIsFirstPaint=*/false, - /*aThisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); // Now that the scroll position was shifted with the overscroll amount. EXPECT_EQ(apzc->GetScrollMetadata().GetMetrics().GetVisualScrollOffset().y, @@ -2211,8 +2220,9 @@ TEST_F(APZCOverscrollTester, FillOutGutterWhileAnimating) { metadata.SetScrollUpdates(scrollUpdates); metadata.GetMetrics().SetScrollGeneration( scrollUpdates.LastElement().GetGeneration()); - apzc->NotifyLayersUpdated(metadata, /*aIsFirstPaint=*/false, - /*aThisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); CSSPoint scrollOffset = metadata.GetMetrics().GetLayoutScrollOffset(); @@ -2241,8 +2251,9 @@ TEST_F(APZCOverscrollTester, FillOutGutterWhileAnimating) { const CSSRect& scrollableRect = metrics.GetScrollableRect(); metrics.SetScrollableRect(scrollableRect + CSSSize(0, scrollableRect.height + 10)); - apzc->NotifyLayersUpdated(metadata, /*aIsFirstPaint=*/false, - /*aThisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); // Now that the scroll position was shifted with the overscroll amount. EXPECT_EQ(apzc->GetScrollMetadata().GetMetrics().GetVisualScrollOffset().y, @@ -2268,8 +2279,9 @@ TEST_F(APZCOverscrollTester, ProgrammaticScroll) { metadata.SetScrollUpdates(scrollUpdates); metadata.GetMetrics().SetScrollGeneration( scrollUpdates.LastElement().GetGeneration()); - apzc->NotifyLayersUpdated(metadata, /*aIsFirstPaint=*/false, - /*aThisLayerTreeUpdated=*/true); + apzc->NotifyLayersUpdated( + metadata, + LayersUpdateFlags{.mIsFirstPaint = false, .mThisLayerTreeUpdated = true}); apzc->AssertInSmoothMsdScroll();