Title: [237978] trunk
Revision
237978
Author
za...@apple.com
Date
2018-11-07 19:33:30 -0800 (Wed, 07 Nov 2018)

Log Message

Click and touch event listeners on the body don't work
https://bugs.webkit.org/show_bug.cgi?id=191392
<rdar://problem/5844416>

Reviewed by Simon Fraser.

Source/WebCore:

Remove the old quirk of ignoring onclick handlers on the body and beyond.

Test: fast/events/click-handler-on-body-simple.html

* page/ios/FrameIOS.mm:
(WebCore::Frame::nodeRespondingToClickEvents):

LayoutTests:

* fast/events/click-handler-on-body-simple-expected.txt: Added.
* fast/events/click-handler-on-body-simple.html: Added.
* fast/events/touch/touch-handler-on-body-simple-expected.txt: Added.
* fast/events/touch/touch-handler-on-body-simple.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (237977 => 237978)


--- trunk/LayoutTests/ChangeLog	2018-11-08 03:30:36 UTC (rev 237977)
+++ trunk/LayoutTests/ChangeLog	2018-11-08 03:33:30 UTC (rev 237978)
@@ -1,3 +1,16 @@
+2018-11-07  Zalan Bujtas  <za...@apple.com>
+
+        Click and touch event listeners on the body don't work
+        https://bugs.webkit.org/show_bug.cgi?id=191392
+        <rdar://problem/5844416>
+
+        Reviewed by Simon Fraser.
+
+        * fast/events/click-handler-on-body-simple-expected.txt: Added.
+        * fast/events/click-handler-on-body-simple.html: Added.
+        * fast/events/touch/touch-handler-on-body-simple-expected.txt: Added.
+        * fast/events/touch/touch-handler-on-body-simple.html: Added.
+
 2018-11-07  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Add an editing command for creating and inserting child lists

Added: trunk/LayoutTests/fast/events/click-handler-on-body-simple-expected.txt (0 => 237978)


--- trunk/LayoutTests/fast/events/click-handler-on-body-simple-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/click-handler-on-body-simple-expected.txt	2018-11-08 03:33:30 UTC (rev 237978)
@@ -0,0 +1 @@
+clicked

Added: trunk/LayoutTests/fast/events/click-handler-on-body-simple.html (0 => 237978)


--- trunk/LayoutTests/fast/events/click-handler-on-body-simple.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/click-handler-on-body-simple.html	2018-11-08 03:33:30 UTC (rev 237978)
@@ -0,0 +1,37 @@
+<html>
+<head>
+<script src=""
+<style>
+div {
+    width: 400px;
+    height: 400px;
+}
+</style>
+<script>
+async function test() {
+    if (!window.testRunner || !testRunner.runUIScript)
+        return;
+
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+
+    document.body.addEventListener("click", function( event ) {
+        result.innerHTML = "clicked";
+    }, false);
+
+    let element = document.getElementById("clickme");
+    let rect = element.getBoundingClientRect();
+    let x = rect.left + rect.width / 2;
+    let y = rect.top + rect.height / 2;
+
+    await UIHelper.activateAt(x, y);
+
+    testRunner.notifyDone();
+}
+</script>
+</head>
+<body _onload_="test()">
+<div id=clickme></div>
+<pre id=result></pre>
+</body>
+</html>

Added: trunk/LayoutTests/fast/events/touch/ios/touch-handler-on-body-simple-expected.txt (0 => 237978)


--- trunk/LayoutTests/fast/events/touch/ios/touch-handler-on-body-simple-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/touch-handler-on-body-simple-expected.txt	2018-11-08 03:33:30 UTC (rev 237978)
@@ -0,0 +1 @@
+tapped

Added: trunk/LayoutTests/fast/events/touch/ios/touch-handler-on-body-simple.html (0 => 237978)


--- trunk/LayoutTests/fast/events/touch/ios/touch-handler-on-body-simple.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/touch-handler-on-body-simple.html	2018-11-08 03:33:30 UTC (rev 237978)
@@ -0,0 +1,37 @@
+<html>
+<head>
+<script src=""
+<style>
+div {
+    width: 400px;
+    height: 400px;
+}
+</style>
+<script>
+async function test() {
+    if (!window.testRunner || !testRunner.runUIScript)
+        return;
+
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+
+    document.body.addEventListener("touchstart", function( event ) {
+        result.innerHTML = "tapped";
+    }, false);
+
+    let element = document.getElementById("tapthis");
+    let rect = element.getBoundingClientRect();
+    let x = rect.left + rect.width / 2;
+    let y = rect.top + rect.height / 2;
+
+	await tapAtPoint(x, y);
+
+    testRunner.notifyDone();
+}
+</script>
+</head>
+<body _onload_="test()">
+<div id=tapthis></div>
+<pre id=result></pre>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (237977 => 237978)


--- trunk/Source/WebCore/ChangeLog	2018-11-08 03:30:36 UTC (rev 237977)
+++ trunk/Source/WebCore/ChangeLog	2018-11-08 03:33:30 UTC (rev 237978)
@@ -1,3 +1,18 @@
+2018-11-07  Zalan Bujtas  <za...@apple.com>
+
+        Click and touch event listeners on the body don't work
+        https://bugs.webkit.org/show_bug.cgi?id=191392
+        <rdar://problem/5844416>
+
+        Reviewed by Simon Fraser.
+
+        Remove the old quirk of ignoring onclick handlers on the body and beyond.
+
+        Test: fast/events/click-handler-on-body-simple.html
+
+        * page/ios/FrameIOS.mm:
+        (WebCore::Frame::nodeRespondingToClickEvents):
+
 2018-11-07  Brent Fulgham  <bfulg...@apple.com>
 
         [Windows][DirectX] Update canvas code to pass more tests

Modified: trunk/Source/WebCore/page/ios/FrameIOS.mm (237977 => 237978)


--- trunk/Source/WebCore/page/ios/FrameIOS.mm	2018-11-08 03:30:36 UTC (rev 237977)
+++ trunk/Source/WebCore/page/ios/FrameIOS.mm	2018-11-08 03:33:30 UTC (rev 237978)
@@ -390,9 +390,6 @@
 Node* Frame::nodeRespondingToClickEvents(const FloatPoint& viewportLocation, FloatPoint& adjustedViewportLocation, SecurityOrigin* securityOrigin)
 {
     auto&& ancestorRespondingToClickEvents = [securityOrigin](const HitTestResult& hitTestResult, Node* terminationNode, IntRect* nodeBounds) -> Node* {
-        bool bodyHasBeenReached = false;
-        bool pointerCursorStillValid = true;
-
         if (nodeBounds)
             *nodeBounds = IntRect();
 
@@ -400,35 +397,8 @@
         if (!node || (securityOrigin && !securityOrigin->isSameOriginAs(node->document().securityOrigin())))
             return nullptr;
 
-        Node* pointerCursorNode = nullptr;
         for (; node && node != terminationNode; node = node->parentInComposedTree()) {
-            // We only accept pointer nodes before reaching the body tag.
-            if (node->hasTagName(HTMLNames::bodyTag)) {
-#if USE(UIKIT_EDITING)
-                // Make sure we cover the case of an empty editable body.
-                if (!pointerCursorNode && node->isContentEditable())
-                    pointerCursorNode = node;
-#endif
-                bodyHasBeenReached = true;
-                pointerCursorStillValid = false;
-            }
-
-            // If we already have a pointer, and we reach a table, don't accept it.
-            if (pointerCursorNode && (node->hasTagName(HTMLNames::tableTag) || node->hasTagName(HTMLNames::tbodyTag)))
-                pointerCursorStillValid = false;
-
-            // If we haven't reached the body, and we are still paying attention to pointer cursors, and the node has a pointer cursor...
-            if (pointerCursorStillValid && node->renderStyle() && node->renderStyle()->cursor() == CursorType::Pointer)
-                pointerCursorNode = node;
-            // We want the lowest unbroken chain of pointer cursors.
-            else if (pointerCursorNode)
-                pointerCursorStillValid = false;
-
             if (node->willRespondToMouseClickEvents() || node->willRespondToMouseMoveEvents() || (is<Element>(*node) && downcast<Element>(*node).isMouseFocusable())) {
-                // If we're at the body or higher, use the pointer cursor node (which may be null).
-                if (bodyHasBeenReached)
-                    node = pointerCursorNode;
-
                 // If we are interested about the frame, use it.
                 if (nodeBounds) {
                     // This is a check to see whether this node is an area element. The only way this can happen is if this is the first check.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to