Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / dom / custom / CustomElementCallbackInvocation.cpp
index 7263ffc..444f39c 100644 (file)
 #include "config.h"
 #include "core/dom/custom/CustomElementCallbackInvocation.h"
 
+#include "core/dom/Document.h"
 #include "core/dom/Element.h"
-#include "core/dom/custom/CustomElementCallbackScheduler.h"
+#include "core/dom/custom/CustomElementScheduler.h"
 
-namespace WebCore {
+namespace blink {
 
-class CreatedInvocation : public CustomElementCallbackInvocation {
+class AttachedDetachedInvocation : public CustomElementCallbackInvocation {
 public:
-    CreatedInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callbacks)
-        : CustomElementCallbackInvocation(callbacks)
-    {
-    }
+    AttachedDetachedInvocation(PassRefPtr<CustomElementLifecycleCallbacks>, CustomElementLifecycleCallbacks::CallbackType which);
 
 private:
-    virtual void dispatch(Element*) OVERRIDE;
-    virtual bool isCreated() const OVERRIDE { return true; }
-};
-
-void CreatedInvocation::dispatch(Element* element)
-{
-    if (element->inDocument() && element->document().domWindow())
-        CustomElementCallbackScheduler::scheduleEnteredViewCallback(callbacks(), element);
-    callbacks()->created(element);
-}
-
-class EnteredLeftViewInvocation : public CustomElementCallbackInvocation {
-public:
-    EnteredLeftViewInvocation(PassRefPtr<CustomElementLifecycleCallbacks>, CustomElementLifecycleCallbacks::CallbackType which);
-
-private:
-    virtual void dispatch(Element*) OVERRIDE;
+    virtual void dispatch(Element*) override;
 
     CustomElementLifecycleCallbacks::CallbackType m_which;
 };
 
-EnteredLeftViewInvocation::EnteredLeftViewInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, CustomElementLifecycleCallbacks::CallbackType which)
+AttachedDetachedInvocation::AttachedDetachedInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, CustomElementLifecycleCallbacks::CallbackType which)
     : CustomElementCallbackInvocation(callbacks)
     , m_which(which)
 {
-    ASSERT(m_which == CustomElementLifecycleCallbacks::EnteredView || m_which == CustomElementLifecycleCallbacks::LeftView);
+    ASSERT(m_which == CustomElementLifecycleCallbacks::AttachedCallback || m_which == CustomElementLifecycleCallbacks::DetachedCallback);
 }
 
-void EnteredLeftViewInvocation::dispatch(Element* element)
+void AttachedDetachedInvocation::dispatch(Element* element)
 {
     switch (m_which) {
-    case CustomElementLifecycleCallbacks::EnteredView:
-        callbacks()->enteredView(element);
+    case CustomElementLifecycleCallbacks::AttachedCallback:
+        callbacks()->attached(element);
         break;
-    case CustomElementLifecycleCallbacks::LeftView:
-        callbacks()->leftView(element);
+    case CustomElementLifecycleCallbacks::DetachedCallback:
+        callbacks()->detached(element);
         break;
     default:
         ASSERT_NOT_REACHED();
@@ -91,7 +73,7 @@ public:
     AttributeChangedInvocation(PassRefPtr<CustomElementLifecycleCallbacks>, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue);
 
 private:
-    virtual void dispatch(Element*) OVERRIDE;
+    virtual void dispatch(Element*) override;
 
     AtomicString m_name;
     AtomicString m_oldValue;
@@ -111,16 +93,34 @@ void AttributeChangedInvocation::dispatch(Element* element)
     callbacks()->attributeChanged(element, m_name, m_oldValue, m_newValue);
 }
 
+class CreatedInvocation : public CustomElementCallbackInvocation {
+public:
+    CreatedInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callbacks)
+        : CustomElementCallbackInvocation(callbacks)
+    {
+    }
+
+private:
+    virtual void dispatch(Element*) override;
+    virtual bool isCreatedCallback() const override { return true; }
+};
+
+void CreatedInvocation::dispatch(Element* element)
+{
+    if (element->inDocument() && element->document().domWindow())
+        CustomElementScheduler::scheduleCallback(callbacks(), element, CustomElementLifecycleCallbacks::AttachedCallback);
+    callbacks()->created(element);
+}
+
 PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::createInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, CustomElementLifecycleCallbacks::CallbackType which)
 {
     switch (which) {
-    case CustomElementLifecycleCallbacks::Created:
+    case CustomElementLifecycleCallbacks::CreatedCallback:
         return adoptPtr(new CreatedInvocation(callbacks));
 
-    case CustomElementLifecycleCallbacks::EnteredView:
-    case CustomElementLifecycleCallbacks::LeftView:
-        return adoptPtr(new EnteredLeftViewInvocation(callbacks, which));
-
+    case CustomElementLifecycleCallbacks::AttachedCallback:
+    case CustomElementLifecycleCallbacks::DetachedCallback:
+        return adoptPtr(new AttachedDetachedInvocation(callbacks, which));
     default:
         ASSERT_NOT_REACHED();
         return PassOwnPtr<CustomElementCallbackInvocation>();
@@ -132,4 +132,4 @@ PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::cre
     return adoptPtr(new AttributeChangedInvocation(callbacks, name, oldValue, newValue));
 }
 
-} // namespace WebCore
+} // namespace blink