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

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

Issue 125503002: We should unify various forms of tree traversal in DOM (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix the comments in TreeNode.h to be more descriptive 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
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 if (lastChild() && lastChild()->isBlockingFollowersFromCreatingDocument()) 57 if (lastChild() && lastChild()->isBlockingFollowersFromCreatingDocument())
58 child->blockFromCreatingDocument(); 58 child->blockFromCreatingDocument();
59 TreeNode<HTMLImport>::appendChild(child); 59 TreeNode<HTMLImport>::appendChild(child);
60 if (child->isCreatedByParser()) 60 if (child->isCreatedByParser())
61 blockPredecessorsOf(child); 61 blockPredecessorsOf(child);
62 } 62 }
63 63
64 inline bool HTMLImport::isBlockedFromCreatingDocumentByPredecessors() const 64 inline bool HTMLImport::isBlockedFromCreatingDocumentByPredecessors() const
65 { 65 {
66 ASSERT(isBlockedFromCreatingDocument()); 66 ASSERT(isBlockedFromCreatingDocument());
67 HTMLImport* elder = previous(); 67 HTMLImport* elder = previousSibling();
68 return (elder && !elder->isDone()); 68 return (elder && !elder->isDone());
69 } 69 }
70 70
71 bool HTMLImport::isBlockedFromRunningScriptByPredecessors() const 71 bool HTMLImport::isBlockedFromRunningScriptByPredecessors() const
72 { 72 {
73 HTMLImport* parent = this->parent(); 73 HTMLImport* parent = this->parent();
74 if (!parent) 74 if (!parent)
75 return false; 75 return false;
76 76
77 for (HTMLImport* sibling = parent->firstChild(); sibling; sibling = sibling- >next()) { 77 for (HTMLImport* sibling = parent->firstChild(); sibling; sibling = sibling- >nextSibling()) {
78 if (sibling == this) 78 if (sibling == this)
79 break; 79 break;
80 if (sibling->isBlockingFollowersFromRunningScript()) 80 if (sibling->isBlockingFollowersFromRunningScript())
81 return true; 81 return true;
82 } 82 }
83 83
84 return false; 84 return false;
85 } 85 }
86 86
87 void HTMLImport::blockFromRunningScript() 87 void HTMLImport::blockFromRunningScript()
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 141
142 bool HTMLImport::unblock(HTMLImport* import) 142 bool HTMLImport::unblock(HTMLImport* import)
143 { 143 {
144 ASSERT(!import->isBlockedFromRunningScriptByPredecessors()); 144 ASSERT(!import->isBlockedFromRunningScriptByPredecessors());
145 145
146 if (import->isBlockedFromCreatingDocument() && import->isBlockedFromCreating DocumentByPredecessors()) 146 if (import->isBlockedFromCreatingDocument() && import->isBlockedFromCreating DocumentByPredecessors())
147 return false; 147 return false;
148 import->unblockFromCreatingDocument(); 148 import->unblockFromCreatingDocument();
149 149
150 for (HTMLImport* child = import->firstChild(); child; child = child->next()) { 150 for (HTMLImport* child = import->firstChild(); child; child = child->nextSib ling()) {
151 if (!unblock(child)) 151 if (!unblock(child))
152 return false; 152 return false;
153 } 153 }
154 154
155 import->unblockFromRunningScript(); 155 import->unblockFromRunningScript();
156 156
157 return !import->isBlockingFollowersFromRunningScript(); 157 return !import->isBlockingFollowersFromRunningScript();
158 } 158 }
159 159
160 void HTMLImport::block(HTMLImport* import) 160 void HTMLImport::block(HTMLImport* import)
161 { 161 {
162 for (HTMLImport* child = import; child; child = traverseNext(child, import)) 162 for (HTMLImport* child = import; child; child = traverseNext(*child, import) )
163 child->blockFromRunningScript(); 163 child->blockFromRunningScript();
164 } 164 }
165 165
166 void HTMLImport::blockPredecessorsOf(HTMLImport* child) 166 void HTMLImport::blockPredecessorsOf(HTMLImport* child)
167 { 167 {
168 ASSERT(child->parent() == this); 168 ASSERT(child->parent() == this);
169 169
170 for (HTMLImport* sibling = lastChild(); sibling; sibling = sibling->previous ()) { 170 for (HTMLImport* sibling = lastChild(); sibling; sibling = sibling->previous Sibling()) {
171 if (sibling == child) 171 if (sibling == child)
172 break; 172 break;
173 HTMLImport::block(sibling); 173 HTMLImport::block(sibling);
174 } 174 }
175 175
176 this->blockFromRunningScript(); 176 this->blockFromRunningScript();
177 177
178 if (HTMLImport* parent = this->parent()) { 178 if (HTMLImport* parent = this->parent()) {
179 if (isCreatedByParser()) 179 if (isCreatedByParser())
180 parent->blockPredecessorsOf(this); 180 parent->blockPredecessorsOf(this);
181 } 181 }
182 } 182 }
183 183
184 bool HTMLImport::isMaster(Document* document) 184 bool HTMLImport::isMaster(Document* document)
185 { 185 {
186 if (!document->import()) 186 if (!document->import())
187 return true; 187 return true;
188 return (document->import()->master() == document); 188 return (document->import()->master() == document);
189 } 189 }
190 190
191 } // namespace WebCore 191 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/StyleEngine.cpp ('k') | Source/wtf/TreeNode.h » ('j') | Source/wtf/TreeNode.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698