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

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

Issue 1489433002: Support the essential part of Shadow DOM v1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert Internals.* Created 5 years 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
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 8fe40abce5dc806bdfebd6c90c9dc9eac8f74458..57e12cdf66c11d1110710dc922d8aee4b3414593 100644
--- a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp
@@ -37,22 +37,72 @@ namespace blink {
using namespace HTMLNames;
-PassRefPtrWillBeRawPtr<HTMLSlotElement> HTMLSlotElement::create(Document& document)
+inline HTMLSlotElement::HTMLSlotElement(Document& document)
+ : HTMLElement(slotTag, document)
{
- return adoptRefWillBeNoop(new HTMLSlotElement(document));
}
-inline HTMLSlotElement::HTMLSlotElement(Document& document)
- : HTMLElement(slotTag, document)
+DEFINE_NODE_FACTORY(HTMLSlotElement);
+
+void HTMLSlotElement::appendAssignedNode(Node& node)
{
+ m_assignedNodes.append(&node);
}
-HTMLSlotElement::~HTMLSlotElement()
+void HTMLSlotElement::appendDistributedNode(Node& node)
{
+ m_distributedNodes.append(&node);
+}
+
+void HTMLSlotElement::appendDistributedNodes(const WillBeHeapVector<RefPtrWillBeMember<Node>>& nodes)
+{
+ m_distributedNodes.appendVector(nodes);
+}
+
+void HTMLSlotElement::clearDistribution()
+{
+ m_assignedNodes.clear();
+ m_distributedNodes.clear();
+}
+
+Node* HTMLSlotElement::distributedNodeNextTo(const Node& node) const
+{
+ size_t index = m_distributedNodes.find(&node);
+ if (index == kNotFound || index + 1 == m_distributedNodes.size())
+ return nullptr;
+ return m_distributedNodes[index + 1].get();
+}
+
+Node* HTMLSlotElement::distributedNodePreviousTo(const Node& node) const
+{
+ size_t index = m_distributedNodes.find(&node);
+ if (index == kNotFound || index == 0)
+ return nullptr;
+ return m_distributedNodes[index - 1].get();
+}
+
+void HTMLSlotElement::attach(const AttachContext& context)
+{
+ for (auto& node : m_distributedNodes) {
+ if (node->needsAttach())
+ node->attach(context);
+ }
+
+ HTMLElement::attach(context);
+}
+
+void HTMLSlotElement::detach(const AttachContext& context)
+{
+ for (auto& node : m_distributedNodes)
+ node->lazyReattachIfAttached();
+
+ HTMLElement::detach(context);
}
DEFINE_TRACE(HTMLSlotElement)
{
+ visitor->trace(m_assignedNodes);
+ visitor->trace(m_distributedNodes);
HTMLElement::trace(visitor);
}
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSlotElement.h ('k') | third_party/WebKit/Source/core/html/HTMLSlotElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698