diff --git a/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp b/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp index 424082198f1..bd5fc2aacb9 100644 --- a/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp +++ b/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp @@ -31,10 +31,8 @@ NS_DEF_PTR(nsIStyleContext); #ifdef NS_DEBUG static PRBool gsDebug = PR_FALSE; -static PRBool gsDebugCLD = PR_FALSE; #else static const PRBool gsDebug = PR_FALSE; -static const PRBool gsDebugCLD = PR_FALSE; #endif const nscoord gBigSpace = 100000; diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index 53638332d64..136fbedb7cd 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -1041,6 +1041,7 @@ void nsTableFrame::DumpCellMap () { PRInt32 rowCount = mCellMap->GetRowCount(); PRInt32 colCount = mCellMap->GetColCount(); + printf("rowCount=%d, colCount=%d\n", rowCount, colCount); for (PRInt32 rowIndex = 0; rowIndex < rowCount; rowIndex++) { if (gsDebug==PR_TRUE) @@ -1591,6 +1592,11 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext& aPresContext, delete mCellMap; mCellMap = new nsCellMap(0,0); ReBuildCellMap(); + if (PR_TRUE==gsDebugIR) + { + DumpCellMap(); + printf("tableFrame thinks colCount is %d\n", mEffectiveColCount); + } needsRecalc=PR_TRUE; } if (PR_FALSE==IsFirstPassValid()) diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp index 0580b114191..e065eb8b884 100644 --- a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp @@ -111,6 +111,7 @@ NS_IMETHODIMP nsTableOuterFrame::Init(nsIPresContext& aPresContext, nsIFrame* aC // Set our internal member data mInnerTableFrame = mFirstChild; + //XXX this should go through the child list looking for a displaytype==caption if (2 == LengthOf(mFirstChild)) { mFirstChild->GetNextSibling(mCaptionFrame); } @@ -289,7 +290,20 @@ nsresult nsTableOuterFrame::IR_TargetIsChild(nsIPresContext& aPresContext else if (aNextFrame==mCaptionFrame) rv = IR_TargetIsCaptionFrame(aPresContext, aDesiredSize, aReflowState, aStatus); else - rv = NS_ERROR_ILLEGAL_VALUE; + { + const nsStyleDisplay* nextDisplay; + aNextFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)nextDisplay); + if (NS_STYLE_DISPLAY_TABLE_HEADER_GROUP==nextDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP==nextDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_ROW_GROUP ==nextDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP==nextDisplay->mDisplay) + rv = IR_TargetIsInnerTableFrame(aPresContext, aDesiredSize, aReflowState, aStatus); + else + { + NS_ASSERTION(PR_FALSE, "illegal next frame in incremental reflow."); + rv = NS_ERROR_ILLEGAL_VALUE; + } + } return rv; } @@ -402,6 +416,7 @@ nsresult nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext& aPres return rv; } +// IR_TargetIsMe is free to foward the request to the inner table frame nsresult nsTableOuterFrame::IR_TargetIsMe(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, OuterTableReflowState& aReflowState, diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.cpp b/mozilla/layout/html/table/src/nsTableRowFrame.cpp index a2ca5d7c9d8..1348f2dda84 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowFrame.cpp @@ -107,6 +107,7 @@ nsTableRowFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList) NS_IMETHODIMP nsTableRowFrame::InitChildren(PRInt32 aRowIndex) { + if (gsDebug) printf("Row InitChildren: begin\n"); nsTableFrame* table = nsnull; nsresult result=NS_OK; @@ -114,6 +115,7 @@ nsTableRowFrame::InitChildren(PRInt32 aRowIndex) // for now, we remember globally whether we've added all or none if (PR_FALSE==mInitializedChildren) { + if (gsDebug) printf("Row InitChildren: mInitializedChildren=PR_FALSE\n"); result = nsTableFrame::GetTableFrame(this, table); if ((NS_OK==result) && (table != nsnull)) { @@ -124,6 +126,7 @@ nsTableRowFrame::InitChildren(PRInt32 aRowIndex) else rowIndex = aRowIndex; SetRowIndex(rowIndex); + if (gsDebug) printf("Row InitChildren: set row index to %d\n", rowIndex); PRInt32 colIndex = 0; for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; kidFrame->GetNextSibling(kidFrame)) { @@ -133,6 +136,7 @@ nsTableRowFrame::InitChildren(PRInt32 aRowIndex) { // what column does this cell belong to? colIndex = table->GetNextAvailColIndex(mRowIndex, colIndex); + if (gsDebug) printf("Row InitChildren: cell given colIndex %d\n", colIndex); /* for style context optimization, set the content's column index if possible. * this can only be done if we really have an nsTableCell. * other tags mapped to table cell display won't benefit from this optimization @@ -155,11 +159,13 @@ nsTableRowFrame::InitChildren(PRInt32 aRowIndex) ((nsTableCellFrame *)kidFrame)->InitCellFrame(colIndex); if (gsDebug) printf("%p : set cell frame %p to col index = %d\n", this, kidFrame, colIndex); // add the cell frame to the table's cell map + if (gsDebug) printf("Row InitChildren: calling AddCellToTable...\n"); table->AddCellToTable(this, (nsTableCellFrame *)kidFrame, kidFrame == mFirstChild); } } } } + if (gsDebug) printf("Row InitChildren: end\n"); return NS_OK; } @@ -170,6 +176,7 @@ NS_METHOD nsTableRowFrame::DidReflow(nsIPresContext& aPresContext, nsDidReflowStatus aStatus) { + if (gsDebug) printf("Row DidReflow: begin\n"); if (NS_FRAME_REFLOW_FINISHED == aStatus) { // Resize and re-align the cell frames based on our row height nscoord cellHeight = mRect.height - mCellMaxTopMargin - mCellMaxBottomMargin; @@ -183,13 +190,14 @@ nsTableRowFrame::DidReflow(nsIPresContext& aPresContext, if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay) { PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(mRowIndex, (nsTableCellFrame *)cellFrame); + if (gsDebug) printf("Row DidReflow: cellFrame %p\n", cellFrame); if (1==rowSpan) { // resize the cell's height nsSize cellFrameSize; cellFrame->GetSize(cellFrameSize); cellFrame->SizeTo(cellFrameSize.width, cellHeight); - + if (gsDebug) printf("Row DidReflow: cellFrame %p given height %d\n", cellFrame, cellHeight); // realign cell content based on the new height ((nsTableCellFrame *)cellFrame)->VerticallyAlignChild(&aPresContext); } @@ -201,10 +209,12 @@ nsTableRowFrame::DidReflow(nsIPresContext& aPresContext, // Let our base class do the usual work return nsContainerFrame::DidReflow(aPresContext, aStatus); + if (gsDebug) printf("Row DidReflow: end\n"); } void nsTableRowFrame::ResetMaxChildHeight() { + if (gsDebug) printf("Row ResetMaxChildHeight\n"); mTallestCell=0; mCellMaxTopMargin=0; mCellMaxBottomMargin=0; @@ -212,6 +222,7 @@ void nsTableRowFrame::ResetMaxChildHeight() void nsTableRowFrame::SetMaxChildHeight(nscoord aChildHeight, nscoord aTopMargin, nscoord aBottomMargin) { + if (gsDebug) printf("Row ResetMaxChildHeight to %d\n", aChildHeight); if (mTallestCellInvalidateCellMap(); tableFrame->InvalidateColumnCache(); @@ -1001,6 +1017,12 @@ NS_METHOD nsTableRowFrame::IR_CellAppended(nsIPresContext& aPresContext, return rv; } + // set row state + GetMinRowSpan(tableFrame); + FixMinCellHeight(tableFrame); + + // set table state + tableFrame->InvalidateCellMap(); tableFrame->InvalidateColumnCache(); @@ -1055,10 +1077,17 @@ NS_METHOD nsTableRowFrame::IR_CellRemoved(nsIPresContext& aPresContext, nsresult rv = RemoveFrame((nsIFrame*)aDeletedFrame); if (NS_SUCCEEDED(rv)) { + ResetMaxChildHeight(); nsTableFrame *tableFrame=nsnull; rv = nsTableFrame::GetTableFrame(this, tableFrame); if (NS_FAILED(rv) || nsnull==tableFrame) return rv; + + // set row state + GetMinRowSpan(tableFrame); + FixMinCellHeight(tableFrame); + + // set table state tableFrame->InvalidateCellMap(); tableFrame->InvalidateColumnCache(); diff --git a/mozilla/layout/tables/BasicTableLayoutStrategy.cpp b/mozilla/layout/tables/BasicTableLayoutStrategy.cpp index 424082198f1..bd5fc2aacb9 100644 --- a/mozilla/layout/tables/BasicTableLayoutStrategy.cpp +++ b/mozilla/layout/tables/BasicTableLayoutStrategy.cpp @@ -31,10 +31,8 @@ NS_DEF_PTR(nsIStyleContext); #ifdef NS_DEBUG static PRBool gsDebug = PR_FALSE; -static PRBool gsDebugCLD = PR_FALSE; #else static const PRBool gsDebug = PR_FALSE; -static const PRBool gsDebugCLD = PR_FALSE; #endif const nscoord gBigSpace = 100000; diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index 53638332d64..136fbedb7cd 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -1041,6 +1041,7 @@ void nsTableFrame::DumpCellMap () { PRInt32 rowCount = mCellMap->GetRowCount(); PRInt32 colCount = mCellMap->GetColCount(); + printf("rowCount=%d, colCount=%d\n", rowCount, colCount); for (PRInt32 rowIndex = 0; rowIndex < rowCount; rowIndex++) { if (gsDebug==PR_TRUE) @@ -1591,6 +1592,11 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext& aPresContext, delete mCellMap; mCellMap = new nsCellMap(0,0); ReBuildCellMap(); + if (PR_TRUE==gsDebugIR) + { + DumpCellMap(); + printf("tableFrame thinks colCount is %d\n", mEffectiveColCount); + } needsRecalc=PR_TRUE; } if (PR_FALSE==IsFirstPassValid()) diff --git a/mozilla/layout/tables/nsTableOuterFrame.cpp b/mozilla/layout/tables/nsTableOuterFrame.cpp index 0580b114191..e065eb8b884 100644 --- a/mozilla/layout/tables/nsTableOuterFrame.cpp +++ b/mozilla/layout/tables/nsTableOuterFrame.cpp @@ -111,6 +111,7 @@ NS_IMETHODIMP nsTableOuterFrame::Init(nsIPresContext& aPresContext, nsIFrame* aC // Set our internal member data mInnerTableFrame = mFirstChild; + //XXX this should go through the child list looking for a displaytype==caption if (2 == LengthOf(mFirstChild)) { mFirstChild->GetNextSibling(mCaptionFrame); } @@ -289,7 +290,20 @@ nsresult nsTableOuterFrame::IR_TargetIsChild(nsIPresContext& aPresContext else if (aNextFrame==mCaptionFrame) rv = IR_TargetIsCaptionFrame(aPresContext, aDesiredSize, aReflowState, aStatus); else - rv = NS_ERROR_ILLEGAL_VALUE; + { + const nsStyleDisplay* nextDisplay; + aNextFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)nextDisplay); + if (NS_STYLE_DISPLAY_TABLE_HEADER_GROUP==nextDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP==nextDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_ROW_GROUP ==nextDisplay->mDisplay || + NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP==nextDisplay->mDisplay) + rv = IR_TargetIsInnerTableFrame(aPresContext, aDesiredSize, aReflowState, aStatus); + else + { + NS_ASSERTION(PR_FALSE, "illegal next frame in incremental reflow."); + rv = NS_ERROR_ILLEGAL_VALUE; + } + } return rv; } @@ -402,6 +416,7 @@ nsresult nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext& aPres return rv; } +// IR_TargetIsMe is free to foward the request to the inner table frame nsresult nsTableOuterFrame::IR_TargetIsMe(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, OuterTableReflowState& aReflowState, diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index a2ca5d7c9d8..1348f2dda84 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -107,6 +107,7 @@ nsTableRowFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList) NS_IMETHODIMP nsTableRowFrame::InitChildren(PRInt32 aRowIndex) { + if (gsDebug) printf("Row InitChildren: begin\n"); nsTableFrame* table = nsnull; nsresult result=NS_OK; @@ -114,6 +115,7 @@ nsTableRowFrame::InitChildren(PRInt32 aRowIndex) // for now, we remember globally whether we've added all or none if (PR_FALSE==mInitializedChildren) { + if (gsDebug) printf("Row InitChildren: mInitializedChildren=PR_FALSE\n"); result = nsTableFrame::GetTableFrame(this, table); if ((NS_OK==result) && (table != nsnull)) { @@ -124,6 +126,7 @@ nsTableRowFrame::InitChildren(PRInt32 aRowIndex) else rowIndex = aRowIndex; SetRowIndex(rowIndex); + if (gsDebug) printf("Row InitChildren: set row index to %d\n", rowIndex); PRInt32 colIndex = 0; for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; kidFrame->GetNextSibling(kidFrame)) { @@ -133,6 +136,7 @@ nsTableRowFrame::InitChildren(PRInt32 aRowIndex) { // what column does this cell belong to? colIndex = table->GetNextAvailColIndex(mRowIndex, colIndex); + if (gsDebug) printf("Row InitChildren: cell given colIndex %d\n", colIndex); /* for style context optimization, set the content's column index if possible. * this can only be done if we really have an nsTableCell. * other tags mapped to table cell display won't benefit from this optimization @@ -155,11 +159,13 @@ nsTableRowFrame::InitChildren(PRInt32 aRowIndex) ((nsTableCellFrame *)kidFrame)->InitCellFrame(colIndex); if (gsDebug) printf("%p : set cell frame %p to col index = %d\n", this, kidFrame, colIndex); // add the cell frame to the table's cell map + if (gsDebug) printf("Row InitChildren: calling AddCellToTable...\n"); table->AddCellToTable(this, (nsTableCellFrame *)kidFrame, kidFrame == mFirstChild); } } } } + if (gsDebug) printf("Row InitChildren: end\n"); return NS_OK; } @@ -170,6 +176,7 @@ NS_METHOD nsTableRowFrame::DidReflow(nsIPresContext& aPresContext, nsDidReflowStatus aStatus) { + if (gsDebug) printf("Row DidReflow: begin\n"); if (NS_FRAME_REFLOW_FINISHED == aStatus) { // Resize and re-align the cell frames based on our row height nscoord cellHeight = mRect.height - mCellMaxTopMargin - mCellMaxBottomMargin; @@ -183,13 +190,14 @@ nsTableRowFrame::DidReflow(nsIPresContext& aPresContext, if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay) { PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(mRowIndex, (nsTableCellFrame *)cellFrame); + if (gsDebug) printf("Row DidReflow: cellFrame %p\n", cellFrame); if (1==rowSpan) { // resize the cell's height nsSize cellFrameSize; cellFrame->GetSize(cellFrameSize); cellFrame->SizeTo(cellFrameSize.width, cellHeight); - + if (gsDebug) printf("Row DidReflow: cellFrame %p given height %d\n", cellFrame, cellHeight); // realign cell content based on the new height ((nsTableCellFrame *)cellFrame)->VerticallyAlignChild(&aPresContext); } @@ -201,10 +209,12 @@ nsTableRowFrame::DidReflow(nsIPresContext& aPresContext, // Let our base class do the usual work return nsContainerFrame::DidReflow(aPresContext, aStatus); + if (gsDebug) printf("Row DidReflow: end\n"); } void nsTableRowFrame::ResetMaxChildHeight() { + if (gsDebug) printf("Row ResetMaxChildHeight\n"); mTallestCell=0; mCellMaxTopMargin=0; mCellMaxBottomMargin=0; @@ -212,6 +222,7 @@ void nsTableRowFrame::ResetMaxChildHeight() void nsTableRowFrame::SetMaxChildHeight(nscoord aChildHeight, nscoord aTopMargin, nscoord aBottomMargin) { + if (gsDebug) printf("Row ResetMaxChildHeight to %d\n", aChildHeight); if (mTallestCellInvalidateCellMap(); tableFrame->InvalidateColumnCache(); @@ -1001,6 +1017,12 @@ NS_METHOD nsTableRowFrame::IR_CellAppended(nsIPresContext& aPresContext, return rv; } + // set row state + GetMinRowSpan(tableFrame); + FixMinCellHeight(tableFrame); + + // set table state + tableFrame->InvalidateCellMap(); tableFrame->InvalidateColumnCache(); @@ -1055,10 +1077,17 @@ NS_METHOD nsTableRowFrame::IR_CellRemoved(nsIPresContext& aPresContext, nsresult rv = RemoveFrame((nsIFrame*)aDeletedFrame); if (NS_SUCCEEDED(rv)) { + ResetMaxChildHeight(); nsTableFrame *tableFrame=nsnull; rv = nsTableFrame::GetTableFrame(this, tableFrame); if (NS_FAILED(rv) || nsnull==tableFrame) return rv; + + // set row state + GetMinRowSpan(tableFrame); + FixMinCellHeight(tableFrame); + + // set table state tableFrame->InvalidateCellMap(); tableFrame->InvalidateColumnCache();