Go back to having UnblockOnload firing onload sync in cases where it's safe.

Attempting to address Tp fallout from bug 294114, r+sr=jst
This commit is contained in:
bzbarsky%mit.edu 2005-08-23 23:24:30 +00:00
Родитель 344d326ae4
Коммит f41b587cae
5 изменённых файлов: 23 добавлений и 13 удалений

Просмотреть файл

@ -93,8 +93,8 @@ class nsILayoutHistoryState;
// IID for the nsIDocument interface
#define NS_IDOCUMENT_IID \
{ 0xd0128d9f, 0x8d36, 0x4944, \
{ 0xb2, 0x4b, 0x05, 0xba, 0xc2, 0x73, 0x1c, 0x66 } }
{ 0x6a524f45, 0x4e21, 0x4049, \
{ 0xb3, 0x57, 0x2d, 0x29, 0x75, 0x76, 0x7a, 0x43 } }
// The base value for the content ID counter.
// This counter is used by the document to
@ -725,12 +725,16 @@ public:
* should block onload is posted. onload is guaranteed to not fire until
* either all calls to BlockOnload() have been matched by calls to
* UnblockOnload() or the load has been stopped altogether (by the user
* pressing the Stop button, say). onload will fire asynchronously after all
* onload blocks have been removed. It will NOT fire from inside
* UnblockOnload.
* pressing the Stop button, say).
*/
virtual void BlockOnload() = 0;
virtual void UnblockOnload() = 0;
/**
* @param aFireSync whether to fire onload synchronously. If false,
* onload will fire asynchronously after all onload blocks have been
* removed. It will NOT fire from inside UnblockOnload. If true,
* onload may fire from inside UnblockOnload.
*/
virtual void UnblockOnload(PRBool aFireSync) = 0;
/**
* Notification that the page has been shown, for documents which are loaded

Просмотреть файл

@ -2281,7 +2281,7 @@ nsDocument::EndLoad()
observer->EndLoad(this);
}
DispatchContentLoadedEvents();
UnblockOnload();
UnblockOnload(PR_TRUE);
}
void
@ -5079,7 +5079,7 @@ nsDocument::BlockOnload()
}
void
nsDocument::UnblockOnload()
nsDocument::UnblockOnload(PRBool aFireSync)
{
if (mOnloadBlockCount == 0) {
NS_NOTREACHED("More UnblockOnload() calls than BlockOnload() calls; dropping call");
@ -5091,7 +5091,13 @@ nsDocument::UnblockOnload()
// If mScriptGlobalObject is null, we shouldn't be messing with the loadgroup
// -- it's not ours.
if (mOnloadBlockCount == 0 && mScriptGlobalObject) {
PostUnblockOnloadEvent();
if (aFireSync) {
// Increment mOnloadBlockCount, since DoUnblockOnload will decrement it
++mOnloadBlockCount;
DoUnblockOnload();
} else {
PostUnblockOnloadEvent();
}
}
}

Просмотреть файл

@ -646,7 +646,7 @@ public:
virtual NS_HIDDEN_(already_AddRefed<nsILayoutHistoryState>) GetLayoutHistoryState() const;
virtual NS_HIDDEN_(void) BlockOnload();
virtual NS_HIDDEN_(void) UnblockOnload();
virtual NS_HIDDEN_(void) UnblockOnload(PRBool aFireSync);
virtual NS_HIDDEN_(void) AddStyleRelevantLink(nsIContent* aContent, nsIURI* aURI);
virtual NS_HIDDEN_(void) ForgetLink(nsIContent* aContent);

Просмотреть файл

@ -670,7 +670,7 @@ PR_STATIC_CALLBACK(void)
DestroyImagePLEvent(PLEvent* aEvent)
{
ImageEvent* evt = NS_STATIC_CAST(ImageEvent*, aEvent);
evt->mDocument->UnblockOnload();
evt->mDocument->UnblockOnload(PR_TRUE);
delete evt;
}

Просмотреть файл

@ -3842,7 +3842,7 @@ struct CantRenderReplacedElementEvent : public PLEvent {
CantRenderReplacedElementEvent(PresShell* aPresShell,
nsIFrame* aFrame) NS_HIDDEN;
~CantRenderReplacedElementEvent() {
OurPresShell()->GetDocument()->UnblockOnload();
OurPresShell()->GetDocument()->UnblockOnload(PR_TRUE);
}
NS_HIDDEN_(PresShell*) OurPresShell() {
@ -6835,7 +6835,7 @@ PresShell::DoneRemovingReflowCommands()
// can well fire with no presentation in sight. So just check
// whether we actually blocked onload.
if (mRCCreatedDuringLoad == 0 && mDocumentOnloadBlocked) {
mDocument->UnblockOnload();
mDocument->UnblockOnload(PR_FALSE);
mDocumentOnloadBlocked = PR_FALSE;
}
}