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

Unified Diff: Source/core/html/imports/HTMLImportTreeRoot.cpp

Issue 301803002: Extract tree root responsibility out of HTMLImportsController. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix compile. Created 6 years, 7 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/imports/HTMLImportTreeRoot.h ('k') | Source/core/html/imports/HTMLImportsController.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
+}
+
+}
« no previous file with comments | « Source/core/html/imports/HTMLImportTreeRoot.h ('k') | Source/core/html/imports/HTMLImportsController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698