| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 { | 107 { |
| 108 stateWillChange(); | 108 stateWillChange(); |
| 109 m_customElementMicrotaskStep.clear(); | 109 m_customElementMicrotaskStep.clear(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool HTMLImportChild::isLoaded() const | 112 bool HTMLImportChild::isLoaded() const |
| 113 { | 113 { |
| 114 return m_loader && m_loader->isDone(); | 114 return m_loader && m_loader->isDone(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 bool HTMLImportChild::isFirst() const |
| 118 { |
| 119 return m_loader && m_loader->isFirstImport(this); |
| 120 } |
| 121 |
| 117 Document* HTMLImportChild::importedDocument() const | 122 Document* HTMLImportChild::importedDocument() const |
| 118 { | 123 { |
| 119 if (!m_loader) | 124 if (!m_loader) |
| 120 return 0; | 125 return 0; |
| 121 return m_loader->importedDocument(); | 126 return m_loader->importedDocument(); |
| 122 } | 127 } |
| 123 | 128 |
| 124 void HTMLImportChild::importDestroyed() | 129 void HTMLImportChild::importDestroyed() |
| 125 { | 130 { |
| 126 if (parent()) | 131 if (parent()) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 143 | 148 |
| 144 void HTMLImportChild::stateDidChange() | 149 void HTMLImportChild::stateDidChange() |
| 145 { | 150 { |
| 146 HTMLImport::stateDidChange(); | 151 HTMLImport::stateDidChange(); |
| 147 | 152 |
| 148 ensureLoader(); | 153 ensureLoader(); |
| 149 if (state().isReady()) | 154 if (state().isReady()) |
| 150 didFinish(); | 155 didFinish(); |
| 151 } | 156 } |
| 152 | 157 |
| 158 void HTMLImportChild::createCustomElementMicrotaskStepIfNeeded() |
| 159 { |
| 160 // HTMLImportChild::normalize(), which is called from HTMLImportLoader::addI
mport(), |
| 161 // can move import children to new parents. So their microtask steps should
be updated as well, |
| 162 // to let the steps be in the new parent queues.This method handles such mig
ration. |
| 163 // For implementation simplicity, outdated step objects that are owned by mo
ved children |
| 164 // aren't removed from the (now wrong) queues. Instead, each step invalidate
s its content so that |
| 165 // it is removed from the wrong queue during the next traversal. See parentW
asChanged() for the detail. |
| 166 |
| 167 if (m_customElementMicrotaskStep) { |
| 168 m_customElementMicrotaskStep->parentWasChanged(); |
| 169 m_customElementMicrotaskStep.clear(); |
| 170 } |
| 171 |
| 172 if (!isDone() && !formsCycle()) { |
| 173 m_customElementMicrotaskStep = CustomElement::didCreateImport(this)->wea
kPtr(); |
| 174 } |
| 175 |
| 176 for (HTMLImport* child = firstChild(); child; child = child->next()) |
| 177 toHTMLImportChild(child)->createCustomElementMicrotaskStepIfNeeded(); |
| 178 } |
| 179 |
| 153 void HTMLImportChild::ensureLoader() | 180 void HTMLImportChild::ensureLoader() |
| 154 { | 181 { |
| 155 if (m_loader) | 182 if (m_loader) |
| 156 return; | 183 return; |
| 157 | 184 |
| 158 if (HTMLImportChild* found = toHTMLImportsController(root())->findLinkFor(m_
url, this)) | 185 if (HTMLImportChild* found = toHTMLImportsController(root())->findLinkFor(m_
url, this)) |
| 159 shareLoader(found); | 186 shareLoader(found); |
| 160 else | 187 else |
| 161 createLoader(); | 188 createLoader(); |
| 162 | 189 |
| 163 if (!isDone() && !formsCycle()) { | 190 createCustomElementMicrotaskStepIfNeeded(); |
| 164 ASSERT(!m_customElementMicrotaskStep); | |
| 165 m_customElementMicrotaskStep = CustomElement::didCreateImport(this)->wea
kPtr(); | |
| 166 } | |
| 167 } | 191 } |
| 168 | 192 |
| 169 void HTMLImportChild::createLoader() | 193 void HTMLImportChild::createLoader() |
| 170 { | 194 { |
| 171 ASSERT(!m_loader); | 195 ASSERT(!m_loader); |
| 172 m_loader = toHTMLImportsController(root())->createLoader(); | 196 m_loader = toHTMLImportsController(root())->createLoader(); |
| 173 m_loader->addImport(this); | 197 m_loader->addImport(this); |
| 174 m_loader->startLoading(resource()); | 198 m_loader->startLoading(resource()); |
| 175 } | 199 } |
| 176 | 200 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 fprintf(stderr, " loader=%p first=%d, step=%p sync=%s url=%s", | 261 fprintf(stderr, " loader=%p first=%d, step=%p sync=%s url=%s", |
| 238 m_loader, | 262 m_loader, |
| 239 isFirst, | 263 isFirst, |
| 240 m_customElementMicrotaskStep.get(), | 264 m_customElementMicrotaskStep.get(), |
| 241 isSync() ? "Y" : "N", | 265 isSync() ? "Y" : "N", |
| 242 url().string().utf8().data()); | 266 url().string().utf8().data()); |
| 243 } | 267 } |
| 244 #endif | 268 #endif |
| 245 | 269 |
| 246 } // namespace WebCore | 270 } // namespace WebCore |
| OLD | NEW |