| 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 "sky/engine/config.h" | 31 #include "sky/engine/config.h" |
| 32 #include "sky/engine/core/html/imports/HTMLImportChild.h" | 32 #include "sky/engine/core/html/imports/HTMLImportChild.h" |
| 33 | 33 |
| 34 #include "sky/engine/core/dom/Document.h" | 34 #include "sky/engine/core/dom/Document.h" |
| 35 #include "sky/engine/core/dom/custom/CustomElement.h" | |
| 36 #include "sky/engine/core/dom/custom/CustomElementMicrotaskImportStep.h" | |
| 37 #include "sky/engine/core/dom/custom/CustomElementSyncMicrotaskQueue.h" | |
| 38 #include "sky/engine/core/html/imports/HTMLImportChildClient.h" | 35 #include "sky/engine/core/html/imports/HTMLImportChildClient.h" |
| 39 #include "sky/engine/core/html/imports/HTMLImportLoader.h" | 36 #include "sky/engine/core/html/imports/HTMLImportLoader.h" |
| 40 #include "sky/engine/core/html/imports/HTMLImportTreeRoot.h" | 37 #include "sky/engine/core/html/imports/HTMLImportTreeRoot.h" |
| 41 #include "sky/engine/core/html/imports/HTMLImportsController.h" | 38 #include "sky/engine/core/html/imports/HTMLImportsController.h" |
| 42 | 39 |
| 43 namespace blink { | 40 namespace blink { |
| 44 | 41 |
| 45 HTMLImportChild::HTMLImportChild(const KURL& url, HTMLImportLoader* loader, Sync
Mode sync) | 42 HTMLImportChild::HTMLImportChild(const KURL& url, HTMLImportLoader* loader, Sync
Mode sync) |
| 46 : HTMLImport(sync) | 43 : HTMLImport(sync) |
| 47 , m_url(url) | 44 , m_url(url) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 66 | 63 |
| 67 void HTMLImportChild::ownerInserted() | 64 void HTMLImportChild::ownerInserted() |
| 68 { | 65 { |
| 69 if (!m_loader->isDone()) | 66 if (!m_loader->isDone()) |
| 70 return; | 67 return; |
| 71 root()->document()->styleResolverChanged(); | 68 root()->document()->styleResolverChanged(); |
| 72 } | 69 } |
| 73 | 70 |
| 74 void HTMLImportChild::didShareLoader() | 71 void HTMLImportChild::didShareLoader() |
| 75 { | 72 { |
| 76 createCustomElementMicrotaskStepIfNeeded(); | |
| 77 stateWillChange(); | 73 stateWillChange(); |
| 78 } | 74 } |
| 79 | 75 |
| 80 void HTMLImportChild::didStartLoading() | 76 void HTMLImportChild::didStartLoading() |
| 81 { | 77 { |
| 82 createCustomElementMicrotaskStepIfNeeded(); | |
| 83 } | 78 } |
| 84 | 79 |
| 85 void HTMLImportChild::didFinish() | 80 void HTMLImportChild::didFinish() |
| 86 { | 81 { |
| 87 if (m_client) | 82 if (m_client) |
| 88 m_client->didFinish(); | 83 m_client->didFinish(); |
| 89 } | 84 } |
| 90 | 85 |
| 91 void HTMLImportChild::didFinishLoading() | 86 void HTMLImportChild::didFinishLoading() |
| 92 { | 87 { |
| 93 stateWillChange(); | 88 stateWillChange(); |
| 94 CustomElement::didFinishLoadingImport(*(root()->document())); | |
| 95 } | |
| 96 | |
| 97 void HTMLImportChild::didFinishUpgradingCustomElements() | |
| 98 { | |
| 99 stateWillChange(); | |
| 100 m_customElementMicrotaskStep.clear(); | |
| 101 } | 89 } |
| 102 | 90 |
| 103 #if !ENABLE(OILPAN) | 91 #if !ENABLE(OILPAN) |
| 104 void HTMLImportChild::importDestroyed() | 92 void HTMLImportChild::importDestroyed() |
| 105 { | 93 { |
| 106 if (parent()) | 94 if (parent()) |
| 107 parent()->removeChild(this); | 95 parent()->removeChild(this); |
| 108 | 96 |
| 109 ASSERT(m_loader); | 97 ASSERT(m_loader); |
| 110 m_loader->removeImport(this); | 98 m_loader->removeImport(this); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 130 } | 118 } |
| 131 | 119 |
| 132 void HTMLImportChild::stateDidChange() | 120 void HTMLImportChild::stateDidChange() |
| 133 { | 121 { |
| 134 HTMLImport::stateDidChange(); | 122 HTMLImport::stateDidChange(); |
| 135 | 123 |
| 136 if (state().isReady()) | 124 if (state().isReady()) |
| 137 didFinish(); | 125 didFinish(); |
| 138 } | 126 } |
| 139 | 127 |
| 140 void HTMLImportChild::invalidateCustomElementMicrotaskStep() | |
| 141 { | |
| 142 if (!m_customElementMicrotaskStep) | |
| 143 return; | |
| 144 m_customElementMicrotaskStep->invalidate(); | |
| 145 m_customElementMicrotaskStep.clear(); | |
| 146 } | |
| 147 | |
| 148 void HTMLImportChild::createCustomElementMicrotaskStepIfNeeded() | |
| 149 { | |
| 150 ASSERT(!m_customElementMicrotaskStep); | |
| 151 | |
| 152 if (!isDone() && !formsCycle()) { | |
| 153 #if ENABLE(OILPAN) | |
| 154 m_customElementMicrotaskStep = CustomElement::didCreateImport(this); | |
| 155 #else | |
| 156 m_customElementMicrotaskStep = CustomElement::didCreateImport(this)->wea
kPtr(); | |
| 157 #endif | |
| 158 } | |
| 159 } | |
| 160 | |
| 161 bool HTMLImportChild::isDone() const | 128 bool HTMLImportChild::isDone() const |
| 162 { | 129 { |
| 163 ASSERT(m_loader); | 130 ASSERT(m_loader); |
| 164 | 131 return m_loader->isDone(); |
| 165 return m_loader->isDone() && m_loader->microtaskQueue()->isEmpty() && !m_cus
tomElementMicrotaskStep; | |
| 166 } | 132 } |
| 167 | 133 |
| 168 HTMLImportLoader* HTMLImportChild::loader() const | 134 HTMLImportLoader* HTMLImportChild::loader() const |
| 169 { | 135 { |
| 170 // This should never be called after importDestroyed. | 136 // This should never be called after importDestroyed. |
| 171 ASSERT(m_loader); | 137 ASSERT(m_loader); |
| 172 return m_loader; | 138 return m_loader; |
| 173 } | 139 } |
| 174 | 140 |
| 175 void HTMLImportChild::setClient(HTMLImportChildClient* client) | 141 void HTMLImportChild::setClient(HTMLImportChildClient* client) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 199 // - HTMLImportChild::firstImport() is the "first import" of the DFS order of th
e import tree. | 165 // - HTMLImportChild::firstImport() is the "first import" of the DFS order of th
e import tree. |
| 200 // - The "first import" manages all the children that is loaded by the document. | 166 // - The "first import" manages all the children that is loaded by the document. |
| 201 void HTMLImportChild::normalize() | 167 void HTMLImportChild::normalize() |
| 202 { | 168 { |
| 203 if (!loader()->isFirstImport(this) && this->precedes(loader()->firstImport()
)) { | 169 if (!loader()->isFirstImport(this) && this->precedes(loader()->firstImport()
)) { |
| 204 HTMLImportChild* oldFirst = loader()->firstImport(); | 170 HTMLImportChild* oldFirst = loader()->firstImport(); |
| 205 loader()->moveToFirst(this); | 171 loader()->moveToFirst(this); |
| 206 takeChildrenFrom(oldFirst); | 172 takeChildrenFrom(oldFirst); |
| 207 } | 173 } |
| 208 | 174 |
| 209 for (HTMLImportChild* child = toHTMLImportChild(firstChild()); child; child
= toHTMLImportChild(child->next())) { | 175 for (HTMLImportChild* child = toHTMLImportChild(firstChild()); child; child
= toHTMLImportChild(child->next())) |
| 210 if (child->formsCycle()) | |
| 211 child->invalidateCustomElementMicrotaskStep(); | |
| 212 child->normalize(); | 176 child->normalize(); |
| 213 } | |
| 214 } | 177 } |
| 215 | 178 |
| 216 #if !defined(NDEBUG) | 179 #if !defined(NDEBUG) |
| 217 void HTMLImportChild::showThis() | 180 void HTMLImportChild::showThis() |
| 218 { | 181 { |
| 219 bool isFirst = loader() ? loader()->isFirstImport(this) : false; | 182 bool isFirst = loader() ? loader()->isFirstImport(this) : false; |
| 220 HTMLImport::showThis(); | 183 HTMLImport::showThis(); |
| 221 fprintf(stderr, " loader=%p first=%d, step=%p sync=%s url=%s", | 184 fprintf(stderr, " loader=%p first=%d, sync=%s url=%s", |
| 222 m_loader.get(), | 185 m_loader.get(), |
| 223 isFirst, | 186 isFirst, |
| 224 m_customElementMicrotaskStep.get(), | |
| 225 isSync() ? "Y" : "N", | 187 isSync() ? "Y" : "N", |
| 226 url().string().utf8().data()); | 188 url().string().utf8().data()); |
| 227 } | 189 } |
| 228 #endif | 190 #endif |
| 229 | 191 |
| 230 } // namespace blink | 192 } // namespace blink |
| OLD | NEW |