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

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

Issue 913473002: Testing a fix to crbug.com/456059. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: refactored Created 5 years, 10 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/ScriptRunner.h ('k') | Source/core/html/HTMLScriptElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ScriptRunner.cpp
diff --git a/Source/core/dom/ScriptRunner.cpp b/Source/core/dom/ScriptRunner.cpp
index 44543abd54da0b4edd9e54bbfd7b30a2b3f8d947..88ed1e1c360659213e8affaf7f2ffebd37670c3f 100644
--- a/Source/core/dom/ScriptRunner.cpp
+++ b/Source/core/dom/ScriptRunner.cpp
@@ -118,6 +118,32 @@ void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy
}
}
+void ScriptRunner::movePendingAsyncScript(Document& oldDocument, Document& newDocument, ScriptLoader* scriptLoader)
+{
+ RefPtrWillBeRawPtr<Document> newContextDocument = newDocument.contextDocument().get();
+ if (!newContextDocument) {
+ // Document's contextDocument() method will return no Document if the
+ // following conditions both hold:
+ //
+ // - The Document wasn't created with an explicit context document
+ // and that document is otherwise kept alive.
+ // - The Document itself is detached from its frame.
+ //
+ // The script element's loader is in that case moved to document() and
+ // its script runner, which is the non-null Document that contextDocument()
+ // would return if not detached.
+ ASSERT(!newDocument.frame());
+ newContextDocument = &newDocument;
+ }
+ RefPtrWillBeRawPtr<Document> oldContextDocument = oldDocument.contextDocument().get();
+ if (!oldContextDocument) {
+ ASSERT(!oldDocument.frame());
+ oldContextDocument = &oldDocument;
+ }
+ if (oldContextDocument != newContextDocument)
+ oldContextDocument->scriptRunner()->movePendingAsyncScript(newContextDocument->scriptRunner(), scriptLoader);
+}
+
void ScriptRunner::movePendingAsyncScript(ScriptRunner* newRunner, ScriptLoader* scriptLoader)
{
if (m_pendingAsyncScripts.contains(scriptLoader)) {
« no previous file with comments | « Source/core/dom/ScriptRunner.h ('k') | Source/core/html/HTMLScriptElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698