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 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/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/StyleEngine.h" | 35 #include "core/dom/StyleEngine.h" |
| 36 #include "core/dom/custom/CustomElementMicrotaskQueue.h" |
36 #include "core/html/HTMLDocument.h" | 37 #include "core/html/HTMLDocument.h" |
37 #include "core/html/imports/HTMLImportChild.h" | 38 #include "core/html/imports/HTMLImportChild.h" |
38 #include "core/html/imports/HTMLImportsController.h" | 39 #include "core/html/imports/HTMLImportsController.h" |
39 #include "core/loader/DocumentWriter.h" | 40 #include "core/loader/DocumentWriter.h" |
40 #include "platform/network/ContentSecurityPolicyResponseHeaders.h" | 41 #include "platform/network/ContentSecurityPolicyResponseHeaders.h" |
41 | 42 |
42 | 43 |
43 namespace WebCore { | 44 namespace WebCore { |
44 | 45 |
45 HTMLImportLoader::HTMLImportLoader(HTMLImportsController* controller) | 46 HTMLImportLoader::HTMLImportLoader(HTMLImportsController* controller) |
46 : m_controller(controller) | 47 : m_controller(controller) |
47 , m_state(StateLoading) | 48 , m_state(StateLoading) |
| 49 , m_microtaskQueue(CustomElementMicrotaskQueue::create()) |
48 { | 50 { |
49 } | 51 } |
50 | 52 |
51 HTMLImportLoader::~HTMLImportLoader() | 53 HTMLImportLoader::~HTMLImportLoader() |
52 { | 54 { |
53 clear(); | 55 clear(); |
54 } | 56 } |
55 | 57 |
56 void HTMLImportLoader::importDestroyed() | 58 void HTMLImportLoader::importDestroyed() |
57 { | 59 { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void HTMLImportLoader::didFinishLoading() | 175 void HTMLImportLoader::didFinishLoading() |
174 { | 176 { |
175 for (size_t i = 0; i < m_imports.size(); ++i) | 177 for (size_t i = 0; i < m_imports.size(); ++i) |
176 m_imports[i]->didFinishLoading(); | 178 m_imports[i]->didFinishLoading(); |
177 | 179 |
178 clearResource(); | 180 clearResource(); |
179 | 181 |
180 ASSERT(!m_importedDocument || !m_importedDocument->parsing()); | 182 ASSERT(!m_importedDocument || !m_importedDocument->parsing()); |
181 } | 183 } |
182 | 184 |
183 void HTMLImportLoader::addImport(HTMLImportChild* client) | 185 void HTMLImportLoader::addImport(HTMLImportChild* import) |
184 { | 186 { |
185 ASSERT(kNotFound == m_imports.find(client)); | 187 ASSERT(kNotFound == m_imports.find(import)); |
186 m_imports.append(client); | 188 |
| 189 // Ensuring firstImport() manages all children that is loaded by the documen
t. |
| 190 // |
| 191 // FIXME: |
| 192 // This is a design flaw. |
| 193 // Import children should be managed by HTMLImportLoader, not by HTMLImpor
t. |
| 194 if (!m_imports.isEmpty() && import->precedes(firstImport())) { |
| 195 import->takeChildrenFrom(firstImport()); |
| 196 m_imports.insert(0, import); |
| 197 } else { |
| 198 m_imports.append(import); |
| 199 } |
| 200 |
187 if (isDone()) | 201 if (isDone()) |
188 client->didFinishLoading(); | 202 import->didFinishLoading(); |
189 } | 203 } |
190 | 204 |
191 void HTMLImportLoader::removeImport(HTMLImportChild* client) | 205 void HTMLImportLoader::removeImport(HTMLImportChild* client) |
192 { | 206 { |
193 ASSERT(kNotFound != m_imports.find(client)); | 207 ASSERT(kNotFound != m_imports.find(client)); |
194 m_imports.remove(m_imports.find(client)); | 208 m_imports.remove(m_imports.find(client)); |
195 } | 209 } |
196 | 210 |
| 211 bool HTMLImportLoader::shouldBlockScriptExecution() const |
| 212 { |
| 213 for (size_t i = 0; i < m_imports.size(); ++i) { |
| 214 if (!m_imports[i]->state().shouldBlockScriptExecution()) |
| 215 return false; |
| 216 } |
| 217 |
| 218 return true; |
| 219 } |
| 220 |
| 221 PassRefPtr<CustomElementMicrotaskQueue> HTMLImportLoader::microtaskQueue() const |
| 222 { |
| 223 return m_microtaskQueue; |
| 224 } |
| 225 |
197 } // namespace WebCore | 226 } // namespace WebCore |
OLD | NEW |