| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 void HTMLImportChild::importDestroyed() | 125 void HTMLImportChild::importDestroyed() |
| 126 { | 126 { |
| 127 if (parent()) | 127 if (parent()) |
| 128 parent()->removeChild(this); | 128 parent()->removeChild(this); |
| 129 if (m_loader) { | 129 if (m_loader) { |
| 130 m_loader->removeImport(this); | 130 m_loader->removeImport(this); |
| 131 m_loader = 0; | 131 m_loader = 0; |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 HTMLImportRoot* HTMLImportChild::root() | |
| 136 { | |
| 137 return parent() ? parent()->root() : 0; | |
| 138 } | |
| 139 | |
| 140 Document* HTMLImportChild::document() const | 135 Document* HTMLImportChild::document() const |
| 141 { | 136 { |
| 142 return (m_loader && m_loader->isOwnedBy(this)) ? m_loader->document() : 0; | 137 return (m_loader && m_loader->isOwnedBy(this)) ? m_loader->document() : 0; |
| 143 } | 138 } |
| 144 | 139 |
| 140 void HTMLImportChild::stateWillChange() |
| 141 { |
| 142 toHTMLImportsController(root())->scheduleRecalcState(); |
| 143 } |
| 144 |
| 145 void HTMLImportChild::stateDidChange() | 145 void HTMLImportChild::stateDidChange() |
| 146 { | 146 { |
| 147 HTMLImport::stateDidChange(); | 147 HTMLImport::stateDidChange(); |
| 148 | 148 |
| 149 // Once all preceding imports are loaded, | 149 // Once all preceding imports are loaded, |
| 150 // HTMLImportChild can decide whether it should load the import by itself | 150 // HTMLImportChild can decide whether it should load the import by itself |
| 151 // or it can share existing one. | 151 // or it can share existing one. |
| 152 if (!state().shouldBlockDocumentCreation()) | 152 if (!state().shouldBlockDocumentCreation()) |
| 153 ensureLoader(); | 153 ensureLoader(); |
| 154 if (state().isReady()) | 154 if (state().isReady()) |
| 155 didFinish(); | 155 didFinish(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void HTMLImportChild::ensureLoader() | 158 void HTMLImportChild::ensureLoader() |
| 159 { | 159 { |
| 160 if (m_loader) | 160 if (m_loader) |
| 161 return; | 161 return; |
| 162 | 162 |
| 163 if (HTMLImportChild* found = root()->findLinkFor(m_url, this)) | 163 if (HTMLImportChild* found = toHTMLImportsController(root())->findLinkFor(m_
url, this)) |
| 164 shareLoader(found); | 164 shareLoader(found); |
| 165 else | 165 else |
| 166 createLoader(); | 166 createLoader(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void HTMLImportChild::createLoader() | 169 void HTMLImportChild::createLoader() |
| 170 { | 170 { |
| 171 ASSERT(!state().shouldBlockDocumentCreation()); | 171 ASSERT(!state().shouldBlockDocumentCreation()); |
| 172 ASSERT(!m_loader); | 172 ASSERT(!m_loader); |
| 173 m_loader = root()->toController()->createLoader(); | 173 m_loader = toHTMLImportsController(root())->createLoader(); |
| 174 m_loader->addImport(this); | 174 m_loader->addImport(this); |
| 175 m_loader->startLoading(resource()); | 175 m_loader->startLoading(resource()); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void HTMLImportChild::shareLoader(HTMLImportChild* loader) | 178 void HTMLImportChild::shareLoader(HTMLImportChild* loader) |
| 179 { | 179 { |
| 180 ASSERT(!m_loader); | 180 ASSERT(!m_loader); |
| 181 m_loader = loader->m_loader; | 181 m_loader = loader->m_loader; |
| 182 m_loader->addImport(this); | 182 m_loader->addImport(this); |
| 183 stateWillChange(); | 183 stateWillChange(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 HTMLImport::showThis(); | 231 HTMLImport::showThis(); |
| 232 fprintf(stderr, " loader=%p own=%s async=%s url=%s", | 232 fprintf(stderr, " loader=%p own=%s async=%s url=%s", |
| 233 m_loader, | 233 m_loader, |
| 234 hasLoader() && ownsLoader() ? "Y" : "N", | 234 hasLoader() && ownsLoader() ? "Y" : "N", |
| 235 isSync() ? "Y" : "N", | 235 isSync() ? "Y" : "N", |
| 236 url().string().utf8().data()); | 236 url().string().utf8().data()); |
| 237 } | 237 } |
| 238 #endif | 238 #endif |
| 239 | 239 |
| 240 } // namespace WebCore | 240 } // namespace WebCore |
| OLD | NEW |