Bug 1673728 - Default to adding phase information to the synthesized scroll events on macOS. r=tnikkel

This causes the generated scroll events to be turned into PanGestureInput events
instead of ScrollWheelInput events. This exercises different codepaths that are
more representative of real-world behaviour on mac laptops. This patch also
allows a pref to flip the behaviour back to the old behaviour of triggering
ScrollWheelInputs, since in some cases we may want to test that behaviour
explicitly.

Depends on D95320

Differential Revision: https://phabricator.services.mozilla.com/D95321
This commit is contained in:
Kartikaya Gupta 2020-10-30 18:33:54 +00:00
parent e81dabfa00
commit 719ed26689
3 changed files with 17 additions and 2 deletions

View File

@ -33,7 +33,14 @@ function nativeVerticalWheelEventMsg() {
case "windows":
return 0x020a; // WM_MOUSEWHEEL
case "mac":
return 0; // value is unused, can be anything
var useWheelCodepath = SpecialPowers.getBoolPref(
"apz.test.mac.synth_wheel_input",
false
);
// Default to 1 (kCGScrollPhaseBegan) to trigger PanGestureInput events
// from widget code. Allow setting a pref to override this behaviour and
// trigger ScrollWheelInput events instead.
return useWheelCodepath ? 0 : 1;
case "linux":
return 4; // value is unused, pass GDK_SCROLL_SMOOTH anyway
}

View File

@ -125,7 +125,11 @@ SimpleTest.waitForExplicitFinish();
// Disable smooth scrolling because it makes the test flaky (we don't have a good
// way of detecting when the scrolling is finished).
pushPrefs([["general.smoothScroll", false]])
// Also, on macOS, force the native events to be wheel inputs rather than pan
// inputs since this test is specifically testing things related to wheel
// transactions.
pushPrefs([["general.smoothScroll", false],
["apz.test.mac.synth_wheel_input", true]])
.then(waitUntilApzStable)
.then(runContinuation(test))
.then(SimpleTest.finish, SimpleTest.finishWithFailure);

View File

@ -947,6 +947,10 @@ nsresult nsChildView::SynthesizeNativeMouseScrollEvent(
return NS_ERROR_FAILURE;
}
if (aNativeMessage) {
CGEventSetIntegerValueField(cgEvent, kCGScrollWheelEventScrollPhase, aNativeMessage);
}
// On macOS 10.14 and up CGEventPost won't work because of changes in macOS
// to improve security. This code makes an NSEvent corresponding to the
// wheel event and dispatches it directly to the scrollWheel handler. Some