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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 { | 131 { |
132 // Precondition: | 132 // Precondition: |
133 // - TreeScopes in m_treeScopeEventContexts must be *connected* in the sam
e tree of trees. | 133 // - TreeScopes in m_treeScopeEventContexts must be *connected* in the sam
e tree of trees. |
134 // - The root tree must be included. | 134 // - The root tree must be included. |
135 HashMap<RawPtr<const TreeScope>, RawPtr<TreeScopeEventContext> > treeScopeEv
entContextMap; | 135 HashMap<RawPtr<const TreeScope>, RawPtr<TreeScopeEventContext> > treeScopeEv
entContextMap; |
136 for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) | 136 for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) |
137 treeScopeEventContextMap.add(&m_treeScopeEventContexts[i]->treeScope(),
m_treeScopeEventContexts[i].get()); | 137 treeScopeEventContextMap.add(&m_treeScopeEventContexts[i]->treeScope(),
m_treeScopeEventContexts[i].get()); |
138 TreeScopeEventContext* rootTree = 0; | 138 TreeScopeEventContext* rootTree = 0; |
139 for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) { | 139 for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) { |
140 TreeScopeEventContext* treeScopeEventContext = m_treeScopeEventContexts[
i].get(); | 140 TreeScopeEventContext* treeScopeEventContext = m_treeScopeEventContexts[
i].get(); |
141 // Use olderShadowRootOrParentTreeScope here for parent-child relationsh
ips. | 141 // Use parentTreeScope here for parent-child relationships. |
142 // See the definition of trees of trees in the Shado DOM spec: http://w3
c.github.io/webcomponents/spec/shadow/ | 142 // See the definition of trees of trees in the Shado DOM spec: http://w3
c.github.io/webcomponents/spec/shadow/ |
143 TreeScope* parent = treeScopeEventContext->treeScope().olderShadowRootOr
ParentTreeScope(); | 143 TreeScope* parent = treeScopeEventContext->treeScope().parentTreeScope()
; |
144 if (!parent) { | 144 if (!parent) { |
145 ASSERT(!rootTree); | 145 ASSERT(!rootTree); |
146 rootTree = treeScopeEventContext; | 146 rootTree = treeScopeEventContext; |
147 continue; | 147 continue; |
148 } | 148 } |
149 ASSERT(treeScopeEventContextMap.find(parent) != treeScopeEventContextMap
.end()); | 149 ASSERT(treeScopeEventContextMap.find(parent) != treeScopeEventContextMap
.end()); |
150 treeScopeEventContextMap.find(parent)->value->addChild(*treeScopeEventCo
ntext); | 150 treeScopeEventContextMap.find(parent)->value->addChild(*treeScopeEventCo
ntext); |
151 } | 151 } |
152 ASSERT(rootTree); | 152 ASSERT(rootTree); |
153 rootTree->calculatePrePostOrderNumber(0); | 153 rootTree->calculatePrePostOrderNumber(0); |
154 } | 154 } |
155 | 155 |
156 TreeScopeEventContext* EventPath::ensureTreeScopeEventContext(Node* currentTarge
t, TreeScope* treeScope, TreeScopeEventContextMap& treeScopeEventContextMap) | 156 TreeScopeEventContext* EventPath::ensureTreeScopeEventContext(Node* currentTarge
t, TreeScope* treeScope, TreeScopeEventContextMap& treeScopeEventContextMap) |
157 { | 157 { |
158 if (!treeScope) | 158 if (!treeScope) |
159 return 0; | 159 return 0; |
160 TreeScopeEventContext* treeScopeEventContext; | 160 TreeScopeEventContext* treeScopeEventContext; |
161 bool isNewEntry; | 161 bool isNewEntry; |
162 { | 162 { |
163 TreeScopeEventContextMap::AddResult addResult = treeScopeEventContextMap
.add(treeScope, nullptr); | 163 TreeScopeEventContextMap::AddResult addResult = treeScopeEventContextMap
.add(treeScope, nullptr); |
164 isNewEntry = addResult.isNewEntry; | 164 isNewEntry = addResult.isNewEntry; |
165 if (isNewEntry) | 165 if (isNewEntry) |
166 addResult.storedValue->value = TreeScopeEventContext::create(*treeSc
ope); | 166 addResult.storedValue->value = TreeScopeEventContext::create(*treeSc
ope); |
167 treeScopeEventContext = addResult.storedValue->value.get(); | 167 treeScopeEventContext = addResult.storedValue->value.get(); |
168 } | 168 } |
169 if (isNewEntry) { | 169 if (isNewEntry) { |
170 TreeScopeEventContext* parentTreeScopeEventContext = ensureTreeScopeEven
tContext(0, treeScope->olderShadowRootOrParentTreeScope(), treeScopeEventContext
Map); | 170 TreeScopeEventContext* parentTreeScopeEventContext = ensureTreeScopeEven
tContext(0, treeScope->parentTreeScope(), treeScopeEventContextMap); |
171 if (parentTreeScopeEventContext && parentTreeScopeEventContext->target()
) { | 171 if (parentTreeScopeEventContext && parentTreeScopeEventContext->target()
) { |
172 treeScopeEventContext->setTarget(parentTreeScopeEventContext->target
()); | 172 treeScopeEventContext->setTarget(parentTreeScopeEventContext->target
()); |
173 } else if (currentTarget) { | 173 } else if (currentTarget) { |
174 treeScopeEventContext->setTarget(eventTargetRespectingTargetRules(cu
rrentTarget)); | 174 treeScopeEventContext->setTarget(eventTargetRespectingTargetRules(cu
rrentTarget)); |
175 } | 175 } |
176 } else if (!treeScopeEventContext->target() && currentTarget) { | 176 } else if (!treeScopeEventContext->target() && currentTarget) { |
177 treeScopeEventContext->setTarget(eventTargetRespectingTargetRules(curren
tTarget)); | 177 treeScopeEventContext->setTarget(eventTargetRespectingTargetRules(curren
tTarget)); |
178 } | 178 } |
179 return treeScopeEventContext; | 179 return treeScopeEventContext; |
180 } | 180 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 { | 212 { |
213 Vector<RawPtr<TreeScope>, 32> parentTreeScopes; | 213 Vector<RawPtr<TreeScope>, 32> parentTreeScopes; |
214 EventTarget* relatedNode = 0; | 214 EventTarget* relatedNode = 0; |
215 while (scope) { | 215 while (scope) { |
216 parentTreeScopes.append(scope); | 216 parentTreeScopes.append(scope); |
217 RelatedTargetMap::const_iterator iter = relatedTargetMap.find(scope); | 217 RelatedTargetMap::const_iterator iter = relatedTargetMap.find(scope); |
218 if (iter != relatedTargetMap.end() && iter->value) { | 218 if (iter != relatedTargetMap.end() && iter->value) { |
219 relatedNode = iter->value; | 219 relatedNode = iter->value; |
220 break; | 220 break; |
221 } | 221 } |
222 scope = scope->olderShadowRootOrParentTreeScope(); | 222 scope = scope->parentTreeScope(); |
223 } | 223 } |
224 ASSERT(relatedNode); | 224 ASSERT(relatedNode); |
225 for (Vector<RawPtr<TreeScope>, 32>::iterator iter = parentTreeScopes.begin()
; iter < parentTreeScopes.end(); ++iter) | 225 for (Vector<RawPtr<TreeScope>, 32>::iterator iter = parentTreeScopes.begin()
; iter < parentTreeScopes.end(); ++iter) |
226 relatedTargetMap.add(*iter, relatedNode); | 226 relatedTargetMap.add(*iter, relatedNode); |
227 return relatedNode; | 227 return relatedNode; |
228 } | 228 } |
229 | 229 |
230 void EventPath::adjustForRelatedTarget(Node* target, EventTarget* relatedTarget) | 230 void EventPath::adjustForRelatedTarget(Node* target, EventTarget* relatedTarget) |
231 { | 231 { |
232 if (!target) | 232 if (!target) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 319 |
320 #if ENABLE(ASSERT) | 320 #if ENABLE(ASSERT) |
321 void EventPath::checkReachability(TreeScope& treeScope, TouchList& touchList) | 321 void EventPath::checkReachability(TreeScope& treeScope, TouchList& touchList) |
322 { | 322 { |
323 for (size_t i = 0; i < touchList.length(); ++i) | 323 for (size_t i = 0; i < touchList.length(); ++i) |
324 ASSERT(touchList.item(i)->target()->toNode()->treeScope().isInclusiveOld
erSiblingShadowRootOrAncestorTreeScopeOf(treeScope)); | 324 ASSERT(touchList.item(i)->target()->toNode()->treeScope().isInclusiveOld
erSiblingShadowRootOrAncestorTreeScopeOf(treeScope)); |
325 } | 325 } |
326 #endif | 326 #endif |
327 | 327 |
328 } // namespace | 328 } // namespace |
OLD | NEW |