| 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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/html/imports/HTMLImportLoader.h" | 32 #include "core/html/imports/HTMLImportLoader.h" |
| 33 | 33 |
| 34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
| 35 #include "core/dom/DocumentParser.h" |
| 35 #include "core/dom/StyleEngine.h" | 36 #include "core/dom/StyleEngine.h" |
| 36 #include "core/dom/custom/CustomElementSyncMicrotaskQueue.h" | 37 #include "core/dom/custom/CustomElementSyncMicrotaskQueue.h" |
| 37 #include "core/html/HTMLDocument.h" | 38 #include "core/html/HTMLDocument.h" |
| 38 #include "core/html/imports/HTMLImportChild.h" | 39 #include "core/html/imports/HTMLImportChild.h" |
| 39 #include "core/html/imports/HTMLImportsController.h" | 40 #include "core/html/imports/HTMLImportsController.h" |
| 40 #include "core/loader/DocumentWriter.h" | 41 #include "core/loader/DocumentWriter.h" |
| 41 #include "platform/network/ContentSecurityPolicyResponseHeaders.h" | 42 #include "platform/network/ContentSecurityPolicyResponseHeaders.h" |
| 42 | 43 |
| 43 | 44 |
| 44 namespace blink { | 45 namespace blink { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 110 } |
| 110 | 111 |
| 111 HTMLImportLoader::State HTMLImportLoader::startWritingAndParsing(const ResourceR
esponse& response) | 112 HTMLImportLoader::State HTMLImportLoader::startWritingAndParsing(const ResourceR
esponse& response) |
| 112 { | 113 { |
| 113 ASSERT(!m_imports.isEmpty()); | 114 ASSERT(!m_imports.isEmpty()); |
| 114 DocumentInit init = DocumentInit(response.url(), 0, m_controller->master()->
contextDocument(), m_controller) | 115 DocumentInit init = DocumentInit(response.url(), 0, m_controller->master()->
contextDocument(), m_controller) |
| 115 .withRegistrationContext(m_controller->master()->registrationContext()); | 116 .withRegistrationContext(m_controller->master()->registrationContext()); |
| 116 m_document = HTMLDocument::create(init); | 117 m_document = HTMLDocument::create(init); |
| 117 m_writer = DocumentWriter::create(m_document.get(), response.mimeType(), "UT
F-8"); | 118 m_writer = DocumentWriter::create(m_document.get(), response.mimeType(), "UT
F-8"); |
| 118 | 119 |
| 120 DocumentParser* parser = m_document->parser(); |
| 121 ASSERT(parser); |
| 122 parser->addClient(this); |
| 123 |
| 119 return StateLoading; | 124 return StateLoading; |
| 120 } | 125 } |
| 121 | 126 |
| 122 HTMLImportLoader::State HTMLImportLoader::finishWriting() | 127 HTMLImportLoader::State HTMLImportLoader::finishWriting() |
| 123 { | 128 { |
| 124 return StateWritten; | 129 return StateWritten; |
| 125 } | 130 } |
| 126 | 131 |
| 127 HTMLImportLoader::State HTMLImportLoader::finishParsing() | 132 HTMLImportLoader::State HTMLImportLoader::finishParsing() |
| 128 { | 133 { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 144 if (m_state == StateParsed || m_state == StateError || m_state == StateWritt
en) { | 149 if (m_state == StateParsed || m_state == StateError || m_state == StateWritt
en) { |
| 145 if (RefPtrWillBeRawPtr<DocumentWriter> writer = m_writer.release()) | 150 if (RefPtrWillBeRawPtr<DocumentWriter> writer = m_writer.release()) |
| 146 writer->end(); | 151 writer->end(); |
| 147 } | 152 } |
| 148 | 153 |
| 149 // Since DocumentWriter::end() can let setState() reenter, we shouldn't refe
r to m_state here. | 154 // Since DocumentWriter::end() can let setState() reenter, we shouldn't refe
r to m_state here. |
| 150 if (state == StateLoaded || state == StateError) | 155 if (state == StateLoaded || state == StateError) |
| 151 didFinishLoading(); | 156 didFinishLoading(); |
| 152 } | 157 } |
| 153 | 158 |
| 154 void HTMLImportLoader::didFinishParsing() | 159 void HTMLImportLoader::notifyParserStopped() |
| 155 { | 160 { |
| 156 setState(finishParsing()); | 161 setState(finishParsing()); |
| 157 if (!hasPendingResources()) | 162 if (!hasPendingResources()) |
| 158 setState(finishLoading()); | 163 setState(finishLoading()); |
| 164 |
| 165 DocumentParser* parser = m_document->parser(); |
| 166 ASSERT(parser); |
| 167 parser->removeClient(this); |
| 159 } | 168 } |
| 160 | 169 |
| 161 void HTMLImportLoader::didRemoveAllPendingStylesheet() | 170 void HTMLImportLoader::didRemoveAllPendingStylesheet() |
| 162 { | 171 { |
| 163 if (m_state == StateParsed) | 172 if (m_state == StateParsed) |
| 164 setState(finishLoading()); | 173 setState(finishLoading()); |
| 165 } | 174 } |
| 166 | 175 |
| 167 bool HTMLImportLoader::hasPendingResources() const | 176 bool HTMLImportLoader::hasPendingResources() const |
| 168 { | 177 { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 visitor->trace(m_controller); | 229 visitor->trace(m_controller); |
| 221 #if ENABLE(OILPAN) | 230 #if ENABLE(OILPAN) |
| 222 visitor->trace(m_imports); | 231 visitor->trace(m_imports); |
| 223 #endif | 232 #endif |
| 224 visitor->trace(m_document); | 233 visitor->trace(m_document); |
| 225 visitor->trace(m_writer); | 234 visitor->trace(m_writer); |
| 226 visitor->trace(m_microtaskQueue); | 235 visitor->trace(m_microtaskQueue); |
| 227 } | 236 } |
| 228 | 237 |
| 229 } // namespace blink | 238 } // namespace blink |
| OLD | NEW |