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

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

Issue 1852663002: Oilpan: Remove WillBe types (part 9) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 void EventPath::calculatePath() 92 void EventPath::calculatePath()
93 { 93 {
94 ASSERT(m_node); 94 ASSERT(m_node);
95 ASSERT(m_nodeEventContexts.isEmpty()); 95 ASSERT(m_nodeEventContexts.isEmpty());
96 m_node->updateDistribution(); 96 m_node->updateDistribution();
97 97
98 // For performance and memory usage reasons we want to store the 98 // For performance and memory usage reasons we want to store the
99 // path using as few bytes as possible and with as few allocations 99 // path using as few bytes as possible and with as few allocations
100 // as possible which is why we gather the data on the stack before 100 // as possible which is why we gather the data on the stack before
101 // storing it in a perfectly sized m_nodeEventContexts Vector. 101 // storing it in a perfectly sized m_nodeEventContexts Vector.
102 WillBeHeapVector<RawPtrWillBeMember<Node>, 64> nodesInPath; 102 HeapVector<Member<Node>, 64> nodesInPath;
103 Node* current = m_node; 103 Node* current = m_node;
104 nodesInPath.append(current); 104 nodesInPath.append(current);
105 while (current) { 105 while (current) {
106 if (m_event && current->keepEventInNode(m_event)) 106 if (m_event && current->keepEventInNode(m_event))
107 break; 107 break;
108 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints; 108 HeapVector<Member<InsertionPoint>, 8> insertionPoints;
109 collectDestinationInsertionPoints(*current, insertionPoints); 109 collectDestinationInsertionPoints(*current, insertionPoints);
110 if (!insertionPoints.isEmpty()) { 110 if (!insertionPoints.isEmpty()) {
111 for (const auto& insertionPoint : insertionPoints) { 111 for (const auto& insertionPoint : insertionPoints) {
112 if (insertionPoint->isShadowInsertionPoint()) { 112 if (insertionPoint->isShadowInsertionPoint()) {
113 ShadowRoot* containingShadowRoot = insertionPoint->containin gShadowRoot(); 113 ShadowRoot* containingShadowRoot = insertionPoint->containin gShadowRoot();
114 ASSERT(containingShadowRoot); 114 ASSERT(containingShadowRoot);
115 if (!containingShadowRoot->isOldest()) 115 if (!containingShadowRoot->isOldest())
116 nodesInPath.append(containingShadowRoot->olderShadowRoot ()); 116 nodesInPath.append(containingShadowRoot->olderShadowRoot ());
117 } 117 }
118 nodesInPath.append(insertionPoint); 118 nodesInPath.append(insertionPoint);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 for (Node* nodeInPath : nodesInPath) { 152 for (Node* nodeInPath : nodesInPath) {
153 m_nodeEventContexts.append(NodeEventContext(nodeInPath, eventTargetRespe ctingTargetRules(*nodeInPath))); 153 m_nodeEventContexts.append(NodeEventContext(nodeInPath, eventTargetRespe ctingTargetRules(*nodeInPath)));
154 } 154 }
155 } 155 }
156 156
157 void EventPath::calculateTreeOrderAndSetNearestAncestorClosedTree() 157 void EventPath::calculateTreeOrderAndSetNearestAncestorClosedTree()
158 { 158 {
159 // Precondition: 159 // Precondition:
160 // - TreeScopes in m_treeScopeEventContexts must be *connected* in the sam e composed tree. 160 // - TreeScopes in m_treeScopeEventContexts must be *connected* in the sam e composed tree.
161 // - The root tree must be included. 161 // - The root tree must be included.
162 WillBeHeapHashMap<RawPtrWillBeMember<const TreeScope>, RawPtrWillBeMember<Tr eeScopeEventContext>> treeScopeEventContextMap; 162 HeapHashMap<Member<const TreeScope>, Member<TreeScopeEventContext>> treeScop eEventContextMap;
163 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) 163 for (const auto& treeScopeEventContext : m_treeScopeEventContexts)
164 treeScopeEventContextMap.add(&treeScopeEventContext->treeScope(), treeSc opeEventContext.get()); 164 treeScopeEventContextMap.add(&treeScopeEventContext->treeScope(), treeSc opeEventContext.get());
165 TreeScopeEventContext* rootTree = nullptr; 165 TreeScopeEventContext* rootTree = nullptr;
166 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) { 166 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) {
167 // Use olderShadowRootOrParentTreeScope here for parent-child relationsh ips. 167 // Use olderShadowRootOrParentTreeScope here for parent-child relationsh ips.
168 // See the definition of trees of trees in the Shadow DOM spec: 168 // See the definition of trees of trees in the Shadow DOM spec:
169 // http://w3c.github.io/webcomponents/spec/shadow/ 169 // http://w3c.github.io/webcomponents/spec/shadow/
170 TreeScope* parent = treeScopeEventContext.get()->treeScope().olderShadow RootOrParentTreeScope(); 170 TreeScope* parent = treeScopeEventContext.get()->treeScope().olderShadow RootOrParentTreeScope();
171 if (!parent) { 171 if (!parent) {
172 ASSERT(!rootTree); 172 ASSERT(!rootTree);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 221 }
222 ASSERT(lastTreeScopeEventContext); 222 ASSERT(lastTreeScopeEventContext);
223 at(i).setTreeScopeEventContext(lastTreeScopeEventContext); 223 at(i).setTreeScopeEventContext(lastTreeScopeEventContext);
224 lastTreeScope = &currentTreeScope; 224 lastTreeScope = &currentTreeScope;
225 } 225 }
226 m_treeScopeEventContexts.appendRange(treeScopeEventContextMap.values().begin (), treeScopeEventContextMap.values().end()); 226 m_treeScopeEventContexts.appendRange(treeScopeEventContextMap.values().begin (), treeScopeEventContextMap.values().end());
227 } 227 }
228 228
229 void EventPath::buildRelatedNodeMap(const Node& relatedNode, RelatedTargetMap& r elatedTargetMap) 229 void EventPath::buildRelatedNodeMap(const Node& relatedNode, RelatedTargetMap& r elatedTargetMap)
230 { 230 {
231 OwnPtrWillBeRawPtr<EventPath> relatedTargetEventPath = adoptPtrWillBeNoop(ne w EventPath(const_cast<Node&>(relatedNode))); 231 RawPtr<EventPath> relatedTargetEventPath = new EventPath(const_cast<Node&>(r elatedNode));
232 for (size_t i = 0; i < relatedTargetEventPath->m_treeScopeEventContexts.size (); ++i) { 232 for (size_t i = 0; i < relatedTargetEventPath->m_treeScopeEventContexts.size (); ++i) {
233 TreeScopeEventContext* treeScopeEventContext = relatedTargetEventPath->m _treeScopeEventContexts[i].get(); 233 TreeScopeEventContext* treeScopeEventContext = relatedTargetEventPath->m _treeScopeEventContexts[i].get();
234 relatedTargetMap.add(&treeScopeEventContext->treeScope(), treeScopeEvent Context->target()); 234 relatedTargetMap.add(&treeScopeEventContext->treeScope(), treeScopeEvent Context->target());
235 } 235 }
236 #if ENABLE(OILPAN) 236 #if ENABLE(OILPAN)
237 // Oilpan: It is important to explicitly clear the vectors to reuse 237 // Oilpan: It is important to explicitly clear the vectors to reuse
238 // the memory in subsequent event dispatchings. 238 // the memory in subsequent event dispatchings.
239 relatedTargetEventPath->clear(); 239 relatedTargetEventPath->clear();
240 #endif 240 #endif
241 } 241 }
242 242
243 EventTarget* EventPath::findRelatedNode(TreeScope& scope, RelatedTargetMap& rela tedTargetMap) 243 EventTarget* EventPath::findRelatedNode(TreeScope& scope, RelatedTargetMap& rela tedTargetMap)
244 { 244 {
245 WillBeHeapVector<RawPtrWillBeMember<TreeScope>, 32> parentTreeScopes; 245 HeapVector<Member<TreeScope>, 32> parentTreeScopes;
246 EventTarget* relatedNode = nullptr; 246 EventTarget* relatedNode = nullptr;
247 for (TreeScope* current = &scope; current; current = current->olderShadowRoo tOrParentTreeScope()) { 247 for (TreeScope* current = &scope; current; current = current->olderShadowRoo tOrParentTreeScope()) {
248 parentTreeScopes.append(current); 248 parentTreeScopes.append(current);
249 RelatedTargetMap::const_iterator iter = relatedTargetMap.find(current); 249 RelatedTargetMap::const_iterator iter = relatedTargetMap.find(current);
250 if (iter != relatedTargetMap.end() && iter->value) { 250 if (iter != relatedTargetMap.end() && iter->value) {
251 relatedNode = iter->value; 251 relatedNode = iter->value;
252 break; 252 break;
253 } 253 }
254 } 254 }
255 ASSERT(relatedNode); 255 ASSERT(relatedNode);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 } else if (at(i).target() == at(i).relatedTarget()) { 297 } else if (at(i).target() == at(i).relatedTarget()) {
298 // Event dispatching should be stopped here. 298 // Event dispatching should be stopped here.
299 shrink(i); 299 shrink(i);
300 break; 300 break;
301 } 301 }
302 } 302 }
303 } 303 }
304 304
305 void EventPath::adjustForTouchEvent(TouchEvent& touchEvent) 305 void EventPath::adjustForTouchEvent(TouchEvent& touchEvent)
306 { 306 {
307 WillBeHeapVector<RawPtrWillBeMember<TouchList>> adjustedTouches; 307 HeapVector<Member<TouchList>> adjustedTouches;
308 WillBeHeapVector<RawPtrWillBeMember<TouchList>> adjustedTargetTouches; 308 HeapVector<Member<TouchList>> adjustedTargetTouches;
309 WillBeHeapVector<RawPtrWillBeMember<TouchList>> adjustedChangedTouches; 309 HeapVector<Member<TouchList>> adjustedChangedTouches;
310 WillBeHeapVector<RawPtrWillBeMember<TreeScope>> treeScopes; 310 HeapVector<Member<TreeScope>> treeScopes;
311 311
312 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) { 312 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) {
313 TouchEventContext* touchEventContext = treeScopeEventContext->ensureTouc hEventContext(); 313 TouchEventContext* touchEventContext = treeScopeEventContext->ensureTouc hEventContext();
314 adjustedTouches.append(&touchEventContext->touches()); 314 adjustedTouches.append(&touchEventContext->touches());
315 adjustedTargetTouches.append(&touchEventContext->targetTouches()); 315 adjustedTargetTouches.append(&touchEventContext->targetTouches());
316 adjustedChangedTouches.append(&touchEventContext->changedTouches()); 316 adjustedChangedTouches.append(&touchEventContext->changedTouches());
317 treeScopes.append(&treeScopeEventContext->treeScope()); 317 treeScopes.append(&treeScopeEventContext->treeScope());
318 } 318 }
319 319
320 adjustTouchList(touchEvent.touches(), adjustedTouches, treeScopes); 320 adjustTouchList(touchEvent.touches(), adjustedTouches, treeScopes);
321 adjustTouchList(touchEvent.targetTouches(), adjustedTargetTouches, treeScope s); 321 adjustTouchList(touchEvent.targetTouches(), adjustedTargetTouches, treeScope s);
322 adjustTouchList(touchEvent.changedTouches(), adjustedChangedTouches, treeSco pes); 322 adjustTouchList(touchEvent.changedTouches(), adjustedChangedTouches, treeSco pes);
323 323
324 #if ENABLE(ASSERT) 324 #if ENABLE(ASSERT)
325 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) { 325 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) {
326 TreeScope& treeScope = treeScopeEventContext->treeScope(); 326 TreeScope& treeScope = treeScopeEventContext->treeScope();
327 TouchEventContext* touchEventContext = treeScopeEventContext->touchEvent Context(); 327 TouchEventContext* touchEventContext = treeScopeEventContext->touchEvent Context();
328 checkReachability(treeScope, touchEventContext->touches()); 328 checkReachability(treeScope, touchEventContext->touches());
329 checkReachability(treeScope, touchEventContext->targetTouches()); 329 checkReachability(treeScope, touchEventContext->targetTouches());
330 checkReachability(treeScope, touchEventContext->changedTouches()); 330 checkReachability(treeScope, touchEventContext->changedTouches());
331 } 331 }
332 #endif 332 #endif
333 } 333 }
334 334
335 void EventPath::adjustTouchList(const TouchList* touchList, WillBeHeapVector<Raw PtrWillBeMember<TouchList>> adjustedTouchList, const WillBeHeapVector<RawPtrWill BeMember<TreeScope>>& treeScopes) 335 void EventPath::adjustTouchList(const TouchList* touchList, HeapVector<Member<To uchList>> adjustedTouchList, const HeapVector<Member<TreeScope>>& treeScopes)
336 { 336 {
337 if (!touchList) 337 if (!touchList)
338 return; 338 return;
339 for (size_t i = 0; i < touchList->length(); ++i) { 339 for (size_t i = 0; i < touchList->length(); ++i) {
340 const Touch& touch = *touchList->item(i); 340 const Touch& touch = *touchList->item(i);
341 if (!touch.target()) 341 if (!touch.target())
342 continue; 342 continue;
343 343
344 Node* targetNode = touch.target()->toNode(); 344 Node* targetNode = touch.target()->toNode();
345 if (!targetNode) 345 if (!targetNode)
(...skipping 10 matching lines...) Expand all
356 const NodeEventContext& EventPath::topNodeEventContext() 356 const NodeEventContext& EventPath::topNodeEventContext()
357 { 357 {
358 ASSERT(!isEmpty()); 358 ASSERT(!isEmpty());
359 return last(); 359 return last();
360 } 360 }
361 361
362 void EventPath::ensureWindowEventContext() 362 void EventPath::ensureWindowEventContext()
363 { 363 {
364 ASSERT(m_event); 364 ASSERT(m_event);
365 if (!m_windowEventContext) 365 if (!m_windowEventContext)
366 m_windowEventContext = adoptPtrWillBeNoop(new WindowEventContext(*m_even t, topNodeEventContext())); 366 m_windowEventContext = new WindowEventContext(*m_event, topNodeEventCont ext());
367 } 367 }
368 368
369 #if ENABLE(ASSERT) 369 #if ENABLE(ASSERT)
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 DEFINE_TRACE(EventPath) 377 DEFINE_TRACE(EventPath)
378 { 378 {
379 #if ENABLE(OILPAN) 379 #if ENABLE(OILPAN)
380 visitor->trace(m_nodeEventContexts); 380 visitor->trace(m_nodeEventContexts);
381 visitor->trace(m_node); 381 visitor->trace(m_node);
382 visitor->trace(m_event); 382 visitor->trace(m_event);
383 visitor->trace(m_treeScopeEventContexts); 383 visitor->trace(m_treeScopeEventContexts);
384 visitor->trace(m_windowEventContext); 384 visitor->trace(m_windowEventContext);
385 #endif 385 #endif
386 } 386 }
387 387
388 } // namespace blink 388 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/EventPath.h ('k') | third_party/WebKit/Source/core/events/EventPathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698