Index: Source/core/html/HTMLImport.cpp |
diff --git a/Source/core/html/HTMLImport.cpp b/Source/core/html/HTMLImport.cpp |
index e55f8433125732d32614abeecdbbc23d5e20ecd7..0f1407635f699278e922524ec75c252c6d3dfc8c 100644 |
--- a/Source/core/html/HTMLImport.cpp |
+++ b/Source/core/html/HTMLImport.cpp |
@@ -35,13 +35,6 @@ |
namespace WebCore { |
-bool HTMLImport::haveChildrenLoaded() |
-{ |
- if (HTMLImportsController* controller = this->controller()) |
- return controller->haveChildrenLoaded(this); |
- return true; |
-} |
- |
Frame* HTMLImport::frame() |
{ |
return master()->frame(); |
@@ -52,4 +45,94 @@ Document* HTMLImport::master() |
return controller()->document(); |
} |
+void HTMLImport::appendChild(HTMLImport* child) |
+{ |
+ ASSERT(child->parent() == this); |
+ ASSERT(!child->hasChildren()); |
+ |
+ if (isBlocked()) |
+ child->setBlocked(true); |
+ m_children.append(child); |
+ blockAfter(child); |
+} |
+ |
+void HTMLImport::didUnblock() |
+{ |
+ ASSERT(!isBlocked()); |
+ if (!isProcessing()) |
+ return; |
+ |
+ if (Document* document = this->document()) |
+ document->didLoadAllImports(); |
+} |
+ |
+bool HTMLImport::areChilrenLoaded() const |
+{ |
+ for (size_t i = 0; i < m_children.size(); ++i) { |
+ if (!m_children[i]->isLoaded()) |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
+bool HTMLImport::arePredecessorsLoaded() const |
+{ |
+ HTMLImport* parent = this->parent(); |
+ if (!parent) |
+ return true; |
+ |
+ for (size_t i = 0; i < parent->m_children.size(); ++i) { |
+ HTMLImport* sibling = parent->m_children[i]; |
+ if (sibling == this) |
+ break; |
+ if (!sibling->isLoaded()) |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
+bool HTMLImport::unblock(HTMLImport* import) |
+{ |
+ ASSERT(import->arePredecessorsLoaded()); |
+ ASSERT(import->isBlocked() || import->areChilrenLoaded()); |
+ |
+ if (import->isBlocked()) { |
+ for (size_t i = 0; i < import->m_children.size(); ++i) { |
+ if (!unblock(import->m_children[i])) |
+ return false; |
+ } |
+ } |
+ |
+ import->setBlocked(false); |
dglazkov
2013/07/30 22:45:27
Sounds like this gets marked as unblocked even if
Hajime Morrita
2013/07/31 00:49:40
Yes! Unblocked means it can continue parsing.
"lo
|
+ import->didUnblock(); |
dglazkov
2013/07/30 22:45:27
Will this cause multiple document->didLoadAllImpor
Hajime Morrita
2013/07/31 00:49:40
Yes, I don't think that's a big deal though
becaus
|
+ return import->isLoaded(); |
+} |
+ |
+void HTMLImport::setTreeBlocked(bool blocked) |
+{ |
+ setBlocked(blocked); |
+ for (size_t i = 0; i < m_children.size(); ++i) |
+ m_children[i]->setTreeBlocked(blocked); |
+} |
+ |
+void HTMLImport::blockAfter(HTMLImport* child) |
+{ |
+ ASSERT(child->parent() == this); |
+ |
+ for (size_t i = 0; i < m_children.size(); ++i) { |
+ HTMLImport* sibling = m_children[m_children.size() - i - 1]; |
+ if (sibling == child) |
+ break; |
+ sibling->setTreeBlocked(true); |
+ } |
+ |
+ setBlocked(true); |
+ |
+ if (HTMLImport* parent = this->parent()) |
+ parent->blockAfter(this); |
+} |
+ |
+ |
} // namespace WebCore |