Commit 2c4ead59 authored by akling@apple.com's avatar akling@apple.com

Remove EventPathWalker.

<https://webkit.org/b/121890>

Reviewed by Antti Koivisto.

Purge some more leftover Shadow DOM code.

* dom/EventPathWalker.cpp:
* dom/EventPathWalker.h:

    Removed.

* dom/EventRetargeter.cpp:
(WebCore::nodeOrHostIfPseudoElement):
(WebCore::EventRetargeter::calculateEventPath):
(WebCore::EventRetargeter::buildRelatedNodeMap):

    If starting at a pseudo element, e.g for events originating from
    a transition on :before/:after, retarget to the pseudo element's
    host as appropriate. This was the only real "feature" we were
    using in EventPathWalker.

* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseDraggedEvent):
(WebCore::EventHandler::updateDragAndDrop):
(WebCore::EventHandler::updateMouseEventTargetNode):
(WebCore::EventHandler::handleWheelEvent):
(WebCore::EventHandler::handleTouchEvent):

    Replace use of EventPathWalker with parentOrShadowHostElement()
    parent chain climbing.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156390 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7d92d674
......@@ -1168,7 +1168,6 @@ set(WebCore_SOURCES
dom/EventException.cpp
dom/EventListenerMap.cpp
dom/EventNames.cpp
dom/EventPathWalker.cpp
dom/EventRetargeter.cpp
dom/EventTarget.cpp
dom/ExceptionBase.cpp
......
2013-09-25 Andreas Kling <akling@apple.com>
Remove EventPathWalker.
<https://webkit.org/b/121890>
Reviewed by Antti Koivisto.
Purge some more leftover Shadow DOM code.
* dom/EventPathWalker.cpp:
* dom/EventPathWalker.h:
Removed.
* dom/EventRetargeter.cpp:
(WebCore::nodeOrHostIfPseudoElement):
(WebCore::EventRetargeter::calculateEventPath):
(WebCore::EventRetargeter::buildRelatedNodeMap):
If starting at a pseudo element, e.g for events originating from
a transition on :before/:after, retarget to the pseudo element's
host as appropriate. This was the only real "feature" we were
using in EventPathWalker.
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseDraggedEvent):
(WebCore::EventHandler::updateDragAndDrop):
(WebCore::EventHandler::updateMouseEventTargetNode):
(WebCore::EventHandler::handleWheelEvent):
(WebCore::EventHandler::handleTouchEvent):
Replace use of EventPathWalker with parentOrShadowHostElement()
parent chain climbing.
2013-09-25 Gurpreet Kaur <k.gurpreet@samsung.com>
:read-write pseudo-class should not be applied on <input type="text" disabled>
......@@ -2927,8 +2927,6 @@ webcore_sources += \
Source/WebCore/dom/EventListenerMap.h \
Source/WebCore/dom/EventNames.cpp \
Source/WebCore/dom/EventNames.h \
Source/WebCore/dom/EventPathWalker.cpp \
Source/WebCore/dom/EventPathWalker.h \
Source/WebCore/dom/EventRetargeter.cpp \
Source/WebCore/dom/EventRetargeter.h \
Source/WebCore/dom/EventTarget.cpp \
......
......@@ -409,7 +409,6 @@ SOURCES += \
dom/EventException.cpp \
dom/EventListenerMap.cpp \
dom/EventNames.cpp \
dom/EventPathWalker.cpp \
dom/EventRetargeter.cpp \
dom/EventTarget.cpp \
dom/ExceptionBase.cpp \
......@@ -1614,7 +1613,6 @@ HEADERS += \
dom/EventDispatchMediator.h \
dom/EventListenerMap.h \
dom/EventNames.h \
dom/EventPathWalker.h \
dom/EventQueue.h \
dom/EventSender.h \
dom/EventTarget.h \
......
......@@ -1514,8 +1514,6 @@
4A9CC81816BB9AC600EC645A /* CSSDefaultStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A9CC81616BB9AC600EC645A /* CSSDefaultStyleSheets.h */; };
4A9CC82016BF9BB400EC645A /* InspectorCSSOMWrappers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A9CC81E16BF9BB400EC645A /* InspectorCSSOMWrappers.cpp */; };
4A9CC82116BF9BB400EC645A /* InspectorCSSOMWrappers.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A9CC81F16BF9BB400EC645A /* InspectorCSSOMWrappers.h */; };
4AAAB4C416D379B5001DA41B /* EventPathWalker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AAAB4C216D379B5001DA41B /* EventPathWalker.cpp */; };
4AAAB4C516D379B5001DA41B /* EventPathWalker.h in Headers */ = {isa = PBXBuildFile; fileRef = 4AAAB4C316D379B5001DA41B /* EventPathWalker.h */; };
4ACBC0BE12713CBD0094F9B2 /* ClassList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4ACBC0BC12713CBD0094F9B2 /* ClassList.cpp */; };
4ACBC0BF12713CBD0094F9B2 /* ClassList.h in Headers */ = {isa = PBXBuildFile; fileRef = 4ACBC0BD12713CBD0094F9B2 /* ClassList.h */; };
4ACBC0C312713CCA0094F9B2 /* DOMSettableTokenList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4ACBC0C012713CCA0094F9B2 /* DOMSettableTokenList.cpp */; };
......@@ -8098,8 +8096,6 @@
4A9CC81616BB9AC600EC645A /* CSSDefaultStyleSheets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSDefaultStyleSheets.h; sourceTree = "<group>"; };
4A9CC81E16BF9BB400EC645A /* InspectorCSSOMWrappers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCSSOMWrappers.cpp; sourceTree = "<group>"; };
4A9CC81F16BF9BB400EC645A /* InspectorCSSOMWrappers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCSSOMWrappers.h; sourceTree = "<group>"; };
4AAAB4C216D379B5001DA41B /* EventPathWalker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventPathWalker.cpp; sourceTree = "<group>"; };
4AAAB4C316D379B5001DA41B /* EventPathWalker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventPathWalker.h; sourceTree = "<group>"; };
4ACBC0BC12713CBD0094F9B2 /* ClassList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClassList.cpp; sourceTree = "<group>"; };
4ACBC0BD12713CBD0094F9B2 /* ClassList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassList.h; sourceTree = "<group>"; };
4ACBC0C012713CCA0094F9B2 /* DOMSettableTokenList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMSettableTokenList.cpp; sourceTree = "<group>"; };
......@@ -20959,8 +20955,6 @@
939885C108B7E3D100E707C4 /* EventNames.cpp */,
939885C208B7E3D100E707C4 /* EventNames.h */,
BC9A6142146859D9006057FD /* EventNames.in */,
4AAAB4C216D379B5001DA41B /* EventPathWalker.cpp */,
4AAAB4C316D379B5001DA41B /* EventPathWalker.h */,
8F6756191288B17B0047ACA3 /* EventQueue.h */,
4A5CB1C316C3A5FD00AB2886 /* EventRetargeter.cpp */,
4A5CB1C416C3A5FD00AB2886 /* EventRetargeter.h */,
......@@ -22432,7 +22426,6 @@
AD4495F4141FC08900541EDF /* EventListenerMap.h in Headers */,
1CA19E160DC255CA0065A994 /* EventLoop.h in Headers */,
939885C408B7E3D100E707C4 /* EventNames.h in Headers */,
4AAAB4C516D379B5001DA41B /* EventPathWalker.h in Headers */,
8F67561B1288B17B0047ACA3 /* EventQueue.h in Headers */,
4A5CB1C616C3A5FD00AB2886 /* EventRetargeter.h in Headers */,
E0FEF372B17C53EAC1C1FBEE /* EventSource.h in Headers */,
......@@ -25728,7 +25721,6 @@
26F40D4A14904A6300CA67C4 /* EventLoopIOS.mm in Sources */,
1CA19E050DC255950065A994 /* EventLoopMac.mm in Sources */,
939885C308B7E3D100E707C4 /* EventNames.cpp in Sources */,
4AAAB4C416D379B5001DA41B /* EventPathWalker.cpp in Sources */,
07969DB917D14151007FF842 /* JSRTCPeerConnection.cpp in Sources */,
4A5CB1C516C3A5FD00AB2886 /* EventRetargeter.cpp in Sources */,
E0FEF372B27C53EAC1C1FBEE /* EventSource.cpp in Sources */,
......@@ -77,7 +77,6 @@
#include "EventException.cpp"
#include "EventListenerMap.cpp"
#include "EventNames.cpp"
#include "EventPathWalker.cpp"
#include "EventRetargeter.cpp"
#include "EventTarget.cpp"
#include "ExceptionBase.cpp"
......
......@@ -29,7 +29,6 @@
#include "ContainerNode.h"
#include "EventContext.h"
#include "EventDispatchMediator.h"
#include "EventPathWalker.h"
#include "EventRetargeter.h"
#include "FrameView.h"
#include "HTMLMediaElement.h"
......
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "EventPathWalker.h"
#include "ContentDistributor.h"
#include "InsertionPoint.h"
#include "PseudoElement.h"
#include "ShadowRoot.h"
namespace WebCore {
EventPathWalker::EventPathWalker(const Node* node)
: m_node(node)
, m_distributedNode(node)
, m_isVisitingInsertionPointInReprojection(false)
{
ASSERT(node);
}
Node* EventPathWalker::parent(const Node* node)
{
EventPathWalker walker(node);
walker.moveToParent();
return walker.node();
}
void EventPathWalker::moveToParent()
{
ASSERT(m_node);
ASSERT(m_distributedNode);
if (ShadowRoot* shadowRoot = m_node->parentElement() ? m_node->parentElement()->shadowRoot() : 0) {
if (InsertionPoint* insertionPoint = shadowRoot->distributor().findInsertionPointFor(m_distributedNode)) {
m_node = insertionPoint;
m_isVisitingInsertionPointInReprojection = true;
return;
}
}
m_isVisitingInsertionPointInReprojection = false;
if (m_node->isPseudoElement()) {
// FIXME: Pseudo elements should probably not be dispatching events in the first place.
m_node = toPseudoElement(m_node)->hostElement();
return;
}
if (m_node->isShadowRoot()) {
m_node = toShadowRoot(m_node)->hostElement();
m_distributedNode = m_node;
return;
}
m_node = m_node->parentNode();
}
} // namespace
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EventPathWalker_h
#define EventPathWalker_h
namespace WebCore {
class Node;
class EventPathWalker {
public:
explicit EventPathWalker(const Node*);
static Node* parent(const Node*);
void moveToParent();
Node* node() const { return const_cast<Node*>(m_node); }
bool isVisitingInsertionPointInReprojection() { return m_isVisitingInsertionPointInReprojection; }
private:
const Node* m_node;
const Node* m_distributedNode;
bool m_isVisitingInsertionPointInReprojection;
};
} // namespace
#endif
......@@ -22,7 +22,6 @@
#include "ContainerNode.h"
#include "EventContext.h"
#include "EventPathWalker.h"
#include "FocusEvent.h"
#include "MouseEvent.h"
#include "ShadowRoot.h"
......@@ -75,21 +74,24 @@ static inline EventDispatchBehavior determineDispatchBehavior(Event* event, Shad
return RetargetEvent;
}
void EventRetargeter::calculateEventPath(Node* node, Event* event, EventPath& eventPath)
static Node* nodeOrHostIfPseudoElement(Node* node)
{
bool inDocument = node->inDocument();
bool isSVGElement = node->isSVGElement();
return node->isPseudoElement() ? toPseudoElement(node)->hostElement() : node;
}
void EventRetargeter::calculateEventPath(Node* targetNode, Event* event, EventPath& eventPath)
{
bool inDocument = targetNode->inDocument();
bool isSVGElement = targetNode->isSVGElement();
bool isMouseOrFocusEvent = event->isMouseEvent() || event->isFocusEvent();
#if ENABLE(TOUCH_EVENTS)
bool isTouchEvent = event->isTouchEvent();
#endif
Vector<EventTarget*, 32> targetStack;
for (EventPathWalker walker(node); walker.node(); walker.moveToParent()) {
Node* node = walker.node();
for (Node* node = nodeOrHostIfPseudoElement(targetNode); node; node = node->parentOrShadowHostNode()) {
if (targetStack.isEmpty())
targetStack.append(eventTargetRespectingTargetRules(node));
else if (walker.isVisitingInsertionPointInReprojection())
targetStack.append(targetStack.last());
if (isMouseOrFocusEvent)
eventPath.append(adoptPtr(new MouseOrFocusEventContext(node, eventTargetRespectingTargetRules(node), targetStack.last())));
#if ENABLE(TOUCH_EVENTS)
......@@ -219,12 +221,9 @@ void EventRetargeter::buildRelatedNodeMap(const Node* relatedNode, RelatedNodeMa
{
Vector<Node*, 32> relatedNodeStack;
TreeScope* lastTreeScope = 0;
for (EventPathWalker walker(relatedNode); walker.node(); walker.moveToParent()) {
Node* node = walker.node();
for (Node* node = nodeOrHostIfPseudoElement(const_cast<Node*>(relatedNode)); node; node = node->parentOrShadowHostNode()) {
if (relatedNodeStack.isEmpty())
relatedNodeStack.append(node);
else if (walker.isVisitingInsertionPointInReprojection())
relatedNodeStack.append(relatedNodeStack.last());
TreeScope* scope = node->treeScope();
// Skips adding a node to the map if treeScope does not change. Just for the performance optimization.
if (scope != lastTreeScope)
......
......@@ -26,7 +26,6 @@
#include "Attribute.h"
#include "CSSPropertyNames.h"
#include "CSSValueKeywords.h"
#include "EventPathWalker.h"
#include "HTMLNames.h"
#include "RenderListItem.h"
......
......@@ -42,7 +42,6 @@
#include "Editor.h"
#include "EditorClient.h"
#include "EventNames.h"
#include "EventPathWalker.h"
#include "ExceptionCodePlaceholder.h"
#include "FileList.h"
#include "FloatPoint.h"
......@@ -733,7 +732,7 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
RenderObject* renderer = targetNode->renderer();
if (!renderer) {
Node* parent = EventPathWalker::parent(targetNode);
Element* parent = targetNode->parentOrShadowHostElement();
if (!parent)
return false;
......@@ -2095,7 +2094,7 @@ bool EventHandler::updateDragAndDrop(const PlatformMouseEvent& event, Clipboard*
// Drag events should never go to text nodes (following IE, and proper mouseover/out dispatch)
RefPtr<Node> newTarget = mev.targetNode();
if (newTarget && newTarget->isTextNode())
newTarget = EventPathWalker::parent(newTarget.get());
newTarget = newTarget->parentOrShadowHostElement();
m_autoscrollController->updateDragAndDrop(newTarget.get(), event.position(), event.timestamp());
......@@ -2232,7 +2231,7 @@ void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo
else {
// If the target node is a text node, dispatch on the parent node - rdar://4196646
if (result && result->isTextNode())
result = EventPathWalker::parent(result);
result = result->parentOrShadowHostElement();
}
m_nodeUnderMouse = result;
#if ENABLE(SVG)
......@@ -2479,11 +2478,8 @@ bool EventHandler::handleWheelEvent(const PlatformWheelEvent& e)
bool useLatchedWheelEventNode = e.useLatchedEventNode();
// FIXME: Is the following code different from just calling innerElement?
Node* node = result.innerNode();
// Wheel events should not dispatch to text nodes.
if (node && node->isTextNode())
node = EventPathWalker::parent(node);
// FIXME: This code should use Element* instead of Node*.
Node* node = result.innerElement();
bool isOverWidget;
if (useLatchedWheelEventNode) {
......@@ -4024,12 +4020,9 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
} else
continue;
// FIXME: Is the following code different from just calling innerElement?
Node* node = result.innerNode();
// FIXME: This code should use Element* instead of Node*.
Node* node = result.innerElement();
ASSERT(node);
// Touch events should not go to text nodes
if (node->isTextNode())
node = EventPathWalker::parent(node);
if (InspectorInstrumentation::handleTouchEvent(m_frame.page(), node))
return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment