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

Side by Side Diff: Source/core/html/imports/HTMLImportTreeRoot.cpp

Issue 305723004: Make HTMLImportTreeNode own the whole import tree. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Comments addressed. 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/html/imports/HTMLImportTreeRoot.h" 6 #include "core/html/imports/HTMLImportTreeRoot.h"
7 7
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/StyleEngine.h" 9 #include "core/dom/StyleEngine.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
11 #include "core/html/imports/HTMLImportChild.h"
11 12
12 namespace WebCore { 13 namespace WebCore {
13 14
14 PassOwnPtr<HTMLImportTreeRoot> HTMLImportTreeRoot::create(Document* document) 15 PassOwnPtr<HTMLImportTreeRoot> HTMLImportTreeRoot::create(Document* document)
15 { 16 {
16 return adoptPtr(new HTMLImportTreeRoot(document)); 17 return adoptPtr(new HTMLImportTreeRoot(document));
17 } 18 }
18 19
19 HTMLImportTreeRoot::HTMLImportTreeRoot(Document* document) 20 HTMLImportTreeRoot::HTMLImportTreeRoot(Document* document)
20 : HTMLImport(HTMLImport::Sync) 21 : HTMLImport(HTMLImport::Sync)
21 , m_document(document) 22 , m_document(document)
22 , m_recalcTimer(this, &HTMLImportTreeRoot::recalcTimerFired) 23 , m_recalcTimer(this, &HTMLImportTreeRoot::recalcTimerFired)
23 { 24 {
24 recalcTreeState(this); // This recomputes initial state. 25 recalcTreeState(this); // This recomputes initial state.
25 } 26 }
26 27
28 HTMLImportTreeRoot::~HTMLImportTreeRoot()
29 {
30 for (size_t i = 0; i < m_imports.size(); ++i)
31 m_imports[i]->importDestroyed();
32 m_imports.clear();
33 }
34
27 Document* HTMLImportTreeRoot::document() const 35 Document* HTMLImportTreeRoot::document() const
28 { 36 {
29 return m_document; 37 return m_document;
30 } 38 }
31 39
32 bool HTMLImportTreeRoot::isDone() const 40 bool HTMLImportTreeRoot::isDone() const
33 { 41 {
34 return !m_document->parsing() && m_document->styleEngine()->haveStylesheetsL oaded(); 42 return !m_document->parsing() && m_document->styleEngine()->haveStylesheetsL oaded();
35 } 43 }
36 44
(...skipping 12 matching lines...) Expand all
49 frame->loader().checkCompleted(); 57 frame->loader().checkCompleted();
50 } 58 }
51 59
52 void HTMLImportTreeRoot::scheduleRecalcState() 60 void HTMLImportTreeRoot::scheduleRecalcState()
53 { 61 {
54 if (m_recalcTimer.isActive() || !m_document) 62 if (m_recalcTimer.isActive() || !m_document)
55 return; 63 return;
56 m_recalcTimer.startOneShot(0, FROM_HERE); 64 m_recalcTimer.startOneShot(0, FROM_HERE);
57 } 65 }
58 66
67 HTMLImportChild* HTMLImportTreeRoot::add(PassOwnPtr<HTMLImportChild> child)
68 {
69 m_imports.append(child);
70 return m_imports.last().get();
71 }
72
73 HTMLImportChild* HTMLImportTreeRoot::find(const KURL& url) const
74 {
75 for (size_t i = 0; i < m_imports.size(); ++i) {
76 HTMLImportChild* candidate = m_imports[i].get();
77 if (equalIgnoringFragmentIdentifier(candidate->url(), url))
78 return candidate;
79 }
80
81 return 0;
82 }
83
59 void HTMLImportTreeRoot::recalcTimerFired(Timer<HTMLImportTreeRoot>*) 84 void HTMLImportTreeRoot::recalcTimerFired(Timer<HTMLImportTreeRoot>*)
60 { 85 {
61 ASSERT(m_document); 86 ASSERT(m_document);
62 87
63 do { 88 do {
64 m_recalcTimer.stop(); 89 m_recalcTimer.stop();
65 HTMLImport::recalcTreeState(this); 90 HTMLImport::recalcTreeState(this);
66 } while (m_recalcTimer.isActive()); 91 } while (m_recalcTimer.isActive());
67 } 92 }
68 93
69 } 94 }
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