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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLSlotElement.cpp

Issue 1671823002: Restrict the types of nodes that could be assigned to a slot. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 10 months 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/shadow/SlotAssignment.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) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 if (isInShadowTree()) 61 if (isInShadowTree())
62 return m_distributedNodes; 62 return m_distributedNodes;
63 63
64 // A slot is unlikely to be used outside of a shadow tree. 64 // A slot is unlikely to be used outside of a shadow tree.
65 // We do not need to optimize this case in most cases. 65 // We do not need to optimize this case in most cases.
66 // TODO(hayato): If this path causes a performance issue, we should move 66 // TODO(hayato): If this path causes a performance issue, we should move
67 // ShadowRootRaraDate::m_descendantSlots into TreeScopreRareData-ish and 67 // ShadowRootRaraDate::m_descendantSlots into TreeScopreRareData-ish and
68 // update the distribution code so it considers a document tree too. 68 // update the distribution code so it considers a document tree too.
69 clearDistribution(); 69 clearDistribution();
70 for (Node& child : NodeTraversal::childrenOf(*this)) { 70 for (Node& child : NodeTraversal::childrenOf(*this)) {
71 if (!child.isSlotAssignable())
72 continue;
71 if (isHTMLSlotElement(child)) 73 if (isHTMLSlotElement(child))
72 m_distributedNodes.appendVector(toHTMLSlotElement(child).getDistribu tedNodes()); 74 m_distributedNodes.appendVector(toHTMLSlotElement(child).getDistribu tedNodes());
73 else 75 else
74 m_distributedNodes.append(&child); 76 m_distributedNodes.append(&child);
75 } 77 }
76 return m_distributedNodes; 78 return m_distributedNodes;
77 } 79 }
78 80
79 void HTMLSlotElement::appendAssignedNode(Node& node) 81 void HTMLSlotElement::appendAssignedNode(Node& node)
80 { 82 {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 root->didRemoveSlot(); 199 root->didRemoveSlot();
198 200
199 HTMLElement::removedFrom(insertionPoint); 201 HTMLElement::removedFrom(insertionPoint);
200 } 202 }
201 203
202 void HTMLSlotElement::updateDistributedNodesWithFallback() 204 void HTMLSlotElement::updateDistributedNodesWithFallback()
203 { 205 {
204 if (!m_distributedNodes.isEmpty()) 206 if (!m_distributedNodes.isEmpty())
205 return; 207 return;
206 for (auto& child : NodeTraversal::childrenOf(*this)) { 208 for (auto& child : NodeTraversal::childrenOf(*this)) {
209 if (!child.isSlotAssignable())
210 continue;
207 // Insertion points are not supported as slots fallback 211 // Insertion points are not supported as slots fallback
208 if (isActiveInsertionPoint(child)) 212 if (isActiveInsertionPoint(child))
209 continue; 213 continue;
210 if (isHTMLSlotElement(child)) 214 if (isHTMLSlotElement(child))
211 appendDistributedNodesFrom(toHTMLSlotElement(child)); 215 appendDistributedNodesFrom(toHTMLSlotElement(child));
212 else 216 else
213 appendDistributedNode(child); 217 appendDistributedNode(child);
214 } 218 }
215 } 219 }
216 220
217 DEFINE_TRACE(HTMLSlotElement) 221 DEFINE_TRACE(HTMLSlotElement)
218 { 222 {
219 #if ENABLE(OILPAN) 223 #if ENABLE(OILPAN)
220 visitor->trace(m_assignedNodes); 224 visitor->trace(m_assignedNodes);
221 visitor->trace(m_distributedNodes); 225 visitor->trace(m_distributedNodes);
222 visitor->trace(m_distributedIndices); 226 visitor->trace(m_distributedIndices);
223 #endif 227 #endif
224 HTMLElement::trace(visitor); 228 HTMLElement::trace(visitor);
225 } 229 }
226 230
227 } // namespace blink 231 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/shadow/SlotAssignment.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698