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

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

Issue 238923009: HTML Imports: No more BlockingDocumentCreation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed the build breakage 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 m_loaders[i]->importDestroyed(); 72 m_loaders[i]->importDestroyed();
73 m_loaders.clear(); 73 m_loaders.clear();
74 74
75 if (m_master) 75 if (m_master)
76 m_master->setImportsController(0); 76 m_master->setImportsController(0);
77 m_master = 0; 77 m_master = 0;
78 78
79 m_recalcTimer.stop(); 79 m_recalcTimer.stop();
80 } 80 }
81 81
82 static bool makesCyclce(HTMLImport* parent, const KURL& url)
dominicc (has gone to gerrit) 2014/04/18 00:56:26 Spelling: cycle
Hajime Morrita 2014/04/18 01:48:33 Done.
83 {
84 for (HTMLImport* ancestor = parent; ancestor; ancestor = ancestor->parent()) {
85 if (!ancestor->isRoot() && equalIgnoringFragmentIdentifier(toHTMLImportC hild(parent)->url(), url))
86 return true;
87 }
88
89 return false;
90 }
91
82 HTMLImportChild* HTMLImportsController::createChild(const KURL& url, HTMLImport* parent, HTMLImportChildClient* client) 92 HTMLImportChild* HTMLImportsController::createChild(const KURL& url, HTMLImport* parent, HTMLImportChildClient* client)
83 { 93 {
84 OwnPtr<HTMLImportChild> loader = adoptPtr(new HTMLImportChild(*m_master, url , client->isSync() ? HTMLImport::Sync : HTMLImport::Async)); 94 HTMLImport::SyncMode mode = client->isSync() && !makesCyclce(parent, url) ? HTMLImport::Sync : HTMLImport::Async;
95 OwnPtr<HTMLImportChild> loader = adoptPtr(new HTMLImportChild(*m_master, url , mode));
85 loader->setClient(client); 96 loader->setClient(client);
86 parent->appendChild(loader.get()); 97 parent->appendImport(loader.get());
87 m_imports.append(loader.release()); 98 m_imports.append(loader.release());
88 return m_imports.last().get(); 99 return m_imports.last().get();
89 } 100 }
90 101
91 HTMLImportChild* HTMLImportsController::load(HTMLImport* parent, HTMLImportChild Client* client, FetchRequest request) 102 HTMLImportChild* HTMLImportsController::load(HTMLImport* parent, HTMLImportChild Client* client, FetchRequest request)
92 { 103 {
93 ASSERT(!request.url().isEmpty() && request.url().isValid()); 104 ASSERT(!request.url().isEmpty() && request.url().isValid());
94 105
95 if (findLinkFor(request.url())) { 106 if (findLinkFor(request.url())) {
96 HTMLImportChild* child = createChild(request.url(), parent, client); 107 HTMLImportChild* child = createChild(request.url(), parent, client);
(...skipping 19 matching lines...) Expand all
116 127
117 void HTMLImportsController::showSecurityErrorMessage(const String& message) 128 void HTMLImportsController::showSecurityErrorMessage(const String& message)
118 { 129 {
119 m_master->addConsoleMessage(JSMessageSource, ErrorMessageLevel, message); 130 m_master->addConsoleMessage(JSMessageSource, ErrorMessageLevel, message);
120 } 131 }
121 132
122 HTMLImportChild* HTMLImportsController::findLinkFor(const KURL& url, HTMLImport* excluding) const 133 HTMLImportChild* HTMLImportsController::findLinkFor(const KURL& url, HTMLImport* excluding) const
123 { 134 {
124 for (size_t i = 0; i < m_imports.size(); ++i) { 135 for (size_t i = 0; i < m_imports.size(); ++i) {
125 HTMLImportChild* candidate = m_imports[i].get(); 136 HTMLImportChild* candidate = m_imports[i].get();
126 if (candidate != excluding && equalIgnoringFragmentIdentifier(candidate- >url(), url) && candidate->hasLoader()) 137 if (candidate != excluding && equalIgnoringFragmentIdentifier(candidate- >url(), url) && candidate->loader())
127 return candidate; 138 return candidate;
128 } 139 }
129 140
130 return 0; 141 return 0;
131 } 142 }
132 143
133 SecurityOrigin* HTMLImportsController::securityOrigin() const 144 SecurityOrigin* HTMLImportsController::securityOrigin() const
134 { 145 {
135 return m_master->securityOrigin(); 146 return m_master->securityOrigin();
136 } 147 }
(...skipping 10 matching lines...) Expand all
147 158
148 Document* HTMLImportsController::document() const 159 Document* HTMLImportsController::document() const
149 { 160 {
150 return m_master; 161 return m_master;
151 } 162 }
152 163
153 bool HTMLImportsController::shouldBlockScriptExecution(const Document& document) const 164 bool HTMLImportsController::shouldBlockScriptExecution(const Document& document) const
154 { 165 {
155 ASSERT(document.importsController() == this); 166 ASSERT(document.importsController() == this);
156 if (HTMLImportLoader* loader = loaderFor(document)) 167 if (HTMLImportLoader* loader = loaderFor(document))
157 return loader->firstImport()->state().shouldBlockScriptExecution(); 168 return loader->shouldBlockScriptExecution();
158 return state().shouldBlockScriptExecution(); 169 return state().shouldBlockScriptExecution();
159 } 170 }
160 171
161 void HTMLImportsController::wasDetachedFrom(const Document& document) 172 void HTMLImportsController::wasDetachedFrom(const Document& document)
162 { 173 {
163 ASSERT(document.importsController() == this); 174 ASSERT(document.importsController() == this);
164 if (m_master == &document) 175 if (m_master == &document)
165 clear(); 176 clear();
166 } 177 }
167 178
168 bool HTMLImportsController::hasLoader() const
169 {
170 return true;
171 }
172
173 bool HTMLImportsController::isDone() const 179 bool HTMLImportsController::isDone() const
174 { 180 {
175 return !m_master->parsing() && m_master->styleEngine()->haveStylesheetsLoade d(); 181 return !m_master->parsing() && m_master->styleEngine()->haveStylesheetsLoade d();
176 } 182 }
177 183
178 void HTMLImportsController::stateWillChange() 184 void HTMLImportsController::stateWillChange()
179 { 185 {
180 scheduleRecalcState(); 186 scheduleRecalcState();
181 } 187 }
182 188
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 { 223 {
218 for (size_t i = 0; i < m_loaders.size(); ++i) { 224 for (size_t i = 0; i < m_loaders.size(); ++i) {
219 if (m_loaders[i]->document() == &document) 225 if (m_loaders[i]->document() == &document)
220 return m_loaders[i].get(); 226 return m_loaders[i].get();
221 } 227 }
222 228
223 return 0; 229 return 0;
224 } 230 }
225 231
226 } // namespace WebCore 232 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698