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

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp

Issue 2023093003: Upgrade in-document custom elements when an element is defined. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ASAN failure in test helper. Created 4 years, 7 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
Index: third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp
index 0e9fb986ac4b248e3d095790b443e4d0ebf698e0..4c7626d3171b1e9405d056961fc2d425cf1a3e6d 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.cpp
@@ -16,4 +16,42 @@ CustomElementDefinition::~CustomElementDefinition()
{
}
+DEFINE_TRACE(CustomElementDefinition)
+{
+ visitor->trace(m_constructionStack);
+}
+
+// https://html.spec.whatwg.org/multipage/scripting.html#concept-upgrade-an-element
+void CustomElementDefinition::upgrade(Element* element)
+{
+ m_constructionStack.append(element);
+ size_t depth = m_constructionStack.size();
+
+ bool succeeded = runConstructor(element);
+
+ // Pop the construction stack.
+ if (m_constructionStack.last().get())
+ DCHECK_EQ(m_constructionStack.last(), element);
+ DCHECK_EQ(m_constructionStack.size(), depth); // It's a *stack*.
+ m_constructionStack.removeLast();
+
+ if (!succeeded)
+ return;
+
+ // TODO(dominicc): Turn this into an assertion when setting
+ // 'custom' moves to the HTMLElement constructor. We will need to
+ // add a bit for MARQUEE to be custom-gets-callbacks-yet-not-custom.
+ element->setCustomElementState(CustomElementState::Custom);
+
+ // TODO(dominicc): When the attributeChangedCallback is implemented,
+ // enqueue reactions for attributes here.
+ // TODO(dominicc): When the connectedCallback is implemented, enqueue
+ // reactions here, if applicable.
+}
+
+bool CustomElementDefinition::runConstructor(Element*)
+{
+ return true;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698