зеркало из https://github.com/mozilla/gecko-dev.git
Bug 453801. Make sure to not fire onload before deferred scripts have executed. r+sr=sicking
This commit is contained in:
Родитель
2894d13353
Коммит
7aa39e7e29
|
@ -123,7 +123,9 @@ NS_IMPL_THREADSAFE_ISUPPORTS0(nsScriptLoadRequest)
|
|||
nsScriptLoader::nsScriptLoader(nsIDocument *aDocument)
|
||||
: mDocument(aDocument),
|
||||
mBlockerCount(0),
|
||||
mEnabled(PR_TRUE)
|
||||
mEnabled(PR_TRUE),
|
||||
mDeferEnabled(PR_FALSE),
|
||||
mUnblockOnloadWhenDoneProcessing(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -711,6 +713,15 @@ nsScriptLoader::ProcessPendingRequests()
|
|||
mPendingChildLoaders.RemoveElementAt(0);
|
||||
child->RemoveExecuteBlocker();
|
||||
}
|
||||
|
||||
if (mUnblockOnloadWhenDoneProcessing && mDocument &&
|
||||
!GetFirstPendingRequest()) {
|
||||
// No more pending scripts; time to unblock onload.
|
||||
// OK to unblock onload synchronously here, since callers must be
|
||||
// prepared for the world changing anyway.
|
||||
mUnblockOnloadWhenDoneProcessing = PR_FALSE;
|
||||
mDocument->UnblockOnload(PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
@ -988,6 +999,11 @@ nsScriptLoader::ShouldExecuteScript(nsIDocument* aDocument,
|
|||
void
|
||||
nsScriptLoader::EndDeferringScripts()
|
||||
{
|
||||
if (mDeferEnabled) {
|
||||
// Have to check because we apparently get EndDeferringScripts
|
||||
// without BeginDeferringScripts in some cases
|
||||
mUnblockOnloadWhenDoneProcessing = PR_TRUE;
|
||||
}
|
||||
mDeferEnabled = PR_FALSE;
|
||||
for (PRUint32 i = 0; i < (PRUint32)mRequests.Count(); ++i) {
|
||||
mRequests[i]->mDefer = PR_FALSE;
|
||||
|
|
|
@ -194,6 +194,9 @@ public:
|
|||
void BeginDeferringScripts()
|
||||
{
|
||||
mDeferEnabled = PR_TRUE;
|
||||
if (mDocument) {
|
||||
mDocument->BlockOnload();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -229,9 +232,11 @@ protected:
|
|||
nsresult StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType);
|
||||
|
||||
/**
|
||||
* Process any pending requests asyncronously (i.e. off an event) if there
|
||||
* Process any pending requests asynchronously (i.e. off an event) if there
|
||||
* are any. Note that this is a no-op if there aren't any currently pending
|
||||
* requests.
|
||||
*
|
||||
* This function is virtual to allow cross-library calls to SetEnabled()
|
||||
*/
|
||||
virtual void ProcessPendingRequestsAsync();
|
||||
|
||||
|
@ -300,6 +305,7 @@ protected:
|
|||
PRUint32 mBlockerCount;
|
||||
PRPackedBool mEnabled;
|
||||
PRPackedBool mDeferEnabled;
|
||||
PRPackedBool mUnblockOnloadWhenDoneProcessing;
|
||||
};
|
||||
|
||||
#endif //__nsScriptLoader_h__
|
||||
|
|
Загрузка…
Ссылка в новой задаче