From 6059a83cca344387a620f3c8859468dc54feb129 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Thu, 22 Feb 2001 13:58:17 +0000 Subject: [PATCH] Added additional reflow count info on a frame by frame basis Bug 69361 r=attinasi sr=waterson --- layout/base/nsIPresShell.h | 2 +- layout/base/nsPresContext.cpp | 4 +- layout/base/nsPresContext.h | 4 +- layout/base/nsPresShell.cpp | 161 +++++++++++++++++++++++++-- layout/base/public/nsIPresContext.h | 4 +- layout/base/public/nsIPresShell.h | 2 +- layout/base/public/nsPresContext.h | 4 +- layout/base/src/nsPresContext.cpp | 4 +- layout/base/src/nsPresContext.h | 2 +- layout/html/base/src/nsPresShell.cpp | 161 +++++++++++++++++++++++++-- 10 files changed, 319 insertions(+), 29 deletions(-) diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index b95215e6b89..c22e214b3c5 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -509,7 +509,7 @@ public: #ifdef MOZ_REFLOW_PERF NS_IMETHOD ClearTotals() = 0; NS_IMETHOD DumpReflows() = 0; - NS_IMETHOD CountReflows(const char * aName, PRUint32 aType) = 0; + NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0; #endif }; diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 99d7d05ecda..c828daa1463 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1333,10 +1333,10 @@ nsPresContext::IsRenderingOnlySelection(PRBool* aResult) #ifdef MOZ_REFLOW_PERF NS_IMETHODIMP -nsPresContext::CountReflows(const char * aName, PRUint32 aType) +nsPresContext::CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) { if (mShell) { - mShell->CountReflows(aName, aType); + mShell->CountReflows(aName, aType, aFrame); } return NS_OK; } diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index d24d3cb2846..98d8043f7e4 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -380,7 +380,7 @@ public: NS_IMETHOD IsRenderingOnlySelection(PRBool* aResult) = 0; #ifdef MOZ_REFLOW_PERF - NS_IMETHOD CountReflows(const char * aName, PRUint32 aType) = 0; + NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0; #endif }; @@ -403,7 +403,7 @@ extern NS_LAYOUT nsresult #ifdef MOZ_REFLOW_PERF #define DO_GLOBAL_REFLOW_COUNT(_name, _type) \ - aPresContext->CountReflows((_name), (_type)); + aPresContext->CountReflows((_name), (_type), (nsIFrame*)this); #else #define DO_GLOBAL_REFLOW_COUNT(_name, _type) #endif // MOZ_REFLOW_PERF diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 47a97d87765..eca4512361e 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -194,8 +194,7 @@ static const char * kGrandTotalsStr = "Grand Totals"; // Counting Class class ReflowCounter { public: - ReflowCounter() { mMgr = nsnull; } - ReflowCounter(ReflowCountMgr * aMgr); + ReflowCounter(ReflowCountMgr * aMgr = nsnull); ~ReflowCounter(); void ClearTotals(); @@ -211,6 +210,8 @@ public: void SetMgr(ReflowCountMgr * aMgr) { mMgr = aMgr; } + PRUint32 GetTotalByType(nsReflowReason aType) { if (aType >= eReflowReason_Initial && aType <= eReflowReason_Dirty) return mTotals[aType]; else return 0; } + protected: void DisplayTotals(PRUint32 * aArray, const char * aTitle); void DisplayHTMLTotals(PRUint32 * aArray, const char * aTitle); @@ -221,6 +222,24 @@ protected: ReflowCountMgr * mMgr; }; +// Counting Class +class IndiReflowCounter { +public: + IndiReflowCounter(ReflowCountMgr * aMgr = nsnull):mMgr(aMgr),mCounter(aMgr),mFrame(nsnull),mParent(nsnull), mCount(0), mHasBeenOutput(PR_FALSE) {} + virtual ~IndiReflowCounter() {} + + nsAutoString mName; + nsIFrame * mFrame; + nsIFrame * mParent; + PRInt32 mCount; + + ReflowCountMgr * mMgr; + + ReflowCounter mCounter; + PRBool mHasBeenOutput; + +}; + // Manager Class class ReflowCountMgr { public: @@ -235,21 +254,30 @@ public: void DisplayHTMLTotals(const char * aStr); void DisplayDiffsInTotals(const char * aStr); - void Add(const char * aName, nsReflowReason aType); + void Add(const char * aName, nsReflowReason aType, nsIFrame * aFrame); ReflowCounter * LookUp(const char * aName); FILE * GetOutFile() { return mFD; } + PLHashTable * GetIndiFrameHT() { return mIndiFrameCounts; } + + void SetPresContext(nsIPresContext * aPresContext) { mPresContext = aPresContext; } // weak reference + void SetPresShell(nsIPresShell* aPresShell) { mPresShell= aPresShell; } // weak reference + protected: void DisplayTotals(PRUint32 * aArray, PRUint32 * aDupArray, char * aTitle); void DisplayHTMLTotals(PRUint32 * aArray, PRUint32 * aDupArray, char * aTitle); static PRIntn RemoveItems(PLHashEntry *he, PRIntn i, void *arg); + static PRIntn RemoveIndiItems(PLHashEntry *he, PRIntn i, void *arg); void CleanUp(); // stdout Output Methods static PRIntn DoSingleTotal(PLHashEntry *he, PRIntn i, void *arg); + static PRIntn DoSingleIndi(PLHashEntry *he, PRIntn i, void *arg); + void DoGrandTotals(); + void DoIndiTotalsTree(); // HTML Output Methods static PRIntn DoSingleHTMLTotal(PLHashEntry *he, PRIntn i, void *arg); @@ -262,10 +290,15 @@ protected: static PRIntn DoDisplayDiffTotals(PLHashEntry *he, PRIntn i, void *arg); PLHashTable * mCounts; + PLHashTable * mIndiFrameCounts; FILE * mFD; - + PRBool mCycledOnce; + // Root Frame for Individual Tracking + nsIPresContext * mPresContext; + nsIPresShell* mPresShell; + // ReflowCountMgr gReflowCountMgr; }; #endif @@ -953,7 +986,7 @@ public: #ifdef MOZ_REFLOW_PERF NS_IMETHOD ClearTotals(); NS_IMETHOD DumpReflows(); - NS_IMETHOD CountReflows(const char * aName, PRUint32 aType); + NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame); #endif protected: @@ -1210,6 +1243,8 @@ PresShell::PresShell():mAnonymousContentTable(nsnull), #ifdef MOZ_REFLOW_PERF mReflowCountMgr = new ReflowCountMgr(); + mReflowCountMgr->SetPresContext(mPresContext); + mReflowCountMgr->SetPresShell(this); #endif } @@ -6003,10 +6038,10 @@ PresShell::DumpReflows() //------------------------------------------------------------- NS_IMETHODIMP -PresShell::CountReflows(const char * aName, PRUint32 aType) +PresShell::CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) { if (mReflowCountMgr) { - mReflowCountMgr->Add(aName, (nsReflowReason)aType); + mReflowCountMgr->Add(aName, (nsReflowReason)aType, aFrame); } return NS_OK; } @@ -6138,6 +6173,8 @@ ReflowCountMgr::ReflowCountMgr() { mCounts = PL_NewHashTable(10, PL_HashString, PL_CompareStrings, PL_CompareValues, nsnull, nsnull); + mIndiFrameCounts = PL_NewHashTable(10, PL_HashString, PL_CompareStrings, + PL_CompareValues, nsnull, nsnull); mCycledOnce = PR_FALSE; } @@ -6162,8 +6199,10 @@ ReflowCounter * ReflowCountMgr::LookUp(const char * aName) } //------------------------------------------------------------------ -void ReflowCountMgr::Add(const char * aName, nsReflowReason aType) +void ReflowCountMgr::Add(const char * aName, nsReflowReason aType, nsIFrame * aFrame) { + NS_ASSERTION(aName != nsnull, "Name shouldn't be null!"); + if (nsnull != mCounts) { ReflowCounter * counter = (ReflowCounter *)PL_HashTableLookup(mCounts, aName); if (counter == nsnull) { @@ -6175,6 +6214,25 @@ void ReflowCountMgr::Add(const char * aName, nsReflowReason aType) } counter->Add(aType); } + + if (nsnull != mIndiFrameCounts && aFrame != nsnull) { + char * key = new char[16]; + sprintf(key, "%p", aFrame); + IndiReflowCounter * counter = (IndiReflowCounter *)PL_HashTableLookup(mIndiFrameCounts, key); + if (counter == nsnull) { + counter = new IndiReflowCounter(this); + NS_ASSERTION(counter != nsnull, "null ptr"); + counter->mFrame = aFrame; + aFrame->GetParent(&counter->mParent); + counter->mName.AssignWithConversion(aName); + PL_HashTableAdd(mIndiFrameCounts, key, counter); + } + // this eliminates extra counts from super classes + if (counter->mName.EqualsWithConversion(aName)) { + counter->mCount++; + counter->mCounter.Add(aType, 1); + } + } } //------------------------------------------------------------------ @@ -6188,13 +6246,27 @@ PRIntn ReflowCountMgr::RemoveItems(PLHashEntry *he, PRIntn i, void *arg) return HT_ENUMERATE_REMOVE; } +//------------------------------------------------------------------ +PRIntn ReflowCountMgr::RemoveIndiItems(PLHashEntry *he, PRIntn i, void *arg) +{ + char *str = (char *)he->key; + IndiReflowCounter * counter = (IndiReflowCounter *)he->value; + delete counter; + delete [] str; + + return HT_ENUMERATE_REMOVE; +} + //------------------------------------------------------------------ void ReflowCountMgr::CleanUp() { if (nsnull != mCounts) { PL_HashTableEnumerateEntries(mCounts, RemoveItems, nsnull); + PL_HashTableEnumerateEntries(mIndiFrameCounts, RemoveIndiItems, nsnull); PL_HashTableDestroy(mCounts); + PL_HashTableDestroy(mIndiFrameCounts); mCounts = nsnull; + mCounts = mIndiFrameCounts; } } @@ -6236,6 +6308,78 @@ void ReflowCountMgr::DoGrandTotals() } } +static void RecurseIndiTotals(nsIPresContext* aPresContext, + PLHashTable * aHT, + nsIFrame * aParentFrame, + PRInt32 aLevel) +{ + if (aParentFrame == nsnull) { + return; + } + + char key[16]; + sprintf(key, "%p", aParentFrame); + IndiReflowCounter * counter = (IndiReflowCounter *)PL_HashTableLookup(aHT, key); + if (counter) { + counter->mHasBeenOutput = PR_TRUE; + char * name = counter->mName.ToNewCString(); + for (PRInt32 i=0;imCount); + for (PRInt32 inx=0;inx<5;inx++) { + if (inx != 0) printf(","); + printf("%d", counter->mCounter.GetTotalByType(nsReflowReason(inx))); + } + printf("]\n"); + nsMemory::Free(name); + } + + nsIFrame * child; + aParentFrame->FirstChild(aPresContext, nsnull, &child); + while (child) { + RecurseIndiTotals(aPresContext, aHT, child, aLevel+1); + child->GetNextSibling(&child); + } + +} + +//------------------------------------------------------------------ +PRIntn ReflowCountMgr::DoSingleIndi(PLHashEntry *he, PRIntn i, void *arg) +{ + char *str = (char *)he->key; + IndiReflowCounter * counter = (IndiReflowCounter *)he->value; + if (counter && !counter->mHasBeenOutput) { + char * name = counter->mName.ToNewCString(); + printf("%s - %p [%d][", name, counter->mFrame, counter->mCount); + for (PRInt32 inx=0;inx<5;inx++) { + if (inx != 0) printf(","); + printf("%d", counter->mCounter.GetTotalByType(nsReflowReason(inx))); + } + printf("]\n"); + nsMemory::Free(name); + } + return HT_ENUMERATE_NEXT; +} + +//------------------------------------------------------------------ +void ReflowCountMgr::DoIndiTotalsTree() +{ + if (nsnull != mCounts) { + printf("\n------------------------------------------------\n"); + printf("-- Individual Frame Counts\n"); + printf("------------------------------------------------\n"); + + if (mPresShell) { + nsIFrame * rootFrame; + mPresShell->GetRootFrame(&rootFrame); + RecurseIndiTotals(mPresContext, mIndiFrameCounts, rootFrame, 0); + printf("------------------------------------------------\n"); + printf("-- Individual Counts of Frames not in Root Tree\n"); + printf("------------------------------------------------\n"); + PL_HashTableEnumerateEntries(mIndiFrameCounts, DoSingleIndi, this); + } + } +} + //------------------------------------------------------------------ PRIntn ReflowCountMgr::DoSingleHTMLTotal(PLHashEntry *he, PRIntn i, void *arg) { @@ -6275,6 +6419,7 @@ void ReflowCountMgr::DisplayTotals(const char * aStr) { printf("%s\n", aStr?aStr:"No name"); DoGrandTotals(); + DoIndiTotalsTree(); } //------------------------------------ diff --git a/layout/base/public/nsIPresContext.h b/layout/base/public/nsIPresContext.h index d24d3cb2846..98d8043f7e4 100644 --- a/layout/base/public/nsIPresContext.h +++ b/layout/base/public/nsIPresContext.h @@ -380,7 +380,7 @@ public: NS_IMETHOD IsRenderingOnlySelection(PRBool* aResult) = 0; #ifdef MOZ_REFLOW_PERF - NS_IMETHOD CountReflows(const char * aName, PRUint32 aType) = 0; + NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0; #endif }; @@ -403,7 +403,7 @@ extern NS_LAYOUT nsresult #ifdef MOZ_REFLOW_PERF #define DO_GLOBAL_REFLOW_COUNT(_name, _type) \ - aPresContext->CountReflows((_name), (_type)); + aPresContext->CountReflows((_name), (_type), (nsIFrame*)this); #else #define DO_GLOBAL_REFLOW_COUNT(_name, _type) #endif // MOZ_REFLOW_PERF diff --git a/layout/base/public/nsIPresShell.h b/layout/base/public/nsIPresShell.h index b95215e6b89..c22e214b3c5 100644 --- a/layout/base/public/nsIPresShell.h +++ b/layout/base/public/nsIPresShell.h @@ -509,7 +509,7 @@ public: #ifdef MOZ_REFLOW_PERF NS_IMETHOD ClearTotals() = 0; NS_IMETHOD DumpReflows() = 0; - NS_IMETHOD CountReflows(const char * aName, PRUint32 aType) = 0; + NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0; #endif }; diff --git a/layout/base/public/nsPresContext.h b/layout/base/public/nsPresContext.h index d24d3cb2846..98d8043f7e4 100644 --- a/layout/base/public/nsPresContext.h +++ b/layout/base/public/nsPresContext.h @@ -380,7 +380,7 @@ public: NS_IMETHOD IsRenderingOnlySelection(PRBool* aResult) = 0; #ifdef MOZ_REFLOW_PERF - NS_IMETHOD CountReflows(const char * aName, PRUint32 aType) = 0; + NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0; #endif }; @@ -403,7 +403,7 @@ extern NS_LAYOUT nsresult #ifdef MOZ_REFLOW_PERF #define DO_GLOBAL_REFLOW_COUNT(_name, _type) \ - aPresContext->CountReflows((_name), (_type)); + aPresContext->CountReflows((_name), (_type), (nsIFrame*)this); #else #define DO_GLOBAL_REFLOW_COUNT(_name, _type) #endif // MOZ_REFLOW_PERF diff --git a/layout/base/src/nsPresContext.cpp b/layout/base/src/nsPresContext.cpp index 99d7d05ecda..c828daa1463 100644 --- a/layout/base/src/nsPresContext.cpp +++ b/layout/base/src/nsPresContext.cpp @@ -1333,10 +1333,10 @@ nsPresContext::IsRenderingOnlySelection(PRBool* aResult) #ifdef MOZ_REFLOW_PERF NS_IMETHODIMP -nsPresContext::CountReflows(const char * aName, PRUint32 aType) +nsPresContext::CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) { if (mShell) { - mShell->CountReflows(aName, aType); + mShell->CountReflows(aName, aType, aFrame); } return NS_OK; } diff --git a/layout/base/src/nsPresContext.h b/layout/base/src/nsPresContext.h index f94e55e8255..eb8f2e28495 100644 --- a/layout/base/src/nsPresContext.h +++ b/layout/base/src/nsPresContext.h @@ -160,7 +160,7 @@ public: NS_IMETHOD IsRenderingOnlySelection(PRBool* aResult); #ifdef MOZ_REFLOW_PERF - NS_IMETHOD CountReflows(const char * aName, PRUint32 aType); + NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame); #endif // nsIObserver method diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index 47a97d87765..eca4512361e 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -194,8 +194,7 @@ static const char * kGrandTotalsStr = "Grand Totals"; // Counting Class class ReflowCounter { public: - ReflowCounter() { mMgr = nsnull; } - ReflowCounter(ReflowCountMgr * aMgr); + ReflowCounter(ReflowCountMgr * aMgr = nsnull); ~ReflowCounter(); void ClearTotals(); @@ -211,6 +210,8 @@ public: void SetMgr(ReflowCountMgr * aMgr) { mMgr = aMgr; } + PRUint32 GetTotalByType(nsReflowReason aType) { if (aType >= eReflowReason_Initial && aType <= eReflowReason_Dirty) return mTotals[aType]; else return 0; } + protected: void DisplayTotals(PRUint32 * aArray, const char * aTitle); void DisplayHTMLTotals(PRUint32 * aArray, const char * aTitle); @@ -221,6 +222,24 @@ protected: ReflowCountMgr * mMgr; }; +// Counting Class +class IndiReflowCounter { +public: + IndiReflowCounter(ReflowCountMgr * aMgr = nsnull):mMgr(aMgr),mCounter(aMgr),mFrame(nsnull),mParent(nsnull), mCount(0), mHasBeenOutput(PR_FALSE) {} + virtual ~IndiReflowCounter() {} + + nsAutoString mName; + nsIFrame * mFrame; + nsIFrame * mParent; + PRInt32 mCount; + + ReflowCountMgr * mMgr; + + ReflowCounter mCounter; + PRBool mHasBeenOutput; + +}; + // Manager Class class ReflowCountMgr { public: @@ -235,21 +254,30 @@ public: void DisplayHTMLTotals(const char * aStr); void DisplayDiffsInTotals(const char * aStr); - void Add(const char * aName, nsReflowReason aType); + void Add(const char * aName, nsReflowReason aType, nsIFrame * aFrame); ReflowCounter * LookUp(const char * aName); FILE * GetOutFile() { return mFD; } + PLHashTable * GetIndiFrameHT() { return mIndiFrameCounts; } + + void SetPresContext(nsIPresContext * aPresContext) { mPresContext = aPresContext; } // weak reference + void SetPresShell(nsIPresShell* aPresShell) { mPresShell= aPresShell; } // weak reference + protected: void DisplayTotals(PRUint32 * aArray, PRUint32 * aDupArray, char * aTitle); void DisplayHTMLTotals(PRUint32 * aArray, PRUint32 * aDupArray, char * aTitle); static PRIntn RemoveItems(PLHashEntry *he, PRIntn i, void *arg); + static PRIntn RemoveIndiItems(PLHashEntry *he, PRIntn i, void *arg); void CleanUp(); // stdout Output Methods static PRIntn DoSingleTotal(PLHashEntry *he, PRIntn i, void *arg); + static PRIntn DoSingleIndi(PLHashEntry *he, PRIntn i, void *arg); + void DoGrandTotals(); + void DoIndiTotalsTree(); // HTML Output Methods static PRIntn DoSingleHTMLTotal(PLHashEntry *he, PRIntn i, void *arg); @@ -262,10 +290,15 @@ protected: static PRIntn DoDisplayDiffTotals(PLHashEntry *he, PRIntn i, void *arg); PLHashTable * mCounts; + PLHashTable * mIndiFrameCounts; FILE * mFD; - + PRBool mCycledOnce; + // Root Frame for Individual Tracking + nsIPresContext * mPresContext; + nsIPresShell* mPresShell; + // ReflowCountMgr gReflowCountMgr; }; #endif @@ -953,7 +986,7 @@ public: #ifdef MOZ_REFLOW_PERF NS_IMETHOD ClearTotals(); NS_IMETHOD DumpReflows(); - NS_IMETHOD CountReflows(const char * aName, PRUint32 aType); + NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame); #endif protected: @@ -1210,6 +1243,8 @@ PresShell::PresShell():mAnonymousContentTable(nsnull), #ifdef MOZ_REFLOW_PERF mReflowCountMgr = new ReflowCountMgr(); + mReflowCountMgr->SetPresContext(mPresContext); + mReflowCountMgr->SetPresShell(this); #endif } @@ -6003,10 +6038,10 @@ PresShell::DumpReflows() //------------------------------------------------------------- NS_IMETHODIMP -PresShell::CountReflows(const char * aName, PRUint32 aType) +PresShell::CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) { if (mReflowCountMgr) { - mReflowCountMgr->Add(aName, (nsReflowReason)aType); + mReflowCountMgr->Add(aName, (nsReflowReason)aType, aFrame); } return NS_OK; } @@ -6138,6 +6173,8 @@ ReflowCountMgr::ReflowCountMgr() { mCounts = PL_NewHashTable(10, PL_HashString, PL_CompareStrings, PL_CompareValues, nsnull, nsnull); + mIndiFrameCounts = PL_NewHashTable(10, PL_HashString, PL_CompareStrings, + PL_CompareValues, nsnull, nsnull); mCycledOnce = PR_FALSE; } @@ -6162,8 +6199,10 @@ ReflowCounter * ReflowCountMgr::LookUp(const char * aName) } //------------------------------------------------------------------ -void ReflowCountMgr::Add(const char * aName, nsReflowReason aType) +void ReflowCountMgr::Add(const char * aName, nsReflowReason aType, nsIFrame * aFrame) { + NS_ASSERTION(aName != nsnull, "Name shouldn't be null!"); + if (nsnull != mCounts) { ReflowCounter * counter = (ReflowCounter *)PL_HashTableLookup(mCounts, aName); if (counter == nsnull) { @@ -6175,6 +6214,25 @@ void ReflowCountMgr::Add(const char * aName, nsReflowReason aType) } counter->Add(aType); } + + if (nsnull != mIndiFrameCounts && aFrame != nsnull) { + char * key = new char[16]; + sprintf(key, "%p", aFrame); + IndiReflowCounter * counter = (IndiReflowCounter *)PL_HashTableLookup(mIndiFrameCounts, key); + if (counter == nsnull) { + counter = new IndiReflowCounter(this); + NS_ASSERTION(counter != nsnull, "null ptr"); + counter->mFrame = aFrame; + aFrame->GetParent(&counter->mParent); + counter->mName.AssignWithConversion(aName); + PL_HashTableAdd(mIndiFrameCounts, key, counter); + } + // this eliminates extra counts from super classes + if (counter->mName.EqualsWithConversion(aName)) { + counter->mCount++; + counter->mCounter.Add(aType, 1); + } + } } //------------------------------------------------------------------ @@ -6188,13 +6246,27 @@ PRIntn ReflowCountMgr::RemoveItems(PLHashEntry *he, PRIntn i, void *arg) return HT_ENUMERATE_REMOVE; } +//------------------------------------------------------------------ +PRIntn ReflowCountMgr::RemoveIndiItems(PLHashEntry *he, PRIntn i, void *arg) +{ + char *str = (char *)he->key; + IndiReflowCounter * counter = (IndiReflowCounter *)he->value; + delete counter; + delete [] str; + + return HT_ENUMERATE_REMOVE; +} + //------------------------------------------------------------------ void ReflowCountMgr::CleanUp() { if (nsnull != mCounts) { PL_HashTableEnumerateEntries(mCounts, RemoveItems, nsnull); + PL_HashTableEnumerateEntries(mIndiFrameCounts, RemoveIndiItems, nsnull); PL_HashTableDestroy(mCounts); + PL_HashTableDestroy(mIndiFrameCounts); mCounts = nsnull; + mCounts = mIndiFrameCounts; } } @@ -6236,6 +6308,78 @@ void ReflowCountMgr::DoGrandTotals() } } +static void RecurseIndiTotals(nsIPresContext* aPresContext, + PLHashTable * aHT, + nsIFrame * aParentFrame, + PRInt32 aLevel) +{ + if (aParentFrame == nsnull) { + return; + } + + char key[16]; + sprintf(key, "%p", aParentFrame); + IndiReflowCounter * counter = (IndiReflowCounter *)PL_HashTableLookup(aHT, key); + if (counter) { + counter->mHasBeenOutput = PR_TRUE; + char * name = counter->mName.ToNewCString(); + for (PRInt32 i=0;imCount); + for (PRInt32 inx=0;inx<5;inx++) { + if (inx != 0) printf(","); + printf("%d", counter->mCounter.GetTotalByType(nsReflowReason(inx))); + } + printf("]\n"); + nsMemory::Free(name); + } + + nsIFrame * child; + aParentFrame->FirstChild(aPresContext, nsnull, &child); + while (child) { + RecurseIndiTotals(aPresContext, aHT, child, aLevel+1); + child->GetNextSibling(&child); + } + +} + +//------------------------------------------------------------------ +PRIntn ReflowCountMgr::DoSingleIndi(PLHashEntry *he, PRIntn i, void *arg) +{ + char *str = (char *)he->key; + IndiReflowCounter * counter = (IndiReflowCounter *)he->value; + if (counter && !counter->mHasBeenOutput) { + char * name = counter->mName.ToNewCString(); + printf("%s - %p [%d][", name, counter->mFrame, counter->mCount); + for (PRInt32 inx=0;inx<5;inx++) { + if (inx != 0) printf(","); + printf("%d", counter->mCounter.GetTotalByType(nsReflowReason(inx))); + } + printf("]\n"); + nsMemory::Free(name); + } + return HT_ENUMERATE_NEXT; +} + +//------------------------------------------------------------------ +void ReflowCountMgr::DoIndiTotalsTree() +{ + if (nsnull != mCounts) { + printf("\n------------------------------------------------\n"); + printf("-- Individual Frame Counts\n"); + printf("------------------------------------------------\n"); + + if (mPresShell) { + nsIFrame * rootFrame; + mPresShell->GetRootFrame(&rootFrame); + RecurseIndiTotals(mPresContext, mIndiFrameCounts, rootFrame, 0); + printf("------------------------------------------------\n"); + printf("-- Individual Counts of Frames not in Root Tree\n"); + printf("------------------------------------------------\n"); + PL_HashTableEnumerateEntries(mIndiFrameCounts, DoSingleIndi, this); + } + } +} + //------------------------------------------------------------------ PRIntn ReflowCountMgr::DoSingleHTMLTotal(PLHashEntry *he, PRIntn i, void *arg) { @@ -6275,6 +6419,7 @@ void ReflowCountMgr::DisplayTotals(const char * aStr) { printf("%s\n", aStr?aStr:"No name"); DoGrandTotals(); + DoIndiTotalsTree(); } //------------------------------------