Added support for incremental reflow of nested row groups (yeah, baby, yeah, baby, YEAH).

This commit is contained in:
hyatt%netscape.com 1999-06-15 01:19:18 +00:00
parent 65f4e3f274
commit 000e6b29df
8 changed files with 166 additions and 16 deletions

View File

@ -3163,6 +3163,19 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext& aPresContext,
return NS_OK;
}
NS_METHOD nsTableFrame::GetBorderPlusMarginPadding(nsMargin& aResult)
{
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsMargin borderPadding;
GetTableBorder (borderPadding);
nsMargin padding;
mySpacing->GetPadding(padding);
borderPadding += padding;
aResult = borderPadding;
return NS_OK;
}
NS_METHOD nsTableFrame::IncrementalReflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
@ -3171,14 +3184,8 @@ NS_METHOD nsTableFrame::IncrementalReflow(nsIPresContext& aPresContext,
if (PR_TRUE==gsDebugIR) printf("\nTIF IR: IncrementalReflow\n");
nsresult rv = NS_OK;
// create an inner table reflow state
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsMargin borderPadding;
GetTableBorder (borderPadding);
nsMargin padding;
mySpacing->GetPadding(padding);
borderPadding += padding;
GetBorderPlusMarginPadding(borderPadding);
InnerTableReflowState state(aPresContext, aReflowState, borderPadding);
// determine if this frame is the target or not

View File

@ -416,6 +416,8 @@ public:
static PRBool IsFinalPass(const nsReflowState& aReflowState);
NS_METHOD GetBorderPlusMarginPadding(nsMargin& aResult);
protected:
/** protected constructor.
@ -431,6 +433,7 @@ protected:
virtual PRBool ParentDisablesSelection() const; //override default behavior
public:
/** first pass of ResizeReflow.
* lays out all table content with aMaxSize(NS_UNCONSTRAINEDSIZE,NS_UNCONSTRAINEDSIZE) and
* a non-null aMaxElementSize so we get all the metrics we need to do column balancing.
@ -450,6 +453,7 @@ protected:
nsReflowReason aReason,
PRBool aDoSiblings);
protected:
/** second pass of ResizeReflow.
* lays out all table content with aMaxSize(computed_table_width, given_table_height)
* Pass 2 is executed every time the table needs to resize. An optimization is included
@ -463,7 +467,7 @@ protected:
nsReflowStatus& aStatus);
// begin incremental reflow methods
/** Incremental Reflow attempts to do column balancing with the minimum number of reflow
* commands to child elements. This is done by processing the reflow command,
* rebalancing column widths (if necessary), then comparing the resulting column widths

View File

@ -1152,6 +1152,11 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext,
rv = IR_RowInserted(aPresContext, aDesiredSize, aReflowState, aStatus,
(nsTableRowFrame *)objectFrame, PR_FALSE);
}
else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay)
{
rv = IR_RowGroupInserted(aPresContext, aDesiredSize, aReflowState, aStatus,
(nsTableRowGroupFrame*)objectFrame, PR_FALSE);
}
else
{
rv = AddFrame(aReflowState.reflowState, objectFrame);
@ -1166,6 +1171,11 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext,
rv = IR_RowAppended(aPresContext, aDesiredSize, aReflowState, aStatus,
(nsTableRowFrame *)objectFrame);
}
else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay)
{
rv = IR_RowGroupInserted(aPresContext, aDesiredSize, aReflowState, aStatus,
(nsTableRowGroupFrame*)objectFrame, PR_FALSE);
}
else
{ // no optimization to be done for Unknown frame types, so just reuse the Inserted method
rv = AddFrame(aReflowState.reflowState, objectFrame);
@ -1185,6 +1195,11 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext,
rv = IR_RowRemoved(aPresContext, aDesiredSize, aReflowState, aStatus,
(nsTableRowFrame *)objectFrame);
}
else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay)
{
rv = IR_RowGroupRemoved(aPresContext, aDesiredSize, aReflowState, aStatus,
(nsTableRowGroupFrame *)objectFrame);
}
else
{
rv = mFrames.DeleteFrame(aPresContext, objectFrame);
@ -1218,6 +1233,42 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext,
return rv;
}
NS_METHOD nsTableRowGroupFrame::IR_RowGroupInserted(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,
nsReflowStatus& aStatus,
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;
aReflowState.tableFrame->InvalidateCellMap();
aReflowState.tableFrame->InvalidateColumnCache();
return rv;
}
NS_METHOD nsTableRowGroupFrame::IR_RowGroupRemoved(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,
nsReflowStatus& aStatus,
nsTableRowGroupFrame * aDeletedFrame)
{
if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_RowGroupRemoved for frame %p\n", aDeletedFrame);
nsresult rv = mFrames.DeleteFrame(aPresContext, aDeletedFrame);
aReflowState.tableFrame->InvalidateCellMap();
aReflowState.tableFrame->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
aReflowState.tableFrame->InvalidateColumnWidths();
return rv;
}
NS_METHOD nsTableRowGroupFrame::IR_RowInserted(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,

View File

@ -188,6 +188,19 @@ protected:
nsReflowStatus& aStatus,
nsTableRowFrame * aDeletedFrame);
NS_IMETHOD IR_RowGroupInserted(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,
nsReflowStatus& aStatus,
nsTableRowGroupFrame * aInsertedFrame,
PRBool aReplace);
NS_IMETHOD IR_RowGroupRemoved(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,
nsReflowStatus& aStatus,
nsTableRowGroupFrame * aDeletedFrame);
NS_IMETHOD IR_StyleChanged(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,

View File

@ -3163,6 +3163,19 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext& aPresContext,
return NS_OK;
}
NS_METHOD nsTableFrame::GetBorderPlusMarginPadding(nsMargin& aResult)
{
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsMargin borderPadding;
GetTableBorder (borderPadding);
nsMargin padding;
mySpacing->GetPadding(padding);
borderPadding += padding;
aResult = borderPadding;
return NS_OK;
}
NS_METHOD nsTableFrame::IncrementalReflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
@ -3171,14 +3184,8 @@ NS_METHOD nsTableFrame::IncrementalReflow(nsIPresContext& aPresContext,
if (PR_TRUE==gsDebugIR) printf("\nTIF IR: IncrementalReflow\n");
nsresult rv = NS_OK;
// create an inner table reflow state
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsMargin borderPadding;
GetTableBorder (borderPadding);
nsMargin padding;
mySpacing->GetPadding(padding);
borderPadding += padding;
GetBorderPlusMarginPadding(borderPadding);
InnerTableReflowState state(aPresContext, aReflowState, borderPadding);
// determine if this frame is the target or not

View File

@ -416,6 +416,8 @@ public:
static PRBool IsFinalPass(const nsReflowState& aReflowState);
NS_METHOD GetBorderPlusMarginPadding(nsMargin& aResult);
protected:
/** protected constructor.
@ -431,6 +433,7 @@ protected:
virtual PRBool ParentDisablesSelection() const; //override default behavior
public:
/** first pass of ResizeReflow.
* lays out all table content with aMaxSize(NS_UNCONSTRAINEDSIZE,NS_UNCONSTRAINEDSIZE) and
* a non-null aMaxElementSize so we get all the metrics we need to do column balancing.
@ -450,6 +453,7 @@ protected:
nsReflowReason aReason,
PRBool aDoSiblings);
protected:
/** second pass of ResizeReflow.
* lays out all table content with aMaxSize(computed_table_width, given_table_height)
* Pass 2 is executed every time the table needs to resize. An optimization is included
@ -463,7 +467,7 @@ protected:
nsReflowStatus& aStatus);
// begin incremental reflow methods
/** Incremental Reflow attempts to do column balancing with the minimum number of reflow
* commands to child elements. This is done by processing the reflow command,
* rebalancing column widths (if necessary), then comparing the resulting column widths

View File

@ -1152,6 +1152,11 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext,
rv = IR_RowInserted(aPresContext, aDesiredSize, aReflowState, aStatus,
(nsTableRowFrame *)objectFrame, PR_FALSE);
}
else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay)
{
rv = IR_RowGroupInserted(aPresContext, aDesiredSize, aReflowState, aStatus,
(nsTableRowGroupFrame*)objectFrame, PR_FALSE);
}
else
{
rv = AddFrame(aReflowState.reflowState, objectFrame);
@ -1166,6 +1171,11 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext,
rv = IR_RowAppended(aPresContext, aDesiredSize, aReflowState, aStatus,
(nsTableRowFrame *)objectFrame);
}
else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay)
{
rv = IR_RowGroupInserted(aPresContext, aDesiredSize, aReflowState, aStatus,
(nsTableRowGroupFrame*)objectFrame, PR_FALSE);
}
else
{ // no optimization to be done for Unknown frame types, so just reuse the Inserted method
rv = AddFrame(aReflowState.reflowState, objectFrame);
@ -1185,6 +1195,11 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext,
rv = IR_RowRemoved(aPresContext, aDesiredSize, aReflowState, aStatus,
(nsTableRowFrame *)objectFrame);
}
else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay)
{
rv = IR_RowGroupRemoved(aPresContext, aDesiredSize, aReflowState, aStatus,
(nsTableRowGroupFrame *)objectFrame);
}
else
{
rv = mFrames.DeleteFrame(aPresContext, objectFrame);
@ -1218,6 +1233,42 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext,
return rv;
}
NS_METHOD nsTableRowGroupFrame::IR_RowGroupInserted(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,
nsReflowStatus& aStatus,
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;
aReflowState.tableFrame->InvalidateCellMap();
aReflowState.tableFrame->InvalidateColumnCache();
return rv;
}
NS_METHOD nsTableRowGroupFrame::IR_RowGroupRemoved(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,
nsReflowStatus& aStatus,
nsTableRowGroupFrame * aDeletedFrame)
{
if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_RowGroupRemoved for frame %p\n", aDeletedFrame);
nsresult rv = mFrames.DeleteFrame(aPresContext, aDeletedFrame);
aReflowState.tableFrame->InvalidateCellMap();
aReflowState.tableFrame->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
aReflowState.tableFrame->InvalidateColumnWidths();
return rv;
}
NS_METHOD nsTableRowGroupFrame::IR_RowInserted(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,

View File

@ -188,6 +188,19 @@ protected:
nsReflowStatus& aStatus,
nsTableRowFrame * aDeletedFrame);
NS_IMETHOD IR_RowGroupInserted(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,
nsReflowStatus& aStatus,
nsTableRowGroupFrame * aInsertedFrame,
PRBool aReplace);
NS_IMETHOD IR_RowGroupRemoved(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,
nsReflowStatus& aStatus,
nsTableRowGroupFrame * aDeletedFrame);
NS_IMETHOD IR_StyleChanged(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
RowGroupReflowState& aReflowState,