diff --git a/content/base/src/nsContentSink.cpp b/content/base/src/nsContentSink.cpp index bb5b782bd60..71544edd528 100644 --- a/content/base/src/nsContentSink.cpp +++ b/content/base/src/nsContentSink.cpp @@ -1780,7 +1780,7 @@ nsContentSink::ReadyToCallDidBuildModelImpl(PRBool aTerminated) } if (mScriptLoader) { - mScriptLoader->EndDeferringScripts(aTerminated); + mScriptLoader->ParsingComplete(aTerminated); } } diff --git a/content/base/src/nsScriptLoader.cpp b/content/base/src/nsScriptLoader.cpp index 340f2ac78cd..a739d5e944b 100644 --- a/content/base/src/nsScriptLoader.cpp +++ b/content/base/src/nsScriptLoader.cpp @@ -1029,23 +1029,24 @@ nsScriptLoader::ShouldExecuteScript(nsIDocument* aDocument, } void -nsScriptLoader::EndDeferringScripts(PRBool aKillDeferred) +nsScriptLoader::ParsingComplete(PRBool aTerminated) { if (mDeferEnabled) { - // Have to check because we apparently get EndDeferringScripts + // Have to check because we apparently get ParsingComplete // without BeginDeferringScripts in some cases mUnblockOnloadWhenDoneProcessing = PR_TRUE; } mDeferEnabled = PR_FALSE; - for (PRUint32 i = 0; i < (PRUint32)mRequests.Count(); ++i) { - if (aKillDeferred && mRequests[i]->mDefer) { - mRequests.RemoveObjectAt(i--); - } - else { + if (aTerminated) { + mRequests.Clear(); + } else { + for (PRUint32 i = 0; i < (PRUint32)mRequests.Count(); ++i) { mRequests[i]->mDefer = PR_FALSE; } } + // Have to call this even if aTerminated so we'll correctly unblock + // onload and all. ProcessPendingRequests(); } diff --git a/content/base/src/nsScriptLoader.h b/content/base/src/nsScriptLoader.h index 5a297cb6dd5..13cdd317b9b 100644 --- a/content/base/src/nsScriptLoader.h +++ b/content/base/src/nsScriptLoader.h @@ -209,16 +209,15 @@ public: } /** - * Stops defering scripts and immediately processes the mDeferredRequests - * queue. + * Notifies the script loader that parsing is done. If aTerminated is true, + * this will drop any pending scripts that haven't run yet. Otherwise, it + * will stops deferring scripts and immediately processes the + * mDeferredRequests queue. * - * WARNING: This function will syncronously execute content scripts, so be + * WARNING: This function will synchronously execute content scripts, so be * prepared that the world might change around you. - * - * If aKillDeferred is PR_TRUE, deferred scripts won't be run, but instead - * removed. */ - void EndDeferringScripts(PRBool aKillDeferred); + void ParsingComplete(PRBool aTerminated); /** * Returns the number of pending scripts, deferred or not.