Diff
Modified: trunk/LayoutTests/ChangeLog (264189 => 264190)
--- trunk/LayoutTests/ChangeLog 2020-07-09 20:00:45 UTC (rev 264189)
+++ trunk/LayoutTests/ChangeLog 2020-07-09 20:01:53 UTC (rev 264190)
@@ -1,3 +1,13 @@
+2020-07-09 Simon Fraser <[email protected]>
+
+ After a scroll gesture, content changes don't trigger re-snapping with scroll snap
+ https://bugs.webkit.org/show_bug.cgi?id=214123
+
+ Reviewed by Wenson Hsieh.
+
+ * fast/scrolling/mac/adjust-scroll-snap-after-gesture-expected.txt: Added.
+ * fast/scrolling/mac/adjust-scroll-snap-after-gesture.html: Added.
+
2020-07-09 Wenson Hsieh <[email protected]>
REGRESSION (r259840): Pressing Esc or ⌘+"." does not dismiss time picker on iOS
Added: trunk/LayoutTests/fast/scrolling/mac/adjust-scroll-snap-after-gesture-expected.txt (0 => 264190)
--- trunk/LayoutTests/fast/scrolling/mac/adjust-scroll-snap-after-gesture-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/adjust-scroll-snap-after-gesture-expected.txt 2020-07-09 20:01:53 UTC (rev 264190)
@@ -0,0 +1,10 @@
+
+
+Scrolling
+PASS scroller.scrollLeft is 258
+Scroller should re-snap
+PASS scroller.scrollLeft is 278
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/scrolling/mac/adjust-scroll-snap-after-gesture.html (0 => 264190)
--- trunk/LayoutTests/fast/scrolling/mac/adjust-scroll-snap-after-gesture.html (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/adjust-scroll-snap-after-gesture.html 2020-07-09 20:01:53 UTC (rev 264190)
@@ -0,0 +1,83 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+ <style>
+ body {
+ height: 2000px;
+ }
+
+ .scroller {
+ width: 620px;
+ height: 120px;
+ border: 1px solid black;
+ overflow-x: scroll;
+ scroll-snap-type: x mandatory;
+ }
+
+ .contents {
+ width: 200%;
+ }
+
+ .box {
+ scroll-snap-align: start;
+ width: 100px;
+ height: 100px;
+ margin: 10px;
+ background-color: blue;
+ display: inline-block;
+ }
+
+ .scroller.changed .box {
+ width: 110px;
+ }
+
+ </style>
+ <script src=""
+ <script src=""
+ <script>
+ var jsTestIsAsync = true;
+
+ var scroller;
+
+ async function scrollTest()
+ {
+ debug('');
+ debug('Scrolling');
+ await UIHelper.mouseWheelScrollAt(20, 20, -1, 0, -20, 0);
+ shouldBe('scroller.scrollLeft', '258');
+
+ scroller.classList.add('changed');
+
+ debug('Scroller should re-snap');
+ await UIHelper.animationFrame();
+ shouldBe('scroller.scrollLeft', '278');
+
+ finishJSTest();
+ }
+
+ window.addEventListener('load', () => {
+ document.body.addEventListener('wheel', () => {}, false); // Force sync scrolling.
+ scroller = document.querySelector('.scroller');
+ setTimeout(scrollTest, 0);
+ }, false);
+ </script>
+</head>
+<body>
+ <div class="scroller">
+ <div class="contents">
+ <div class="box"></div>
+ <div class="box"></div>
+ <div class="box"></div>
+ <div class="box"></div>
+ <div class="box"></div>
+ <div class="box"></div>
+ <div class="box"></div>
+ <div class="box"></div>
+ <div class="box"></div>
+ <div class="box"></div>
+ </div>
+ </div>
+ <div id="console"></div>
+ <script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (264189 => 264190)
--- trunk/Source/WebCore/ChangeLog 2020-07-09 20:00:45 UTC (rev 264189)
+++ trunk/Source/WebCore/ChangeLog 2020-07-09 20:01:53 UTC (rev 264190)
@@ -1,3 +1,54 @@
+2020-07-09 Simon Fraser <[email protected]>
+
+ After a scroll gesture, content changes don't trigger re-snapping with scroll snap
+ https://bugs.webkit.org/show_bug.cgi?id=214123
+
+ Reviewed by Wenson Hsieh.
+
+ ScrollController::m_inScrollGesture could get stuck as true after a scroll gesture, because
+ ScrollAnimatorMac::handleWheelEvent() didn't reliably call m_scrollController.handleWheelEvent() for
+ the event event based on the hokey shouldForwardWheelEventsToParent() code.
+
+ Fix by explicitly calling m_scrollController.updateGestureInProgressState() which maintains
+ m_inScrollGesture.
+
+ When m_inScrollGesture was stuck as true, ScrollableArea::updateScrollSnapState() would return early
+ because isScrollSnapInProgress() would return true. In addition,
+ ScrollController::isScrollSnapInProgress() was a lie for non-scroll-snapping scrollable areas, so
+ explicitly check for snap points there, using an explicit usesScrollSnap() function.
+
+ Rename some WheelEventStatus values to use "momentum" rather than "inertia".
+
+ Test: fast/scrolling/mac/adjust-scroll-snap-after-gesture.html
+
+ * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
+ (WebCore::ScrollingTreeScrollingNodeDelegateMac::handleWheelEvent):
+ * platform/ScrollableArea.cpp:
+ (WebCore::ScrollableArea::usesScrollSnap const):
+ (WebCore::ScrollableArea::updateScrollSnapState):
+ * platform/ScrollableArea.h:
+ * platform/cocoa/ScrollController.h:
+ * platform/cocoa/ScrollController.mm:
+ (WebCore::ScrollController::handleWheelEvent):
+ (WebCore::ScrollController::usesScrollSnap const):
+ (WebCore::ScrollController::isScrollSnapInProgress const):
+ (WebCore::ScrollController::snapRubberBand):
+ (WebCore::toWheelEventStatus):
+ (WebCore::operator<<):
+ (WebCore::ScrollController::shouldOverrideMomentumScrolling const):
+ (WebCore::ScrollController::scheduleStatelessScrollSnap):
+ (WebCore::ScrollController::statelessSnapTransitionTimerFired):
+ (WebCore::ScrollController::processWheelEventForScrollSnap):
+ (WebCore::ScrollController::updateGestureInProgressState):
+ (WebCore::ScrollController::scrollSnapTimerFired):
+ (WebCore::ScrollController::activeScrollSnapIndexForAxis const):
+ (WebCore::ScrollController::setActiveScrollSnapIndexForAxis):
+ (WebCore::ScrollController::setNearestScrollSnapIndexForAxisAndOffset):
+ (WebCore::ScrollController::setActiveScrollSnapIndicesForOffset):
+ (WebCore::ScrollController::shouldOverrideInertialScrolling const): Deleted.
+ * platform/mac/ScrollAnimatorMac.mm:
+ (WebCore::ScrollAnimatorMac::handleWheelEvent):
+
2020-07-09 Fujii Hironori <[email protected]>
[WinCairo][MediaFoundation] Use /DELAYLOAD for mf.dll
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm (264189 => 264190)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm 2020-07-09 20:00:45 UTC (rev 264189)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm 2020-07-09 20:01:53 UTC (rev 264190)
@@ -139,6 +139,8 @@
deferWheelEventTestCompletionForReason(reinterpret_cast<WheelEventTestMonitor::ScrollableAreaIdentifier>(scrollingNode().scrollingNodeID()), WheelEventTestMonitor::HandlingWheelEvent);
#endif
+ m_scrollController.updateGestureInProgressState(wheelEvent);
+
// PlatformWheelEventPhaseMayBegin fires when two fingers touch the trackpad, and is used to flash overlay scrollbars.
// We know we're scrollable at this point, so handle the event.
if (wheelEvent.phase() == PlatformWheelEventPhaseMayBegin)
Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (264189 => 264190)
--- trunk/Source/WebCore/platform/ScrollableArea.cpp 2020-07-09 20:00:45 UTC (rev 264189)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp 2020-07-09 20:01:53 UTC (rev 264190)
@@ -536,6 +536,11 @@
m_currentVerticalSnapPointIndex = 0;
}
+bool ScrollableArea::usesScrollSnap() const
+{
+ return !!m_snapOffsetsInfo;
+}
+
IntPoint ScrollableArea::nearestActiveSnapPoint(const IntPoint& currentPosition)
{
if (!horizontalSnapOffsets() && !verticalSnapOffsets())
@@ -570,6 +575,9 @@
if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
scrollAnimator->updateScrollSnapState();
+ if (!usesScrollSnap())
+ return;
+
LOG_WITH_STREAM(ScrollSnap, stream << *this << " updateScrollSnapState: isScrollSnapInProgress " << isScrollSnapInProgress() << " isUserScrollInProgress " << isUserScrollInProgress());
if (isScrollSnapInProgress() || isUserScrollInProgress())
Modified: trunk/Source/WebCore/platform/ScrollableArea.h (264189 => 264190)
--- trunk/Source/WebCore/platform/ScrollableArea.h 2020-07-09 20:00:45 UTC (rev 264189)
+++ trunk/Source/WebCore/platform/ScrollableArea.h 2020-07-09 20:01:53 UTC (rev 264190)
@@ -88,6 +88,8 @@
WEBCORE_EXPORT bool handleWheelEvent(const PlatformWheelEvent&);
+ bool usesScrollSnap() const;
+
#if ENABLE(CSS_SCROLL_SNAP)
WEBCORE_EXPORT const Vector<LayoutUnit>* horizontalSnapOffsets() const;
WEBCORE_EXPORT const Vector<LayoutUnit>* verticalSnapOffsets() const;
Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.h (264189 => 264190)
--- trunk/Source/WebCore/platform/cocoa/ScrollController.h 2020-07-09 20:00:45 UTC (rev 264189)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.h 2020-07-09 20:01:53 UTC (rev 264190)
@@ -119,9 +119,9 @@
UserScrollBegin,
UserScrolling,
UserScrollEnd,
- InertialScrollBegin,
- InertialScrolling,
- InertialScrollEnd,
+ MomentumScrollBegin,
+ MomentumScrolling,
+ MomentumScrollEnd,
StatelessScrollEvent,
Unknown
};
@@ -137,6 +137,8 @@
bool handleWheelEvent(const PlatformWheelEvent&);
#endif
+ bool usesScrollSnap() const;
+
bool isUserScrollInProgress() const;
bool isRubberBandInProgress() const;
bool isScrollSnapInProgress() const;
@@ -149,6 +151,9 @@
void setScrollSnapIndexDidChange(bool state) { m_activeScrollSnapIndexDidChange = state; }
unsigned activeScrollSnapIndexForAxis(ScrollEventAxis) const;
void updateScrollSnapState(const ScrollableArea&);
+
+ void updateGestureInProgressState(const PlatformWheelEvent&);
+
#if PLATFORM(MAC)
bool processWheelEventForScrollSnap(const PlatformWheelEvent&);
#endif
@@ -179,7 +184,7 @@
void startScrollSnapTimer();
void stopScrollSnapTimer();
- bool shouldOverrideInertialScrolling() const;
+ bool shouldOverrideMomentumScrolling() const;
void statelessSnapTransitionTimerFired();
void scheduleStatelessScrollSnap();
Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.mm (264189 => 264190)
--- trunk/Source/WebCore/platform/cocoa/ScrollController.mm 2020-07-09 20:00:45 UTC (rev 264189)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.mm 2020-07-09 20:01:53 UTC (rev 264190)
@@ -137,7 +137,6 @@
if (direction && m_client.pinnedInDirection(FloatSize(0, -wheelEvent.deltaY())) && !shouldRubberBandInDirection(direction.value()))
return false;
- m_inScrollGesture = true;
m_momentumScrollInProgress = false;
m_ignoreMomentumScrolls = false;
m_lastMomentumScrollTimestamp = { };
@@ -455,6 +454,15 @@
}
#endif
+bool ScrollController::usesScrollSnap() const
+{
+#if ENABLE(CSS_SCROLL_SNAP)
+ return !!m_scrollSnapState;
+#else
+ return false;
+#endif
+}
+
bool ScrollController::isUserScrollInProgress() const
{
#if PLATFORM(MAC)
@@ -478,6 +486,9 @@
bool ScrollController::isScrollSnapInProgress() const
{
+ if (!usesScrollSnap())
+ return false;
+
#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
if (m_inScrollGesture || m_momentumScrollInProgress || m_scrollSnapTimer)
return true;
@@ -517,8 +528,6 @@
if (m_lastMomentumScrollTimestamp && timeDelta >= scrollVelocityZeroingTimeout)
m_momentumVelocity = { };
- m_inScrollGesture = false;
-
if (m_snapRubberbandTimer)
return;
@@ -553,13 +562,13 @@
if (phase == PlatformWheelEventPhaseNone) {
switch (momentumPhase) {
case PlatformWheelEventPhaseBegan:
- return WheelEventStatus::InertialScrollBegin;
+ return WheelEventStatus::MomentumScrollBegin;
case PlatformWheelEventPhaseChanged:
- return WheelEventStatus::InertialScrolling;
+ return WheelEventStatus::MomentumScrolling;
case PlatformWheelEventPhaseEnded:
- return WheelEventStatus::InertialScrollEnd;
+ return WheelEventStatus::MomentumScrollEnd;
case PlatformWheelEventPhaseNone:
return WheelEventStatus::StatelessScrollEvent;
@@ -595,9 +604,9 @@
case WheelEventStatus::UserScrollBegin: ts << "UserScrollBegin"; break;
case WheelEventStatus::UserScrolling: ts << "UserScrolling"; break;
case WheelEventStatus::UserScrollEnd: ts << "UserScrollEnd"; break;
- case WheelEventStatus::InertialScrollBegin: ts << "InertialScrollBegin"; break;
- case WheelEventStatus::InertialScrolling: ts << "InertialScrolling"; break;
- case WheelEventStatus::InertialScrollEnd: ts << "InertialScrollEnd"; break;
+ case WheelEventStatus::MomentumScrollBegin: ts << "MomentumScrollBegin"; break;
+ case WheelEventStatus::MomentumScrolling: ts << "MomentumScrolling"; break;
+ case WheelEventStatus::MomentumScrollEnd: ts << "MomentumScrollEnd"; break;
case WheelEventStatus::StatelessScrollEvent: ts << "StatelessScrollEvent"; break;
case WheelEventStatus::Unknown: ts << "Unknown"; break;
}
@@ -605,9 +614,9 @@
}
#endif
-bool ScrollController::shouldOverrideInertialScrolling() const
+bool ScrollController::shouldOverrideMomentumScrolling() const
{
- if (!m_scrollSnapState)
+ if (!usesScrollSnap())
return false;
ScrollSnapState scrollSnapState = m_scrollSnapState->currentState();
@@ -621,7 +630,7 @@
m_statelessSnapTransitionTimer->stop();
m_statelessSnapTransitionTimer = nullptr;
}
- if (!m_scrollSnapState)
+ if (!usesScrollSnap())
return;
static const Seconds statelessScrollSnapDelay = 750_ms;
@@ -636,7 +645,7 @@
{
m_statelessSnapTransitionTimer = nullptr;
- if (!m_scrollSnapState)
+ if (!usesScrollSnap())
return;
m_scrollSnapState->transitionToSnapAnimationState(m_client.scrollExtent(), m_client.viewportSize(), m_client.pageScaleFactor(), m_client.scrollOffset());
@@ -655,17 +664,17 @@
bool ScrollController::processWheelEventForScrollSnap(const PlatformWheelEvent& wheelEvent)
{
- if (!m_scrollSnapState)
+ if (!usesScrollSnap())
return true;
if (m_scrollSnapState->snapOffsetsForAxis(ScrollEventAxis::Horizontal).isEmpty() && m_scrollSnapState->snapOffsetsForAxis(ScrollEventAxis::Vertical).isEmpty())
return true;
- WheelEventStatus status = toWheelEventStatus(wheelEvent.phase(), wheelEvent.momentumPhase());
+ auto status = toWheelEventStatus(wheelEvent.phase(), wheelEvent.momentumPhase());
LOG_WITH_STREAM(ScrollSnap, stream << "ScrollController " << this << " processWheelEventForScrollSnap: status " << status);
- bool isInertialScrolling = false;
+ bool isMomentumScrolling = false;
switch (status) {
case WheelEventStatus::UserScrollBegin:
case WheelEventStatus::UserScrolling:
@@ -677,14 +686,14 @@
m_scrollSnapState->transitionToSnapAnimationState(m_client.scrollExtent(), m_client.viewportSize(), m_client.pageScaleFactor(), m_client.scrollOffset());
startScrollSnapTimer();
break;
- case WheelEventStatus::InertialScrollBegin:
+ case WheelEventStatus::MomentumScrollBegin:
m_scrollSnapState->transitionToGlideAnimationState(m_client.scrollExtent(), m_client.viewportSize(), m_client.pageScaleFactor(), m_client.scrollOffset(), m_dragEndedScrollingVelocity, FloatSize(-wheelEvent.deltaX(), -wheelEvent.deltaY()));
m_dragEndedScrollingVelocity = { };
- isInertialScrolling = true;
+ isMomentumScrolling = true;
break;
- case WheelEventStatus::InertialScrolling:
- case WheelEventStatus::InertialScrollEnd:
- isInertialScrolling = true;
+ case WheelEventStatus::MomentumScrolling:
+ case WheelEventStatus::MomentumScrollEnd:
+ isMomentumScrolling = true;
break;
case WheelEventStatus::StatelessScrollEvent:
m_scrollSnapState->transitionToUserInteractionState();
@@ -695,9 +704,17 @@
break;
}
- return !(isInertialScrolling && shouldOverrideInertialScrolling());
+ return !(isMomentumScrolling && shouldOverrideMomentumScrolling());
}
+void ScrollController::updateGestureInProgressState(const PlatformWheelEvent& wheelEvent)
+{
+ if (wheelEvent.isGestureBegin() || wheelEvent.isTransitioningToMomentumScroll())
+ m_inScrollGesture = true;
+ else if (wheelEvent.isEndOfNonMomentumScroll() || wheelEvent.isGestureCancel() || wheelEvent.isEndOfMomentumScroll())
+ m_inScrollGesture = false;
+}
+
void ScrollController::startScrollSnapTimer()
{
if (m_scrollSnapTimer)
@@ -729,7 +746,7 @@
void ScrollController::scrollSnapTimerFired()
{
- if (!m_scrollSnapState) {
+ if (!usesScrollSnap()) {
ASSERT_NOT_REACHED();
return;
}
@@ -786,7 +803,7 @@
unsigned ScrollController::activeScrollSnapIndexForAxis(ScrollEventAxis axis) const
{
- if (!m_scrollSnapState)
+ if (!usesScrollSnap())
return 0;
return m_scrollSnapState->activeSnapIndexForAxis(axis);
@@ -794,7 +811,7 @@
void ScrollController::setActiveScrollSnapIndexForAxis(ScrollEventAxis axis, unsigned index)
{
- if (!m_scrollSnapState)
+ if (!usesScrollSnap())
return;
m_scrollSnapState->setActiveSnapIndexForAxis(axis, index);
@@ -802,7 +819,7 @@
void ScrollController::setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis axis, int offset)
{
- if (!m_scrollSnapState)
+ if (!usesScrollSnap())
return;
float scaleFactor = m_client.pageScaleFactor();
@@ -826,7 +843,7 @@
void ScrollController::setActiveScrollSnapIndicesForOffset(int x, int y)
{
- if (!m_scrollSnapState)
+ if (!usesScrollSnap())
return;
setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis::Horizontal, x);
Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (264189 => 264190)
--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm 2020-07-09 20:00:45 UTC (rev 264189)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm 2020-07-09 20:01:53 UTC (rev 264190)
@@ -1272,6 +1272,8 @@
if (!wheelEvent.hasPreciseScrollingDeltas() || !rubberBandingEnabledForSystem())
return ScrollAnimator::handleWheelEvent(wheelEvent);
+ m_scrollController.updateGestureInProgressState(wheelEvent);
+
// FIXME: This is somewhat roundabout hack to allow forwarding wheel events
// up to the parent scrollable area. It takes advantage of the fact that
// the base class implementation of handleWheelEvent will not accept the