| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } | 56 } |
| 57 | 57 |
| 58 void HTMLImportLoader::importDestroyed() | 58 void HTMLImportLoader::importDestroyed() |
| 59 { | 59 { |
| 60 clear(); | 60 clear(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void HTMLImportLoader::clear() | 63 void HTMLImportLoader::clear() |
| 64 { | 64 { |
| 65 m_controller = 0; | 65 m_controller = 0; |
| 66 if (m_importedDocument) { | 66 if (m_document) { |
| 67 m_importedDocument->setImportsController(0); | 67 m_document->setImportsController(0); |
| 68 m_importedDocument->cancelParsing(); | 68 m_document->cancelParsing(); |
| 69 m_importedDocument.clear(); | 69 m_document.clear(); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 void HTMLImportLoader::startLoading(const ResourcePtr<RawResource>& resource) | 73 void HTMLImportLoader::startLoading(const ResourcePtr<RawResource>& resource) |
| 74 { | 74 { |
| 75 setResource(resource); | 75 setResource(resource); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void HTMLImportLoader::responseReceived(Resource* resource, const ResourceRespon
se& response) | 78 void HTMLImportLoader::responseReceived(Resource* resource, const ResourceRespon
se& response) |
| 79 { | 79 { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 102 } | 102 } |
| 103 | 103 |
| 104 setState(finishWriting()); | 104 setState(finishWriting()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 HTMLImportLoader::State HTMLImportLoader::startWritingAndParsing(const ResourceR
esponse& response) | 107 HTMLImportLoader::State HTMLImportLoader::startWritingAndParsing(const ResourceR
esponse& response) |
| 108 { | 108 { |
| 109 ASSERT(!m_imports.isEmpty()); | 109 ASSERT(!m_imports.isEmpty()); |
| 110 DocumentInit init = DocumentInit(response.url(), 0, m_controller->master()->
contextDocument(), m_controller) | 110 DocumentInit init = DocumentInit(response.url(), 0, m_controller->master()->
contextDocument(), m_controller) |
| 111 .withRegistrationContext(m_controller->master()->registrationContext()); | 111 .withRegistrationContext(m_controller->master()->registrationContext()); |
| 112 m_importedDocument = HTMLDocument::create(init); | 112 m_document = HTMLDocument::create(init); |
| 113 m_writer = DocumentWriter::create(m_importedDocument.get(), response.mimeTyp
e(), "UTF-8"); | 113 m_writer = DocumentWriter::create(m_document.get(), response.mimeType(), "UT
F-8"); |
| 114 | 114 |
| 115 return StateLoading; | 115 return StateLoading; |
| 116 } | 116 } |
| 117 | 117 |
| 118 HTMLImportLoader::State HTMLImportLoader::finishWriting() | 118 HTMLImportLoader::State HTMLImportLoader::finishWriting() |
| 119 { | 119 { |
| 120 return StateWritten; | 120 return StateWritten; |
| 121 } | 121 } |
| 122 | 122 |
| 123 HTMLImportLoader::State HTMLImportLoader::finishParsing() | 123 HTMLImportLoader::State HTMLImportLoader::finishParsing() |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } | 155 } |
| 156 | 156 |
| 157 void HTMLImportLoader::didRemoveAllPendingStylesheet() | 157 void HTMLImportLoader::didRemoveAllPendingStylesheet() |
| 158 { | 158 { |
| 159 if (m_state == StateParsed) | 159 if (m_state == StateParsed) |
| 160 setState(finishLoading()); | 160 setState(finishLoading()); |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool HTMLImportLoader::hasPendingResources() const | 163 bool HTMLImportLoader::hasPendingResources() const |
| 164 { | 164 { |
| 165 return m_importedDocument && m_importedDocument->styleEngine()->hasPendingSh
eets(); | 165 return m_document && m_document->styleEngine()->hasPendingSheets(); |
| 166 } | |
| 167 | |
| 168 Document* HTMLImportLoader::importedDocument() const | |
| 169 { | |
| 170 if (m_state == StateError) | |
| 171 return 0; | |
| 172 return m_importedDocument.get(); | |
| 173 } | 166 } |
| 174 | 167 |
| 175 void HTMLImportLoader::didFinishLoading() | 168 void HTMLImportLoader::didFinishLoading() |
| 176 { | 169 { |
| 177 for (size_t i = 0; i < m_imports.size(); ++i) | 170 for (size_t i = 0; i < m_imports.size(); ++i) |
| 178 m_imports[i]->didFinishLoading(); | 171 m_imports[i]->didFinishLoading(); |
| 179 | 172 |
| 180 clearResource(); | 173 clearResource(); |
| 181 | 174 |
| 182 ASSERT(!m_importedDocument || !m_importedDocument->parsing()); | 175 ASSERT(!m_document || !m_document->parsing()); |
| 183 } | 176 } |
| 184 | 177 |
| 185 void HTMLImportLoader::moveToFirst(HTMLImportChild* import) | 178 void HTMLImportLoader::moveToFirst(HTMLImportChild* import) |
| 186 { | 179 { |
| 187 size_t position = m_imports.find(import); | 180 size_t position = m_imports.find(import); |
| 188 ASSERT(kNotFound != position); | 181 ASSERT(kNotFound != position); |
| 189 m_imports.remove(position); | 182 m_imports.remove(position); |
| 190 m_imports.insert(0, import); | 183 m_imports.insert(0, import); |
| 191 } | 184 } |
| 192 | 185 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 210 { | 203 { |
| 211 return firstImport()->state().shouldBlockScriptExecution(); | 204 return firstImport()->state().shouldBlockScriptExecution(); |
| 212 } | 205 } |
| 213 | 206 |
| 214 PassRefPtr<CustomElementMicrotaskQueue> HTMLImportLoader::microtaskQueue() const | 207 PassRefPtr<CustomElementMicrotaskQueue> HTMLImportLoader::microtaskQueue() const |
| 215 { | 208 { |
| 216 return m_microtaskQueue; | 209 return m_microtaskQueue; |
| 217 } | 210 } |
| 218 | 211 |
| 219 } // namespace WebCore | 212 } // namespace WebCore |
| OLD | NEW |