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

Unified Diff: third_party/WebKit/Source/core/html/HTMLSlotElement.cpp

Issue 1590533006: Support Slot.getAssignedNodes({flatten: true}) in a document tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v1-descendant-slots
Patch Set: rebased Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSlotElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLSlotElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp
index 2546a721aae5e2e1a731726537d169b934e837bc..230144be09fef59eae872e1986c2f5ecaaa7d010 100644
--- a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp
@@ -55,6 +55,27 @@ const WillBeHeapVector<RefPtrWillBeMember<Node>> HTMLSlotElement::getAssignedNod
return m_assignedNodes;
}
+const WillBeHeapVector<RefPtrWillBeMember<Node>>& HTMLSlotElement::getDistributedNodes()
+{
+ ASSERT(!needsDistributionRecalc());
+ if (isInShadowTree())
+ return m_distributedNodes;
+
+ // A slot is unlikely to be used outside of a shadow tree.
+ // We do not need to optimize this case in most cases.
+ // TODO(hayato): If this path causes a performance issue, we should move
+ // ShadowRootRaraDate::m_descendantSlots into TreeScopreRareData-ish and
+ // update the distribution code so it considers a document tree too.
+ clearDistribution();
+ for (Node& child : NodeTraversal::childrenOf(*this)) {
+ if (isHTMLSlotElement(child))
+ m_distributedNodes.appendVector(toHTMLSlotElement(child).getDistributedNodes());
+ else
+ m_distributedNodes.append(&child);
+ }
+ return m_distributedNodes;
+}
+
void HTMLSlotElement::appendAssignedNode(Node& node)
{
m_assignedNodes.append(&node);
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSlotElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698