Index: Source/core/html/imports/HTMLImportTreeRoot.cpp |
diff --git a/Source/core/html/imports/HTMLImportTreeRoot.cpp b/Source/core/html/imports/HTMLImportTreeRoot.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d44d93291be97f173f54b87f1c95423d30bae3a6 |
--- /dev/null |
+++ b/Source/core/html/imports/HTMLImportTreeRoot.cpp |
@@ -0,0 +1,69 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "core/html/imports/HTMLImportTreeRoot.h" |
+ |
+#include "core/dom/Document.h" |
+#include "core/dom/StyleEngine.h" |
+#include "core/frame/LocalFrame.h" |
+ |
+namespace WebCore { |
+ |
+PassOwnPtr<HTMLImportTreeRoot> HTMLImportTreeRoot::create(Document* document) |
+{ |
+ return adoptPtr(new HTMLImportTreeRoot(document)); |
+} |
+ |
+HTMLImportTreeRoot::HTMLImportTreeRoot(Document* document) |
+ : HTMLImport(HTMLImport::Sync) |
+ , m_document(document) |
+ , m_recalcTimer(this, &HTMLImportTreeRoot::recalcTimerFired) |
+{ |
+ recalcTreeState(this); // This recomputes initial state. |
+} |
+ |
+Document* HTMLImportTreeRoot::document() const |
+{ |
+ return m_document; |
+} |
+ |
+bool HTMLImportTreeRoot::isDone() const |
+{ |
+ return !m_document->parsing() && m_document->styleEngine()->haveStylesheetsLoaded(); |
+} |
+ |
+void HTMLImportTreeRoot::stateWillChange() |
+{ |
+ scheduleRecalcState(); |
+} |
+ |
+void HTMLImportTreeRoot::stateDidChange() |
+{ |
+ HTMLImport::stateDidChange(); |
+ |
+ if (!state().isReady()) |
+ return; |
+ if (LocalFrame* frame = m_document->frame()) |
+ frame->loader().checkCompleted(); |
+} |
+ |
+void HTMLImportTreeRoot::scheduleRecalcState() |
+{ |
+ if (m_recalcTimer.isActive() || !m_document) |
+ return; |
+ m_recalcTimer.startOneShot(0, FROM_HERE); |
+} |
+ |
+void HTMLImportTreeRoot::recalcTimerFired(Timer<HTMLImportTreeRoot>*) |
+{ |
+ ASSERT(m_document); |
+ |
+ do { |
+ m_recalcTimer.stop(); |
+ HTMLImport::recalcTreeState(this); |
+ } while (m_recalcTimer.isActive()); |
+} |
+ |
+} |