Diff
Modified: trunk/LayoutTests/ChangeLog (285786 => 285787)
--- trunk/LayoutTests/ChangeLog 2021-11-14 05:05:59 UTC (rev 285786)
+++ trunk/LayoutTests/ChangeLog 2021-11-14 07:37:36 UTC (rev 285787)
@@ -1,3 +1,17 @@
+2021-11-13 Simon Fraser <simon.fra...@apple.com>
+
+ Run a ScrollAnimationMomentum for the momentum phase of a scroll
+ https://bugs.webkit.org/show_bug.cgi?id=232897
+
+ Reviewed by Tim Horton.
+
+ Some tests that enable the momentum animator.
+
+ * fast/scrolling/mac/momentum-animator-expected.txt: Added.
+ * fast/scrolling/mac/momentum-animator-in-overflow-expected.txt: Added.
+ * fast/scrolling/mac/momentum-animator-in-overflow.html: Added.
+ * fast/scrolling/mac/momentum-animator.html: Added.
+
2021-11-13 Said Abou-Hallawa <s...@apple.com>
REGRESSION (r285618): [mac-wk1] ASSERTION FAILED: cgContext == [currentContext CGContext]
Added: trunk/LayoutTests/fast/scrolling/mac/momentum-animator-expected.txt (0 => 285787)
--- trunk/LayoutTests/fast/scrolling/mac/momentum-animator-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/momentum-animator-expected.txt 2021-11-14 07:37:36 UTC (rev 285787)
@@ -0,0 +1,5 @@
+PASS window.scrollY > 150 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/scrolling/mac/momentum-animator-in-overflow-expected.txt (0 => 285787)
--- trunk/LayoutTests/fast/scrolling/mac/momentum-animator-in-overflow-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/momentum-animator-in-overflow-expected.txt 2021-11-14 07:37:36 UTC (rev 285787)
@@ -0,0 +1,6 @@
+PASS window.scrollY is 0
+PASS scroller.scrollTop > 200 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/scrolling/mac/momentum-animator-in-overflow.html (0 => 285787)
--- trunk/LayoutTests/fast/scrolling/mac/momentum-animator-in-overflow.html (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/momentum-animator-in-overflow.html 2021-11-14 07:37:36 UTC (rev 285787)
@@ -0,0 +1,89 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ MomentumScrollingAnimatorEnabled=true AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+ <style>
+ body {
+ height: 2000px;
+ width: 200%;
+ }
+
+ .scroller {
+ height: 500px;
+ width: 400px;
+ border: 1px solid black;
+ overflow: auto;
+ }
+
+ .content {
+ width: 200%;
+ height: 500%;
+ }
+ </style>
+ <script src=""
+ <script src=""
+ <script>
+ var jsTestIsAsync = true;
+
+ let scroller;
+ async function testEventSequence()
+ {
+ const wheelEventSquence = {
+ "events" : [
+ {
+ type : "wheel",
+ viewX : 100,
+ viewY : 100,
+ deltaY : -10, // Note that this delta is currently ignored.
+ phase : "began"
+ },
+ {
+ type : "wheel",
+ deltaY : -100,
+ phase : "changed"
+ },
+ {
+ type : "wheel",
+ phase : "ended"
+ },
+ {
+ type : "wheel",
+ deltaY : -100,
+ momentumPhase : "began"
+ },
+ {
+ type : "wheel",
+ deltaY : -80,
+ momentumPhase : "changed"
+ },
+ {
+ type : "wheel",
+ momentumPhase : "ended"
+ }
+ ]
+ };
+
+ await UIHelper.mouseWheelSequence(wheelEventSquence);
+ shouldBe('window.scrollY', '0');
+ scroller = document.querySelector('.scroller');
+ // Make sure we scrolled some non-trivial amount.
+ shouldBeTrue('scroller.scrollTop > 200');
+ }
+
+ async function scrollTest()
+ {
+ await testEventSequence();
+ finishJSTest();
+ }
+
+ window.addEventListener('load', () => {
+ setTimeout(scrollTest, 0);
+ }, false);
+ </script>
+</head>
+<body>
+ <div class="scroller">
+ <div class="content"></div>
+ </div>
+ <script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/scrolling/mac/momentum-animator.html (0 => 285787)
--- trunk/LayoutTests/fast/scrolling/mac/momentum-animator.html (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/momentum-animator.html 2021-11-14 07:37:36 UTC (rev 285787)
@@ -0,0 +1,71 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ MomentumScrollingAnimatorEnabled=true ] -->
+<html>
+<head>
+ <style>
+ body {
+ height: 2000px;
+ width: 200%;
+ }
+ </style>
+ <script src=""
+ <script src=""
+ <script>
+ var jsTestIsAsync = true;
+
+ async function testEventSequence()
+ {
+ const wheelEventSquence = {
+ "events" : [
+ {
+ type : "wheel",
+ viewX : 100,
+ viewY : 100,
+ deltaY : -10, // Note that this delta is currently ignored.
+ phase : "began"
+ },
+ {
+ type : "wheel",
+ deltaY : -100,
+ phase : "changed"
+ },
+ {
+ type : "wheel",
+ phase : "ended"
+ },
+ {
+ type : "wheel",
+ deltaY : -100,
+ momentumPhase : "began"
+ },
+ {
+ type: "wheel",
+ deltaY: -80,
+ momentumPhase: "changed"
+ },
+ {
+ type : "wheel",
+ momentumPhase : "ended"
+ }
+ ]
+ };
+
+ await UIHelper.mouseWheelSequence(wheelEventSquence);
+ // Make sure we scrolled some non-trivial amount.
+ shouldBeTrue('window.scrollY > 150');
+ }
+
+ async function scrollTest()
+ {
+ await testEventSequence();
+ finishJSTest();
+ }
+
+ window.addEventListener('load', () => {
+ setTimeout(scrollTest, 0);
+ }, false);
+ </script>
+</head>
+<body>
+ <script src=""
+</body>
+</html>
Modified: trunk/Source/WTF/ChangeLog (285786 => 285787)
--- trunk/Source/WTF/ChangeLog 2021-11-14 05:05:59 UTC (rev 285786)
+++ trunk/Source/WTF/ChangeLog 2021-11-14 07:37:36 UTC (rev 285787)
@@ -1,3 +1,15 @@
+2021-11-13 Simon Fraser <simon.fra...@apple.com>
+
+ Run a ScrollAnimationMomentum for the momentum phase of a scroll
+ https://bugs.webkit.org/show_bug.cgi?id=232897
+
+ Reviewed by Tim Horton.
+
+ Set the MomentumScrollingAnimatorEnabled internal setting to off by default
+ while we bring up tests.
+
+ * Scripts/Preferences/WebPreferencesInternal.yaml:
+
2021-11-12 Chris Dumez <cdu...@apple.com>
Disable MathML when in Captive Portal Mode
Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml (285786 => 285787)
--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml 2021-11-14 05:05:59 UTC (rev 285786)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml 2021-11-14 07:37:36 UTC (rev 285787)
@@ -542,13 +542,10 @@
humanReadableDescription: "Drive momentum scrolling via an internal animator instead of using momentum events"
defaultValue:
WebKitLegacy:
- "PLATFORM(MAC)": true
default: false
WebKit:
- "PLATFORM(MAC)": true
default: false
WebCore:
- "PLATFORM(MAC)": true
default: false
MouseEventsSimulationEnabled:
Modified: trunk/Source/WebCore/ChangeLog (285786 => 285787)
--- trunk/Source/WebCore/ChangeLog 2021-11-14 05:05:59 UTC (rev 285786)
+++ trunk/Source/WebCore/ChangeLog 2021-11-14 07:37:36 UTC (rev 285787)
@@ -1,3 +1,53 @@
+2021-11-13 Simon Fraser <simon.fra...@apple.com>
+
+ Run a ScrollAnimationMomentum for the momentum phase of a scroll
+ https://bugs.webkit.org/show_bug.cgi?id=232897
+
+ Reviewed by Tim Horton.
+
+ Run an animation for the momentum phase of a scroll, rather than scrolling in response
+ to wheel events, because it produces a smoother result with fewer dropped frames.
+
+ We re-use ScrollAnimationMomentum which is already used for scroll snap, but have to
+ allow it to yield unclamped coordinates, since using it for momentum can result in
+ rubber-banding.
+
+ When we get the momentum "began" event, we start the ScrollAnimationMomentum
+ using initial velocity computed from WheelEventDeltaFilter. ScrollingEffectsController then
+ ignores the reset of the momentum "changed" events.
+
+ We have to stop this animation when we receive a "begin" or "mayBegin" event, since
+ this indicates that the user has put fingers down on the trackpad.
+
+ Rename m_dragEndedScrollingVelocity to m_scrollingVelocityForScrollSnap for clarity
+ (at some point we should merge this with m_scrollingVelocityForMomentumAnimation).
+
+ Tests: fast/scrolling/mac/momentum-animator-in-overflow.html
+ fast/scrolling/mac/momentum-animator.html
+
+ * page/WheelEventDeltaFilter.cpp:
+ (WebCore::WheelEventDeltaFilter::shouldApplyFilteringForEvent):
+ * page/WheelEventDeltaFilter.h:
+ * platform/PlatformWheelEvent.cpp:
+ (WebCore::operator<<):
+ * platform/ScrollAnimationMomentum.cpp:
+ (WebCore::ScrollAnimationMomentum::startAnimatedScrollWithInitialVelocity):
+ (WebCore::ScrollAnimationMomentum::stop):
+ (WebCore::ScrollAnimationMomentum::serviceAnimation):
+ * platform/ScrollAnimationMomentum.h:
+ * platform/ScrollingEffectsController.cpp:
+ (WebCore::ScrollingEffectsController::ScrollingEffectsController):
+ (WebCore::ScrollingEffectsController::stopAnimatedNonRubberbandingScroll):
+ (WebCore::ScrollingEffectsController::startMomentumScrollWithInitialVelocity):
+ * platform/ScrollingEffectsController.h:
+ (WebCore::ScrollingEffectsController::momentumScrollingAnimatorEnabled const):
+ * platform/mac/ScrollingEffectsController.mm:
+ (WebCore::phaseToString):
+ (WebCore::ScrollingEffectsController::handleWheelEvent):
+ (WebCore::ScrollingEffectsController::startRubberBandAnimation):
+ (WebCore::ScrollingEffectsController::startRubberBandAnimationIfNecessary):
+ (WebCore::ScrollingEffectsController::processWheelEventForScrollSnap):
+
2021-11-13 Tim Horton <timothy_hor...@apple.com>
Clean up IOKit SPI headers
Modified: trunk/Source/WebCore/page/WheelEventDeltaFilter.cpp (285786 => 285787)
--- trunk/Source/WebCore/page/WheelEventDeltaFilter.cpp 2021-11-14 05:05:59 UTC (rev 285786)
+++ trunk/Source/WebCore/page/WheelEventDeltaFilter.cpp 2021-11-14 07:37:36 UTC (rev 285787)
@@ -54,6 +54,7 @@
{
#if ENABLE(KINETIC_SCROLLING)
// Maybe it's a per-platform decision about which event phases get filtered. Ideally we'd filter momentum events too (but that breaks some diagonal scrolling cases).
+ // Also, ScrollingEffectsController should ask WheelEventDeltaFilter directly for the filtered velocity, rather than sending the velocity via PlatformWheelEvent.
auto phase = event.phase();
return phase == PlatformWheelEventPhase::Began || phase == PlatformWheelEventPhase::Changed;
#else
Modified: trunk/Source/WebCore/page/WheelEventDeltaFilter.h (285786 => 285787)
--- trunk/Source/WebCore/page/WheelEventDeltaFilter.h 2021-11-14 05:05:59 UTC (rev 285786)
+++ trunk/Source/WebCore/page/WheelEventDeltaFilter.h 2021-11-14 07:37:36 UTC (rev 285787)
@@ -62,7 +62,7 @@
private:
std::optional<ScrollEventAxis> dominantAxis() const;
-
+
void reset();
void updateWithDelta(FloatSize);
Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.cpp (285786 => 285787)
--- trunk/Source/WebCore/platform/PlatformWheelEvent.cpp 2021-11-14 05:05:59 UTC (rev 285786)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.cpp 2021-11-14 07:37:36 UTC (rev 285787)
@@ -108,6 +108,7 @@
#if ENABLE(KINETIC_SCROLLING)
ts << " phase \"" << event.phase() << "\" momentum phase \"" << event.momentumPhase() << "\"";
#endif
+ ts << " velocity " << event.scrollingVelocity();
return ts;
}
Modified: trunk/Source/WebCore/platform/ScrollAnimationMomentum.cpp (285786 => 285787)
--- trunk/Source/WebCore/platform/ScrollAnimationMomentum.cpp 2021-11-14 05:05:59 UTC (rev 285786)
+++ trunk/Source/WebCore/platform/ScrollAnimationMomentum.cpp 2021-11-14 07:37:36 UTC (rev 285787)
@@ -55,6 +55,9 @@
}
}
+ LOG(ScrollAnimations, "ScrollAnimationMomentum::startAnimatedScrollWithInitialVelocity: velocity %.2f,%.2f from %.2f,%.2f to %.2f,%.2f",
+ initialVelocity.width(), initialVelocity.height(), initialOffset.x(), initialOffset.y(), destinationScrollOffset.x(), destinationScrollOffset.y());
+
if (destinationScrollOffset == initialOffset) {
m_momentumCalculator = nullptr;
return false;
@@ -81,6 +84,8 @@
void ScrollAnimationMomentum::stop()
{
+ LOG(ScrollAnimations, "ScrollAnimationMomentum::stop: offset %.2f,%.2f", m_currentOffset.x(), m_currentOffset.y());
+
m_momentumCalculator = nullptr;
ScrollAnimation::stop();
}
@@ -98,6 +103,8 @@
m_client.scrollAnimationDidUpdate(*this, m_currentOffset);
+ LOG(ScrollAnimations, "ScrollAnimationMomentum::serviceAnimation: offset %.2f,%.2f complete %d", m_currentOffset.x(), m_currentOffset.y(), animationComplete);
+
if (animationComplete)
didEnd();
}
Modified: trunk/Source/WebCore/platform/ScrollAnimationMomentum.h (285786 => 285787)
--- trunk/Source/WebCore/platform/ScrollAnimationMomentum.h 2021-11-14 05:05:59 UTC (rev 285786)
+++ trunk/Source/WebCore/platform/ScrollAnimationMomentum.h 2021-11-14 07:37:36 UTC (rev 285787)
@@ -42,6 +42,7 @@
void updateScrollExtents() final;
private:
+ ScrollClamping clamping() const final { return ScrollClamping::Unclamped; }
String debugDescription() const final;
std::unique_ptr<ScrollingMomentumCalculator> m_momentumCalculator;
Modified: trunk/Source/WebCore/platform/ScrollingEffectsController.cpp (285786 => 285787)
--- trunk/Source/WebCore/platform/ScrollingEffectsController.cpp 2021-11-14 05:05:59 UTC (rev 285786)
+++ trunk/Source/WebCore/platform/ScrollingEffectsController.cpp 2021-11-14 07:37:36 UTC (rev 285787)
@@ -49,6 +49,7 @@
ScrollingEffectsController::ScrollingEffectsController(ScrollingEffectsControllerClient& client)
: m_client(client)
+ , m_momentumScrollingAnimatorEnabled(client.momentumScrollingAnimatorEnabled())
{
}
@@ -131,6 +132,30 @@
return false;
}
+void ScrollingEffectsController::stopAnimatedNonRubberbandingScroll()
+{
+ LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController " << this << " stopAnimatedNonRubberbandingScroll");
+
+ if (!m_currentAnimation)
+ return;
+
+#if HAVE(RUBBER_BANDING)
+ if (is<ScrollAnimationRubberBand>(m_currentAnimation))
+ return;
+#endif
+
+ if (is<ScrollAnimationMomentum>(m_currentAnimation)) {
+ // If the animation is currently triggering rubberbanding, let it run. Ideally we'd check if the animation will cause rubberbanding at any time in the future.
+ auto currentOffset = m_currentAnimation->currentOffset();
+ auto extents = m_client.scrollExtents();
+ auto constrainedOffset = currentOffset.constrainedBetween(extents.minimumScrollOffset(), extents.maximumScrollOffset());
+ if (currentOffset != constrainedOffset)
+ return;
+ }
+
+ m_currentAnimation->stop();
+}
+
void ScrollingEffectsController::stopAnimatedScroll()
{
LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController " << this << " stopAnimatedScroll");
@@ -151,7 +176,7 @@
m_currentAnimation = makeUnique<ScrollAnimationMomentum>(*this);
bool started = downcast<ScrollAnimationMomentum>(*m_currentAnimation).startAnimatedScrollWithInitialVelocity(initialOffset, initialVelocity, initialDelta, destinationModifier);
- LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::startMomentumScrollWithInitialVelocity() - animation " << *m_currentAnimation << " started " << started);
+ LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::startMomentumScrollWithInitialVelocity() - animation " << *m_currentAnimation << " initialVelocity " << initialVelocity << " initialDelta " << initialDelta << " started " << started);
return started;
}
Modified: trunk/Source/WebCore/platform/ScrollingEffectsController.h (285786 => 285787)
--- trunk/Source/WebCore/platform/ScrollingEffectsController.h 2021-11-14 05:05:59 UTC (rev 285786)
+++ trunk/Source/WebCore/platform/ScrollingEffectsController.h 2021-11-14 07:37:36 UTC (rev 285787)
@@ -138,7 +138,9 @@
bool startAnimatedScrollToDestination(FloatPoint startOffset, FloatPoint destinationOffset);
bool retargetAnimatedScroll(FloatPoint newDestinationOffset);
bool retargetAnimatedScrollBy(FloatSize);
+
void stopAnimatedScroll();
+ void stopAnimatedNonRubberbandingScroll();
void stopKeyboardScrolling();
@@ -221,6 +223,8 @@
void startOrStopAnimationCallbacks();
+ bool momentumScrollingAnimatorEnabled() const { return m_momentumScrollingAnimatorEnabled; }
+
// ScrollAnimationClient
void scrollAnimationDidUpdate(ScrollAnimation&, const FloatPoint& /* currentOffset */) final;
void scrollAnimationWillStart(ScrollAnimation&) final;
@@ -248,6 +252,7 @@
bool m_isAnimatingScrollSnap { false };
bool m_isAnimatingKeyboardScrolling { false };
bool m_inScrollGesture { false };
+ bool m_momentumScrollingAnimatorEnabled { false };
#if PLATFORM(MAC)
WallTime m_lastMomentumScrollTimestamp;
@@ -255,11 +260,16 @@
FloatSize m_stretchScrollForce;
FloatSize m_momentumVelocity;
+ FloatSize m_scrollingVelocityForMomentumAnimation; // Do we need both this, m_scrollingVelocityForScrollSnap and m_momentumVelocity?
+ FloatSize m_scrollingVelocityForScrollSnap;
+#if !LOG_DISABLED
+ FloatPoint m_eventDrivenScrollOffset;
+#endif
+
bool m_momentumScrollInProgress { false };
bool m_ignoreMomentumScrolls { false };
bool m_isRubberBanding { false };
- FloatSize m_dragEndedScrollingVelocity;
std::unique_ptr<ScrollingEffectsControllerTimer> m_statelessSnapTransitionTimer;
#if HAVE(RUBBER_BANDING)
Modified: trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm (285786 => 285787)
--- trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm 2021-11-14 05:05:59 UTC (rev 285786)
+++ trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm 2021-11-14 07:37:36 UTC (rev 285787)
@@ -30,6 +30,7 @@
#import "PlatformWheelEvent.h"
#import "ScrollAnimationRubberBand.h"
#import "ScrollExtents.h"
+#import "WheelEventDeltaFilter.h"
#import "WheelEventTestMonitor.h"
#import <pal/spi/mac/NSScrollViewSPI.h>
#import <sys/sysctl.h>
@@ -110,15 +111,44 @@
return ScrollableArea::targetSideForScrollDelta(delta, dominantAxis);
}
+#if !LOG_DISABLED
+static const char* phaseToString(PlatformWheelEventPhase phase)
+{
+ switch (phase) {
+ case PlatformWheelEventPhase::None: return "none";
+ case PlatformWheelEventPhase::Began: return "began";
+ case PlatformWheelEventPhase::Stationary: return "stationary";
+ case PlatformWheelEventPhase::Changed: return "changed";
+ case PlatformWheelEventPhase::Ended: return "ended";
+ case PlatformWheelEventPhase::Cancelled: return "cancelled";
+ case PlatformWheelEventPhase::MayBegin: return "mayBegin";
+ }
+ return "";
+}
+#endif
+
bool ScrollingEffectsController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
{
+ if (WheelEventDeltaFilter::shouldApplyFilteringForEvent(wheelEvent))
+ m_scrollingVelocityForMomentumAnimation = -wheelEvent.scrollingVelocity(); // Note that event delta is reversed from scroll direction.
+
if (processWheelEventForScrollSnap(wheelEvent))
return true;
- if (wheelEvent.phase() == PlatformWheelEventPhase::MayBegin || wheelEvent.phase() == PlatformWheelEventPhase::Cancelled)
+ if (wheelEvent.phase() == PlatformWheelEventPhase::MayBegin || wheelEvent.phase() == PlatformWheelEventPhase::Cancelled) {
+ if (momentumScrollingAnimatorEnabled()) {
+ LOG(ScrollAnimations, "Event (%s, %s): stopping animated scroll", phaseToString(wheelEvent.phase()), phaseToString(wheelEvent.momentumPhase()));
+ stopAnimatedScroll();
+ }
return false;
+ }
if (wheelEvent.phase() == PlatformWheelEventPhase::Began) {
+ if (momentumScrollingAnimatorEnabled()) {
+ LOG(ScrollAnimations, "Event (%s, %s): stopping animated scroll", phaseToString(wheelEvent.phase()), phaseToString(wheelEvent.momentumPhase()));
+ stopAnimatedScroll();
+ }
+
// FIXME: Trying to decide if a gesture is horizontal or vertical at the "began" phase is very error-prone.
auto horizontalSide = ScrollableArea::targetSideForScrollDelta(-wheelEvent.delta(), ScrollEventAxis::Horizontal);
if (horizontalSide && m_client.isPinnedOnSide(*horizontalSide) && !shouldRubberBandOnSide(*horizontalSide))
@@ -177,9 +207,25 @@
delta = deltaAlignedToDominantAxis(delta);
auto momentumPhase = wheelEvent.momentumPhase();
- if (!m_momentumScrollInProgress && (momentumPhase == PlatformWheelEventPhase::Began || momentumPhase == PlatformWheelEventPhase::Changed))
+ if (!m_momentumScrollInProgress && (momentumPhase == PlatformWheelEventPhase::Began || momentumPhase == PlatformWheelEventPhase::Changed)) {
m_momentumScrollInProgress = true;
+ if (momentumScrollingAnimatorEnabled()) {
+ startMomentumScrollWithInitialVelocity(m_client.scrollOffset(), m_scrollingVelocityForMomentumAnimation, -wheelEvent.delta(), [](const FloatPoint& targetOffset) { return targetOffset; });
+#if !LOG_DISABLED
+ m_eventDrivenScrollOffset = m_client.scrollOffset();
+#endif
+ }
+ }
+ if (momentumPhase == PlatformWheelEventPhase::Changed && momentumScrollingAnimatorEnabled()) {
+#if !LOG_DISABLED
+ m_eventDrivenScrollOffset -= wheelEvent.delta();
+#endif
+ LOG(ScrollAnimations, "Event (%s, %s): ignoring - would have scrolled to %.2f,%.2f", phaseToString(wheelEvent.phase()), phaseToString(wheelEvent.momentumPhase()),
+ m_eventDrivenScrollOffset.x(), m_eventDrivenScrollOffset.y());
+ return true;
+ }
+
bool shouldStretch = false;
auto timeDelta = wheelEvent.timestamp() - m_lastMomentumScrollTimestamp;
if (m_inScrollGesture || m_momentumScrollInProgress) {
@@ -393,6 +439,11 @@
bool ScrollingEffectsController::startRubberBandAnimation(const FloatPoint& targetOffset, const FloatSize& initialVelocity, const FloatSize& initialOverscroll)
{
+ if (is<ScrollAnimationMomentum>(m_currentAnimation) && m_currentAnimation->isActive()) {
+ LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::startRubberBandAnimation() - momentum animation is present");
+ return false;
+ }
+
if (m_currentAnimation)
m_currentAnimation->stop();
@@ -439,9 +490,6 @@
bool willOverscroll = targetOffset != contrainedOffset;
auto stretchAmount = m_client.stretchAmount();
-
- LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::startRubberBandAnimationIfNecessary() - rubberBandAnimationRunning " << m_isAnimatingRubberBand << " stretchAmount " << stretchAmount << " targetOffset " << targetOffset);
-
if (stretchAmount.isZero() && !willOverscroll)
return;
@@ -459,6 +507,7 @@
if (!m_client.allowsVerticalScrolling())
initialVelocity.setHeight(0);
+ LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::startRubberBandAnimationIfNecessary() - rubberBandAnimationRunning " << m_isAnimatingRubberBand << " stretchAmount " << stretchAmount << " contrainedOffset " << contrainedOffset << " initialVelocity " << initialVelocity);
startRubberBandAnimation(contrainedOffset, initialVelocity, stretchAmount);
}
@@ -635,7 +684,7 @@
case WheelEventStatus::UserScrolling:
stopScrollSnapAnimation();
m_scrollSnapState->transitionToUserInteractionState();
- m_dragEndedScrollingVelocity = -wheelEvent.scrollingVelocity();
+ m_scrollingVelocityForScrollSnap = -wheelEvent.scrollingVelocity();
break;
case WheelEventStatus::UserScrollEnd:
if (m_scrollSnapState->transitionToSnapAnimationState(m_client.scrollExtents(), m_client.pageScaleFactor(), m_client.scrollOffset()))
@@ -642,11 +691,11 @@
startScrollSnapAnimation();
break;
case WheelEventStatus::MomentumScrollBegin:
- if (m_scrollSnapState->transitionToGlideAnimationState(m_client.scrollExtents(), m_client.pageScaleFactor(), m_client.scrollOffset(), m_dragEndedScrollingVelocity, FloatSize(-wheelEvent.deltaX(), -wheelEvent.deltaY()))) {
+ if (m_scrollSnapState->transitionToGlideAnimationState(m_client.scrollExtents(), m_client.pageScaleFactor(), m_client.scrollOffset(), m_scrollingVelocityForScrollSnap, -wheelEvent.delta())) {
startScrollSnapAnimation();
isMomentumScrolling = true;
}
- m_dragEndedScrollingVelocity = { };
+ m_scrollingVelocityForScrollSnap = { };
break;
case WheelEventStatus::MomentumScrolling:
case WheelEventStatus::MomentumScrollEnd: