diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index d2f96c26aa6..697e0501632 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -5716,14 +5716,16 @@ EventStateManager::WheelPrefs::NeedToComputeLineOrPageDelta( (mMultiplierY[index] != 1.0 && mMultiplierY[index] != -1.0); } -bool -EventStateManager::WheelPrefs::HasUserPrefsForDelta(WidgetWheelEvent* aEvent) +void +EventStateManager::WheelPrefs::GetUserPrefsForEvent(WidgetWheelEvent* aEvent, + double* aOutMultiplierX, + double* aOutMultiplierY) { Index index = GetIndexFor(aEvent); Init(index); - return mMultiplierX[index] != 1.0 || - mMultiplierY[index] != 1.0; + *aOutMultiplierX = mMultiplierX[index]; + *aOutMultiplierY = mMultiplierY[index]; } bool @@ -5733,10 +5735,13 @@ EventStateManager::WheelEventIsScrollAction(WidgetWheelEvent* aEvent) WheelPrefs::GetInstance()->ComputeActionFor(aEvent) == WheelPrefs::ACTION_SCROLL; } -bool -EventStateManager::WheelEventNeedsDeltaMultipliers(WidgetWheelEvent* aEvent) +void +EventStateManager::GetUserPrefsForWheelEvent(WidgetWheelEvent* aEvent, + double* aOutMultiplierX, + double* aOutMultiplierY) { - return WheelPrefs::GetInstance()->HasUserPrefsForDelta(aEvent); + WheelPrefs::GetInstance()->GetUserPrefsForEvent( + aEvent, aOutMultiplierX, aOutMultiplierY); } bool diff --git a/dom/events/EventStateManager.h b/dom/events/EventStateManager.h index 0575233c05e..e10e87e3303 100644 --- a/dom/events/EventStateManager.h +++ b/dom/events/EventStateManager.h @@ -242,9 +242,10 @@ public: // Returns true if the given WidgetWheelEvent will resolve to a scroll action. static bool WheelEventIsScrollAction(WidgetWheelEvent* aEvent); - // Returns true if user prefs for wheel deltas apply to the given - // WidgetWheelEvent. - static bool WheelEventNeedsDeltaMultipliers(WidgetWheelEvent* aEvent); + // Returns user-set multipliers for a wheel event. + static void GetUserPrefsForWheelEvent(WidgetWheelEvent* aEvent, + double* aOutMultiplierX, + double* aOutMultiplierY); // Returns whether or not a frame can be vertically scrolled with a mouse // wheel (as opposed to, say, a selection or touch scroll). @@ -449,7 +450,9 @@ protected: * Returns whether or not ApplyUserPrefsToDelta() would change the delta * values of an event. */ - bool HasUserPrefsForDelta(WidgetWheelEvent* aEvent); + void GetUserPrefsForEvent(WidgetWheelEvent* aEvent, + double* aOutMultiplierX, + double* aOutMultiplierY); /** * If ApplyUserPrefsToDelta() changed the delta values with customized diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index 4d7e7df26d5..6989933bfaf 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -626,8 +626,7 @@ WillHandleWheelEvent(WidgetWheelEvent* aEvent) { return EventStateManager::WheelEventIsScrollAction(aEvent) && (aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_LINE || - aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_PIXEL) && - !EventStateManager::WheelEventNeedsDeltaMultipliers(aEvent); + aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_PIXEL); } static bool @@ -1090,8 +1089,17 @@ APZCTreeManager::ProcessWheelEvent(WidgetWheelEvent& aEvent, scrollMode, ScrollWheelInput::DeltaTypeForDeltaMode(aEvent.deltaMode), origin, - aEvent.deltaX, - aEvent.deltaY); + aEvent.deltaX, aEvent.deltaY); + + // We add the user multiplier as a separate field, rather than premultiplying + // it, because if the input is converted back to a WidgetWheelEvent, then + // EventStateManager would apply the delta a second time. We could in theory + // work around this by asking ESM to customize the event much sooner, and + // then save the "customizedByUserPrefs" bit on ScrollWheelInput - but for + // now, this seems easier. + EventStateManager::GetUserPrefsForWheelEvent(&aEvent, + &input.mUserDeltaMultiplierX, + &input.mUserDeltaMultiplierY); nsEventStatus status = ReceiveInputEvent(input, aOutTargetGuid, aOutInputBlockId); aEvent.refPoint.x = input.mOrigin.x; diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 173ecdab1fb..c4da0148a8c 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -1604,7 +1604,18 @@ AsyncPanZoomController::GetScrollWheelDelta(const ScrollWheelInput& aEvent) cons MOZ_ASSERT_UNREACHABLE("unexpected scroll delta type"); } - if (isRootContent && gfxPrefs::MouseWheelHasRootScrollDeltaOverride()) { + // Apply user-set multipliers. + delta.x *= aEvent.mUserDeltaMultiplierX; + delta.y *= aEvent.mUserDeltaMultiplierY; + + // For the conditions under which we allow system scroll overrides, see + // EventStateManager::DeltaAccumulator::ComputeScrollAmountForDefaultAction + // and WheelTransaction::OverrideSystemScrollSpeed. + if (isRootContent && + gfxPrefs::MouseWheelHasRootScrollDeltaOverride() && + !aEvent.IsCustomizedByUserPrefs() && + aEvent.mDeltaType == ScrollWheelInput::SCROLLDELTA_LINE) + { // Only apply delta multipliers if we're increasing the delta. double hfactor = double(gfxPrefs::MouseWheelRootHScrollDeltaFactor()) / 100; double vfactor = double(gfxPrefs::MouseWheelRootVScrollDeltaFactor()) / 100; diff --git a/widget/InputData.cpp b/widget/InputData.cpp index 471717903f9..a0d0bb868e9 100644 --- a/widget/InputData.cpp +++ b/widget/InputData.cpp @@ -376,6 +376,8 @@ ScrollWheelInput::ScrollWheelInput(const WidgetWheelEvent& aWheelEvent) : mDeltaY(aWheelEvent.deltaY), mLineOrPageDeltaX(aWheelEvent.lineOrPageDeltaX), mLineOrPageDeltaY(aWheelEvent.lineOrPageDeltaY), + mUserDeltaMultiplierX(1.0), + mUserDeltaMultiplierY(1.0), mIsMomentum(aWheelEvent.isMomentum) { mOrigin = @@ -415,4 +417,11 @@ ScrollWheelInput::TransformToLocal(const gfx::Matrix4x4& aTransform) return true; } +bool +ScrollWheelInput::IsCustomizedByUserPrefs() const +{ + return mUserDeltaMultiplierX != 1.0 || + mUserDeltaMultiplierY != 1.0; +} + } // namespace mozilla diff --git a/widget/InputData.h b/widget/InputData.h index 0c1a4979468..331f52874a6 100644 --- a/widget/InputData.h +++ b/widget/InputData.h @@ -583,6 +583,8 @@ public: mLineOrPageDeltaX(0), mLineOrPageDeltaY(0), mScrollSeriesNumber(0), + mUserDeltaMultiplierX(1.0), + mUserDeltaMultiplierY(1.0), mIsMomentum(false) {} @@ -591,6 +593,8 @@ public: WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const; bool TransformToLocal(const gfx::Matrix4x4& aTransform); + bool IsCustomizedByUserPrefs() const; + ScrollDeltaType mDeltaType; ScrollMode mScrollMode; ScreenPoint mOrigin; @@ -620,6 +624,10 @@ public: // first event is 1; if not a member of a transaction, this is 0. uint32_t mScrollSeriesNumber; + // User-set delta multipliers. + double mUserDeltaMultiplierX; + double mUserDeltaMultiplierY; + bool mIsMomentum; };