| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/dom/custom/CustomElementCallbackInvocation.h" | 32 #include "core/dom/custom/CustomElementCallbackInvocation.h" |
| 33 | 33 |
| 34 #include "core/dom/Element.h" | 34 #include "core/dom/Element.h" |
| 35 #include "core/dom/custom/CustomElementCallbackScheduler.h" | 35 #include "core/dom/custom/CustomElementCallbackScheduler.h" |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 class CreatedInvocation : public CustomElementCallbackInvocation { | |
| 40 public: | |
| 41 CreatedInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callbacks) | |
| 42 : CustomElementCallbackInvocation(callbacks) | |
| 43 { | |
| 44 } | |
| 45 | |
| 46 private: | |
| 47 virtual void dispatch(Element*) OVERRIDE; | |
| 48 virtual bool isCreated() const OVERRIDE { return true; } | |
| 49 }; | |
| 50 | |
| 51 void CreatedInvocation::dispatch(Element* element) | |
| 52 { | |
| 53 if (element->inDocument() && element->document().domWindow()) | |
| 54 CustomElementCallbackScheduler::scheduleAttachedCallback(callbacks(), el
ement); | |
| 55 callbacks()->created(element); | |
| 56 } | |
| 57 | |
| 58 class AttachedDetachedInvocation : public CustomElementCallbackInvocation { | 39 class AttachedDetachedInvocation : public CustomElementCallbackInvocation { |
| 59 public: | 40 public: |
| 60 AttachedDetachedInvocation(PassRefPtr<CustomElementLifecycleCallbacks>, Cust
omElementLifecycleCallbacks::CallbackType which); | 41 AttachedDetachedInvocation(PassRefPtr<CustomElementLifecycleCallbacks>, Cust
omElementLifecycleCallbacks::CallbackType which); |
| 61 | 42 |
| 62 private: | 43 private: |
| 63 virtual void dispatch(Element*) OVERRIDE; | 44 virtual void dispatch(Element*) OVERRIDE; |
| 64 | 45 |
| 65 CustomElementLifecycleCallbacks::CallbackType m_which; | 46 CustomElementLifecycleCallbacks::CallbackType m_which; |
| 66 }; | 47 }; |
| 67 | 48 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 88 } |
| 108 | 89 |
| 109 void AttributeChangedInvocation::dispatch(Element* element) | 90 void AttributeChangedInvocation::dispatch(Element* element) |
| 110 { | 91 { |
| 111 callbacks()->attributeChanged(element, m_name, m_oldValue, m_newValue); | 92 callbacks()->attributeChanged(element, m_name, m_oldValue, m_newValue); |
| 112 } | 93 } |
| 113 | 94 |
| 114 PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::cre
ateInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, CustomEleme
ntLifecycleCallbacks::CallbackType which) | 95 PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::cre
ateInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callbacks, CustomEleme
ntLifecycleCallbacks::CallbackType which) |
| 115 { | 96 { |
| 116 switch (which) { | 97 switch (which) { |
| 117 case CustomElementLifecycleCallbacks::Created: | |
| 118 return adoptPtr(new CreatedInvocation(callbacks)); | |
| 119 | |
| 120 case CustomElementLifecycleCallbacks::Attached: | 98 case CustomElementLifecycleCallbacks::Attached: |
| 121 case CustomElementLifecycleCallbacks::Detached: | 99 case CustomElementLifecycleCallbacks::Detached: |
| 122 return adoptPtr(new AttachedDetachedInvocation(callbacks, which)); | 100 return adoptPtr(new AttachedDetachedInvocation(callbacks, which)); |
| 123 | |
| 124 default: | 101 default: |
| 125 ASSERT_NOT_REACHED(); | 102 ASSERT_NOT_REACHED(); |
| 126 return PassOwnPtr<CustomElementCallbackInvocation>(); | 103 return PassOwnPtr<CustomElementCallbackInvocation>(); |
| 127 } | 104 } |
| 128 } | 105 } |
| 129 | 106 |
| 130 PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::cre
ateAttributeChangedInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callba
cks, const AtomicString& name, const AtomicString& oldValue, const AtomicString&
newValue) | 107 PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::cre
ateAttributeChangedInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callba
cks, const AtomicString& name, const AtomicString& oldValue, const AtomicString&
newValue) |
| 131 { | 108 { |
| 132 return adoptPtr(new AttributeChangedInvocation(callbacks, name, oldValue, ne
wValue)); | 109 return adoptPtr(new AttributeChangedInvocation(callbacks, name, oldValue, ne
wValue)); |
| 133 } | 110 } |
| 134 | 111 |
| 135 } // namespace WebCore | 112 } // namespace WebCore |
| OLD | NEW |