Title: [245742] trunk
Revision
245742
Author
[email protected]
Date
2019-05-23 20:25:27 -0700 (Thu, 23 May 2019)

Log Message

With async overflow scrolling, programmatic scroll to a negative offset fails to clamp the scroll offset
https://bugs.webkit.org/show_bug.cgi?id=198208
<rdar://problem/49720087>

Reviewed by Zalan Bujtas.

Source/WebCore:

RenderLayer::scrollToOffset() needs to pass the clamped offset to scrollingCoordinator->requestScrollPositionUpdate(),
otherwise the scrolling tree will round-trip a negative value and scrollLeft will end up negative.

Test: fast/scrolling/programmatic-scroll-to-negative-offset.html

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollToOffset):

LayoutTests:

* fast/scrolling/programmatic-scroll-to-negative-offset-expected.txt: Added.
* fast/scrolling/programmatic-scroll-to-negative-offset.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (245741 => 245742)


--- trunk/LayoutTests/ChangeLog	2019-05-24 03:19:52 UTC (rev 245741)
+++ trunk/LayoutTests/ChangeLog	2019-05-24 03:25:27 UTC (rev 245742)
@@ -1,3 +1,14 @@
+2019-05-23  Simon Fraser  <[email protected]>
+
+        With async overflow scrolling, programmatic scroll to a negative offset fails to clamp the scroll offset
+        https://bugs.webkit.org/show_bug.cgi?id=198208
+        <rdar://problem/49720087>
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/scrolling/programmatic-scroll-to-negative-offset-expected.txt: Added.
+        * fast/scrolling/programmatic-scroll-to-negative-offset.html: Added.
+
 2019-05-23  Fujii Hironori  <[email protected]>
 
         run-webkit-tests: Remove feature detection support

Added: trunk/LayoutTests/fast/scrolling/programmatic-scroll-to-negative-offset-expected.txt (0 => 245742)


--- trunk/LayoutTests/fast/scrolling/programmatic-scroll-to-negative-offset-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/programmatic-scroll-to-negative-offset-expected.txt	2019-05-24 03:25:27 UTC (rev 245742)
@@ -0,0 +1,11 @@
+Tests a programmatic scroll to a negative offset does not result in negative scrollLeft/scrollTop
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS scroller.scrollLeft is 0
+PASS scroller.scrollLeft is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/scrolling/programmatic-scroll-to-negative-offset.html (0 => 245742)


--- trunk/LayoutTests/fast/scrolling/programmatic-scroll-to-negative-offset.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/programmatic-scroll-to-negative-offset.html	2019-05-24 03:25:27 UTC (rev 245742)
@@ -0,0 +1,49 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <style>
+        .container {
+            height: 200px;
+            width: 200px;
+            border: 1px solid black;
+            overflow: scroll;
+        }
+        .contents {
+            height: 500px;
+            width: 500px;
+            background-color: silver;
+        }
+    </style>
+	<script src=""
+    <script>
+		jsTestIsAsync = true;
+		description("Tests a programmatic scroll to a negative offset does not result in negative scrollLeft/scrollTop");
+
+		var scroller;
+		function doScroll()
+        {
+            scroller = document.getElementById('scroller');
+			scroller.scrollLeft = 50;
+
+			scroller.addEventListener('scroll', (event) => {
+				shouldBe("scroller.scrollLeft", "0");
+				shouldBe("scroller.scrollLeft", "0");
+				finishJSTest();
+			}, false);
+
+			setTimeout(() => {
+				scroller.scrollLeft = -200;
+				scroller.scrollTop = -100;
+			}, 0)
+        }
+        window.addEventListener('load', doScroll, false);
+    </script>
+</head>
+<body>
+    <div id="scroller" class="container">
+        <div class="contents">
+        </div>
+    </div>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (245741 => 245742)


--- trunk/Source/WebCore/ChangeLog	2019-05-24 03:19:52 UTC (rev 245741)
+++ trunk/Source/WebCore/ChangeLog	2019-05-24 03:25:27 UTC (rev 245742)
@@ -1,3 +1,19 @@
+2019-05-23  Simon Fraser  <[email protected]>
+
+        With async overflow scrolling, programmatic scroll to a negative offset fails to clamp the scroll offset
+        https://bugs.webkit.org/show_bug.cgi?id=198208
+        <rdar://problem/49720087>
+
+        Reviewed by Zalan Bujtas.
+
+        RenderLayer::scrollToOffset() needs to pass the clamped offset to scrollingCoordinator->requestScrollPositionUpdate(),
+        otherwise the scrolling tree will round-trip a negative value and scrollLeft will end up negative.
+
+        Test: fast/scrolling/programmatic-scroll-to-negative-offset.html
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollToOffset):
+
 2019-05-23  Devin Rousso  <[email protected]>
 
         Web Inspector: Overlay: rulers/guides should be shown whenever element selection is enabled

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (245741 => 245742)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2019-05-24 03:19:52 UTC (rev 245741)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2019-05-24 03:25:27 UTC (rev 245742)
@@ -2435,8 +2435,8 @@
 
 void RenderLayer::scrollToOffset(const ScrollOffset& scrollOffset, ScrollType scrollType, ScrollClamping clamping)
 {
-    ScrollOffset newScrollOffset = clamping == ScrollClamping::Clamped ? clampScrollOffset(scrollOffset) : scrollOffset;
-    if (newScrollOffset == this->scrollOffset())
+    ScrollOffset clampedScrollOffset = clamping == ScrollClamping::Clamped ? clampScrollOffset(scrollOffset) : scrollOffset;
+    if (clampedScrollOffset == this->scrollOffset())
         return;
 
     auto previousScrollType = currentScrollType();
@@ -2445,11 +2445,11 @@
     bool handled = false;
 #if ENABLE(ASYNC_SCROLLING)
     if (ScrollingCoordinator* scrollingCoordinator = page().scrollingCoordinator())
-        handled = scrollingCoordinator->requestScrollPositionUpdate(*this, scrollPositionFromOffset(scrollOffset));
+        handled = scrollingCoordinator->requestScrollPositionUpdate(*this, scrollPositionFromOffset(clampedScrollOffset));
 #endif
 
     if (!handled)
-        scrollToOffsetWithoutAnimation(newScrollOffset, clamping);
+        scrollToOffsetWithoutAnimation(clampedScrollOffset, clamping);
 
     setCurrentScrollType(previousScrollType);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to