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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 if (HTMLSlotElement* slot = current->assignedSlot()) { | 124 if (HTMLSlotElement* slot = current->assignedSlot()) { |
125 current = slot; | 125 current = slot; |
126 nodesInPath.append(current); | 126 nodesInPath.append(current); |
127 continue; | 127 continue; |
128 } | 128 } |
129 } | 129 } |
130 if (current->isShadowRoot()) { | 130 if (current->isShadowRoot()) { |
131 if (m_event && shouldStopAtShadowRoot(*m_event, *toShadowRoot(curren
t), *m_node)) | 131 if (m_event && shouldStopAtShadowRoot(*m_event, *toShadowRoot(curren
t), *m_node)) |
132 break; | 132 break; |
133 current = current->shadowHost(); | 133 current = current->shadowHost(); |
134 #if !ENABLE(OILPAN) | |
135 // TODO(kochi): crbug.com/507413 This check is necessary when some a
synchronous event | |
136 // is queued while its shadow host is removed and the shadow root ge
ts the event | |
137 // immediately after it. When Oilpan is enabled, this situation doe
s not happen. | |
138 // Except this case, shadow root's host is assumed to be non-null. | |
139 if (current) | |
140 nodesInPath.append(current); | |
141 #else | |
142 nodesInPath.append(current); | 134 nodesInPath.append(current); |
143 #endif | |
144 } else { | 135 } else { |
145 current = current->parentNode(); | 136 current = current->parentNode(); |
146 if (current) | 137 if (current) |
147 nodesInPath.append(current); | 138 nodesInPath.append(current); |
148 } | 139 } |
149 } | 140 } |
150 | 141 |
151 m_nodeEventContexts.reserveCapacity(nodesInPath.size()); | 142 m_nodeEventContexts.reserveCapacity(nodesInPath.size()); |
152 for (Node* nodeInPath : nodesInPath) { | 143 for (Node* nodeInPath : nodesInPath) { |
153 m_nodeEventContexts.append(NodeEventContext(nodeInPath, eventTargetRespe
ctingTargetRules(*nodeInPath))); | 144 m_nodeEventContexts.append(NodeEventContext(nodeInPath, eventTargetRespe
ctingTargetRules(*nodeInPath))); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 m_treeScopeEventContexts.appendRange(treeScopeEventContextMap.values().begin
(), treeScopeEventContextMap.values().end()); | 217 m_treeScopeEventContexts.appendRange(treeScopeEventContextMap.values().begin
(), treeScopeEventContextMap.values().end()); |
227 } | 218 } |
228 | 219 |
229 void EventPath::buildRelatedNodeMap(const Node& relatedNode, RelatedTargetMap& r
elatedTargetMap) | 220 void EventPath::buildRelatedNodeMap(const Node& relatedNode, RelatedTargetMap& r
elatedTargetMap) |
230 { | 221 { |
231 EventPath* relatedTargetEventPath = new EventPath(const_cast<Node&>(relatedN
ode)); | 222 EventPath* relatedTargetEventPath = new EventPath(const_cast<Node&>(relatedN
ode)); |
232 for (size_t i = 0; i < relatedTargetEventPath->m_treeScopeEventContexts.size
(); ++i) { | 223 for (size_t i = 0; i < relatedTargetEventPath->m_treeScopeEventContexts.size
(); ++i) { |
233 TreeScopeEventContext* treeScopeEventContext = relatedTargetEventPath->m
_treeScopeEventContexts[i].get(); | 224 TreeScopeEventContext* treeScopeEventContext = relatedTargetEventPath->m
_treeScopeEventContexts[i].get(); |
234 relatedTargetMap.add(&treeScopeEventContext->treeScope(), treeScopeEvent
Context->target()); | 225 relatedTargetMap.add(&treeScopeEventContext->treeScope(), treeScopeEvent
Context->target()); |
235 } | 226 } |
236 #if ENABLE(OILPAN) | |
237 // Oilpan: It is important to explicitly clear the vectors to reuse | 227 // Oilpan: It is important to explicitly clear the vectors to reuse |
238 // the memory in subsequent event dispatchings. | 228 // the memory in subsequent event dispatchings. |
239 relatedTargetEventPath->clear(); | 229 relatedTargetEventPath->clear(); |
240 #endif | |
241 } | 230 } |
242 | 231 |
243 EventTarget* EventPath::findRelatedNode(TreeScope& scope, RelatedTargetMap& rela
tedTargetMap) | 232 EventTarget* EventPath::findRelatedNode(TreeScope& scope, RelatedTargetMap& rela
tedTargetMap) |
244 { | 233 { |
245 HeapVector<Member<TreeScope>, 32> parentTreeScopes; | 234 HeapVector<Member<TreeScope>, 32> parentTreeScopes; |
246 EventTarget* relatedNode = nullptr; | 235 EventTarget* relatedNode = nullptr; |
247 for (TreeScope* current = &scope; current; current = current->olderShadowRoo
tOrParentTreeScope()) { | 236 for (TreeScope* current = &scope; current; current = current->olderShadowRoo
tOrParentTreeScope()) { |
248 parentTreeScopes.append(current); | 237 parentTreeScopes.append(current); |
249 RelatedTargetMap::const_iterator iter = relatedTargetMap.find(current); | 238 RelatedTargetMap::const_iterator iter = relatedTargetMap.find(current); |
250 if (iter != relatedTargetMap.end() && iter->value) { | 239 if (iter != relatedTargetMap.end() && iter->value) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 DEFINE_TRACE(EventPath) | 366 DEFINE_TRACE(EventPath) |
378 { | 367 { |
379 visitor->trace(m_nodeEventContexts); | 368 visitor->trace(m_nodeEventContexts); |
380 visitor->trace(m_node); | 369 visitor->trace(m_node); |
381 visitor->trace(m_event); | 370 visitor->trace(m_event); |
382 visitor->trace(m_treeScopeEventContexts); | 371 visitor->trace(m_treeScopeEventContexts); |
383 visitor->trace(m_windowEventContext); | 372 visitor->trace(m_windowEventContext); |
384 } | 373 } |
385 | 374 |
386 } // namespace blink | 375 } // namespace blink |
OLD | NEW |