From edb1ea12e8228f2834bfcee00dc3f65da82ba4ba Mon Sep 17 00:00:00 2001 From: "karnaze%netscape.com" Date: Thu, 1 Feb 2001 02:29:14 +0000 Subject: [PATCH] more peformance work on test case of bug 60494. Removed redundant calls to recompute colspan widths. Added more debug reflow timing code. r=peterl. git-svn-id: svn://10.0.0.236/trunk@85925 18797224-902f-48f8-a5cc-f745e15eee43 --- .../table/src/BasicTableLayoutStrategy.cpp | 26 ++++- .../layout/html/table/src/nsTableFrame.cpp | 107 +++++++++++++++--- mozilla/layout/html/table/src/nsTableFrame.h | 20 ++++ .../tables/BasicTableLayoutStrategy.cpp | 26 ++++- mozilla/layout/tables/nsTableFrame.cpp | 107 +++++++++++++++--- mozilla/layout/tables/nsTableFrame.h | 20 ++++ 6 files changed, 266 insertions(+), 40 deletions(-) diff --git a/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp b/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp index 99ed762986f..e913b9dffe7 100644 --- a/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp +++ b/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp @@ -484,6 +484,9 @@ BasicTableLayoutStrategy::ComputeNonPctColspanWidths(const nsHTMLReflowState& aR PRBool aConsiderPct, float aPixelToTwips) { +#ifdef DEBUG_TABLE_REFLOW_TIMING + nsTableFrame::DebugTimeNonPctColspans(*mTableFrame, (nsHTMLReflowState&)aReflowState, PR_TRUE); +#endif PRInt32 numCols = mTableFrame->GetColCount(); // zero out prior ADJ values @@ -549,6 +552,9 @@ BasicTableLayoutStrategy::ComputeNonPctColspanWidths(const nsHTMLReflowState& aR } } } +#ifdef DEBUG_TABLE_REFLOW_TIMING + nsTableFrame::DebugTimeNonPctColspans(*mTableFrame, (nsHTMLReflowState&)aReflowState, PR_FALSE); +#endif } #ifdef DEBUG @@ -843,6 +849,9 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre const nsHTMLReflowState& aReflowState, float aPixelToTwips) { +#ifdef DEBUG_TABLE_REFLOW_TIMING + nsTableFrame::DebugTimeNonPctCols(*mTableFrame, (nsHTMLReflowState&)aReflowState, PR_TRUE); +#endif if (gsDebugAssign) {printf("AssignNonPctColWidths en max=%d count=%d \n", aMaxWidth, gsDebugCount++); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);} PRBool rv = PR_FALSE; PRInt32 numRows = mTableFrame->GetRowCount(); @@ -1028,6 +1037,9 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre } if (gsDebugAssign) {printf("AssignNonPctColWidths ex\n"); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);} +#ifdef DEBUG_TABLE_REFLOW_TIMING + nsTableFrame::DebugTimeNonPctCols(*mTableFrame, (nsHTMLReflowState&)aReflowState, PR_FALSE); +#endif return rv; } @@ -1064,6 +1076,9 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(const nsHTMLReflowState aReflowS PRBool aTableIsAutoWidth, float aPixelToTwips) { +#ifdef DEBUG_TABLE_REFLOW_TIMING + nsTableFrame::DebugTimePctCols(*mTableFrame, (nsHTMLReflowState&)aReflowState, PR_TRUE); +#endif mTableFrame->SetHasCellSpanningPctCol(PR_FALSE); // this gets refigured below PRInt32 numRows = mTableFrame->GetRowCount(); PRInt32 numCols = mTableFrame->GetColCount(); // consider cols at end without orig cells @@ -1250,8 +1265,9 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(const nsHTMLReflowState aReflowS // check to see if a cell spans a percentage col. This will cause the MIN_ADJ, // FIX_ADJ, and DES_ADJ values to be recomputed - for (colX = 0; colX < numCols; colX++) { - for (rowX = 0; rowX < numRows; rowX++) { + PRBool done = PR_FALSE; + for (colX = 0; (colX < numCols) && !done; colX++) { + for (rowX = 0; (rowX < numRows) && !done; rowX++) { PRBool originates; PRInt32 colSpan; nsTableCellFrame* cellFrame = mTableFrame->GetCellInfoAt(rowX, colX, &originates, &colSpan); @@ -1259,13 +1275,14 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(const nsHTMLReflowState aReflowS continue; } // determine if the cell spans cols which have a pct value - for (PRInt32 spanX = 0; spanX < colSpan; spanX++) { + for (PRInt32 spanX = 0; (spanX < colSpan) && !done; spanX++) { nsTableColFrame* colFrame = mTableFrame->GetColFrame(colX + spanX); if (!colFrame) continue; if (colFrame->GetWidth(PCT) > 0) { mTableFrame->SetHasCellSpanningPctCol(PR_TRUE); // recompute the MIN_ADJ, FIX_ADJ, and DES_ADJ values ComputeNonPctColspanWidths(aReflowState, PR_TRUE, aPixelToTwips); + done = PR_TRUE; break; } } @@ -1362,6 +1379,9 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(const nsHTMLReflowState aReflowS ReduceOverSpecifiedPctCols(NSToCoordRound(((float)(colPctTotal - 100)) * 0.01f * (float)basis)); } +#ifdef DEBUG_TABLE_REFLOW_TIMING + nsTableFrame::DebugTimePctCols(*mTableFrame, (nsHTMLReflowState&)aReflowState, PR_FALSE); +#endif return basis; } diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index 1e6dea0f8bd..212af65d0f4 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -170,6 +170,12 @@ nsTableFrame::nsTableFrame() #endif #ifdef DEBUG_TABLE_REFLOW_TIMING mTimer = new nsReflowTimer(this); + nsReflowTimer* timer = new nsReflowTimer(this); + mTimer->mNextSibling = timer; + timer = new nsReflowTimer(this); + mTimer->mNextSibling->mNextSibling = timer; + timer = new nsReflowTimer(this); + mTimer->mNextSibling->mNextSibling->mNextSibling = timer; #endif } @@ -4625,13 +4631,16 @@ void PrettyUC(nscoord aSize, } } -void GetFrameTypeName(nsIAtom* aFrameType, - char* aName) +PRBool GetFrameTypeName(nsIAtom* aFrameType, + char* aName) { + PRBool isTable = PR_FALSE; if (nsLayoutAtoms::tableOuterFrame == aFrameType) strcpy(aName, "Tbl"); - else if (nsLayoutAtoms::tableFrame == aFrameType) + else if (nsLayoutAtoms::tableFrame == aFrameType) { strcpy(aName, "Tbl"); + isTable = PR_TRUE; + } else if (nsLayoutAtoms::tableRowGroupFrame == aFrameType) strcpy(aName, "RowG"); else if (nsLayoutAtoms::tableRowFrame == aFrameType) @@ -4642,6 +4651,8 @@ void GetFrameTypeName(nsIAtom* aFrameType, strcpy(aName, "Block"); else NS_ASSERTION(PR_FALSE, "invalid call to GetFrameTypeName"); + + return isTable; } #ifdef DEBUG_TABLE_REFLOW @@ -4750,6 +4761,15 @@ nsReflowTimer* GetFrameTimer(nsIFrame* aFrame, return nsnull; } +void DebugReflowPrintAuxTimer(char* aMes, + nsReflowTimer* aTimer) +{ + printf("%s %dms", aMes, aTimer->Elapsed()); + if (aTimer->mNumStarts > 1) { + printf(" times=%d", aTimer->mNumStarts); + } +} + void DebugReflowPrint(nsReflowTimer& aTimer, PRUint32 aLevel, PRBool aSummary) @@ -4762,12 +4782,18 @@ void DebugReflowPrint(nsReflowTimer& aTimer, // get the frame type char fName[128]; - GetFrameTypeName(aTimer.mFrameType, fName); + PRBool isTable = GetFrameTypeName(aTimer.mFrameType, fName); // print the timer printf("\n%s%s %dms %p", indentChar, fName, aTimer.Elapsed(), aTimer.mFrame); if (aSummary) { printf(" times=%d", aTimer.mNumStarts); + if (isTable) { + printf("\n%s", indentChar); + DebugReflowPrintAuxTimer("nonPctCols", aTimer.mNextSibling); + DebugReflowPrintAuxTimer(" nonPctColspans", aTimer.mNextSibling->mNextSibling); + DebugReflowPrintAuxTimer(" pctCols", aTimer.mNextSibling->mNextSibling->mNextSibling); + } } else { char avWidth[16]; @@ -4794,6 +4820,12 @@ void DebugReflowPrint(nsReflowTimer& aTimer, printf(" status=%d", aTimer.mStatus); } printf(" cnt=%d", aTimer.mCount); + if (isTable) { + printf("\n%s", indentChar); + DebugReflowPrintAuxTimer("nonPctCols", aTimer.mNextSibling); + DebugReflowPrintAuxTimer(" nonPctColspans", aTimer.mNextSibling->mNextSibling); + DebugReflowPrintAuxTimer(" pctCols", aTimer.mNextSibling->mNextSibling->mNextSibling); + } } // print the timer's children nsVoidArray& children = aTimer.mChildren; @@ -4824,16 +4856,15 @@ void nsTableFrame::DebugReflow(nsIFrame* aFrame, nsCOMPtr frameType = nsnull; aFrame->GetFrameType(getter_AddRefs(frameType)); nsReflowTimer* frameTimer = GetFrameTimer(aFrame, frameType.get()); - if (!frameTimer) { - NS_ASSERTION(PR_FALSE, "no frame timer"); - return; - } + if (!frameTimer) {NS_ASSERTION(PR_FALSE, "no frame timer");return;} if (!aMetrics) { // start // create the reflow timer nsReflowTimer* timer = new nsReflowTimer(aFrame); - if (!timer) { - NS_ASSERTION(PR_FALSE, "could not create timer"); - return; + // create the aux table timers if they don't exist + if ((nsLayoutAtoms::tableFrame == frameType.get()) && !timer->mNextSibling) { + timer->mNextSibling = new nsReflowTimer(aFrame); + timer->mNextSibling->mNextSibling = new nsReflowTimer(aFrame); + timer->mNextSibling->mNextSibling->mNextSibling = new nsReflowTimer(aFrame); } timer->mReason = aState.reason; timer->mAvailWidth = aState.availableWidth; @@ -4861,17 +4892,59 @@ void nsTableFrame::DebugReflow(nsIFrame* aFrame, ? aMetrics->mMaximumWidth : -1; timer->mStatus = aStatus; } - else { - NS_ASSERTION(PR_FALSE, "bad DebugTimeReflow"); - return; - } + else {NS_ASSERTION(PR_FALSE, "bad DebugTimeReflow");return;} + // stop the frame summary timer + frameTimer->Stop(); if (!parentTimer) { // print out all of the reflow timers DebugReflowPrint(*timer, 0, PR_FALSE); timer->Destroy(); } - // stop the frame summary timer - frameTimer->Stop(); + } +} + +void nsTableFrame::DebugTimeNonPctCols(nsTableFrame& aFrame, + nsHTMLReflowState& aState, + PRBool aStart) +{ + nsReflowTimer* timer = (nsReflowTimer*)aState.mDebugHook; + if (aStart) { + timer->mNextSibling->Start(); + aFrame.mTimer->mNextSibling->Start(); + } + else { + timer->mNextSibling->Stop(); + aFrame.mTimer->mNextSibling->Stop(); + } +} + +void nsTableFrame::DebugTimeNonPctColspans(nsTableFrame& aFrame, + nsHTMLReflowState& aState, + PRBool aStart) +{ + nsReflowTimer* timer = (nsReflowTimer*)aState.mDebugHook; + if (aStart) { + timer->mNextSibling->mNextSibling->Start(); + aFrame.mTimer->mNextSibling->mNextSibling->Start(); + } + else { + timer->mNextSibling->mNextSibling->Stop(); + aFrame.mTimer->mNextSibling->mNextSibling->Stop(); + } +} + +void nsTableFrame::DebugTimePctCols(nsTableFrame& aFrame, + nsHTMLReflowState& aState, + PRBool aStart) +{ + nsReflowTimer* timer = (nsReflowTimer*)aState.mDebugHook; + if (aStart) { + timer->mNextSibling->mNextSibling->mNextSibling->Start(); + aFrame.mTimer->mNextSibling->mNextSibling->mNextSibling->Start(); + } + else { + timer->mNextSibling->mNextSibling->mNextSibling->Stop(); + aFrame.mTimer->mNextSibling->mNextSibling->mNextSibling->Stop(); } } diff --git a/mozilla/layout/html/table/src/nsTableFrame.h b/mozilla/layout/html/table/src/nsTableFrame.h index 544600d02e3..618019c660c 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.h +++ b/mozilla/layout/html/table/src/nsTableFrame.h @@ -55,6 +55,7 @@ class nsReflowTimer public: nsReflowTimer(nsIFrame* aFrame) { mFrame = aFrame; + mNextSibling = nsnull; aFrame->GetFrameType(&mFrameType); Reset(); } @@ -65,6 +66,11 @@ public: ((nsReflowTimer*)mChildren.ElementAt(childX))->Destroy(); } NS_IF_RELEASE(mFrameType); + if (mNextSibling) { // table frames have 3 auxillary timers + delete mNextSibling->mNextSibling->mNextSibling; + delete mNextSibling->mNextSibling; + delete mNextSibling; + } delete this; } @@ -119,6 +125,7 @@ public: nscoord mDesiredWidth; nscoord mDesiredHeight; nsReflowStatus mStatus; + nsReflowTimer* mNextSibling; private: ~nsReflowTimer() {} @@ -943,9 +950,22 @@ public: nsHTMLReflowState& aReflowState, nsHTMLReflowMetrics* aMetrics = nsnull, nsReflowStatus aStatus = NS_FRAME_COMPLETE); + #ifdef DEBUG_TABLE_REFLOW_TIMING static void DebugReflowDone(nsIFrame* aFrame); + static void DebugTimePctCols(nsTableFrame& aFrame, + nsHTMLReflowState& aReflowState, + PRBool aStart); + + static void DebugTimeNonPctCols(nsTableFrame& aFrame, + nsHTMLReflowState& aReflowState, + PRBool aStart); + + static void DebugTimeNonPctColspans(nsTableFrame& aFrame, + nsHTMLReflowState& aReflowState, + PRBool aStart); + nsReflowTimer* mTimer; #endif #endif diff --git a/mozilla/layout/tables/BasicTableLayoutStrategy.cpp b/mozilla/layout/tables/BasicTableLayoutStrategy.cpp index 99ed762986f..e913b9dffe7 100644 --- a/mozilla/layout/tables/BasicTableLayoutStrategy.cpp +++ b/mozilla/layout/tables/BasicTableLayoutStrategy.cpp @@ -484,6 +484,9 @@ BasicTableLayoutStrategy::ComputeNonPctColspanWidths(const nsHTMLReflowState& aR PRBool aConsiderPct, float aPixelToTwips) { +#ifdef DEBUG_TABLE_REFLOW_TIMING + nsTableFrame::DebugTimeNonPctColspans(*mTableFrame, (nsHTMLReflowState&)aReflowState, PR_TRUE); +#endif PRInt32 numCols = mTableFrame->GetColCount(); // zero out prior ADJ values @@ -549,6 +552,9 @@ BasicTableLayoutStrategy::ComputeNonPctColspanWidths(const nsHTMLReflowState& aR } } } +#ifdef DEBUG_TABLE_REFLOW_TIMING + nsTableFrame::DebugTimeNonPctColspans(*mTableFrame, (nsHTMLReflowState&)aReflowState, PR_FALSE); +#endif } #ifdef DEBUG @@ -843,6 +849,9 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre const nsHTMLReflowState& aReflowState, float aPixelToTwips) { +#ifdef DEBUG_TABLE_REFLOW_TIMING + nsTableFrame::DebugTimeNonPctCols(*mTableFrame, (nsHTMLReflowState&)aReflowState, PR_TRUE); +#endif if (gsDebugAssign) {printf("AssignNonPctColWidths en max=%d count=%d \n", aMaxWidth, gsDebugCount++); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);} PRBool rv = PR_FALSE; PRInt32 numRows = mTableFrame->GetRowCount(); @@ -1028,6 +1037,9 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre } if (gsDebugAssign) {printf("AssignNonPctColWidths ex\n"); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);} +#ifdef DEBUG_TABLE_REFLOW_TIMING + nsTableFrame::DebugTimeNonPctCols(*mTableFrame, (nsHTMLReflowState&)aReflowState, PR_FALSE); +#endif return rv; } @@ -1064,6 +1076,9 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(const nsHTMLReflowState aReflowS PRBool aTableIsAutoWidth, float aPixelToTwips) { +#ifdef DEBUG_TABLE_REFLOW_TIMING + nsTableFrame::DebugTimePctCols(*mTableFrame, (nsHTMLReflowState&)aReflowState, PR_TRUE); +#endif mTableFrame->SetHasCellSpanningPctCol(PR_FALSE); // this gets refigured below PRInt32 numRows = mTableFrame->GetRowCount(); PRInt32 numCols = mTableFrame->GetColCount(); // consider cols at end without orig cells @@ -1250,8 +1265,9 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(const nsHTMLReflowState aReflowS // check to see if a cell spans a percentage col. This will cause the MIN_ADJ, // FIX_ADJ, and DES_ADJ values to be recomputed - for (colX = 0; colX < numCols; colX++) { - for (rowX = 0; rowX < numRows; rowX++) { + PRBool done = PR_FALSE; + for (colX = 0; (colX < numCols) && !done; colX++) { + for (rowX = 0; (rowX < numRows) && !done; rowX++) { PRBool originates; PRInt32 colSpan; nsTableCellFrame* cellFrame = mTableFrame->GetCellInfoAt(rowX, colX, &originates, &colSpan); @@ -1259,13 +1275,14 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(const nsHTMLReflowState aReflowS continue; } // determine if the cell spans cols which have a pct value - for (PRInt32 spanX = 0; spanX < colSpan; spanX++) { + for (PRInt32 spanX = 0; (spanX < colSpan) && !done; spanX++) { nsTableColFrame* colFrame = mTableFrame->GetColFrame(colX + spanX); if (!colFrame) continue; if (colFrame->GetWidth(PCT) > 0) { mTableFrame->SetHasCellSpanningPctCol(PR_TRUE); // recompute the MIN_ADJ, FIX_ADJ, and DES_ADJ values ComputeNonPctColspanWidths(aReflowState, PR_TRUE, aPixelToTwips); + done = PR_TRUE; break; } } @@ -1362,6 +1379,9 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(const nsHTMLReflowState aReflowS ReduceOverSpecifiedPctCols(NSToCoordRound(((float)(colPctTotal - 100)) * 0.01f * (float)basis)); } +#ifdef DEBUG_TABLE_REFLOW_TIMING + nsTableFrame::DebugTimePctCols(*mTableFrame, (nsHTMLReflowState&)aReflowState, PR_FALSE); +#endif return basis; } diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index 1e6dea0f8bd..212af65d0f4 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -170,6 +170,12 @@ nsTableFrame::nsTableFrame() #endif #ifdef DEBUG_TABLE_REFLOW_TIMING mTimer = new nsReflowTimer(this); + nsReflowTimer* timer = new nsReflowTimer(this); + mTimer->mNextSibling = timer; + timer = new nsReflowTimer(this); + mTimer->mNextSibling->mNextSibling = timer; + timer = new nsReflowTimer(this); + mTimer->mNextSibling->mNextSibling->mNextSibling = timer; #endif } @@ -4625,13 +4631,16 @@ void PrettyUC(nscoord aSize, } } -void GetFrameTypeName(nsIAtom* aFrameType, - char* aName) +PRBool GetFrameTypeName(nsIAtom* aFrameType, + char* aName) { + PRBool isTable = PR_FALSE; if (nsLayoutAtoms::tableOuterFrame == aFrameType) strcpy(aName, "Tbl"); - else if (nsLayoutAtoms::tableFrame == aFrameType) + else if (nsLayoutAtoms::tableFrame == aFrameType) { strcpy(aName, "Tbl"); + isTable = PR_TRUE; + } else if (nsLayoutAtoms::tableRowGroupFrame == aFrameType) strcpy(aName, "RowG"); else if (nsLayoutAtoms::tableRowFrame == aFrameType) @@ -4642,6 +4651,8 @@ void GetFrameTypeName(nsIAtom* aFrameType, strcpy(aName, "Block"); else NS_ASSERTION(PR_FALSE, "invalid call to GetFrameTypeName"); + + return isTable; } #ifdef DEBUG_TABLE_REFLOW @@ -4750,6 +4761,15 @@ nsReflowTimer* GetFrameTimer(nsIFrame* aFrame, return nsnull; } +void DebugReflowPrintAuxTimer(char* aMes, + nsReflowTimer* aTimer) +{ + printf("%s %dms", aMes, aTimer->Elapsed()); + if (aTimer->mNumStarts > 1) { + printf(" times=%d", aTimer->mNumStarts); + } +} + void DebugReflowPrint(nsReflowTimer& aTimer, PRUint32 aLevel, PRBool aSummary) @@ -4762,12 +4782,18 @@ void DebugReflowPrint(nsReflowTimer& aTimer, // get the frame type char fName[128]; - GetFrameTypeName(aTimer.mFrameType, fName); + PRBool isTable = GetFrameTypeName(aTimer.mFrameType, fName); // print the timer printf("\n%s%s %dms %p", indentChar, fName, aTimer.Elapsed(), aTimer.mFrame); if (aSummary) { printf(" times=%d", aTimer.mNumStarts); + if (isTable) { + printf("\n%s", indentChar); + DebugReflowPrintAuxTimer("nonPctCols", aTimer.mNextSibling); + DebugReflowPrintAuxTimer(" nonPctColspans", aTimer.mNextSibling->mNextSibling); + DebugReflowPrintAuxTimer(" pctCols", aTimer.mNextSibling->mNextSibling->mNextSibling); + } } else { char avWidth[16]; @@ -4794,6 +4820,12 @@ void DebugReflowPrint(nsReflowTimer& aTimer, printf(" status=%d", aTimer.mStatus); } printf(" cnt=%d", aTimer.mCount); + if (isTable) { + printf("\n%s", indentChar); + DebugReflowPrintAuxTimer("nonPctCols", aTimer.mNextSibling); + DebugReflowPrintAuxTimer(" nonPctColspans", aTimer.mNextSibling->mNextSibling); + DebugReflowPrintAuxTimer(" pctCols", aTimer.mNextSibling->mNextSibling->mNextSibling); + } } // print the timer's children nsVoidArray& children = aTimer.mChildren; @@ -4824,16 +4856,15 @@ void nsTableFrame::DebugReflow(nsIFrame* aFrame, nsCOMPtr frameType = nsnull; aFrame->GetFrameType(getter_AddRefs(frameType)); nsReflowTimer* frameTimer = GetFrameTimer(aFrame, frameType.get()); - if (!frameTimer) { - NS_ASSERTION(PR_FALSE, "no frame timer"); - return; - } + if (!frameTimer) {NS_ASSERTION(PR_FALSE, "no frame timer");return;} if (!aMetrics) { // start // create the reflow timer nsReflowTimer* timer = new nsReflowTimer(aFrame); - if (!timer) { - NS_ASSERTION(PR_FALSE, "could not create timer"); - return; + // create the aux table timers if they don't exist + if ((nsLayoutAtoms::tableFrame == frameType.get()) && !timer->mNextSibling) { + timer->mNextSibling = new nsReflowTimer(aFrame); + timer->mNextSibling->mNextSibling = new nsReflowTimer(aFrame); + timer->mNextSibling->mNextSibling->mNextSibling = new nsReflowTimer(aFrame); } timer->mReason = aState.reason; timer->mAvailWidth = aState.availableWidth; @@ -4861,17 +4892,59 @@ void nsTableFrame::DebugReflow(nsIFrame* aFrame, ? aMetrics->mMaximumWidth : -1; timer->mStatus = aStatus; } - else { - NS_ASSERTION(PR_FALSE, "bad DebugTimeReflow"); - return; - } + else {NS_ASSERTION(PR_FALSE, "bad DebugTimeReflow");return;} + // stop the frame summary timer + frameTimer->Stop(); if (!parentTimer) { // print out all of the reflow timers DebugReflowPrint(*timer, 0, PR_FALSE); timer->Destroy(); } - // stop the frame summary timer - frameTimer->Stop(); + } +} + +void nsTableFrame::DebugTimeNonPctCols(nsTableFrame& aFrame, + nsHTMLReflowState& aState, + PRBool aStart) +{ + nsReflowTimer* timer = (nsReflowTimer*)aState.mDebugHook; + if (aStart) { + timer->mNextSibling->Start(); + aFrame.mTimer->mNextSibling->Start(); + } + else { + timer->mNextSibling->Stop(); + aFrame.mTimer->mNextSibling->Stop(); + } +} + +void nsTableFrame::DebugTimeNonPctColspans(nsTableFrame& aFrame, + nsHTMLReflowState& aState, + PRBool aStart) +{ + nsReflowTimer* timer = (nsReflowTimer*)aState.mDebugHook; + if (aStart) { + timer->mNextSibling->mNextSibling->Start(); + aFrame.mTimer->mNextSibling->mNextSibling->Start(); + } + else { + timer->mNextSibling->mNextSibling->Stop(); + aFrame.mTimer->mNextSibling->mNextSibling->Stop(); + } +} + +void nsTableFrame::DebugTimePctCols(nsTableFrame& aFrame, + nsHTMLReflowState& aState, + PRBool aStart) +{ + nsReflowTimer* timer = (nsReflowTimer*)aState.mDebugHook; + if (aStart) { + timer->mNextSibling->mNextSibling->mNextSibling->Start(); + aFrame.mTimer->mNextSibling->mNextSibling->mNextSibling->Start(); + } + else { + timer->mNextSibling->mNextSibling->mNextSibling->Stop(); + aFrame.mTimer->mNextSibling->mNextSibling->mNextSibling->Stop(); } } diff --git a/mozilla/layout/tables/nsTableFrame.h b/mozilla/layout/tables/nsTableFrame.h index 544600d02e3..618019c660c 100644 --- a/mozilla/layout/tables/nsTableFrame.h +++ b/mozilla/layout/tables/nsTableFrame.h @@ -55,6 +55,7 @@ class nsReflowTimer public: nsReflowTimer(nsIFrame* aFrame) { mFrame = aFrame; + mNextSibling = nsnull; aFrame->GetFrameType(&mFrameType); Reset(); } @@ -65,6 +66,11 @@ public: ((nsReflowTimer*)mChildren.ElementAt(childX))->Destroy(); } NS_IF_RELEASE(mFrameType); + if (mNextSibling) { // table frames have 3 auxillary timers + delete mNextSibling->mNextSibling->mNextSibling; + delete mNextSibling->mNextSibling; + delete mNextSibling; + } delete this; } @@ -119,6 +125,7 @@ public: nscoord mDesiredWidth; nscoord mDesiredHeight; nsReflowStatus mStatus; + nsReflowTimer* mNextSibling; private: ~nsReflowTimer() {} @@ -943,9 +950,22 @@ public: nsHTMLReflowState& aReflowState, nsHTMLReflowMetrics* aMetrics = nsnull, nsReflowStatus aStatus = NS_FRAME_COMPLETE); + #ifdef DEBUG_TABLE_REFLOW_TIMING static void DebugReflowDone(nsIFrame* aFrame); + static void DebugTimePctCols(nsTableFrame& aFrame, + nsHTMLReflowState& aReflowState, + PRBool aStart); + + static void DebugTimeNonPctCols(nsTableFrame& aFrame, + nsHTMLReflowState& aReflowState, + PRBool aStart); + + static void DebugTimeNonPctColspans(nsTableFrame& aFrame, + nsHTMLReflowState& aReflowState, + PRBool aStart); + nsReflowTimer* mTimer; #endif #endif