From 0edd0b1707ba57a3795ca93cc6fa488cd4b7d67c Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 24 Mar 2015 14:58:49 -0700 Subject: [PATCH] Don't route wheel events through APZ if they require custom deltas. (bug 1146674, r=kats) --- dom/events/EventStateManager.cpp | 16 ++++++++++++++++ dom/events/EventStateManager.h | 10 ++++++++++ gfx/layers/apz/src/APZCTreeManager.cpp | 3 ++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 5d75e7fcdbc6..abcedc8f5e1e 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -5514,12 +5514,28 @@ EventStateManager::WheelPrefs::NeedToComputeLineOrPageDelta( (mMultiplierY[index] != 1.0 && mMultiplierY[index] != -1.0); } +bool +EventStateManager::WheelPrefs::HasUserPrefsForDelta(WidgetWheelEvent* aEvent) +{ + Index index = GetIndexFor(aEvent); + Init(index); + + return mMultiplierX[index] != 1.0 || + mMultiplierY[index] != 1.0; +} + bool EventStateManager::WheelEventIsScrollAction(WidgetWheelEvent* aEvent) { return WheelPrefs::GetInstance()->ComputeActionFor(aEvent) == WheelPrefs::ACTION_SCROLL; } +bool +EventStateManager::WheelEventNeedsDeltaMultipliers(WidgetWheelEvent* aEvent) +{ + return WheelPrefs::GetInstance()->HasUserPrefsForDelta(aEvent); +} + bool EventStateManager::WheelPrefs::IsOverOnePageScrollAllowedX( WidgetWheelEvent* aEvent) diff --git a/dom/events/EventStateManager.h b/dom/events/EventStateManager.h index 6f73f1d0cf67..911e14b28cec 100644 --- a/dom/events/EventStateManager.h +++ b/dom/events/EventStateManager.h @@ -225,6 +225,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 whether or not a frame can be vertically scrolled with a mouse // wheel (as opposed to, say, a selection or touch scroll). static bool CanVerticallyScrollFrameWithWheel(nsIFrame* aFrame); @@ -423,6 +427,12 @@ protected: */ void ApplyUserPrefsToDelta(WidgetWheelEvent* aEvent); + /** + * Returns whether or not ApplyUserPrefsToDelta() would change the delta + * values of an event. + */ + bool HasUserPrefsForDelta(WidgetWheelEvent* aEvent); + /** * If ApplyUserPrefsToDelta() changed the delta values with customized * prefs, the overflowDelta values would be inflated. diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index f5fc91495c9c..0d158ffee742 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -903,7 +903,8 @@ APZCTreeManager::WillHandleWheelEvent(WidgetWheelEvent* aEvent) { return EventStateManager::WheelEventIsScrollAction(aEvent) && aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_LINE && - !gfxPrefs::MouseWheelHasScrollDeltaOverride(); + !gfxPrefs::MouseWheelHasScrollDeltaOverride() && + !EventStateManager::WheelEventNeedsDeltaMultipliers(aEvent); } nsEventStatus