Chromium Code Reviews| Index: Source/core/dom/CustomElementCallbackInvocation.cpp |
| diff --git a/Source/core/dom/CustomElementCallbackInvocation.cpp b/Source/core/dom/CustomElementCallbackInvocation.cpp |
| index 3b6aab9befaf419897f181b78258a1c9b330a3ec..ae9f6bb05343fc29c0b14e1c8d6effb7867102c3 100644 |
| --- a/Source/core/dom/CustomElementCallbackInvocation.cpp |
| +++ b/Source/core/dom/CustomElementCallbackInvocation.cpp |
| @@ -31,54 +31,72 @@ |
| #include "config.h" |
| #include "core/dom/CustomElementCallbackInvocation.h" |
| -#include "core/dom/CustomElementLifecycleCallbacks.h" |
| +#include "core/dom/CustomElementCallbackDispatcher.h" |
| namespace WebCore { |
| class AttributeChangedInvocation : public CustomElementCallbackInvocation { |
|
Yuta Kitamura
2013/07/08 03:40:49
The separation between AttributeChangedInvocation
|
| public: |
| - AttributeChangedInvocation(const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue); |
| + AttributeChangedInvocation(PassRefPtr<CustomElementLifecycleCallbacks>, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue); |
| private: |
| - virtual void dispatch(CustomElementLifecycleCallbacks*, Element*) OVERRIDE; |
| + virtual void dispatch(Element*) OVERRIDE; |
| AtomicString m_name; |
| AtomicString m_oldValue; |
| AtomicString m_newValue; |
| }; |
| -class CreatedInvocation : public CustomElementCallbackInvocation { |
| -public: |
| - CreatedInvocation() { } |
| -private: |
| - virtual void dispatch(CustomElementLifecycleCallbacks*, Element*) OVERRIDE; |
| -}; |
| - |
| -PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::createCreatedInvocation() |
| +PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::createInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, CustomElementLifecycleCallbacks::CallbackType which) |
| { |
| - return adoptPtr(new CreatedInvocation()); |
| + switch (which) { |
| + case CustomElementLifecycleCallbacks::Created: |
| + case CustomElementLifecycleCallbacks::EnteredDocument: |
| + case CustomElementLifecycleCallbacks::LeftDocument: |
|
Yuta Kitamura
2013/07/08 03:40:49
CELifecycleCallbacks::CallbackType looks like a bi
|
| + return adoptPtr(new CustomElementCallbackInvocation(callbacks, which)); |
| + |
| + case CustomElementLifecycleCallbacks::AttributeChanged: // Use createAttributeChangedInvocation |
| + default: |
| + ASSERT_NOT_REACHED(); |
| + return PassOwnPtr<CustomElementCallbackInvocation>(); |
| + } |
| } |
| -PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::createAttributeChangedInvocation(const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue) |
| +void CustomElementCallbackInvocation::dispatch(Element* element) |
| { |
| - return adoptPtr(new AttributeChangedInvocation(name, oldValue, newValue)); |
| + switch (m_which) { |
| + case CustomElementLifecycleCallbacks::Created: |
| + if (element->inDocument()) |
| + CustomElementCallbackDispatcher::instance().enqueueEnteredDocumentCallback(m_callbacks, element); |
| + m_callbacks->created(element); |
| + break; |
| + case CustomElementLifecycleCallbacks::EnteredDocument: |
| + m_callbacks->enteredDocument(element); |
| + break; |
| + case CustomElementLifecycleCallbacks::LeftDocument: |
| + m_callbacks->leftDocument(element); |
| + break; |
| + default: |
| + ASSERT_NOT_REACHED(); |
| + } |
| } |
| -AttributeChangedInvocation::AttributeChangedInvocation(const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue) |
| - : m_name(name) |
| - , m_oldValue(oldValue) |
| - , m_newValue(newValue) |
| +PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::createAttributeChangedInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue) |
| { |
| + return adoptPtr(new AttributeChangedInvocation(callbacks, name, oldValue, newValue)); |
| } |
| -void AttributeChangedInvocation::dispatch(CustomElementLifecycleCallbacks* callbacks, Element* element) |
| +AttributeChangedInvocation::AttributeChangedInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue) |
| + : CustomElementCallbackInvocation(callbacks, CustomElementLifecycleCallbacks::AttributeChanged) |
| + , m_name(name) |
| + , m_oldValue(oldValue) |
| + , m_newValue(newValue) |
| { |
| - callbacks->attributeChanged(element, m_name, m_oldValue, m_newValue); |
| } |
| -void CreatedInvocation::dispatch(CustomElementLifecycleCallbacks* callbacks, Element* element) |
| +void AttributeChangedInvocation::dispatch(Element* element) |
| { |
| - callbacks->created(element); |
| + callbacks()->attributeChanged(element, m_name, m_oldValue, m_newValue); |
| } |
| } // namespace WebCore |