Tweaked incremental reflow support logic

This commit is contained in:
kipp%netscape.com 1999-09-10 18:49:23 +00:00
Родитель 9a70323f4e
Коммит c211a54bed
2 изменённых файлов: 92 добавлений и 94 удалений

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

@ -271,7 +271,7 @@ protected:
#ifdef NS_DEBUG #ifdef NS_DEBUG
nsresult CloneStyleSet(nsIStyleSet* aSet, nsIStyleSet** aResult); nsresult CloneStyleSet(nsIStyleSet* aSet, nsIStyleSet** aResult);
void VerifyIncrementalReflow(); PRBool VerifyIncrementalReflow();
PRBool mInVerifyReflow; PRBool mInVerifyReflow;
#endif #endif
@ -320,40 +320,46 @@ private:
* means that you cannot perform logging before then. * means that you cannot perform logging before then.
*/ */
static PRLogModuleInfo* gLogModule; static PRLogModuleInfo* gLogModule;
static PRUint32 gVerifyReflowFlags;
#define VERIFY_REFLOW_ON 0x1
#define VERIFY_REFLOW_NOISY 0x2
#define VERIFY_REFLOW_ALL 0x4
#endif #endif
static PRBool gVerifyReflow = PRBool(0x55); static PRBool gVerifyReflowEnabled;
#ifdef NS_DEBUG
static PRBool gVerifyReflowAll;
#endif
NS_LAYOUT PRBool NS_LAYOUT PRBool
nsIPresShell::GetVerifyReflowEnable() nsIPresShell::GetVerifyReflowEnable()
{ {
#ifdef NS_DEBUG #ifdef NS_DEBUG
if (gVerifyReflow == PRBool(0x55)) { static PRBool firstTime = PR_TRUE;
if (firstTime) {
firstTime = PR_FALSE;
gLogModule = PR_NewLogModule("verifyreflow"); gLogModule = PR_NewLogModule("verifyreflow");
gVerifyReflow = 0 != gLogModule->level; gVerifyReflowFlags = gLogModule->level;
if (gLogModule->level > 1) { if (VERIFY_REFLOW_ON & gVerifyReflowFlags) {
gVerifyReflowAll = PR_TRUE; gVerifyReflowEnabled = PR_TRUE;
} }
printf("Note: verifyreflow is %sabled", printf("Note: verifyreflow is %sabled",
gVerifyReflow ? "en" : "dis"); gVerifyReflowEnabled ? "en" : "dis");
if (gVerifyReflowAll) { if (VERIFY_REFLOW_NOISY & gVerifyReflowFlags) {
printf(" (diff all enabled)\n"); printf(" (noisy)");
} }
else { if (VERIFY_REFLOW_ALL & gVerifyReflowFlags) {
printf("\n"); printf(" (all)");
} }
printf("\n");
} }
#endif #endif
return gVerifyReflow; return gVerifyReflowEnabled;
} }
NS_LAYOUT void NS_LAYOUT void
nsIPresShell::SetVerifyReflowEnable(PRBool aEnabled) nsIPresShell::SetVerifyReflowEnable(PRBool aEnabled)
{ {
gVerifyReflow = aEnabled; gVerifyReflowEnabled = aEnabled;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1244,23 +1250,21 @@ PresShell::ProcessReflowCommands()
if (GetVerifyReflowEnable()) { if (GetVerifyReflowEnable()) {
// First synchronously render what we have so far so that we can // First synchronously render what we have so far so that we can
// see it. // see it.
// if (gVerifyReflowAll) { nsIView* rootView;
// printf("Before verify-reflow\n"); mViewManager->GetRootView(rootView);
nsIView* rootView; mViewManager->UpdateView(rootView, nsnull, NS_VMREFRESH_IMMEDIATE);
mViewManager->GetRootView(rootView);
mViewManager->UpdateView(rootView, nsnull, NS_VMREFRESH_IMMEDIATE);
// PR_Sleep(PR_SecondsToInterval(3));
// }
mInVerifyReflow = PR_TRUE; mInVerifyReflow = PR_TRUE;
VerifyIncrementalReflow(); PRBool ok = VerifyIncrementalReflow();
mInVerifyReflow = PR_FALSE; mInVerifyReflow = PR_FALSE;
if (gVerifyReflowAll) { if (!ok) {
printf("After verify-reflow\n"); if (VERIFY_REFLOW_ALL & gVerifyReflowFlags) {
printf("verifyreflow: finished\n");
}
} }
if (0 != mReflowCommands.Count()) { if (0 != mReflowCommands.Count()) {
printf("XXX yikes!\n"); printf("XXX yikes! reflow commands queued during verify-reflow\n");
} }
} }
#endif #endif
@ -2095,13 +2099,13 @@ LogVerifyMessage(nsIFrame* k1, nsIFrame* k2, const char* aMsg,
nsAutoString name; nsAutoString name;
k1->GetFrameName(name); k1->GetFrameName(name);
fputs(name, stdout); fputs(name, stdout);
stdout << r1; printf("{%d, %d, %d, %d}", r1.x, r1.y, r1.width, r1.height);
printf(" != "); printf(" != ");
k2->GetFrameName(name); k2->GetFrameName(name);
fputs(name, stdout); fputs(name, stdout);
stdout << r2; printf("{%d, %d, %d, %d}", r2.x, r2.y, r2.width, r2.height);
printf(" %s\n", aMsg); printf(" %s\n", aMsg);
} }
@ -2110,7 +2114,6 @@ static PRBool
CompareTrees(nsIFrame* aA, nsIFrame* aB) CompareTrees(nsIFrame* aA, nsIFrame* aB)
{ {
PRBool ok = PR_TRUE; PRBool ok = PR_TRUE;
PRBool whoops = PR_FALSE;
nsIAtom* listName = nsnull; nsIAtom* listName = nsnull;
PRInt32 listIndex = 0; PRInt32 listIndex = 0;
do { do {
@ -2123,7 +2126,7 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
ok = PR_FALSE; ok = PR_FALSE;
LogVerifyMessage(k1, k2, "child counts don't match: "); LogVerifyMessage(k1, k2, "child counts don't match: ");
printf("%d != %d\n", l1, l2); printf("%d != %d\n", l1, l2);
if (!gVerifyReflowAll) { if (0 == (VERIFY_REFLOW_ALL & gVerifyReflowFlags)) {
break; break;
} }
} }
@ -2136,7 +2139,6 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
((nsnull != k1) && (nsnull == k2))) { ((nsnull != k1) && (nsnull == k2))) {
ok = PR_FALSE; ok = PR_FALSE;
LogVerifyMessage(k1, k2, "child lists are different\n"); LogVerifyMessage(k1, k2, "child lists are different\n");
whoops = PR_TRUE;
break; break;
} }
else if (nsnull != k1) { else if (nsnull != k1) {
@ -2146,7 +2148,6 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
if (r1 != r2) { if (r1 != r2) {
ok = PR_FALSE; ok = PR_FALSE;
LogVerifyMessage(k1, k2, "(frame rects)", r1, r2); LogVerifyMessage(k1, k2, "(frame rects)", r1, r2);
whoops = PR_TRUE;
} }
// Make sure either both have views or neither have views; if they // Make sure either both have views or neither have views; if they
@ -2159,15 +2160,12 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
((nsnull != v1) && (nsnull == v2))) { ((nsnull != v1) && (nsnull == v2))) {
ok = PR_FALSE; ok = PR_FALSE;
LogVerifyMessage(k1, k2, "child views are not matched\n"); LogVerifyMessage(k1, k2, "child views are not matched\n");
whoops = PR_TRUE;
} }
else if (nsnull != v1) { else if (nsnull != v1) {
v1->GetBounds(r1); v1->GetBounds(r1);
v2->GetBounds(r2); v2->GetBounds(r2);
if (r1 != r2) { if (r1 != r2) {
// ok = PR_FALSE;
LogVerifyMessage(k1, k2, "(view rects)", r1, r2); LogVerifyMessage(k1, k2, "(view rects)", r1, r2);
// whoops = PR_TRUE;
} }
v1->GetWidget(w1); v1->GetWidget(w1);
@ -2176,27 +2174,23 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
((nsnull != w1) && (nsnull == w2))) { ((nsnull != w1) && (nsnull == w2))) {
ok = PR_FALSE; ok = PR_FALSE;
LogVerifyMessage(k1, k2, "child widgets are not matched\n"); LogVerifyMessage(k1, k2, "child widgets are not matched\n");
whoops = PR_TRUE;
} }
else if (nsnull != w1) { else if (nsnull != w1) {
w1->GetBounds(r1); w1->GetBounds(r1);
w2->GetBounds(r2); w2->GetBounds(r2);
if (r1 != r2) { if (r1 != r2) {
// ok = PR_FALSE;
LogVerifyMessage(k1, k2, "(widget rects)", r1, r2); LogVerifyMessage(k1, k2, "(widget rects)", r1, r2);
// whoops = PR_TRUE;
} }
} }
} }
if (whoops && !gVerifyReflowAll) { if (!ok && (0 == (VERIFY_REFLOW_ALL & gVerifyReflowFlags))) {
break; break;
} }
// Compare the sub-trees too // Compare the sub-trees too
if (!CompareTrees(k1, k2)) { if (!CompareTrees(k1, k2)) {
if (!gVerifyReflowAll) { ok = PR_FALSE;
ok = PR_FALSE; if (0 == (VERIFY_REFLOW_ALL & gVerifyReflowFlags)) {
whoops = PR_TRUE;
break; break;
} }
} }
@ -2209,7 +2203,7 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
break; break;
} }
} }
if (whoops && !gVerifyReflowAll) { if (!ok && (0 == (VERIFY_REFLOW_ALL & gVerifyReflowFlags))) {
break; break;
} }
NS_IF_RELEASE(listName); NS_IF_RELEASE(listName);
@ -2220,7 +2214,9 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
aB->GetAdditionalChildListName(listIndex, &listName2); aB->GetAdditionalChildListName(listIndex, &listName2);
listIndex++; listIndex++;
if (listName1 != listName2) { if (listName1 != listName2) {
ok = PR_FALSE; if (0 == (VERIFY_REFLOW_ALL & gVerifyReflowFlags)) {
ok = PR_FALSE;
}
LogVerifyMessage(k1, k2, "child list names are not matched: "); LogVerifyMessage(k1, k2, "child list names are not matched: ");
nsAutoString tmp; nsAutoString tmp;
if (nsnull != listName1) { if (nsnull != listName1) {
@ -2326,7 +2322,7 @@ PresShell::CloneStyleSet(nsIStyleSet* aSet, nsIStyleSet** aResult)
// After an incremental reflow, we verify the correctness by doing a // After an incremental reflow, we verify the correctness by doing a
// full reflow into a fresh frame tree. // full reflow into a fresh frame tree.
void PRBool
PresShell::VerifyIncrementalReflow() PresShell::VerifyIncrementalReflow()
{ {
// All the stuff we are creating that needs releasing // All the stuff we are creating that needs releasing
@ -2439,7 +2435,8 @@ PresShell::VerifyIncrementalReflow()
root1 = FindTopFrame(root1); root1 = FindTopFrame(root1);
root2 = FindTopFrame(root2); root2 = FindTopFrame(root2);
#endif #endif
if (!CompareTrees(root1, root2)) { PRBool ok = CompareTrees(root1, root2);
if (!ok && (VERIFY_REFLOW_NOISY & gVerifyReflowFlags)) {
printf("Verify reflow failed, primary tree:\n"); printf("Verify reflow failed, primary tree:\n");
root1->List(stdout, 0); root1->List(stdout, 0);
printf("Verification tree:\n"); printf("Verification tree:\n");
@ -2455,5 +2452,7 @@ PresShell::VerifyIncrementalReflow()
sh->EndObservingDocument(); sh->EndObservingDocument();
NS_RELEASE(sh); NS_RELEASE(sh);
NS_RELEASE(vm); NS_RELEASE(vm);
return ok;
} }
#endif #endif

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

@ -271,7 +271,7 @@ protected:
#ifdef NS_DEBUG #ifdef NS_DEBUG
nsresult CloneStyleSet(nsIStyleSet* aSet, nsIStyleSet** aResult); nsresult CloneStyleSet(nsIStyleSet* aSet, nsIStyleSet** aResult);
void VerifyIncrementalReflow(); PRBool VerifyIncrementalReflow();
PRBool mInVerifyReflow; PRBool mInVerifyReflow;
#endif #endif
@ -320,40 +320,46 @@ private:
* means that you cannot perform logging before then. * means that you cannot perform logging before then.
*/ */
static PRLogModuleInfo* gLogModule; static PRLogModuleInfo* gLogModule;
static PRUint32 gVerifyReflowFlags;
#define VERIFY_REFLOW_ON 0x1
#define VERIFY_REFLOW_NOISY 0x2
#define VERIFY_REFLOW_ALL 0x4
#endif #endif
static PRBool gVerifyReflow = PRBool(0x55); static PRBool gVerifyReflowEnabled;
#ifdef NS_DEBUG
static PRBool gVerifyReflowAll;
#endif
NS_LAYOUT PRBool NS_LAYOUT PRBool
nsIPresShell::GetVerifyReflowEnable() nsIPresShell::GetVerifyReflowEnable()
{ {
#ifdef NS_DEBUG #ifdef NS_DEBUG
if (gVerifyReflow == PRBool(0x55)) { static PRBool firstTime = PR_TRUE;
if (firstTime) {
firstTime = PR_FALSE;
gLogModule = PR_NewLogModule("verifyreflow"); gLogModule = PR_NewLogModule("verifyreflow");
gVerifyReflow = 0 != gLogModule->level; gVerifyReflowFlags = gLogModule->level;
if (gLogModule->level > 1) { if (VERIFY_REFLOW_ON & gVerifyReflowFlags) {
gVerifyReflowAll = PR_TRUE; gVerifyReflowEnabled = PR_TRUE;
} }
printf("Note: verifyreflow is %sabled", printf("Note: verifyreflow is %sabled",
gVerifyReflow ? "en" : "dis"); gVerifyReflowEnabled ? "en" : "dis");
if (gVerifyReflowAll) { if (VERIFY_REFLOW_NOISY & gVerifyReflowFlags) {
printf(" (diff all enabled)\n"); printf(" (noisy)");
} }
else { if (VERIFY_REFLOW_ALL & gVerifyReflowFlags) {
printf("\n"); printf(" (all)");
} }
printf("\n");
} }
#endif #endif
return gVerifyReflow; return gVerifyReflowEnabled;
} }
NS_LAYOUT void NS_LAYOUT void
nsIPresShell::SetVerifyReflowEnable(PRBool aEnabled) nsIPresShell::SetVerifyReflowEnable(PRBool aEnabled)
{ {
gVerifyReflow = aEnabled; gVerifyReflowEnabled = aEnabled;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1244,23 +1250,21 @@ PresShell::ProcessReflowCommands()
if (GetVerifyReflowEnable()) { if (GetVerifyReflowEnable()) {
// First synchronously render what we have so far so that we can // First synchronously render what we have so far so that we can
// see it. // see it.
// if (gVerifyReflowAll) { nsIView* rootView;
// printf("Before verify-reflow\n"); mViewManager->GetRootView(rootView);
nsIView* rootView; mViewManager->UpdateView(rootView, nsnull, NS_VMREFRESH_IMMEDIATE);
mViewManager->GetRootView(rootView);
mViewManager->UpdateView(rootView, nsnull, NS_VMREFRESH_IMMEDIATE);
// PR_Sleep(PR_SecondsToInterval(3));
// }
mInVerifyReflow = PR_TRUE; mInVerifyReflow = PR_TRUE;
VerifyIncrementalReflow(); PRBool ok = VerifyIncrementalReflow();
mInVerifyReflow = PR_FALSE; mInVerifyReflow = PR_FALSE;
if (gVerifyReflowAll) { if (!ok) {
printf("After verify-reflow\n"); if (VERIFY_REFLOW_ALL & gVerifyReflowFlags) {
printf("verifyreflow: finished\n");
}
} }
if (0 != mReflowCommands.Count()) { if (0 != mReflowCommands.Count()) {
printf("XXX yikes!\n"); printf("XXX yikes! reflow commands queued during verify-reflow\n");
} }
} }
#endif #endif
@ -2095,13 +2099,13 @@ LogVerifyMessage(nsIFrame* k1, nsIFrame* k2, const char* aMsg,
nsAutoString name; nsAutoString name;
k1->GetFrameName(name); k1->GetFrameName(name);
fputs(name, stdout); fputs(name, stdout);
stdout << r1; printf("{%d, %d, %d, %d}", r1.x, r1.y, r1.width, r1.height);
printf(" != "); printf(" != ");
k2->GetFrameName(name); k2->GetFrameName(name);
fputs(name, stdout); fputs(name, stdout);
stdout << r2; printf("{%d, %d, %d, %d}", r2.x, r2.y, r2.width, r2.height);
printf(" %s\n", aMsg); printf(" %s\n", aMsg);
} }
@ -2110,7 +2114,6 @@ static PRBool
CompareTrees(nsIFrame* aA, nsIFrame* aB) CompareTrees(nsIFrame* aA, nsIFrame* aB)
{ {
PRBool ok = PR_TRUE; PRBool ok = PR_TRUE;
PRBool whoops = PR_FALSE;
nsIAtom* listName = nsnull; nsIAtom* listName = nsnull;
PRInt32 listIndex = 0; PRInt32 listIndex = 0;
do { do {
@ -2123,7 +2126,7 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
ok = PR_FALSE; ok = PR_FALSE;
LogVerifyMessage(k1, k2, "child counts don't match: "); LogVerifyMessage(k1, k2, "child counts don't match: ");
printf("%d != %d\n", l1, l2); printf("%d != %d\n", l1, l2);
if (!gVerifyReflowAll) { if (0 == (VERIFY_REFLOW_ALL & gVerifyReflowFlags)) {
break; break;
} }
} }
@ -2136,7 +2139,6 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
((nsnull != k1) && (nsnull == k2))) { ((nsnull != k1) && (nsnull == k2))) {
ok = PR_FALSE; ok = PR_FALSE;
LogVerifyMessage(k1, k2, "child lists are different\n"); LogVerifyMessage(k1, k2, "child lists are different\n");
whoops = PR_TRUE;
break; break;
} }
else if (nsnull != k1) { else if (nsnull != k1) {
@ -2146,7 +2148,6 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
if (r1 != r2) { if (r1 != r2) {
ok = PR_FALSE; ok = PR_FALSE;
LogVerifyMessage(k1, k2, "(frame rects)", r1, r2); LogVerifyMessage(k1, k2, "(frame rects)", r1, r2);
whoops = PR_TRUE;
} }
// Make sure either both have views or neither have views; if they // Make sure either both have views or neither have views; if they
@ -2159,15 +2160,12 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
((nsnull != v1) && (nsnull == v2))) { ((nsnull != v1) && (nsnull == v2))) {
ok = PR_FALSE; ok = PR_FALSE;
LogVerifyMessage(k1, k2, "child views are not matched\n"); LogVerifyMessage(k1, k2, "child views are not matched\n");
whoops = PR_TRUE;
} }
else if (nsnull != v1) { else if (nsnull != v1) {
v1->GetBounds(r1); v1->GetBounds(r1);
v2->GetBounds(r2); v2->GetBounds(r2);
if (r1 != r2) { if (r1 != r2) {
// ok = PR_FALSE;
LogVerifyMessage(k1, k2, "(view rects)", r1, r2); LogVerifyMessage(k1, k2, "(view rects)", r1, r2);
// whoops = PR_TRUE;
} }
v1->GetWidget(w1); v1->GetWidget(w1);
@ -2176,27 +2174,23 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
((nsnull != w1) && (nsnull == w2))) { ((nsnull != w1) && (nsnull == w2))) {
ok = PR_FALSE; ok = PR_FALSE;
LogVerifyMessage(k1, k2, "child widgets are not matched\n"); LogVerifyMessage(k1, k2, "child widgets are not matched\n");
whoops = PR_TRUE;
} }
else if (nsnull != w1) { else if (nsnull != w1) {
w1->GetBounds(r1); w1->GetBounds(r1);
w2->GetBounds(r2); w2->GetBounds(r2);
if (r1 != r2) { if (r1 != r2) {
// ok = PR_FALSE;
LogVerifyMessage(k1, k2, "(widget rects)", r1, r2); LogVerifyMessage(k1, k2, "(widget rects)", r1, r2);
// whoops = PR_TRUE;
} }
} }
} }
if (whoops && !gVerifyReflowAll) { if (!ok && (0 == (VERIFY_REFLOW_ALL & gVerifyReflowFlags))) {
break; break;
} }
// Compare the sub-trees too // Compare the sub-trees too
if (!CompareTrees(k1, k2)) { if (!CompareTrees(k1, k2)) {
if (!gVerifyReflowAll) { ok = PR_FALSE;
ok = PR_FALSE; if (0 == (VERIFY_REFLOW_ALL & gVerifyReflowFlags)) {
whoops = PR_TRUE;
break; break;
} }
} }
@ -2209,7 +2203,7 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
break; break;
} }
} }
if (whoops && !gVerifyReflowAll) { if (!ok && (0 == (VERIFY_REFLOW_ALL & gVerifyReflowFlags))) {
break; break;
} }
NS_IF_RELEASE(listName); NS_IF_RELEASE(listName);
@ -2220,7 +2214,9 @@ CompareTrees(nsIFrame* aA, nsIFrame* aB)
aB->GetAdditionalChildListName(listIndex, &listName2); aB->GetAdditionalChildListName(listIndex, &listName2);
listIndex++; listIndex++;
if (listName1 != listName2) { if (listName1 != listName2) {
ok = PR_FALSE; if (0 == (VERIFY_REFLOW_ALL & gVerifyReflowFlags)) {
ok = PR_FALSE;
}
LogVerifyMessage(k1, k2, "child list names are not matched: "); LogVerifyMessage(k1, k2, "child list names are not matched: ");
nsAutoString tmp; nsAutoString tmp;
if (nsnull != listName1) { if (nsnull != listName1) {
@ -2326,7 +2322,7 @@ PresShell::CloneStyleSet(nsIStyleSet* aSet, nsIStyleSet** aResult)
// After an incremental reflow, we verify the correctness by doing a // After an incremental reflow, we verify the correctness by doing a
// full reflow into a fresh frame tree. // full reflow into a fresh frame tree.
void PRBool
PresShell::VerifyIncrementalReflow() PresShell::VerifyIncrementalReflow()
{ {
// All the stuff we are creating that needs releasing // All the stuff we are creating that needs releasing
@ -2439,7 +2435,8 @@ PresShell::VerifyIncrementalReflow()
root1 = FindTopFrame(root1); root1 = FindTopFrame(root1);
root2 = FindTopFrame(root2); root2 = FindTopFrame(root2);
#endif #endif
if (!CompareTrees(root1, root2)) { PRBool ok = CompareTrees(root1, root2);
if (!ok && (VERIFY_REFLOW_NOISY & gVerifyReflowFlags)) {
printf("Verify reflow failed, primary tree:\n"); printf("Verify reflow failed, primary tree:\n");
root1->List(stdout, 0); root1->List(stdout, 0);
printf("Verification tree:\n"); printf("Verification tree:\n");
@ -2455,5 +2452,7 @@ PresShell::VerifyIncrementalReflow()
sh->EndObservingDocument(); sh->EndObservingDocument();
NS_RELEASE(sh); NS_RELEASE(sh);
NS_RELEASE(vm); NS_RELEASE(vm);
return ok;
} }
#endif #endif