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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/html/imports/HTMLImportTreeRoot.h"
7
8 #include "core/dom/Document.h"
9 #include "core/dom/StyleEngine.h"
10 #include "core/frame/LocalFrame.h"
11
12 namespace WebCore {
13
14 PassOwnPtr<HTMLImportTreeRoot> HTMLImportTreeRoot::create(Document* document)
15 {
16 return adoptPtr(new HTMLImportTreeRoot(document));
17 }
18
19 HTMLImportTreeRoot::HTMLImportTreeRoot(Document* document)
20 : HTMLImport(HTMLImport::Sync)
21 , m_document(document)
22 , m_recalcTimer(this, &HTMLImportTreeRoot::recalcTimerFired)
23 {
24 recalcTreeState(this); // This recomputes initial state.
25 }
26
27 Document* HTMLImportTreeRoot::document() const
28 {
29 return m_document;
30 }
31
32 bool HTMLImportTreeRoot::isDone() const
33 {
34 return !m_document->parsing() && m_document->styleEngine()->haveStylesheetsL oaded();
35 }
36
37 void HTMLImportTreeRoot::stateWillChange()
38 {
39 scheduleRecalcState();
40 }
41
42 void HTMLImportTreeRoot::stateDidChange()
43 {
44 HTMLImport::stateDidChange();
45
46 if (!state().isReady())
47 return;
48 if (LocalFrame* frame = m_document->frame())
49 frame->loader().checkCompleted();
50 }
51
52 void HTMLImportTreeRoot::scheduleRecalcState()
53 {
54 if (m_recalcTimer.isActive() || !m_document)
55 return;
56 m_recalcTimer.startOneShot(0, FROM_HERE);
57 }
58
59 void HTMLImportTreeRoot::recalcTimerFired(Timer<HTMLImportTreeRoot>*)
60 {
61 ASSERT(m_document);
62
63 do {
64 m_recalcTimer.stop();
65 HTMLImport::recalcTreeState(this);
66 } while (m_recalcTimer.isActive());
67 }
68
69 }
OLDNEW
« 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