Bug 1355340 - Don't attempt to accumulate line scrolls for line scroll events. r?masayuki draft
authorMarkus Stange <mstange@themasta.com>
Thu, 20 Apr 2017 15:21:48 -0400
changeset 566081 225aaedbb840379722161c7fcfc5adb3577da24c
parent 565261 a34919b3d942cfd4f0737d432742b0ffa9929389
child 566086 4057b470a976db6f7022a83b3dedb5d11605fb83
push id55075
push userbmo:mstange@themasta.com
push dateThu, 20 Apr 2017 19:22:06 +0000
reviewersmasayuki
bugs1355340
milestone55.0a1
Bug 1355340 - Don't attempt to accumulate line scrolls for line scroll events. r?masayuki MozReview-Commit-ID: 6xvqJBVupYo
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -4835,26 +4835,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]) {