Bug 819252 WheelEvent along x-axis with a modifier key on Mac shouldn't cause zoom action for not preventing following horizontal swip event which will cause going back/forward in the history r=smaug+smichaud

This commit is contained in:
Masayuki Nakano 2013-01-05 21:14:27 +09:00
parent 58f2c34d5f
commit dfe3307bf9
3 changed files with 41 additions and 14 deletions

View File

@ -536,6 +536,11 @@ pref("mousewheel.with_shift.action", 1);
// 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 mousewheel events, since
// those are used on Mac as part of modified swipe gestures (e.g.
// Left swipe+Cmd = go back in a new tab).
pref("mousewheel.with_control.action.override_x", 0);
pref("mousewheel.with_meta.action.override_x", 0);
#else
pref("mousewheel.with_alt.action", 1);
pref("mousewheel.with_shift.action", 2);

View File

@ -3314,6 +3314,9 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
widget::WheelEvent* wheelEvent = static_cast<widget::WheelEvent*>(aEvent);
switch (WheelPrefs::GetInstance()->ComputeActionFor(wheelEvent)) {
case WheelPrefs::ACTION_SCROLL: {
if (!wheelEvent->deltaX && !wheelEvent->deltaY) {
break;
}
// For scrolling of default action, we should honor the mouse wheel
// transaction.
nsIScrollableFrame* scrollTarget =
@ -3330,15 +3333,34 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
}
break;
}
case WheelPrefs::ACTION_HISTORY:
DoScrollHistory(wheelEvent->GetPreferredIntDelta());
case WheelPrefs::ACTION_HISTORY: {
// If this event doesn't cause NS_MOUSE_SCROLL event or the direction
// is oblique, don't perform history back/forward.
int32_t intDelta = wheelEvent->GetPreferredIntDelta();
if (!intDelta) {
break;
}
DoScrollHistory(intDelta);
break;
case WheelPrefs::ACTION_ZOOM:
DoScrollZoom(aTargetFrame, wheelEvent->GetPreferredIntDelta());
}
case WheelPrefs::ACTION_ZOOM: {
// If this event doesn't cause NS_MOUSE_SCROLL event or the direction
// is oblique, don't perform zoom in/out.
int32_t intDelta = wheelEvent->GetPreferredIntDelta();
if (!intDelta) {
break;
}
DoScrollZoom(aTargetFrame, intDelta);
break;
}
case WheelPrefs::ACTION_NONE:
default:
// If we don't handle the wheel event, all of the delta values must
// be overflown delta values.
wheelEvent->overflowDeltaX = wheelEvent->deltaX;
wheelEvent->overflowDeltaY = wheelEvent->deltaY;
WheelPrefs::GetInstance()->
CancelApplyingUserPrefsFromOverflowDelta(wheelEvent);
break;
}
*aStatus = nsEventStatus_eConsumeNoDefault;
@ -5529,10 +5551,6 @@ nsEventStateManager::WheelPrefs::CancelApplyingUserPrefsFromOverflowDelta(
nsEventStateManager::WheelPrefs::Action
nsEventStateManager::WheelPrefs::ComputeActionFor(widget::WheelEvent* aEvent)
{
if (!aEvent->deltaX && !aEvent->deltaY) {
return ACTION_NONE;
}
Index index = GetIndexFor(aEvent);
Init(index);
@ -5552,9 +5570,7 @@ nsEventStateManager::WheelPrefs::ComputeActionFor(widget::WheelEvent* aEvent)
ACTION_NONE;
}
// If this event doesn't cause NS_MOUSE_SCROLL event or the direction is
// oblique, history and zoom shouldn't be executed.
return !aEvent->GetPreferredIntDelta() ? ACTION_NONE : actions[index];
return actions[index];
}
bool

View File

@ -1681,7 +1681,7 @@ function doTestActionOverride(aCallback)
}
if (++index == kTests.length) {
SpecialPowers.setIntPref("mousewheel.default.action", 1);
SpecialPowers.clearUserPref("mousewheel.default.action.override_x");
SpecialPowers.setIntPref("mousewheel.default.action.override_x", -1);
SimpleTest.executeSoon(aCallback);
} else {
doIt();
@ -1696,8 +1696,11 @@ function runTests()
SpecialPowers.setBoolPref("general.smoothScroll", false);
SpecialPowers.setIntPref("mousewheel.default.action", 1); // scroll
SpecialPowers.setIntPref("mousewheel.default.action.override_x", -1);
SpecialPowers.setIntPref("mousewheel.with_shift.action", 2); // history
SpecialPowers.setIntPref("mousewheel.with_shift.action.override_x", -1);
SpecialPowers.setIntPref("mousewheel.with_control.action", 3); // zoom
SpecialPowers.setIntPref("mousewheel.with_control.action.override_x", -1);
const kSettings = [
{ description: "all delta values are not customized",
@ -1751,8 +1754,11 @@ function finishTests()
SpecialPowers.clearUserPref("general.smoothScroll");
SpecialPowers.clearUserPref("mousewheel.default.action");
SpecialPowers.clearUserPref("mousewheel.default.action.override_x");
SpecialPowers.clearUserPref("mousewheel.with_shift.action");
SpecialPowers.clearUserPref("mousewheel.with_shift.action.override_x");
SpecialPowers.clearUserPref("mousewheel.with_control.action");
SpecialPowers.clearUserPref("mousewheel.with_control.action.override_x");
SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_x");
SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_y");