Changeset 188641 in webkit


Ignore:
Timestamp:
Aug 19, 2015 11:13:53 AM (9 years ago)
Author:
Wenson Hsieh
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.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r188634 r188641  
     12015-08-18  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Scroll snapping should trigger when receiving a momentum end wheel event
     4        https://bugs.webkit.org/show_bug.cgi?id=148155
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        No new tests, since the purpose of this patch is to get existing tests to pass when
     9        allowing similar wheel events to coalesce. To accomplish this, we relax our assumption
     10        that the user must have generated at least 3 momentum wheel events in order for the
     11        gliding animation to trigger. Upon receiving a wheel event indicating the end of the
     12        momentum phase, we now kick off the gliding animation as long as any momentum event
     13        was tracked earlier in the gesture with a nonzero wheel delta.
     14
     15        * platform/cocoa/ScrollController.mm:
     16        (WebCore::ScrollController::processWheelEventForScrollSnapOnAxis): Added logic to
     17            begin a glide animation if we have received a momentum end event but have not
     18            yet triggered a gliding animation.
     19        * platform/cocoa/ScrollSnapAnimatorState.h:
     20        * platform/cocoa/ScrollSnapAnimatorState.mm:
     21        (WebCore::ScrollSnapAnimatorState::wheelDeltaTrackingIsInProgress): Minor refactoring
     22            to make the wheel event processing code more readable.
     23        (WebCore::ScrollSnapAnimatorState::hasFinishedTrackingWheelDeltas): Ditto.
     24
    1252015-08-18  Myles C. Maxfield  <mmaxfield@apple.com>
    226
  • trunk/Source/WebCore/platform/cocoa/ScrollController.mm

    r186469 r188641  
    555555        // This check for DestinationReached ensures that we don't receive another set of momentum events after ending the last glide.
    556556        if (snapState.m_currentState != ScrollSnapState::Gliding && snapState.m_currentState != ScrollSnapState::DestinationReached) {
    557             if (snapState.m_numWheelDeltasTracked < snapState.wheelDeltaWindowSize && wheelDelta)
     557            if (snapState.wheelDeltaTrackingIsInProgress() && wheelDelta)
    558558                snapState.pushInitialWheelDelta(wheelDelta);
    559559           
    560             if ((snapState.m_numWheelDeltasTracked == snapState.wheelDeltaWindowSize) && snapState.averageInitialWheelDelta())
     560            if (snapState.hasFinishedTrackingWheelDeltas() && snapState.averageInitialWheelDelta())
    561561                beginScrollSnapAnimation(axis, ScrollSnapState::Gliding);
    562562        }
     
    564564       
    565565    case WheelEventStatus::InertialScrollEnd:
     566        if (snapState.wheelDeltaTrackingIsInProgress() && snapState.averageInitialWheelDelta())
     567            beginScrollSnapAnimation(axis, ScrollSnapState::Gliding);
     568
    566569        snapState.clearInitialWheelDeltaWindow();
    567570        snapState.m_shouldOverrideWheelEvent = false;
  • trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.h

    r186469 r188641  
    5353    bool isSnapping() const;
    5454    bool canReachTargetWithCurrentInitialScrollDelta() const;
     55    bool wheelDeltaTrackingIsInProgress() const;
     56    bool hasFinishedTrackingWheelDeltas() const;
    5557    float interpolatedOffsetAtProgress(float) const;
    5658   
  • trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.mm

    r186469 r188641  
    8585}
    8686   
     87bool ScrollSnapAnimatorState::wheelDeltaTrackingIsInProgress() const
     88{
     89    return m_numWheelDeltasTracked && m_numWheelDeltasTracked < wheelDeltaWindowSize;
     90}
     91
     92bool ScrollSnapAnimatorState::hasFinishedTrackingWheelDeltas() const
     93{
     94    return m_numWheelDeltasTracked == wheelDeltaWindowSize;
     95}
     96
    8797float ScrollSnapAnimatorState::interpolatedOffsetAtProgress(float progress) const
    8898{
Note: See TracChangeset for help on using the changeset viewer.