From 08a826f3e2528e5ec1c2765b937d4f3ed96bb0f3 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Sun, 12 Aug 2012 10:42:34 +0900 Subject: [PATCH] Bug 719320 part.4 Remove mousewheel.*.*numlines and add mousewheel.*.delta_multiplier_* r=smaug --- browser/app/profile/firefox.js | 14 -- content/events/src/nsEventStateManager.cpp | 277 +++++++++++++-------- content/events/src/nsEventStateManager.h | 82 ++++-- modules/libpref/src/init/all.js | 37 ++- widget/nsGUIEvent.h | 4 +- widget/tests/window_mouse_scroll_win.html | 44 ++-- 6 files changed, 285 insertions(+), 173 deletions(-) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 1643b1515669..c2d2dabe7fb3 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -516,28 +516,14 @@ pref("browser.gesture.tap", "cmd_fullZoomReset"); // horizontal scroll event. Thus, we can't assign anything other than normal // scrolling to shift+wheel. pref("mousewheel.withshiftkey.action",0); -pref("mousewheel.withshiftkey.sysnumlines",true); -pref("mousewheel.withshiftkey.numlines",1); pref("mousewheel.withaltkey.action",2); -pref("mousewheel.withaltkey.sysnumlines",false); -pref("mousewheel.withaltkey.numlines",1); pref("mousewheel.withmetakey.action",0); -pref("mousewheel.withmetakey.sysnumlines",false); -pref("mousewheel.withmetakey.numlines",1); #else pref("mousewheel.withshiftkey.action",2); -pref("mousewheel.withshiftkey.sysnumlines",false); -pref("mousewheel.withshiftkey.numlines",1); pref("mousewheel.withaltkey.action",0); -pref("mousewheel.withaltkey.sysnumlines",false); -pref("mousewheel.withaltkey.numlines",1); pref("mousewheel.withmetakey.action",0); -pref("mousewheel.withmetakey.sysnumlines",true); -pref("mousewheel.withmetakey.numlines",1); #endif pref("mousewheel.withcontrolkey.action",3); -pref("mousewheel.withcontrolkey.sysnumlines",false); -pref("mousewheel.withcontrolkey.numlines",1); // pref to control the alert notification pref("alerts.slideIncrement", 1); diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 680711d3f93a..89a6e65fc1fa 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -141,6 +141,9 @@ static PRUint32 gPixelScrollDeltaTimeout = 0; TimeStamp nsEventStateManager::sHandlingInputStart; +nsEventStateManager::WheelPrefs* + nsEventStateManager::WheelPrefs::sInstance = nullptr; + static inline bool IsMouseEventReal(nsEvent* aEvent) { @@ -787,20 +790,6 @@ static const char* kObservedPrefs[] = { "ui.key.chromeAccess", "ui.key.contentAccess", "ui.click_hold_context_menus", -#if 0 - "mousewheel.withaltkey.action", - "mousewheel.withaltkey.numlines", - "mousewheel.withaltkey.sysnumlines", - "mousewheel.withcontrolkey.action", - "mousewheel.withcontrolkey.numlines", - "mousewheel.withcontrolkey.sysnumlines", - "mousewheel.withnokey.action", - "mousewheel.withnokey.numlines", - "mousewheel.withnokey.sysnumlines", - "mousewheel.withshiftkey.action", - "mousewheel.withshiftkey.numlines", - "mousewheel.withshiftkey.sysnumlines", -#endif "dom.popup_allowed_events", nullptr }; @@ -857,6 +846,7 @@ nsEventStateManager::~nsEventStateManager() gUserInteractionTimer->Cancel(); NS_RELEASE(gUserInteractionTimer); } + WheelPrefs::Shutdown(); } if (sDragOverContent && sDragOverContent->OwnerDoc() == mDocument) { @@ -921,20 +911,6 @@ nsEventStateManager::Observe(nsISupports *aSubject, } else if (data.EqualsLiteral("ui.click_hold_context_menus")) { mClickHoldContextMenu = Preferences::GetBool("ui.click_hold_context_menus", false); -#if 0 - } else if (data.EqualsLiteral("mousewheel.withaltkey.action")) { - } else if (data.EqualsLiteral("mousewheel.withaltkey.numlines")) { - } else if (data.EqualsLiteral("mousewheel.withaltkey.sysnumlines")) { - } else if (data.EqualsLiteral("mousewheel.withcontrolkey.action")) { - } else if (data.EqualsLiteral("mousewheel.withcontrolkey.numlines")) { - } else if (data.EqualsLiteral("mousewheel.withcontrolkey.sysnumlines")) { - } else if (data.EqualsLiteral("mousewheel.withshiftkey.action")) { - } else if (data.EqualsLiteral("mousewheel.withshiftkey.numlines")) { - } else if (data.EqualsLiteral("mousewheel.withshiftkey.sysnumlines")) { - } else if (data.EqualsLiteral("mousewheel.withnokey.action")) { - } else if (data.EqualsLiteral("mousewheel.withnokey.numlines")) { - } else if (data.EqualsLiteral("mousewheel.withnokey.sysnumlines")) { -#endif } else if (data.EqualsLiteral("dom.popup_allowed_events")) { nsDOMEvent::PopupAllowedEventsChanged(); } @@ -1190,8 +1166,13 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, mCurrentTargetContent = content; nsMouseScrollEvent* msEvent = static_cast(aEvent); + WheelPrefs::GetInstance()->ApplyUserPrefsToDelta(msEvent); - msEvent->delta = ComputeWheelDeltaFor(msEvent); + if (ComputeWheelActionFor(msEvent) == MOUSE_SCROLL_PAGE) { + msEvent->delta = + (msEvent->delta > 0) ? PRInt32(nsIDOMUIEvent::SCROLL_PAGE_DOWN) : + PRInt32(nsIDOMUIEvent::SCROLL_PAGE_UP); + } } break; case NS_MOUSE_PIXEL_SCROLL: @@ -1201,6 +1182,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, mCurrentTargetContent = content; nsMouseScrollEvent *msEvent = static_cast(aEvent); + WheelPrefs::GetInstance()->ApplyUserPrefsToDelta(msEvent); // Clear old deltas after a period of non action if (OutOfTime(gPixelScrollDeltaTimeout, nsMouseWheelTransaction::GetTimeoutTime())) { @@ -2704,50 +2686,10 @@ nsEventStateManager::SendPixelScrollEvent(nsIFrame* aTargetFrame, } PRInt32 -nsEventStateManager::ComputeWheelDeltaFor(nsMouseScrollEvent* aMouseEvent) -{ - PRInt32 delta = aMouseEvent->delta; - bool useSysNumLines = UseSystemScrollSettingFor(aMouseEvent); - if (!useSysNumLines) { - // If the scroll event's delta isn't to our liking, we can - // override it with the "numlines" parameter. There are two - // things we can do: - // - // (1) Pick a different number. Instead of scrolling 3 - // lines ("delta" in Gtk2), we would scroll 1 line. - // (2) Swap directions. Instead of scrolling down, scroll up. - // - // For the first item, the magnitude of the parameter is - // used instead of the magnitude of the delta. For the - // second item, if the parameter is negative we swap - // directions. - - PRInt32 numLines = GetScrollLinesFor(aMouseEvent); - - bool swapDirs = (numLines < 0); - PRInt32 userSize = swapDirs ? -numLines : numLines; - - bool deltaUp = (delta < 0); - if (swapDirs) { - deltaUp = !deltaUp; - } - delta = deltaUp ? -userSize : userSize; - } - - if (ComputeWheelActionFor(aMouseEvent, useSysNumLines) == MOUSE_SCROLL_PAGE) { - delta = (delta > 0) ? PRInt32(nsIDOMUIEvent::SCROLL_PAGE_DOWN) : - PRInt32(nsIDOMUIEvent::SCROLL_PAGE_UP); - } - - return delta; -} - -PRInt32 -nsEventStateManager::ComputeWheelActionFor(nsMouseScrollEvent* aMouseEvent, - bool aUseSystemSettings) +nsEventStateManager::ComputeWheelActionFor(nsMouseScrollEvent* aMouseEvent) { PRInt32 action = GetWheelActionFor(aMouseEvent); - if (aUseSystemSettings && + if (!aMouseEvent->customizedByUserPrefs && (aMouseEvent->scrollFlags & nsMouseScrollEvent::kIsFullPage)) { action = MOUSE_SCROLL_PAGE; } @@ -2761,7 +2703,7 @@ nsEventStateManager::ComputeWheelActionFor(nsMouseScrollEvent* aMouseEvent, action = -1; } } else if (((aMouseEvent->scrollFlags & nsMouseScrollEvent::kHasPixels) && - (aUseSystemSettings || + (!aMouseEvent->customizedByUserPrefs || action == MOUSE_SCROLL_N_LINES || action == MOUSE_SCROLL_PAGE)) || ((aMouseEvent->scrollFlags & nsMouseScrollEvent::kIsMomentum) && (action == MOUSE_SCROLL_HISTORY || action == MOUSE_SCROLL_ZOOM))) { @@ -2783,26 +2725,6 @@ nsEventStateManager::GetWheelActionFor(nsMouseScrollEvent* aMouseEvent) return Preferences::GetInt(prefName.get()); } -PRInt32 -nsEventStateManager::GetScrollLinesFor(nsMouseScrollEvent* aMouseEvent) -{ - NS_ASSERTION(!UseSystemScrollSettingFor(aMouseEvent), - "GetScrollLinesFor() called when should use system settings"); - nsCAutoString prefName; - GetBasePrefKeyForMouseWheel(aMouseEvent, prefName); - prefName.Append(".numlines"); - return Preferences::GetInt(prefName.get()); -} - -bool -nsEventStateManager::UseSystemScrollSettingFor(nsMouseScrollEvent* aMouseEvent) -{ - nsCAutoString prefName; - GetBasePrefKeyForMouseWheel(aMouseEvent, prefName); - prefName.Append(".sysnumlines"); - return Preferences::GetBool(prefName.get()); -} - nsIScrollableFrame* nsEventStateManager::ComputeScrollTarget(nsIFrame* aTargetFrame, nsMouseScrollEvent* aEvent, @@ -3383,13 +3305,13 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext, } if (*aStatus != nsEventStatus_eConsumeNoDefault) { - bool useSysNumLines = UseSystemScrollSettingFor(msEvent); - PRInt32 action = ComputeWheelActionFor(msEvent, useSysNumLines); + PRInt32 action = ComputeWheelActionFor(msEvent); switch (action) { case MOUSE_SCROLL_N_LINES: DoScrollText(aTargetFrame, msEvent, nsIScrollableFrame::LINES, - useSysNumLines, nullptr, nsGkAtoms::mouseWheel); + !msEvent->customizedByUserPrefs, nullptr, + nsGkAtoms::mouseWheel); break; case MOUSE_SCROLL_PAGE: @@ -5192,17 +5114,17 @@ nsEventStateManager::DoQueryScrollTargetInfo(nsQueryContentEvent* aEvent, msEvent.buttons = aEvent->mInput.mMouseScrollEvent->buttons; msEvent.scrollFlags = aEvent->mInput.mMouseScrollEvent->scrollFlags; - msEvent.delta = ComputeWheelDeltaFor(aEvent->mInput.mMouseScrollEvent); + msEvent.delta = aEvent->mInput.mMouseScrollEvent->delta; msEvent.scrollOverflow = aEvent->mInput.mMouseScrollEvent->scrollOverflow; - bool useSystemSettings = UseSystemScrollSettingFor(&msEvent); + WheelPrefs::GetInstance()->ApplyUserPrefsToDelta(&msEvent); nsIScrollableFrame::ScrollUnit unit; bool allowOverrideSystemSettings; - switch (ComputeWheelActionFor(&msEvent, useSystemSettings)) { + switch (ComputeWheelActionFor(&msEvent)) { case MOUSE_SCROLL_N_LINES: unit = nsIScrollableFrame::LINES; - allowOverrideSystemSettings = useSystemSettings; + allowOverrideSystemSettings = !msEvent.customizedByUserPrefs; break; case MOUSE_SCROLL_PAGE: unit = nsIScrollableFrame::PAGES; @@ -5255,3 +5177,160 @@ nsEventStateManager::ClearGlobalActiveContent(nsEventStateManager* aClearer) } sActiveESM = nullptr; } + + +/******************************************************************/ +/* nsEventStateManager::WheelPrefs */ +/******************************************************************/ + +// static +nsEventStateManager::WheelPrefs* +nsEventStateManager::WheelPrefs::GetInstance() +{ + if (!sInstance) { + sInstance = new WheelPrefs(); + } + return sInstance; +} + +// static +void +nsEventStateManager::WheelPrefs::Shutdown() +{ + delete sInstance; + sInstance = nullptr; +} + +// static +int +nsEventStateManager::WheelPrefs::OnPrefChanged(const char* aPrefName, + void* aClosure) +{ + // forget all prefs, it's not problem for performance. + sInstance->Reset(); + return 0; +} + +nsEventStateManager::WheelPrefs::WheelPrefs() +{ + Reset(); + Preferences::RegisterCallback(OnPrefChanged, "mousewheel.", nullptr); +} + +nsEventStateManager::WheelPrefs::~WheelPrefs() +{ + Preferences::UnregisterCallback(OnPrefChanged, "mousewheel.", nullptr); +} + +void +nsEventStateManager::WheelPrefs::Reset() +{ + memset(mInit, 0, sizeof(mInit)); + +} + +nsEventStateManager::WheelPrefs::Index +nsEventStateManager::WheelPrefs::GetIndexFor(nsMouseEvent_base* aEvent) +{ + widget::Modifiers modifiers = + (aEvent->modifiers & (widget::MODIFIER_ALT | + widget::MODIFIER_CONTROL | + widget::MODIFIER_META | + widget::MODIFIER_SHIFT | + widget::MODIFIER_OS)); + + switch (modifiers) { + case widget::MODIFIER_ALT: + return INDEX_ALT; + case widget::MODIFIER_CONTROL: + return INDEX_CONTROL; + case widget::MODIFIER_META: + return INDEX_META; + case widget::MODIFIER_SHIFT: + return INDEX_SHIFT; + case widget::MODIFIER_OS: + return INDEX_OS; + default: + // If two or more modifier keys are pressed, we should use default + // settings. + return INDEX_DEFAULT; + } +} + +void +nsEventStateManager::WheelPrefs::GetBasePrefName( + nsEventStateManager::WheelPrefs::Index aIndex, + nsACString& aBasePrefName) +{ + aBasePrefName.AssignLiteral("mousewheel."); + switch (aIndex) { + case INDEX_ALT: + aBasePrefName.AppendLiteral("withaltkey."); + break; + case INDEX_CONTROL: + aBasePrefName.AppendLiteral("withcontrolkey."); + break; + case INDEX_META: + aBasePrefName.AppendLiteral("withmetakey."); + break; + case INDEX_SHIFT: + aBasePrefName.AppendLiteral("withshiftkey."); + break; + case INDEX_OS: + aBasePrefName.AppendLiteral("withwinkey."); + break; + case INDEX_DEFAULT: + default: + aBasePrefName.AppendLiteral("withnokey."); + break; + } +} + +void +nsEventStateManager::WheelPrefs::Init( + nsEventStateManager::WheelPrefs::Index aIndex) +{ + if (mInit[aIndex]) { + return; + } + mInit[aIndex] = true; + + nsCAutoString basePrefName; + GetBasePrefName(aIndex, basePrefName); + + nsCAutoString prefNameX(basePrefName); + prefNameX.AppendLiteral("delta_multiplier_x"); + mMultiplierX[aIndex] = + static_cast(Preferences::GetInt(prefNameX.get(), 100)) / 100; + if (mMultiplierX[aIndex] < 1.0 && mMultiplierX[aIndex] > -1.0) { + mMultiplierX[aIndex] = mMultiplierX[aIndex] < 0.0 ? -1.0 : 1.0; + } + + nsCAutoString prefNameY(basePrefName); + prefNameY.AppendLiteral("delta_multiplier_y"); + mMultiplierY[aIndex] = + static_cast(Preferences::GetInt(prefNameY.get(), 100)) / 100; + if (mMultiplierY[aIndex] < 1.0 && mMultiplierY[aIndex] > -1.0) { + mMultiplierY[aIndex] = mMultiplierY[aIndex] < 0.0 ? -1.0 : 1.0; + } +} + +void +nsEventStateManager::WheelPrefs::ApplyUserPrefsToDelta( + nsMouseScrollEvent* aEvent) +{ + Index index = GetIndexFor(aEvent); + Init(index); + + if (aEvent->scrollFlags & nsMouseScrollEvent::kIsHorizontal) { + double delta = aEvent->delta * mMultiplierX[index]; + aEvent->delta = + static_cast((delta > 0.0) ? ceil(delta) : floor(delta)); + aEvent->customizedByUserPrefs = (mMultiplierX[index] != 1.0); + } else if (aEvent->scrollFlags & nsMouseScrollEvent::kIsVertical) { + double delta = aEvent->delta * mMultiplierY[index]; + aEvent->delta = + static_cast((delta > 0.0) ? ceil(delta) : floor(delta)); + aEvent->customizedByUserPrefs = (mMultiplierY[index] != 1.0); + } +} diff --git a/content/events/src/nsEventStateManager.h b/content/events/src/nsEventStateManager.h index 52f6970a2c4d..01dc3bc46571 100644 --- a/content/events/src/nsEventStateManager.h +++ b/content/events/src/nsEventStateManager.h @@ -317,6 +317,66 @@ protected: bool IsShellVisible(nsIDocShell* aShell); // These functions are for mousewheel and pixel scrolling + + class WheelPrefs + { + public: + static WheelPrefs* GetInstance(); + static void Shutdown(); + + /** + * ApplyUserPrefsToDelta() overrides the wheel event's delta values with + * user prefs. + */ + void ApplyUserPrefsToDelta(nsMouseScrollEvent* aEvent); + + private: + WheelPrefs(); + ~WheelPrefs(); + + static int OnPrefChanged(const char* aPrefName, void* aClosure); + + enum Index + { + INDEX_DEFAULT = 0, + INDEX_ALT, + INDEX_CONTROL, + INDEX_META, + INDEX_SHIFT, + INDEX_OS, + COUNT_OF_MULTIPLIERS + }; + + /** + * GetIndexFor() returns the index of the members which should be used for + * the aEvent. When only one modifier key of MODIFIER_ALT, + * MODIFIER_CONTROL, MODIFIER_META, MODIFIER_SHIFT or MODIFIER_OS is + * pressed, returns the index for the modifier. Otherwise, this return the + * default index which is used at either no modifier key is pressed or + * two or modifier keys are pressed. + */ + Index GetIndexFor(nsMouseEvent_base* aEvent); + + /** + * GetPrefNameBase() returns the base pref name for aEvent. + * It's decided by GetModifierForPref() which modifier should be used for + * the aEvent. + * + * @param aBasePrefName The result, it must be "mousewheel.with*.". + */ + void GetBasePrefName(Index aIndex, nsACString& aBasePrefName); + + void Init(Index aIndex); + + void Reset(); + + bool mInit[COUNT_OF_MULTIPLIERS]; + double mMultiplierX[COUNT_OF_MULTIPLIERS]; + double mMultiplierY[COUNT_OF_MULTIPLIERS]; + + static WheelPrefs* sInstance; + }; + void SendLineScrollEvent(nsIFrame* aTargetFrame, nsMouseScrollEvent* aEvent, nsPresContext* aPresContext, @@ -381,39 +441,19 @@ protected: nsresult GetMarkupDocumentViewer(nsIMarkupDocumentViewer** aMv); nsresult ChangeTextSize(PRInt32 change); nsresult ChangeFullZoom(PRInt32 change); - /** - * Computes actual delta value used for scrolling. If user customized the - * scrolling speed and/or direction, this would return the customized value. - * Otherwise, it would return the original delta value of aMouseEvent. - */ - PRInt32 ComputeWheelDeltaFor(nsMouseScrollEvent* aMouseEvent); /** * Computes the action for the aMouseEvent with prefs. The result is * MOUSE_SCROLL_N_LINES, MOUSE_SCROLL_PAGE, MOUSE_SCROLL_HISTORY, * MOUSE_SCROLL_ZOOM, MOUSE_SCROLL_PIXELS or -1. * When the result is -1, nothing happens for the event. - * - * @param aUseSystemSettings Set the result of UseSystemScrollSettingFor(). */ - PRInt32 ComputeWheelActionFor(nsMouseScrollEvent* aMouseEvent, - bool aUseSystemSettings); + PRInt32 ComputeWheelActionFor(nsMouseScrollEvent* aMouseEvent); /** * Gets the wheel action for the aMouseEvent ONLY with the pref. * When you actually do something for the event, probably you should use * ComputeWheelActionFor(). */ PRInt32 GetWheelActionFor(nsMouseScrollEvent* aMouseEvent); - /** - * Gets the pref value for line scroll amount for the aMouseEvent. - * Note that this method doesn't check whether the aMouseEvent is line scroll - * event and doesn't use system settings. - */ - PRInt32 GetScrollLinesFor(nsMouseScrollEvent* aMouseEvent); - /** - * Whether use system scroll settings or settings in our prefs for the event. - * TRUE, if use system scroll settings. Otherwise, FALSE. - */ - bool UseSystemScrollSettingFor(nsMouseScrollEvent* aMouseEvent); // end mousewheel functions /* diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index fc11995a35cb..a6cd6d2a6803 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -1382,38 +1382,35 @@ pref("mousewheel.system_scroll_override_on_root_content.horizontal.factor", 200) // 0=lines, 1=pages, 2=history , 3=text size pref("mousewheel.withnokey.action",0); -pref("mousewheel.withnokey.numlines",6); -pref("mousewheel.withnokey.sysnumlines",true); pref("mousewheel.withcontrolkey.action",0); -pref("mousewheel.withcontrolkey.numlines",1); -pref("mousewheel.withcontrolkey.sysnumlines",true); // mousewheel.withshiftkey, see the Mac note below. pref("mousewheel.withshiftkey.action",0); -pref("mousewheel.withshiftkey.numlines",1); -pref("mousewheel.withshiftkey.sysnumlines",true); pref("mousewheel.withaltkey.action",2); -pref("mousewheel.withaltkey.numlines",1); -pref("mousewheel.withaltkey.sysnumlines",false); pref("mousewheel.withmetakey.action",0); -pref("mousewheel.withmetakey.numlines",1); -pref("mousewheel.withmetakey.sysnumlines",true); // activate horizontal scrolling by default pref("mousewheel.horizscroll.withnokey.action",0); -pref("mousewheel.horizscroll.withnokey.numlines",1); -pref("mousewheel.horizscroll.withnokey.sysnumlines",true); pref("mousewheel.horizscroll.withcontrolkey.action",0); -pref("mousewheel.horizscroll.withcontrolkey.numlines",1); -pref("mousewheel.horizscroll.withcontrolkey.sysnumlines",true); pref("mousewheel.horizscroll.withshiftkey.action",0); -pref("mousewheel.horizscroll.withshiftkey.numlines",1); -pref("mousewheel.horizscroll.withshiftkey.sysnumlines",true); pref("mousewheel.horizscroll.withaltkey.action",2); -pref("mousewheel.horizscroll.withaltkey.numlines",-1); -pref("mousewheel.horizscroll.withaltkey.sysnumlines",false); pref("mousewheel.horizscroll.withmetakey.action",0); -pref("mousewheel.horizscroll.withmetakey.numlines",1); -pref("mousewheel.horizscroll.withmetakey.sysnumlines",true); + +// mousewheel.*.delta_multiplier_* can specify the value muliplied by the delta +// value. The values will be used after divided by 100. I.e., 100 means 1.0, +// -100 means -1.0. If the values were negative, the direction would be +// reverted. The absolue value must be 100 or larger. +pref("mousewheel.withnokey.delta_multiplier_x", 100); +pref("mousewheel.withnokey.delta_multiplier_y", 100); +pref("mousewheel.withaltkey.delta_multiplier_x", 100); +pref("mousewheel.withaltkey.delta_multiplier_y", 100); +pref("mousewheel.withcontrolkey.delta_multiplier_x", 100); +pref("mousewheel.withcontrolkey.delta_multiplier_y", 100); +pref("mousewheel.withmetakey.delta_multiplier_x", 100); // command key on Mac +pref("mousewheel.withmetakey.delta_multiplier_y", 100); // command key on Mac +pref("mousewheel.withshiftkey.delta_multiplier_x", 100); +pref("mousewheel.withshiftkey.delta_multiplier_y", 100); +pref("mousewheel.withwinkey.delta_multiplier_x", 100); +pref("mousewheel.withwinkey.delta_multiplier_y", 100); // These define the smooth scroll behavior (min ms, max ms) for different triggers // Some triggers: diff --git a/widget/nsGUIEvent.h b/widget/nsGUIEvent.h index 166e06fc0eeb..e18f548b65c1 100644 --- a/widget/nsGUIEvent.h +++ b/widget/nsGUIEvent.h @@ -1377,13 +1377,15 @@ public: nsMouseScrollEvent(bool isTrusted, PRUint32 msg, nsIWidget *w) : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_SCROLL_EVENT), - scrollFlags(0), delta(0), scrollOverflow(0) + scrollFlags(0), delta(0), scrollOverflow(0), customizedByUserPrefs(false) { } PRInt32 scrollFlags; PRInt32 delta; PRInt32 scrollOverflow; + + bool customizedByUserPrefs; }; /** diff --git a/widget/tests/window_mouse_scroll_win.html b/widget/tests/window_mouse_scroll_win.html index 774b6d20858d..cd8e5f79cf44 100644 --- a/widget/tests/window_mouse_scroll_win.html +++ b/widget/tests/window_mouse_scroll_win.html @@ -50,18 +50,20 @@ const DOM_PAGE_SCROLL_DELTA = 32768; const kSystemScrollSpeedOverridePref = "mousewheel.system_scroll_override_on_root_content.enabled"; const kAltKeyVActionPref = "mousewheel.withaltkey.action"; -const kAltKeyVSysNumLinesPref = "mousewheel.withaltkey.sysnumlines"; const kAltKeyHActionPref = "mousewheel.horizscroll.withaltkey.action"; -const kAltKeyHSysNumLinesPref = "mousewheel.horizscroll.withaltkey.sysnumlines"; const kCtrlKeyVActionPref = "mousewheel.withcontrolkey.action"; -const kCtrlKeyVSysNumLinesPref = "mousewheel.withcontrolkey.sysnumlines"; const kCtrlKeyHActionPref = "mousewheel.horizscroll.withcontrolkey.action"; -const kCtrlKeyHSysNumLinesPref = "mousewheel.horizscroll.withcontrolkey.sysnumlines"; const kShiftKeyVActionPref = "mousewheel.withshiftkey.action"; -const kShiftKeyVSysNumLinesPref = "mousewheel.withshiftkey.sysnumlines"; const kShiftKeyHActionPref = "mousewheel.horizscroll.withshiftkey.action"; -const kShiftKeyHSysNumLinesPref = "mousewheel.horizscroll.withshiftkey.sysnumlines"; +const kAltKeyDeltaMultiplierXPref = "mousewheel.withaltkey.delta_multiplier_x"; +const kAltKeyDeltaMultiplierYPref = "mousewheel.withaltkey.delta_multiplier_y"; +const kCtrlKeyDeltaMultiplierXPref = "mousewheel.withcontrolkey.delta_multiplier_x"; +const kCtrlKeyDeltaMultiplierYPref = "mousewheel.withcontrolkey.delta_multiplier_y"; +const kShiftKeyDeltaMultiplierXPref = "mousewheel.withshiftkey.delta_multiplier_x"; +const kShiftKeyDeltaMultiplierYPref = "mousewheel.withshiftkey.delta_multiplier_y"; +const kWinKeyDeltaMultiplierXPref = "mousewheel.withwinkey.delta_multiplier_x"; +const kWinKeyDeltaMultiplierYPref = "mousewheel.withwinkey.delta_multiplier_y"; const kPixelEnabledPref = "mousewheel.enable_pixel_scrolling"; const kEmulateWheelByWMSCROLLPref = "mousewheel.emulate_at_wm_scroll"; @@ -108,17 +110,20 @@ function todo_is(aLeft, aRight, aMessage) function onUnload() { SpecialPowers.clearUserPref(kAltKeyVActionPref); - SpecialPowers.clearUserPref(kAltKeyVSysNumLinesPref); SpecialPowers.clearUserPref(kAltKeyHActionPref); - SpecialPowers.clearUserPref(kAltKeyHSysNumLinesPref); SpecialPowers.clearUserPref(kCtrlKeyVActionPref); - SpecialPowers.clearUserPref(kCtrlKeyVSysNumLinesPref); SpecialPowers.clearUserPref(kCtrlKeyHActionPref); - SpecialPowers.clearUserPref(kCtrlKeyHSysNumLinesPref); SpecialPowers.clearUserPref(kShiftKeyVActionPref); - SpecialPowers.clearUserPref(kShiftKeyVSysNumLinesPref); SpecialPowers.clearUserPref(kShiftKeyHActionPref); - SpecialPowers.clearUserPref(kShiftKeyHSysNumLinesPref); + + SpecialPowers.clearUserPref(kAltKeyDeltaMultiplierXPref); + SpecialPowers.clearUserPref(kAltKeyDeltaMultiplierYPref); + SpecialPowers.clearUserPref(kCtrlKeyDeltaMultiplierXPref); + SpecialPowers.clearUserPref(kCtrlKeyDeltaMultiplierYPref); + SpecialPowers.clearUserPref(kShiftKeyDeltaMultiplierXPref); + SpecialPowers.clearUserPref(kShiftKeyDeltaMultiplierYPref); + SpecialPowers.clearUserPref(kWinKeyDeltaMultiplierXPref); + SpecialPowers.clearUserPref(kWinKeyDeltaMultiplierYPref); SpecialPowers.clearUserPref(kSystemScrollSpeedOverridePref); SpecialPowers.clearUserPref(kPixelEnabledPref); @@ -1879,12 +1884,15 @@ function prepareTests() SpecialPowers.setIntPref(kAltKeyHActionPref, 0); SpecialPowers.setIntPref(kCtrlKeyHActionPref, 0); SpecialPowers.setIntPref(kShiftKeyHActionPref, 0); - SpecialPowers.setBoolPref(kAltKeyVSysNumLinesPref, true); - SpecialPowers.setBoolPref(kCtrlKeyVSysNumLinesPref, true); - SpecialPowers.setBoolPref(kShiftKeyVSysNumLinesPref, true); - SpecialPowers.setBoolPref(kAltKeyHSysNumLinesPref, true); - SpecialPowers.setBoolPref(kCtrlKeyHSysNumLinesPref, true); - SpecialPowers.setBoolPref(kShiftKeyHSysNumLinesPref, true); + + SpecialPowers.setIntPref(kAltKeyDeltaMultiplierXPref, 100); + SpecialPowers.setIntPref(kAltKeyDeltaMultiplierYPref, 100); + SpecialPowers.setIntPref(kCtrlKeyDeltaMultiplierXPref, 100); + SpecialPowers.setIntPref(kCtrlKeyDeltaMultiplierYPref, 100); + SpecialPowers.setIntPref(kShiftKeyDeltaMultiplierXPref, 100); + SpecialPowers.setIntPref(kShiftKeyDeltaMultiplierYPref, 100); + SpecialPowers.setIntPref(kWinKeyDeltaMultiplierXPref, 100); + SpecialPowers.setIntPref(kWinKeyDeltaMultiplierYPref, 100); SpecialPowers.setBoolPref(kSystemScrollSpeedOverridePref, false); SpecialPowers.setBoolPref(kPixelEnabledPref, true);