| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h" | 6 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h" |
| 7 | 7 |
| 8 #include "core/dom/Microtask.h" | 8 #include "core/dom/Microtask.h" |
| 9 #include "core/dom/custom/CustomElementCallbackDispatcher.h" | 9 #include "core/dom/custom/CustomElementCallbackDispatcher.h" |
| 10 #include "core/dom/custom/CustomElementCallbackQueue.h" | 10 #include "core/dom/custom/CustomElementCallbackQueue.h" |
| 11 #include "core/dom/custom/CustomElementMicrotaskImportStep.h" | 11 #include "core/dom/custom/CustomElementMicrotaskImportStep.h" |
| 12 #include "core/dom/custom/CustomElementScheduler.h" | 12 #include "core/dom/custom/CustomElementScheduler.h" |
| 13 #include "core/html/imports/HTMLImport.h" | 13 #include "core/dom/custom/RefCountedCustomElementMicrotaskQueue.h" |
| 14 #include "core/html/imports/HTMLImportLoader.h" |
| 14 #include "wtf/MainThread.h" | 15 #include "wtf/MainThread.h" |
| 15 | 16 |
| 16 namespace WebCore { | 17 namespace WebCore { |
| 17 | 18 |
| 18 static const CustomElementCallbackQueue::ElementQueueId kMicrotaskQueueId = 0; | 19 static const CustomElementCallbackQueue::ElementQueueId kMicrotaskQueueId = 0; |
| 19 | 20 |
| 20 CustomElementMicrotaskDispatcher::CustomElementMicrotaskDispatcher() | 21 CustomElementMicrotaskDispatcher::CustomElementMicrotaskDispatcher() |
| 21 : m_hasScheduledMicrotask(false) | 22 : m_hasScheduledMicrotask(false) |
| 22 , m_phase(Quiescent) | 23 , m_phase(Quiescent) |
| 23 { | 24 { |
| 24 } | 25 } |
| 25 | 26 |
| 26 CustomElementMicrotaskDispatcher& CustomElementMicrotaskDispatcher::instance() | 27 CustomElementMicrotaskDispatcher& CustomElementMicrotaskDispatcher::instance() |
| 27 { | 28 { |
| 28 DEFINE_STATIC_LOCAL(CustomElementMicrotaskDispatcher, instance, ()); | 29 DEFINE_STATIC_LOCAL(CustomElementMicrotaskDispatcher, instance, ()); |
| 29 return instance; | 30 return instance; |
| 30 } | 31 } |
| 31 | 32 |
| 32 void CustomElementMicrotaskDispatcher::enqueue(HTMLImport* import, PassOwnPtr<Cu
stomElementMicrotaskStep> step) | 33 void CustomElementMicrotaskDispatcher::enqueue(HTMLImportLoader* importLoader, P
assOwnPtr<CustomElementMicrotaskStep> step) |
| 33 { | 34 { |
| 34 ASSERT(m_phase == Quiescent || m_phase == DispatchingCallbacks); | 35 ASSERT(m_phase == Quiescent || m_phase == DispatchingCallbacks); |
| 35 ensureMicrotaskScheduled(); | 36 ensureMicrotaskScheduled(); |
| 36 if (import && import->customElementMicrotaskStep()) | 37 if (importLoader) |
| 37 import->customElementMicrotaskStep()->enqueue(step); | 38 importLoader->microtaskQueue()->enqueue(step); |
| 38 else | 39 else |
| 39 m_resolutionAndImports.enqueue(step); | 40 m_resolutionAndImports.enqueue(step); |
| 40 } | 41 } |
| 41 | 42 |
| 42 void CustomElementMicrotaskDispatcher::enqueue(CustomElementCallbackQueue* queue
) | 43 void CustomElementMicrotaskDispatcher::enqueue(CustomElementCallbackQueue* queue
) |
| 43 { | 44 { |
| 44 ASSERT(m_phase == Quiescent || m_phase == Resolving); | 45 ASSERT(m_phase == Quiescent || m_phase == Resolving); |
| 45 ensureMicrotaskScheduled(); | 46 ensureMicrotaskScheduled(); |
| 46 queue->setOwner(kMicrotaskQueueId); | 47 queue->setOwner(kMicrotaskQueueId); |
| 47 m_elements.append(queue); | 48 m_elements.append(queue); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 CustomElementCallbackDispatcher::CallbackDeliveryScope scope; | 88 CustomElementCallbackDispatcher::CallbackDeliveryScope scope; |
| 88 (*it)->processInElementQueue(kMicrotaskQueueId); | 89 (*it)->processInElementQueue(kMicrotaskQueueId); |
| 89 } | 90 } |
| 90 | 91 |
| 91 m_elements.clear(); | 92 m_elements.clear(); |
| 92 CustomElementScheduler::microtaskDispatcherDidFinish(); | 93 CustomElementScheduler::microtaskDispatcherDidFinish(); |
| 93 m_phase = Quiescent; | 94 m_phase = Quiescent; |
| 94 } | 95 } |
| 95 | 96 |
| 96 } // namespace WebCore | 97 } // namespace WebCore |
| OLD | NEW |