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

Unified Diff: Source/core/html/HTMLScriptElement.cpp

Issue 827233002: Improve HTMLScriptElement::didMoveToNewDocument() comment. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLScriptElement.cpp
diff --git a/Source/core/html/HTMLScriptElement.cpp b/Source/core/html/HTMLScriptElement.cpp
index bce71bdbcb9686e604a03408401a08950b6eeb5f..d429566d61384e6d8863194220a569b943ce31e2 100644
--- a/Source/core/html/HTMLScriptElement.cpp
+++ b/Source/core/html/HTMLScriptElement.cpp
@@ -75,12 +75,17 @@ void HTMLScriptElement::didMoveToNewDocument(Document& oldDocument)
{
RefPtrWillBeRawPtr<Document> contextDocument = document().contextDocument().get();
if (!contextDocument) {
+ // 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(!document().frame());
- // A frame-detached document is handled as having no context
- // document - it would be the document if not detached. The
- // newly moved script element needs to be the latter here as
- // the script loader for the pending script must also move to
- // reside with that document and its script runner.
contextDocument = &document();
}
oldDocument.scriptRunner()->movePendingAsyncScript(contextDocument->scriptRunner(), m_loader.get());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698