From f6d6922fd66e31c8afe8c0e638cbdb0be45048c3 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Tue, 14 Dec 2021 17:52:56 +0000 Subject: [PATCH] Bug 1745649 - Consistently ignore wheel deltas on MayBegin and Cancelled events. r=mac-reviewers,spohl,bradwerth We're already ignoring them during APZ scroll handling. Zeroing out the deltas means that we will also ignore them for DOM wheel events. This is more consistent and works around a bug in macOS 12.1. Differential Revision: https://phabricator.services.mozilla.com/D133766 --- widget/cocoa/nsChildView.mm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 006314586f67..ae3b45b59873 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -3397,8 +3397,17 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) { if (usePreciseDeltas && hasPhaseInformation) { PanGestureInput panEvent(PanGestureTypeForEvent(theEvent), eventIntervalTime, eventTimeStamp, - position, preciseDelta, modifiers); - panEvent.SetLineOrPageDeltas(lineOrPageDelta.x, lineOrPageDelta.y); + position, ScreenPoint(), modifiers); + + // Always force zero deltas on event types that shouldn't cause any scrolling, + // so that we don't dispatch DOM wheel events for them. + bool shouldIgnoreDeltas = panEvent.mType == PanGestureInput::PANGESTURE_MAYSTART || + panEvent.mType == PanGestureInput::PANGESTURE_CANCELLED; + + if (!shouldIgnoreDeltas) { + panEvent.mPanDisplacement = preciseDelta; + panEvent.SetLineOrPageDeltas(lineOrPageDelta.x, lineOrPageDelta.y); + } if (panEvent.mType == PanGestureInput::PANGESTURE_END) { // Check if there's a momentum start event in the event queue, so that we