⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 285917 in webkit


Ignore:
Timestamp:
Nov 16, 2021, 10:25:17 PM (5 years ago)
Author:
Simon Fraser
Message:

Stop a momentum scroll animation when receiving a momentum end event
https://bugs.webkit.org/show_bug.cgi?id=233236

Reviewed by Tim Horton.

Source/WebCore:

The stream of momentum events is terminated by an "end" event under two circumstances:

  1. The gesture finished naturally without interruption.
  2. The user tapped the trackpad with two fingers.

Unfortunately we can't tell these apart, so we always have to stop the animation.

Sadly this reveals a hole in the testing infrastructure. All the "changed" momentum
events in the sequence handed to UIHelper.mouseWheelSequence() are ignored while the
animation is running, but the "ended" event stops the animation. So any test without
a reasonable number of "changed" events will terminate its animation prematurely.
We can't fix this without new testing infrastructure (webkit.org/b/233234).

Test: fast/scrolling/mac/momentum-animator-end-event-stops.html

  • platform/ScrollingEffectsController.h:
  • platform/mac/ScrollingEffectsController.mm:

(WebCore::ScrollingEffectsController::handleWheelEvent):

LayoutTests:

New test, and skip one that breaks now because we need a fix for webkit.org/b/233234.

  • fast/scrolling/mac/momentum-animator-end-event-stops-expected.txt: Added.
  • fast/scrolling/mac/momentum-animator-end-event-stops.html: Added.
  • platform/mac-wk2/TestExpectations:
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r285912 r285917  
     12021-11-16  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Stop a momentum scroll animation when receiving a momentum end event
     4        https://bugs.webkit.org/show_bug.cgi?id=233236
     5
     6        Reviewed by Tim Horton.
     7
     8        New test, and skip one that breaks now because we need a fix for webkit.org/b/233234.
     9
     10        * fast/scrolling/mac/momentum-animator-end-event-stops-expected.txt: Added.
     11        * fast/scrolling/mac/momentum-animator-end-event-stops.html: Added.
     12        * platform/mac-wk2/TestExpectations:
     13
    1142021-11-16  Sihui Liu  <sihui_liu@apple.com>
    215
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r285669 r285917  
    15631563
    15641564webkit.org/b/228591 fast/scrolling/mac/programmatic-scroll-overrides-rubberband.html [ Pass Failure ]
     1565webkit.org/b/233234 fast/scrolling/mac/momentum-animator-in-overflow.html [ Failure ]
    15651566
    15661567webkit.org/b/229156 [ BigSur+ ] webrtc/video-addTrack.html [ Pass Failure ]
  • trunk/Source/WebCore/ChangeLog

    r285916 r285917  
     12021-11-16  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Stop a momentum scroll animation when receiving a momentum end event
     4        https://bugs.webkit.org/show_bug.cgi?id=233236
     5
     6        Reviewed by Tim Horton.
     7
     8        The stream of momentum events is terminated by an "end" event under two circumstances:
     9        1. The gesture finished naturally without interruption.
     10        2. The user tapped the trackpad with two fingers.
     11
     12        Unfortunately we can't tell these apart, so we always have to stop the animation.
     13       
     14        Sadly this reveals a hole in the testing infrastructure. All the "changed" momentum
     15        events in the sequence handed to UIHelper.mouseWheelSequence() are ignored while the
     16        animation is running, but the "ended" event stops the animation. So any test without
     17        a reasonable number of "changed" events will terminate its animation prematurely.
     18        We can't fix this without new testing infrastructure (webkit.org/b/233234).
     19
     20        Test: fast/scrolling/mac/momentum-animator-end-event-stops.html
     21
     22        * platform/ScrollingEffectsController.h:
     23        * platform/mac/ScrollingEffectsController.mm:
     24        (WebCore::ScrollingEffectsController::handleWheelEvent):
     25
    1262021-11-16  Said Abou-Hallawa  <said@apple.com>
    227
  • trunk/Source/WebCore/platform/ScrollingEffectsController.h

    r285787 r285917  
    264264    FloatSize m_scrollingVelocityForScrollSnap;
    265265#if !LOG_DISABLED
     266    FloatPoint m_eventDrivenScrollMomentumStartOffset;
    266267    FloatPoint m_eventDrivenScrollOffset;
     268    WallTime m_momentumBeganEventTime;
    267269#endif
    268270
  • trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm

    r285797 r285917  
    181181    }
    182182
     183#if !LOG_DISABLED
     184    if (wheelEvent.momentumPhase() == PlatformWheelEventPhase::Began)
     185        m_momentumBeganEventTime = wheelEvent.timestamp();
     186#endif
     187
     188    if (wheelEvent.momentumPhase() == PlatformWheelEventPhase::Ended && momentumScrollingAnimatorEnabled()) {
     189#if !LOG_DISABLED
     190        auto timeSinceStart = wheelEvent.timestamp() - m_momentumBeganEventTime;
     191        auto distance = m_eventDrivenScrollOffset - m_eventDrivenScrollMomentumStartOffset;
     192#endif
     193        // FIXME: We can't distinguish between the natural end of a momentum sequence, and a two-finger tap on the trackpad (rdar://85414238),
     194        // so we always have to end the animation here.
     195        LOG(ScrollAnimations, "Event (%s, %s): stopping event scroll duration %.2fms distance %.2f %.2f",
     196            phaseToString(wheelEvent.phase()), phaseToString(wheelEvent.momentumPhase()), timeSinceStart.milliseconds(),
     197            fabs(distance.width()), fabs(distance.height()));
     198        stopAnimatedNonRubberbandingScroll();
     199    }
     200
    183201    bool isMomentumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhase::None);
    184202    if (m_ignoreMomentumScrolls && (isMomentumScrollEvent || m_isAnimatingRubberBand)) {
     
    214232#if !LOG_DISABLED
    215233            m_eventDrivenScrollOffset = m_client.scrollOffset();
     234            m_eventDrivenScrollMomentumStartOffset = m_eventDrivenScrollOffset;
    216235#endif
    217236        }
Note: See TracChangeset for help on using the changeset viewer.