Title: [188641] trunk/Source/WebCore
Revision
188641
Author
wenson_hs...@apple.com
Date
2015-08-19 11:13:53 -0700 (Wed, 19 Aug 2015)

Log Message

Scroll snapping should trigger when receiving a momentum end wheel event
https://bugs.webkit.org/show_bug.cgi?id=148155

Reviewed by Alexey Proskuryakov.

No new tests, since the purpose of this patch is to get existing tests to pass when
allowing similar wheel events to coalesce. To accomplish this, we relax our assumption
that the user must have generated at least 3 momentum wheel events in order for the
gliding animation to trigger. Upon receiving a wheel event indicating the end of the
momentum phase, we now kick off the gliding animation as long as any momentum event
was tracked earlier in the gesture with a nonzero wheel delta.

* platform/cocoa/ScrollController.mm:
(WebCore::ScrollController::processWheelEventForScrollSnapOnAxis): Added logic to
    begin a glide animation if we have received a momentum end event but have not
    yet triggered a gliding animation.
* platform/cocoa/ScrollSnapAnimatorState.h:
* platform/cocoa/ScrollSnapAnimatorState.mm:
(WebCore::ScrollSnapAnimatorState::wheelDeltaTrackingIsInProgress): Minor refactoring
    to make the wheel event processing code more readable.
(WebCore::ScrollSnapAnimatorState::hasFinishedTrackingWheelDeltas): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (188640 => 188641)


--- trunk/Source/WebCore/ChangeLog	2015-08-19 16:50:50 UTC (rev 188640)
+++ trunk/Source/WebCore/ChangeLog	2015-08-19 18:13:53 UTC (rev 188641)
@@ -1,3 +1,27 @@
+2015-08-18  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Scroll snapping should trigger when receiving a momentum end wheel event
+        https://bugs.webkit.org/show_bug.cgi?id=148155
+
+        Reviewed by Alexey Proskuryakov.
+
+        No new tests, since the purpose of this patch is to get existing tests to pass when
+        allowing similar wheel events to coalesce. To accomplish this, we relax our assumption
+        that the user must have generated at least 3 momentum wheel events in order for the
+        gliding animation to trigger. Upon receiving a wheel event indicating the end of the
+        momentum phase, we now kick off the gliding animation as long as any momentum event
+        was tracked earlier in the gesture with a nonzero wheel delta.
+
+        * platform/cocoa/ScrollController.mm:
+        (WebCore::ScrollController::processWheelEventForScrollSnapOnAxis): Added logic to
+            begin a glide animation if we have received a momentum end event but have not
+            yet triggered a gliding animation.
+        * platform/cocoa/ScrollSnapAnimatorState.h:
+        * platform/cocoa/ScrollSnapAnimatorState.mm:
+        (WebCore::ScrollSnapAnimatorState::wheelDeltaTrackingIsInProgress): Minor refactoring
+            to make the wheel event processing code more readable.
+        (WebCore::ScrollSnapAnimatorState::hasFinishedTrackingWheelDeltas): Ditto.
+
 2015-08-18  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         [Cocoa] Punctuation near Hindi text is garbled when styled with the system font

Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.mm (188640 => 188641)


--- trunk/Source/WebCore/platform/cocoa/ScrollController.mm	2015-08-19 16:50:50 UTC (rev 188640)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.mm	2015-08-19 18:13:53 UTC (rev 188641)
@@ -554,15 +554,18 @@
     case WheelEventStatus::InertialScrolling:
         // This check for DestinationReached ensures that we don't receive another set of momentum events after ending the last glide.
         if (snapState.m_currentState != ScrollSnapState::Gliding && snapState.m_currentState != ScrollSnapState::DestinationReached) {
-            if (snapState.m_numWheelDeltasTracked < snapState.wheelDeltaWindowSize && wheelDelta)
+            if (snapState.wheelDeltaTrackingIsInProgress() && wheelDelta)
                 snapState.pushInitialWheelDelta(wheelDelta);
             
-            if ((snapState.m_numWheelDeltasTracked == snapState.wheelDeltaWindowSize) && snapState.averageInitialWheelDelta())
+            if (snapState.hasFinishedTrackingWheelDeltas() && snapState.averageInitialWheelDelta())
                 beginScrollSnapAnimation(axis, ScrollSnapState::Gliding);
         }
         break;
         
     case WheelEventStatus::InertialScrollEnd:
+        if (snapState.wheelDeltaTrackingIsInProgress() && snapState.averageInitialWheelDelta())
+            beginScrollSnapAnimation(axis, ScrollSnapState::Gliding);
+
         snapState.clearInitialWheelDeltaWindow();
         snapState.m_shouldOverrideWheelEvent = false;
         break;

Modified: trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.h (188640 => 188641)


--- trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.h	2015-08-19 16:50:50 UTC (rev 188640)
+++ trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.h	2015-08-19 18:13:53 UTC (rev 188641)
@@ -52,6 +52,8 @@
     void clearInitialWheelDeltaWindow();
     bool isSnapping() const;
     bool canReachTargetWithCurrentInitialScrollDelta() const;
+    bool wheelDeltaTrackingIsInProgress() const;
+    bool hasFinishedTrackingWheelDeltas() const;
     float interpolatedOffsetAtProgress(float) const;
     
     static const int wheelDeltaWindowSize = 3;

Modified: trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.mm (188640 => 188641)


--- trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.mm	2015-08-19 16:50:50 UTC (rev 188640)
+++ trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.mm	2015-08-19 18:13:53 UTC (rev 188641)
@@ -84,6 +84,16 @@
     return m_initialOffset < m_targetOffset ? m_initialScrollDelta > 0 : m_initialScrollDelta < 0;
 }
     
+bool ScrollSnapAnimatorState::wheelDeltaTrackingIsInProgress() const
+{
+    return m_numWheelDeltasTracked && m_numWheelDeltasTracked < wheelDeltaWindowSize;
+}
+
+bool ScrollSnapAnimatorState::hasFinishedTrackingWheelDeltas() const
+{
+    return m_numWheelDeltasTracked == wheelDeltaWindowSize;
+}
+
 float ScrollSnapAnimatorState::interpolatedOffsetAtProgress(float progress) const
 {
     progress = std::max(0.0f, std::min(1.0f, progress));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to