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

Side by Side 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, 4 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
« no previous file with comments | « Source/core/html/HTMLImport.h ('k') | Source/core/html/HTMLImportsController.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/html/HTMLImport.h" 32 #include "core/html/HTMLImport.h"
33 33
34 #include "core/html/HTMLImportsController.h" 34 #include "core/html/HTMLImportsController.h"
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 bool HTMLImport::haveChildrenLoaded()
39 {
40 if (HTMLImportsController* controller = this->controller())
41 return controller->haveChildrenLoaded(this);
42 return true;
43 }
44
45 Frame* HTMLImport::frame() 38 Frame* HTMLImport::frame()
46 { 39 {
47 return master()->frame(); 40 return master()->frame();
48 } 41 }
49 42
50 Document* HTMLImport::master() 43 Document* HTMLImport::master()
51 { 44 {
52 return controller()->document(); 45 return controller()->document();
53 } 46 }
54 47
48 void HTMLImport::appendChild(HTMLImport* child)
49 {
50 ASSERT(child->parent() == this);
51 ASSERT(!child->hasChildren());
52
53 if (isBlocked())
54 child->block();
55 m_children.append(child);
56 blockAfter(child);
57 }
58
59 bool HTMLImport::areChilrenLoaded() const
60 {
61 for (size_t i = 0; i < m_children.size(); ++i) {
62 if (!m_children[i]->isLoaded())
63 return false;
64 }
65
66 return true;
67 }
68
69 bool HTMLImport::arePredecessorsLoaded() const
70 {
71 HTMLImport* parent = this->parent();
72 if (!parent)
73 return true;
74
75 for (size_t i = 0; i < parent->m_children.size(); ++i) {
76 HTMLImport* sibling = parent->m_children[i];
77 if (sibling == this)
78 break;
79 if (!sibling->isLoaded())
80 return false;
81 }
82
83 return true;
84 }
85
86 void HTMLImport::block()
87 {
88 m_blocked = true;
89 }
90
91 void HTMLImport::unblock()
92 {
93 bool wasBlocked = m_blocked;
94 m_blocked = false;
95 if (wasBlocked)
96 didUnblock();
97 }
98
99 void HTMLImport::didUnblock()
100 {
101 ASSERT(!isBlocked());
102 if (!isProcessing())
103 return;
104
105 if (Document* document = this->document())
106 document->didLoadAllImports();
107 }
108
109 bool HTMLImport::unblock(HTMLImport* import)
110 {
111 ASSERT(import->arePredecessorsLoaded());
112 ASSERT(import->isBlocked() || import->areChilrenLoaded());
113
114 if (import->isBlocked()) {
115 for (size_t i = 0; i < import->m_children.size(); ++i) {
116 if (!unblock(import->m_children[i]))
117 return false;
118 }
119 }
120
121 import->unblock();
122 return import->isLoaded();
123 }
124
125 void HTMLImport::block(HTMLImport* import)
126 {
127 import->block();
128 for (size_t i = 0; i < import->m_children.size(); ++i)
129 block(import->m_children[i]);
130 }
131
132 void HTMLImport::blockAfter(HTMLImport* child)
133 {
134 ASSERT(child->parent() == this);
135
136 for (size_t i = 0; i < m_children.size(); ++i) {
137 HTMLImport* sibling = m_children[m_children.size() - i - 1];
138 if (sibling == child)
139 break;
140 HTMLImport::block(sibling);
141 }
142
143 this->block();
144
145 if (HTMLImport* parent = this->parent())
146 parent->blockAfter(this);
147 }
148
149
55 } // namespace WebCore 150 } // namespace WebCore
OLDNEW
« 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