Made sure that column cache is invalidated if necessary when appending rows

frames and cell frames
This commit is contained in:
troy%netscape.com 1999-08-07 15:12:50 +00:00
Родитель d877f03c04
Коммит 6b325a5196
8 изменённых файлов: 78 добавлений и 24 удалений

Просмотреть файл

@ -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");

Просмотреть файл

@ -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,

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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");

Просмотреть файл

@ -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,

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;