| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/html/imports/HTMLImport.h" | 32 #include "core/html/imports/HTMLImport.h" |
| 33 | 33 |
| 34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
| 35 #include "core/html/imports/HTMLImportStateResolver.h" | 35 #include "core/html/imports/HTMLImportStateResolver.h" |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 HTMLImport* HTMLImport::root() |
| 40 { |
| 41 HTMLImport* i = this; |
| 42 while (i->parent()) |
| 43 i = i->parent(); |
| 44 return i; |
| 45 } |
| 46 |
| 39 void HTMLImport::appendChild(HTMLImport* child) | 47 void HTMLImport::appendChild(HTMLImport* child) |
| 40 { | 48 { |
| 41 TreeNode<HTMLImport>::appendChild(child); | 49 TreeNode<HTMLImport>::appendChild(child); |
| 42 | 50 |
| 43 // This prevents HTML parser from going beyond the | 51 // This prevents HTML parser from going beyond the |
| 44 // blockage line before the precise state is computed by recalcState(). | 52 // blockage line before the precise state is computed by recalcState(). |
| 45 if (child->isSync()) | 53 if (child->isSync()) |
| 46 m_state = HTMLImportState::blockedState(); | 54 m_state = HTMLImportState::blockedState(); |
| 47 | 55 |
| 48 stateWillChange(); | 56 stateWillChange(); |
| 49 } | 57 } |
| 50 | 58 |
| 51 void HTMLImport::stateDidChange() | 59 void HTMLImport::stateDidChange() |
| 52 { | 60 { |
| 53 if (!state().shouldBlockScriptExecution()) { | 61 if (!state().shouldBlockScriptExecution()) { |
| 54 if (Document* document = this->document()) | 62 if (Document* document = this->document()) |
| 55 document->didLoadAllImports(); | 63 document->didLoadAllImports(); |
| 56 } | 64 } |
| 57 } | 65 } |
| 58 | 66 |
| 59 void HTMLImport::stateWillChange() | |
| 60 { | |
| 61 root()->scheduleRecalcState(); | |
| 62 } | |
| 63 | |
| 64 void HTMLImport::recalcTreeState(HTMLImport* root) | 67 void HTMLImport::recalcTreeState(HTMLImport* root) |
| 65 { | 68 { |
| 66 ASSERT(root == root->root()); | |
| 67 | |
| 68 HashMap<HTMLImport*, HTMLImportState> snapshot; | 69 HashMap<HTMLImport*, HTMLImportState> snapshot; |
| 69 Vector<HTMLImport*> updated; | 70 Vector<HTMLImport*> updated; |
| 70 | 71 |
| 71 for (HTMLImport* i = root; i; i = traverseNext(i)) { | 72 for (HTMLImport* i = root; i; i = traverseNext(i)) { |
| 72 snapshot.add(i, i->state()); | 73 snapshot.add(i, i->state()); |
| 73 i->m_state = HTMLImportState::invalidState(); | 74 i->m_state = HTMLImportState::invalidState(); |
| 74 } | 75 } |
| 75 | 76 |
| 76 // The post-visit DFS order matters here because | 77 // The post-visit DFS order matters here because |
| 77 // HTMLImportStateResolver in recalcState() Depends on | 78 // HTMLImportStateResolver in recalcState() Depends on |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 child->showTree(highlight, depth + 1); | 113 child->showTree(highlight, depth + 1); |
| 113 } | 114 } |
| 114 | 115 |
| 115 void HTMLImport::showThis() | 116 void HTMLImport::showThis() |
| 116 { | 117 { |
| 117 fprintf(stderr, "%p state=%d", this, m_state.peekValueForDebug()); | 118 fprintf(stderr, "%p state=%d", this, m_state.peekValueForDebug()); |
| 118 } | 119 } |
| 119 #endif | 120 #endif |
| 120 | 121 |
| 121 } // namespace WebCore | 122 } // namespace WebCore |
| OLD | NEW |