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

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

Issue 138643003: Simpler return value of HashTable::add/HashMap:add and others (Closed)
Patch Set: Daily master update (now with base url?) Created 6 years, 10 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 197 }
198 treeScopeEventContext->adoptEventPath(nodes); 198 treeScopeEventContext->adoptEventPath(nodes);
199 } 199 }
200 } 200 }
201 201
202 TreeScopeEventContext* EventPath::ensureTreeScopeEventContext(Node* currentTarge t, TreeScope* treeScope, TreeScopeEventContextMap& treeScopeEventContextMap) 202 TreeScopeEventContext* EventPath::ensureTreeScopeEventContext(Node* currentTarge t, TreeScope* treeScope, TreeScopeEventContextMap& treeScopeEventContextMap)
203 { 203 {
204 if (!treeScope) 204 if (!treeScope)
205 return 0; 205 return 0;
206 TreeScopeEventContextMap::AddResult addResult = treeScopeEventContextMap.add (treeScope, TreeScopeEventContext::create(*treeScope)); 206 TreeScopeEventContextMap::AddResult addResult = treeScopeEventContextMap.add (treeScope, TreeScopeEventContext::create(*treeScope));
207 TreeScopeEventContext* treeScopeEventContext = addResult.iterator->value.get (); 207 TreeScopeEventContext* treeScopeEventContext = addResult.storedValue->value. get();
208 if (addResult.isNewEntry) { 208 if (addResult.isNewEntry) {
209 TreeScopeEventContext* parentTreeScopeEventContext = ensureTreeScopeEven tContext(0, treeScope->olderShadowRootOrParentTreeScope(), treeScopeEventContext Map); 209 TreeScopeEventContext* parentTreeScopeEventContext = ensureTreeScopeEven tContext(0, treeScope->olderShadowRootOrParentTreeScope(), treeScopeEventContext Map);
210 if (parentTreeScopeEventContext && parentTreeScopeEventContext->target() ) { 210 if (parentTreeScopeEventContext && parentTreeScopeEventContext->target() ) {
211 treeScopeEventContext->setTarget(parentTreeScopeEventContext->target ()); 211 treeScopeEventContext->setTarget(parentTreeScopeEventContext->target ());
212 } else if (currentTarget) { 212 } else if (currentTarget) {
213 treeScopeEventContext->setTarget(eventTargetRespectingTargetRules(cu rrentTarget)); 213 treeScopeEventContext->setTarget(eventTargetRespectingTargetRules(cu rrentTarget));
214 } 214 }
215 } else if (!treeScopeEventContext->target() && currentTarget) { 215 } else if (!treeScopeEventContext->target() && currentTarget) {
216 treeScopeEventContext->setTarget(eventTargetRespectingTargetRules(curren tTarget)); 216 treeScopeEventContext->setTarget(eventTargetRespectingTargetRules(curren tTarget));
217 } 217 }
218 return treeScopeEventContext; 218 return treeScopeEventContext;
219 } 219 }
220 220
221 void EventPath::calculateAdjustedTargets() 221 void EventPath::calculateAdjustedTargets()
222 { 222 {
223 const TreeScope* lastTreeScope = 0; 223 const TreeScope* lastTreeScope = 0;
224 bool isSVGElement = at(0).node()->isSVGElement(); 224 bool isSVGElement = at(0).node()->isSVGElement();
225 225
226 TreeScopeEventContextMap treeScopeEventContextMap; 226 TreeScopeEventContextMap treeScopeEventContextMap;
227 TreeScopeEventContext* lastTreeScopeEventContext = 0; 227 TreeScopeEventContext* lastTreeScopeEventContext = 0;
228 228
229 for (size_t i = 0; i < size(); ++i) { 229 for (size_t i = 0; i < size(); ++i) {
230 Node* currentNode = at(i).node(); 230 Node* currentNode = at(i).node();
231 TreeScope& currentTreeScope = currentNode->treeScope(); 231 TreeScope& currentTreeScope = currentNode->treeScope();
232 if (lastTreeScope != &currentTreeScope) { 232 if (lastTreeScope != &currentTreeScope) {
233 if (!isSVGElement) { 233 if (!isSVGElement) {
234 lastTreeScopeEventContext = ensureTreeScopeEventContext(currentN ode, &currentTreeScope, treeScopeEventContextMap); 234 lastTreeScopeEventContext = ensureTreeScopeEventContext(currentN ode, &currentTreeScope, treeScopeEventContextMap);
235 } else { 235 } else {
236 TreeScopeEventContextMap::AddResult addResult = treeScopeEventCo ntextMap.add(&currentTreeScope, TreeScopeEventContext::create(currentTreeScope)) ; 236 TreeScopeEventContextMap::AddResult addResult = treeScopeEventCo ntextMap.add(&currentTreeScope, TreeScopeEventContext::create(currentTreeScope)) ;
237 lastTreeScopeEventContext = addResult.iterator->value.get(); 237 lastTreeScopeEventContext = addResult.storedValue->value.get();
238 if (addResult.isNewEntry) { 238 if (addResult.isNewEntry) {
239 // Don't adjust an event target for SVG. 239 // Don't adjust an event target for SVG.
240 lastTreeScopeEventContext->setTarget(eventTargetRespectingTa rgetRules(at(0).node())); 240 lastTreeScopeEventContext->setTarget(eventTargetRespectingTa rgetRules(at(0).node()));
241 } 241 }
242 } 242 }
243 } 243 }
244 ASSERT(lastTreeScopeEventContext); 244 ASSERT(lastTreeScopeEventContext);
245 at(i).setTreeScopeEventContext(lastTreeScopeEventContext); 245 at(i).setTreeScopeEventContext(lastTreeScopeEventContext);
246 lastTreeScope = &currentTreeScope; 246 lastTreeScope = &currentTreeScope;
247 } 247 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 368
369 #ifndef NDEBUG 369 #ifndef NDEBUG
370 void EventPath::checkReachability(TreeScope& treeScope, TouchList& touchList) 370 void EventPath::checkReachability(TreeScope& treeScope, TouchList& touchList)
371 { 371 {
372 for (size_t i = 0; i < touchList.length(); ++i) 372 for (size_t i = 0; i < touchList.length(); ++i)
373 ASSERT(touchList.item(i)->target()->toNode()->treeScope().isInclusiveOld erSiblingShadowRootOrAncestorTreeScopeOf(treeScope)); 373 ASSERT(touchList.item(i)->target()->toNode()->treeScope().isInclusiveOld erSiblingShadowRootOrAncestorTreeScopeOf(treeScope));
374 } 374 }
375 #endif 375 #endif
376 376
377 } // namespace 377 } // namespace
OLDNEW
« no previous file with comments | « Source/core/dom/shadow/ElementShadow.cpp ('k') | Source/core/fetch/ResourceLoadPriorityOptimizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698