From 771cfdf22657bbb35a6fe104ddf46de9f7fa259c Mon Sep 17 00:00:00 2001 From: "buster%netscape.com" Date: Fri, 23 Oct 1998 03:23:29 +0000 Subject: [PATCH] minor bug fixes --- .../table/src/BasicTableLayoutStrategy.cpp | 6 +++--- layout/html/table/src/nsTableFrame.cpp | 19 ++++++++++++++----- layout/tables/BasicTableLayoutStrategy.cpp | 6 +++--- layout/tables/nsTableFrame.cpp | 19 ++++++++++++++----- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/layout/html/table/src/BasicTableLayoutStrategy.cpp b/layout/html/table/src/BasicTableLayoutStrategy.cpp index bd5fc2aacb9f..8fba8c25df7d 100644 --- a/layout/html/table/src/BasicTableLayoutStrategy.cpp +++ b/layout/html/table/src/BasicTableLayoutStrategy.cpp @@ -673,7 +673,7 @@ PRBool BasicTableLayoutStrategy::AssignPreliminaryColumnWidths() // clean up if (nsnull!=spanList) { - NS_ASSERTION(0==spanList->Count(), "space leak, span list not empty"); + if (gsDebug) printf("BTLS::APCW...space leak, span list not empty"); delete spanList; } if (nsnull!=colSpanList) @@ -1542,7 +1542,7 @@ PRBool BasicTableLayoutStrategy::BalanceColumnsTableFits(const nsHTMLReflowState // cleanup if (nsnull!=spanList) { - NS_ASSERTION(0==spanList->Count(), "space leak, span list not empty"); + if (gsDebug) printf("BTLS::BCTFits...space leak, span list not empty"); delete spanList; } return result; @@ -2091,7 +2091,7 @@ PRBool BasicTableLayoutStrategy::BalanceColumnsConstrained( const nsHTMLReflowSt // clean up if (nsnull!=spanList) { - NS_ASSERTION(0==spanList->Count(), "space leak, span list not empty"); + if (gsDebug) printf("BTLS::BCTConstrained...space leak, span list not empty"); delete spanList; } diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp index 6697ab4c6ba8..a5ebacaa0e78 100644 --- a/layout/html/table/src/nsTableFrame.cpp +++ b/layout/html/table/src/nsTableFrame.cpp @@ -171,7 +171,7 @@ private: ColumnInfoCache::ColumnInfoCache(PRInt32 aNumColumns) { - if (PR_TRUE==gsDebug) printf("CIC constructor: aNumColumns %d\n", aNumColumns); + if (PR_TRUE==gsDebug || PR_TRUE==gsDebugIR) printf("CIC constructor: aNumColumns %d\n", aNumColumns); mNumColumns = aNumColumns; for (PRInt32 i=0; iInitialize(aDesiredSize.maxElementSize, mCellMap->GetColCount()); + mTableLayoutStrategy->Initialize(aDesiredSize.maxElementSize, GetColCount()); mColumnWidthsValid=PR_TRUE; //so we don't do this a second time below } } @@ -2006,6 +2007,7 @@ NS_METHOD nsTableFrame::IR_ColGroupInserted(nsIPresContext& aPresContext, nsTableColGroupFrame * aInsertedFrame, PRBool aReplace) { + if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_ColGroupInserted for frame %p\n", aInsertedFrame); nsresult rv=NS_OK; PRBool adjustStartingColIndex=PR_FALSE; PRInt32 startingColIndex=0; @@ -2070,6 +2072,7 @@ NS_METHOD nsTableFrame::IR_ColGroupAppended(nsIPresContext& aPresContext, nsReflowStatus& aStatus, nsTableColGroupFrame * aAppendedFrame) { + if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_ColGroupAppended for frame %p\n", aAppendedFrame); nsresult rv=NS_OK; PRInt32 startingColIndex=0; nsIFrame *childFrame=mFirstChild; @@ -2152,6 +2155,7 @@ NS_METHOD nsTableFrame::IR_ColGroupRemoved(nsIPresContext& aPresContext, nsReflowStatus& aStatus, nsTableColGroupFrame * aDeletedFrame) { + if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_ColGroupRemoved for frame %p\n", aDeletedFrame); nsresult rv=NS_OK; PRBool adjustStartingColIndex=PR_FALSE; PRInt32 startingColIndex=0; @@ -2199,6 +2203,7 @@ NS_METHOD nsTableFrame::IR_RowGroupInserted(nsIPresContext& aPresContext, nsTableRowGroupFrame * aInsertedFrame, PRBool aReplace) { + if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_RowGroupInserted for frame %p\n", aInsertedFrame); nsresult rv = AddFrame(aReflowState.reflowState, aInsertedFrame); if (NS_FAILED(rv)) return rv; @@ -2222,6 +2227,7 @@ NS_METHOD nsTableFrame::IR_RowGroupAppended(nsIPresContext& aPresContext, nsReflowStatus& aStatus, nsTableRowGroupFrame * aAppendedFrame) { + if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_RowGroupAppended for frame %p\n", aAppendedFrame); // hook aAppendedFrame into the child list nsresult rv = AddFrame(aReflowState.reflowState, aAppendedFrame); if (NS_FAILED(rv)) @@ -2239,7 +2245,9 @@ NS_METHOD nsTableFrame::IR_RowGroupAppended(nsIPresContext& aPresContext, if (NS_FAILED(rv)) return rv; - EnsureColumns(aPresContext); + // if we've added any columns, we need to rebuild the column cache + // XXX: it would be nice to have a mechanism to just extend the column cache, rather than rebuild it completely + InvalidateColumnCache(); // if any column widths have to change due to this, rebalance column widths //XXX need to calculate this, but for now just do it @@ -2254,6 +2262,7 @@ NS_METHOD nsTableFrame::IR_RowGroupRemoved(nsIPresContext& aPresContext, nsReflowStatus& aStatus, nsTableRowGroupFrame * aDeletedFrame) { + if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_RowGroupRemoved for frame %p\n", aDeletedFrame); nsresult rv = RemoveFrame(aDeletedFrame); InvalidateCellMap(); InvalidateColumnCache(); @@ -2767,7 +2776,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext& aPresContext, mTableLayoutStrategy = new FixedTableLayoutStrategy(this); else mTableLayoutStrategy = new BasicTableLayoutStrategy(this); - mTableLayoutStrategy->Initialize(aMaxElementSize, mCellMap->GetColCount()); + mTableLayoutStrategy->Initialize(aMaxElementSize, GetColCount()); mColumnWidthsValid=PR_TRUE; } mTableLayoutStrategy->BalanceColumnWidths(mStyleContext, aReflowState, maxWidth); diff --git a/layout/tables/BasicTableLayoutStrategy.cpp b/layout/tables/BasicTableLayoutStrategy.cpp index bd5fc2aacb9f..8fba8c25df7d 100644 --- a/layout/tables/BasicTableLayoutStrategy.cpp +++ b/layout/tables/BasicTableLayoutStrategy.cpp @@ -673,7 +673,7 @@ PRBool BasicTableLayoutStrategy::AssignPreliminaryColumnWidths() // clean up if (nsnull!=spanList) { - NS_ASSERTION(0==spanList->Count(), "space leak, span list not empty"); + if (gsDebug) printf("BTLS::APCW...space leak, span list not empty"); delete spanList; } if (nsnull!=colSpanList) @@ -1542,7 +1542,7 @@ PRBool BasicTableLayoutStrategy::BalanceColumnsTableFits(const nsHTMLReflowState // cleanup if (nsnull!=spanList) { - NS_ASSERTION(0==spanList->Count(), "space leak, span list not empty"); + if (gsDebug) printf("BTLS::BCTFits...space leak, span list not empty"); delete spanList; } return result; @@ -2091,7 +2091,7 @@ PRBool BasicTableLayoutStrategy::BalanceColumnsConstrained( const nsHTMLReflowSt // clean up if (nsnull!=spanList) { - NS_ASSERTION(0==spanList->Count(), "space leak, span list not empty"); + if (gsDebug) printf("BTLS::BCTConstrained...space leak, span list not empty"); delete spanList; } diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 6697ab4c6ba8..a5ebacaa0e78 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -171,7 +171,7 @@ private: ColumnInfoCache::ColumnInfoCache(PRInt32 aNumColumns) { - if (PR_TRUE==gsDebug) printf("CIC constructor: aNumColumns %d\n", aNumColumns); + if (PR_TRUE==gsDebug || PR_TRUE==gsDebugIR) printf("CIC constructor: aNumColumns %d\n", aNumColumns); mNumColumns = aNumColumns; for (PRInt32 i=0; iInitialize(aDesiredSize.maxElementSize, mCellMap->GetColCount()); + mTableLayoutStrategy->Initialize(aDesiredSize.maxElementSize, GetColCount()); mColumnWidthsValid=PR_TRUE; //so we don't do this a second time below } } @@ -2006,6 +2007,7 @@ NS_METHOD nsTableFrame::IR_ColGroupInserted(nsIPresContext& aPresContext, nsTableColGroupFrame * aInsertedFrame, PRBool aReplace) { + if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_ColGroupInserted for frame %p\n", aInsertedFrame); nsresult rv=NS_OK; PRBool adjustStartingColIndex=PR_FALSE; PRInt32 startingColIndex=0; @@ -2070,6 +2072,7 @@ NS_METHOD nsTableFrame::IR_ColGroupAppended(nsIPresContext& aPresContext, nsReflowStatus& aStatus, nsTableColGroupFrame * aAppendedFrame) { + if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_ColGroupAppended for frame %p\n", aAppendedFrame); nsresult rv=NS_OK; PRInt32 startingColIndex=0; nsIFrame *childFrame=mFirstChild; @@ -2152,6 +2155,7 @@ NS_METHOD nsTableFrame::IR_ColGroupRemoved(nsIPresContext& aPresContext, nsReflowStatus& aStatus, nsTableColGroupFrame * aDeletedFrame) { + if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_ColGroupRemoved for frame %p\n", aDeletedFrame); nsresult rv=NS_OK; PRBool adjustStartingColIndex=PR_FALSE; PRInt32 startingColIndex=0; @@ -2199,6 +2203,7 @@ NS_METHOD nsTableFrame::IR_RowGroupInserted(nsIPresContext& aPresContext, nsTableRowGroupFrame * aInsertedFrame, PRBool aReplace) { + if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_RowGroupInserted for frame %p\n", aInsertedFrame); nsresult rv = AddFrame(aReflowState.reflowState, aInsertedFrame); if (NS_FAILED(rv)) return rv; @@ -2222,6 +2227,7 @@ NS_METHOD nsTableFrame::IR_RowGroupAppended(nsIPresContext& aPresContext, nsReflowStatus& aStatus, nsTableRowGroupFrame * aAppendedFrame) { + if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_RowGroupAppended for frame %p\n", aAppendedFrame); // hook aAppendedFrame into the child list nsresult rv = AddFrame(aReflowState.reflowState, aAppendedFrame); if (NS_FAILED(rv)) @@ -2239,7 +2245,9 @@ NS_METHOD nsTableFrame::IR_RowGroupAppended(nsIPresContext& aPresContext, if (NS_FAILED(rv)) return rv; - EnsureColumns(aPresContext); + // if we've added any columns, we need to rebuild the column cache + // XXX: it would be nice to have a mechanism to just extend the column cache, rather than rebuild it completely + InvalidateColumnCache(); // if any column widths have to change due to this, rebalance column widths //XXX need to calculate this, but for now just do it @@ -2254,6 +2262,7 @@ NS_METHOD nsTableFrame::IR_RowGroupRemoved(nsIPresContext& aPresContext, nsReflowStatus& aStatus, nsTableRowGroupFrame * aDeletedFrame) { + if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_RowGroupRemoved for frame %p\n", aDeletedFrame); nsresult rv = RemoveFrame(aDeletedFrame); InvalidateCellMap(); InvalidateColumnCache(); @@ -2767,7 +2776,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext& aPresContext, mTableLayoutStrategy = new FixedTableLayoutStrategy(this); else mTableLayoutStrategy = new BasicTableLayoutStrategy(this); - mTableLayoutStrategy->Initialize(aMaxElementSize, mCellMap->GetColCount()); + mTableLayoutStrategy->Initialize(aMaxElementSize, GetColCount()); mColumnWidthsValid=PR_TRUE; } mTableLayoutStrategy->BalanceColumnWidths(mStyleContext, aReflowState, maxWidth);