Use EventPathWalker rather than parentNode() to normalize event targets in EventHandler.
authormkwst@chromium.org <mkwst@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2013 09:43:11 +0000 (09:43 +0000)
committermkwst@chromium.org <mkwst@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2013 09:43:11 +0000 (09:43 +0000)
commit7f2def70f1fd2b065e050675fcddc9ef1461ed79
treec1c9795719b9b0ea93690feb9d3795862e1359ee
parente5ebebfc782730d9146675f48c4190023182c54d
Use EventPathWalker rather than parentNode() to normalize event targets in EventHandler.
https://bugs.webkit.org/show_bug.cgi?id=110037

Reviewed by Ryosuke Niwa.

Source/WebCore:

We need to teach EventHandler about Shadow DOM in a few places in order
to ensure that we properly target events dispatched upon text nodes.
Rather than naively grabbing the text node's direct parent via
parentNode(), we need to account for the case in which the text node is
distributed[1] to an insertion point inside a shadow host.
EventPathWalker::parent understands these relationships, and should
be used when dealing with mouse, drag, and touch events.

[1]: http://www.w3.org/TR/shadow-dom/#dfn-distribution

* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseDraggedEvent):
(WebCore::EventHandler::handleTouchEvent):
(WebCore::EventHandler::passGestureEventToWidgetIfPossible):
(WebCore::EventHandler::updateDragAndDrop):
    Refactor parentNode callsites to use EventPathWalker::parent().

LayoutTests:

* fast/dom/shadow/resources/event-dispatching.js:
(scrollMouseWheel):
(addEventListeners):
    Add MouseWheel, Drag, and Touch support to the event-dispatching
    tests in Shadow DOM.
* fast/dom/shadow/shadow-dom-event-dispatching-distributed-text-node.html:
* fast/dom/shadow/shadow-dom-event-dispatching-text-node-in-shadow-root.html:
    Scroll the mouse wheel, drag a bit, and touch before leaving the
    text node, and record the generated events.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143439 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/dom/shadow/resources/event-dispatching.js
LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching-distributed-text-node-expected.txt
LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching-distributed-text-node.html
LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching-text-node-in-shadow-root-expected.txt
LayoutTests/fast/dom/shadow/shadow-dom-event-dispatching-text-node-in-shadow-root.html
Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp