Title: [193997] trunk
Revision
193997
Author
bda...@apple.com
Date
2015-12-11 17:21:52 -0800 (Fri, 11 Dec 2015)

Log Message

_touchEventRegions should return regions in the view's coordinates
https://bugs.webkit.org/show_bug.cgi?id=152189
-and corresponding-
rdar://problem/23188605

Reviewed by Dan Bernstein.

Source/WebKit/mac:

The comment here was actually out of date. It claimed that touch rectangles 
are in the coordinate system of the document, but we had actually changed 
them to be in the view’s coordinate system in order to fix issues with 
handling touch events in UIWebView. But now we are going back to having the 
touch rectangles be in the document’s coordinate system, so we should fix the 
rtl bugs here by converting to view coordinates before handing the rects off 
to iOS WK1 clients.
* WebView/WebView.mm:
(-[WebView _touchEventRegions]):

LayoutTests:

* fast/events/touch/ios/touch-event-rtl-expected.txt: Added.
* fast/events/touch/ios/touch-event-rtl.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (193996 => 193997)


--- trunk/LayoutTests/ChangeLog	2015-12-12 00:46:23 UTC (rev 193996)
+++ trunk/LayoutTests/ChangeLog	2015-12-12 01:21:52 UTC (rev 193997)
@@ -1,3 +1,15 @@
+2015-12-11  Beth Dakin  <bda...@apple.com>
+
+        _touchEventRegions should return regions in the view's coordinates
+        https://bugs.webkit.org/show_bug.cgi?id=152189
+        -and corresponding-
+        rdar://problem/23188605
+
+        Reviewed by Dan Bernstein.
+
+        * fast/events/touch/ios/touch-event-rtl-expected.txt: Added.
+        * fast/events/touch/ios/touch-event-rtl.html: Added.
+
 2015-12-11  Alexey Proskuryakov  <a...@apple.com>
 
         Roll out http://trac.webkit.org/r193984, because the new test is timing out.

Added: trunk/LayoutTests/fast/events/touch/ios/touch-event-rtl-expected.txt (0 => 193997)


--- trunk/LayoutTests/fast/events/touch/ios/touch-event-rtl-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/touch-event-rtl-expected.txt	2015-12-12 01:21:52 UTC (rev 193997)
@@ -0,0 +1,3 @@
+Tap me
+Received event touchstart at 58, 50
+Done

Added: trunk/LayoutTests/fast/events/touch/ios/touch-event-rtl.html (0 => 193997)


--- trunk/LayoutTests/fast/events/touch/ios/touch-event-rtl.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/touch-event-rtl.html	2015-12-12 01:21:52 UTC (rev 193997)
@@ -0,0 +1,60 @@
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" dir="rtl">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
+<style>
+body {
+    width: 900px;
+}
+.button {
+    padding: 40px;
+    background: #ccc;
+}
+.button.tapped {
+    background: green;
+}
+</style>
+
+<script>
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function getUIScript()
+{
+    return `
+    (function() {
+        uiController.singleTapAtPoint(-50, 50, function() {
+            uiController.uiScriptComplete("Done");
+                });
+    })();`
+}
+
+function setUp()
+{
+    var output = '';
+    var target = document.getElementById('target');
+    target.addEventListener('touchstart', function(event) {
+        output += 'Received event ' + event.type + ' at ' + event.touches[0].clientX + ', ' + event.touches[0].clientY + '<br>';
+        target.classList.toggle('tapped');
+    });
+
+    if (testRunner.runUIScript) {
+        testRunner.runUIScript(getUIScript(), function(result) {
+            output += result;
+            document.getElementById('console').innerHTML = output;
+            testRunner.notifyDone();
+        });
+    }
+}
+
+window.addEventListener('load', setUp, false);
+</script>
+</head>
+<body>
+    <div class="button" id="target">Tap me</div>
+    <pre id="console">To test manually, tap the box. If it turns green, then the test passes.</pre>
+</body>
+</html>

Modified: trunk/Source/WebKit/mac/ChangeLog (193996 => 193997)


--- trunk/Source/WebKit/mac/ChangeLog	2015-12-12 00:46:23 UTC (rev 193996)
+++ trunk/Source/WebKit/mac/ChangeLog	2015-12-12 01:21:52 UTC (rev 193997)
@@ -1,3 +1,22 @@
+2015-12-11  Beth Dakin  <bda...@apple.com>
+
+        _touchEventRegions should return regions in the view's coordinates
+        https://bugs.webkit.org/show_bug.cgi?id=152189
+        -and corresponding-
+        rdar://problem/23188605
+
+        Reviewed by Dan Bernstein.
+
+        The comment here was actually out of date. It claimed that touch rectangles 
+        are in the coordinate system of the document, but we had actually changed 
+        them to be in the view’s coordinate system in order to fix issues with 
+        handling touch events in UIWebView. But now we are going back to having the 
+        touch rectangles be in the document’s coordinate system, so we should fix the 
+        rtl bugs here by converting to view coordinates before handing the rects off 
+        to iOS WK1 clients.
+        * WebView/WebView.mm:
+        (-[WebView _touchEventRegions]):
+
 2015-12-10  Eric Carlson  <eric.carl...@apple.com>
 
         [MediaStream] Expose media capture devices persistent permissions to WebCore

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (193996 => 193997)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2015-12-12 00:46:23 UTC (rev 193996)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2015-12-12 01:21:52 UTC (rev 193997)
@@ -3733,26 +3733,27 @@
 
     NSMutableArray *eventRegionArray = [[[NSMutableArray alloc] initWithCapacity:rects.size()] autorelease];
 
+    NSView <WebDocumentView> *documentView = [[[self mainFrame] frameView] documentView];
     Vector<IntRect>::const_iterator end = rects.end();
     for (Vector<IntRect>::const_iterator it = rects.begin(); it != end; ++it) {
         const IntRect& rect = *it;
         if (rect.isEmpty())
             continue;
 
-        // Note that these rectangles are in the coordinate system of the document (inside the WebHTMLView), which is not
-        // the same as the coordinate system of the WebView. If you want to do comparisons with locations in the WebView,
-        // you must convert between the two using WAKView's convertRect:toView: selector. This will take care of scaling
-        // and translations (which are relevant for right-to-left column layout).
+        // The touch rectangles are in the coordinate system of the document (inside the WebHTMLView), which is not
+        // the same as the coordinate system of the WebView. UIWebView currently expects view coordinates, so we'll
+        // convert them here now.
+        IntRect viewRect = IntRect([documentView convertRect:rect toView:self]);
 
         // The event region wants this points in this order:
         //  p2------p3
         //  |       |
         //  p1------p4
         //
-        WebEventRegion *eventRegion = [[WebEventRegion alloc] initWithPoints:FloatPoint(rect.x(), rect.maxY())
-                                                                            :FloatPoint(rect.x(), rect.y())
-                                                                            :FloatPoint(rect.maxX(), rect.y())
-                                                                            :FloatPoint(rect.maxX(), rect.maxY())];
+        WebEventRegion *eventRegion = [[WebEventRegion alloc] initWithPoints:FloatPoint(viewRect.x(), viewRect.maxY())
+                                                                            :FloatPoint(viewRect.x(), viewRect.y())
+                                                                            :FloatPoint(viewRect.maxX(), viewRect.y())
+                                                                            :FloatPoint(viewRect.maxX(), viewRect.maxY())];
         if (eventRegion) {
             [eventRegionArray addObject:eventRegion];
             [eventRegion release];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to