| 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 19 matching lines...) Expand all Loading... |
| 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 | 35 |
| 36 namespace WebCore { | 36 namespace WebCore { |
| 37 | 37 |
| 38 inline bool HTMLImportStateResolver::isBlockingFollowers(HTMLImport* import) | 38 inline bool HTMLImportStateResolver::isBlockingFollowers(HTMLImport* import) |
| 39 { | 39 { |
| 40 if (!import->hasLoader()) | 40 if (!import->loader()) |
| 41 return true; | 41 return true; |
| 42 if (!import->ownsLoader()) | |
| 43 return false; | |
| 44 return !import->state().isReady(); | 42 return !import->state().isReady(); |
| 45 } | 43 } |
| 46 | 44 |
| 47 inline bool HTMLImportStateResolver::shouldBlockDocumentCreation() const | 45 inline bool HTMLImportStateResolver::shouldBlockScriptExecution() const |
| 48 { | 46 { |
| 49 // If any of its preceeding imports isn't ready, this import | |
| 50 // cannot start loading because such preceeding onces can include | |
| 51 // duplicating import that should wins over this. | |
| 52 for (const HTMLImport* ancestor = m_import; ancestor; ancestor = ancestor->p
arent()) { | 47 for (const HTMLImport* ancestor = m_import; ancestor; ancestor = ancestor->p
arent()) { |
| 53 if (ancestor->previous() && isBlockingFollowers(ancestor->previous())) | 48 if (ancestor->previous() && isBlockingFollowers(ancestor->previous())) |
| 54 return true; | 49 return true; |
| 55 } | 50 } |
| 56 | 51 |
| 57 return false; | |
| 58 } | |
| 59 | |
| 60 inline bool HTMLImportStateResolver::shouldBlockScriptExecution() const | |
| 61 { | |
| 62 for (HTMLImport* child = m_import->firstChild(); child; child = child->next(
)) { | 52 for (HTMLImport* child = m_import->firstChild(); child; child = child->next(
)) { |
| 63 if (child->isSync() && isBlockingFollowers(child)) | 53 if (child->isSync() && isBlockingFollowers(child)) |
| 64 return true; | 54 return true; |
| 65 } | 55 } |
| 66 | 56 |
| 67 return false; | 57 return false; |
| 68 } | 58 } |
| 69 | 59 |
| 70 inline bool HTMLImportStateResolver::isActive() const | 60 inline bool HTMLImportStateResolver::isActive() const |
| 71 { | 61 { |
| 72 return !m_import->isDone(); | 62 return !m_import->isDone(); |
| 73 } | 63 } |
| 74 | 64 |
| 75 HTMLImportState HTMLImportStateResolver::resolve() const | 65 HTMLImportState HTMLImportStateResolver::resolve() const |
| 76 { | 66 { |
| 77 if (shouldBlockDocumentCreation()) | |
| 78 return HTMLImportState(HTMLImportState::BlockingDocumentCreation); | |
| 79 if (shouldBlockScriptExecution()) | 67 if (shouldBlockScriptExecution()) |
| 80 return HTMLImportState(HTMLImportState::BlockingScriptExecution); | 68 return HTMLImportState(HTMLImportState::BlockingScriptExecution); |
| 81 if (isActive()) | 69 if (isActive()) |
| 82 return HTMLImportState(HTMLImportState::Active); | 70 return HTMLImportState(HTMLImportState::Active); |
| 83 return HTMLImportState(HTMLImportState::Ready); | 71 return HTMLImportState(HTMLImportState::Ready); |
| 84 } | 72 } |
| 85 | 73 |
| 86 } | 74 } |
| 87 | 75 |
| OLD | NEW |