Chromium Code Reviews| 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..bdee9add703a438f2dcd88c8d8cf150d25c2a9d3 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,38 @@ 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); |
| + DCHECK(definition); |
|
dominicc (has gone to gerrit)
2016/06/13 07:59:01
We will null deref right after this, so this DCHEC
|
| + if (definition->hasConnectedCallback()) |
| + definition->enqueueConnectedCallback(element); |
| +} |
| + |
| +void CustomElement::enqueueDisconnectedCallback(Element* element) |
| +{ |
| + DCHECK_EQ(element->getCustomElementState(), CustomElementState::Custom); |
| + CustomElementDefinition* definition = definitionForElement(*element); |
| + DCHECK(definition); |
| + 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); |
| + DCHECK(definition); |
| + if (definition->hasAttributeChangedCallback(name)) |
| + definition->enqueueAttributeChangedCallback(element, name, oldValue, newValue); |
| } |
| } // namespace blink |