Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Unified Diff: Source/core/html/HTMLImport.cpp

Issue 21182004: [HTML Imports] Make import loading in order. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed feedback. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLImport.h ('k') | Source/core/html/HTMLImportsController.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/core/html/HTMLImport.h ('k') | Source/core/html/HTMLImportsController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698