| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 "config.h" | 31 #include "config.h" |
| 32 #include "core/html/imports/HTMLImportStateResolver.h" | 32 #include "core/html/imports/HTMLImportStateResolver.h" |
| 33 | 33 |
| 34 #include "core/html/imports/HTMLImport.h" | 34 #include "core/html/imports/HTMLImport.h" |
| 35 #include "core/html/imports/HTMLImportChild.h" |
| 35 | 36 |
| 36 namespace WebCore { | 37 namespace WebCore { |
| 37 | 38 |
| 38 inline bool HTMLImportStateResolver::isBlockingFollowers(HTMLImport* import) | 39 inline bool HTMLImportStateResolver::isBlockingFollowers(HTMLImport* import) |
| 39 { | 40 { |
| 40 if (!import->isSync()) | 41 if (!import->isSync()) |
| 41 return false; | 42 return false; |
| 43 if (!toHTMLImportChild(import)->isFirst()) |
| 44 return false; |
| 42 if (!import->loader()) | 45 if (!import->loader()) |
| 43 return true; | 46 return true; |
| 44 return !import->state().isReady(); | 47 return !import->state().isReady(); |
| 45 } | 48 } |
| 46 | 49 |
| 47 inline bool HTMLImportStateResolver::shouldBlockScriptExecution() const | 50 inline bool HTMLImportStateResolver::shouldBlockScriptExecution() const |
| 48 { | 51 { |
| 49 for (const HTMLImport* ancestor = m_import; ancestor; ancestor = ancestor->p
arent()) { | 52 // FIXME: Memoize to make this faster. |
| 50 if (ancestor->previous() && isBlockingFollowers(ancestor->previous())) | 53 for (HTMLImport* ancestor = m_import; ancestor; ancestor = ancestor->parent(
)) { |
| 51 return true; | 54 for (HTMLImport* predecessor = ancestor->previous(); predecessor; predec
essor = predecessor->previous()) { |
| 55 if (isBlockingFollowers(predecessor)) |
| 56 return true; |
| 57 } |
| 52 } | 58 } |
| 53 | 59 |
| 54 for (HTMLImport* child = m_import->firstChild(); child; child = child->next(
)) { | 60 for (HTMLImport* child = m_import->firstChild(); child; child = child->next(
)) { |
| 55 if (isBlockingFollowers(child)) | 61 if (isBlockingFollowers(child)) |
| 56 return true; | 62 return true; |
| 57 } | 63 } |
| 58 | 64 |
| 59 return false; | 65 return false; |
| 60 } | 66 } |
| 61 | 67 |
| 62 inline bool HTMLImportStateResolver::isActive() const | 68 inline bool HTMLImportStateResolver::isActive() const |
| 63 { | 69 { |
| 64 return !m_import->isDone(); | 70 return !m_import->isDone(); |
| 65 } | 71 } |
| 66 | 72 |
| 67 HTMLImportState HTMLImportStateResolver::resolve() const | 73 HTMLImportState HTMLImportStateResolver::resolve() const |
| 68 { | 74 { |
| 69 if (shouldBlockScriptExecution()) | 75 if (shouldBlockScriptExecution()) |
| 70 return HTMLImportState(HTMLImportState::BlockingScriptExecution); | 76 return HTMLImportState(HTMLImportState::BlockingScriptExecution); |
| 71 if (isActive()) | 77 if (isActive()) |
| 72 return HTMLImportState(HTMLImportState::Active); | 78 return HTMLImportState(HTMLImportState::Active); |
| 73 return HTMLImportState(HTMLImportState::Ready); | 79 return HTMLImportState(HTMLImportState::Ready); |
| 74 } | 80 } |
| 75 | 81 |
| 76 } | 82 } |
| 77 | 83 |
| OLD | NEW |