mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-14 10:43:24 +00:00
Remove reflow callbacks from the list as they are processed, to avoid crashes when reentering HandlePostedReflowCallbacks. b=220126 Patch from Mats Palmgren <mats.palmgren@bredband.net>. r=dbaron sr=roc
This commit is contained in:
parent
5047f7cadc
commit
d7a7c453f5
@ -5040,12 +5040,16 @@ PresShell::CancelReflowCallback(nsIReflowCallback* aCallback)
|
||||
{
|
||||
nsCallbackEventRequest* toFree = node;
|
||||
if (node == mFirstCallbackEventRequest) {
|
||||
mFirstCallbackEventRequest = node->next;
|
||||
node = mFirstCallbackEventRequest;
|
||||
before = nsnull;
|
||||
node = node->next;
|
||||
mFirstCallbackEventRequest = node;
|
||||
NS_ASSERTION(before == nsnull, "impossible");
|
||||
} else {
|
||||
node = node->next;
|
||||
before->next = node;
|
||||
node = node->next;
|
||||
before->next = node;
|
||||
}
|
||||
|
||||
if (toFree == mLastCallbackEventRequest) {
|
||||
mLastCallbackEventRequest = before;
|
||||
}
|
||||
|
||||
FreeFrame(sizeof(nsCallbackEventRequest), toFree);
|
||||
@ -5134,20 +5138,19 @@ void
|
||||
PresShell::HandlePostedReflowCallbacks()
|
||||
{
|
||||
PRBool shouldFlush = PR_FALSE;
|
||||
nsCallbackEventRequest* node = mFirstCallbackEventRequest;
|
||||
while(node)
|
||||
{
|
||||
nsIReflowCallback* callback = node->callback;
|
||||
nsCallbackEventRequest* toFree = node;
|
||||
node = node->next;
|
||||
mFirstCallbackEventRequest = node;
|
||||
FreeFrame(sizeof(nsCallbackEventRequest), toFree);
|
||||
if (callback)
|
||||
callback->ReflowFinished(this, &shouldFlush);
|
||||
NS_IF_RELEASE(callback);
|
||||
}
|
||||
|
||||
mFirstCallbackEventRequest = mLastCallbackEventRequest = nsnull;
|
||||
while (mFirstCallbackEventRequest) {
|
||||
nsCallbackEventRequest* node = mFirstCallbackEventRequest;
|
||||
mFirstCallbackEventRequest = node->next;
|
||||
if (!mFirstCallbackEventRequest) {
|
||||
mLastCallbackEventRequest = nsnull;
|
||||
}
|
||||
nsIReflowCallback* callback = node->callback;
|
||||
FreeFrame(sizeof(nsCallbackEventRequest), node);
|
||||
if (callback)
|
||||
callback->ReflowFinished(this, &shouldFlush);
|
||||
NS_IF_RELEASE(callback);
|
||||
}
|
||||
|
||||
if (shouldFlush)
|
||||
FlushPendingNotifications(PR_FALSE);
|
||||
|
@ -5040,12 +5040,16 @@ PresShell::CancelReflowCallback(nsIReflowCallback* aCallback)
|
||||
{
|
||||
nsCallbackEventRequest* toFree = node;
|
||||
if (node == mFirstCallbackEventRequest) {
|
||||
mFirstCallbackEventRequest = node->next;
|
||||
node = mFirstCallbackEventRequest;
|
||||
before = nsnull;
|
||||
node = node->next;
|
||||
mFirstCallbackEventRequest = node;
|
||||
NS_ASSERTION(before == nsnull, "impossible");
|
||||
} else {
|
||||
node = node->next;
|
||||
before->next = node;
|
||||
node = node->next;
|
||||
before->next = node;
|
||||
}
|
||||
|
||||
if (toFree == mLastCallbackEventRequest) {
|
||||
mLastCallbackEventRequest = before;
|
||||
}
|
||||
|
||||
FreeFrame(sizeof(nsCallbackEventRequest), toFree);
|
||||
@ -5134,20 +5138,19 @@ void
|
||||
PresShell::HandlePostedReflowCallbacks()
|
||||
{
|
||||
PRBool shouldFlush = PR_FALSE;
|
||||
nsCallbackEventRequest* node = mFirstCallbackEventRequest;
|
||||
while(node)
|
||||
{
|
||||
nsIReflowCallback* callback = node->callback;
|
||||
nsCallbackEventRequest* toFree = node;
|
||||
node = node->next;
|
||||
mFirstCallbackEventRequest = node;
|
||||
FreeFrame(sizeof(nsCallbackEventRequest), toFree);
|
||||
if (callback)
|
||||
callback->ReflowFinished(this, &shouldFlush);
|
||||
NS_IF_RELEASE(callback);
|
||||
}
|
||||
|
||||
mFirstCallbackEventRequest = mLastCallbackEventRequest = nsnull;
|
||||
while (mFirstCallbackEventRequest) {
|
||||
nsCallbackEventRequest* node = mFirstCallbackEventRequest;
|
||||
mFirstCallbackEventRequest = node->next;
|
||||
if (!mFirstCallbackEventRequest) {
|
||||
mLastCallbackEventRequest = nsnull;
|
||||
}
|
||||
nsIReflowCallback* callback = node->callback;
|
||||
FreeFrame(sizeof(nsCallbackEventRequest), node);
|
||||
if (callback)
|
||||
callback->ReflowFinished(this, &shouldFlush);
|
||||
NS_IF_RELEASE(callback);
|
||||
}
|
||||
|
||||
if (shouldFlush)
|
||||
FlushPendingNotifications(PR_FALSE);
|
||||
|
Loading…
Reference in New Issue
Block a user