Bug 1355340 - Don't attempt to accumulate line scrolls for line scroll events. r=masayuki, a=ritu
authorMarkus Stange <mstange@themasta.com>
Thu, 20 Apr 2017 15:21:48 -0400
changeset 578500 6b174b41fa44963901d4f09597bd97f60e8e9076
parent 578499 dea90d232813befee3c736800ad140e3b5cdaf9e
child 578501 779be1f13cb996f18cc08abca120dc4c3af86a88
child 641644 5827f42b5caf6afa9762b7ebaf1f9ced3ae57bbd
push id58939
push userbmo:cku@mozilla.com
push dateTue, 16 May 2017 04:17:59 +0000
reviewersmasayuki, ritu
bugs1355340
milestone52.1.2
Bug 1355340 - Don't attempt to accumulate line scrolls for line scroll events. r=masayuki, a=ritu MozReview-Commit-ID: 6xvqJBVupYo
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -4820,26 +4820,30 @@ AccumulateIntegerDelta(NSEvent* aEvent)
   sAccumulator.y += [aEvent deltaY];
   return gfx::IntPoint(TakeLargestInt(&sAccumulator.x),
                        TakeLargestInt(&sAccumulator.y));
 }
 
 static gfx::IntPoint
 GetIntegerDeltaForEvent(NSEvent* aEvent)
 {
-  if (nsCocoaFeatures::OnSierraOrLater()) {
+  if (nsCocoaFeatures::OnSierraOrLater() && [aEvent hasPreciseScrollingDeltas]) {
+    // Pixel scroll events (events with hasPreciseScrollingDeltas == YES)
+    // carry pixel deltas in the scrollingDeltaX/Y fields and line scroll
+    // information in the deltaX/Y fields.
+    // Prior to 10.12, these line scroll fields would be zero for most pixel
+    // scroll events and non-zero for some, whenever at least a full line
+    // worth of pixel scrolling had accumulated. That's the behavior we want.
+    // Starting with 10.12 however, pixel scroll events no longer accumulate
+    // deltaX and deltaY; they just report floating point values for every
+    // single event. So we need to do our own accumulation.
     return AccumulateIntegerDelta(aEvent);
   }
 
-  // Pre-10.12, deltaX/deltaY had the accumulation behavior that we want, and
-  // it worked more reliably than doing it on our own, so use it on pre-10.12
-  // versions. For example, with a traditional USB mouse, the first wheel
-  // "tick" would always senda line scroll of at least one line, but with our
-  // own accumulation you sometimes need to do multiple wheel ticks before one
-  // line has been accumulated.
+  // For line scrolls, or pre-10.12, just use the rounded up value of deltaX / deltaY.
   return gfx::IntPoint(RoundUp([aEvent deltaX]), RoundUp([aEvent deltaY]));
 }
 
 - (void)scrollWheel:(NSEvent*)theEvent
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (gfxPrefs::AsyncPanZoomSeparateEventThread() && [self apzctm]) {