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 |