| OLD | NEW |
| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } else if (at(i).target() == at(i).relatedTarget()) { | 317 } else if (at(i).target() == at(i).relatedTarget()) { |
| 318 // Event dispatching should be stopped here. | 318 // Event dispatching should be stopped here. |
| 319 shrink(i); | 319 shrink(i); |
| 320 break; | 320 break; |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 } | 323 } |
| 324 | 324 |
| 325 void EventPath::adjustForTouchEvent(Node* node, TouchEvent& touchEvent) | 325 void EventPath::adjustForTouchEvent(Node* node, TouchEvent& touchEvent) |
| 326 { | 326 { |
| 327 Vector<TouchList*> adjustedTouches; | 327 WillBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedTouches; |
| 328 Vector<TouchList*> adjustedTargetTouches; | 328 WillBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedTargetTouches; |
| 329 Vector<TouchList*> adjustedChangedTouches; | 329 WillBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedChangedTouches; |
| 330 Vector<TreeScope*> treeScopes; | 330 Vector<TreeScope*> treeScopes; |
| 331 | 331 |
| 332 for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) { | 332 for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) { |
| 333 TouchEventContext* touchEventContext = m_treeScopeEventContexts[i]->ensu
reTouchEventContext(); | 333 TouchEventContext* touchEventContext = m_treeScopeEventContexts[i]->ensu
reTouchEventContext(); |
| 334 adjustedTouches.append(&touchEventContext->touches()); | 334 adjustedTouches.append(&touchEventContext->touches()); |
| 335 adjustedTargetTouches.append(&touchEventContext->targetTouches()); | 335 adjustedTargetTouches.append(&touchEventContext->targetTouches()); |
| 336 adjustedChangedTouches.append(&touchEventContext->changedTouches()); | 336 adjustedChangedTouches.append(&touchEventContext->changedTouches()); |
| 337 treeScopes.append(&m_treeScopeEventContexts[i]->treeScope()); | 337 treeScopes.append(&m_treeScopeEventContexts[i]->treeScope()); |
| 338 } | 338 } |
| 339 | 339 |
| 340 adjustTouchList(node, touchEvent.touches(), adjustedTouches, treeScopes); | 340 adjustTouchList(node, touchEvent.touches(), adjustedTouches, treeScopes); |
| 341 adjustTouchList(node, touchEvent.targetTouches(), adjustedTargetTouches, tre
eScopes); | 341 adjustTouchList(node, touchEvent.targetTouches(), adjustedTargetTouches, tre
eScopes); |
| 342 adjustTouchList(node, touchEvent.changedTouches(), adjustedChangedTouches, t
reeScopes); | 342 adjustTouchList(node, touchEvent.changedTouches(), adjustedChangedTouches, t
reeScopes); |
| 343 | 343 |
| 344 #ifndef NDEBUG | 344 #ifndef NDEBUG |
| 345 for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) { | 345 for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) { |
| 346 TreeScope& treeScope = m_treeScopeEventContexts[i]->treeScope(); | 346 TreeScope& treeScope = m_treeScopeEventContexts[i]->treeScope(); |
| 347 TouchEventContext* touchEventContext = m_treeScopeEventContexts[i]->touc
hEventContext(); | 347 TouchEventContext* touchEventContext = m_treeScopeEventContexts[i]->touc
hEventContext(); |
| 348 checkReachability(treeScope, touchEventContext->touches()); | 348 checkReachability(treeScope, touchEventContext->touches()); |
| 349 checkReachability(treeScope, touchEventContext->targetTouches()); | 349 checkReachability(treeScope, touchEventContext->targetTouches()); |
| 350 checkReachability(treeScope, touchEventContext->changedTouches()); | 350 checkReachability(treeScope, touchEventContext->changedTouches()); |
| 351 } | 351 } |
| 352 #endif | 352 #endif |
| 353 } | 353 } |
| 354 | 354 |
| 355 void EventPath::adjustTouchList(const Node* node, const TouchList* touchList, Ve
ctor<TouchList*> adjustedTouchList, const Vector<TreeScope*>& treeScopes) | 355 void EventPath::adjustTouchList(const Node* node, const TouchList* touchList, Wi
llBeHeapVector<RawPtrWillBeMember<TouchList> > adjustedTouchList, const Vector<T
reeScope*>& treeScopes) |
| 356 { | 356 { |
| 357 if (!touchList) | 357 if (!touchList) |
| 358 return; | 358 return; |
| 359 for (size_t i = 0; i < touchList->length(); ++i) { | 359 for (size_t i = 0; i < touchList->length(); ++i) { |
| 360 const Touch& touch = *touchList->item(i); | 360 const Touch& touch = *touchList->item(i); |
| 361 RelatedTargetMap relatedNodeMap; | 361 RelatedTargetMap relatedNodeMap; |
| 362 buildRelatedNodeMap(touch.target()->toNode(), relatedNodeMap); | 362 buildRelatedNodeMap(touch.target()->toNode(), relatedNodeMap); |
| 363 for (size_t j = 0; j < treeScopes.size(); ++j) { | 363 for (size_t j = 0; j < treeScopes.size(); ++j) { |
| 364 adjustedTouchList[j]->append(touch.cloneWithNewTarget(findRelatedNod
e(treeScopes[j], relatedNodeMap))); | 364 adjustedTouchList[j]->append(touch.cloneWithNewTarget(findRelatedNod
e(treeScopes[j], relatedNodeMap))); |
| 365 } | 365 } |
| 366 } | 366 } |
| 367 } | 367 } |
| 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 |
| OLD | NEW |