Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: Source/core/dom/EventRetargeter.cpp

Issue 15063004: Make Event.path() return a pre-calculated NodeList rather than calculating it dynamically. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add an include. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/EventContext.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #include "config.h" 20 #include "config.h"
21 #include "core/dom/EventRetargeter.h" 21 #include "core/dom/EventRetargeter.h"
22 22
23 #include "RuntimeEnabledFeatures.h"
23 #include "core/dom/ContainerNode.h" 24 #include "core/dom/ContainerNode.h"
24 #include "core/dom/EventContext.h" 25 #include "core/dom/EventContext.h"
25 #include "core/dom/EventPathWalker.h" 26 #include "core/dom/EventPathWalker.h"
26 #include "core/dom/FocusEvent.h" 27 #include "core/dom/FocusEvent.h"
27 #include "core/dom/MouseEvent.h" 28 #include "core/dom/MouseEvent.h"
28 #include "core/dom/Touch.h" 29 #include "core/dom/Touch.h"
29 #include "core/dom/TouchEvent.h" 30 #include "core/dom/TouchEvent.h"
30 #include "core/dom/TouchList.h" 31 #include "core/dom/TouchList.h"
31 #include "core/dom/TreeScope.h" 32 #include "core/dom/TreeScope.h"
32 #include "core/dom/shadow/ShadowRoot.h" 33 #include "core/dom/shadow/ShadowRoot.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return; 97 return;
97 if (!node->isShadowRoot()) 98 if (!node->isShadowRoot())
98 continue; 99 continue;
99 if (determineDispatchBehavior(event, toShadowRoot(node), targetStack.las t()) == StayInsideShadowDOM) 100 if (determineDispatchBehavior(event, toShadowRoot(node), targetStack.las t()) == StayInsideShadowDOM)
100 return; 101 return;
101 if (!isSVGElement) { 102 if (!isSVGElement) {
102 ASSERT(!targetStack.isEmpty()); 103 ASSERT(!targetStack.isEmpty());
103 targetStack.removeLast(); 104 targetStack.removeLast();
104 } 105 }
105 } 106 }
107
108 // Calculates eventPath for each node for Event.path() API.
109 if (!RuntimeEnabledFeatures::experimentalShadowDOMEnabled())
110 return;
111 TreeScope* lastScope = 0;
112 size_t eventPathSize = eventPath.size();
113 for (size_t i = 0; i < eventPathSize; ++i) {
114 TreeScope* currentScope = eventPath[i]->node()->treeScope();
115 if (currentScope == lastScope) {
116 // Fast path.
117 eventPath[i]->setEventPath(eventPath[i - 1]->eventPath());
118 continue;
119 }
120 lastScope = currentScope;
121 Vector<RefPtr<Node> > nodes;
122 for (size_t j = 0; j < eventPathSize; ++j) {
123 Node* node = eventPath[j]->node();
124 if (node->treeScope()->isInclusiveAncestorOf(currentScope))
125 nodes.append(node);
126 }
127 eventPath[i]->adoptEventPath(nodes);
128 }
106 } 129 }
107 130
108 void EventRetargeter::adjustForMouseEvent(Node* node, MouseEvent& mouseEvent) 131 void EventRetargeter::adjustForMouseEvent(Node* node, MouseEvent& mouseEvent)
109 { 132 {
110 adjustForRelatedTarget(node, mouseEvent.relatedTarget(), mouseEvent.eventPat h()); 133 adjustForRelatedTarget(node, mouseEvent.relatedTarget(), mouseEvent.eventPat h());
111 } 134 }
112 135
113 void EventRetargeter::adjustForFocusEvent(Node* node, FocusEvent& focusEvent) 136 void EventRetargeter::adjustForFocusEvent(Node* node, FocusEvent& focusEvent)
114 { 137 {
115 adjustForRelatedTarget(node, focusEvent.relatedTarget(), focusEvent.eventPat h()); 138 adjustForRelatedTarget(node, focusEvent.relatedTarget(), focusEvent.eventPat h());
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 break; 265 break;
243 } 266 }
244 scope = scope->parentTreeScope(); 267 scope = scope->parentTreeScope();
245 } 268 }
246 for (Vector<TreeScope*, 32>::iterator iter = parentTreeScopes.begin(); iter < parentTreeScopes.end(); ++iter) 269 for (Vector<TreeScope*, 32>::iterator iter = parentTreeScopes.begin(); iter < parentTreeScopes.end(); ++iter)
247 relatedNodeMap.add(*iter, relatedNode); 270 relatedNodeMap.add(*iter, relatedNode);
248 return relatedNode; 271 return relatedNode;
249 } 272 }
250 273
251 } 274 }
OLDNEW
« no previous file with comments | « Source/core/dom/EventContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698