Index: Source/core/html/HTMLImport.cpp |
diff --git a/Source/core/html/HTMLImport.cpp b/Source/core/html/HTMLImport.cpp |
index e55f8433125732d32614abeecdbbc23d5e20ecd7..a6c08869ed8bc9bcb365643326523f2a1f135344 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,106 @@ Document* HTMLImport::master() |
return controller()->document(); |
} |
+void HTMLImport::appendChild(HTMLImport* child) |
+{ |
+ ASSERT(child->parent() == this); |
+ ASSERT(!child->hasChildren()); |
+ |
+ if (isBlocked()) |
+ child->block(); |
+ m_children.append(child); |
+ blockAfter(child); |
+} |
+ |
+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; |
+} |
+ |
+void HTMLImport::block() |
+{ |
+ m_blocked = true; |
+} |
+ |
+void HTMLImport::unblock() |
+{ |
+ bool wasBlocked = m_blocked; |
+ m_blocked = false; |
+ if (wasBlocked) |
+ didUnblock(); |
+} |
+ |
+void HTMLImport::didUnblock() |
+{ |
+ ASSERT(!isBlocked()); |
+ if (!isProcessing()) |
+ return; |
+ |
+ if (Document* document = this->document()) |
+ document->didLoadAllImports(); |
+} |
+ |
+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->unblock(); |
+ return import->isLoaded(); |
+} |
+ |
+void HTMLImport::block(HTMLImport* import) |
+{ |
+ import->block(); |
+ for (size_t i = 0; i < import->m_children.size(); ++i) |
+ block(import->m_children[i]); |
+} |
+ |
+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; |
+ HTMLImport::block(sibling); |
+ } |
+ |
+ this->block(); |
+ |
+ if (HTMLImport* parent = this->parent()) |
+ parent->blockAfter(this); |
+} |
+ |
+ |
} // namespace WebCore |