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

Side by Side Diff: third_party/WebKit/Source/core/events/EventPath.cpp

Issue 2585283002: Migrate WTF::Vector::append() to ::push_back() [part 6 of N] (Closed)
Patch Set: Created 3 years, 12 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // Exclude nodes in SVG <use>'s shadow tree from event path. 112 // Exclude nodes in SVG <use>'s shadow tree from event path.
113 // See crbug.com/630870 113 // See crbug.com/630870
114 while (current->isSVGElement()) { 114 while (current->isSVGElement()) {
115 SVGUseElement* correspondingUseElement = 115 SVGUseElement* correspondingUseElement =
116 toSVGElement(current)->correspondingUseElement(); 116 toSVGElement(current)->correspondingUseElement();
117 if (!correspondingUseElement) 117 if (!correspondingUseElement)
118 break; 118 break;
119 current = correspondingUseElement; 119 current = correspondingUseElement;
120 } 120 }
121 121
122 nodesInPath.append(current); 122 nodesInPath.push_back(current);
123 while (current) { 123 while (current) {
124 if (m_event && current->keepEventInNode(m_event)) 124 if (m_event && current->keepEventInNode(m_event))
125 break; 125 break;
126 HeapVector<Member<InsertionPoint>, 8> insertionPoints; 126 HeapVector<Member<InsertionPoint>, 8> insertionPoints;
127 collectDestinationInsertionPoints(*current, insertionPoints); 127 collectDestinationInsertionPoints(*current, insertionPoints);
128 if (!insertionPoints.isEmpty()) { 128 if (!insertionPoints.isEmpty()) {
129 for (const auto& insertionPoint : insertionPoints) { 129 for (const auto& insertionPoint : insertionPoints) {
130 if (insertionPoint->isShadowInsertionPoint()) { 130 if (insertionPoint->isShadowInsertionPoint()) {
131 ShadowRoot* containingShadowRoot = 131 ShadowRoot* containingShadowRoot =
132 insertionPoint->containingShadowRoot(); 132 insertionPoint->containingShadowRoot();
133 DCHECK(containingShadowRoot); 133 DCHECK(containingShadowRoot);
134 if (!containingShadowRoot->isOldest()) 134 if (!containingShadowRoot->isOldest())
135 nodesInPath.append(containingShadowRoot->olderShadowRoot()); 135 nodesInPath.push_back(containingShadowRoot->olderShadowRoot());
136 } 136 }
137 nodesInPath.append(insertionPoint); 137 nodesInPath.push_back(insertionPoint);
138 } 138 }
139 current = insertionPoints.back(); 139 current = insertionPoints.back();
140 continue; 140 continue;
141 } 141 }
142 if (current->isChildOfV1ShadowHost()) { 142 if (current->isChildOfV1ShadowHost()) {
143 if (HTMLSlotElement* slot = current->assignedSlot()) { 143 if (HTMLSlotElement* slot = current->assignedSlot()) {
144 current = slot; 144 current = slot;
145 nodesInPath.append(current); 145 nodesInPath.push_back(current);
146 continue; 146 continue;
147 } 147 }
148 } 148 }
149 if (current->isShadowRoot()) { 149 if (current->isShadowRoot()) {
150 if (m_event && 150 if (m_event &&
151 shouldStopAtShadowRoot(*m_event, *toShadowRoot(current), *m_node)) 151 shouldStopAtShadowRoot(*m_event, *toShadowRoot(current), *m_node))
152 break; 152 break;
153 current = current->ownerShadowHost(); 153 current = current->ownerShadowHost();
154 nodesInPath.append(current); 154 nodesInPath.push_back(current);
155 } else { 155 } else {
156 current = current->parentNode(); 156 current = current->parentNode();
157 if (current) 157 if (current)
158 nodesInPath.append(current); 158 nodesInPath.push_back(current);
159 } 159 }
160 } 160 }
161 161
162 m_nodeEventContexts.reserveCapacity(nodesInPath.size()); 162 m_nodeEventContexts.reserveCapacity(nodesInPath.size());
163 for (Node* nodeInPath : nodesInPath) { 163 for (Node* nodeInPath : nodesInPath) {
164 m_nodeEventContexts.append(NodeEventContext( 164 m_nodeEventContexts.push_back(NodeEventContext(
165 nodeInPath, eventTargetRespectingTargetRules(*nodeInPath))); 165 nodeInPath, eventTargetRespectingTargetRules(*nodeInPath)));
166 } 166 }
167 } 167 }
168 168
169 void EventPath::calculateTreeOrderAndSetNearestAncestorClosedTree() { 169 void EventPath::calculateTreeOrderAndSetNearestAncestorClosedTree() {
170 // Precondition: 170 // Precondition:
171 // - TreeScopes in m_treeScopeEventContexts must be *connected* in the same 171 // - TreeScopes in m_treeScopeEventContexts must be *connected* in the same
172 // composed tree. 172 // composed tree.
173 // - The root tree must be included. 173 // - The root tree must be included.
174 HeapHashMap<Member<const TreeScope>, Member<TreeScopeEventContext>> 174 HeapHashMap<Member<const TreeScope>, Member<TreeScopeEventContext>>
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // the memory in subsequent event dispatchings. 267 // the memory in subsequent event dispatchings.
268 relatedTargetEventPath->clear(); 268 relatedTargetEventPath->clear();
269 } 269 }
270 270
271 EventTarget* EventPath::findRelatedNode(TreeScope& scope, 271 EventTarget* EventPath::findRelatedNode(TreeScope& scope,
272 RelatedTargetMap& relatedTargetMap) { 272 RelatedTargetMap& relatedTargetMap) {
273 HeapVector<Member<TreeScope>, 32> parentTreeScopes; 273 HeapVector<Member<TreeScope>, 32> parentTreeScopes;
274 EventTarget* relatedNode = nullptr; 274 EventTarget* relatedNode = nullptr;
275 for (TreeScope* current = &scope; current; 275 for (TreeScope* current = &scope; current;
276 current = current->olderShadowRootOrParentTreeScope()) { 276 current = current->olderShadowRootOrParentTreeScope()) {
277 parentTreeScopes.append(current); 277 parentTreeScopes.push_back(current);
278 RelatedTargetMap::const_iterator iter = relatedTargetMap.find(current); 278 RelatedTargetMap::const_iterator iter = relatedTargetMap.find(current);
279 if (iter != relatedTargetMap.end() && iter->value) { 279 if (iter != relatedTargetMap.end() && iter->value) {
280 relatedNode = iter->value; 280 relatedNode = iter->value;
281 break; 281 break;
282 } 282 }
283 } 283 }
284 DCHECK(relatedNode); 284 DCHECK(relatedNode);
285 for (const auto& entry : parentTreeScopes) 285 for (const auto& entry : parentTreeScopes)
286 relatedTargetMap.add(entry, relatedNode); 286 relatedTargetMap.add(entry, relatedNode);
287 287
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 337
338 void EventPath::adjustForTouchEvent(TouchEvent& touchEvent) { 338 void EventPath::adjustForTouchEvent(TouchEvent& touchEvent) {
339 HeapVector<Member<TouchList>> adjustedTouches; 339 HeapVector<Member<TouchList>> adjustedTouches;
340 HeapVector<Member<TouchList>> adjustedTargetTouches; 340 HeapVector<Member<TouchList>> adjustedTargetTouches;
341 HeapVector<Member<TouchList>> adjustedChangedTouches; 341 HeapVector<Member<TouchList>> adjustedChangedTouches;
342 HeapVector<Member<TreeScope>> treeScopes; 342 HeapVector<Member<TreeScope>> treeScopes;
343 343
344 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) { 344 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) {
345 TouchEventContext* touchEventContext = 345 TouchEventContext* touchEventContext =
346 treeScopeEventContext->ensureTouchEventContext(); 346 treeScopeEventContext->ensureTouchEventContext();
347 adjustedTouches.append(&touchEventContext->touches()); 347 adjustedTouches.push_back(&touchEventContext->touches());
348 adjustedTargetTouches.append(&touchEventContext->targetTouches()); 348 adjustedTargetTouches.push_back(&touchEventContext->targetTouches());
349 adjustedChangedTouches.append(&touchEventContext->changedTouches()); 349 adjustedChangedTouches.push_back(&touchEventContext->changedTouches());
350 treeScopes.append(&treeScopeEventContext->treeScope()); 350 treeScopes.push_back(&treeScopeEventContext->treeScope());
351 } 351 }
352 352
353 adjustTouchList(touchEvent.touches(), adjustedTouches, treeScopes); 353 adjustTouchList(touchEvent.touches(), adjustedTouches, treeScopes);
354 adjustTouchList(touchEvent.targetTouches(), adjustedTargetTouches, 354 adjustTouchList(touchEvent.targetTouches(), adjustedTargetTouches,
355 treeScopes); 355 treeScopes);
356 adjustTouchList(touchEvent.changedTouches(), adjustedChangedTouches, 356 adjustTouchList(touchEvent.changedTouches(), adjustedChangedTouches,
357 treeScopes); 357 treeScopes);
358 358
359 #if DCHECK_IS_ON() 359 #if DCHECK_IS_ON()
360 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) { 360 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 418
419 DEFINE_TRACE(EventPath) { 419 DEFINE_TRACE(EventPath) {
420 visitor->trace(m_nodeEventContexts); 420 visitor->trace(m_nodeEventContexts);
421 visitor->trace(m_node); 421 visitor->trace(m_node);
422 visitor->trace(m_event); 422 visitor->trace(m_event);
423 visitor->trace(m_treeScopeEventContexts); 423 visitor->trace(m_treeScopeEventContexts);
424 visitor->trace(m_windowEventContext); 424 visitor->trace(m_windowEventContext);
425 } 425 }
426 426
427 } // namespace blink 427 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/EventListenerMap.cpp ('k') | third_party/WebKit/Source/core/events/EventSender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698