WebKit Bugzilla
Attachment 369858 Details for
Bug 197881
: [Pointer Events] The pointerenter and pointerleave events target the wrong element on iOS
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197881-20190514181954.patch (text/plain), 7.23 KB, created by
Antoine Quint
on 2019-05-14 09:19:55 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Antoine Quint
Created:
2019-05-14 09:19:55 PDT
Size:
7.23 KB
patch
obsolete
>Subversion Revision: 245272 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index ec1fd0759b74f1f95d3094c89cca1bacff95fbfe..a89716c1b83310c11c8a45b3ee0932d0339d04fb 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2019-05-14 Antoine Quint <graouts@apple.com> >+ >+ [Pointer Events] The pointerenter and pointerleave events target the wrong element on iOS >+ https://bugs.webkit.org/show_bug.cgi?id=197881 >+ <rdar://problem/50187657> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test: pointerevents/ios/enter-leave-target.html >+ >+ The "pointerenter" and "pointerleave" should target the element on which the event listener was added and not >+ the element that would otherwise hit test. This matches the behavior of "mouseenter" and "mouseleave" on macOS. >+ >+ * page/PointerCaptureController.cpp: >+ (WebCore::PointerCaptureController::dispatchEventForTouchAtIndex): >+ > 2019-05-13 Yusuke Suzuki <ysuzuki@apple.com> > > Unreviewed, build fix after 245258, missing ThreadSpecific.h include >diff --git a/Source/WebCore/page/PointerCaptureController.cpp b/Source/WebCore/page/PointerCaptureController.cpp >index a0fd0871a860e0171c1a1c1ce8e0fc98d5b4a675..c9453614b9d520f1aec66ff635d67ebcf21218f6 100644 >--- a/Source/WebCore/page/PointerCaptureController.cpp >+++ b/Source/WebCore/page/PointerCaptureController.cpp >@@ -164,6 +164,26 @@ void PointerCaptureController::dispatchEventForTouchAtIndex(EventTarget& target, > target.dispatchEvent(PointerEvent::create(type, platformTouchEvent, index, isPrimary, view)); > }; > >+ auto dispatchEnterOrLeaveEvent = [&](const String& type) { >+ if (!is<Element>(&target)) >+ return; >+ >+ auto* targetElement = &downcast<Element>(target); >+ >+ bool hasCapturingListenerInHierarchy = false; >+ for (ContainerNode* curr = targetElement; curr; curr = curr->parentInComposedTree()) { >+ if (curr->hasCapturingEventListeners(type)) { >+ hasCapturingListenerInHierarchy = true; >+ break; >+ } >+ } >+ >+ for (Element* element = &downcast<Element>(target); element; element = element->parentElementInComposedTree()) { >+ if (hasCapturingListenerInHierarchy || element->hasEventListeners(type)) >+ element->dispatchEvent(PointerEvent::create(type, platformTouchEvent, index, isPrimary, view)); >+ } >+ }; >+ > auto pointerEvent = PointerEvent::create(platformTouchEvent, index, isPrimary, view); > > if (pointerEvent->type() == eventNames().pointerdownEvent) { >@@ -171,7 +191,7 @@ void PointerCaptureController::dispatchEventForTouchAtIndex(EventTarget& target, > // For input devices that do not support hover, a user agent MUST also fire a pointer event named pointerover followed by a pointer event named > // pointerenter prior to dispatching the pointerdown event. > dispatchEvent(eventNames().pointeroverEvent); >- dispatchEvent(eventNames().pointerenterEvent); >+ dispatchEnterOrLeaveEvent(eventNames().pointerenterEvent); > } > > pointerEventWillBeDispatched(pointerEvent, &target); >@@ -183,7 +203,7 @@ void PointerCaptureController::dispatchEventForTouchAtIndex(EventTarget& target, > // For input devices that do not support hover, a user agent MUST also fire a pointer event named pointerout followed by a > // pointer event named pointerleave after dispatching the pointerup event. > dispatchEvent(eventNames().pointeroutEvent); >- dispatchEvent(eventNames().pointerleaveEvent); >+ dispatchEnterOrLeaveEvent(eventNames().pointerleaveEvent); > } > } > #endif >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 604e40764674a5051ca94cf49514be6f5e3d36b4..f5c00a827d1c440e61e2e16a88d1e252d099bfc7 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,17 @@ >+2019-05-14 Antoine Quint <graouts@apple.com> >+ >+ [Pointer Events] The pointerenter and pointerleave events target the wrong element on iOS >+ https://bugs.webkit.org/show_bug.cgi?id=197881 >+ <rdar://problem/50187657> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a test where we tap an element that is the child of another element where the parent is the element with the "pointerenter" >+ and "pointerleave" events registered. The test shows that we correctly set the target to the parent element and not the child. >+ >+ * pointerevents/ios/enter-leave-target-expected.txt: Added. >+ * pointerevents/ios/enter-leave-target.html: Added. >+ > 2019-05-13 Wenson Hsieh <wenson_hsieh@apple.com> > > [iOS] When running layout tests that tap in the same location, subsequent tests fail to fire click handlers >diff --git a/LayoutTests/pointerevents/ios/enter-leave-target-expected.txt b/LayoutTests/pointerevents/ios/enter-leave-target-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..890c4e8faa5727876f80b6d3b9c8511f58a83d71 >--- /dev/null >+++ b/LayoutTests/pointerevents/ios/enter-leave-target-expected.txt >@@ -0,0 +1,3 @@ >+ >+PASS Testing that "pointerenter" and "pointerleave" have the element on which the event listener was added as their target. >+ >diff --git a/LayoutTests/pointerevents/ios/enter-leave-target.html b/LayoutTests/pointerevents/ios/enter-leave-target.html >new file mode 100644 >index 0000000000000000000000000000000000000000..d39f43f16c2064b173c13017656a8018c3971c65 >--- /dev/null >+++ b/LayoutTests/pointerevents/ios/enter-leave-target.html >@@ -0,0 +1,44 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<meta charset=utf-8> >+<meta name="viewport" content="width=device-width, initial-scale=1"> >+</head> >+<body> >+<script src="../../resources/testharness.js"></script> >+<script src="../../resources/testharnessreport.js"></script> >+<script src="../utils.js"></script> >+<script> >+ >+'use strict'; >+ >+target_test({ width: "200px", height: "200px" }, (target, test) => { >+ // Add a child element covering the same bounds as the target so that it hit tests when tapping. >+ target.appendChild(document.createElement("div")).setAttribute("style", "position: absolute; width: 100%; height: 100%;"); >+ >+ // FIXME: https://bugs.webkit.org/show_bug.cgi?id=197882 >+ // [Pointer Events] Listening to a "pointerover", "pointerenter", "pointerout" or "pointerleave" event alone does not fire the event on iOS >+ target.addEventListener("pointerdown", event => { }); >+ >+ const entered = new Promise(resolve => { >+ target.addEventListener("pointerenter", event => { >+ assert_equals(event.target, target, `The ${event.type} event target matches the element on which the event listener was added.`); >+ resolve(); >+ }); >+ }); >+ >+ const left = new Promise(resolve => { >+ target.addEventListener("pointerleave", event => { >+ assert_equals(event.target, target, `The ${event.type} event target matches the element on which the event listener was added.`); >+ resolve(); >+ }); >+ }); >+ >+ const tapped = ui.tap({ x: 100, y: 100 }); >+ >+ Promise.all([entered, left, tapped]).then(() => test.done()); >+}, `Testing that "pointerenter" and "pointerleave" have the element on which the event listener was added as their target.`); >+ >+</script> >+</body> >+</html> >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197881
: 369858