Bug 1255634 - APZ should scroll by more than a page with large values of mousewheel.default.delta_multiplier_{x,y}. r=masayuki,kats
authorAndrew McCreight <continuation@gmail.com>
Tue, 12 Apr 2016 00:06:49 -0400
changeset 292710 927fe582c13f5406cc7c2af7b0dbe1b3ce99f57e
parent 292709 a68f4eb45a851e94f19fab3a780f3e329d2b2aa8
child 292711 d8d50064c15b51ccdeae349dca3b0a83e567487e
push id74961
push userkgupta@mozilla.com
push dateTue, 12 Apr 2016 04:07:14 +0000
treeherdermozilla-inbound@927fe582c13f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki, kats
bugs1255634
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1255634 - APZ should scroll by more than a page with large values of mousewheel.default.delta_multiplier_{x,y}. r=masayuki,kats The constants in doTestWholeScroll() have to be reduced because otherwise some subtests end up returning results that are off by a few pixels with e10s, presumably due to differences in floating point precision in APZ compared to non-APZ. MozReview-Commit-ID: BxmqHrcN8IL
dom/events/EventStateManager.h
dom/events/test/window_wheel_default_action.html
gfx/layers/apz/src/AsyncPanZoomController.cpp
--- a/dom/events/EventStateManager.h
+++ b/dom/events/EventStateManager.h
@@ -289,16 +289,25 @@ public:
   // dom::Event::GetClientCoords() to make mouse events' client coords appear
   // frozen at the last mouse position while the pointer is locked.
   static CSSIntPoint sLastClientPoint;
 
   static bool sIsPointerLocked;
   static nsWeakPtr sPointerLockedElement;
   static nsWeakPtr sPointerLockedDoc;
 
+  /**
+   * If the absolute values of mMultiplierX and/or mMultiplierY are equal or
+   * larger than this value, the computed scroll amount isn't rounded down to
+   * the page width or height.
+   */
+  enum {
+    MIN_MULTIPLIER_VALUE_ALLOWING_OVER_ONE_PAGE_SCROLL = 1000
+  };
+
 protected:
   /**
    * Prefs class capsules preference management.
    */
   class Prefs
   {
   public:
     static bool KeyCausesActivation() { return sKeyCausesActivation; }
@@ -555,25 +564,16 @@ protected:
      *                      "mousewheel.default.".
      */
     void GetBasePrefName(Index aIndex, nsACString& aBasePrefName);
 
     void Init(Index aIndex);
 
     void Reset();
 
-    /**
-     * If the abosolute values of mMultiplierX and/or mMultiplierY are equals or
-     * larger than this value, the computed scroll amount isn't rounded down to
-     * the page width or height.
-     */
-    enum {
-      MIN_MULTIPLIER_VALUE_ALLOWING_OVER_ONE_PAGE_SCROLL = 1000
-    };
-
     bool mInit[COUNT_OF_MULTIPLIERS];
     double mMultiplierX[COUNT_OF_MULTIPLIERS];
     double mMultiplierY[COUNT_OF_MULTIPLIERS];
     double mMultiplierZ[COUNT_OF_MULTIPLIERS];
     Action mActions[COUNT_OF_MULTIPLIERS];
     /**
      * action values overridden by .override_x pref.
      * If an .override_x value is -1, same as the
--- a/dom/events/test/window_wheel_default_action.html
+++ b/dom/events/test/window_wheel_default_action.html
@@ -1347,18 +1347,18 @@ function doTestZoomedScroll(aCallback)
   //     is computed by complex logic.
 
   prepareTestZoomedPixelScroll();
 }
 
 function doTestWholeScroll(aCallback)
 {
   SpecialPowers.pushPrefEnv({"set": [
-    ["mousewheel.default.delta_multiplier_x", 99999999],
-    ["mousewheel.default.delta_multiplier_y", 99999999]]},
+    ["mousewheel.default.delta_multiplier_x", 999999],
+    ["mousewheel.default.delta_multiplier_y", 999999]]},
     function() { doTestWholeScroll2(aCallback); });
 }
 
 function doTestWholeScroll2(aCallback)
 {
   const kTests = [
     { description: "try whole-scroll to top (line)",
       prepare: function () {
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -1645,16 +1645,24 @@ AsyncPanZoomController::ConvertToGecko(c
                   PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent))
             / mFrameMetrics.GetDevPixelsPerCSSPixel();
     }
     return true;
   }
   return false;
 }
 
+static bool
+AllowsScrollingMoreThanOnePage(double aMultiplier)
+{
+  const int32_t kMinAllowPageScroll =
+    EventStateManager::MIN_MULTIPLIER_VALUE_ALLOWING_OVER_ONE_PAGE_SCROLL;
+  return Abs(aMultiplier) >= kMinAllowPageScroll;
+}
+
 ParentLayerPoint
 AsyncPanZoomController::GetScrollWheelDelta(const ScrollWheelInput& aEvent) const
 {
   ParentLayerSize scrollAmount;
   ParentLayerSize pageScrollSize;
   bool isRootContent = false;
 
   {
@@ -1715,22 +1723,26 @@ AsyncPanZoomController::GetScrollWheelDe
       int32_t factor = gfxPrefs::MouseWheelAccelerationFactor();
       if (factor > 0) {
         delta.x = ComputeAcceleratedWheelDelta(delta.x, aEvent.mScrollSeriesNumber, factor);
         delta.y = ComputeAcceleratedWheelDelta(delta.y, aEvent.mScrollSeriesNumber, factor);
       }
     }
   }
 
-  if (Abs(delta.x) > pageScrollSize.width) {
+  // We shouldn't scroll more than one page at once except when the
+  // user preference is large.
+  if (!AllowsScrollingMoreThanOnePage(aEvent.mUserDeltaMultiplierX) &&
+      Abs(delta.x) > pageScrollSize.width) {
     delta.x = (delta.x >= 0)
               ? pageScrollSize.width
               : -pageScrollSize.width;
   }
-  if (Abs(delta.y) > pageScrollSize.height) {
+  if (!AllowsScrollingMoreThanOnePage(aEvent.mUserDeltaMultiplierY) &&
+      Abs(delta.y) > pageScrollSize.height) {
     delta.y = (delta.y >= 0)
               ? pageScrollSize.height
               : -pageScrollSize.height;
   }
 
   return delta;
 }