Chromium Code Reviews| 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/CustomElementMicrotaskImportStep.h" | 32 #include "core/dom/custom/CustomElementMicrotaskImportStep.h" |
| 33 | 33 |
| 34 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h" | 34 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h" |
| 35 #include "core/dom/custom/CustomElementMicrotaskQueue.h" | 35 #include "core/dom/custom/CustomElementMicrotaskQueue.h" |
| 36 #include "core/html/imports/HTMLImportChild.h" | |
| 36 | 37 |
| 37 namespace WebCore { | 38 namespace WebCore { |
| 38 | 39 |
| 39 PassOwnPtr<CustomElementMicrotaskImportStep> CustomElementMicrotaskImportStep::c reate(PassRefPtr<CustomElementMicrotaskQueue> queue) | 40 PassOwnPtr<CustomElementMicrotaskImportStep> CustomElementMicrotaskImportStep::c reate(PassRefPtr<CustomElementMicrotaskQueue> queue, bool shouldStopProcessing) |
| 40 { | 41 { |
| 41 return adoptPtr(new CustomElementMicrotaskImportStep(queue)); | 42 return adoptPtr(new CustomElementMicrotaskImportStep(queue, shouldStopProces sing)); |
| 42 } | 43 } |
| 43 | 44 |
| 44 CustomElementMicrotaskImportStep::CustomElementMicrotaskImportStep(PassRefPtr<Cu stomElementMicrotaskQueue> queue) | 45 CustomElementMicrotaskImportStep::CustomElementMicrotaskImportStep(PassRefPtr<Cu stomElementMicrotaskQueue> queue, bool shouldStopProcessing) |
| 45 : m_importFinished(false) | 46 : m_shouldStopProcessing(shouldStopProcessing) |
| 47 , m_importWaitingFinish(0) | |
| 46 , m_queue(queue) | 48 , m_queue(queue) |
| 47 { | 49 { |
| 48 } | 50 } |
| 49 | 51 |
| 50 CustomElementMicrotaskImportStep::~CustomElementMicrotaskImportStep() | 52 CustomElementMicrotaskImportStep::~CustomElementMicrotaskImportStep() |
| 51 { | 53 { |
| 52 } | 54 } |
| 53 | 55 |
| 54 void CustomElementMicrotaskImportStep::importDidFinish() | 56 void CustomElementMicrotaskImportStep::importWasDestroyed() |
| 55 { | 57 { |
| 56 // imports should only "finish" once | 58 m_importWaitingFinish = 0; |
| 57 ASSERT(!m_importFinished); | 59 m_queue.clear(); |
| 58 m_importFinished = true; | 60 } |
| 61 | |
| 62 void CustomElementMicrotaskImportStep::importDidLoad(HTMLImportChild* importWait ingFinish) | |
| 63 { | |
| 64 ASSERT(!m_importWaitingFinish); | |
| 65 m_importWaitingFinish = importWaitingFinish; | |
| 59 CustomElementMicrotaskDispatcher::instance().importDidFinish(this); | 66 CustomElementMicrotaskDispatcher::instance().importDidFinish(this); |
| 60 } | 67 } |
| 61 | 68 |
| 62 CustomElementMicrotaskStep::Result CustomElementMicrotaskImportStep::process() | 69 CustomElementMicrotaskStep::Result CustomElementMicrotaskImportStep::process() |
| 63 { | 70 { |
| 71 if (!m_queue) | |
| 72 return Continue; | |
| 73 | |
| 64 Result result = m_queue->dispatch(); | 74 Result result = m_queue->dispatch(); |
| 65 if (!m_importFinished) | 75 |
| 76 if (m_importWaitingFinish) { | |
| 77 if (m_queue->isEmpty()) { | |
| 78 ASSERT(result == Continue); | |
| 79 m_importWaitingFinish->didFinishMicrotask(); | |
| 80 m_importWaitingFinish = 0; | |
| 81 m_queue.clear(); | |
| 82 } | |
| 83 | |
| 84 return result; | |
| 85 } | |
| 86 | |
| 87 result = Result(result | ShouldRemain); | |
|
dominicc (has gone to gerrit)
2014/04/30 23:57:20
It seems bad to have a microtask queue whose impor
| |
| 88 if (m_shouldStopProcessing) | |
| 66 result = Result(result | ShouldStop); | 89 result = Result(result | ShouldStop); |
| 90 | |
| 67 return result; | 91 return result; |
| 68 } | 92 } |
| 69 | 93 |
| 94 #if !defined(NDEBUG) | |
| 95 | |
| 96 void CustomElementMicrotaskImportStep::show(unsigned indent) | |
| 97 { | |
| 98 for (unsigned i = 0; i < indent; ++i) | |
| 99 fprintf(stderr, " "); | |
| 100 fprintf(stderr, "Import(stop=%d, finish=%p): \n", m_shouldStopProcessing, m_ importWaitingFinish); | |
| 101 m_queue->show(indent + 1); | |
| 102 } | |
| 103 | |
| 104 #endif | |
| 105 | |
| 70 } // namespace WebCore | 106 } // namespace WebCore |
| OLD | NEW |