| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/input/BoundaryEventDispatcher.h" | 5 #include "core/input/BoundaryEventDispatcher.h" |
| 6 | 6 |
| 7 #include "core/dom/Node.h" | 7 #include "core/dom/Node.h" |
| 8 #include "core/dom/shadow/FlatTreeTraversal.h" | 8 #include "core/dom/shadow/FlatTreeTraversal.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 bool isInDocument(EventTarget* target) { | 14 bool isInDocument(EventTarget* target) { |
| 15 return target && target->toNode() && target->toNode()->isConnected(); | 15 return target && target->toNode() && target->toNode()->isConnected(); |
| 16 } | 16 } |
| 17 | 17 |
| 18 void buildAncestorChain(EventTarget* target, | 18 void buildAncestorChain(EventTarget* target, |
| 19 HeapVector<Member<Node>, 20>* ancestors) { | 19 HeapVector<Member<Node>, 20>* ancestors) { |
| 20 if (!isInDocument(target)) | 20 if (!isInDocument(target)) |
| 21 return; | 21 return; |
| 22 Node* targetNode = target->toNode(); | 22 Node* targetNode = target->toNode(); |
| 23 DCHECK(targetNode); | 23 DCHECK(targetNode); |
| 24 targetNode->updateDistribution(); | 24 targetNode->updateDistribution(); |
| 25 // Index 0 element in the ancestors arrays will be the corresponding | 25 // Index 0 element in the ancestors arrays will be the corresponding |
| 26 // target. So the root of their document will be their last element. | 26 // target. So the root of their document will be their last element. |
| 27 for (Node* node = targetNode; node; node = FlatTreeTraversal::parent(*node)) | 27 for (Node* node = targetNode; node; node = FlatTreeTraversal::parent(*node)) |
| 28 ancestors->append(node); | 28 ancestors->push_back(node); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void buildAncestorChainsAndFindCommonAncestors( | 31 void buildAncestorChainsAndFindCommonAncestors( |
| 32 EventTarget* exitedTarget, | 32 EventTarget* exitedTarget, |
| 33 EventTarget* enteredTarget, | 33 EventTarget* enteredTarget, |
| 34 HeapVector<Member<Node>, 20>* exitedAncestorsOut, | 34 HeapVector<Member<Node>, 20>* exitedAncestorsOut, |
| 35 HeapVector<Member<Node>, 20>* enteredAncestorsOut, | 35 HeapVector<Member<Node>, 20>* enteredAncestorsOut, |
| 36 size_t* exitedAncestorsCommonParentIndexOut, | 36 size_t* exitedAncestorsCommonParentIndexOut, |
| 37 size_t* enteredAncestorsCommonParentIndexOut) { | 37 size_t* enteredAncestorsCommonParentIndexOut) { |
| 38 DCHECK(exitedAncestorsOut); | 38 DCHECK(exitedAncestorsOut); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 // Dispatch enter events, in parent-to-child order. | 129 // Dispatch enter events, in parent-to-child order. |
| 130 for (size_t i = enteredAncestorsCommonParentIndex; i > 0; i--) | 130 for (size_t i = enteredAncestorsCommonParentIndex; i > 0; i--) |
| 131 dispatchEnter(enteredAncestors[i - 1], exitedTarget, | 131 dispatchEnter(enteredAncestors[i - 1], exitedTarget, |
| 132 !enteredNodeHasCapturingAncestor); | 132 !enteredNodeHasCapturingAncestor); |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace blink | 135 } // namespace blink |
| OLD | NEW |