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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 : m_node(node) | 118 : m_node(node) |
119 , m_event(0) | 119 , m_event(0) |
120 { | 120 { |
121 resetWith(node); | 121 resetWith(node); |
122 } | 122 } |
123 | 123 |
124 void EventPath::resetWith(Node* node) | 124 void EventPath::resetWith(Node* node) |
125 { | 125 { |
126 ASSERT(node); | 126 ASSERT(node); |
127 m_node = node; | 127 m_node = node; |
128 m_eventContexts.clear(); | 128 m_nodeEventContexts.clear(); |
129 m_treeScopeEventContexts.clear(); | 129 m_treeScopeEventContexts.clear(); |
130 calculatePath(); | 130 calculatePath(); |
131 calculateAdjustedTargets(); | 131 calculateAdjustedTargets(); |
132 calculateAdjustedEventPath(); | 132 calculateAdjustedEventPath(); |
133 } | 133 } |
134 | 134 |
135 void EventPath::addEventContext(Node* node) | 135 void EventPath::addNodeEventContext(Node* node) |
136 { | 136 { |
137 m_eventContexts.append(EventContext(node, eventTargetRespectingTargetRules(n
ode))); | 137 m_nodeEventContexts.append(NodeEventContext(node, eventTargetRespectingTarge
tRules(node))); |
138 } | 138 } |
139 | 139 |
140 void EventPath::calculatePath() | 140 void EventPath::calculatePath() |
141 { | 141 { |
142 ASSERT(m_node); | 142 ASSERT(m_node); |
143 ASSERT(m_eventContexts.isEmpty()); | 143 ASSERT(m_nodeEventContexts.isEmpty()); |
144 m_node->document().updateDistributionForNodeIfNeeded(const_cast<Node*>(m_nod
e)); | 144 m_node->document().updateDistributionForNodeIfNeeded(const_cast<Node*>(m_nod
e)); |
145 | 145 |
146 Node* current = m_node; | 146 Node* current = m_node; |
147 addEventContext(current); | 147 addNodeEventContext(current); |
148 if (!m_node->inDocument()) | 148 if (!m_node->inDocument()) |
149 return; | 149 return; |
150 while (current) { | 150 while (current) { |
151 if (current->isShadowRoot() && m_event && determineDispatchBehavior(m_ev
ent, toShadowRoot(current), m_node) == StayInsideShadowDOM) | 151 if (current->isShadowRoot() && m_event && determineDispatchBehavior(m_ev
ent, toShadowRoot(current), m_node) == StayInsideShadowDOM) |
152 break; | 152 break; |
153 Vector<InsertionPoint*, 8> insertionPoints; | 153 Vector<InsertionPoint*, 8> insertionPoints; |
154 collectDestinationInsertionPoints(*current, insertionPoints); | 154 collectDestinationInsertionPoints(*current, insertionPoints); |
155 if (!insertionPoints.isEmpty()) { | 155 if (!insertionPoints.isEmpty()) { |
156 for (size_t i = 0; i < insertionPoints.size(); ++i) { | 156 for (size_t i = 0; i < insertionPoints.size(); ++i) { |
157 InsertionPoint* insertionPoint = insertionPoints[i]; | 157 InsertionPoint* insertionPoint = insertionPoints[i]; |
158 if (insertionPoint->isShadowInsertionPoint()) { | 158 if (insertionPoint->isShadowInsertionPoint()) { |
159 ShadowRoot* containingShadowRoot = insertionPoint->containin
gShadowRoot(); | 159 ShadowRoot* containingShadowRoot = insertionPoint->containin
gShadowRoot(); |
160 ASSERT(containingShadowRoot); | 160 ASSERT(containingShadowRoot); |
161 if (!containingShadowRoot->isOldest()) | 161 if (!containingShadowRoot->isOldest()) |
162 addEventContext(containingShadowRoot->olderShadowRoot())
; | 162 addNodeEventContext(containingShadowRoot->olderShadowRoo
t()); |
163 } | 163 } |
164 addEventContext(insertionPoint); | 164 addNodeEventContext(insertionPoint); |
165 } | 165 } |
166 current = insertionPoints.last(); | 166 current = insertionPoints.last(); |
167 continue; | 167 continue; |
168 } | 168 } |
169 if (current->isShadowRoot()) { | 169 if (current->isShadowRoot()) { |
170 current = current->shadowHost(); | 170 current = current->shadowHost(); |
171 addEventContext(current); | 171 addNodeEventContext(current); |
172 } else { | 172 } else { |
173 current = current->parentNode(); | 173 current = current->parentNode(); |
174 if (current) | 174 if (current) |
175 addEventContext(current); | 175 addNodeEventContext(current); |
176 } | 176 } |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 void EventPath::calculateAdjustedEventPath() | 180 void EventPath::calculateAdjustedEventPath() |
181 { | 181 { |
182 if (!RuntimeEnabledFeatures::shadowDOMEnabled()) | 182 if (!RuntimeEnabledFeatures::shadowDOMEnabled()) |
183 return; | 183 return; |
184 for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) { | 184 for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) { |
185 TreeScopeEventContext* treeScopeEventContext = m_treeScopeEventContexts[
i].get(); | 185 TreeScopeEventContext* treeScopeEventContext = m_treeScopeEventContexts[
i].get(); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 | 377 |
378 #ifndef NDEBUG | 378 #ifndef NDEBUG |
379 void EventPath::checkReachability(TreeScope& treeScope, TouchList& touchList) | 379 void EventPath::checkReachability(TreeScope& treeScope, TouchList& touchList) |
380 { | 380 { |
381 for (size_t i = 0; i < touchList.length(); ++i) | 381 for (size_t i = 0; i < touchList.length(); ++i) |
382 ASSERT(touchList.item(i)->target()->toNode()->treeScope().isInclusiveAnc
estorOf(treeScope)); | 382 ASSERT(touchList.item(i)->target()->toNode()->treeScope().isInclusiveAnc
estorOf(treeScope)); |
383 } | 383 } |
384 #endif | 384 #endif |
385 | 385 |
386 } // namespace | 386 } // namespace |
OLD | NEW |