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

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

Issue 234063004: Refactoring: Get rid of HTMLImportRoot. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 /* 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 void HTMLImportChild::importDestroyed() 125 void HTMLImportChild::importDestroyed()
126 { 126 {
127 if (parent()) 127 if (parent())
128 parent()->removeChild(this); 128 parent()->removeChild(this);
129 if (m_loader) { 129 if (m_loader) {
130 m_loader->removeImport(this); 130 m_loader->removeImport(this);
131 m_loader = 0; 131 m_loader = 0;
132 } 132 }
133 } 133 }
134 134
135 HTMLImportRoot* HTMLImportChild::root()
136 {
137 return parent() ? parent()->root() : 0;
138 }
139
140 Document* HTMLImportChild::document() const 135 Document* HTMLImportChild::document() const
141 { 136 {
142 return (m_loader && m_loader->isOwnedBy(this)) ? m_loader->document() : 0; 137 return (m_loader && m_loader->isOwnedBy(this)) ? m_loader->document() : 0;
143 } 138 }
144 139
140 void HTMLImportChild::stateWillChange()
141 {
142 toHTMLImportsController(root())->scheduleRecalcState();
143 }
144
145 void HTMLImportChild::stateDidChange() 145 void HTMLImportChild::stateDidChange()
146 { 146 {
147 HTMLImport::stateDidChange(); 147 HTMLImport::stateDidChange();
148 148
149 // Once all preceding imports are loaded, 149 // Once all preceding imports are loaded,
150 // HTMLImportChild can decide whether it should load the import by itself 150 // HTMLImportChild can decide whether it should load the import by itself
151 // or it can share existing one. 151 // or it can share existing one.
152 if (!state().shouldBlockDocumentCreation()) 152 if (!state().shouldBlockDocumentCreation())
153 ensureLoader(); 153 ensureLoader();
154 if (state().isReady()) 154 if (state().isReady())
155 didFinish(); 155 didFinish();
156 } 156 }
157 157
158 void HTMLImportChild::ensureLoader() 158 void HTMLImportChild::ensureLoader()
159 { 159 {
160 if (m_loader) 160 if (m_loader)
161 return; 161 return;
162 162
163 if (HTMLImportChild* found = root()->findLinkFor(m_url, this)) 163 if (HTMLImportChild* found = toHTMLImportsController(root())->findLinkFor(m_ url, this))
164 shareLoader(found); 164 shareLoader(found);
165 else 165 else
166 createLoader(); 166 createLoader();
167 } 167 }
168 168
169 void HTMLImportChild::createLoader() 169 void HTMLImportChild::createLoader()
170 { 170 {
171 ASSERT(!state().shouldBlockDocumentCreation()); 171 ASSERT(!state().shouldBlockDocumentCreation());
172 ASSERT(!m_loader); 172 ASSERT(!m_loader);
173 m_loader = root()->toController()->createLoader(); 173 m_loader = toHTMLImportsController(root())->createLoader();
174 m_loader->addImport(this); 174 m_loader->addImport(this);
175 m_loader->startLoading(resource()); 175 m_loader->startLoading(resource());
176 } 176 }
177 177
178 void HTMLImportChild::shareLoader(HTMLImportChild* loader) 178 void HTMLImportChild::shareLoader(HTMLImportChild* loader)
179 { 179 {
180 ASSERT(!m_loader); 180 ASSERT(!m_loader);
181 m_loader = loader->m_loader; 181 m_loader = loader->m_loader;
182 m_loader->addImport(this); 182 m_loader->addImport(this);
183 stateWillChange(); 183 stateWillChange();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 HTMLImport::showThis(); 231 HTMLImport::showThis();
232 fprintf(stderr, " loader=%p own=%s async=%s url=%s", 232 fprintf(stderr, " loader=%p own=%s async=%s url=%s",
233 m_loader, 233 m_loader,
234 hasLoader() && ownsLoader() ? "Y" : "N", 234 hasLoader() && ownsLoader() ? "Y" : "N",
235 isSync() ? "Y" : "N", 235 isSync() ? "Y" : "N",
236 url().string().utf8().data()); 236 url().string().utf8().data());
237 } 237 }
238 #endif 238 #endif
239 239
240 } // namespace WebCore 240 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/imports/HTMLImportChild.h ('k') | Source/core/html/imports/HTMLImportsController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698