OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h" |
| 7 |
| 8 #include "core/dom/custom/CustomElementCallbackDispatcher.h" |
| 9 #include "core/dom/custom/CustomElementCallbackQueue.h" |
| 10 #include "core/dom/custom/CustomElementMicrotaskImportStep.h" |
| 11 #include "core/html/HTMLImport.h" |
| 12 |
| 13 namespace WebCore { |
| 14 |
| 15 static const CustomElementCallbackQueue::ElementQueueId kMicrotaskQueueId = 0; |
| 16 |
| 17 void CustomElementMicrotaskDispatcher::enqueue(HTMLImport* import, PassOwnPtr<Cu
stomElementMicrotaskStep> step) |
| 18 { |
| 19 ASSERT(m_phase == Quiescent || m_phase == DispatchingCallbacks); |
| 20 if (import && import->customElementMicrotaskStep()) |
| 21 import->customElementMicrotaskStep()->enqueue(step); |
| 22 else |
| 23 m_resolutionAndImports.enqueue(step); |
| 24 } |
| 25 |
| 26 void CustomElementMicrotaskDispatcher::enqueue(CustomElementCallbackQueue* queue
) |
| 27 { |
| 28 ASSERT(m_phase == Quiescent || m_phase == Resolving); |
| 29 queue->setOwner(kMicrotaskQueueId); |
| 30 m_elements.append(queue); |
| 31 } |
| 32 |
| 33 bool CustomElementMicrotaskDispatcher::dispatch() |
| 34 { |
| 35 ASSERT(m_phase == Quiescent); |
| 36 |
| 37 bool didWork = false; |
| 38 |
| 39 m_phase = Resolving; |
| 40 m_resolutionAndImports.dispatch(); |
| 41 |
| 42 m_phase = DispatchingCallbacks; |
| 43 for (Vector<CustomElementCallbackQueue*>::iterator it = m_elements.begin();i
t != m_elements.end(); ++it) { |
| 44 // Created callback may enqueue an attached callback. |
| 45 CustomElementCallbackDispatcher::CallbackDeliveryScope scope; |
| 46 (*it)->processInElementQueue(kMicrotaskQueueId); |
| 47 |
| 48 didWork = true; |
| 49 } |
| 50 |
| 51 m_elements.clear(); |
| 52 m_phase = Quiescent; |
| 53 |
| 54 return didWork; |
| 55 } |
| 56 |
| 57 } // namespace WebCore |
OLD | NEW |