Process queued-up events after all types of reflow so we don't leak things referenced by the queues. b=231278 r=bzbarsky sr=roc

This commit is contained in:
dbaron@dbaron.org
2004-01-21 04:15:00 +00:00
parent c3747a259f
commit 23f9cfdd7c
2 changed files with 44 additions and 20 deletions

View File

@@ -206,11 +206,11 @@ static NS_DEFINE_CID(kViewCID, NS_VIEW_CID);
static PRUint32 gVerifyReflowFlags; static PRUint32 gVerifyReflowFlags;
struct VerifyReflowFlags { struct VerifyReflowFlags {
char* name; const char* name;
PRUint32 bit; PRUint32 bit;
}; };
static VerifyReflowFlags gFlags[] = { static const VerifyReflowFlags gFlags[] = {
{ "verify", VERIFY_REFLOW_ON }, { "verify", VERIFY_REFLOW_ON },
{ "reflow", VERIFY_REFLOW_NOISY }, { "reflow", VERIFY_REFLOW_NOISY },
{ "all", VERIFY_REFLOW_ALL }, { "all", VERIFY_REFLOW_ALL },
@@ -227,8 +227,8 @@ static void
ShowVerifyReflowFlags() ShowVerifyReflowFlags()
{ {
printf("Here are the available GECKO_VERIFY_REFLOW_FLAGS:\n"); printf("Here are the available GECKO_VERIFY_REFLOW_FLAGS:\n");
VerifyReflowFlags* flag = gFlags; const VerifyReflowFlags* flag = gFlags;
VerifyReflowFlags* limit = gFlags + NUM_VERIFY_REFLOW_FLAGS; const VerifyReflowFlags* limit = gFlags + NUM_VERIFY_REFLOW_FLAGS;
while (flag < limit) { while (flag < limit) {
printf(" %s\n", flag->name); printf(" %s\n", flag->name);
++flag; ++flag;
@@ -1430,8 +1430,8 @@ nsIPresShell::GetVerifyReflowEnable()
*comma = '\0'; *comma = '\0';
PRBool found = PR_FALSE; PRBool found = PR_FALSE;
VerifyReflowFlags* flag = gFlags; const VerifyReflowFlags* flag = gFlags;
VerifyReflowFlags* limit = gFlags + NUM_VERIFY_REFLOW_FLAGS; const VerifyReflowFlags* limit = gFlags + NUM_VERIFY_REFLOW_FLAGS;
while (flag < limit) { while (flag < limit) {
if (PL_strcasecmp(flag->name, flags) == 0) { if (PL_strcasecmp(flag->name, flags) == 0) {
gVerifyReflowFlags |= flag->bit; gVerifyReflowFlags |= flag->bit;
@@ -1592,6 +1592,13 @@ PresShell::~PresShell()
NS_ASSERTION(mCurrentEventContentStack.Count() == 0, NS_ASSERTION(mCurrentEventContentStack.Count() == 0,
"Huh, event content left on the stack in pres shell dtor!"); "Huh, event content left on the stack in pres shell dtor!");
NS_ASSERTION(mFirstDOMEventRequest == nsnull &&
mLastDOMEventRequest == nsnull &&
mFirstAttributeRequest == nsnull &&
mLastAttributeRequest == nsnull &&
mFirstCallbackEventRequest == nsnull &&
mLastCallbackEventRequest == nsnull,
"post-reflow queues not empty. This means we're leaking");
NS_IF_RELEASE(mCurrentEventContent); NS_IF_RELEASE(mCurrentEventContent);
@@ -2819,6 +2826,10 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
DidCauseReflow(); DidCauseReflow();
HandlePostedDOMEvents();
HandlePostedAttributeChanges();
HandlePostedReflowCallbacks();
if (mViewManager && mCaret && !mViewEventListener) { if (mViewManager && mCaret && !mViewEventListener) {
nsIScrollableView* scrollingView = nsnull; nsIScrollableView* scrollingView = nsnull;
mViewManager->GetRootScrollableView(&scrollingView); mViewManager->GetRootScrollableView(&scrollingView);
@@ -2879,13 +2890,11 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
{ {
PRBool firstReflow = PR_FALSE; PRBool firstReflow = PR_FALSE;
mViewManager->CacheWidgetChanges(PR_TRUE); WillCauseReflow();
if (mCaret) if (mCaret)
mCaret->EraseCaret(); mCaret->EraseCaret();
WillCauseReflow();
if (mPresContext) { if (mPresContext) {
nsRect r(0, 0, aWidth, aHeight); nsRect r(0, 0, aWidth, aHeight);
mPresContext->SetVisibleArea(r); mPresContext->SetVisibleArea(r);
@@ -2966,7 +2975,6 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
} }
#endif #endif
mViewManager->CacheWidgetChanges(PR_FALSE);
HandlePostedDOMEvents(); HandlePostedDOMEvents();
HandlePostedAttributeChanges(); HandlePostedAttributeChanges();
HandlePostedReflowCallbacks(); HandlePostedReflowCallbacks();
@@ -3487,6 +3495,10 @@ PresShell::StyleChangeReflow()
DidCauseReflow(); DidCauseReflow();
HandlePostedDOMEvents();
HandlePostedAttributeChanges();
HandlePostedReflowCallbacks();
return NS_OK; //XXX this needs to be real. MMP return NS_OK; //XXX this needs to be real. MMP
} }

View File

@@ -206,11 +206,11 @@ static NS_DEFINE_CID(kViewCID, NS_VIEW_CID);
static PRUint32 gVerifyReflowFlags; static PRUint32 gVerifyReflowFlags;
struct VerifyReflowFlags { struct VerifyReflowFlags {
char* name; const char* name;
PRUint32 bit; PRUint32 bit;
}; };
static VerifyReflowFlags gFlags[] = { static const VerifyReflowFlags gFlags[] = {
{ "verify", VERIFY_REFLOW_ON }, { "verify", VERIFY_REFLOW_ON },
{ "reflow", VERIFY_REFLOW_NOISY }, { "reflow", VERIFY_REFLOW_NOISY },
{ "all", VERIFY_REFLOW_ALL }, { "all", VERIFY_REFLOW_ALL },
@@ -227,8 +227,8 @@ static void
ShowVerifyReflowFlags() ShowVerifyReflowFlags()
{ {
printf("Here are the available GECKO_VERIFY_REFLOW_FLAGS:\n"); printf("Here are the available GECKO_VERIFY_REFLOW_FLAGS:\n");
VerifyReflowFlags* flag = gFlags; const VerifyReflowFlags* flag = gFlags;
VerifyReflowFlags* limit = gFlags + NUM_VERIFY_REFLOW_FLAGS; const VerifyReflowFlags* limit = gFlags + NUM_VERIFY_REFLOW_FLAGS;
while (flag < limit) { while (flag < limit) {
printf(" %s\n", flag->name); printf(" %s\n", flag->name);
++flag; ++flag;
@@ -1430,8 +1430,8 @@ nsIPresShell::GetVerifyReflowEnable()
*comma = '\0'; *comma = '\0';
PRBool found = PR_FALSE; PRBool found = PR_FALSE;
VerifyReflowFlags* flag = gFlags; const VerifyReflowFlags* flag = gFlags;
VerifyReflowFlags* limit = gFlags + NUM_VERIFY_REFLOW_FLAGS; const VerifyReflowFlags* limit = gFlags + NUM_VERIFY_REFLOW_FLAGS;
while (flag < limit) { while (flag < limit) {
if (PL_strcasecmp(flag->name, flags) == 0) { if (PL_strcasecmp(flag->name, flags) == 0) {
gVerifyReflowFlags |= flag->bit; gVerifyReflowFlags |= flag->bit;
@@ -1592,6 +1592,13 @@ PresShell::~PresShell()
NS_ASSERTION(mCurrentEventContentStack.Count() == 0, NS_ASSERTION(mCurrentEventContentStack.Count() == 0,
"Huh, event content left on the stack in pres shell dtor!"); "Huh, event content left on the stack in pres shell dtor!");
NS_ASSERTION(mFirstDOMEventRequest == nsnull &&
mLastDOMEventRequest == nsnull &&
mFirstAttributeRequest == nsnull &&
mLastAttributeRequest == nsnull &&
mFirstCallbackEventRequest == nsnull &&
mLastCallbackEventRequest == nsnull,
"post-reflow queues not empty. This means we're leaking");
NS_IF_RELEASE(mCurrentEventContent); NS_IF_RELEASE(mCurrentEventContent);
@@ -2819,6 +2826,10 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
DidCauseReflow(); DidCauseReflow();
HandlePostedDOMEvents();
HandlePostedAttributeChanges();
HandlePostedReflowCallbacks();
if (mViewManager && mCaret && !mViewEventListener) { if (mViewManager && mCaret && !mViewEventListener) {
nsIScrollableView* scrollingView = nsnull; nsIScrollableView* scrollingView = nsnull;
mViewManager->GetRootScrollableView(&scrollingView); mViewManager->GetRootScrollableView(&scrollingView);
@@ -2879,13 +2890,11 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
{ {
PRBool firstReflow = PR_FALSE; PRBool firstReflow = PR_FALSE;
mViewManager->CacheWidgetChanges(PR_TRUE); WillCauseReflow();
if (mCaret) if (mCaret)
mCaret->EraseCaret(); mCaret->EraseCaret();
WillCauseReflow();
if (mPresContext) { if (mPresContext) {
nsRect r(0, 0, aWidth, aHeight); nsRect r(0, 0, aWidth, aHeight);
mPresContext->SetVisibleArea(r); mPresContext->SetVisibleArea(r);
@@ -2966,7 +2975,6 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
} }
#endif #endif
mViewManager->CacheWidgetChanges(PR_FALSE);
HandlePostedDOMEvents(); HandlePostedDOMEvents();
HandlePostedAttributeChanges(); HandlePostedAttributeChanges();
HandlePostedReflowCallbacks(); HandlePostedReflowCallbacks();
@@ -3487,6 +3495,10 @@ PresShell::StyleChangeReflow()
DidCauseReflow(); DidCauseReflow();
HandlePostedDOMEvents();
HandlePostedAttributeChanges();
HandlePostedReflowCallbacks();
return NS_OK; //XXX this needs to be real. MMP return NS_OK; //XXX this needs to be real. MMP
} }