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

Unified Diff: Source/core/dom/ScriptLoader.cpp

Issue 229753004: Handle didMoveToNewDocument() for <script> (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/ScriptLoader.h ('k') | Source/core/html/HTMLScriptElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ScriptLoader.cpp
diff --git a/Source/core/dom/ScriptLoader.cpp b/Source/core/dom/ScriptLoader.cpp
index efb322abdee5bf93be74037552c83fa7cc5e4775..90a7ffb5910e49bfc75c0cd05f5dc3c6a22fb867 100644
--- a/Source/core/dom/ScriptLoader.cpp
+++ b/Source/core/dom/ScriptLoader.cpp
@@ -363,15 +363,16 @@ void ScriptLoader::execute(ScriptResource* resource)
resource->removeClient(this);
}
-void ScriptLoader::notifyFinished(Resource* resource)
+void ScriptLoader::cancel(Document* contextDocument)
{
- ASSERT(!m_willBeParserExecuted);
-
- RefPtr<Document> elementDocument(m_element->document());
- RefPtr<Document> contextDocument = elementDocument->contextDocument().get();
- if (!contextDocument)
+ if (!m_resource)
return;
+ finishLoading(contextDocument, FinishWithErrorOrCancel);
+ stopLoadRequest();
+}
+void ScriptLoader::notifyFinished(Resource* resource)
+{
// Resource possibly invokes this notifyFinished() more than
// once because ScriptLoader doesn't unsubscribe itself from
// Resource here and does it in execute() instead.
@@ -379,7 +380,20 @@ void ScriptLoader::notifyFinished(Resource* resource)
ASSERT_UNUSED(resource, resource == m_resource);
if (!m_resource)
return;
- if (m_resource->errorOccurred()) {
+
+ RefPtr<Document> elementDocument(m_element->document());
+ RefPtr<Document> contextDocument = elementDocument->contextDocument().get();
+ finishLoading(contextDocument.get(), resource->errorOccurred() ? FinishWithErrorOrCancel : FinishSuccessfully);
+}
+
+void ScriptLoader::finishLoading(Document* contextDocument, ScriptLoader::FinishType type)
+{
+ ASSERT(!m_willBeParserExecuted);
+
+ if (!contextDocument)
+ return;
+
+ if (type == FinishWithErrorOrCancel) {
dispatchErrorEvent();
contextDocument->scriptRunner()->notifyScriptLoadError(this, m_willExecuteInOrder ? ScriptRunner::IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION);
return;
« no previous file with comments | « Source/core/dom/ScriptLoader.h ('k') | Source/core/html/HTMLScriptElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698