Commit 5fa209cd authored by hayato@chromium.org's avatar hayato@chromium.org

Remove EventPath::parent() in favor of NodeRenderingTraversal::parent().

EventPath::parent() is only used in adjusting the result of HitTest in some places.
For example, if a text node is clicked, we have to adjust the result to the *reasonable* parent element of the text node.

In adjusting, we should use NodeRenderingTraversal::parent() instead of EventPath::parent().
That means the adjusted result is no longer shadow roots or insertion points.
The result would be the parent element of the text node in the composed tree.
That should make sense because neither shadow roots nor insertion points are rendered.

BUG=354366

Review URL: https://codereview.chromium.org/210753002

git-svn-id: svn://svn.chromium.org/blink/trunk@169923 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 4b1ae5bf
...@@ -5,14 +5,15 @@ Composed Shadow Tree will be: ...@@ -5,14 +5,15 @@ Composed Shadow Tree will be:
DIV id=sandbox DIV id=sandbox
DIV id=top DIV id=top
DIV id=shadow-host DIV id=shadow-host
#text DIV id=content-parent
#text
Moving mouse from a distributed text node to top Moving mouse from a distributed text node to top
mouseout mouseout
@content (target: content) (related: top) @content-parent (target: content-parent) (related: top)
@shadow-root (target: content) (related: top) @shadow-root (target: content-parent) (related: top)
@shadow-host (target: shadow-host) (related: top) @shadow-host (target: shadow-host) (related: top)
@top (target: shadow-host) (related: top) @top (target: shadow-host) (related: top)
...@@ -20,14 +21,14 @@ Moving mouse from a distributed text node to top ...@@ -20,14 +21,14 @@ Moving mouse from a distributed text node to top
@top (target: top) (related: shadow-host) @top (target: top) (related: shadow-host)
mousewheel mousewheel
@content (target: content) @content-parent (target: content-parent)
@shadow-root (target: content) @shadow-root (target: content-parent)
@shadow-host (target: shadow-host) @shadow-host (target: shadow-host)
@top (target: shadow-host) @top (target: shadow-host)
touchstart touchstart
@content (target: content) (touches: content) (targetTouches: content) (changedTouches: content) @content-parent (target: content-parent) (touches: content-parent) (targetTouches: content-parent) (changedTouches: content-parent)
@shadow-root (target: content) (touches: content) (targetTouches: content) (changedTouches: content) @shadow-root (target: content-parent) (touches: content-parent) (targetTouches: content-parent) (changedTouches: content-parent)
@shadow-host (target: shadow-host) (touches: shadow-host) (targetTouches: shadow-host) (changedTouches: shadow-host) @shadow-host (target: shadow-host) (touches: shadow-host) (targetTouches: shadow-host) (changedTouches: shadow-host)
@top (target: shadow-host) (touches: shadow-host) (targetTouches: shadow-host) (changedTouches: shadow-host) @top (target: shadow-host) (touches: shadow-host) (targetTouches: shadow-host) (changedTouches: shadow-host)
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -12,14 +12,15 @@ ...@@ -12,14 +12,15 @@
<script> <script>
var sandbox = document.getElementById('sandbox'); var sandbox = document.getElementById('sandbox');
// Makes sure an insertion point can receive a event when a distributed text node is clicked. // Makes sure the parent of the insertion point can receive an event when a distributed text node is clicked.
sandbox.appendChild( sandbox.appendChild(
createDOM('div', {'id': 'top'}, createDOM('div', {'id': 'top'},
createDOM('div', {'id': 'shadow-host'}, createDOM('div', {'id': 'shadow-host'},
createShadowRoot({'id': 'shadow-root'}, createShadowRoot({'id': 'shadow-root'},
createDOM('content', {'id': 'content'})), createDOM('div', {'id': 'content-parent'},
createDOM('content', {'id': 'content'}))),
document.createTextNode('Text Node')))); document.createTextNode('Text Node'))));
addEventListeners(['top', 'shadow-host', 'shadow-host/', 'shadow-host/content']); addEventListeners(['top', 'shadow-host', 'shadow-host/', 'shadow-host/content-parent', 'shadow-host/content']);
showSandboxTree(); showSandboxTree();
// Calculates the position of the text node. // Calculates the position of the text node.
......
...@@ -10,7 +10,6 @@ DIV id=sandbox ...@@ -10,7 +10,6 @@ DIV id=sandbox
Moving mouse from a direct child text node of the shadow root to top Moving mouse from a direct child text node of the shadow root to top
mouseout mouseout
@shadow-root (target: shadow-root) (related: top)
@shadow-host (target: shadow-host) (related: top) @shadow-host (target: shadow-host) (related: top)
@top (target: shadow-host) (related: top) @top (target: shadow-host) (related: top)
...@@ -18,12 +17,10 @@ Moving mouse from a direct child text node of the shadow root to top ...@@ -18,12 +17,10 @@ Moving mouse from a direct child text node of the shadow root to top
@top (target: top) (related: shadow-host) @top (target: top) (related: shadow-host)
touchstart touchstart
@shadow-root (target: shadow-root) (touches: shadow-root) (targetTouches: shadow-root) (changedTouches: shadow-root)
@shadow-host (target: shadow-host) (touches: shadow-host) (targetTouches: shadow-host) (changedTouches: shadow-host) @shadow-host (target: shadow-host) (touches: shadow-host) (targetTouches: shadow-host) (changedTouches: shadow-host)
@top (target: shadow-host) (touches: shadow-host) (targetTouches: shadow-host) (changedTouches: shadow-host) @top (target: shadow-host) (touches: shadow-host) (targetTouches: shadow-host) (changedTouches: shadow-host)
mousewheel mousewheel
@shadow-root (target: shadow-root)
@shadow-host (target: shadow-host) @shadow-host (target: shadow-host)
@top (target: shadow-host) @top (target: shadow-host)
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -45,12 +45,6 @@ ...@@ -45,12 +45,6 @@
namespace WebCore { namespace WebCore {
Node* EventPath::parent(Node* node)
{
EventPath eventPath(node);
return eventPath.size() > 1 ? eventPath[1].node() : 0;
}
EventTarget* EventPath::eventTargetRespectingTargetRules(Node* referenceNode) EventTarget* EventPath::eventTargetRespectingTargetRules(Node* referenceNode)
{ {
ASSERT(referenceNode); ASSERT(referenceNode);
......
...@@ -63,7 +63,6 @@ public: ...@@ -63,7 +63,6 @@ public:
void adjustForRelatedTarget(Node*, EventTarget* relatedTarget); void adjustForRelatedTarget(Node*, EventTarget* relatedTarget);
void adjustForTouchEvent(Node*, TouchEvent&); void adjustForTouchEvent(Node*, TouchEvent&);
static Node* parent(Node*);
static EventTarget* eventTargetRespectingTargetRules(Node*); static EventTarget* eventTargetRespectingTargetRules(Node*);
private: private:
......
...@@ -699,7 +699,7 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e ...@@ -699,7 +699,7 @@ bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
RenderObject* renderer = targetNode->renderer(); RenderObject* renderer = targetNode->renderer();
if (!renderer) { if (!renderer) {
Node* parent = EventPath::parent(targetNode); Node* parent = NodeRenderingTraversal::parent(targetNode);
if (!parent) if (!parent)
return false; return false;
...@@ -1801,7 +1801,7 @@ bool EventHandler::updateDragAndDrop(const PlatformMouseEvent& event, Clipboard* ...@@ -1801,7 +1801,7 @@ bool EventHandler::updateDragAndDrop(const PlatformMouseEvent& event, Clipboard*
// Drag events should never go to text nodes (following IE, and proper mouseover/out dispatch) // Drag events should never go to text nodes (following IE, and proper mouseover/out dispatch)
RefPtr<Node> newTarget = mev.targetNode(); RefPtr<Node> newTarget = mev.targetNode();
if (newTarget && newTarget->isTextNode()) if (newTarget && newTarget->isTextNode())
newTarget = EventPath::parent(newTarget.get()); newTarget = NodeRenderingTraversal::parent(newTarget.get());
if (AutoscrollController* controller = autoscrollController()) if (AutoscrollController* controller = autoscrollController())
controller->updateDragAndDrop(newTarget.get(), event.position(), event.timestamp()); controller->updateDragAndDrop(newTarget.get(), event.position(), event.timestamp());
...@@ -1935,7 +1935,7 @@ void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo ...@@ -1935,7 +1935,7 @@ void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo
else { else {
// If the target node is a text node, dispatch on the parent node - rdar://4196646 // If the target node is a text node, dispatch on the parent node - rdar://4196646
if (result && result->isTextNode()) if (result && result->isTextNode())
result = EventPath::parent(result); result = NodeRenderingTraversal::parent(result);
} }
m_nodeUnderMouse = result; m_nodeUnderMouse = result;
m_instanceUnderMouse = instanceAssociatedWithShadowTreeElement(result); m_instanceUnderMouse = instanceAssociatedWithShadowTreeElement(result);
...@@ -2143,7 +2143,7 @@ bool EventHandler::handleWheelEvent(const PlatformWheelEvent& e) ...@@ -2143,7 +2143,7 @@ bool EventHandler::handleWheelEvent(const PlatformWheelEvent& e)
Node* node = result.innerNode(); Node* node = result.innerNode();
// Wheel events should not dispatch to text nodes. // Wheel events should not dispatch to text nodes.
if (node && node->isTextNode()) if (node && node->isTextNode())
node = EventPath::parent(node); node = NodeRenderingTraversal::parent(node);
bool isOverWidget; bool isOverWidget;
if (e.useLatchedEventNode()) { if (e.useLatchedEventNode()) {
...@@ -3664,7 +3664,7 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) ...@@ -3664,7 +3664,7 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
// Touch events should not go to text nodes // Touch events should not go to text nodes
if (node->isTextNode()) if (node->isTextNode())
node = EventPath::parent(node); node = NodeRenderingTraversal::parent(node);
Document& doc = node->document(); Document& doc = node->document();
// Record the originating touch document even if it does not have a touch listener. // Record the originating touch document even if it does not have a touch listener.
......
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