Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.


Canonical link: https://commits.webkit.org/206200@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237978 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbaradlay committed Nov 8, 2018
1 parent 267b557 commit 67a62d9
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 30 deletions.
13 changes: 13 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
2018-11-07 Zalan Bujtas <zalan@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_hsieh@apple.com>

Add an editing command for creating and inserting child lists
Expand Down
@@ -0,0 +1 @@
clicked
37 changes: 37 additions & 0 deletions LayoutTests/fast/events/click-handler-on-body-simple.html
@@ -0,0 +1,37 @@
<html>
<head>
<script src="../../resources/ui-helper.js"></script>
<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>
@@ -0,0 +1 @@
tapped
@@ -0,0 +1,37 @@
<html>
<head>
<script src="../../../../resources/basic-gestures.js"></script>
<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>
15 changes: 15 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,18 @@
2018-11-07 Zalan Bujtas <zalan@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 <bfulgham@apple.com>

[Windows][DirectX] Update canvas code to pass more tests
Expand Down
30 changes: 0 additions & 30 deletions Source/WebCore/page/ios/FrameIOS.mm
Expand Up @@ -390,45 +390,15 @@
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();

auto node = hitTestResult.innerNode();
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.
Expand Down

0 comments on commit 67a62d9

Please sign in to comment.