Title: [242773] trunk
Revision
242773
Author
[email protected]
Date
2019-03-11 21:59:35 -0700 (Mon, 11 Mar 2019)

Log Message

Add testing API to hit-test and scroll overflow scrollers
https://bugs.webkit.org/show_bug.cgi?id=195278

Reviewed by Antti Koivisto.

Tools:

Add UIScriptController::immediateScrollElementAtContentPointToOffset() to enable
testing of the view hit-testing code path, and immediate scrolling of overflow:scroll.

Tests: scrollingcoordinator/ios/scroll-element-at-point.html

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::immediateScrollElementAtContentPointToOffset):
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::immediateScrollElementAtContentPointToOffset):
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::enclosingScrollViewIncludingSelf):
(WTR::UIScriptController::immediateScrollElementAtContentPointToOffset):

LayoutTests:

The test loads a scaled page with accelerated overflow:scroll, and hit-tests
near the top-left and bottom-right corners to test the point conversion logic.

* scrollingcoordinator/ios/scroll-element-at-point-expected.txt: Added.
* scrollingcoordinator/ios/scroll-element-at-point.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (242772 => 242773)


--- trunk/LayoutTests/ChangeLog	2019-03-12 04:56:41 UTC (rev 242772)
+++ trunk/LayoutTests/ChangeLog	2019-03-12 04:59:35 UTC (rev 242773)
@@ -1,3 +1,16 @@
+2019-03-11  Simon Fraser  <[email protected]>
+
+        Add testing API to hit-test and scroll overflow scrollers
+        https://bugs.webkit.org/show_bug.cgi?id=195278
+
+        Reviewed by Antti Koivisto.
+        
+        The test loads a scaled page with accelerated overflow:scroll, and hit-tests
+        near the top-left and bottom-right corners to test the point conversion logic.
+
+        * scrollingcoordinator/ios/scroll-element-at-point-expected.txt: Added.
+        * scrollingcoordinator/ios/scroll-element-at-point.html: Added.
+
 2019-03-11  Zalan Bujtas  <[email protected]>
 
         [Synthetic Click] Dispatch mouseout soon after mouseup

Added: trunk/LayoutTests/scrollingcoordinator/ios/scroll-element-at-point-expected.txt (0 => 242773)


--- trunk/LayoutTests/scrollingcoordinator/ios/scroll-element-at-point-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/ios/scroll-element-at-point-expected.txt	2019-03-12 04:59:35 UTC (rev 242773)
@@ -0,0 +1,8 @@
+PASS scrollTopAfterOutsideTopLeft is 0
+PASS scrollTopAfterInsideTopLeft is 200
+PASS scrollTopAfterOutsideBottomRight is 200
+PASS scrollTopAfterInsideBottomRight is 400
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/scrollingcoordinator/ios/scroll-element-at-point.html (0 => 242773)


--- trunk/LayoutTests/scrollingcoordinator/ios/scroll-element-at-point.html	                        (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/ios/scroll-element-at-point.html	2019-03-12 04:59:35 UTC (rev 242773)
@@ -0,0 +1,82 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <!--Trigger some scaling -->
+    <meta name="viewport" content="width=500"> 
+    
+    <style>
+        body {
+            height: 2000px;
+            margin: 0;
+        }
+        
+        #scroller {
+            margin: 10px;
+            width: 300px;
+            height: 300px;
+            border: 1px solid black;
+            box-sizing: border-box;
+            overflow: scroll;
+            -webkit-overflow-scrolling: touch;
+        }
+        .content {
+            height: 1000px;
+        }
+    </style>
+    <script src=""
+    <script src=""
+    <script>
+        jsTestIsAsync = true;
+
+        async function tryScrollAt(x, y, xScrollOffset, yScrollOffset)
+        {
+            await new Promise(resolve => {
+                testRunner.runUIScript(`
+                    uiController.immediateScrollElementAtContentPointToOffset(${x}, ${y}, ${xScrollOffset}, ${yScrollOffset}, true);`, resolve);
+            });
+        }
+
+        let scrollTopAfterOutsideTopLeft;
+        let scrollTopAfterInsideTopLeft;
+        let scrollTopAfterOutsideBottomRight;
+        let scrollTopAfterInsideBottomRight;
+
+        async function doTest()
+        {
+            if (!testRunner.runUIScript)
+                return
+
+            // Test near the corners to exercise the point conversion logic.
+            // Don't call shouldBe() until the end because it inserts content, offsetting the scroller.
+            await tryScrollAt(9, 9, 0, 100);
+            scrollTopAfterOutsideTopLeft = scroller.scrollTop;
+
+            await tryScrollAt(12, 12, 0, 200);
+            scrollTopAfterInsideTopLeft = scroller.scrollTop;
+
+            await tryScrollAt(311, 311, 0, 300);
+            scrollTopAfterOutsideBottomRight = scroller.scrollTop;
+
+            await tryScrollAt(308, 308, 0, 400);
+            scrollTopAfterInsideBottomRight = scroller.scrollTop;
+
+            shouldBe('scrollTopAfterOutsideTopLeft', '0');
+            shouldBe('scrollTopAfterInsideTopLeft', '200');
+            shouldBe('scrollTopAfterOutsideBottomRight', '200');
+            shouldBe('scrollTopAfterInsideBottomRight', '400');
+
+            finishJSTest(); 
+        }
+        
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+    <div id="scroller">
+        <div class="content">
+        </div>
+    </div>
+    <script src=""
+</body>
+</html>

Modified: trunk/Tools/ChangeLog (242772 => 242773)


--- trunk/Tools/ChangeLog	2019-03-12 04:56:41 UTC (rev 242772)
+++ trunk/Tools/ChangeLog	2019-03-12 04:59:35 UTC (rev 242773)
@@ -1,3 +1,25 @@
+2019-03-11  Simon Fraser  <[email protected]>
+
+        Add testing API to hit-test and scroll overflow scrollers
+        https://bugs.webkit.org/show_bug.cgi?id=195278
+
+        Reviewed by Antti Koivisto.
+        
+        Add UIScriptController::immediateScrollElementAtContentPointToOffset() to enable
+        testing of the view hit-testing code path, and immediate scrolling of overflow:scroll.
+        
+        Tests: scrollingcoordinator/ios/scroll-element-at-point.html
+
+        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::immediateScrollElementAtContentPointToOffset):
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
+        (WTR::UIScriptController::immediateScrollElementAtContentPointToOffset):
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::enclosingScrollViewIncludingSelf):
+        (WTR::UIScriptController::immediateScrollElementAtContentPointToOffset):
+
 2019-03-11  Tim Horton  <[email protected]>
 
         API test WebKit.RequestTextInputContext fails on iOS

Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm (242772 => 242773)


--- trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm	2019-03-12 04:56:41 UTC (rev 242772)
+++ trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm	2019-03-12 04:59:35 UTC (rev 242773)
@@ -248,6 +248,10 @@
     [gWebScrollView setContentOffset:contentOffsetBoundedInValidRange(gWebScrollView, CGPointMake(x, y)) animated:NO];
 }
 
+void UIScriptController::immediateScrollElementAtContentPointToOffset(long x, long y, long xScrollOffset, long yScrollOffset)
+{
+}
+
 void UIScriptController::immediateZoomToScale(double scale)
 {
     [gWebScrollView setZoomScale:scale animated:NO];

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (242772 => 242773)


--- trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2019-03-12 04:56:41 UTC (rev 242772)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2019-03-12 04:59:35 UTC (rev 242773)
@@ -52,7 +52,7 @@
 
     // Interaction.
     // These functions post events asynchronously. The callback is fired when the events have been dispatched, but any
-    // resulting behavior may also be asynchronous.
+    // resulting behavior may also be asynchronous. Points are in "global" (WKWebView) coordinates.
     void touchDownAtPoint(long x, long y, long touchCount, object callback);
     void liftUpAtPoint(long x, long y, long touchCount, object callback);
     void singleTapAtPoint(long x, long y, object callback);
@@ -250,6 +250,9 @@
     void immediateScrollToOffset(long x, long y); // Set the scroll position in the UI process without animation.
     void immediateZoomToScale(double scale); // Set the zoom scale in the UI process without animation.
 
+    // Find the scroller for the given point in content ("absolute") coordinates, and do an immediate scroll.
+    void immediateScrollElementAtContentPointToOffset(long x, long y, long xOffset, long yOffset);
+
     // View state
     readonly attribute double zoomScale;
     readonly attribute double minimumZoomScale;

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp (242772 => 242773)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp	2019-03-12 04:56:41 UTC (rev 242772)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp	2019-03-12 04:59:35 UTC (rev 242773)
@@ -393,6 +393,10 @@
 {
 }
 
+void UIScriptController::immediateScrollElementAtContentPointToOffset(long x, long y, long xScrollOffset, long yScrollOffset)
+{
+}
+
 void UIScriptController::immediateZoomToScale(double scale)
 {
 }

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (242772 => 242773)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2019-03-12 04:56:41 UTC (rev 242772)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2019-03-12 04:59:35 UTC (rev 242773)
@@ -128,6 +128,7 @@
     void scrollToOffset(long x, long y);
 
     void immediateScrollToOffset(long x, long y);
+    void immediateScrollElementAtContentPointToOffset(long x, long y, long xScrollOffset, long yScrollOffset);
     void immediateZoomToScale(double scale);
 
     void beginBackSwipe(JSValueRef callback);

Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (242772 => 242773)


--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2019-03-12 04:56:41 UTC (rev 242772)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2019-03-12 04:59:35 UTC (rev 242773)
@@ -558,6 +558,24 @@
     [webView.scrollView setContentOffset:contentOffsetBoundedInValidRange(webView.scrollView, CGPointMake(x, y)) animated:NO];
 }
 
+static UIScrollView *enclosingScrollViewIncludingSelf(UIView *view)
+{
+    do {
+        if ([view isKindOfClass:[UIScrollView self]])
+            return static_cast<UIScrollView *>(view);
+    } while ((view = [view superview]));
+
+    return nil;
+}
+
+void UIScriptController::immediateScrollElementAtContentPointToOffset(long x, long y, long xScrollOffset, long yScrollOffset)
+{
+    UIView *contentView = platformContentView();
+    UIView *hitView = [contentView hitTest:CGPointMake(x, y) withEvent:nil];
+    UIScrollView *enclosingScrollView = enclosingScrollViewIncludingSelf(hitView);
+    [enclosingScrollView setContentOffset:CGPointMake(xScrollOffset, yScrollOffset)];
+}
+
 void UIScriptController::immediateZoomToScale(double scale)
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to