Add page scroll support for APZ wheel events. (bug 1228028, r=kats)
authorDavid Anderson <danderson@mozilla.com>
Wed, 02 Dec 2015 17:05:11 -0800
changeset 275373 f7ee42669b87f05416eb785ab9db27b5c66de1a3
parent 275372 0dbac1acaca7ae2a767604fdbcf5105853518c88
child 275374 d873179a7da024a8d42b73e571d64b1eb53efa63
push id29752
push usercbook@mozilla.com
push dateThu, 03 Dec 2015 11:03:31 +0000
treeherdermozilla-central@85cf2e720a84 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1228028
milestone45.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
Add page scroll support for APZ wheel events. (bug 1228028, r=kats)
gfx/layers/apz/src/APZCTreeManager.cpp
gfx/layers/apz/src/AsyncPanZoomController.cpp
widget/InputData.cpp
widget/InputData.h
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -621,17 +621,18 @@ APZCTreeManager::UpdateHitTestingTree(Tr
 //
 // Even if this returns false, all wheel events in APZ-aware widgets must
 // be sent through APZ so they are transformed correctly for TabParent.
 static bool
 WillHandleWheelEvent(WidgetWheelEvent* aEvent)
 {
   return EventStateManager::WheelEventIsScrollAction(aEvent) &&
          (aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_LINE ||
-          aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_PIXEL);
+          aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_PIXEL ||
+          aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_PAGE);
 }
 
 static bool
 WillHandleMouseEvent(const WidgetMouseEventBase& aEvent)
 {
   if (!gfxPrefs::APZDragEnabled()) {
     return false;
   }
@@ -1074,18 +1075,20 @@ APZCTreeManager::ProcessMouseEvent(Widge
 }
 
 nsEventStatus
 APZCTreeManager::ProcessWheelEvent(WidgetWheelEvent& aEvent,
                                    ScrollableLayerGuid* aOutTargetGuid,
                                    uint64_t* aOutInputBlockId)
 {
   ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::SCROLLMODE_INSTANT;
-  if (aEvent.deltaMode == nsIDOMWheelEvent::DOM_DELTA_LINE &&
-      gfxPrefs::SmoothScrollEnabled() && gfxPrefs::WheelSmoothScrollEnabled()) {
+  if ((aEvent.deltaMode == nsIDOMWheelEvent::DOM_DELTA_LINE ||
+       aEvent.deltaMode == nsIDOMWheelEvent::DOM_DELTA_PAGE) &&
+      gfxPrefs::SmoothScrollEnabled() && gfxPrefs::WheelSmoothScrollEnabled())
+  {
     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,
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -1591,16 +1591,21 @@ AsyncPanZoomController::GetScrollWheelDe
 
   ParentLayerPoint delta;
   switch (aEvent.mDeltaType) {
     case ScrollWheelInput::SCROLLDELTA_LINE: {
       delta.x = aEvent.mDeltaX * scrollAmount.width;
       delta.y = aEvent.mDeltaY * scrollAmount.height;
       break;
     }
+    case ScrollWheelInput::SCROLLDELTA_PAGE: {
+      delta.x = aEvent.mDeltaX * pageScrollSize.width;
+      delta.y = aEvent.mDeltaY * pageScrollSize.height;
+      break;
+    }
     case ScrollWheelInput::SCROLLDELTA_PIXEL: {
       delta = ToParentLayerCoordinates(ScreenPoint(aEvent.mDeltaX, aEvent.mDeltaY), aEvent.mOrigin);
       break;
     }
     default:
       MOZ_ASSERT_UNREACHABLE("unexpected scroll delta type");
   }
 
--- a/widget/InputData.cpp
+++ b/widget/InputData.cpp
@@ -356,16 +356,18 @@ TapGestureInput::TransformToLocal(const 
 }
 
 static uint32_t
 DeltaModeForDeltaType(ScrollWheelInput::ScrollDeltaType aDeltaType)
 {
   switch (aDeltaType) {
     case ScrollWheelInput::SCROLLDELTA_LINE:
       return nsIDOMWheelEvent::DOM_DELTA_LINE;
+    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),
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -537,25 +537,28 @@ public:
 class ScrollWheelInput : public InputData
 {
 public:
   enum ScrollDeltaType
   {
     // There are three kinds of scroll delta modes in Gecko: "page", "line" and
     // "pixel". For apz, we currently only support the "line" and "pixel" modes.
     SCROLLDELTA_LINE,
+    SCROLLDELTA_PAGE,
     SCROLLDELTA_PIXEL
   };
 
   static ScrollDeltaType
   DeltaTypeForDeltaMode(uint32_t aDeltaMode)
   {
     switch (aDeltaMode) {
       case nsIDOMWheelEvent::DOM_DELTA_LINE:
         return SCROLLDELTA_LINE;
+      case nsIDOMWheelEvent::DOM_DELTA_PAGE:
+        return SCROLLDELTA_PAGE;
       case nsIDOMWheelEvent::DOM_DELTA_PIXEL:
         return SCROLLDELTA_PIXEL;
       default:
         MOZ_CRASH();
     }
     return SCROLLDELTA_LINE;
   }