Title: [282903] trunk/Source/WebCore
Revision
282903
Author
simon.fra...@apple.com
Date
2021-09-22 19:52:21 -0700 (Wed, 22 Sep 2021)

Log Message

Move more scroll snap-related code into ScrollSnapAnimatorState
https://bugs.webkit.org/show_bug.cgi?id=230659

Reviewed by Wenson Hsieh.

Reduce the brain print of ScrollingEffectsController by moving scroll snap-related code
into ScrollSnapAnimatorState, which is going to become a ScrollSnapController at some
point.

* page/FrameView.cpp:
(WebCore::FrameView::setScrollPosition):
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::scroll):
(WebCore::ScrollAnimator::scrollOffsetAdjustedForSnapping const):
(WebCore::ScrollAnimator::adjustScrollOffsetForSnappingIfNeeded): Deleted.
* platform/ScrollAnimator.h:
* platform/ScrollSnapAnimatorState.cpp:
(WebCore::ScrollSnapAnimatorState::closestSnapPointForOffset const):
(WebCore::ScrollSnapAnimatorState::adjustedScrollDestination const):
(WebCore::ScrollSnapAnimatorState::resnapAfterLayout):
(WebCore::ScrollSnapAnimatorState::setNearestScrollSnapIndexForAxisAndOffset):
(WebCore::ScrollSnapAnimatorState::setNearestScrollSnapIndexForOffset):
* platform/ScrollSnapAnimatorState.h:
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::doPostThumbMoveSnapping):
* platform/ScrollingEffectsController.cpp:
(WebCore::ScrollingEffectsController::adjustedScrollDestination const):
(WebCore::ScrollingEffectsController::updateActiveScrollSnapIndexForClientOffset):
(WebCore::ScrollingEffectsController::resnapAfterLayout):
(WebCore::ScrollingEffectsController::setNearestScrollSnapIndexForAxisAndOffset): Deleted.
(WebCore::ScrollingEffectsController::adjustScrollDestination): Deleted.
* platform/ScrollingEffectsController.h:
(WebCore::ScrollingEffectsController::setScrollSnapIndexDidChange):
* rendering/RenderLayerScrollableArea.cpp:
(WebCore::RenderLayerScrollableArea::scrollToOffset):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (282902 => 282903)


--- trunk/Source/WebCore/ChangeLog	2021-09-23 02:39:34 UTC (rev 282902)
+++ trunk/Source/WebCore/ChangeLog	2021-09-23 02:52:21 UTC (rev 282903)
@@ -1,3 +1,41 @@
+2021-09-22  Simon Fraser  <simon.fra...@apple.com>
+
+        Move more scroll snap-related code into ScrollSnapAnimatorState
+        https://bugs.webkit.org/show_bug.cgi?id=230659
+
+        Reviewed by Wenson Hsieh.
+
+        Reduce the brain print of ScrollingEffectsController by moving scroll snap-related code
+        into ScrollSnapAnimatorState, which is going to become a ScrollSnapController at some
+        point.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::setScrollPosition):
+        * platform/ScrollAnimator.cpp:
+        (WebCore::ScrollAnimator::scroll):
+        (WebCore::ScrollAnimator::scrollOffsetAdjustedForSnapping const):
+        (WebCore::ScrollAnimator::adjustScrollOffsetForSnappingIfNeeded): Deleted.
+        * platform/ScrollAnimator.h:
+        * platform/ScrollSnapAnimatorState.cpp:
+        (WebCore::ScrollSnapAnimatorState::closestSnapPointForOffset const):
+        (WebCore::ScrollSnapAnimatorState::adjustedScrollDestination const):
+        (WebCore::ScrollSnapAnimatorState::resnapAfterLayout):
+        (WebCore::ScrollSnapAnimatorState::setNearestScrollSnapIndexForAxisAndOffset):
+        (WebCore::ScrollSnapAnimatorState::setNearestScrollSnapIndexForOffset):
+        * platform/ScrollSnapAnimatorState.h:
+        * platform/ScrollableArea.cpp:
+        (WebCore::ScrollableArea::doPostThumbMoveSnapping):
+        * platform/ScrollingEffectsController.cpp:
+        (WebCore::ScrollingEffectsController::adjustedScrollDestination const):
+        (WebCore::ScrollingEffectsController::updateActiveScrollSnapIndexForClientOffset):
+        (WebCore::ScrollingEffectsController::resnapAfterLayout):
+        (WebCore::ScrollingEffectsController::setNearestScrollSnapIndexForAxisAndOffset): Deleted.
+        (WebCore::ScrollingEffectsController::adjustScrollDestination): Deleted.
+        * platform/ScrollingEffectsController.h:
+        (WebCore::ScrollingEffectsController::setScrollSnapIndexDidChange):
+        * rendering/RenderLayerScrollableArea.cpp:
+        (WebCore::RenderLayerScrollableArea::scrollToOffset):
+
 2021-09-22  Alan Bujtas  <za...@apple.com>
 
         [LFC][IFC] Move LineGeometry under InlineDisplay namespace

Modified: trunk/Source/WebCore/page/FrameView.cpp (282902 => 282903)


--- trunk/Source/WebCore/page/FrameView.cpp	2021-09-23 02:39:34 UTC (rev 282902)
+++ trunk/Source/WebCore/page/FrameView.cpp	2021-09-23 02:52:21 UTC (rev 282903)
@@ -2318,7 +2318,7 @@
     if (page && page->isMonitoringWheelEvents())
         scrollAnimator().setWheelEventTestMonitor(page->wheelEventTestMonitor());
 
-    ScrollOffset snappedOffset = ceiledIntPoint(scrollAnimator().adjustScrollOffsetForSnappingIfNeeded(scrollOffsetFromPosition(scrollPosition), options.snapPointSelectionMethod));
+    ScrollOffset snappedOffset = ceiledIntPoint(scrollAnimator().scrollOffsetAdjustedForSnapping(scrollOffsetFromPosition(scrollPosition), options.snapPointSelectionMethod));
     auto snappedPosition = scrollPositionFromOffset(snappedOffset);
 
     if (options.animated == AnimatedScroll::Yes)

Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (282902 => 282903)


--- trunk/Source/WebCore/platform/ScrollAnimator.cpp	2021-09-23 02:39:34 UTC (rev 282902)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp	2021-09-23 02:52:21 UTC (rev 282903)
@@ -78,13 +78,14 @@
         auto currentOffset = offsetFromPosition(currentPosition());
         auto newOffset = currentOffset + delta;
         if (orientation == HorizontalScrollbar)
-            newOffset.setX(m_scrollController.adjustScrollDestination(ScrollEventAxis::Horizontal, newOffset, multiplier, currentOffset.x()));
+            newOffset.setX(m_scrollController.adjustedScrollDestination(ScrollEventAxis::Horizontal, newOffset, multiplier, currentOffset.x()));
         else
-            newOffset.setY(m_scrollController.adjustScrollDestination(ScrollEventAxis::Vertical, newOffset, multiplier, currentOffset.y()));
+            newOffset.setY(m_scrollController.adjustedScrollDestination(ScrollEventAxis::Vertical, newOffset, multiplier, currentOffset.y()));
+
         auto newDelta = newOffset - currentOffset;
-
         if (orientation == HorizontalScrollbar)
             return scroll(HorizontalScrollbar, granularity, newDelta.width(), 1.0, behavior);
+
         return scroll(VerticalScrollbar, granularity, newDelta.height(), 1.0, behavior);
     }
 
@@ -393,18 +394,18 @@
     m_scrollAnimation->updateScrollExtents();
 }
 
-FloatPoint ScrollAnimator::adjustScrollOffsetForSnappingIfNeeded(const FloatPoint& offset, ScrollSnapPointSelectionMethod method)
+FloatPoint ScrollAnimator::scrollOffsetAdjustedForSnapping(const FloatPoint& offset, ScrollSnapPointSelectionMethod method) const
 {
     if (!m_scrollController.usesScrollSnap())
         return offset;
 
-    FloatPoint newOffset = offset;
-    newOffset.setX(adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Horizontal, newOffset, method));
-    newOffset.setY(adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Vertical, newOffset, method));
-    return newOffset;
+    return {
+        scrollOffsetAdjustedForSnapping(ScrollEventAxis::Horizontal, offset, method),
+        scrollOffsetAdjustedForSnapping(ScrollEventAxis::Vertical, offset, method)
+    };
 }
 
-float ScrollAnimator::adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis axis, const FloatPoint& newOffset, ScrollSnapPointSelectionMethod method)
+float ScrollAnimator::scrollOffsetAdjustedForSnapping(ScrollEventAxis axis, const FloatPoint& newOffset, ScrollSnapPointSelectionMethod method) const
 {
     if (!m_scrollController.usesScrollSnap())
         return axis == ScrollEventAxis::Horizontal ? newOffset.x() : newOffset.y();
@@ -419,7 +420,7 @@
         velocityInScrollAxis = axis == ScrollEventAxis::Horizontal ? velocity.width() : velocity.height();
     }
 
-    return m_scrollController.adjustScrollDestination(axis, newOffset, velocityInScrollAxis, originalOffset);
+    return m_scrollController.adjustedScrollDestination(axis, newOffset, velocityInScrollAxis, originalOffset);
 }
 
 void ScrollAnimator::scrollAnimationDidUpdate(ScrollAnimation&, const FloatPoint& currentOffset)

Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (282902 => 282903)


--- trunk/Source/WebCore/platform/ScrollAnimator.h	2021-09-23 02:39:34 UTC (rev 282902)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h	2021-09-23 02:52:21 UTC (rev 282903)
@@ -109,8 +109,8 @@
     void setWheelEventTestMonitor(RefPtr<WheelEventTestMonitor>&& testMonitor) { m_wheelEventTestMonitor = testMonitor; }
     WheelEventTestMonitor* wheelEventTestMonitor() const { return m_wheelEventTestMonitor.get(); }
 
-    FloatPoint adjustScrollOffsetForSnappingIfNeeded(const FloatPoint& offset, ScrollSnapPointSelectionMethod);
-    float adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis, const FloatPoint& newOffset, ScrollSnapPointSelectionMethod);
+    FloatPoint scrollOffsetAdjustedForSnapping(const FloatPoint& offset, ScrollSnapPointSelectionMethod) const;
+    float scrollOffsetAdjustedForSnapping(ScrollEventAxis, const FloatPoint& newOffset, ScrollSnapPointSelectionMethod) const;
 
     bool activeScrollSnapIndexDidChange() const;
     std::optional<unsigned> activeScrollSnapIndexForAxis(ScrollEventAxis) const;

Modified: trunk/Source/WebCore/platform/ScrollSnapAnimatorState.cpp (282902 => 282903)


--- trunk/Source/WebCore/platform/ScrollSnapAnimatorState.cpp	2021-09-23 02:39:34 UTC (rev 282902)
+++ trunk/Source/WebCore/platform/ScrollSnapAnimatorState.cpp	2021-09-23 02:52:21 UTC (rev 282903)
@@ -72,6 +72,67 @@
     return animating;
 }
 
+std::optional<unsigned> ScrollSnapAnimatorState::closestSnapPointForOffset(ScrollEventAxis axis, ScrollOffset scrollOffset, const ScrollExtents& scrollExtents, float pageScale) const
+{
+    LayoutPoint layoutScrollOffset(scrollOffset.x() / pageScale, scrollOffset.y() / pageScale);
+
+    auto snapOffsets = snapOffsetsForAxis(axis);
+    LayoutSize viewportSize(scrollExtents.viewportSize);
+    std::optional<unsigned> activeIndex;
+    if (snapOffsets.size())
+        activeIndex = snapOffsetInfo().closestSnapOffset(axis, viewportSize, layoutScrollOffset, 0).second;
+
+    return activeIndex;
+}
+
+float ScrollSnapAnimatorState::adjustedScrollDestination(ScrollEventAxis axis, FloatPoint destinationOffset, float velocity, std::optional<float> originalOffset, const ScrollExtents& scrollExtents, float pageScale) const
+{
+    auto snapOffsets = snapOffsetsForAxis(axis);
+    if (!snapOffsets.size())
+        return axis == ScrollEventAxis::Horizontal ? destinationOffset.x() : destinationOffset.y();
+
+    std::optional<LayoutUnit> originalOffsetInLayoutUnits;
+    if (originalOffset)
+        originalOffsetInLayoutUnits = LayoutUnit(*originalOffset / pageScale);
+    LayoutSize viewportSize(scrollExtents.viewportSize);
+    LayoutPoint layoutDestinationOffset(destinationOffset.x() / pageScale, destinationOffset.y() / pageScale);
+    LayoutUnit offset = snapOffsetInfo().closestSnapOffset(axis, viewportSize, layoutDestinationOffset, velocity, originalOffsetInLayoutUnits).first;
+    return offset * pageScale;
+}
+
+bool ScrollSnapAnimatorState::resnapAfterLayout(ScrollOffset scrollOffset, const ScrollExtents& scrollExtents, float pageScale)
+{
+    bool snapPointChanged = false;
+    // If we are already snapped in a particular axis, maintain that. Otherwise, snap to the nearest eligible snap point.
+    auto activeHorizontalIndex = activeSnapIndexForAxis(ScrollEventAxis::Horizontal);
+    if (!activeHorizontalIndex || *activeHorizontalIndex >= snapOffsetsForAxis(ScrollEventAxis::Horizontal).size())
+        snapPointChanged |= setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis::Horizontal, scrollOffset, scrollExtents, pageScale);
+
+    auto activeVerticalIndex = activeSnapIndexForAxis(ScrollEventAxis::Vertical);
+    if (!activeVerticalIndex || *activeVerticalIndex >= snapOffsetsForAxis(ScrollEventAxis::Vertical).size())
+        snapPointChanged |= setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis::Vertical, scrollOffset, scrollExtents, pageScale);
+
+    return snapPointChanged;
+}
+
+bool ScrollSnapAnimatorState::setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis axis, ScrollOffset scrollOffset, const ScrollExtents& scrollExtents, float pageScale)
+{
+    auto activeIndex = closestSnapPointForOffset(axis, scrollOffset, scrollExtents, pageScale);
+    if (activeIndex == activeSnapIndexForAxis(axis))
+        return false;
+
+    setActiveSnapIndexForAxis(axis, activeIndex);
+    return true;
+}
+
+bool ScrollSnapAnimatorState::setNearestScrollSnapIndexForOffset(ScrollOffset scrollOffset, const ScrollExtents& scrollExtents, float pageScale)
+{
+    bool snapIndexChanged = false;
+    snapIndexChanged |= setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis::Horizontal, scrollOffset, scrollExtents, pageScale);
+    snapIndexChanged |= setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis::Vertical, scrollOffset, scrollExtents, pageScale);
+    return snapIndexChanged;
+}
+
 void ScrollSnapAnimatorState::transitionToUserInteractionState()
 {
     teardownAnimationForState(ScrollSnapState::UserInteraction);

Modified: trunk/Source/WebCore/platform/ScrollSnapAnimatorState.h (282902 => 282903)


--- trunk/Source/WebCore/platform/ScrollSnapAnimatorState.h	2021-09-23 02:39:34 UTC (rev 282902)
+++ trunk/Source/WebCore/platform/ScrollSnapAnimatorState.h	2021-09-23 02:52:21 UTC (rev 282903)
@@ -75,6 +75,15 @@
             m_activeSnapIndexY = index;
     }
 
+    std::optional<unsigned> closestSnapPointForOffset(ScrollEventAxis, ScrollOffset, const ScrollExtents&, float pageScale) const;
+    float adjustedScrollDestination(ScrollEventAxis, FloatPoint destinationOffset, float velocity, std::optional<float> originalOffset, const ScrollExtents&, float pageScale) const;
+
+    // returns true if an active snap index changed.
+    bool resnapAfterLayout(ScrollOffset, const ScrollExtents&, float pageScale);
+    bool setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis, ScrollOffset, const ScrollExtents&, float pageScale);
+
+    bool setNearestScrollSnapIndexForOffset(ScrollOffset, const ScrollExtents&, float pageScale);
+
     FloatPoint currentAnimatedScrollOffset(MonotonicTime, bool& isAnimationComplete) const;
 
     // State transition helpers.

Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (282902 => 282903)


--- trunk/Source/WebCore/platform/ScrollableArea.cpp	2021-09-23 02:39:34 UTC (rev 282902)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp	2021-09-23 02:52:21 UTC (rev 282903)
@@ -567,9 +567,9 @@
     auto currentOffset = scrollOffset();
     auto newOffset = currentOffset;
     if (orientation == HorizontalScrollbar)
-        newOffset.setX(scrollAnimator->adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Horizontal, currentOffset, ScrollSnapPointSelectionMethod::Closest));
+        newOffset.setX(scrollAnimator->scrollOffsetAdjustedForSnapping(ScrollEventAxis::Horizontal, currentOffset, ScrollSnapPointSelectionMethod::Closest));
     else
-        newOffset.setY(scrollAnimator->adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Vertical, currentOffset, ScrollSnapPointSelectionMethod::Closest));
+        newOffset.setY(scrollAnimator->scrollOffsetAdjustedForSnapping(ScrollEventAxis::Vertical, currentOffset, ScrollSnapPointSelectionMethod::Closest));
 
     if (newOffset == currentOffset)
         return;

Modified: trunk/Source/WebCore/platform/ScrollingEffectsController.cpp (282902 => 282903)


--- trunk/Source/WebCore/platform/ScrollingEffectsController.cpp	2021-09-23 02:39:34 UTC (rev 282902)
+++ trunk/Source/WebCore/platform/ScrollingEffectsController.cpp	2021-09-23 02:52:21 UTC (rev 282903)
@@ -147,46 +147,12 @@
     m_scrollSnapState->setActiveSnapIndexForAxis(axis, index);
 }
 
-void ScrollingEffectsController::setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis axis, ScrollOffset scrollOffset)
+float ScrollingEffectsController::adjustedScrollDestination(ScrollEventAxis axis, FloatPoint destinationOffset, float velocity, std::optional<float> originalOffset) const
 {
     if (!usesScrollSnap())
-        return;
-
-    float scaleFactor = m_client.pageScaleFactor();
-    LayoutPoint layoutScrollOffset(scrollOffset.x() / scaleFactor, scrollOffset.y() / scaleFactor);
-    ScrollSnapAnimatorState& snapState = *m_scrollSnapState;
-
-    auto snapOffsets = snapState.snapOffsetsForAxis(axis);
-    LayoutSize viewportSize(m_client.scrollExtents().viewportSize);
-    std::optional<unsigned> activeIndex;
-    if (snapOffsets.size())
-        activeIndex = snapState.snapOffsetInfo().closestSnapOffset(axis, viewportSize, layoutScrollOffset, 0).second;
-
-    if (activeIndex == activeScrollSnapIndexForAxis(axis))
-        return;
-
-    m_activeScrollSnapIndexDidChange = true;
-    setActiveScrollSnapIndexForAxis(axis, activeIndex);
-}
-
-float ScrollingEffectsController::adjustScrollDestination(ScrollEventAxis axis, FloatPoint destinationOffset, float velocity, std::optional<float> originalOffset)
-{
-    if (!usesScrollSnap())
         return axis == ScrollEventAxis::Horizontal ? destinationOffset.x() : destinationOffset.y();
 
-    ScrollSnapAnimatorState& snapState = *m_scrollSnapState;
-    auto snapOffsets = snapState.snapOffsetsForAxis(axis);
-    if (!snapOffsets.size())
-        return axis == ScrollEventAxis::Horizontal ? destinationOffset.x() : destinationOffset.y();
-
-    float scaleFactor = m_client.pageScaleFactor();
-    std::optional<LayoutUnit> originalOffsetInLayoutUnits;
-    if (originalOffset)
-        originalOffsetInLayoutUnits = LayoutUnit(*originalOffset / scaleFactor);
-    LayoutSize viewportSize(m_client.scrollExtents().viewportSize);
-    LayoutPoint layoutDestinationOffset(destinationOffset.x() / scaleFactor, destinationOffset.y() / scaleFactor);
-    LayoutUnit offset = snapState.snapOffsetInfo().closestSnapOffset(axis, viewportSize, layoutDestinationOffset, velocity, originalOffsetInLayoutUnits).first;
-    return offset * scaleFactor;
+    return m_scrollSnapState->adjustedScrollDestination(axis, destinationOffset, velocity, originalOffset, m_client.scrollExtents(), m_client.pageScaleFactor());
 }
 
 void ScrollingEffectsController::updateActiveScrollSnapIndexForClientOffset()
@@ -195,8 +161,8 @@
         return;
 
     ScrollOffset offset = roundedIntPoint(m_client.scrollOffset());
-    setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis::Horizontal, offset);
-    setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis::Vertical, offset);
+    if (m_scrollSnapState->setNearestScrollSnapIndexForOffset(offset, m_client.scrollExtents(), m_client.pageScaleFactor()))
+        m_activeScrollSnapIndexDidChange = true;
 }
 
 void ScrollingEffectsController::resnapAfterLayout()
@@ -206,16 +172,8 @@
 
     // If we are already snapped in a particular axis, maintain that. Otherwise, snap to the nearest eligible snap point.
     ScrollOffset offset = roundedIntPoint(m_client.scrollOffset());
-    ScrollSnapAnimatorState& snapState = *m_scrollSnapState;
-
-    auto activeHorizontalIndex = m_scrollSnapState->activeSnapIndexForAxis(ScrollEventAxis::Horizontal);
-    if (!activeHorizontalIndex || *activeHorizontalIndex >= snapState.snapOffsetsForAxis(ScrollEventAxis::Horizontal).size())
-        setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis::Horizontal, offset);
-
-    auto activeVerticalIndex = m_scrollSnapState->activeSnapIndexForAxis(ScrollEventAxis::Vertical);
-    if (!activeVerticalIndex || *activeVerticalIndex >= snapState.snapOffsetsForAxis(ScrollEventAxis::Vertical).size())
-        setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis::Vertical, offset);
-
+    if (m_scrollSnapState->resnapAfterLayout(offset, m_client.scrollExtents(), m_client.pageScaleFactor()))
+        m_activeScrollSnapIndexDidChange = true;
 }
 
 void ScrollingEffectsController::updateKeyboardScrollingAnimatingState(MonotonicTime currentTime)

Modified: trunk/Source/WebCore/platform/ScrollingEffectsController.h (282902 => 282903)


--- trunk/Source/WebCore/platform/ScrollingEffectsController.h	2021-09-23 02:39:34 UTC (rev 282902)
+++ trunk/Source/WebCore/platform/ScrollingEffectsController.h	2021-09-23 02:52:21 UTC (rev 282903)
@@ -133,17 +133,20 @@
     // Should be called periodically by the client. Started by startAnimationCallback(), stopped by stopAnimationCallback().
     void animationCallback(MonotonicTime);
 
+    void updateGestureInProgressState(const PlatformWheelEvent&);
+
     void setSnapOffsetsInfo(const LayoutScrollSnapOffsetsInfo&);
     const LayoutScrollSnapOffsetsInfo* snapOffsetsInfo() const;
     void setActiveScrollSnapIndexForAxis(ScrollEventAxis, std::optional<unsigned>);
     void updateActiveScrollSnapIndexForClientOffset();
     void resnapAfterLayout();
+
+    std::optional<unsigned> activeScrollSnapIndexForAxis(ScrollEventAxis) const;
+    float adjustedScrollDestination(ScrollEventAxis, FloatPoint destinationOffset, float velocity, std::optional<float> originalOffset) const;
+
     bool activeScrollSnapIndexDidChange() const { return m_activeScrollSnapIndexDidChange; }
+    // FIXME: This is never called. We never set m_activeScrollSnapIndexDidChange back to false.
     void setScrollSnapIndexDidChange(bool state) { m_activeScrollSnapIndexDidChange = state; }
-    std::optional<unsigned> activeScrollSnapIndexForAxis(ScrollEventAxis) const;
-    void updateScrollSnapState(const ScrollableArea&);
-    void updateGestureInProgressState(const PlatformWheelEvent&);
-    float adjustScrollDestination(ScrollEventAxis, FloatPoint destinationOffset, float velocity, std::optional<float> originalOffset);
 
 #if PLATFORM(MAC)
     // Returns true if handled.
@@ -167,8 +170,6 @@
 #endif
 
 private:
-    void setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis, ScrollOffset);
-
     void updateScrollSnapAnimatingState(MonotonicTime);
     void updateRubberBandAnimatingState(MonotonicTime);
     void updateKeyboardScrollingAnimatingState(MonotonicTime);

Modified: trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp (282902 => 282903)


--- trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp	2021-09-23 02:39:34 UTC (rev 282902)
+++ trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp	2021-09-23 02:52:21 UTC (rev 282903)
@@ -266,7 +266,7 @@
     auto previousScrollType = currentScrollType();
     setCurrentScrollType(options.type);
 
-    ScrollOffset snappedOffset = ceiledIntPoint(scrollAnimator().adjustScrollOffsetForSnappingIfNeeded(clampedScrollOffset, options.snapPointSelectionMethod));
+    ScrollOffset snappedOffset = ceiledIntPoint(scrollAnimator().scrollOffsetAdjustedForSnapping(clampedScrollOffset, options.snapPointSelectionMethod));
     auto snappedPosition = scrollPositionFromOffset(snappedOffset);
     if (options.animated == AnimatedScroll::Yes)
         ScrollableArea::scrollToPositionWithAnimation(snappedPosition);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to