From e75261acb52c7b367837594d666fddf07e162f2d Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Sat, 23 Apr 2022 00:13:35 +0000 Subject: [PATCH] Bug 1765782 - Hold the APZC lock while calling ScrollMetadata::ForceMousewheelAutodir(). r=tnikkel Differential Revision: https://phabricator.services.mozilla.com/D144494 --- gfx/layers/apz/src/AsyncPanZoomController.cpp | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 22b3616fec1e..eb86d888dbaf 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -2148,8 +2148,8 @@ bool AsyncPanZoomController::CanScroll(const InputData& aEvent) const { // to checking if it is scrollable without adjusting its delta. // 2. For a non-auto-dir scroll, simply check if it is scrollable without // adjusting its delta. + RecursiveMutexAutoLock lock(mRecursiveMutex); if (scrollWheelInput.IsAutoDir(mScrollMetadata.ForceMousewheelAutodir())) { - RecursiveMutexAutoLock lock(mRecursiveMutex); auto deltaX = scrollWheelInput.mDeltaX; auto deltaY = scrollWheelInput.mDeltaY; bool isRTL = @@ -2309,16 +2309,18 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel( auto deltaX = aEvent.mDeltaX; auto deltaY = aEvent.mDeltaY; ParentLayerPoint delta; - if (aEvent.IsAutoDir(mScrollMetadata.ForceMousewheelAutodir())) { - // It's an auto-dir scroll, so check if its delta should be adjusted, if so, - // adjust it. + { RecursiveMutexAutoLock lock(mRecursiveMutex); - bool isRTL = IsContentOfHonouredTargetRightToLeft( - aEvent.HonoursRoot(mScrollMetadata.ForceMousewheelAutodirHonourRoot())); - APZAutoDirWheelDeltaAdjuster adjuster(deltaX, deltaY, mX, mY, isRTL); - if (adjuster.ShouldBeAdjusted()) { - adjuster.Adjust(); - adjustedByAutoDir = true; + if (aEvent.IsAutoDir(mScrollMetadata.ForceMousewheelAutodir())) { + // It's an auto-dir scroll, so check if its delta should be adjusted, if + // so, adjust it. + bool isRTL = IsContentOfHonouredTargetRightToLeft(aEvent.HonoursRoot( + mScrollMetadata.ForceMousewheelAutodirHonourRoot())); + APZAutoDirWheelDeltaAdjuster adjuster(deltaX, deltaY, mX, mY, isRTL); + if (adjuster.ShouldBeAdjusted()) { + adjuster.Adjust(); + adjustedByAutoDir = true; + } } } // Ensure the calls to GetScrollWheelDelta are outside the mRecursiveMutex