diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp index ce5ec32b3de4..df7b6ca07b18 100644 --- a/layout/html/table/src/nsTableFrame.cpp +++ b/layout/html/table/src/nsTableFrame.cpp @@ -437,8 +437,8 @@ nsTableFrame::SetInitialChildList(nsIPresContext& aPresContext, prevColGroupChild->SetNextSibling(nsnull); if (NS_SUCCEEDED(rv)) { - //mCellMap->Dump(); - EnsureColumns(aPresContext); + PRBool createdColFrames; + EnsureColumns(aPresContext, createdColFrames); } return rv; @@ -633,10 +633,13 @@ PRInt32 nsTableFrame::GetEffectiveCOLSAttribute() * if the cell map says there are more columns than this, * add extra implicit columns to the content tree. */ -void nsTableFrame::EnsureColumns(nsIPresContext& aPresContext) +void nsTableFrame::EnsureColumns(nsIPresContext& aPresContext, + PRBool& aCreatedColFrames) { if (PR_TRUE==gsDebug) printf("TIF EnsureColumns\n"); NS_PRECONDITION(nsnull!=mCellMap, "bad state: null cellmap"); + + aCreatedColFrames = PR_FALSE; // initialize OUT parameter if (nsnull == mCellMap) return; // no info yet, so nothing useful to do @@ -715,6 +718,7 @@ void nsTableFrame::EnsureColumns(nsIPresContext& aPresContext) lastColGroupStyle, PR_TRUE, &colStyleContext); // colStyleContext: REFCNT++ + aCreatedColFrames = PR_TRUE; // remember that we're creating implicit col frames NS_NewTableColFrame(&colFrame); colFrame->Init(aPresContext, lastColGroupElement, lastColGroupFrame, colStyleContext, nsnull); @@ -4386,8 +4390,9 @@ void nsTableFrame::BuildColumnCache( nsIPresContext& aPresContext, NS_ASSERTION(nsnull!=mCellMap, "never ever call me until the cell map is built!"); PRInt32 colIndex=0; const nsStyleTable* tableStyle; + PRBool createdColFrames; GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle); - EnsureColumns(aPresContext); + EnsureColumns(aPresContext, createdColFrames); if (nsnull!=mColCache) { if (PR_TRUE==gsDebugIR) printf("TIF BCC: clearing column cache and cell map column frame cache.\n"); diff --git a/layout/html/table/src/nsTableFrame.h b/layout/html/table/src/nsTableFrame.h index c6adfbf1d91d..0faa52e29be3 100644 --- a/layout/html/table/src/nsTableFrame.h +++ b/layout/html/table/src/nsTableFrame.h @@ -722,6 +722,15 @@ public: */ virtual void InvalidateCellMap(); + /** sum the columns represented by all nsTableColGroup objects. + * if the cell map says there are more columns than this, + * add extra implicit columns to the content tree. + * + * returns whether any implicit column frames were created + */ + virtual void EnsureColumns (nsIPresContext& aPresContext, + PRBool& aCreatedColFrames); + protected: /** iterates all child frames and creates a new cell map */ NS_IMETHOD ReBuildCellMap(); @@ -735,12 +744,6 @@ protected: void ListColumnLayoutData(FILE* out, PRInt32 aIndent); #endif - /** sum the columns represented by all nsTableColGroup objects. - * if the cell map says there are more columns than this, - * add extra implicit columns to the content tree. - */ - virtual void EnsureColumns (nsIPresContext& aPresContext); - virtual void BuildColumnCache(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, diff --git a/layout/html/table/src/nsTableRowFrame.cpp b/layout/html/table/src/nsTableRowFrame.cpp index d621fe541236..3abd40de0e15 100644 --- a/layout/html/table/src/nsTableRowFrame.cpp +++ b/layout/html/table/src/nsTableRowFrame.cpp @@ -177,6 +177,16 @@ nsTableRowFrame::AppendFrames(nsIPresContext& aPresContext, } } + // See if any implicit column frames need to be created as a result of + // adding the new rows + PRBool createdColFrames; + tableFrame->EnsureColumns(aPresContext, createdColFrames); + if (createdColFrames) { + // We need to rebuild the column cache + // XXX It would be nice if this could be done incrementally + tableFrame->InvalidateColumnCache(); + } + // Reflow the new frames. They're already marked dirty, so generate a reflow // command that tells us to reflow our dirty child frames nsIReflowCommand* reflowCmd; @@ -1265,7 +1275,6 @@ NS_METHOD nsTableRowFrame::IR_TargetIsMe(nsIPresContext& aPresContext, // If any column widths have to change due to this, rebalance column widths. // XXX need to calculate this, but for now just do it aReflowState.tableFrame->InvalidateColumnWidths(); - aReflowState.tableFrame->InvalidateColumnCache(); break; } diff --git a/layout/html/table/src/nsTableRowGroupFrame.cpp b/layout/html/table/src/nsTableRowGroupFrame.cpp index 5f9548e08696..5660cd0495e5 100644 --- a/layout/html/table/src/nsTableRowGroupFrame.cpp +++ b/layout/html/table/src/nsTableRowGroupFrame.cpp @@ -1170,7 +1170,7 @@ nsTableRowGroupFrame::AppendFrames(nsIPresContext& aPresContext, nsIFrame* aFrameList) { // Get the table frame - nsTableFrame* tableFrame = nsnull; + nsTableFrame* tableFrame; nsTableFrame::GetTableFrame(this, tableFrame); // Append the frames @@ -1188,6 +1188,16 @@ nsTableRowGroupFrame::AppendFrames(nsIPresContext& aPresContext, DidAppendRow((nsTableRowFrame*)rowFrame); } + // See if any implicit column frames need to be created as a result of + // adding the new rows + PRBool createdColFrames; + tableFrame->EnsureColumns(aPresContext, createdColFrames); + if (createdColFrames) { + // We need to rebuild the column cache + // XXX It would be nice if this could be done incrementally + tableFrame->InvalidateColumnCache(); + } + // Reflow the new frames. They're already marked dirty, so generate a reflow // command that tells us to reflow our dirty child frames nsIReflowCommand* reflowCmd; diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index ce5ec32b3de4..df7b6ca07b18 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -437,8 +437,8 @@ nsTableFrame::SetInitialChildList(nsIPresContext& aPresContext, prevColGroupChild->SetNextSibling(nsnull); if (NS_SUCCEEDED(rv)) { - //mCellMap->Dump(); - EnsureColumns(aPresContext); + PRBool createdColFrames; + EnsureColumns(aPresContext, createdColFrames); } return rv; @@ -633,10 +633,13 @@ PRInt32 nsTableFrame::GetEffectiveCOLSAttribute() * if the cell map says there are more columns than this, * add extra implicit columns to the content tree. */ -void nsTableFrame::EnsureColumns(nsIPresContext& aPresContext) +void nsTableFrame::EnsureColumns(nsIPresContext& aPresContext, + PRBool& aCreatedColFrames) { if (PR_TRUE==gsDebug) printf("TIF EnsureColumns\n"); NS_PRECONDITION(nsnull!=mCellMap, "bad state: null cellmap"); + + aCreatedColFrames = PR_FALSE; // initialize OUT parameter if (nsnull == mCellMap) return; // no info yet, so nothing useful to do @@ -715,6 +718,7 @@ void nsTableFrame::EnsureColumns(nsIPresContext& aPresContext) lastColGroupStyle, PR_TRUE, &colStyleContext); // colStyleContext: REFCNT++ + aCreatedColFrames = PR_TRUE; // remember that we're creating implicit col frames NS_NewTableColFrame(&colFrame); colFrame->Init(aPresContext, lastColGroupElement, lastColGroupFrame, colStyleContext, nsnull); @@ -4386,8 +4390,9 @@ void nsTableFrame::BuildColumnCache( nsIPresContext& aPresContext, NS_ASSERTION(nsnull!=mCellMap, "never ever call me until the cell map is built!"); PRInt32 colIndex=0; const nsStyleTable* tableStyle; + PRBool createdColFrames; GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle); - EnsureColumns(aPresContext); + EnsureColumns(aPresContext, createdColFrames); if (nsnull!=mColCache) { if (PR_TRUE==gsDebugIR) printf("TIF BCC: clearing column cache and cell map column frame cache.\n"); diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index c6adfbf1d91d..0faa52e29be3 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -722,6 +722,15 @@ public: */ virtual void InvalidateCellMap(); + /** sum the columns represented by all nsTableColGroup objects. + * if the cell map says there are more columns than this, + * add extra implicit columns to the content tree. + * + * returns whether any implicit column frames were created + */ + virtual void EnsureColumns (nsIPresContext& aPresContext, + PRBool& aCreatedColFrames); + protected: /** iterates all child frames and creates a new cell map */ NS_IMETHOD ReBuildCellMap(); @@ -735,12 +744,6 @@ protected: void ListColumnLayoutData(FILE* out, PRInt32 aIndent); #endif - /** sum the columns represented by all nsTableColGroup objects. - * if the cell map says there are more columns than this, - * add extra implicit columns to the content tree. - */ - virtual void EnsureColumns (nsIPresContext& aPresContext); - virtual void BuildColumnCache(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index d621fe541236..3abd40de0e15 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -177,6 +177,16 @@ nsTableRowFrame::AppendFrames(nsIPresContext& aPresContext, } } + // See if any implicit column frames need to be created as a result of + // adding the new rows + PRBool createdColFrames; + tableFrame->EnsureColumns(aPresContext, createdColFrames); + if (createdColFrames) { + // We need to rebuild the column cache + // XXX It would be nice if this could be done incrementally + tableFrame->InvalidateColumnCache(); + } + // Reflow the new frames. They're already marked dirty, so generate a reflow // command that tells us to reflow our dirty child frames nsIReflowCommand* reflowCmd; @@ -1265,7 +1275,6 @@ NS_METHOD nsTableRowFrame::IR_TargetIsMe(nsIPresContext& aPresContext, // If any column widths have to change due to this, rebalance column widths. // XXX need to calculate this, but for now just do it aReflowState.tableFrame->InvalidateColumnWidths(); - aReflowState.tableFrame->InvalidateColumnCache(); break; } diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index 5f9548e08696..5660cd0495e5 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -1170,7 +1170,7 @@ nsTableRowGroupFrame::AppendFrames(nsIPresContext& aPresContext, nsIFrame* aFrameList) { // Get the table frame - nsTableFrame* tableFrame = nsnull; + nsTableFrame* tableFrame; nsTableFrame::GetTableFrame(this, tableFrame); // Append the frames @@ -1188,6 +1188,16 @@ nsTableRowGroupFrame::AppendFrames(nsIPresContext& aPresContext, DidAppendRow((nsTableRowFrame*)rowFrame); } + // See if any implicit column frames need to be created as a result of + // adding the new rows + PRBool createdColFrames; + tableFrame->EnsureColumns(aPresContext, createdColFrames); + if (createdColFrames) { + // We need to rebuild the column cache + // XXX It would be nice if this could be done incrementally + tableFrame->InvalidateColumnCache(); + } + // Reflow the new frames. They're already marked dirty, so generate a reflow // command that tells us to reflow our dirty child frames nsIReflowCommand* reflowCmd;