[Shadow] Implements event re-targeting for Touch Events.
authorhayato@chromium.org <hayato@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Mar 2013 05:16:16 +0000 (05:16 +0000)
committerhayato@chromium.org <hayato@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Mar 2013 05:16:16 +0000 (05:16 +0000)
commita26d07c6e4fd1c6357c642553ca55c322c2d9b2e
treee9cab4a3c52b6e4acd424551ea23c7464e965fbc
parent21ad61d4ccf181008dc7125da889ac81804a1078
[Shadow] Implements event re-targeting for Touch Events.
https://bugs.webkit.org/show_bug.cgi?id=107800

Reviewed by Dimitri Glazkov.

Source/WebCore:

So far, Touch Events have been intentionally disabled in shadow
tree since it allows users to access internal nodes in shadow tree
by accessing Touch Event's information.

This patch re-targets all individual touch point's target in
TouchList (touches, targetTouches and changedTouches) owned by a Touch Event
before the Touch Event is dispatched so that we won't break an
upper boundary of shadow DOM.

Touch Events re-targeting is similar to that of Mouse Events
re-targeting. The difference is that a Touch Event can have more
than one related target because of multiple touches. We must
re-target all individual touch points which can be referred from
the Touch Event.

Now, Touch Events can be fired in shadow tree. I've removed the
existing limitation.

Test: fast/dom/shadow/touch-event-retargeting.html

* dom/EventContext.cpp:
(WebCore::EventContext::isTouchEventContext):
(WebCore):
(WebCore::TouchEventContext::TouchEventContext):
(WebCore::TouchEventContext::~TouchEventContext):
(WebCore::TouchEventContext::handleLocalEvents):
(WebCore::TouchEventContext::isTouchEventContext):
(WebCore::TouchEventContext::checkReachability):  Used for assertion of reachability for each Touch point.
* dom/EventContext.h:
(WebCore):
(EventContext):
(TouchEventContext): Introduced to hold necessary information for re-targeting Touch event.
(WebCore::TouchEventContext::touches):
(WebCore::TouchEventContext::targetTouches):
(WebCore::TouchEventContext::changedTouches):
(WebCore::EventContext::isReachable):
* dom/EventRetargeter.cpp:
(WebCore::EventRetargeter::calculateEventPath):
(WebCore::EventRetargeter::adjustForTouchEvent):
(WebCore):
(WebCore::EventRetargeter::adjustTouchList):
(WebCore::EventRetargeter::adjustForRelatedTarget):
(WebCore::EventRetargeter::calculateAdjustedNodes): Updated so that this can be used for Touch point re-targeting.
(WebCore::EventRetargeter::buildRelatedNodeMap):
* dom/EventRetargeter.h:
(WebCore):
(EventRetargeter):
* dom/Node.cpp:
(WebCore::Node::dispatchEvent):
(WebCore):
(WebCore::Node::dispatchTouchEvent):
* dom/Node.h:
(WebCore):
(Node):
* dom/Touch.cpp:
(WebCore::Touch::Touch):
(WebCore):
(WebCore::Touch::cloneWithNewTarget):
* dom/Touch.h:
(Touch):
* dom/TouchEvent.cpp:
(WebCore::TouchEventDispatchMediator::create):
(WebCore):
(WebCore::TouchEventDispatchMediator::TouchEventDispatchMediator):
(WebCore::TouchEventDispatchMediator::event):
(WebCore::TouchEventDispatchMediator::dispatchEvent):
* dom/TouchEvent.h:
(TouchEvent):
(WebCore::TouchEvent::setTouches):
(WebCore::TouchEvent::setTargetTouches):
(WebCore::TouchEvent::setChangedTouches):
(TouchEventDispatchMediator):
(WebCore):
(WebCore::toTouchEvent):
* dom/TouchList.cpp:
(WebCore::TouchList::item):
(WebCore):
* dom/TouchList.h:
(TouchList):
* page/EventHandler.cpp:
(WebCore::EventHandler::hitTestResultInFrame): Removed the limitation. Adjusting is no longer done here.
(WebCore::EventHandler::handleTouchEvent):

LayoutTests:

* fast/dom/shadow/resources/event-dispatching.js:
(recordEvent):
(dumpTouchList):
(sortDispatchedEvent):
(showSandboxTree):
* fast/dom/shadow/shadow-dom-event-dispatching-distributed-text-node-expected.txt:
* fast/dom/shadow/shadow-dom-event-dispatching-distributed-text-node.html:
* fast/dom/shadow/shadow-dom-event-dispatching-text-node-in-shadow-root-expected.txt:
* fast/dom/shadow/touch-event-retargeting-expected.txt: Added.
* fast/dom/shadow/touch-event-retargeting.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144877 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
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/touch-event-retargeting-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/shadow/touch-event-retargeting.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/EventContext.cpp
Source/WebCore/dom/EventContext.h
Source/WebCore/dom/EventRetargeter.cpp
Source/WebCore/dom/EventRetargeter.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/dom/Touch.cpp
Source/WebCore/dom/Touch.h
Source/WebCore/dom/TouchEvent.cpp
Source/WebCore/dom/TouchEvent.h
Source/WebCore/dom/TouchList.cpp
Source/WebCore/dom/TouchList.h
Source/WebCore/page/EventHandler.cpp