Bug 466409. If the load is stopped, don't run any pending scripts. r+sr=sicking

This commit is contained in:
Boris Zbarsky 2009-07-07 22:55:05 -07:00
parent b7e8beed7e
commit 69367704d2
3 changed files with 15 additions and 15 deletions

View File

@ -1780,7 +1780,7 @@ nsContentSink::ReadyToCallDidBuildModelImpl(PRBool aTerminated)
}
if (mScriptLoader) {
mScriptLoader->EndDeferringScripts(aTerminated);
mScriptLoader->ParsingComplete(aTerminated);
}
}

View File

@ -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();
}

View File

@ -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.