Bug 1781960 - Scroll on Cmd or Ctrl + mousewheel on macOS. r=masayuki

Cmd or Ctrl + mousewheel on macOS should scroll instead of zooming the page. This new behavior will match Safari and Chrome on macOS and Firefox on Windows.

Cmd or Ctrl + horizontal mousewheel on macOS should scroll horizontally, like Safari and Chrome. The comments here mention a Left swipe+Cmd gesture, but AFAICT that gesture doesn't currently work (on my MacBook Air running macOS 12.6).

1. Set "mousewheel.with_control.action" to 1 (scroll) on macOS.

2. Stop setting "mousewheel.with_meta.action" to 3 (zoom) on macOS because we want the pref's default value 1 (scroll) from modules/libpref/init/all.js.

3. Stop setting "mousewheel.with_meta.action" to 1 (scroll) on Windows because that's pref's default value from modules/libpref/init/all.js.

4. Stop setting "mousewheel.with_control.action" to 3 (zoom) on Windows because that's pref's default value from modules/libpref/init/all.js.

5. Update the browser_mousewheel_zoom.js, browser_ext_mousewheel_zoom.js, and test_wheel_zoom_on_form_controls.html tests to re-enable mouse wheel zoom for macOS. Alternatively, I could change this test to expect scrolling instead of zooming on macOS (different from other platforms), but testing the zooming functionality for regressions seems more important than testing the mouse wheel pref's default value on macOS.

Differential Revision: https://phabricator.services.mozilla.com/D159974
This commit is contained in:
Chris Peterson 2022-11-20 03:41:22 +00:00
Родитель d05b1727e9
Коммит e20fca4319
4 изменённых файлов: 12 добавлений и 13 удалений

Просмотреть файл

@ -973,16 +973,7 @@ pref("browser.history_swipe_animation.disabled", false);
// scrolling to shift+wheel.
pref("mousewheel.with_shift.action", 1);
pref("mousewheel.with_alt.action", 2);
// On MacOS X, control+wheel is typically handled by system and we don't
// receive the event. So, command key which is the main modifier key for
// acceleration is the best modifier for zoom-in/out. However, we should keep
// the control key setting for backward compatibility.
pref("mousewheel.with_meta.action", 3); // command key on Mac
// Disable control-/meta-modified horizontal wheel events, since those are
// used on Mac as part of modified swipe gestures (e.g. Left swipe+Cmd is
// "go back" in a new tab).
pref("mousewheel.with_control.action.override_x", 0);
pref("mousewheel.with_meta.action.override_x", 0);
pref("mousewheel.with_control.action", 1);
#else
// On the other platforms (non-macOS), user may use legacy mouse which
// supports only vertical wheel but want to scroll horizontally. For such
@ -992,9 +983,8 @@ pref("browser.history_swipe_animation.disabled", false);
// is better for consistency with macOS users.
pref("mousewheel.with_shift.action", 4);
pref("mousewheel.with_alt.action", 2);
pref("mousewheel.with_meta.action", 1); // win key on Win, Super/Hyper on Linux
#endif
pref("mousewheel.with_control.action",3);
pref("mousewheel.with_win.action", 1);
pref("browser.xul.error_pages.expert_bad_cert", false);

Просмотреть файл

@ -11,6 +11,9 @@ var gTab1, gTab2, gLevel1;
function test() {
waitForExplicitFinish();
// Scroll on Ctrl + mousewheel
SpecialPowers.pushPrefEnv({ set: [["mousewheel.with_control.action", 3]] });
(async function() {
gTab1 = BrowserTestUtils.addTab(gBrowser);
gTab2 = BrowserTestUtils.addTab(gBrowser);

Просмотреть файл

@ -35,6 +35,9 @@ async function test_mousewheel_zoom(test) {
info(`Starting test of ${test} extension.`);
let browser;
// Scroll on Ctrl + mousewheel
SpecialPowers.pushPrefEnv({ set: [["mousewheel.with_control.action", 3]] });
function contentScript() {
// eslint-disable-next-line mozilla/balanced-listeners
document.addEventListener("mousedown", e => {

Просмотреть файл

@ -58,7 +58,10 @@
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(() => {
SpecialPowers.pushPrefEnv({
"set":[["test.events.async.enabled", true]]
"set":[
["mousewheel.with_control.action", 3], // Scroll on Ctrl + mousewheel
["test.events.async.enabled", true],
]
}, test)
});
</script>