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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 initialize(); | 81 initialize(); |
82 } | 82 } |
83 | 83 |
84 void EventPath::initialize() | 84 void EventPath::initialize() |
85 { | 85 { |
86 calculatePath(); | 86 calculatePath(); |
87 calculateAdjustedTargets(); | 87 calculateAdjustedTargets(); |
88 calculateTreeScopePrePostOrderNumbers(); | 88 calculateTreeScopePrePostOrderNumbers(); |
89 } | 89 } |
90 | 90 |
91 void EventPath::addNodeEventContext(Node& node) | |
92 { | |
93 m_nodeEventContexts.append(NodeEventContext(&node, eventTargetRespectingTarg etRules(node))); | |
94 } | |
95 | |
96 void EventPath::calculatePath() | 91 void EventPath::calculatePath() |
97 { | 92 { |
98 ASSERT(m_node); | 93 ASSERT(m_node); |
99 ASSERT(m_nodeEventContexts.isEmpty()); | 94 ASSERT(m_nodeEventContexts.isEmpty()); |
100 m_node->updateDistribution(); | 95 m_node->updateDistribution(); |
101 | 96 |
97 Vector<Node*, 256> nodesInPath; | |
sof
2015/05/19 07:16:19
Make this WillBeHeapVector<RawPtrWillBeMember<Node
Daniel Bratell
2015/05/19 08:11:42
Done.
| |
102 Node* current = m_node; | 98 Node* current = m_node; |
103 addNodeEventContext(*current); | 99 nodesInPath.append(current); |
104 if (!m_node->inDocument()) | 100 if (!m_node->inDocument()) |
105 return; | 101 current = nullptr; |
106 while (current) { | 102 while (current) { |
107 if (m_event && current->keepEventInNode(m_event)) | 103 if (m_event && current->keepEventInNode(m_event)) |
108 break; | 104 break; |
109 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints; | 105 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints; |
110 collectDestinationInsertionPoints(*current, insertionPoints); | 106 collectDestinationInsertionPoints(*current, insertionPoints); |
111 if (!insertionPoints.isEmpty()) { | 107 if (!insertionPoints.isEmpty()) { |
112 for (const auto& insertionPoint : insertionPoints) { | 108 for (const auto& insertionPoint : insertionPoints) { |
113 if (insertionPoint->isShadowInsertionPoint()) { | 109 if (insertionPoint->isShadowInsertionPoint()) { |
114 ShadowRoot* containingShadowRoot = insertionPoint->containin gShadowRoot(); | 110 ShadowRoot* containingShadowRoot = insertionPoint->containin gShadowRoot(); |
115 ASSERT(containingShadowRoot); | 111 ASSERT(containingShadowRoot); |
116 if (!containingShadowRoot->isOldest()) | 112 if (!containingShadowRoot->isOldest()) |
117 addNodeEventContext(*containingShadowRoot->olderShadowRo ot()); | 113 nodesInPath.append(containingShadowRoot->olderShadowRoot ()); |
118 } | 114 } |
119 addNodeEventContext(*insertionPoint); | 115 nodesInPath.append(insertionPoint); |
120 } | 116 } |
121 current = insertionPoints.last(); | 117 current = insertionPoints.last(); |
122 continue; | 118 continue; |
123 } | 119 } |
124 if (current->isShadowRoot()) { | 120 if (current->isShadowRoot()) { |
125 if (m_event && shouldStopAtShadowRoot(*m_event, *toShadowRoot(curren t), *m_node)) | 121 if (m_event && shouldStopAtShadowRoot(*m_event, *toShadowRoot(curren t), *m_node)) |
126 break; | 122 break; |
127 current = current->shadowHost(); | 123 current = current->shadowHost(); |
128 addNodeEventContext(*current); | 124 nodesInPath.append(current); |
129 } else { | 125 } else { |
130 current = current->parentNode(); | 126 current = current->parentNode(); |
131 if (current) | 127 if (current) |
132 addNodeEventContext(*current); | 128 nodesInPath.append(current); |
133 } | 129 } |
134 } | 130 } |
131 | |
132 ASSERT(m_nodeEventContexts.size() == 0); | |
hayato
2015/05/19 06:45:29
We don't need this ASSERT since L94 already assert
Daniel Bratell
2015/05/19 08:11:42
Done.
| |
133 m_nodeEventContexts.reserveCapacity(nodesInPath.size()); | |
134 for (Node* nodeInPath : nodesInPath) { | |
135 m_nodeEventContexts.append(NodeEventContext(nodeInPath, eventTargetRespe ctingTargetRules(*nodeInPath))); | |
136 } | |
135 } | 137 } |
136 | 138 |
137 void EventPath::calculateTreeScopePrePostOrderNumbers() | 139 void EventPath::calculateTreeScopePrePostOrderNumbers() |
138 { | 140 { |
139 // Precondition: | 141 // Precondition: |
140 // - TreeScopes in m_treeScopeEventContexts must be *connected* in the sam e tree of trees. | 142 // - TreeScopes in m_treeScopeEventContexts must be *connected* in the sam e tree of trees. |
141 // - The root tree must be included. | 143 // - The root tree must be included. |
142 WillBeHeapHashMap<RawPtrWillBeMember<const TreeScope>, RawPtrWillBeMember<Tr eeScopeEventContext>> treeScopeEventContextMap; | 144 WillBeHeapHashMap<RawPtrWillBeMember<const TreeScope>, RawPtrWillBeMember<Tr eeScopeEventContext>> treeScopeEventContextMap; |
143 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) | 145 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) |
144 treeScopeEventContextMap.add(&treeScopeEventContext->treeScope(), treeSc opeEventContext.get()); | 146 treeScopeEventContextMap.add(&treeScopeEventContext->treeScope(), treeSc opeEventContext.get()); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 DEFINE_TRACE(EventPath) | 350 DEFINE_TRACE(EventPath) |
349 { | 351 { |
350 visitor->trace(m_nodeEventContexts); | 352 visitor->trace(m_nodeEventContexts); |
351 visitor->trace(m_node); | 353 visitor->trace(m_node); |
352 visitor->trace(m_event); | 354 visitor->trace(m_event); |
353 visitor->trace(m_treeScopeEventContexts); | 355 visitor->trace(m_treeScopeEventContexts); |
354 visitor->trace(m_windowEventContext); | 356 visitor->trace(m_windowEventContext); |
355 } | 357 } |
356 | 358 |
357 } // namespace | 359 } // namespace |
OLD | NEW |