Title: [279869] trunk
Revision
279869
Author
[email protected]
Date
2021-07-13 01:17:26 -0700 (Tue, 13 Jul 2021)

Log Message

RenderLayerScrollableArea::updateScrollPosition assumes that it can scroll to the targeted scroll position
https://bugs.webkit.org/show_bug.cgi?id=227803

Patch by Martin Robinson <[email protected]> on 2021-07-13
Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-scroll-snap/nested-scrollIntoView-snaps-expected.txt: Update test result to reflect newly passing test.

Source/WebCore:

No new tests. This is covered by an existing WPT test:
  - web-platform-tests/css/css-scroll-snap/nested-scrollIntoView-snaps.html

* rendering/RenderLayerScrollableArea.cpp:
(WebCore::RenderLayerScrollableArea::scrollToOffset): Modified this method to return the snapped
scroll offset.
(WebCore::RenderLayerScrollableArea::updateScrollPosition): Instead of using the original target offset,
use the return value from scrollToOffset to adjust the output rectangle.
* rendering/RenderLayerScrollableArea.h: Update the method definition.

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279868 => 279869)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-13 07:52:36 UTC (rev 279868)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-13 08:17:26 UTC (rev 279869)
@@ -1,3 +1,12 @@
+2021-07-13  Martin Robinson  <[email protected]>
+
+        RenderLayerScrollableArea::updateScrollPosition assumes that it can scroll to the targeted scroll position
+        https://bugs.webkit.org/show_bug.cgi?id=227803
+
+        Reviewed by Simon Fraser.
+
+        * web-platform-tests/css/css-scroll-snap/nested-scrollIntoView-snaps-expected.txt: Update test result to reflect newly passing test.
+
 2021-07-12  Chris Dumez  <[email protected]>
 
         Resync content-security-policy web-platform-tests from upstream

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/nested-scrollIntoView-snaps-expected.txt (279868 => 279869)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/nested-scrollIntoView-snaps-expected.txt	2021-07-13 07:52:36 UTC (rev 279868)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/nested-scrollIntoView-snaps-expected.txt	2021-07-13 08:17:26 UTC (rev 279869)
@@ -1,3 +1,3 @@
 
-FAIL All the scrollers affected by scrollIntoView should land on a snap position if one exists. Otherwise, land according to the specified alignment assert_equals: ScrollIntoView ends with the specified alignment if no snap position is specified. expected 1185 but got 1000
+PASS All the scrollers affected by scrollIntoView should land on a snap position if one exists. Otherwise, land according to the specified alignment
 

Modified: trunk/Source/WebCore/ChangeLog (279868 => 279869)


--- trunk/Source/WebCore/ChangeLog	2021-07-13 07:52:36 UTC (rev 279868)
+++ trunk/Source/WebCore/ChangeLog	2021-07-13 08:17:26 UTC (rev 279869)
@@ -1,3 +1,20 @@
+2021-07-13  Martin Robinson  <[email protected]>
+
+        RenderLayerScrollableArea::updateScrollPosition assumes that it can scroll to the targeted scroll position
+        https://bugs.webkit.org/show_bug.cgi?id=227803
+
+        Reviewed by Simon Fraser.
+
+        No new tests. This is covered by an existing WPT test:
+          - web-platform-tests/css/css-scroll-snap/nested-scrollIntoView-snaps.html
+
+        * rendering/RenderLayerScrollableArea.cpp:
+        (WebCore::RenderLayerScrollableArea::scrollToOffset): Modified this method to return the snapped
+        scroll offset.
+        (WebCore::RenderLayerScrollableArea::updateScrollPosition): Instead of using the original target offset,
+        use the return value from scrollToOffset to adjust the output rectangle.
+        * rendering/RenderLayerScrollableArea.h: Update the method definition.
+
 2021-07-13  Myles C. Maxfield  <[email protected]>
 
         PUA characters have the wrong advance in the fast text codepath

Modified: trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp (279868 => 279869)


--- trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp	2021-07-13 07:52:36 UTC (rev 279868)
+++ trunk/Source/WebCore/rendering/RenderLayerScrollableArea.cpp	2021-07-13 08:17:26 UTC (rev 279869)
@@ -254,7 +254,7 @@
     return false;
 }
 
-void RenderLayerScrollableArea::scrollToOffset(const ScrollOffset& scrollOffset, const ScrollPositionChangeOptions& options)
+ScrollOffset RenderLayerScrollableArea::scrollToOffset(const ScrollOffset& scrollOffset, const ScrollPositionChangeOptions& options)
 {
     if (currentScrollBehaviorStatus() == ScrollBehaviorStatus::InNonNativeAnimation)
         scrollAnimator().cancelAnimations();
@@ -261,7 +261,7 @@
 
     ScrollOffset clampedScrollOffset = options.clamping == ScrollClamping::Clamped ? clampScrollOffset(scrollOffset) : scrollOffset;
     if (clampedScrollOffset == this->scrollOffset())
-        return;
+        return clampedScrollOffset;
 
     auto previousScrollType = currentScrollType();
     setCurrentScrollType(options.type);
@@ -277,6 +277,7 @@
     }
 
     setCurrentScrollType(previousScrollType);
+    return snappedOffset;
 }
 
 void RenderLayerScrollableArea::scrollTo(const ScrollPosition& position)
@@ -1754,8 +1755,9 @@
     ScrollOffset clampedScrollOffset = clampScrollOffset(scrollOffset() + toIntSize(roundedIntRect(revealRect).location()));
     if (clampedScrollOffset != scrollOffset() || currentScrollBehaviorStatus() != ScrollBehaviorStatus::NotInAnimation) {
         ScrollOffset oldScrollOffset = scrollOffset();
-        scrollToOffset(clampedScrollOffset, options);
-        IntSize scrollOffsetDifference = clampedScrollOffset - oldScrollOffset;
+        ScrollOffset realScrollOffset = scrollToOffset(clampedScrollOffset, options);
+
+        IntSize scrollOffsetDifference = realScrollOffset - oldScrollOffset;
         auto localExposeRectScrolled = localExposeRect;
         localExposeRectScrolled.move(-scrollOffsetDifference);
         return LayoutRect(box->localToAbsoluteQuad(FloatQuad(FloatRect(localExposeRectScrolled)), UseTransforms).boundingBox());

Modified: trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h (279868 => 279869)


--- trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h	2021-07-13 07:52:36 UTC (rev 279868)
+++ trunk/Source/WebCore/rendering/RenderLayerScrollableArea.h	2021-07-13 08:17:26 UTC (rev 279869)
@@ -83,7 +83,10 @@
     // Scrolling methods for layers that can scroll their overflow.
     void scrollByRecursively(const IntSize& delta, ScrollableArea** scrolledArea = nullptr);
 
-    WEBCORE_EXPORT void scrollToOffset(const ScrollOffset&, const ScrollPositionChangeOptions& = ScrollPositionChangeOptions::createProgrammatic());
+    // Attempt to scroll the given ScrollOffset, returning the real target offset after it has
+    // been adjusted by scroll snapping.
+    WEBCORE_EXPORT ScrollOffset scrollToOffset(const ScrollOffset&, const ScrollPositionChangeOptions& = ScrollPositionChangeOptions::createProgrammatic());
+
     void scrollToXPosition(int x, const ScrollPositionChangeOptions&);
     void scrollToYPosition(int y, const ScrollPositionChangeOptions&);
     void setScrollPosition(const ScrollPosition&, const ScrollPositionChangeOptions&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to