bug 126118 - remove code which tries to honor height of cell after it splits, get correct height on 3rd pass reflow. a=asa, sr=attinasi, r=alexsavulov.

This commit is contained in:
karnaze@netscape.com
2002-03-16 21:46:29 +00:00
parent 90904bd364
commit c11438a333
6 changed files with 24 additions and 76 deletions

View File

@@ -77,8 +77,14 @@
nsTableCellFrame::nsTableCellFrame() nsTableCellFrame::nsTableCellFrame()
{ {
mBits.mColIndex = 0; mBits.mColIndex = 0;
mPriorAvailWidth = 0; mPriorAvailWidth = 0;
SetContentEmpty(PR_FALSE);
SetNeedSpecialReflow(PR_FALSE);
SetHadSpecialReflow(PR_FALSE);
SetHasPctOverHeight(PR_FALSE);
#ifdef DEBUG_TABLE_REFLOW_TIMING #ifdef DEBUG_TABLE_REFLOW_TIMING
mTimer = new nsReflowTimer(this); mTimer = new nsReflowTimer(this);
mBlockTimer = new nsReflowTimer(this); mBlockTimer = new nsReflowTimer(this);
@@ -771,20 +777,6 @@ CalcUnpaginagedHeight(nsIPresContext* aPresContext,
return computedHeight; return computedHeight;
} }
static nscoord
CalcHeightOfPrevInFlows(nsTableCellFrame& aCell)
{
nscoord height = 0;
nsIFrame* prevInFlow;
for (aCell.GetPrevInFlow(&prevInFlow); prevInFlow; prevInFlow->GetPrevInFlow(&prevInFlow)) {
nsRect rect;
prevInFlow->GetRect(rect);
height += rect.height;
}
return height;
}
NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext, NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize, nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState, const nsHTMLReflowState& aReflowState,
@@ -795,7 +787,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
#if defined DEBUG_TABLE_REFLOW_TIMING #if defined DEBUG_TABLE_REFLOW_TIMING
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState); nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState);
#endif #endif
float p2t; float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t); aPresContext->GetScaledPixelsToTwips(&p2t);
@@ -1099,7 +1090,9 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
// the height that they could honor in the pass 2 reflow // the height that they could honor in the pass 2 reflow
SetHasPctOverHeight(PR_TRUE); SetHasPctOverHeight(PR_TRUE);
} }
aDesiredSize.height = mRect.height; if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
aDesiredSize.height = mRect.height;
}
SetNeedSpecialReflow(PR_FALSE); SetNeedSpecialReflow(PR_FALSE);
SetHadSpecialReflow(PR_TRUE); SetHadSpecialReflow(PR_TRUE);
} }
@@ -1113,24 +1106,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
SetHadSpecialReflow(PR_FALSE); SetHadSpecialReflow(PR_FALSE);
} }
} }
else if (computedPaginatedHeight > 0) {
nscoord height = computedPaginatedHeight + topInset + bottomInset - CalcHeightOfPrevInFlows(*this);
if (NS_FRAME_COMPLETE == aStatus) {
if (mPrevInFlow) height -= topInset;
height = PR_MAX(aDesiredSize.height, height);
if ((NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight) && (height > aReflowState.availableHeight)) {
height = aReflowState.availableHeight;
aStatus = NS_FRAME_NOT_COMPLETE;
}
}
else {
height -= bottomInset;
if (aDesiredSize.height < height) {
height = aDesiredSize.height;
}
}
aDesiredSize.height = height;
}
// remember the desired size for this reflow // remember the desired size for this reflow
SetDesiredSize(aDesiredSize); SetDesiredSize(aDesiredSize);

View File

@@ -1414,7 +1414,6 @@ nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
switch (aReflowState.reason) { switch (aReflowState.reason) {
case eReflowReason_Initial: case eReflowReason_Initial:
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE); rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE);
aStatus = NS_FRAME_COMPLETE;
break; break;
case eReflowReason_Resize: case eReflowReason_Resize:

View File

@@ -1170,7 +1170,7 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
} }
// See if all the frames fit // See if all the frames fit
if (aDesiredSize.height > aReflowState.availableHeight) { if ((NS_FRAME_NOT_COMPLETE == aStatus) || (aDesiredSize.height > aReflowState.availableHeight)) {
// Nope, find a place to split the row group // Nope, find a place to split the row group
PRBool specialReflow = (PRBool)aReflowState.mFlags.mSpecialHeightReflow; PRBool specialReflow = (PRBool)aReflowState.mFlags.mSpecialHeightReflow;
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = PR_FALSE; ((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = PR_FALSE;
@@ -1178,7 +1178,7 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
SplitRowGroup(aPresContext, aDesiredSize, aReflowState, tableFrame, aStatus); SplitRowGroup(aPresContext, aDesiredSize, aReflowState, tableFrame, aStatus);
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = specialReflow; ((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = specialReflow;
} }
} }
SetHasStyleHeight((NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) && SetHasStyleHeight((NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) &&
(aReflowState.mComputedHeight > 0)); (aReflowState.mComputedHeight > 0));

View File

@@ -77,8 +77,14 @@
nsTableCellFrame::nsTableCellFrame() nsTableCellFrame::nsTableCellFrame()
{ {
mBits.mColIndex = 0; mBits.mColIndex = 0;
mPriorAvailWidth = 0; mPriorAvailWidth = 0;
SetContentEmpty(PR_FALSE);
SetNeedSpecialReflow(PR_FALSE);
SetHadSpecialReflow(PR_FALSE);
SetHasPctOverHeight(PR_FALSE);
#ifdef DEBUG_TABLE_REFLOW_TIMING #ifdef DEBUG_TABLE_REFLOW_TIMING
mTimer = new nsReflowTimer(this); mTimer = new nsReflowTimer(this);
mBlockTimer = new nsReflowTimer(this); mBlockTimer = new nsReflowTimer(this);
@@ -771,20 +777,6 @@ CalcUnpaginagedHeight(nsIPresContext* aPresContext,
return computedHeight; return computedHeight;
} }
static nscoord
CalcHeightOfPrevInFlows(nsTableCellFrame& aCell)
{
nscoord height = 0;
nsIFrame* prevInFlow;
for (aCell.GetPrevInFlow(&prevInFlow); prevInFlow; prevInFlow->GetPrevInFlow(&prevInFlow)) {
nsRect rect;
prevInFlow->GetRect(rect);
height += rect.height;
}
return height;
}
NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext, NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize, nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState, const nsHTMLReflowState& aReflowState,
@@ -795,7 +787,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
#if defined DEBUG_TABLE_REFLOW_TIMING #if defined DEBUG_TABLE_REFLOW_TIMING
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState); nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState);
#endif #endif
float p2t; float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t); aPresContext->GetScaledPixelsToTwips(&p2t);
@@ -1099,7 +1090,9 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
// the height that they could honor in the pass 2 reflow // the height that they could honor in the pass 2 reflow
SetHasPctOverHeight(PR_TRUE); SetHasPctOverHeight(PR_TRUE);
} }
aDesiredSize.height = mRect.height; if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
aDesiredSize.height = mRect.height;
}
SetNeedSpecialReflow(PR_FALSE); SetNeedSpecialReflow(PR_FALSE);
SetHadSpecialReflow(PR_TRUE); SetHadSpecialReflow(PR_TRUE);
} }
@@ -1113,24 +1106,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
SetHadSpecialReflow(PR_FALSE); SetHadSpecialReflow(PR_FALSE);
} }
} }
else if (computedPaginatedHeight > 0) {
nscoord height = computedPaginatedHeight + topInset + bottomInset - CalcHeightOfPrevInFlows(*this);
if (NS_FRAME_COMPLETE == aStatus) {
if (mPrevInFlow) height -= topInset;
height = PR_MAX(aDesiredSize.height, height);
if ((NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight) && (height > aReflowState.availableHeight)) {
height = aReflowState.availableHeight;
aStatus = NS_FRAME_NOT_COMPLETE;
}
}
else {
height -= bottomInset;
if (aDesiredSize.height < height) {
height = aDesiredSize.height;
}
}
aDesiredSize.height = height;
}
// remember the desired size for this reflow // remember the desired size for this reflow
SetDesiredSize(aDesiredSize); SetDesiredSize(aDesiredSize);

View File

@@ -1414,7 +1414,6 @@ nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
switch (aReflowState.reason) { switch (aReflowState.reason) {
case eReflowReason_Initial: case eReflowReason_Initial:
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE); rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE);
aStatus = NS_FRAME_COMPLETE;
break; break;
case eReflowReason_Resize: case eReflowReason_Resize:

View File

@@ -1170,7 +1170,7 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
} }
// See if all the frames fit // See if all the frames fit
if (aDesiredSize.height > aReflowState.availableHeight) { if ((NS_FRAME_NOT_COMPLETE == aStatus) || (aDesiredSize.height > aReflowState.availableHeight)) {
// Nope, find a place to split the row group // Nope, find a place to split the row group
PRBool specialReflow = (PRBool)aReflowState.mFlags.mSpecialHeightReflow; PRBool specialReflow = (PRBool)aReflowState.mFlags.mSpecialHeightReflow;
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = PR_FALSE; ((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = PR_FALSE;
@@ -1178,7 +1178,7 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
SplitRowGroup(aPresContext, aDesiredSize, aReflowState, tableFrame, aStatus); SplitRowGroup(aPresContext, aDesiredSize, aReflowState, tableFrame, aStatus);
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = specialReflow; ((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = specialReflow;
} }
} }
SetHasStyleHeight((NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) && SetHasStyleHeight((NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) &&
(aReflowState.mComputedHeight > 0)); (aReflowState.mComputedHeight > 0));