Bug 1193062 - Make OverscrollHandoffChain::FindFirstScrollable and AsyncPanZoomController::CanScroll able to deal with PanGestureInput events. r=kats
authorMarkus Stange <mstange@themasta.com>
Wed, 26 Aug 2015 11:14:33 -0400
changeset 259470 4178531f85b2d539eb2da75e886628320ac33729
parent 259469 2eef76258ff51cbfda420612c6108cbc111bbb74
child 259471 5f3585512590ebef256e09219f9a12efdce28891
push id29279
push userryanvm@gmail.com
push dateThu, 27 Aug 2015 00:32:41 +0000
treeherdermozilla-central@c1121b67faa0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1193062
milestone43.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 1193062 - Make OverscrollHandoffChain::FindFirstScrollable and AsyncPanZoomController::CanScroll able to deal with PanGestureInput events. r=kats
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/AsyncPanZoomController.h
gfx/layers/apz/src/OverscrollHandoffState.cpp
gfx/layers/apz/src/OverscrollHandoffState.h
widget/InputData.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -1429,37 +1429,37 @@ AsyncPanZoomController::ConvertToGecko(c
     return true;
   }
   return false;
 }
 
 ParentLayerPoint
 AsyncPanZoomController::GetScrollWheelDelta(const ScrollWheelInput& aEvent) const
 {
-  ParentLayerPoint scrollAmount;
-  ParentLayerPoint pageScrollSize;
+  ParentLayerSize scrollAmount;
+  ParentLayerSize pageScrollSize;
   bool isRootContent = false;
 
   {
     // Grab the lock to access the frame metrics.
     ReentrantMonitorAutoEnter lock(mMonitor);
     LayoutDeviceIntSize scrollAmountLD = mFrameMetrics.GetLineScrollAmount();
     LayoutDeviceIntSize pageScrollSizeLD = mFrameMetrics.GetPageScrollAmount();
     isRootContent = mFrameMetrics.IsRootContent();
-    scrollAmount = LayoutDevicePoint(scrollAmountLD.width, scrollAmountLD.height) /
+    scrollAmount = scrollAmountLD /
       mFrameMetrics.GetDevPixelsPerCSSPixel() * mFrameMetrics.GetZoom();
-    pageScrollSize = LayoutDevicePoint(pageScrollSizeLD.width, pageScrollSizeLD.height) /
+    pageScrollSize = pageScrollSizeLD /
       mFrameMetrics.GetDevPixelsPerCSSPixel() * mFrameMetrics.GetZoom();
   }
 
   ParentLayerPoint delta;
   switch (aEvent.mDeltaType) {
     case ScrollWheelInput::SCROLLDELTA_LINE: {
-      delta.x = aEvent.mDeltaX * scrollAmount.x;
-      delta.y = aEvent.mDeltaY * scrollAmount.y;
+      delta.x = aEvent.mDeltaX * scrollAmount.width;
+      delta.y = aEvent.mDeltaY * scrollAmount.height;
       break;
     }
     case ScrollWheelInput::SCROLLDELTA_PIXEL: {
       delta = ToParentLayerCoordinates(ScreenPoint(aEvent.mDeltaX, aEvent.mDeltaY), aEvent.mOrigin);
       break;
     }
     default:
       MOZ_ASSERT_UNREACHABLE("unexpected scroll delta type");
@@ -1472,35 +1472,41 @@ AsyncPanZoomController::GetScrollWheelDe
     if (vfactor > 1.0) {
       delta.x *= hfactor;
     }
     if (hfactor > 1.0) {
       delta.y *= vfactor;
     }
   }
 
-  if (Abs(delta.x) > pageScrollSize.x) {
+  if (Abs(delta.x) > pageScrollSize.width) {
     delta.x = (delta.x >= 0)
-              ? pageScrollSize.x
-              : -pageScrollSize.x;
+              ? pageScrollSize.width
+              : -pageScrollSize.width;
   }
-  if (Abs(delta.y) > pageScrollSize.y) {
+  if (Abs(delta.y) > pageScrollSize.height) {
     delta.y = (delta.y >= 0)
-              ? pageScrollSize.y
-              : -pageScrollSize.y;
+              ? pageScrollSize.height
+              : -pageScrollSize.height;
   }
 
   return delta;
 }
 
 // Return whether or not the underlying layer can be scrolled on either axis.
 bool
-AsyncPanZoomController::CanScroll(const ScrollWheelInput& aEvent) const
+AsyncPanZoomController::CanScroll(const InputData& aEvent) const
 {
-  ParentLayerPoint delta = GetScrollWheelDelta(aEvent);
+  ParentLayerPoint delta;
+  if (aEvent.mInputType == SCROLLWHEEL_INPUT) {
+    delta = GetScrollWheelDelta(aEvent.AsScrollWheelInput());
+  } else if (aEvent.mInputType == PANGESTURE_INPUT) {
+    const PanGestureInput& panInput = aEvent.AsPanGestureInput();
+    delta = ToParentLayerCoordinates(panInput.mPanDisplacement, panInput.mPanStartPoint);
+  }
   if (!delta.x && !delta.y) {
     return false;
   }
 
   return CanScrollWithWheel(delta);
 }
 
 bool
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -365,17 +365,17 @@ public:
    * To respect the lock ordering, mMonitor must NOT be held when calling
    * this function (since this function acquires the tree lock).
    */
   ParentLayerPoint ToParentLayerCoordinates(const ScreenPoint& aVector,
                                             const ScreenPoint& aAnchor) const;
 
   // Return whether or not a wheel event will be able to scroll in either
   // direction.
-  bool CanScroll(const ScrollWheelInput& aEvent) const;
+  bool CanScroll(const InputData& aEvent) const;
 
   // Return whether or not a scroll delta will be able to scroll in either
   // direction.
   bool CanScrollWithWheel(const ParentLayerPoint& aDelta) const;
 
   // Return whether or not there is room to scroll this APZC
   // in the given direction.
   bool CanScroll(Layer::ScrollDirection aDirection) const;
--- a/gfx/layers/apz/src/OverscrollHandoffState.cpp
+++ b/gfx/layers/apz/src/OverscrollHandoffState.cpp
@@ -169,17 +169,17 @@ OverscrollHandoffChain::HasApzcPannedInt
 
 bool
 OverscrollHandoffChain::HasFastFlungApzc() const
 {
   return AnyApzc(&AsyncPanZoomController::IsFlingingFast);
 }
 
 nsRefPtr<AsyncPanZoomController>
-OverscrollHandoffChain::FindFirstScrollable(const ScrollWheelInput& aInput) const
+OverscrollHandoffChain::FindFirstScrollable(const InputData& aInput) const
 {
   for (size_t i = 0; i < Length(); i++) {
     if (mChain[i]->CanScroll(aInput)) {
       return mChain[i];
     }
   }
   return nullptr;
 }
--- a/gfx/layers/apz/src/OverscrollHandoffState.h
+++ b/gfx/layers/apz/src/OverscrollHandoffState.h
@@ -81,17 +81,17 @@ public:
                             Layer::ScrollDirection aDirection) const;
 
   // Determine whether any APZC along this handoff chain is panned into overscroll.
   bool HasApzcPannedIntoOverscroll() const;
 
   // Determine whether any APZC along this handoff chain has been flung fast.
   bool HasFastFlungApzc() const;
 
-  nsRefPtr<AsyncPanZoomController> FindFirstScrollable(const ScrollWheelInput& aInput) const;
+  nsRefPtr<AsyncPanZoomController> FindFirstScrollable(const InputData& aInput) const;
 
 private:
   std::vector<nsRefPtr<AsyncPanZoomController>> mChain;
 
   typedef void (AsyncPanZoomController::*APZCMethod)();
   typedef bool (AsyncPanZoomController::*APZCPredicate)() const;
   void ForEachApzc(APZCMethod aMethod) const;
   bool AnyApzc(APZCPredicate aPredicate) const;
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -524,16 +524,17 @@ public:
 
   ScrollDeltaType mDeltaType;
   ScrollMode mScrollMode;
   ScreenPoint mOrigin;
 
   // Deltas are in units corresponding to the delta type. For line deltas, they
   // are the number of line units to scroll. The number of device pixels for a
   // horizontal and vertical line unit are in FrameMetrics::mLineScrollAmount.
+  // For pixel deltas, these values are in ScreenCoords.
   //
   // The horizontal (X) delta is > 0 for scrolling right and < 0 for scrolling
   // left. The vertical (Y) delta is < 0 for scrolling up and > 0 for
   // scrolling down.
   double mDeltaX;
   double mDeltaY;
 
   // The location of the scroll in local coordinates. This is set and used by