Make event dispatching respect slotting
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Sep 2015 19:00:11 +0000 (19:00 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Sep 2015 19:00:11 +0000 (19:00 +0000)
commit5f39bf8a71b9d7eaa0f8ce0bbdd27fea2c84bf2c
tree33ff78494bf276486bdf7d076b61facdfd8fb1e4
parent7e681bb9dded0e404924a626ed5658db1aea90b6
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
LayoutTests/ChangeLog
LayoutTests/fast/shadow-dom/event-inside-shadow-tree-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/event-inside-shadow-tree.html [new file with mode: 0644]
LayoutTests/fast/shadow-dom/event-inside-slotted-node-expected.txt [new file with mode: 0644]
LayoutTests/fast/shadow-dom/event-inside-slotted-node.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/EventDispatcher.cpp