Changeset 278862 in webkit


Ignore:
Timestamp:
Jun 15, 2021 12:08:07 AM (13 months ago)
Author:
Martin Robinson
Message:

[css-scroll-snap] New snap containers always snap to the first scroll position
https://bugs.webkit.org/show_bug.cgi?id=226630

Reviewed by Simon Fraser.

Source/WebCore:

There are two situations where we should not immediately snap to the first snap position
of a scroller after initial layout:

  1. If that scroll is right-to-left. In this case the last snap position is closest to the origin.
  2. If the scroller uses proximity snapping and the first snap position is far enough away from the origin that it isn't yet active.

Previously, WebKit was always snapping to the first position. The change fixes that by
not snapping to the 0 index snap point immediately after initial layout and only snapping
to an eligible snap positions after running a snap point search.

No new tests. This change fixes two existing WPT tests:

  • imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-snap-003.htm
  • imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-initial-layout-000.htm
  • page/scrolling/ScrollSnapOffsetsInfo.cpp:

(WebCore::closestSnapOffsetWithInfoAndAxis): Pull in isNearEnoughToOffsetForProximity as
an anonymous function and use it to avoid snapping to the first and last position if
they are too far for proximity snapping.

  • page/scrolling/ScrollingStateScrollingNode.cpp:

(WebCore::ScrollingStateScrollingNode::dumpProperties const): Use invalidSnapOffsetIndex as
the default for the snap index property. Interpret 0 as a valid snap position.

  • page/scrolling/ScrollingStateScrollingNode.h: Ditto.
  • page/scrolling/ScrollingTreeScrollingNode.cpp:

(WebCore::ScrollingTreeScrollingNode::dumpProperties const): Ditto.

  • page/scrolling/ScrollingTreeScrollingNode.h: Ditto.
  • platform/ScrollAnimator.cpp:

(WebCore::ScrollAnimator::resnapAfterLayout): Added this method that passes through to ScrollController.
(WebCore::ScrollAnimator::updateActiveScrollSnapIndexForOffset): Simplified setActiveScrollSnapIndicesForOffset
into updateActiveScrollSnapIndexForClientOffset.

  • platform/ScrollAnimator.h: Added method definition.
  • platform/ScrollController.cpp:

(WebCore::ScrollController::setSnapOffsetsInfo): Use updateActiveScrollSnapIndexForClientOffset now.
(WebCore::ScrollController::activeScrollSnapIndexForAxis const): Return invalidSnapOffsetIndex
when snapping is disabled.
(WebCore::ScrollController::setNearestScrollSnapIndexForAxisAndOffset): No longer clamp the scroll
position to the first and last snap points. We might be scrolling to a position before or after
them that isn't subject to proximity snapping.
(WebCore::ScrollController::updateActiveScrollSnapIndexForClientOffset): Renamed from setActiveScrollSnapIndicesForOffset
because it always just took the client's current offset.
(WebCore::ScrollController::resnapAfterLayout): Added this helper which snaps in axes that aren't currently
snapped to a snap position after a layout.

  • platform/ScrollController.h: Removed unused method that used 0 incorrectly as an invalid snap position.

Update method definitions.

  • platform/ScrollSnapAnimatorState.h: Use invalidSnapOffsetIndex to signify no snapping.
  • platform/ScrollSnapAnimatorState.cpp:

(WebCore::ScrollSnapAnimatorState::targetOffsetForStartOffset const): No longer clamp offsets to first and
last scroll snap offsets.

  • platform/ScrollableArea.cpp:

(WebCore::ScrollableArea::currentHorizontalSnapPointIndex const): Ditto.
(WebCore::ScrollableArea::currentVerticalSnapPointIndex const): Ditto.
(WebCore::ScrollableArea::resnapAfterLayout): Call into ScrollController::resnapAfterLayout.

Source/WebKit:

  • UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h: Use invalidSnapOffsetIndex

instead of 0 to initialize the snap position.

LayoutTests:

Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r278861 r278862  
     12021-06-15  Martin Robinson  <mrobinson@webkit.org>
     2
     3        [css-scroll-snap] New snap containers always snap to the first scroll position
     4        https://bugs.webkit.org/show_bug.cgi?id=226630
     5
     6        Reviewed by Simon Fraser.
     7
     8        * TestExpectations: Mark two WPT tests as passing.
     9
    1102021-06-14  Youenn Fablet  <youenn@apple.com>
    211
  • trunk/LayoutTests/TestExpectations

    r278825 r278862  
    45544554imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-snap-001.html [ ImageOnlyFailure ]
    45554555imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-snap-002.html [ ImageOnlyFailure ]
    4556 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-snap-003.html [ ImageOnlyFailure ]
    45574556imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/direction-rtl.html [ ImageOnlyFailure ]
    4558 imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-initial-layout-000.html [ ImageOnlyFailure ]
    45594557imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-writing-mode-000.html [ ImageOnlyFailure ]
    45604558webkit.org/b/218325 imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-001.html [ Pass ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r278858 r278862  
     12021-06-15  Martin Robinson  <mrobinson@webkit.org>
     2
     3        [css-scroll-snap] New snap containers always snap to the first scroll position
     4        https://bugs.webkit.org/show_bug.cgi?id=226630
     5
     6        Reviewed by Simon Fraser.
     7
     8        There are two situations where we should not immediately snap to the first snap position
     9        of a scroller after initial layout:
     10            1. If that scroll is right-to-left. In this case the last snap position is closest to
     11               the origin.
     12            2. If the scroller uses proximity snapping and the first snap position is far enough
     13               away from the origin that it isn't yet active.
     14        Previously, WebKit was always snapping to the first position. The change fixes that by
     15        not snapping to the 0 index snap point immediately after initial layout and only snapping
     16        to an eligible snap positions after running a snap point search.
     17
     18        No new tests. This change fixes two existing WPT tests:
     19            - imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-snap-003.htm
     20            - imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-initial-layout-000.htm
     21
     22        * page/scrolling/ScrollSnapOffsetsInfo.cpp:
     23        (WebCore::closestSnapOffsetWithInfoAndAxis): Pull in isNearEnoughToOffsetForProximity as
     24        an anonymous function and use it to avoid snapping to the first and last position if
     25        they are too far for proximity snapping.
     26        * page/scrolling/ScrollingStateScrollingNode.cpp:
     27        (WebCore::ScrollingStateScrollingNode::dumpProperties const): Use invalidSnapOffsetIndex as
     28        the default for the snap index property. Interpret 0 as a valid snap position.
     29        * page/scrolling/ScrollingStateScrollingNode.h: Ditto.
     30        * page/scrolling/ScrollingTreeScrollingNode.cpp:
     31        (WebCore::ScrollingTreeScrollingNode::dumpProperties const): Ditto.
     32        * page/scrolling/ScrollingTreeScrollingNode.h: Ditto.
     33        * platform/ScrollAnimator.cpp:
     34        (WebCore::ScrollAnimator::resnapAfterLayout): Added this method that passes through to ScrollController.
     35        (WebCore::ScrollAnimator::updateActiveScrollSnapIndexForOffset): Simplified setActiveScrollSnapIndicesForOffset
     36        into updateActiveScrollSnapIndexForClientOffset.
     37        * platform/ScrollAnimator.h: Added method definition.
     38        * platform/ScrollController.cpp:
     39        (WebCore::ScrollController::setSnapOffsetsInfo): Use updateActiveScrollSnapIndexForClientOffset now.
     40        (WebCore::ScrollController::activeScrollSnapIndexForAxis const): Return invalidSnapOffsetIndex
     41        when snapping is disabled.
     42        (WebCore::ScrollController::setNearestScrollSnapIndexForAxisAndOffset): No longer clamp the scroll
     43        position to the first and last snap points. We might be scrolling to a position before or after
     44        them that isn't subject to proximity snapping.
     45        (WebCore::ScrollController::updateActiveScrollSnapIndexForClientOffset): Renamed from setActiveScrollSnapIndicesForOffset
     46        because it always just took the client's current offset.
     47        (WebCore::ScrollController::resnapAfterLayout): Added this helper which snaps in axes that aren't currently
     48        snapped to a snap position after a layout.
     49        * platform/ScrollController.h: Removed unused method that used 0 incorrectly as an invalid snap position.
     50        Update method definitions.
     51        * platform/ScrollSnapAnimatorState.h: Use invalidSnapOffsetIndex to signify no snapping.
     52        * platform/ScrollSnapAnimatorState.cpp:
     53        (WebCore::ScrollSnapAnimatorState::targetOffsetForStartOffset const): No longer clamp offsets to first and
     54        last scroll snap offsets.
     55        * platform/ScrollableArea.cpp:
     56        (WebCore::ScrollableArea::currentHorizontalSnapPointIndex const): Ditto.
     57        (WebCore::ScrollableArea::currentVerticalSnapPointIndex const): Ditto.
     58        (WebCore::ScrollableArea::resnapAfterLayout): Call into ScrollController::resnapAfterLayout.
     59
    1602021-06-14  Myles C. Maxfield  <mmaxfield@apple.com>
    261
  • trunk/Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp

    r278350 r278862  
    4343namespace WebCore {
    4444
    45 template <typename UnitType>
    46 static bool isNearEnoughToOffsetForProximity(ScrollSnapStrictness strictness, UnitType scrollDestination, UnitType candidateSnapOffset, UnitType viewportLength)
    47 {
    48     if (strictness != ScrollSnapStrictness::Proximity)
    49         return true;
    50 
    51     // This is an arbitrary choice for what it means to be "in proximity" of a snap offset. We should play around with
    52     // this and see what feels best.
    53     static const float ratioOfScrollPortAxisLengthToBeConsideredForProximity = 0.3;
    54     return std::abs(float {candidateSnapOffset - scrollDestination}) <= (viewportLength * ratioOfScrollPortAxisLengthToBeConsideredForProximity);
    55 }
    56 
    5745template <typename LayoutType>
    5846static void indicesOfNearestSnapOffsets(LayoutType offset, const Vector<SnapOffset<LayoutType>>& snapOffsets, unsigned& lowerIndex, unsigned& upperIndex)
     
    11199{
    112100    const auto& snapOffsets = info.offsetsForAxis(axis);
     101    auto pairForNoSnapping = std::make_pair(scrollDestinationOffset, invalidSnapOffsetIndex);
    113102    if (snapOffsets.isEmpty())
    114         return std::make_pair(scrollDestinationOffset, invalidSnapOffsetIndex);
     103        return pairForNoSnapping;
    115104
    116105    if (originalOffsetForDirectionalSnapping) {
     
    119108    }
    120109
     110    auto viewportLength = axis == ScrollEventAxis::Horizontal ? viewportSize.width() : viewportSize.height();
     111    auto isNearEnoughToOffsetForProximity = [&](LayoutType candidateSnapOffset) {
     112        if (info.strictness != ScrollSnapStrictness::Proximity)
     113            return true;
     114
     115        // This is an arbitrary choice for what it means to be "in proximity" of a snap offset. We should play around with
     116        // this and see what feels best.
     117        static const float ratioOfScrollPortAxisLengthToBeConsideredForProximity = 0.3;
     118        return std::abs(float {candidateSnapOffset - scrollDestinationOffset}) <= (viewportLength * ratioOfScrollPortAxisLengthToBeConsideredForProximity);
     119    };
     120
    121121    if (scrollDestinationOffset <= snapOffsets.first().offset)
    122         return std::make_pair(snapOffsets.first().offset, 0u);
    123 
    124     if (scrollDestinationOffset >= snapOffsets.last().offset)
    125         return std::make_pair(snapOffsets.last().offset, snapOffsets.size() - 1);
     122        return isNearEnoughToOffsetForProximity(snapOffsets.first().offset) ? std::make_pair(snapOffsets.first().offset, 0u) : pairForNoSnapping;
     123
     124    if (scrollDestinationOffset >= snapOffsets.last().offset) {
     125        unsigned lastIndex = static_cast<unsigned>(snapOffsets.size() - 1);
     126        return isNearEnoughToOffsetForProximity(snapOffsets.last().offset) ? std::make_pair(snapOffsets.last().offset, lastIndex) : pairForNoSnapping;
     127    }
    126128
    127129    unsigned lowerIndex;
     
    131133    LayoutType upperSnapPosition = snapOffsets[upperIndex].offset;
    132134
    133     auto viewportLength = axis == ScrollEventAxis::Horizontal ? viewportSize.width() : viewportSize.height();
    134     if (!isNearEnoughToOffsetForProximity<LayoutType>(info.strictness, scrollDestinationOffset, lowerSnapPosition, viewportLength)) {
     135    if (!isNearEnoughToOffsetForProximity(lowerSnapPosition)) {
    135136        lowerSnapPosition = scrollDestinationOffset;
    136137        lowerIndex = invalidSnapOffsetIndex;
    137138    }
    138139
    139     if (!isNearEnoughToOffsetForProximity<LayoutType>(info.strictness, scrollDestinationOffset, upperSnapPosition, viewportLength)) {
     140    if (!isNearEnoughToOffsetForProximity(upperSnapPosition)) {
    140141        upperSnapPosition = scrollDestinationOffset;
    141142        upperIndex = invalidSnapOffsetIndex;
    142143    }
     144
    143145    if (!std::abs(velocity)) {
    144146        bool isCloserToLowerSnapPosition = (upperIndex == invalidSnapOffsetIndex)
  • trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp

    r275354 r278862  
    314314        ts.dumpProperty("vertical snap offsets", m_snapOffsetsInfo.verticalSnapOffsets);
    315315
    316     if (m_currentHorizontalSnapPointIndex)
     316    if (m_currentHorizontalSnapPointIndex != invalidSnapOffsetIndex)
    317317        ts.dumpProperty("current horizontal snap point index", m_currentHorizontalSnapPointIndex);
    318318
    319     if (m_currentVerticalSnapPointIndex)
     319    if (m_currentVerticalSnapPointIndex != invalidSnapOffsetIndex)
    320320        ts.dumpProperty("current vertical snap point index", m_currentVerticalSnapPointIndex);
    321321#endif
  • trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h

    r275354 r278862  
    132132#if ENABLE(CSS_SCROLL_SNAP)
    133133    FloatScrollSnapOffsetsInfo m_snapOffsetsInfo;
    134     unsigned m_currentHorizontalSnapPointIndex { 0 };
    135     unsigned m_currentVerticalSnapPointIndex { 0 };
     134    unsigned m_currentHorizontalSnapPointIndex { invalidSnapOffsetIndex };
     135    unsigned m_currentVerticalSnapPointIndex { invalidSnapOffsetIndex };
    136136#endif
    137137
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp

    r278253 r278862  
    319319        ts.dumpProperty("vertical snap offsets", m_snapOffsetsInfo.verticalSnapOffsets);
    320320
    321     if (m_currentHorizontalSnapPointIndex)
     321    if (m_currentHorizontalSnapPointIndex != invalidSnapOffsetIndex)
    322322        ts.dumpProperty("current horizontal snap point index", m_currentHorizontalSnapPointIndex);
    323323
    324     if (m_currentVerticalSnapPointIndex)
     324    if (m_currentVerticalSnapPointIndex != invalidSnapOffsetIndex)
    325325        ts.dumpProperty("current vertical snap point index", m_currentVerticalSnapPointIndex);
    326326   
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h

    r278253 r278862  
    161161#if ENABLE(CSS_SCROLL_SNAP)
    162162    FloatScrollSnapOffsetsInfo m_snapOffsetsInfo;
    163     unsigned m_currentHorizontalSnapPointIndex { 0 };
    164     unsigned m_currentVerticalSnapPointIndex { 0 };
     163    unsigned m_currentHorizontalSnapPointIndex { invalidSnapOffsetIndex };
     164    unsigned m_currentVerticalSnapPointIndex { invalidSnapOffsetIndex };
    165165#endif
    166166    ScrollableAreaParameters m_scrollableAreaParameters;
  • trunk/Source/WebCore/platform/ScrollAnimator.cpp

    r278484 r278862  
    194194    return m_scrollController.setActiveScrollSnapIndexForAxis(axis, index);
    195195}
     196
     197void ScrollAnimator::resnapAfterLayout()
     198{
     199    m_scrollController.resnapAfterLayout();
     200}
    196201#endif
    197202
     
    274279{
    275280#if ENABLE(CSS_SCROLL_SNAP)
    276     auto scrollOffset = m_scrollableArea.scrollOffsetFromPosition(roundedIntPoint(currentPosition()));
    277     m_scrollController.setActiveScrollSnapIndicesForOffset(scrollOffset);
     281    m_scrollController.updateActiveScrollSnapIndexForClientOffset();
    278282#endif
    279283}
  • trunk/Source/WebCore/platform/ScrollAnimator.h

    r278484 r278862  
    162162    void setSnapOffsetsInfo(const LayoutScrollSnapOffsetsInfo&);
    163163    const LayoutScrollSnapOffsetsInfo* snapOffsetsInfo() const;
     164    void resnapAfterLayout();
    164165#endif
    165166
  • trunk/Source/WebCore/platform/ScrollController.cpp

    r278484 r278862  
    114114
    115115    if (shouldComputeCurrentSnapIndices)
    116         setActiveScrollSnapIndicesForOffset(roundedIntPoint(m_client.scrollOffset()));
     116        updateActiveScrollSnapIndexForClientOffset();
    117117
    118118    LOG_WITH_STREAM(ScrollSnap, stream << "ScrollController " << this << " setSnapOffsetsInfo new state: " << ValueOrNull(m_scrollSnapState.get()));
     
    127127{
    128128    if (!usesScrollSnap())
    129         return 0;
     129        return invalidSnapOffsetIndex;
    130130
    131131    return m_scrollSnapState->activeSnapIndexForAxis(axis);
     
    152152        return;
    153153
    154     LayoutUnit clampedOffset = std::min(std::max(LayoutUnit(offset / scaleFactor), snapOffsets.first().offset), snapOffsets.last().offset);
    155 
    156154    LayoutSize viewportSize(m_client.viewportSize().width(), m_client.viewportSize().height());
    157     unsigned activeIndex = snapState.snapOffsetInfo().closestSnapOffset(axis, viewportSize, clampedOffset, 0).second;
     155    unsigned activeIndex = snapState.snapOffsetInfo().closestSnapOffset(axis, viewportSize, LayoutUnit(offset / scaleFactor), 0).second;
    158156    if (activeIndex == activeScrollSnapIndexForAxis(axis))
    159157        return;
     
    182180
    183181
    184 void ScrollController::setActiveScrollSnapIndicesForOffset(ScrollOffset offset)
    185 {
    186     if (!usesScrollSnap())
    187         return;
    188 
     182void ScrollController::updateActiveScrollSnapIndexForClientOffset()
     183{
     184    if (!usesScrollSnap())
     185        return;
     186
     187    ScrollOffset offset = roundedIntPoint(m_client.scrollOffset());
    189188    setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis::Horizontal, offset.x());
    190189    setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis::Vertical, offset.y());
     190}
     191
     192void ScrollController::resnapAfterLayout()
     193{
     194    if (!usesScrollSnap())
     195        return;
     196
     197    // If we are already snapped in a particular axis, maintain that. Otherwise, snap to the nearest eligible snap point.
     198    ScrollOffset offset = roundedIntPoint(m_client.scrollOffset());
     199    size_t activeHorizontalIndex = m_scrollSnapState->activeSnapIndexForAxis(ScrollEventAxis::Horizontal);
     200    if (activeHorizontalIndex == invalidSnapOffsetIndex)
     201        setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis::Horizontal, offset.x());
     202    size_t activeVerticalIndex = m_scrollSnapState->activeSnapIndexForAxis(ScrollEventAxis::Vertical);
     203    if (activeVerticalIndex == invalidSnapOffsetIndex)
     204        setNearestScrollSnapIndexForAxisAndOffset(ScrollEventAxis::Vertical, offset.y());
     205
    191206}
    192207#endif
  • trunk/Source/WebCore/platform/ScrollController.h

    r278484 r278862  
    112112    virtual void willStartScrollSnapAnimation() { }
    113113    virtual void didStopScrollSnapAnimation() { }
    114 
    115114    virtual float pageScaleFactor() const = 0;
    116 
    117     virtual unsigned activeScrollOffsetIndex(ScrollEventAxis) const
    118     {
    119         return 0;
    120     }
    121 
    122115    virtual LayoutSize scrollExtent() const = 0;
    123116    virtual FloatSize viewportSize() const = 0;
     
    143136    const LayoutScrollSnapOffsetsInfo* snapOffsetsInfo() const;
    144137    void setActiveScrollSnapIndexForAxis(ScrollEventAxis, unsigned);
    145     void setActiveScrollSnapIndicesForOffset(ScrollOffset);
     138    void updateActiveScrollSnapIndexForClientOffset();
     139    void resnapAfterLayout();
    146140    bool activeScrollSnapIndexDidChange() const { return m_activeScrollSnapIndexDidChange; }
    147141    void setScrollSnapIndexDidChange(bool state) { m_activeScrollSnapIndexDidChange = state; }
  • trunk/Source/WebCore/platform/ScrollSnapAnimatorState.cpp

    r277350 r278862  
    101101
    102102    float targetOffset = m_snapOffsetsInfo.closestSnapOffset(axis, LayoutSize { viewportSize }, LayoutUnit(predictedOffset / pageScale), initialDelta, LayoutUnit(startOffset / pageScale)).first;
    103     float minimumTargetOffset = std::max<float>(0, snapOffsets.first().offset);
    104     float maximumTargetOffset = std::min<float>(maxScrollOffset, snapOffsets.last().offset);
    105     targetOffset = clampTo<float>(targetOffset, minimumTargetOffset, maximumTargetOffset);
    106     return pageScale * targetOffset;
     103    return pageScale * clampTo<float>(targetOffset, 0, maxScrollOffset);
    107104}
    108105
  • trunk/Source/WebCore/platform/ScrollSnapAnimatorState.h

    r277350 r278862  
    9393    LayoutScrollSnapOffsetsInfo m_snapOffsetsInfo;
    9494
    95     unsigned m_activeSnapIndexX { 0 };
    96     unsigned m_activeSnapIndexY { 0 };
     95    unsigned m_activeSnapIndexX { invalidSnapOffsetIndex };
     96    unsigned m_activeSnapIndexY { invalidSnapOffsetIndex };
    9797
    9898    MonotonicTime m_startTime;
  • trunk/Source/WebCore/platform/ScrollableArea.cpp

    r278484 r278862  
    495495    if (auto* scrollAnimator = existingScrollAnimator())
    496496        return scrollAnimator->activeScrollSnapIndexForAxis(ScrollEventAxis::Horizontal);
    497     return 0; // FIXME: This should really be invalidSnapOffsetIndex.
     497    return invalidSnapOffsetIndex;
    498498}
    499499
     
    502502    if (auto* scrollAnimator = existingScrollAnimator())
    503503        return scrollAnimator->activeScrollSnapIndexForAxis(ScrollEventAxis::Vertical);
    504     return 0; // FIXME: This should really be invalidSnapOffsetIndex.
     504    return invalidSnapOffsetIndex;
    505505}
    506506
     
    519519    LOG_WITH_STREAM(ScrollSnap, stream << *this << " updateScrollSnapState: isScrollSnapInProgress " << isScrollSnapInProgress() << " isUserScrollInProgress " << isUserScrollInProgress());
    520520
    521     if (!existingScrollAnimator() || isScrollSnapInProgress() || isUserScrollInProgress())
     521    ScrollAnimator* scrollAnimator = existingScrollAnimator();
     522    if (!scrollAnimator || isScrollSnapInProgress() || isUserScrollInProgress())
    522523        return;
     524
     525    scrollAnimator->resnapAfterLayout();
    523526
    524527    const auto* info = snapOffsetsInfo();
  • trunk/Source/WebKit/ChangeLog

    r278849 r278862  
     12021-06-15  Martin Robinson  <mrobinson@webkit.org>
     2
     3        [css-scroll-snap] New snap containers always snap to the first scroll position
     4        https://bugs.webkit.org/show_bug.cgi?id=226630
     5
     6        Reviewed by Simon Fraser.
     7
     8        * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h: Use invalidSnapOffsetIndex
     9        instead of 0 to initialize the snap position.
     10
    1112021-06-14  Alex Christensen  <achristensen@webkit.org>
    212
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h

    r278253 r278862  
    3333#include "RemoteScrollingUIState.h"
    3434#include <WebCore/GraphicsLayer.h>
     35#include <WebCore/ScrollSnapOffsetsInfo.h>
    3536#include <wtf/Noncopyable.h>
    3637#include <wtf/RefPtr.h>
     
    132133    RemoteScrollingUIState m_uiState;
    133134#if ENABLE(CSS_SCROLL_SNAP)
    134     unsigned m_currentHorizontalSnapPointIndex { 0 };
    135     unsigned m_currentVerticalSnapPointIndex { 0 };
     135    unsigned m_currentHorizontalSnapPointIndex { WebCore::invalidSnapOffsetIndex };
     136    unsigned m_currentVerticalSnapPointIndex { WebCore::invalidSnapOffsetIndex };
    136137#endif
    137138    bool m_propagatesMainFrameScrolls { true };
Note: See TracChangeset for help on using the changeset viewer.