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

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

Issue 2058823002: Implement callback reactions for Custom Elements V1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stack-ce
Patch Set: dominicc review Created 4 years, 6 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/CustomElement.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
index f1e231cb1aa15fc374b15bd984f335d3c4c34276..2758af042f5f6057482e48c9e09bd903a2780622 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
@@ -6,9 +6,7 @@
#include "core/dom/Document.h"
#include "core/dom/QualifiedName.h"
-#include "core/dom/custom/CEReactionsScope.h"
#include "core/dom/custom/CustomElementDefinition.h"
-#include "core/dom/custom/CustomElementUpgradeReaction.h"
#include "core/dom/custom/CustomElementsRegistry.h"
#include "core/dom/custom/V0CustomElement.h"
#include "core/dom/custom/V0CustomElementRegistrationContext.h"
@@ -31,6 +29,13 @@ CustomElementsRegistry* CustomElement::registry(const Document& document)
return nullptr;
}
+CustomElementDefinition* CustomElement::definitionForElement(const Element& element)
+{
+ if (CustomElementsRegistry* registry = CustomElement::registry(element))
+ return registry->definitionForName(element.localName());
+ return nullptr;
+}
+
bool CustomElement::isValidName(const AtomicString& name)
{
if (!name.length() || name[0] < 'a' || name[0] > 'z')
@@ -131,17 +136,35 @@ HTMLElement* CustomElement::createCustomElementAsync(Document& document,
element->setCustomElementState(CustomElementState::Undefined);
// 6.2.2. Enqueue a custom element upgrade reaction given result and
// definition.
- enqueueUpgradeReaction(element, &definition);
+ definition.enqueueUpgradeReaction(element);
return element;
}
-void CustomElement::enqueueUpgradeReaction(Element* element, CustomElementDefinition* definition)
+void CustomElement::enqueueConnectedCallback(Element* element)
+{
+ DCHECK_EQ(element->getCustomElementState(), CustomElementState::Custom);
+ CustomElementDefinition* definition = definitionForElement(*element);
+ if (definition->hasConnectedCallback())
+ definition->enqueueConnectedCallback(element);
+}
+
+void CustomElement::enqueueDisconnectedCallback(Element* element)
+{
+ DCHECK_EQ(element->getCustomElementState(), CustomElementState::Custom);
+ CustomElementDefinition* definition = definitionForElement(*element);
+ if (definition->hasDisconnectedCallback())
+ definition->enqueueDisconnectedCallback(element);
+}
+
+
+void CustomElement::enqueueAttributeChangedCallback(Element* element,
+ const QualifiedName& name,
+ const AtomicString& oldValue, const AtomicString& newValue)
{
- // CEReactionsScope must be created by [CEReactions] in IDL,
- // or callers must setup explicitly if it does not go through bindings.
- DCHECK(CEReactionsScope::current());
- CEReactionsScope::current()->enqueue(element,
- new CustomElementUpgradeReaction(definition));
+ DCHECK_EQ(element->getCustomElementState(), CustomElementState::Custom);
+ CustomElementDefinition* definition = definitionForElement(*element);
+ if (definition->hasAttributeChangedCallback(name))
+ definition->enqueueAttributeChangedCallback(element, name, oldValue, newValue);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698