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

Side by Side Diff: third_party/WebKit/Source/core/dom/shadow/FlatTreeTraversal.cpp

Issue 2460813002: Make slots in non-shadow trees participate in a flat tree (Closed)
Patch Set: update expectation Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 const Node* node, 61 const Node* node,
62 TraversalDirection direction) { 62 TraversalDirection direction) {
63 if (!node) 63 if (!node)
64 return nullptr; 64 return nullptr;
65 for (const Node* sibling = node; sibling; 65 for (const Node* sibling = node; sibling;
66 sibling = (direction == TraversalDirectionForward 66 sibling = (direction == TraversalDirectionForward
67 ? sibling->nextSibling() 67 ? sibling->nextSibling()
68 : sibling->previousSibling())) { 68 : sibling->previousSibling())) {
69 if (isHTMLSlotElement(*sibling)) { 69 if (isHTMLSlotElement(*sibling)) {
70 const HTMLSlotElement& slot = toHTMLSlotElement(*sibling); 70 const HTMLSlotElement& slot = toHTMLSlotElement(*sibling);
71 if (!slot.supportsDistribution()) { 71 if (slot.supportsDistribution()) {
72 const_cast<HTMLSlotElement&>(slot).updateDistributedNodesManually(); 72 if (Node* found = (direction == TraversalDirectionForward
73 ? slot.firstDistributedNode()
74 : slot.lastDistributedNode()))
75 return found;
76 continue;
73 } 77 }
74 if (Node* found = (direction == TraversalDirectionForward
75 ? slot.firstDistributedNode()
76 : slot.lastDistributedNode()))
77 return found;
78 continue;
79 } 78 }
80 if (node->isInV0ShadowTree()) 79 if (node->isInV0ShadowTree())
81 return v0ResolveDistributionStartingAt(*sibling, direction); 80 return v0ResolveDistributionStartingAt(*sibling, direction);
82 return const_cast<Node*>(sibling); 81 return const_cast<Node*>(sibling);
83 } 82 }
84 return nullptr; 83 return nullptr;
85 } 84 }
86 85
87 Node* FlatTreeTraversal::v0ResolveDistributionStartingAt( 86 Node* FlatTreeTraversal::v0ResolveDistributionStartingAt(
88 const Node& node, 87 const Node& node,
89 TraversalDirection direction) { 88 TraversalDirection direction) {
90 DCHECK(!isHTMLSlotElement(node)); 89 DCHECK(!isHTMLSlotElement(node) ||
90 !toHTMLSlotElement(node).supportsDistribution());
91 for (const Node* sibling = &node; sibling; 91 for (const Node* sibling = &node; sibling;
92 sibling = (direction == TraversalDirectionForward 92 sibling = (direction == TraversalDirectionForward
93 ? sibling->nextSibling() 93 ? sibling->nextSibling()
94 : sibling->previousSibling())) { 94 : sibling->previousSibling())) {
95 if (!isActiveInsertionPoint(*sibling)) 95 if (!isActiveInsertionPoint(*sibling))
96 return const_cast<Node*>(sibling); 96 return const_cast<Node*>(sibling);
97 const InsertionPoint& insertionPoint = toInsertionPoint(*sibling); 97 const InsertionPoint& insertionPoint = toInsertionPoint(*sibling);
98 if (Node* found = (direction == TraversalDirectionForward 98 if (Node* found = (direction == TraversalDirectionForward
99 ? insertionPoint.firstDistributedNode() 99 ? insertionPoint.firstDistributedNode()
100 : insertionPoint.lastDistributedNode())) 100 : insertionPoint.lastDistributedNode()))
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 if (node.isChildOfV1ShadowHost()) { 188 if (node.isChildOfV1ShadowHost()) {
189 HTMLSlotElement* slot = finalDestinationSlotFor(node); 189 HTMLSlotElement* slot = finalDestinationSlotFor(node);
190 if (!slot) 190 if (!slot)
191 return nullptr; 191 return nullptr;
192 return traverseParent(*slot); 192 return traverseParent(*slot);
193 } 193 }
194 194
195 Element* parent = node.parentElement(); 195 Element* parent = node.parentElement();
196 if (parent && isHTMLSlotElement(parent)) { 196 if (parent && isHTMLSlotElement(parent)) {
197 HTMLSlotElement& slot = toHTMLSlotElement(*parent); 197 HTMLSlotElement& slot = toHTMLSlotElement(*parent);
198 if (!slot.assignedNodes().isEmpty()) 198 if (slot.supportsDistribution()) {
199 return nullptr; 199 if (!slot.assignedNodes().isEmpty())
200 return traverseParent(slot, details); 200 return nullptr;
201 return traverseParent(slot, details);
202 }
201 } 203 }
202 204
203 if (canBeDistributedToInsertionPoint(node)) 205 if (canBeDistributedToInsertionPoint(node))
204 return traverseParentForV0(node, details); 206 return traverseParentForV0(node, details);
205 207
206 DCHECK(!shadowWhereNodeCanBeDistributedForV0(node)); 208 DCHECK(!shadowWhereNodeCanBeDistributedForV0(node));
207 return traverseParentOrHost(node); 209 return traverseParentOrHost(node);
208 } 210 }
209 211
210 ContainerNode* FlatTreeTraversal::traverseParentForV0( 212 ContainerNode* FlatTreeTraversal::traverseParentForV0(
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 383
382 Node& FlatTreeTraversal::lastWithinOrSelf(const Node& node) { 384 Node& FlatTreeTraversal::lastWithinOrSelf(const Node& node) {
383 assertPrecondition(node); 385 assertPrecondition(node);
384 Node* lastDescendant = lastWithin(node); 386 Node* lastDescendant = lastWithin(node);
385 Node& result = lastDescendant ? *lastDescendant : const_cast<Node&>(node); 387 Node& result = lastDescendant ? *lastDescendant : const_cast<Node&>(node);
386 assertPostcondition(&result); 388 assertPostcondition(&result);
387 return result; 389 return result;
388 } 390 }
389 391
390 } // namespace blink 392 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698