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

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

Issue 2554953005: Avoid WTF::Vector::at() and operator[] in core/events. (Closed)
Patch Set: _ Created 4 years 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/events/EventSender.h » ('j') | 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 * 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 } 231 }
232 return treeScopeEventContext; 232 return treeScopeEventContext;
233 } 233 }
234 234
235 void EventPath::calculateAdjustedTargets() { 235 void EventPath::calculateAdjustedTargets() {
236 const TreeScope* lastTreeScope = nullptr; 236 const TreeScope* lastTreeScope = nullptr;
237 237
238 TreeScopeEventContextMap treeScopeEventContextMap; 238 TreeScopeEventContextMap treeScopeEventContextMap;
239 TreeScopeEventContext* lastTreeScopeEventContext = nullptr; 239 TreeScopeEventContext* lastTreeScopeEventContext = nullptr;
240 240
241 for (size_t i = 0; i < size(); ++i) { 241 for (auto& context : m_nodeEventContexts) {
242 Node* currentNode = at(i).node(); 242 Node* currentNode = context.node();
243 TreeScope& currentTreeScope = currentNode->treeScope(); 243 TreeScope& currentTreeScope = currentNode->treeScope();
244 if (lastTreeScope != &currentTreeScope) { 244 if (lastTreeScope != &currentTreeScope) {
245 lastTreeScopeEventContext = ensureTreeScopeEventContext( 245 lastTreeScopeEventContext = ensureTreeScopeEventContext(
246 currentNode, &currentTreeScope, treeScopeEventContextMap); 246 currentNode, &currentTreeScope, treeScopeEventContextMap);
247 } 247 }
248 DCHECK(lastTreeScopeEventContext); 248 DCHECK(lastTreeScopeEventContext);
249 at(i).setTreeScopeEventContext(lastTreeScopeEventContext); 249 context.setTreeScopeEventContext(lastTreeScopeEventContext);
250 lastTreeScope = &currentTreeScope; 250 lastTreeScope = &currentTreeScope;
251 } 251 }
252 m_treeScopeEventContexts.appendRange( 252 m_treeScopeEventContexts.appendRange(
253 treeScopeEventContextMap.values().begin(), 253 treeScopeEventContextMap.values().begin(),
254 treeScopeEventContextMap.values().end()); 254 treeScopeEventContextMap.values().end());
255 } 255 }
256 256
257 void EventPath::buildRelatedNodeMap(const Node& relatedNode, 257 void EventPath::buildRelatedNodeMap(const Node& relatedNode,
258 RelatedTargetMap& relatedTargetMap) { 258 RelatedTargetMap& relatedTargetMap) {
259 EventPath* relatedTargetEventPath = 259 EventPath* relatedTargetEventPath =
260 new EventPath(const_cast<Node&>(relatedNode)); 260 new EventPath(const_cast<Node&>(relatedNode));
261 for (size_t i = 0; 261 for (const auto& treeScopeEventContext :
262 i < relatedTargetEventPath->m_treeScopeEventContexts.size(); ++i) { 262 relatedTargetEventPath->m_treeScopeEventContexts) {
263 TreeScopeEventContext* treeScopeEventContext =
264 relatedTargetEventPath->m_treeScopeEventContexts[i].get();
265 relatedTargetMap.add(&treeScopeEventContext->treeScope(), 263 relatedTargetMap.add(&treeScopeEventContext->treeScope(),
266 treeScopeEventContext->target()); 264 treeScopeEventContext->target());
267 } 265 }
268 // Oilpan: It is important to explicitly clear the vectors to reuse 266 // Oilpan: It is important to explicitly clear the vectors to reuse
269 // the memory in subsequent event dispatchings. 267 // the memory in subsequent event dispatchings.
270 relatedTargetEventPath->clear(); 268 relatedTargetEventPath->clear();
271 } 269 }
272 270
273 EventTarget* EventPath::findRelatedNode(TreeScope& scope, 271 EventTarget* EventPath::findRelatedNode(TreeScope& scope,
274 RelatedTargetMap& relatedTargetMap) { 272 RelatedTargetMap& relatedTargetMap) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 418
421 DEFINE_TRACE(EventPath) { 419 DEFINE_TRACE(EventPath) {
422 visitor->trace(m_nodeEventContexts); 420 visitor->trace(m_nodeEventContexts);
423 visitor->trace(m_node); 421 visitor->trace(m_node);
424 visitor->trace(m_event); 422 visitor->trace(m_event);
425 visitor->trace(m_treeScopeEventContexts); 423 visitor->trace(m_treeScopeEventContexts);
426 visitor->trace(m_windowEventContext); 424 visitor->trace(m_windowEventContext);
427 } 425 }
428 426
429 } // namespace blink 427 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/events/EventSender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698