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

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

Issue 131043003: [import] Refactoring: Get rid of HTMLImport::isProcessing() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed an extra blank line 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void HTMLImport::didUnblockFromRunningScript() 129 void HTMLImport::didUnblockFromRunningScript()
130 { 130 {
131 ASSERT(!isBlockedFromCreatingDocument()); 131 ASSERT(!isBlockedFromCreatingDocument());
132 ASSERT(!isBlockedFromRunningScript()); 132 ASSERT(!isBlockedFromRunningScript());
133 if (Document* document = this->document()) 133 if (Document* document = this->document())
134 document->didLoadAllImports(); 134 document->didLoadAllImports();
135 } 135 }
136 136
137 void HTMLImport::didBecomeReady() 137 void HTMLImport::didBecomeReady()
138 { 138 {
139 ASSERT(!isProcessing()); 139 ASSERT(isDone());
140 } 140 }
141 141
142 void HTMLImport::didUnblockFromCreatingDocument() 142 void HTMLImport::didUnblockFromCreatingDocument()
143 { 143 {
144 ASSERT(!isBlockedFromCreatingDocument()); 144 ASSERT(!isBlockedFromCreatingDocument());
145 } 145 }
146 146
147 void HTMLImport::loaderWasResolved() 147 void HTMLImport::loaderWasResolved()
148 { 148 {
149 unblockFromCreatingDocument(); 149 unblockFromCreatingDocument();
150 unblockFromRunningScript(); 150 unblockFromRunningScript();
151 } 151 }
152 152
153 void HTMLImport::loaderDidFinish() 153 void HTMLImport::loaderDidFinish()
154 { 154 {
155 if (m_state == WaitingLoaderOrChildren) 155 if (m_state == WaitingLoaderOrChildren)
156 becomeReady(); 156 becomeReady();
157 root()->blockerGone(); 157 root()->blockerGone();
158 } 158 }
159 159
160 inline bool HTMLImport::isBlockingFollowersFromRunningScript() const 160 inline bool HTMLImport::isBlockingFollowersFromRunningScript() const
161 { 161 {
162 return (isBlockedFromRunningScript() || isProcessing()) && isCreatedByParser (); 162 if (!isCreatedByParser())
163 return false;
164 if (isBlockedFromRunningScript())
165 return true;
166 // Blocking here can result dead lock if the node doesn't own loader and has shared loader.
167 // Because the shared loader can point its ascendant and forms a cycle.
168 if (!ownsLoader())
169 return false;
170 return !isDone();
163 } 171 }
164 172
165 inline bool HTMLImport::isBlockingFollowersFromCreatingDocument() const 173 inline bool HTMLImport::isBlockingFollowersFromCreatingDocument() const
166 { 174 {
167 return !isDone(); 175 return !isDone();
168 } 176 }
169 177
170 bool HTMLImport::unblock(HTMLImport* import) 178 bool HTMLImport::unblock(HTMLImport* import)
171 { 179 {
172 ASSERT(!import->isBlockedFromRunningScriptByPredecessors()); 180 ASSERT(!import->isBlockedFromRunningScriptByPredecessors());
173 181
174 if (import->isBlockedFromCreatingDocument() && import->isBlockedFromCreating DocumentByPredecessors()) 182 if (import->isBlockedFromCreatingDocument() && import->isBlockedFromCreating DocumentByPredecessors())
175 return false; 183 return false;
176 import->unblockFromCreatingDocument(); 184 import->unblockFromCreatingDocument();
177 185
178 for (HTMLImport* child = import->firstChild(); child; child = child->nextSib ling()) { 186 for (HTMLImport* child = import->firstChild(); child; child = child->nextSib ling()) {
179 if (!unblock(child)) 187 if (!unblock(child))
180 return false; 188 return false;
181 } 189 }
182 190
183 import->unblockFromRunningScript(); 191 import->unblockFromRunningScript();
184 if (!import->isProcessing()) 192 if (import->isDone())
185 import->becomeReady(); 193 import->becomeReady();
186 194
187 return !import->isBlockingFollowersFromRunningScript(); 195 return !import->isBlockingFollowersFromRunningScript();
188 } 196 }
189 197
190 void HTMLImport::block(HTMLImport* import) 198 void HTMLImport::block(HTMLImport* import)
191 { 199 {
192 for (HTMLImport* child = import; child; child = traverseNext(*child, import) ) 200 for (HTMLImport* child = import; child; child = traverseNext(*child, import) )
193 child->blockFromRunningScript(); 201 child->blockFromRunningScript();
194 } 202 }
(...skipping 17 matching lines...) Expand all
212 } 220 }
213 221
214 bool HTMLImport::isMaster(Document* document) 222 bool HTMLImport::isMaster(Document* document)
215 { 223 {
216 if (!document->import()) 224 if (!document->import())
217 return true; 225 return true;
218 return (document->import()->master() == document); 226 return (document->import()->master() == document);
219 } 227 }
220 228
221 } // namespace WebCore 229 } // 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