Bug 1153156 part.4 Make APZC system scroll speed overriding aware r=mstange, a=lizzard
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 27 Jan 2016 15:09:13 +0900
changeset 316721 8f8f3e46273a6916003d36cc476ef70b22b4770c
parent 316720 ec4502e3c0d40d1af1bfc6443a49e7bb59885a37
child 316722 672aef86e497774513f8fff4887b130ccbe4b4d3
push id5703
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:18:41 +0000
treeherdermozilla-beta@31e373ad5b5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, lizzard
bugs1153156
milestone46.0a2
Bug 1153156 part.4 Make APZC system scroll speed overriding aware r=mstange, a=lizzard
gfx/layers/apz/src/APZCTreeManager.cpp
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/test/gtest/TestHitTesting.cpp
gfx/layers/apz/test/gtest/TestTreeManager.cpp
gfx/thebes/gfxPrefs.h
widget/InputData.cpp
widget/InputData.h
widget/cocoa/nsChildView.mm
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -1057,17 +1057,18 @@ APZCTreeManager::ProcessWheelEvent(Widge
     scrollMode = ScrollWheelInput::SCROLLMODE_SMOOTH;
   }
 
   ScreenPoint origin(aEvent.refPoint.x, aEvent.refPoint.y);
   ScrollWheelInput input(aEvent.time, aEvent.timeStamp, 0,
                          scrollMode,
                          ScrollWheelInput::DeltaTypeForDeltaMode(aEvent.deltaMode),
                          origin,
-                         aEvent.deltaX, aEvent.deltaY);
+                         aEvent.deltaX, aEvent.deltaY,
+                         aEvent.mAllowToOverrideSystemScrollSpeed);
 
   // 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,
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -26,16 +26,17 @@
 #include "base/tracked.h"               // for FROM_HERE
 #include "gfxPrefs.h"                   // for gfxPrefs
 #include "gfxTypes.h"                   // for gfxFloat
 #include "LayersLogging.h"              // for print_stderr
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/BasicEvents.h"        // for Modifiers, MODIFIER_*
 #include "mozilla/ClearOnShutdown.h"    // for ClearOnShutdown
 #include "mozilla/EventForwards.h"      // for nsEventStatus_*
+#include "mozilla/MouseEvents.h"        // for WidgetWheelEvent
 #include "mozilla/Preferences.h"        // for Preferences
 #include "mozilla/ReentrantMonitor.h"   // for ReentrantMonitorAutoEnter, etc
 #include "mozilla/StaticPtr.h"          // for StaticAutoPtr
 #include "mozilla/Telemetry.h"          // for Telemetry
 #include "mozilla/TimeStamp.h"          // for TimeDuration, TimeStamp
 #include "mozilla/dom/CheckerboardReportService.h" // for CheckerboardEventStorage
              // note: CheckerboardReportService.h actually lives in gfx/layers/apz/util/
 #include "mozilla/dom/KeyframeEffect.h" // for ComputedTimingFunction
@@ -1634,27 +1635,20 @@ AsyncPanZoomController::GetScrollWheelDe
   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;
-    if (vfactor > 1.0) {
-      delta.x *= hfactor;
-    }
-    if (hfactor > 1.0) {
-      delta.y *= vfactor;
-    }
+      aEvent.mDeltaType == ScrollWheelInput::SCROLLDELTA_LINE &&
+      aEvent.mAllowToOverrideSystemScrollSpeed) {
+    delta.x = WidgetWheelEvent::ComputeOverriddenDelta(delta.x, false);
+    delta.y = WidgetWheelEvent::ComputeOverriddenDelta(delta.y, true);
   }
 
   // If this is a line scroll, and this event was part of a scroll series, then
   // it might need extra acceleration. See WheelHandlingHelper.cpp.
   if (aEvent.mDeltaType == ScrollWheelInput::SCROLLDELTA_LINE &&
       aEvent.mScrollSeriesNumber > 0)
   {
     int32_t start = gfxPrefs::MouseWheelAccelerationStart();
--- a/gfx/layers/apz/test/gtest/TestHitTesting.cpp
+++ b/gfx/layers/apz/test/gtest/TestHitTesting.cpp
@@ -430,17 +430,17 @@ TEST_F(APZHitTestingTester, TestRepaintF
   manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
   TestAsyncPanZoomController* apzcroot = ApzcOf(root);
 
   EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(AtLeast(3));
   ScreenPoint origin(100, 50);
   for (int i = 0; i < 3; i++) {
     ScrollWheelInput swi(MillisecondsSinceStartup(mcc->Time()), mcc->Time(), 0,
       ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL,
-      origin, 0, 10);
+      origin, 0, 10, false);
     EXPECT_EQ(nsEventStatus_eConsumeDoDefault, manager->ReceiveInputEvent(swi, nullptr, nullptr));
     EXPECT_EQ(origin, swi.mOrigin);
 
     AsyncTransform viewTransform;
     ParentLayerPoint point;
     apzcroot->SampleContentTransformForFrame(&viewTransform, point);
     EXPECT_EQ(0, point.x);
     EXPECT_EQ((i + 1) * 10, point.y);
--- a/gfx/layers/apz/test/gtest/TestTreeManager.cpp
+++ b/gfx/layers/apz/test/gtest/TestTreeManager.cpp
@@ -99,14 +99,14 @@ TEST_F(APZCTreeManagerTester, Bug1198900
   // crash.
   CreateSimpleDTCScrollingLayer();
   ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
   manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
 
   ScreenPoint origin(100, 50);
   ScrollWheelInput swi(MillisecondsSinceStartup(mcc->Time()), mcc->Time(), 0,
     ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL,
-    origin, 0, 10);
+    origin, 0, 10, false);
   uint64_t blockId;
   manager->ReceiveInputEvent(swi, nullptr, &blockId);
   manager->ContentReceivedInputBlock(blockId, /* preventDefault= */ true);
 }
 
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -392,20 +392,16 @@ private:
 
   // These affect how line scrolls from wheel events will be accelerated.
   DECL_GFX_PREF(Live, "mousewheel.acceleration.factor",        MouseWheelAccelerationFactor, int32_t, -1);
   DECL_GFX_PREF(Live, "mousewheel.acceleration.start",         MouseWheelAccelerationStart, int32_t, -1);
 
   // This affects whether events will be routed through APZ or not.
   DECL_GFX_PREF(Live, "mousewheel.system_scroll_override_on_root_content.enabled",
                                                                MouseWheelHasRootScrollDeltaOverride, bool, false);
-  DECL_GFX_PREF(Live, "mousewheel.system_scroll_override_on_root_content.horizontal.factor",
-                                                               MouseWheelRootHScrollDeltaFactor, int32_t, 100);
-  DECL_GFX_PREF(Live, "mousewheel.system_scroll_override_on_root_content.vertical.factor",
-                                                               MouseWheelRootVScrollDeltaFactor, int32_t, 100);
   DECL_GFX_PREF(Live, "mousewheel.transaction.ignoremovedelay",MouseWheelIgnoreMoveDelayMs, int32_t, (int32_t)100);
   DECL_GFX_PREF(Live, "mousewheel.transaction.timeout",        MouseWheelTransactionTimeoutMs, int32_t, (int32_t)1500);
 
   DECL_GFX_PREF(Live, "nglayout.debug.widget_update_flashing", WidgetUpdateFlashing, bool, false);
 
   DECL_GFX_PREF(Live, "test.events.async.enabled",             TestEventsAsyncEnabled, bool, false);
   DECL_GFX_PREF(Live, "test.mousescroll",                      MouseScrollTestingEnabled, bool, false);
 
--- a/widget/InputData.cpp
+++ b/widget/InputData.cpp
@@ -365,29 +365,34 @@ DeltaModeForDeltaType(ScrollWheelInput::
     case ScrollWheelInput::SCROLLDELTA_PAGE:
       return nsIDOMWheelEvent::DOM_DELTA_PAGE;
     case ScrollWheelInput::SCROLLDELTA_PIXEL:
     default:
       return nsIDOMWheelEvent::DOM_DELTA_PIXEL;
   }
 }
 
-ScrollWheelInput::ScrollWheelInput(const WidgetWheelEvent& aWheelEvent) :
-  InputData(SCROLLWHEEL_INPUT, aWheelEvent.time, aWheelEvent.timeStamp, aWheelEvent.modifiers),
-  mDeltaType(DeltaTypeForDeltaMode(aWheelEvent.deltaMode)),
-  mScrollMode(SCROLLMODE_INSTANT),
-  mHandledByAPZ(aWheelEvent.mFlags.mHandledByAPZ),
-  mDeltaX(aWheelEvent.deltaX),
-  mDeltaY(aWheelEvent.deltaY),
-  mLineOrPageDeltaX(aWheelEvent.lineOrPageDeltaX),
-  mLineOrPageDeltaY(aWheelEvent.lineOrPageDeltaY),
-  mUserDeltaMultiplierX(1.0),
-  mUserDeltaMultiplierY(1.0),
-  mMayHaveMomentum(aWheelEvent.mayHaveMomentum),
-  mIsMomentum(aWheelEvent.isMomentum)
+ScrollWheelInput::ScrollWheelInput(const WidgetWheelEvent& aWheelEvent)
+  : InputData(SCROLLWHEEL_INPUT,
+              aWheelEvent.time,
+              aWheelEvent.timeStamp,
+              aWheelEvent.modifiers)
+  , mDeltaType(DeltaTypeForDeltaMode(aWheelEvent.deltaMode))
+  , mScrollMode(SCROLLMODE_INSTANT)
+  , mHandledByAPZ(aWheelEvent.mFlags.mHandledByAPZ)
+  , mDeltaX(aWheelEvent.deltaX)
+  , mDeltaY(aWheelEvent.deltaY)
+  , mLineOrPageDeltaX(aWheelEvent.lineOrPageDeltaX)
+  , mLineOrPageDeltaY(aWheelEvent.lineOrPageDeltaY)
+  , mUserDeltaMultiplierX(1.0)
+  , mUserDeltaMultiplierY(1.0)
+  , mMayHaveMomentum(aWheelEvent.mayHaveMomentum)
+  , mIsMomentum(aWheelEvent.isMomentum)
+  , mAllowToOverrideSystemScrollSpeed(
+      aWheelEvent.mAllowToOverrideSystemScrollSpeed)
 {
   mOrigin =
     ScreenPoint(ViewAs<ScreenPixel>(aWheelEvent.refPoint,
       PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
 }
 
 WidgetWheelEvent
 ScrollWheelInput::ToWidgetWheelEvent(nsIWidget* aWidget) const
@@ -402,16 +407,18 @@ ScrollWheelInput::ToWidgetWheelEvent(nsI
   wheelEvent.buttons = 0;
   wheelEvent.deltaMode = DeltaModeForDeltaType(mDeltaType);
   wheelEvent.mayHaveMomentum = mMayHaveMomentum;
   wheelEvent.isMomentum = mIsMomentum;
   wheelEvent.deltaX = mDeltaX;
   wheelEvent.deltaY = mDeltaY;
   wheelEvent.lineOrPageDeltaX = mLineOrPageDeltaX;
   wheelEvent.lineOrPageDeltaY = mLineOrPageDeltaY;
+  wheelEvent.mAllowToOverrideSystemScrollSpeed =
+    mAllowToOverrideSystemScrollSpeed;
   wheelEvent.mFlags.mHandledByAPZ = mHandledByAPZ;
   return wheelEvent;
 }
 
 bool
 ScrollWheelInput::TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform)
 {
   Maybe<ParentLayerPoint> point = UntransformBy(aTransform, mOrigin);
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -567,31 +567,33 @@ public:
 
   ScrollWheelInput(uint32_t aTime,
                    TimeStamp aTimeStamp,
                    Modifiers aModifiers,
                    ScrollMode aScrollMode,
                    ScrollDeltaType aDeltaType,
                    const ScreenPoint& aOrigin,
                    double aDeltaX,
-                   double aDeltaY)
-   : InputData(SCROLLWHEEL_INPUT, aTime, aTimeStamp, aModifiers),
-     mDeltaType(aDeltaType),
-     mScrollMode(aScrollMode),
-     mOrigin(aOrigin),
-     mHandledByAPZ(false),
-     mDeltaX(aDeltaX),
-     mDeltaY(aDeltaY),
-     mLineOrPageDeltaX(0),
-     mLineOrPageDeltaY(0),
-     mScrollSeriesNumber(0),
-     mUserDeltaMultiplierX(1.0),
-     mUserDeltaMultiplierY(1.0),
-     mMayHaveMomentum(false),
-     mIsMomentum(false)
+                   double aDeltaY,
+                   bool aAllowToOverrideSystemScrollSpeed)
+    : InputData(SCROLLWHEEL_INPUT, aTime, aTimeStamp, aModifiers)
+    , mDeltaType(aDeltaType)
+    , mScrollMode(aScrollMode)
+    , mOrigin(aOrigin)
+    , mHandledByAPZ(false)
+    , mDeltaX(aDeltaX)
+    , mDeltaY(aDeltaY)
+    , mLineOrPageDeltaX(0)
+    , mLineOrPageDeltaY(0)
+    , mScrollSeriesNumber(0)
+    , mUserDeltaMultiplierX(1.0)
+    , mUserDeltaMultiplierY(1.0)
+    , mMayHaveMomentum(false)
+    , mIsMomentum(false)
+    , mAllowToOverrideSystemScrollSpeed(aAllowToOverrideSystemScrollSpeed)
   {}
 
   explicit ScrollWheelInput(const WidgetWheelEvent& aEvent);
 
   WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const;
   bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
 
   bool IsCustomizedByUserPrefs() const;
@@ -626,13 +628,14 @@ public:
   uint32_t mScrollSeriesNumber;
 
   // User-set delta multipliers.
   double mUserDeltaMultiplierX;
   double mUserDeltaMultiplierY;
 
   bool mMayHaveMomentum;
   bool mIsMomentum;
+  bool mAllowToOverrideSystemScrollSpeed;
 };
 
 } // namespace mozilla
 
 #endif // InputData_h__
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -4970,32 +4970,34 @@ PanGestureTypeForEvent(NSEvent* aEvent)
     mGeckoChild->DispatchAPZWheelInputEvent(panEvent, canTriggerSwipe);
   } else if (usePreciseDeltas) {
     // This is on 10.6 or old touchpads that don't have any phase information.
     ScrollWheelInput wheelEvent(eventIntervalTime, eventTimeStamp, modifiers,
                                 ScrollWheelInput::SCROLLMODE_INSTANT,
                                 ScrollWheelInput::SCROLLDELTA_PIXEL,
                                 position,
                                 preciseDelta.x,
-                                preciseDelta.y);
+                                preciseDelta.y,
+                                false);
     wheelEvent.mLineOrPageDeltaX = lineOrPageDeltaX;
     wheelEvent.mLineOrPageDeltaY = lineOrPageDeltaY;
     wheelEvent.mIsMomentum = nsCocoaUtils::IsMomentumScrollEvent(theEvent);
     mGeckoChild->DispatchAPZWheelInputEvent(wheelEvent, false);
   } else {
     ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::SCROLLMODE_INSTANT;
     if (gfxPrefs::SmoothScrollEnabled() && gfxPrefs::WheelSmoothScrollEnabled()) {
       scrollMode = ScrollWheelInput::SCROLLMODE_SMOOTH;
     }
     ScrollWheelInput wheelEvent(eventIntervalTime, eventTimeStamp, modifiers,
                                 scrollMode,
                                 ScrollWheelInput::SCROLLDELTA_LINE,
                                 position,
                                 lineOrPageDeltaX,
-                                lineOrPageDeltaY);
+                                lineOrPageDeltaY,
+                                false);
     wheelEvent.mLineOrPageDeltaX = lineOrPageDeltaX;
     wheelEvent.mLineOrPageDeltaY = lineOrPageDeltaY;
     mGeckoChild->DispatchAPZWheelInputEvent(wheelEvent, false);
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }