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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #if !ENABLE(OILPAN) | 55 #if !ENABLE(OILPAN) |
56 m_master.guardRef(); | 56 m_master.guardRef(); |
57 #endif | 57 #endif |
58 } | 58 } |
59 | 59 |
60 HTMLImportChild::~HTMLImportChild() | 60 HTMLImportChild::~HTMLImportChild() |
61 { | 61 { |
62 // importDestroyed() should be called before the destruction. | 62 // importDestroyed() should be called before the destruction. |
63 ASSERT(!m_loader); | 63 ASSERT(!m_loader); |
64 | 64 |
65 if (m_customElementMicrotaskStep) { | 65 if (m_customElementMicrotaskStep) |
66 // if Custom Elements were blocked, must unblock them before death | 66 m_customElementMicrotaskStep->importWasDestroyed(); |
67 m_customElementMicrotaskStep->importDidFinish(); | |
68 m_customElementMicrotaskStep = 0; | |
69 } | |
70 | 67 |
71 if (m_client) | 68 if (m_client) |
72 m_client->importChildWasDestroyed(this); | 69 m_client->importChildWasDestroyed(this); |
73 | 70 |
74 #if !ENABLE(OILPAN) | 71 #if !ENABLE(OILPAN) |
75 m_master.guardDeref(); | 72 m_master.guardDeref(); |
76 #endif | 73 #endif |
77 } | 74 } |
78 | 75 |
79 void HTMLImportChild::wasAlreadyLoaded() | 76 void HTMLImportChild::wasAlreadyLoaded() |
(...skipping 12 matching lines...) Expand all Loading... |
92 setResource(resource); | 89 setResource(resource); |
93 | 90 |
94 ensureLoader(); | 91 ensureLoader(); |
95 } | 92 } |
96 | 93 |
97 void HTMLImportChild::didFinish() | 94 void HTMLImportChild::didFinish() |
98 { | 95 { |
99 if (m_client) | 96 if (m_client) |
100 m_client->didFinish(); | 97 m_client->didFinish(); |
101 | 98 |
102 if (m_customElementMicrotaskStep) { | 99 ASSERT(!m_customElementMicrotaskStep); |
103 m_customElementMicrotaskStep->importDidFinish(); | |
104 m_customElementMicrotaskStep = 0; | |
105 } | |
106 } | 100 } |
107 | 101 |
108 void HTMLImportChild::didFinishLoading() | 102 void HTMLImportChild::didFinishLoading() |
109 { | 103 { |
| 104 // This triggers closing handshake between CustomElementMicrotaskImportStep. |
| 105 // It eventually tells back through didFinishMicrotask(), then this import b
ecomes "done". |
| 106 if (m_customElementMicrotaskStep) |
| 107 m_customElementMicrotaskStep->importDidLoad(this); |
110 clearResource(); | 108 clearResource(); |
111 stateWillChange(); | 109 stateWillChange(); |
112 } | 110 } |
113 | 111 |
| 112 void HTMLImportChild::didFinishMicrotask() |
| 113 { |
| 114 m_customElementMicrotaskStep = 0; |
| 115 stateWillChange(); |
| 116 } |
| 117 |
114 Document* HTMLImportChild::importedDocument() const | 118 Document* HTMLImportChild::importedDocument() const |
115 { | 119 { |
116 if (!m_loader) | 120 if (!m_loader) |
117 return 0; | 121 return 0; |
118 return m_loader->importedDocument(); | 122 return m_loader->importedDocument(); |
119 } | 123 } |
120 | 124 |
121 void HTMLImportChild::importDestroyed() | 125 void HTMLImportChild::importDestroyed() |
122 { | 126 { |
123 if (parent()) | 127 if (parent()) |
(...skipping 26 matching lines...) Expand all Loading... |
150 void HTMLImportChild::ensureLoader() | 154 void HTMLImportChild::ensureLoader() |
151 { | 155 { |
152 if (m_loader) | 156 if (m_loader) |
153 return; | 157 return; |
154 | 158 |
155 if (HTMLImportChild* found = toHTMLImportsController(root())->findLinkFor(m_
url, this)) | 159 if (HTMLImportChild* found = toHTMLImportsController(root())->findLinkFor(m_
url, this)) |
156 shareLoader(found); | 160 shareLoader(found); |
157 else | 161 else |
158 createLoader(); | 162 createLoader(); |
159 | 163 |
160 if (isSync() && !isDone()) { | 164 if (!isDone() && !formsCycle()) { |
161 ASSERT(!m_customElementMicrotaskStep); | 165 ASSERT(!m_customElementMicrotaskStep); |
162 m_customElementMicrotaskStep = CustomElement::didCreateImport(this); | 166 m_customElementMicrotaskStep = CustomElement::didCreateImport(this); |
163 } | 167 } |
164 } | 168 } |
165 | 169 |
166 void HTMLImportChild::createLoader() | 170 void HTMLImportChild::createLoader() |
167 { | 171 { |
168 ASSERT(!m_loader); | 172 ASSERT(!m_loader); |
169 m_loader = toHTMLImportsController(root())->createLoader(); | 173 m_loader = toHTMLImportsController(root())->createLoader(); |
170 m_loader->addImport(this); | 174 m_loader->addImport(this); |
171 m_loader->startLoading(resource()); | 175 m_loader->startLoading(resource()); |
172 } | 176 } |
173 | 177 |
174 void HTMLImportChild::shareLoader(HTMLImportChild* loader) | 178 void HTMLImportChild::shareLoader(HTMLImportChild* loader) |
175 { | 179 { |
176 ASSERT(!m_loader); | 180 ASSERT(!m_loader); |
177 m_loader = loader->m_loader; | 181 m_loader = loader->m_loader; |
178 m_loader->addImport(this); | 182 m_loader->addImport(this); |
179 stateWillChange(); | 183 stateWillChange(); |
180 } | 184 } |
181 | 185 |
182 bool HTMLImportChild::isDone() const | 186 bool HTMLImportChild::isDone() const |
183 { | 187 { |
184 return m_loader && m_loader->isDone(); | 188 return m_loader && m_loader->isDone() && !m_customElementMicrotaskStep; |
185 } | 189 } |
186 | 190 |
187 bool HTMLImportChild::loaderHasError() const | 191 bool HTMLImportChild::loaderHasError() const |
188 { | 192 { |
189 return m_loader && m_loader->hasError(); | 193 return m_loader && m_loader->hasError(); |
190 } | 194 } |
191 | 195 |
192 | 196 |
193 void HTMLImportChild::setClient(HTMLImportChildClient* client) | 197 void HTMLImportChild::setClient(HTMLImportChildClient* client) |
194 { | 198 { |
(...skipping 21 matching lines...) Expand all Loading... |
216 { | 220 { |
217 HTMLImport::showThis(); | 221 HTMLImport::showThis(); |
218 fprintf(stderr, " loader=%p sync=%s url=%s", | 222 fprintf(stderr, " loader=%p sync=%s url=%s", |
219 m_loader, | 223 m_loader, |
220 isSync() ? "Y" : "N", | 224 isSync() ? "Y" : "N", |
221 url().string().utf8().data()); | 225 url().string().utf8().data()); |
222 } | 226 } |
223 #endif | 227 #endif |
224 | 228 |
225 } // namespace WebCore | 229 } // namespace WebCore |
OLD | NEW |