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/CustomElementCallbackScheduler.h" | 32 #include "core/dom/custom/CustomElementCallbackScheduler.h" |
33 | 33 |
34 #include "core/dom/Element.h" | 34 #include "core/dom/Element.h" |
35 #include "core/dom/custom/CustomElementCallbackDispatcher.h" | 35 #include "core/dom/custom/CustomElementCallbackDispatcher.h" |
| 36 #include "core/dom/custom/CustomElementCallbackInvocation.h" |
36 #include "core/dom/custom/CustomElementLifecycleCallbacks.h" | 37 #include "core/dom/custom/CustomElementLifecycleCallbacks.h" |
| 38 #include "core/dom/custom/CustomElementRegistrationContext.h" |
| 39 #include "core/dom/custom/CustomElementResolutionStep.h" |
37 | 40 |
38 namespace WebCore { | 41 namespace WebCore { |
39 | 42 |
40 void CustomElementCallbackScheduler::scheduleAttributeChangedCallback(PassRefPtr
<CustomElementLifecycleCallbacks> callbacks, PassRefPtr<Element> element, const
AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue) | 43 void CustomElementCallbackScheduler::scheduleAttributeChangedCallback(PassRefPtr
<CustomElementLifecycleCallbacks> callbacks, PassRefPtr<Element> element, const
AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue) |
41 { | 44 { |
42 if (!callbacks->hasAttributeChangedCallback()) | 45 if (!callbacks->hasAttributeChangedCallback()) |
43 return; | 46 return; |
44 | 47 |
45 CustomElementCallbackQueue* queue = instance().schedule(element); | 48 CustomElementCallbackQueue* queue = instance().schedule(element); |
46 queue->append(CustomElementCallbackInvocation::createAttributeChangedInvocat
ion(callbacks, name, oldValue, newValue)); | 49 queue->append(CustomElementCallbackInvocation::createAttributeChangedInvocat
ion(callbacks, name, oldValue, newValue)); |
47 } | 50 } |
48 | 51 |
49 void CustomElementCallbackScheduler::scheduleCreatedCallback(PassRefPtr<CustomEl
ementLifecycleCallbacks> callbacks, PassRefPtr<Element> element) | |
50 { | |
51 if (!callbacks->hasCreatedCallback()) | |
52 return; | |
53 | |
54 CustomElementCallbackQueue* queue = instance().scheduleInCurrentElementQueue
(element); | |
55 queue->append(CustomElementCallbackInvocation::createInvocation(callbacks, C
ustomElementLifecycleCallbacks::Created)); | |
56 } | |
57 | |
58 void CustomElementCallbackScheduler::scheduleAttachedCallback(PassRefPtr<CustomE
lementLifecycleCallbacks> callbacks, PassRefPtr<Element> element) | 52 void CustomElementCallbackScheduler::scheduleAttachedCallback(PassRefPtr<CustomE
lementLifecycleCallbacks> callbacks, PassRefPtr<Element> element) |
59 { | 53 { |
60 if (!callbacks->hasAttachedCallback()) | 54 if (!callbacks->hasAttachedCallback()) |
61 return; | 55 return; |
62 | 56 |
63 CustomElementCallbackQueue* queue = instance().schedule(element); | 57 CustomElementCallbackQueue* queue = instance().schedule(element); |
64 queue->append(CustomElementCallbackInvocation::createInvocation(callbacks, C
ustomElementLifecycleCallbacks::Attached)); | 58 queue->append(CustomElementCallbackInvocation::createInvocation(callbacks, C
ustomElementLifecycleCallbacks::Attached)); |
65 } | 59 } |
66 | 60 |
67 void CustomElementCallbackScheduler::scheduleDetachedCallback(PassRefPtr<CustomE
lementLifecycleCallbacks> callbacks, PassRefPtr<Element> element) | 61 void CustomElementCallbackScheduler::scheduleDetachedCallback(PassRefPtr<CustomE
lementLifecycleCallbacks> callbacks, PassRefPtr<Element> element) |
68 { | 62 { |
69 if (!callbacks->hasDetachedCallback()) | 63 if (!callbacks->hasDetachedCallback()) |
70 return; | 64 return; |
71 | 65 |
72 CustomElementCallbackQueue* queue = instance().schedule(element); | 66 CustomElementCallbackQueue* queue = instance().schedule(element); |
73 queue->append(CustomElementCallbackInvocation::createInvocation(callbacks, C
ustomElementLifecycleCallbacks::Detached)); | 67 queue->append(CustomElementCallbackInvocation::createInvocation(callbacks, C
ustomElementLifecycleCallbacks::Detached)); |
74 } | 68 } |
75 | 69 |
| 70 void CustomElementCallbackScheduler::scheduleResolutionStep(const CustomElementD
escriptor& descriptor, PassRefPtr<Element> element) |
| 71 { |
| 72 RefPtr<CustomElementRegistrationContext> context = element->document().regis
trationContext(); |
| 73 CustomElementCallbackQueue* queue = instance().schedule(element); |
| 74 queue->append(CustomElementResolutionStep::create(context.release(), descrip
tor)); |
| 75 } |
| 76 |
76 CustomElementCallbackScheduler& CustomElementCallbackScheduler::instance() | 77 CustomElementCallbackScheduler& CustomElementCallbackScheduler::instance() |
77 { | 78 { |
78 DEFINE_STATIC_LOCAL(CustomElementCallbackScheduler, instance, ()); | 79 DEFINE_STATIC_LOCAL(CustomElementCallbackScheduler, instance, ()); |
79 return instance; | 80 return instance; |
80 } | 81 } |
81 | 82 |
82 CustomElementCallbackQueue* CustomElementCallbackScheduler::ensureCallbackQueue(
PassRefPtr<Element> element) | 83 CustomElementCallbackQueue* CustomElementCallbackScheduler::ensureCallbackQueue(
PassRefPtr<Element> element) |
83 { | 84 { |
84 Element* key = element.get(); | 85 Element* key = element.get(); |
85 ElementCallbackQueueMap::iterator it = m_elementCallbackQueueMap.find(key); | 86 ElementCallbackQueueMap::iterator it = m_elementCallbackQueueMap.find(key); |
(...skipping 26 matching lines...) Expand all Loading... |
112 // stack. Because callback queues are processed exhaustively, this | 113 // stack. Because callback queues are processed exhaustively, this |
113 // effectively moves the callback queue to the top of the stack. | 114 // effectively moves the callback queue to the top of the stack. |
114 CustomElementCallbackQueue* CustomElementCallbackScheduler::scheduleInCurrentEle
mentQueue(PassRefPtr<Element> element) | 115 CustomElementCallbackQueue* CustomElementCallbackScheduler::scheduleInCurrentEle
mentQueue(PassRefPtr<Element> element) |
115 { | 116 { |
116 CustomElementCallbackQueue* callbackQueue = ensureCallbackQueue(element); | 117 CustomElementCallbackQueue* callbackQueue = ensureCallbackQueue(element); |
117 CustomElementCallbackDispatcher::instance().enqueue(callbackQueue); | 118 CustomElementCallbackDispatcher::instance().enqueue(callbackQueue); |
118 return callbackQueue; | 119 return callbackQueue; |
119 } | 120 } |
120 | 121 |
121 } // namespace WebCore | 122 } // namespace WebCore |
OLD | NEW |