Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: Source/core/events/EventPath.cpp

Issue 59903015: [Shadow DOM]: Empty shadow insertion points should behave like <shadow><content *leftover*></conten… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/shadow/ElementShadow.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 Vector<RefPtr<Node> > nodes; 197 Vector<RefPtr<Node> > nodes;
198 for (size_t j = 0; j < size(); ++j) { 198 for (size_t j = 0; j < size(); ++j) {
199 if (at(j).node()->treeScope().isInclusiveAncestorOf(*currentScope)) 199 if (at(j).node()->treeScope().isInclusiveAncestorOf(*currentScope))
200 nodes.append(at(j).node()); 200 nodes.append(at(j).node());
201 } 201 }
202 at(i).adoptEventPath(nodes); 202 at(i).adoptEventPath(nodes);
203 } 203 }
204 } 204 }
205 205
206 #ifndef NDEBUG 206 #ifndef NDEBUG
207 static inline bool movedFromChildToParent(const TreeScope& lastTreeScope, const TreeScope& currentTreeScope)
208 {
209 return lastTreeScope.parentTreeScope() == &currentTreeScope;
210 }
211
212 static inline bool movedFromOlderToYounger(const TreeScope& lastTreeScope, const TreeScope& currentTreeScope) 207 static inline bool movedFromOlderToYounger(const TreeScope& lastTreeScope, const TreeScope& currentTreeScope)
213 { 208 {
214 Node* rootNode = lastTreeScope.rootNode(); 209 Node* rootNode = lastTreeScope.rootNode();
215 return rootNode->isShadowRoot() && toShadowRoot(rootNode)->youngerShadowRoot () == currentTreeScope.rootNode(); 210 return rootNode->isShadowRoot() && toShadowRoot(rootNode)->youngerShadowRoot () == currentTreeScope.rootNode();
216 } 211 }
217 #endif
218
219 static inline bool movedFromParentToChild(const TreeScope& lastTreeScope, const TreeScope& currentTreeScope)
220 {
221 return currentTreeScope.parentTreeScope() == &lastTreeScope;
222 }
223 212
224 static inline bool movedFromYoungerToOlder(const TreeScope& lastTreeScope, const TreeScope& currentTreeScope) 213 static inline bool movedFromYoungerToOlder(const TreeScope& lastTreeScope, const TreeScope& currentTreeScope)
225 { 214 {
226 Node* rootNode = lastTreeScope.rootNode(); 215 Node* rootNode = lastTreeScope.rootNode();
227 return rootNode->isShadowRoot() && toShadowRoot(rootNode)->olderShadowRoot() == currentTreeScope.rootNode(); 216 return rootNode->isShadowRoot() && toShadowRoot(rootNode)->olderShadowRoot() == currentTreeScope.rootNode();
228 } 217 }
218 #endif
219
220 static inline bool movedFromChildToParent(const TreeScope& lastTreeScope, const TreeScope& currentTreeScope)
221 {
222 return lastTreeScope.parentTreeScope() == &currentTreeScope;
223 }
224
225 static inline bool movedFromParentToChild(const TreeScope& lastTreeScope, const TreeScope& currentTreeScope)
226 {
227 return currentTreeScope.parentTreeScope() == &lastTreeScope;
228 }
229 229
230 void EventPath::calculateAdjustedTargets() 230 void EventPath::calculateAdjustedTargets()
231 { 231 {
232 Vector<Node*, 32> targetStack; 232 Vector<Node*, 32> targetStack;
233 const TreeScope* lastTreeScope = 0; 233 const TreeScope* lastTreeScope = 0;
234 bool isSVGElement = at(0).node()->isSVGElement(); 234 bool isSVGElement = at(0).node()->isSVGElement();
235 235
236 for (size_t i = 0; i < size(); ++i) { 236 for (size_t i = 0; i < size(); ++i) {
237 Node* current = at(i).node(); 237 Node* current = at(i).node();
238 const TreeScope& currentTreeScope = current->treeScope(); 238 const TreeScope& currentTreeScope = current->treeScope();
239 if (targetStack.isEmpty()) { 239 if (targetStack.isEmpty()) {
240 targetStack.append(current); 240 targetStack.append(current);
241 } else if (*lastTreeScope != currentTreeScope && !isSVGElement) { 241 } else if (*lastTreeScope != currentTreeScope && !isSVGElement) {
242 if (movedFromParentToChild(*lastTreeScope, currentTreeScope) || move dFromYoungerToOlder(*lastTreeScope, currentTreeScope)) { 242 if (movedFromParentToChild(*lastTreeScope, currentTreeScope)) {
243 targetStack.append(targetStack.last()); 243 targetStack.append(targetStack.last());
244 } else { 244 } else if (movedFromChildToParent(*lastTreeScope, currentTreeScope)) {
245 ASSERT(movedFromChildToParent(*lastTreeScope, currentTreeScope) || movedFromOlderToYounger(*lastTreeScope, currentTreeScope));
246 ASSERT(!targetStack.isEmpty()); 245 ASSERT(!targetStack.isEmpty());
247 targetStack.removeLast(); 246 targetStack.removeLast();
248 if (targetStack.isEmpty()) 247 if (targetStack.isEmpty())
249 targetStack.append(current); 248 targetStack.append(current);
249 } else {
250 ASSERT(movedFromYoungerToOlder(*lastTreeScope, currentTreeScope) || movedFromOlderToYounger(*lastTreeScope, currentTreeScope));
251 ASSERT(!targetStack.isEmpty());
252 targetStack.removeLast();
253 if (targetStack.isEmpty())
254 targetStack.append(current);
255 else
256 targetStack.append(targetStack.last());
250 } 257 }
251 } 258 }
252 at(i).setTarget(eventTargetRespectingTargetRules(targetStack.last())); 259 at(i).setTarget(eventTargetRespectingTargetRules(targetStack.last()));
253 lastTreeScope = &currentTreeScope; 260 lastTreeScope = &currentTreeScope;
254 } 261 }
255 } 262 }
256 263
257 } // namespace 264 } // namespace
OLDNEW
« no previous file with comments | « Source/core/dom/shadow/ElementShadow.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698