Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7c41fd985950f27acd9a3a55c9c6db4d123bd6ae
      
https://github.com/WebKit/WebKit/commit/7c41fd985950f27acd9a3a55c9c6db4d123bd6ae
  Author: Nikolaos Mouchtaris <nmouchta...@apple.com>
  Date:   2023-01-25 (Wed, 25 Jan 2023)

  Changed paths:
    M LayoutTests/fast/scrolling/mac/adjust-scroll-snap-after-gesture.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-relayout/focus-element-no-snap-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-relayout/focus-element-no-snap.html
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-relayout/snap-to-different-targets-expected.txt
    M Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp
    M Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.h
    M Source/WebCore/platform/ScrollSnapAnimatorState.cpp
    M Source/WebCore/platform/ScrollSnapAnimatorState.h
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in

  Log Message:
  -----------
  [css-scroll-snap] Focusing an element with scroll snap should not always 
result in snapping to that element
https://bugs.webkit.org/show_bug.cgi?id=249354
rdar://103731027

Reviewed by Simon Fraser.

This patch refactors the current implementation of this chunk of the spec: "If 
multiple boxes
were snapped before and their snap positions no longer coincide, then if one of 
them is
focused or targeted, the scroll container must re-snap to that one and 
otherwise which one
to re-snap to is UA-defined." We now more closely follow the language of the 
spec by specifically
keeping track of the boxes we are currently snapped to through 
m_currentlySnappedBoxesX/Y.
Vectors are necessary as we can be snapped to multiple boxes per axis (ie. 
multiple boxes along
the same snap offset). If we see that the number of boxes we are snapped to 
changes due to
relayout, we use the algorithm the spec specifies by first checking if any of 
the previously
snapped boxes are focused, then if not, choosing a UA defined box. This also 
fixes the focus
bug as we are now properly snapping to a focused element only under the correct 
scenario
(when we were previously snapped to multiple boxes). Currently
css/css-scroll-snap/snap-after-relayout/resnap-to-focused.html is failing due 
to getting
the scroll position before we finish triggering relayout, so we need to figure 
out a way
to fix the test.

* Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp:
(WebCore::updateSnapOffsetsForScrollableArea):
(WebCore::convertOffsetInfo):
* Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.h:
* Source/WebCore/platform/ScrollSnapAnimatorState.cpp:
(WebCore::ScrollSnapAnimatorState::setFocusedElementForAxis):
(WebCore::ScrollSnapAnimatorState::preserveCurrentTargetForAxis):
(WebCore::ScrollSnapAnimatorState::currentlySnappedOffsets):
(WebCore::isSnappedToMultipleBoxes):
(WebCore::ScrollSnapAnimatorState::chooseBoxToResnapTo):
(WebCore::ScrollSnapAnimatorState::resnapAfterLayout):
* Source/WebCore/platform/ScrollSnapAnimatorState.h:

Canonical link: https://commits.webkit.org/259381@main


_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to