Make event dispatching respect slotting
https://bugs.webkit.org/show_bug.cgi?id=149243
Reviewed by Antti Koivisto.
Source/WebCore:
There are primarily two cases to consider: getting out of a shadow root to its host,
and moving into a slot from an assigned node.
When getting out of a shadow root, either the event originated in its shadow tree
including its nodes' shadow trees (1) or it moved into this shadow tree via a slot (2).
In (1), event.target should be set to the shadow host. In (2), it should be set to the
first node in the event path that belongs to the same tree as the shadow host. In order
to find such a node in O(1), we use a stack of event targets in each (shadow) tree. We
push event.target of the current tree whenever we move up to a slot from an assigned node
and pop it out of the stack when we move out of the shadow tree.
A follow up patch is needed to update the code to resolve related targets.
Tests: fast/shadow-dom/event-inside-shadow-tree.html
fast/shadow-dom/event-inside-slotted-node.html
* dom/EventDispatcher.cpp:
(WebCore::EventPath::EventPath):
LayoutTests:
Added tests for dispatching events inside shadow trees and nodes assigned to slots using testharness.js.
* fast/shadow-dom/event-inside-shadow-tree-expected.txt: Added.
* fast/shadow-dom/event-inside-shadow-tree.html: Added.
* fast/shadow-dom/event-inside-slotted-node-expected.txt: Added.
* fast/shadow-dom/event-inside-slotted-node.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190214
268f45cc-cd09-0410-ab3c-
d52691b4dbfc