Bug 1016035 - More swipe refactoring. r=kats
authorMarkus Stange <mstange@themasta.com>
Thu, 23 Jul 2015 15:17:28 -0400
changeset 259973 2274ab11481d959ff6b90448d8e136f117f935f0
parent 259972 e2743b8411a3e1b41ebac9f62421b61a1e339988
child 259974 5d4380c90c053a1d42b5b8eaef0bdd2273ddb02d
push id29296
push userryanvm@gmail.com
push dateSun, 30 Aug 2015 19:45:10 +0000
treeherdermozilla-central@2ad5077d86ba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1016035
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 1016035 - More swipe refactoring. r=kats
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -305,20 +305,17 @@ typedef NSInteger NSEventGestureAxis;
 - (void)scrollWheel:(NSEvent *)anEvent;
 - (void)handleAsyncScrollEvent:(CGEventRef)cgEvent ofType:(CGEventType)type;
 
 // Helper function for Lion smart magnify events
 + (BOOL)isLionSmartMagnifyEvent:(NSEvent*)anEvent;
 
 // Support for fluid swipe tracking.
 #ifdef __LP64__
-- (void)maybeTrackScrollEventAsSwipe:(NSEvent *)anEvent
-                     scrollOverflowX:(double)anOverflowX
-                     scrollOverflowY:(double)anOverflowY
-              viewPortIsOverscrolled:(BOOL)aViewPortIsOverscrolled;
+- (void)maybeTrackScrollEventAsSwipe:(NSEvent *)anEvent;
 #endif
 
 - (void)setUsingOMTCompositor:(BOOL)aUseOMTC;
 
 - (NSEvent*)lastKeyDownEvent;
 @end
 
 class ChildViewMouseTracker {
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -4324,34 +4324,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
 // for deciding which is which. But once the decision is made, the OS tracks
 // the swipe until it has finished, and decides whether or not it succeeded.
 // A horizontal swipe has the same functionality as the Back and Forward
 // buttons.
 // This method is partly based on Apple sample code available at
 // developer.apple.com/library/mac/#releasenotes/Cocoa/AppKitOlderNotes.html
 // (under Fluid Swipe Tracking API).
 - (void)maybeTrackScrollEventAsSwipe:(NSEvent *)anEvent
-                     scrollOverflowX:(double)anOverflowX
-                     scrollOverflowY:(double)anOverflowY
-              viewPortIsOverscrolled:(BOOL)aViewPortIsOverscrolled
-{
-  // We should only track scroll events as swipe if the viewport is being
-  // overscrolled.
-  if (!aViewPortIsOverscrolled) {
-    return;
-  }
-
-  // Only initiate tracking if the user has tried to scroll past the edge of
-  // the current page (as indicated by 'anOverflowX' or 'anOverflowY' being
-  // non-zero). Gecko only sets WidgetMouseScrollEvent.scrollOverflow when it's
-  // processing NS_MOUSE_PIXEL_SCROLL events (not NS_MOUSE_SCROLL events).
-  if (anOverflowX == 0.0) {
-    return;
-  }
-
+{
   CGFloat deltaX = [anEvent scrollingDeltaX];
 
   uint32_t direction = (deltaX < 0.0)
     ? (uint32_t)nsIDOMSimpleGestureEvent::DIRECTION_RIGHT
     : (uint32_t)nsIDOMSimpleGestureEvent::DIRECTION_LEFT;
 
   // We're ready to start the animation. Tell Gecko about it, and at the same
   // time ask it if it really wants to start an animation for this event.
@@ -4895,16 +4878,24 @@ PanGestureTypeForEvent(NSEvent* aEvent)
           return PanGestureInput::PANGESTURE_PAN;
       }
     default:
       NS_ERROR("unexpected event phase");
       return PanGestureInput::PANGESTURE_PAN;
   }
 }
 
+static bool
+IsPotentialSwipeStartEventOverscrollingViewport(const WidgetWheelEvent& aEvent)
+{
+  // We should only track scroll events as swipe if the viewport is being
+  // overscrolled.
+  return aEvent.mViewPortIsOverscrolled && aEvent.overflowDeltaX != 0.0;
+}
+
 - (void)scrollWheel:(NSEvent*)theEvent
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (gfxPrefs::AsyncPanZoomSeparateEventThread() && [self apzctm]) {
     // Disable main-thread scrolling completely when using APZ with the
     // separate event thread. This is bug 1013412.
     return;
@@ -4968,23 +4959,18 @@ PanGestureTypeForEvent(NSEvent* aEvent)
     widgetWheelEvent = mGeckoChild->DispatchAPZWheelInputEvent(panEvent);
 
     if (!mGeckoChild) {
       return;
     }
 
 #ifdef __LP64__
     bool canTriggerSwipe = [self shouldConsiderStartingSwipeFromEvent:theEvent];
-    if (canTriggerSwipe) {
-      // overflowDeltaX and overflowDeltaY tell us when the user has tried to
-      // scroll past the edge of a page (in those cases it's non-zero).
-      [self maybeTrackScrollEventAsSwipe:theEvent
-                         scrollOverflowX:widgetWheelEvent.overflowDeltaX
-                         scrollOverflowY:widgetWheelEvent.overflowDeltaY
-                  viewPortIsOverscrolled:widgetWheelEvent.mViewPortIsOverscrolled];
+    if (canTriggerSwipe && IsPotentialSwipeStartEventOverscrollingViewport(widgetWheelEvent)) {
+      [self maybeTrackScrollEventAsSwipe:theEvent];
     }
 #endif // #ifdef __LP64__
 
   } 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,