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 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/dom/custom/CustomElementScheduler.h" | 32 #include "core/dom/custom/CustomElementScheduler.h" |
33 | 33 |
34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
35 #include "core/dom/Element.h" | 35 #include "core/dom/Element.h" |
36 #include "core/dom/custom/CustomElementCallbackDispatcher.h" | |
37 #include "core/dom/custom/CustomElementCallbackInvocation.h" | 36 #include "core/dom/custom/CustomElementCallbackInvocation.h" |
38 #include "core/dom/custom/CustomElementLifecycleCallbacks.h" | 37 #include "core/dom/custom/CustomElementLifecycleCallbacks.h" |
39 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h" | 38 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h" |
40 #include "core/dom/custom/CustomElementMicrotaskImportStep.h" | 39 #include "core/dom/custom/CustomElementMicrotaskImportStep.h" |
41 #include "core/dom/custom/CustomElementMicrotaskResolutionStep.h" | 40 #include "core/dom/custom/CustomElementMicrotaskResolutionStep.h" |
42 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" | 41 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" |
| 42 #include "core/dom/custom/CustomElementProcessingStack.h" |
43 #include "core/dom/custom/CustomElementRegistrationContext.h" | 43 #include "core/dom/custom/CustomElementRegistrationContext.h" |
44 #include "core/dom/custom/CustomElementSyncMicrotaskQueue.h" | 44 #include "core/dom/custom/CustomElementSyncMicrotaskQueue.h" |
45 #include "core/html/imports/HTMLImportChild.h" | 45 #include "core/html/imports/HTMLImportChild.h" |
46 #include "core/html/imports/HTMLImportsController.h" | 46 #include "core/html/imports/HTMLImportsController.h" |
47 | 47 |
48 namespace blink { | 48 namespace blink { |
49 | 49 |
50 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CustomElementScheduler) | 50 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CustomElementScheduler) |
51 | 51 |
52 void CustomElementScheduler::scheduleCallback(PassRefPtr<CustomElementLifecycleC
allbacks> callbacks, PassRefPtrWillBeRawPtr<Element> element, CustomElementLifec
ycleCallbacks::CallbackType type) | 52 void CustomElementScheduler::scheduleCallback(PassRefPtr<CustomElementLifecycleC
allbacks> callbacks, PassRefPtrWillBeRawPtr<Element> element, CustomElementLifec
ycleCallbacks::CallbackType type) |
(...skipping 11 matching lines...) Expand all Loading... |
64 { | 64 { |
65 if (!callbacks->hasCallback(CustomElementLifecycleCallbacks::AttributeChange
dCallback)) | 65 if (!callbacks->hasCallback(CustomElementLifecycleCallbacks::AttributeChange
dCallback)) |
66 return; | 66 return; |
67 | 67 |
68 CustomElementCallbackQueue& queue = instance().schedule(element); | 68 CustomElementCallbackQueue& queue = instance().schedule(element); |
69 queue.append(CustomElementCallbackInvocation::createAttributeChangedInvocati
on(callbacks, name, oldValue, newValue)); | 69 queue.append(CustomElementCallbackInvocation::createAttributeChangedInvocati
on(callbacks, name, oldValue, newValue)); |
70 } | 70 } |
71 | 71 |
72 void CustomElementScheduler::resolveOrScheduleResolution(PassRefPtrWillBeRawPtr<
CustomElementRegistrationContext> context, PassRefPtrWillBeRawPtr<Element> eleme
nt, const CustomElementDescriptor& descriptor) | 72 void CustomElementScheduler::resolveOrScheduleResolution(PassRefPtrWillBeRawPtr<
CustomElementRegistrationContext> context, PassRefPtrWillBeRawPtr<Element> eleme
nt, const CustomElementDescriptor& descriptor) |
73 { | 73 { |
74 if (CustomElementCallbackDispatcher::inCallbackDeliveryScope()) { | 74 if (CustomElementProcessingStack::inCallbackDeliveryScope()) { |
75 context->resolve(element.get(), descriptor); | 75 context->resolve(element.get(), descriptor); |
76 return; | 76 return; |
77 } | 77 } |
78 | 78 |
79 Document& document = element->document(); | 79 Document& document = element->document(); |
80 OwnPtrWillBeRawPtr<CustomElementMicrotaskResolutionStep> step = CustomElemen
tMicrotaskResolutionStep::create(context, element, descriptor); | 80 OwnPtrWillBeRawPtr<CustomElementMicrotaskResolutionStep> step = CustomElemen
tMicrotaskResolutionStep::create(context, element, descriptor); |
81 enqueueMicrotaskStep(document, step.release()); | 81 enqueueMicrotaskStep(document, step.release()); |
82 } | 82 } |
83 | 83 |
84 CustomElementMicrotaskImportStep* CustomElementScheduler::scheduleImport(HTMLImp
ortChild* import) | 84 CustomElementMicrotaskImportStep* CustomElementScheduler::scheduleImport(HTMLImp
ortChild* import) |
(...skipping 30 matching lines...) Expand all Loading... |
115 } | 115 } |
116 | 116 |
117 void CustomElementScheduler::callbackDispatcherDidFinish() | 117 void CustomElementScheduler::callbackDispatcherDidFinish() |
118 { | 118 { |
119 if (CustomElementMicrotaskDispatcher::instance().elementQueueIsEmpty()) | 119 if (CustomElementMicrotaskDispatcher::instance().elementQueueIsEmpty()) |
120 instance().clearElementCallbackQueueMap(); | 120 instance().clearElementCallbackQueueMap(); |
121 } | 121 } |
122 | 122 |
123 void CustomElementScheduler::microtaskDispatcherDidFinish() | 123 void CustomElementScheduler::microtaskDispatcherDidFinish() |
124 { | 124 { |
125 ASSERT(!CustomElementCallbackDispatcher::inCallbackDeliveryScope()); | 125 ASSERT(!CustomElementProcessingStack::inCallbackDeliveryScope()); |
126 instance().clearElementCallbackQueueMap(); | 126 instance().clearElementCallbackQueueMap(); |
127 } | 127 } |
128 | 128 |
129 void CustomElementScheduler::clearElementCallbackQueueMap() | 129 void CustomElementScheduler::clearElementCallbackQueueMap() |
130 { | 130 { |
131 ElementCallbackQueueMap emptyMap; | 131 ElementCallbackQueueMap emptyMap; |
132 m_elementCallbackQueueMap.swap(emptyMap); | 132 m_elementCallbackQueueMap.swap(emptyMap); |
133 } | 133 } |
134 | 134 |
135 // Finds or creates the callback queue for element. | 135 // Finds or creates the callback queue for element. |
136 CustomElementCallbackQueue& CustomElementScheduler::schedule(PassRefPtrWillBeRaw
Ptr<Element> passElement) | 136 CustomElementCallbackQueue& CustomElementScheduler::schedule(PassRefPtrWillBeRaw
Ptr<Element> passElement) |
137 { | 137 { |
138 RefPtrWillBeRawPtr<Element> element(passElement); | 138 RefPtrWillBeRawPtr<Element> element(passElement); |
139 | 139 |
140 CustomElementCallbackQueue& callbackQueue = ensureCallbackQueue(element); | 140 CustomElementCallbackQueue& callbackQueue = ensureCallbackQueue(element); |
141 if (callbackQueue.inCreatedCallback()) { | 141 if (callbackQueue.inCreatedCallback()) { |
142 // Don't move it. Authors use the createdCallback like a | 142 // Don't move it. Authors use the createdCallback like a |
143 // constructor. By not moving it, the createdCallback | 143 // constructor. By not moving it, the createdCallback |
144 // completes before any other callbacks are entered for this | 144 // completes before any other callbacks are entered for this |
145 // element. | 145 // element. |
146 return callbackQueue; | 146 return callbackQueue; |
147 } | 147 } |
148 | 148 |
149 if (CustomElementCallbackDispatcher::inCallbackDeliveryScope()) { | 149 if (CustomElementProcessingStack::inCallbackDeliveryScope()) { |
150 // The processing stack is active. | 150 // The processing stack is active. |
151 CustomElementCallbackDispatcher::instance().enqueue(&callbackQueue); | 151 CustomElementProcessingStack::instance().enqueue(&callbackQueue); |
152 return callbackQueue; | 152 return callbackQueue; |
153 } | 153 } |
154 | 154 |
155 CustomElementMicrotaskDispatcher::instance().enqueue(&callbackQueue); | 155 CustomElementMicrotaskDispatcher::instance().enqueue(&callbackQueue); |
156 return callbackQueue; | 156 return callbackQueue; |
157 } | 157 } |
158 | 158 |
159 void CustomElementScheduler::trace(Visitor* visitor) | 159 void CustomElementScheduler::trace(Visitor* visitor) |
160 { | 160 { |
161 #if ENABLE(OILPAN) | 161 #if ENABLE(OILPAN) |
162 visitor->trace(m_elementCallbackQueueMap); | 162 visitor->trace(m_elementCallbackQueueMap); |
163 #endif | 163 #endif |
164 } | 164 } |
165 | 165 |
166 } // namespace blink | 166 } // namespace blink |
OLD | NEW |