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

Side by Side Diff: Source/core/html/HTMLImport.cpp

Issue 135653006: [import] Refactoring: Get rid of BlockedFromCreatingDocument state (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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/HTMLImportChild.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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 HTMLImportsController* HTMLImport::controller() 48 HTMLImportsController* HTMLImport::controller()
49 { 49 {
50 return root()->toController(); 50 return root()->toController();
51 } 51 }
52 52
53 void HTMLImport::appendChild(HTMLImport* child) 53 void HTMLImport::appendChild(HTMLImport* child)
54 { 54 {
55 if (isBlockedFromRunningScript()) 55 if (isBlockedFromRunningScript())
56 child->blockFromRunningScript(); 56 child->blockFromRunningScript();
57 if (lastChild() && lastChild()->isBlockingFollowersFromCreatingDocument())
58 child->blockFromCreatingDocument();
59 TreeNode<HTMLImport>::appendChild(child); 57 TreeNode<HTMLImport>::appendChild(child);
60 if (child->isCreatedByParser()) 58 if (child->isCreatedByParser())
61 blockPredecessorsOf(child); 59 blockPredecessorsOf(child);
62 } 60 }
63 61
64 inline bool HTMLImport::isBlockedFromCreatingDocumentByPredecessors() const 62 bool HTMLImport::isBlockedFromCreatingDocument() const
65 { 63 {
66 ASSERT(isBlockedFromCreatingDocument()); 64 if (hasLoader())
67 HTMLImport* elder = previous(); 65 return false;
68 return (elder && !elder->isDone()); 66 return previous() && previous()->isBlockingFollowersFromCreatingDocument();
69 } 67 }
70 68
71 bool HTMLImport::isBlockedFromRunningScriptByPredecessors() const 69 bool HTMLImport::isBlockedFromRunningScriptByPredecessors() const
72 { 70 {
73 HTMLImport* parent = this->parent(); 71 HTMLImport* parent = this->parent();
74 if (!parent) 72 if (!parent)
75 return false; 73 return false;
76 74
77 for (HTMLImport* sibling = parent->firstChild(); sibling; sibling = sibling- >next()) { 75 for (HTMLImport* sibling = parent->firstChild(); sibling; sibling = sibling- >next()) {
78 if (sibling == this) 76 if (sibling == this)
(...skipping 10 matching lines...) Expand all
89 if (WaitingLoaderOrChildren < m_state) 87 if (WaitingLoaderOrChildren < m_state)
90 m_state = WaitingLoaderOrChildren; 88 m_state = WaitingLoaderOrChildren;
91 } 89 }
92 90
93 void HTMLImport::blockFromRunningScript() 91 void HTMLImport::blockFromRunningScript()
94 { 92 {
95 if (BlockedFromRunningScript < m_state) 93 if (BlockedFromRunningScript < m_state)
96 m_state = BlockedFromRunningScript; 94 m_state = BlockedFromRunningScript;
97 } 95 }
98 96
99 void HTMLImport::blockFromCreatingDocument()
100 {
101 if (BlockedFromCreatingDocument < m_state)
102 m_state = BlockedFromCreatingDocument;
103 }
104
105 void HTMLImport::becomeReady() 97 void HTMLImport::becomeReady()
106 { 98 {
107 if (!isBlocked()) 99 if (!isBlocked())
108 return; 100 return;
109 m_state = Ready; 101 m_state = Ready;
110 didBecomeReady(); 102 didBecomeReady();
111 } 103 }
112 104
113 void HTMLImport::unblockFromRunningScript() 105 void HTMLImport::unblockFromRunningScript()
114 { 106 {
115 if (!isBlockedFromRunningScript()) 107 if (!isBlockedFromRunningScript())
116 return; 108 return;
117 m_state = WaitingLoaderOrChildren; 109 m_state = WaitingLoaderOrChildren;
118 didUnblockFromRunningScript(); 110 didUnblockFromRunningScript();
119 } 111 }
120 112
121 void HTMLImport::unblockFromCreatingDocument()
122 {
123 if (!isBlockedFromCreatingDocument())
124 return;
125 m_state = BlockedFromRunningScript;
126 didUnblockFromCreatingDocument();
127 }
128
129 void HTMLImport::didUnblockFromRunningScript() 113 void HTMLImport::didUnblockFromRunningScript()
130 { 114 {
131 ASSERT(!isBlockedFromCreatingDocument()); 115 ASSERT(!isBlockedFromCreatingDocument());
132 ASSERT(!isBlockedFromRunningScript()); 116 ASSERT(!isBlockedFromRunningScript());
133 if (Document* document = this->document()) 117 if (Document* document = this->document())
134 document->didLoadAllImports(); 118 document->didLoadAllImports();
135 } 119 }
136 120
137 void HTMLImport::didBecomeReady() 121 void HTMLImport::didBecomeReady()
138 { 122 {
139 ASSERT(isDone()); 123 ASSERT(isDone());
140 } 124 }
141 125
142 void HTMLImport::didUnblockFromCreatingDocument() 126 void HTMLImport::didUnblockFromCreatingDocument()
143 { 127 {
144 ASSERT(!isBlockedFromCreatingDocument()); 128 ASSERT(!isBlockedFromCreatingDocument());
145 } 129 }
146 130
147 void HTMLImport::loaderWasResolved() 131 void HTMLImport::loaderWasResolved()
148 { 132 {
149 unblockFromCreatingDocument();
150 unblockFromRunningScript(); 133 unblockFromRunningScript();
151 } 134 }
152 135
153 void HTMLImport::loaderDidFinish() 136 void HTMLImport::loaderDidFinish()
154 { 137 {
155 if (m_state == WaitingLoaderOrChildren) 138 if (m_state == WaitingLoaderOrChildren)
156 becomeReady(); 139 becomeReady();
157 root()->blockerGone(); 140 root()->blockerGone();
158 } 141 }
159 142
(...skipping 12 matching lines...) Expand all
172 155
173 inline bool HTMLImport::isBlockingFollowersFromCreatingDocument() const 156 inline bool HTMLImport::isBlockingFollowersFromCreatingDocument() const
174 { 157 {
175 return !isDone(); 158 return !isDone();
176 } 159 }
177 160
178 bool HTMLImport::unblock(HTMLImport* import) 161 bool HTMLImport::unblock(HTMLImport* import)
179 { 162 {
180 ASSERT(!import->isBlockedFromRunningScriptByPredecessors()); 163 ASSERT(!import->isBlockedFromRunningScriptByPredecessors());
181 164
182 if (import->isBlockedFromCreatingDocument() && import->isBlockedFromCreating DocumentByPredecessors()) 165 if (import->isBlockedFromCreatingDocument())
183 return false; 166 return false;
184 import->unblockFromCreatingDocument(); 167 import->didUnblockFromCreatingDocument();
185 168
186 for (HTMLImport* child = import->firstChild(); child; child = child->next()) { 169 for (HTMLImport* child = import->firstChild(); child; child = child->next()) {
187 if (!unblock(child)) 170 if (!unblock(child))
188 return false; 171 return false;
189 } 172 }
190 173
191 import->unblockFromRunningScript(); 174 import->unblockFromRunningScript();
192 if (import->isDone()) 175 if (import->isDone())
193 import->becomeReady(); 176 import->becomeReady();
194 177
(...skipping 25 matching lines...) Expand all
220 } 203 }
221 204
222 bool HTMLImport::isMaster(Document* document) 205 bool HTMLImport::isMaster(Document* document)
223 { 206 {
224 if (!document->import()) 207 if (!document->import())
225 return true; 208 return true;
226 return (document->import()->master() == document); 209 return (document->import()->master() == document);
227 } 210 }
228 211
229 } // namespace WebCore 212 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/HTMLImport.h ('k') | Source/core/html/HTMLImportChild.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698