Remove nsTableFrame::GetBorderPadding and related code. b=367458 r=bernd sr=roc

This commit is contained in:
dbaron%dbaron.org 2007-01-27 22:22:24 +00:00
parent 4149173a99
commit d8805141a6
8 changed files with 22 additions and 169 deletions

View File

@ -514,14 +514,13 @@ nsTableCellFrame::GetSelfOverflow(nsRect& aOverflowArea)
// Align the cell's child frame within the cell
void nsTableCellFrame::VerticallyAlignChild(const nsHTMLReflowState& aReflowState,
nscoord aMaxAscent)
void nsTableCellFrame::VerticallyAlignChild(nscoord aMaxAscent)
{
const nsStyleTextReset* textStyle = GetStyleTextReset();
/* It's the 'border-collapse' on the table that matters */
nsPresContext* presContext = GetPresContext();
GET_PIXELS_TO_TWIPS(presContext, p2t);
nsMargin borderPadding = nsTableFrame::GetBorderPadding(aReflowState, p2t, this);
nsMargin borderPadding = GetUsedBorderAndPadding();
nscoord topInset = borderPadding.top;
nscoord bottomInset = borderPadding.bottom;

View File

@ -154,8 +154,7 @@ public:
NS_IMETHOD GetFrameName(nsAString& aResult) const;
#endif
void VerticallyAlignChild(const nsHTMLReflowState& aReflowState,
nscoord aMaxAscent);
void VerticallyAlignChild(nscoord aMaxAscent);
PRBool HasVerticalAlignBaseline();

View File

@ -3055,8 +3055,7 @@ nsTableFrame::CalcDesiredHeight(const nsHTMLReflowState& aReflowState, nsHTMLRef
}
static
void ResizeCells(nsTableFrame& aTableFrame,
const nsHTMLReflowState& aReflowState)
void ResizeCells(nsTableFrame& aTableFrame)
{
nsAutoVoidArray rowGroups;
PRUint32 numRowGroups;
@ -3079,7 +3078,7 @@ void ResizeCells(nsTableFrame& aTableFrame,
groupDesiredSize.height);
nsTableRowFrame* rowFrame = rgFrame->GetFirstRow();
while (rowFrame) {
rowFrame->DidResize(aReflowState);
rowFrame->DidResize();
rgFrame->ConsiderChildOverflow(groupDesiredSize.mOverflowArea, rowFrame);
rowFrame = rowFrame->GetNextRow();
}
@ -3136,7 +3135,7 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
yEndRG += rowRect.height + cellSpacingY;
amountUsed += amountForRow;
amountUsedByRG += amountForRow;
//rowFrame->DidResize(aReflowState);
//rowFrame->DidResize();
nsTableFrame::RePositionViews(rowFrame);
}
}
@ -3165,7 +3164,7 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
}
if (amountUsed >= aAmount) {
ResizeCells(*this, aReflowState);
ResizeCells(*this);
return;
}
@ -3241,7 +3240,7 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
amountUsed += amountForRow;
amountUsedByRG += amountForRow;
NS_ASSERTION((amountUsed <= aAmount), "invalid row allocation");
//rowFrame->DidResize(aReflowState);
//rowFrame->DidResize();
nsTableFrame::RePositionViews(rowFrame);
}
else {
@ -3270,7 +3269,7 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
yOriginRG = yEndRG;
}
ResizeCells(*this, aReflowState);
ResizeCells(*this);
}
PRBool
@ -3321,100 +3320,6 @@ void nsTableFrame::SetColumnWidth(PRInt32 aColIndex, nscoord aWidth)
}
}
nscoord
CalcPercentPadding(nscoord aBasis,
nsStyleCoord aStyleCoord)
{
float percent = (NS_UNCONSTRAINEDSIZE == aBasis)
? 0 : aStyleCoord.GetPercentValue();
return NSToCoordRound(((float)aBasis) * percent);
}
void
GetPaddingFor(const nsSize& aBasis,
const nsStylePadding& aPaddingData,
nsMargin& aPadding)
{
nsStyleCoord styleCoord;
aPaddingData.mPadding.GetTop(styleCoord);
if (eStyleUnit_Percent == aPaddingData.mPadding.GetTopUnit()) {
aPadding.top = CalcPercentPadding(aBasis.height, styleCoord);
}
else if (eStyleUnit_Coord == aPaddingData.mPadding.GetTopUnit()) {
aPadding.top = styleCoord.GetCoordValue();
}
aPaddingData.mPadding.GetRight(styleCoord);
if (eStyleUnit_Percent == aPaddingData.mPadding.GetRightUnit()) {
aPadding.right = CalcPercentPadding(aBasis.width, styleCoord);
}
else if (eStyleUnit_Coord == aPaddingData.mPadding.GetTopUnit()) {
aPadding.right = styleCoord.GetCoordValue();
}
aPaddingData.mPadding.GetBottom(styleCoord);
if (eStyleUnit_Percent == aPaddingData.mPadding.GetBottomUnit()) {
aPadding.bottom = CalcPercentPadding(aBasis.height, styleCoord);
}
else if (eStyleUnit_Coord == aPaddingData.mPadding.GetTopUnit()) {
aPadding.bottom = styleCoord.GetCoordValue();
}
aPaddingData.mPadding.GetLeft(styleCoord);
if (eStyleUnit_Percent == aPaddingData.mPadding.GetLeftUnit()) {
aPadding.left = CalcPercentPadding(aBasis.width, styleCoord);
}
else if (eStyleUnit_Coord == aPaddingData.mPadding.GetTopUnit()) {
aPadding.left = styleCoord.GetCoordValue();
}
}
nsMargin
nsTableFrame::GetBorderPadding(const nsHTMLReflowState& aReflowState,
float aPixelToTwips,
const nsTableCellFrame* aCellFrame)
{
// XXX When we have a more sensible border/padding API (bug 332922),
// we can get rid of the aReflowState parameters here and on all the
// DidResize* functions.
const nsStylePadding* paddingData = aCellFrame->GetStylePadding();
nsMargin padding(0,0,0,0);
if (!paddingData->GetPadding(padding)) {
const nsHTMLReflowState* parentRS = aReflowState.parentReflowState;
while (parentRS) {
if (parentRS->frame) {
if (nsGkAtoms::tableFrame == parentRS->frame->GetType()) {
nsSize basis(parentRS->ComputedWidth(), parentRS->mComputedHeight);
GetPaddingFor(basis, *paddingData, padding);
break;
}
}
parentRS = parentRS->parentReflowState;
}
}
nsMargin border;
aCellFrame->GetBorderWidth(aPixelToTwips, border);
padding += border;
return padding;
}
nsMargin
nsTableFrame::GetBorderPadding(const nsSize& aBasis,
float aPixelToTwips,
const nsTableCellFrame* aCellFrame)
{
const nsStylePadding* paddingData = aCellFrame->GetStylePadding();
nsMargin padding(0,0,0,0);
if (!paddingData->GetPadding(padding)) {
GetPaddingFor(aBasis, *paddingData, padding);
}
nsMargin border;
aCellFrame->GetBorderWidth(aPixelToTwips, border);
padding += border;
return padding;
}
// XXX: could cache this. But be sure to check style changes if you do!
nscoord nsTableFrame::GetCellSpacingX()
{

View File

@ -310,14 +310,6 @@ public:
nsIFrame*& aLastChildReflowed,
nsReflowStatus& aStatus);
static nsMargin GetBorderPadding(const nsHTMLReflowState& aReflowState,
float aPixelToTwips,
const nsTableCellFrame* aCellFrame);
static nsMargin GetBorderPadding(const nsSize& aBasis,
float aPixelToTwips,
const nsTableCellFrame* aCellFrame);
nsFrameList& GetColGroups();
NS_IMETHOD GetParentStyleContextFrame(nsPresContext* aPresContext,

View File

@ -334,7 +334,7 @@ nsTableRowFrame::GetFirstCell()
* Post-reflow hook. This is where the table row does its post-processing
*/
void
nsTableRowFrame::DidResize(const nsHTMLReflowState& aReflowState)
nsTableRowFrame::DidResize()
{
// Resize and re-align the cell frames based on our row height
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
@ -360,7 +360,7 @@ nsTableRowFrame::DidResize(const nsHTMLReflowState& aReflowState)
{
cellFrame->SetSize(nsSize(cellFrame->GetSize().width, cellHeight));
// realign cell content based on the new height
cellFrame->VerticallyAlignChild(aReflowState, mMaxCellAscent);
cellFrame->VerticallyAlignChild(mMaxCellAscent);
ConsiderChildOverflow(desiredSize.mOverflowArea, cellFrame);
// Note that if the cell's *content* needs to change in response
// to this height, it will get a special height reflow.
@ -665,8 +665,6 @@ nsTableRowFrame::CalculateCellActualSize(nsIFrame* aCellFrame,
// column widths taking into account column spans and column spacing
static void
CalcAvailWidth(nsTableFrame& aTableFrame,
nscoord aTableComputedWidth,
float aPixelToTwips,
nsTableCellFrame& aCellFrame,
nscoord aCellSpacingX,
nscoord& aColAvailWidth,
@ -694,28 +692,6 @@ CalcAvailWidth(nsTableFrame& aTableFrame,
aColAvailWidth += cellSpacing;
}
aCellAvailWidth = aColAvailWidth;
// for a cell with a colspan > 1, use its fix width (if set) as the avail width
// if this is its initial reflow
if ((aCellFrame.GetStateBits() & NS_FRAME_FIRST_REFLOW)
&& (aTableFrame.GetEffectiveColSpan(aCellFrame) > 1)) {
// see if the cell has a style width specified
const nsStylePosition* cellPosition = aCellFrame.GetStylePosition();
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
// need to add padding into fixed width
nsMargin borderPadding(0,0,0,0);
if (NS_UNCONSTRAINEDSIZE != aTableComputedWidth) {
borderPadding = nsTableFrame::GetBorderPadding(nsSize(aTableComputedWidth, 0),
aPixelToTwips, &aCellFrame);
}
nscoord fixWidth = cellPosition->mWidth.GetCoordValue() + borderPadding.left + borderPadding.right;
if (NS_UNCONSTRAINEDSIZE != aColAvailWidth) {
aCellAvailWidth = PR_MIN(aColAvailWidth, fixWidth);
} else {
aCellAvailWidth = fixWidth;
}
}
}
}
nscoord
@ -779,22 +755,6 @@ GetSpaceBetween(PRInt32 aPrevColIndex,
return space;
}
static nscoord
GetComputedWidth(const nsHTMLReflowState& aReflowState,
nsTableFrame& aTableFrame)
{
const nsHTMLReflowState* parentReflow = aReflowState.parentReflowState;
nscoord computedWidth = 0;
while (parentReflow) {
if (parentReflow->frame == &aTableFrame) {
computedWidth = parentReflow->ComputedWidth();
break;
}
parentReflow = parentReflow->parentReflowState;
}
return computedWidth;
}
// subtract the heights of aRow's prev in flows from the unpaginated height
static
nscoord CalcHeightFromUnpaginatedHeight(nsPresContext* aPresContext,
@ -903,8 +863,8 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
if (doReflowChild) {
// Calculate the available width for the table cell using the known column widths
nscoord availColWidth, availCellWidth;
CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame), p2t,
*cellFrame, cellSpacingX, availColWidth, availCellWidth);
CalcAvailWidth(aTableFrame, *cellFrame, cellSpacingX,
availColWidth, availCellWidth);
nsHTMLReflowMetrics desiredSize;
@ -1129,7 +1089,7 @@ nsTableRowFrame::ReflowCellFrame(nsPresContext* aPresContext,
// XXX What happens if this cell has 'vertical-align: baseline' ?
// XXX Why is it assumed that the cell's ascent hasn't changed ?
if (fullyComplete) {
aCellFrame->VerticallyAlignChild(aReflowState, mMaxCellAscent);
aCellFrame->VerticallyAlignChild(mMaxCellAscent);
}
aCellFrame->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);

View File

@ -111,7 +111,7 @@ public:
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
void DidResize(const nsHTMLReflowState& aReflowState);
void DidResize();
/**
* Get the "type" of the frame

View File

@ -427,7 +427,7 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
if (!reflowAllKids) {
if (IsSimpleRowFrame(aReflowState.tableFrame, kidFrame)) {
// Inform the row of its new height.
((nsTableRowFrame*)kidFrame)->DidResize(aReflowState.reflowState);
((nsTableRowFrame*)kidFrame)->DidResize();
// the overflow area may have changed inflate the overflow area
if (aReflowState.tableFrame->IsAutoHeight()) {
// Because other cells in the row may need to be aligned
@ -479,7 +479,7 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
aDesiredSize.height = aReflowState.y;
if (aReflowState.reflowState.mFlags.mSpecialHeightReflow) {
DidResizeRows(aReflowState.reflowState, aDesiredSize);
DidResizeRows(aDesiredSize);
if (isPaginated) {
CacheRowHeightsForPrinting(aPresContext, GetFirstRow());
}
@ -535,8 +535,7 @@ UpdateHeights(RowInfo& aRowInfo,
}
void
nsTableRowGroupFrame::DidResizeRows(const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredSize)
nsTableRowGroupFrame::DidResizeRows(nsHTMLReflowMetrics& aDesiredSize)
{
// update the cells spanning rows with their new heights
// this is the place where all of the cells in the row get set to the height of the row
@ -544,7 +543,7 @@ nsTableRowGroupFrame::DidResizeRows(const nsHTMLReflowState& aReflowState,
aDesiredSize.mOverflowArea = nsRect(0, 0, 0, 0);
for (nsTableRowFrame* rowFrame = GetFirstRow();
rowFrame; rowFrame = rowFrame->GetNextRow()) {
rowFrame->DidResize(aReflowState);
rowFrame->DidResize();
ConsiderChildOverflow(aDesiredSize.mOverflowArea, rowFrame);
}
}
@ -820,7 +819,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
CacheRowHeightsForPrinting(aPresContext, GetFirstRow());
}
DidResizeRows(aReflowState, aDesiredSize);
DidResizeRows(aDesiredSize);
aDesiredSize.height = rowGroupHeight; // Adjust our desired size
delete [] rowInfo; // cleanup
@ -1090,7 +1089,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
if (NS_FAILED(rv)) return rv;
rowFrame->SetSize(nsSize(rowMetrics.width, rowMetrics.height));
rowFrame->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
rowFrame->DidResize(aReflowState);
rowFrame->DidResize();
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
// The row frame is incomplete and all of the rowspan 1 cells' block frames split

View File

@ -322,8 +322,7 @@ protected:
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState);
void DidResizeRows(const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredSize);
void DidResizeRows(nsHTMLReflowMetrics& aDesiredSize);
void SlideChild(nsRowGroupReflowState& aReflowState,
nsIFrame* aKidFrame);