[macOS] Fix programmatic scroll in RTL overflow with async scrolling enabled
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 May 2019 15:01:09 +0000 (15:01 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 May 2019 15:01:09 +0000 (15:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198226

Reviewed by Antti Koivisto.

Source/WebCore:

On macOS we need to use a scroll offset to set the layer position, not
a scroll position.

Test: scrollingcoordinator/mac/rtl-programmatic-overflow-scroll.html

* page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:
(WebCore::ScrollingTreeOverflowScrollingNodeMac::repositionScrollingLayers):

Source/WebCore/../../LayoutTests:

* scrollingcoordinator/mac/rtl-programmatic-overflow-scroll-expected.html: Added.
* scrollingcoordinator/mac/rtl-programmatic-overflow-scroll.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245771 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/scrollingcoordinator/mac/rtl-programmatic-overflow-scroll-expected.html [new file with mode: 0644]
LayoutTests/scrollingcoordinator/mac/rtl-programmatic-overflow-scroll.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm

index 863da5f..2510909 100644 (file)
@@ -1,3 +1,13 @@
+2019-05-25  Simon Fraser  <simon.fraser@apple.com>
+
+        [macOS] Fix programmatic scroll in RTL overflow with async scrolling enabled
+        https://bugs.webkit.org/show_bug.cgi?id=198226
+
+        Reviewed by Antti Koivisto.
+
+        * scrollingcoordinator/mac/rtl-programmatic-overflow-scroll-expected.html: Added.
+        * scrollingcoordinator/mac/rtl-programmatic-overflow-scroll.html: Added.
+
 2019-05-24  Joonghun Park  <jh718.park@samsung.com>
 
         Make computed width of non-replaced inline return computed style.
diff --git a/LayoutTests/scrollingcoordinator/mac/rtl-programmatic-overflow-scroll-expected.html b/LayoutTests/scrollingcoordinator/mac/rtl-programmatic-overflow-scroll-expected.html
new file mode 100644 (file)
index 0000000..b7f05ae
--- /dev/null
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        body {
+            margin: 0;
+        }
+        
+        #scroller {
+                   direction: rtl;
+            overflow-x: scroll;
+            margin: 10px;
+            height: 300px;
+            width: 300px;
+        }
+        
+        .contents {
+                   width: 200%;
+                   height: 100%;
+                       background-image: linear-gradient(to right, red, red 50%, green 50%, green);
+        }
+
+        .scrollbar-hider {
+            position: absolute;
+            width: 300px;
+            height: 16px;
+            left: 10px;
+            top: calc(310px - 16px);
+            background-color: gray;
+        }
+    </style>
+</head>
+<body>
+    <div id="scroller">
+        <div class="contents"></div>
+    </div>
+    <div class="scrollbar-hider"></div>
+</body>
+</html>
diff --git a/LayoutTests/scrollingcoordinator/mac/rtl-programmatic-overflow-scroll.html b/LayoutTests/scrollingcoordinator/mac/rtl-programmatic-overflow-scroll.html
new file mode 100644 (file)
index 0000000..653901f
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <style>
+        body {
+            margin: 0;
+        }
+        
+        #scroller {
+                   direction: rtl;
+            overflow-x: scroll;
+            margin: 10px;
+            height: 300px;
+            width: 300px;
+        }
+        
+        .contents {
+                   width: 200%;
+                   height: 100%;
+                       background-image: linear-gradient(to right, green, green 50%, red 50%, red);
+        }
+
+        .scrollbar-hider {
+            position: absolute;
+            width: 300px;
+            height: 16px;
+            left: 10px;
+            top: calc(310px - 16px);
+            background-color: gray;
+        }
+    </style>
+    <script>
+        window.addEventListener('load', () => {
+            scroller.scrollLeft = -300;
+        }, false);
+    </script>
+</head>
+<body>
+    <div id="scroller">
+        <div class="contents"></div>
+    </div>
+    <div class="scrollbar-hider"></div>
+</body>
+</html>
index 6234cd5..6515e70 100644 (file)
@@ -1,3 +1,18 @@
+2019-05-25  Simon Fraser  <simon.fraser@apple.com>
+
+        [macOS] Fix programmatic scroll in RTL overflow with async scrolling enabled
+        https://bugs.webkit.org/show_bug.cgi?id=198226
+
+        Reviewed by Antti Koivisto.
+
+        On macOS we need to use a scroll offset to set the layer position, not
+        a scroll position.
+
+        Test: scrollingcoordinator/mac/rtl-programmatic-overflow-scroll.html
+
+        * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeOverflowScrollingNodeMac::repositionScrollingLayers):
+
 2019-05-24  Joonghun Park  <jh718.park@samsung.com>
 
         Make computed width of non-replaced inline return computed style.
index 208a45b..d15fa94 100644 (file)
@@ -90,8 +90,8 @@ FloatPoint ScrollingTreeOverflowScrollingNodeMac::adjustedScrollPosition(const F
 
 void ScrollingTreeOverflowScrollingNodeMac::repositionScrollingLayers()
 {
-    auto scrollPosition = currentScrollPosition();
-    scrolledContentsLayer().position = -scrollPosition;
+    auto scrollOffset = ScrollableArea::scrollOffsetFromPosition(currentScrollPosition(), toFloatSize(scrollOrigin()));
+    scrolledContentsLayer().position = -scrollOffset;
 }
 
 void ScrollingTreeOverflowScrollingNodeMac::repositionRelatedLayers()