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::scheduleEnteredViewCallback(callbacks(),
element); | |
55 callbacks()->created(element); | |
56 } | |
57 | |
58 class EnteredLeftViewInvocation : public CustomElementCallbackInvocation { | 39 class EnteredLeftViewInvocation : public CustomElementCallbackInvocation { |
59 public: | 40 public: |
60 EnteredLeftViewInvocation(PassRefPtr<CustomElementLifecycleCallbacks>, Custo
mElementLifecycleCallbacks::CallbackType which); | 41 EnteredLeftViewInvocation(PassRefPtr<CustomElementLifecycleCallbacks>, Custo
mElementLifecycleCallbacks::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::EnteredView: | 98 case CustomElementLifecycleCallbacks::EnteredView: |
121 case CustomElementLifecycleCallbacks::LeftView: | 99 case CustomElementLifecycleCallbacks::LeftView: |
122 return adoptPtr(new EnteredLeftViewInvocation(callbacks, which)); | 100 return adoptPtr(new EnteredLeftViewInvocation(callbacks, which)); |
123 | 101 |
124 default: | 102 default: |
125 ASSERT_NOT_REACHED(); | 103 ASSERT_NOT_REACHED(); |
126 return PassOwnPtr<CustomElementCallbackInvocation>(); | 104 return PassOwnPtr<CustomElementCallbackInvocation>(); |
127 } | 105 } |
128 } | 106 } |
129 | 107 |
130 PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::cre
ateAttributeChangedInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callba
cks, const AtomicString& name, const AtomicString& oldValue, const AtomicString&
newValue) | 108 PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::cre
ateAttributeChangedInvocation(PassRefPtr<CustomElementLifecycleCallbacks> callba
cks, const AtomicString& name, const AtomicString& oldValue, const AtomicString&
newValue) |
131 { | 109 { |
132 return adoptPtr(new AttributeChangedInvocation(callbacks, name, oldValue, ne
wValue)); | 110 return adoptPtr(new AttributeChangedInvocation(callbacks, name, oldValue, ne
wValue)); |
133 } | 111 } |
134 | 112 |
135 } // namespace WebCore | 113 } // namespace WebCore |
OLD | NEW |