mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 10:45:42 +00:00
Another attempt to get back Tp perf. Bug 294114 again, r+sr=jst
This commit is contained in:
parent
27d65f3d6e
commit
80788ec7d0
@ -5087,6 +5087,16 @@ nsDocument::UnblockOnload()
|
||||
}
|
||||
}
|
||||
|
||||
struct OnloadBlockerEvent : public PLEvent
|
||||
{
|
||||
OnloadBlockerEvent(PRBool aWouldFireOnload) :
|
||||
mWouldFireOnload(aWouldFireOnload)
|
||||
{}
|
||||
|
||||
// Whether we would have fired onload at the point when we posted this event
|
||||
PRBool mWouldFireOnload;
|
||||
};
|
||||
|
||||
void
|
||||
nsDocument::PostUnblockOnloadEvent()
|
||||
{
|
||||
@ -5102,8 +5112,22 @@ nsDocument::PostUnblockOnloadEvent()
|
||||
if (!eventQ) {
|
||||
return;
|
||||
}
|
||||
|
||||
PLEvent* evt = new PLEvent();
|
||||
|
||||
PRBool wouldUnblockOnload = PR_FALSE;
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = GetDocumentLoadGroup();
|
||||
if (loadGroup) {
|
||||
PRUint32 activeCount;
|
||||
nsresult rv = loadGroup->GetActiveCount(&activeCount);
|
||||
// If there is only one active request, then its our onload
|
||||
// blocker; in that case we should fire onload as soon as our event
|
||||
// fires.
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
NS_ASSERTION(activeCount > 0, "Why isn't mOnloadBlocker active?");
|
||||
wouldUnblockOnload = (activeCount == 1);
|
||||
}
|
||||
}
|
||||
|
||||
PLEvent* evt = new OnloadBlockerEvent(wouldUnblockOnload);
|
||||
if (!evt) {
|
||||
return;
|
||||
}
|
||||
@ -5128,7 +5152,8 @@ void* PR_CALLBACK
|
||||
nsDocument::HandleOnloadBlockerEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsDocument* doc = NS_STATIC_CAST(nsDocument*, aEvent->owner);
|
||||
doc->DoUnblockOnload();
|
||||
OnloadBlockerEvent* evt = NS_STATIC_CAST(OnloadBlockerEvent*, aEvent);
|
||||
doc->DoUnblockOnload(evt->mWouldFireOnload);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
@ -5138,11 +5163,12 @@ nsDocument::DestroyOnloadBlockerEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsDocument* doc = NS_STATIC_CAST(nsDocument*, aEvent->owner);
|
||||
NS_RELEASE(doc);
|
||||
delete aEvent;
|
||||
OnloadBlockerEvent* evt = NS_STATIC_CAST(OnloadBlockerEvent*, aEvent);
|
||||
delete evt;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::DoUnblockOnload()
|
||||
nsDocument::DoUnblockOnload(PRBool aWouldHaveUnblocked)
|
||||
{
|
||||
NS_ASSERTION(mOnloadBlockCount != 0,
|
||||
"Shouldn't have a count of zero here, since we stabilized in "
|
||||
@ -5150,9 +5176,10 @@ nsDocument::DoUnblockOnload()
|
||||
|
||||
--mOnloadBlockCount;
|
||||
|
||||
if (mOnloadBlockCount != 0) {
|
||||
// We blocked again after the last unblock. Nothing to do here. We'll
|
||||
// post a new event when we unblock again.
|
||||
if (!aWouldHaveUnblocked && mOnloadBlockCount != 0) {
|
||||
// We blocked again after the last unblock, and weren't obviously
|
||||
// going to fire onload earlier. Nothing to do here. We'll post
|
||||
// a new event when we unblock again.
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -756,7 +756,9 @@ private:
|
||||
void PostUnblockOnloadEvent();
|
||||
static EventHandlerFunc HandleOnloadBlockerEvent;
|
||||
static EventDestructorFunc DestroyOnloadBlockerEvent;
|
||||
void DoUnblockOnload();
|
||||
// aWouldHaveUnblocked should be true if we would have fired onload in
|
||||
// UnblockOnload were we doing so synchronously.
|
||||
void DoUnblockOnload(PRBool aWouldHaveUnblocked);
|
||||
|
||||
// These are not implemented and not supported.
|
||||
nsDocument(const nsDocument& aOther);
|
||||
|
Loading…
Reference in New Issue
Block a user