mouseenter and mouseleave events don't get dispatched even when there is a capturing...
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Sep 2018 21:54:14 +0000 (21:54 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Sep 2018 21:54:14 +0000 (21:54 +0000)
commit4e5431c42ad8b67f5abd67f3475e4c87d92afa65
treeca8d152821ebdf57962d28d4eed54cf92e30a56e
parent5301b12642a388c5c642a9b069f402019a2c23fc
mouseenter and mouseleave events don't get dispatched even when there is a capturing event listener for a slot ancestor
https://bugs.webkit.org/show_bug.cgi?id=188561

Reviewed by Darin Adler.

Source/WebCore:

This patch makes mouseenter and mouseleave events to work with shadow trees and slots therein, and makes them uncomposed
as discussed in https://github.com/w3c/uievents/issues/208.

This patch also makes these events dispatched on DOM tree ancestors of the currently hovered element instead of
render tree's hover ancestors to be consistent with the check in hierarchyHasCapturingEventListeners and other browsers.
In particular, using hover ancestors is problematic when there is an element with display: contents such as slot elements,
which do not have a render object.

Tests: fast/shadow-dom/mouseenter-mouseleave-across-shadow-boundary.html
       fast/shadow-dom/mouseenter-mouseleave-inside-shadow-tree.html
       fast/shadow-dom/mouseenter-mouseleave-on-slot-parent.html

* dom/MouseEvent.cpp:
(WebCore::MouseEvent::create):
* page/EventHandler.cpp:
(WebCore::nearestCommonHoverAncestor): Deleted.
(WebCore::hierarchyHasCapturingEventListeners): Use parentInComposedTree. Else we would miss capturing event listeners
on inclusive ancestors of slots.
(WebCore::EventHandler::updateMouseEventTargetNode): Use the composed tree's ancestor chain to fire mouseenter and
mouseleave events. This is needed to dispatch mouseenter / mouseleave events on slot elements. Also removed comments
which just state what is self-evident from the code beneath them.

LayoutTests:

Added tests for listening to mouseenter and mouseleave events using capturing and bubbling event listeners
across shadow boundaries.

* fast/shadow-dom/mouseenter-mouseleave-across-shadow-boundary-expected.txt: Added.
* fast/shadow-dom/mouseenter-mouseleave-across-shadow-boundary.html: Added.
* fast/shadow-dom/mouseenter-mouseleave-inside-shadow-tree-expected.txt: Added.
* fast/shadow-dom/mouseenter-mouseleave-inside-shadow-tree.html: Added.
* fast/shadow-dom/mouseenter-mouseleave-on-slot-parent-expected.txt: Added.
* fast/shadow-dom/mouseenter-mouseleave-on-slot-parent.html: Added.
* platform/ios/TestExpectations: Skip the new tests since mouse events aren't supported on iOS.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235865 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/shadow-dom/mouseenter-mouseleave-across-shadow-boundary-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/mouseenter-mouseleave-across-shadow-boundary.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/mouseenter-mouseleave-inside-shadow-tree-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/mouseenter-mouseleave-inside-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/mouseenter-mouseleave-on-slot-parent-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/mouseenter-mouseleave-on-slot-parent.html [new file with mode: 0644]
LayoutTests/platform/ios/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/dom/MouseEvent.cpp
Source/WebCore/page/EventHandler.cpp