change table cell width to content width, bug 119100 r=jkeiser sr=bzbarsky

This commit is contained in:
bmlk%gmx.de 2003-03-21 19:35:36 +00:00
parent 5fe83d7fe4
commit ebf5835d15
12 changed files with 106 additions and 78 deletions

View File

@ -614,9 +614,10 @@ BasicTableLayoutStrategy::ComputeNonPctColspanWidths(const nsHTMLReflowState& aR
const nsStylePosition* cellPosition;
cellFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)cellPosition);
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
// need to add padding into fixed width
nsMargin padding = nsTableFrame::GetPadding(nsSize(aReflowState.mComputedWidth, 0), cellFrame);
cellWidth = cellPosition->mWidth.GetCoordValue() + padding.left + padding.right;
// need to add borde and padding into fixed width
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(aReflowState.mComputedWidth, 0),
aPixelToTwips, cellFrame);
cellWidth = cellPosition->mWidth.GetCoordValue() + borderPadding.left + borderPadding.right;
cellWidth = PR_MAX(cellWidth, cellFrame->GetPass1MaxElementWidth());
}
}
@ -844,8 +845,8 @@ BasicTableLayoutStrategy::ComputeNonPctColspanWidths(PRInt32 aWidthInd
numeratorAutoDes = desWidth;
}
nscoord divisor;
nscoord numerator;
nscoord divisor = 0;
nscoord numerator = 0;
// let pct cols reach their target
if (LIMIT_PCT == aLimitType) {
@ -969,7 +970,6 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
#ifdef DEBUG_TABLE_STRATEGY
printf("AssignNonPctColWidths en max=%d count=%d \n", aMaxWidth, gsDebugCount++); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);
#endif
PRBool rv = PR_FALSE;
PRInt32 numRows = mTableFrame->GetRowCount();
PRInt32 numCols = mTableFrame->GetColCount();
nscoord spacingX = mTableFrame->GetCellSpacingX();
@ -1026,10 +1026,10 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
nscoord coordValue = cellPosition->mWidth.GetCoordValue();
if (coordValue > 0) { // ignore if width == 0
// need to add padding into fixed width
// need to add border and padding into fixed width
nsSize percentBase(aReflowState.mComputedWidth, 0);
nsMargin padding = nsTableFrame::GetPadding(percentBase, cellFrame);
nscoord newFixWidth = coordValue + padding.left + padding.right;
nsMargin borderPadding = nsTableFrame::GetBorderPadding(percentBase, aPixelToTwips, cellFrame);
nscoord newFixWidth = coordValue + borderPadding.left + borderPadding.right;
// 2nd part of condition is Nav/IE Quirk like below
if ((newFixWidth > fixWidth) || ((newFixWidth == fixWidth) && (desContributor == cellFrame))) {
fixWidth = newFixWidth;
@ -1225,7 +1225,6 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
PRInt32 numRows = mTableFrame->GetRowCount();
PRInt32 numCols = mTableFrame->GetColCount(); // consider cols at end without orig cells
nscoord spacingX = mTableFrame->GetCellSpacingX();
PRInt32 colX, rowX;
// For an auto table, determine the potentially new percent adjusted width based
@ -1295,7 +1294,6 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
} // end for (colX ..
float perTotal = 0.0f; // total of percentage constrained cols and/or cells in cols
nscoord fixWidthTotal = 0; // total of fixed widths of all cols
PRInt32 numPerCols = 0; // number of colums that have percentage constraints
nscoord fixDesTotal = 0; // total of fix or des widths of cols
nscoord fixDesTotalNoPct = 0; // total of fix or des widths of cols without pct
@ -1408,9 +1406,9 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(nsIPresContext& aPresCo
maxColPctWidth = nsTableFrame::RoundToPixel(NSToCoordRound( ((float)basis) * maxColPct ), aPixelToTwips);
percentContributor = cellFrame;
if (!mIsNavQuirksMode) {
// need to add padding
nsMargin padding = nsTableFrame::GetPadding(nsSize(basis, 0), cellFrame);
maxColPctWidth += padding.left + padding.right;
// need to add border and padding
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(basis, 0), aPixelToTwips, cellFrame);
maxColPctWidth += borderPadding.left + borderPadding.right;
}
}
}
@ -1516,9 +1514,9 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(nsIPresContext& aPresCo
cellPct = 1.0f; // overwrite spurious percent colspan width's - bug 46944
cellPctWidth = nsTableFrame::RoundToPixel(NSToCoordRound( ((float)basis) * cellPct ), aPixelToTwips);
if (!mIsNavQuirksMode) {
// need to add padding
nsMargin padding = nsTableFrame::GetPadding(nsSize(basis, 0), cellFrame);
cellPctWidth += padding.left + padding.right;
// need to add border and padding
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(basis, 0), aPixelToTwips, cellFrame);
cellPctWidth += borderPadding.left + borderPadding.right;
}
}
if (cellPctWidth > 0) {
@ -1637,7 +1635,6 @@ void BasicTableLayoutStrategy::CalculateTotals(PRInt32* aTotalCounts,
}
a0ProportionalCount = 0;
nscoord spacingX = mTableFrame->GetCellSpacingX();
PRInt32 numEffCols = mTableFrame->GetEffectiveColCount();
PRInt32 colX;

View File

@ -98,8 +98,6 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
delete [] colWidths;
return PR_FALSE;
}
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
memset(propInfo, 0, numCols*sizeof(nscoord));
nscoord propTotal = 0;
@ -143,16 +141,25 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
const nsStylePosition* cellPosition;
cellFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)cellPosition);
nscoord cellWidth = 0;
PRInt32 colSpan = mTableFrame->GetEffectiveColSpan(*cellFrame);
// Get fixed cell width if available
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
colWidths[colX] = nsTableFrame::RoundToPixel(cellPosition->mWidth.GetCoordValue() / colSpan, p2t);
// need to add border and padding into fixed width
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(aReflowState.mComputedWidth, 0),
aPixelToTwips, cellFrame);
cellWidth = cellPosition->mWidth.GetCoordValue() + borderPadding.left + borderPadding.right;
colWidths[colX] = nsTableFrame::RoundToPixel(cellWidth / (float) colSpan, aPixelToTwips);
colFrame->SetWidth(MIN_CON, colWidths[colX]);
}
else if ((eStyleUnit_Percent == cellPosition->mWidth.GetUnit()) &&
(aComputedWidth != NS_UNCONSTRAINEDSIZE)) {
float percent = cellPosition->mWidth.GetPercentValue();
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(percent * (float)availWidth / (float)colSpan), aPixelToTwips);
// need to add border and padding into percent width
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(aReflowState.mComputedWidth, 0),
aPixelToTwips, cellFrame);
cellWidth = percent * (float)availWidth + borderPadding.left + borderPadding.right;
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(cellWidth / (float)colSpan), aPixelToTwips);
colFrame->SetWidth(PCT, colWidths[colX]);
percTotal += colWidths[colX];
}

View File

@ -623,10 +623,7 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContex
(const nsStyleTextReset*)mStyleContext->GetStyleData(eStyleStruct_TextReset);
/* XXX: remove tableFrame when border-collapse inherits */
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
nsMargin borderPadding;
GetBorderWidth (p2t, borderPadding);
nsMargin padding = nsTableFrame::GetPadding(aReflowState, this);
borderPadding += padding;
nsMargin borderPadding = nsTableFrame::GetBorderPadding(aReflowState, p2t, this);
nscoord topInset = borderPadding.top;
nscoord bottomInset = borderPadding.bottom;

View File

@ -4045,7 +4045,8 @@ GetPaddingFor(const nsSize& aBasis,
}
nsMargin
nsTableFrame::GetPadding(const nsHTMLReflowState& aReflowState,
nsTableFrame::GetBorderPadding(const nsHTMLReflowState& aReflowState,
float aPixelToTwips,
const nsTableCellFrame* aCellFrame)
{
const nsStylePadding* paddingData;
@ -4066,11 +4067,15 @@ nsTableFrame::GetPadding(const nsHTMLReflowState& aReflowState,
parentRS = parentRS->parentReflowState;
}
}
nsMargin border;
aCellFrame->GetBorderWidth(aPixelToTwips, border);
padding += border;
return padding;
}
nsMargin
nsTableFrame::GetPadding(const nsSize& aBasis,
nsTableFrame::GetBorderPadding(const nsSize& aBasis,
float aPixelToTwips,
const nsTableCellFrame* aCellFrame)
{
const nsStylePadding* paddingData;
@ -4079,6 +4084,9 @@ nsTableFrame::GetPadding(const nsSize& aBasis,
if (!paddingData->GetPadding(padding)) {
GetPaddingFor(aBasis, *paddingData, padding);
}
nsMargin border;
aCellFrame->GetBorderWidth(aPixelToTwips, border);
padding += border;
return padding;
}

View File

@ -386,10 +386,12 @@ public:
PRBool& aDidBalance,
nsReflowStatus& aStatus);
static nsMargin GetPadding(const nsHTMLReflowState& aReflowState,
static nsMargin GetBorderPadding(const nsHTMLReflowState& aReflowState,
float aPixelToTwips,
const nsTableCellFrame* aCellFrame);
static nsMargin GetPadding(const nsSize& aBasis,
static nsMargin GetBorderPadding(const nsSize& aBasis,
float aPixelToTwips,
const nsTableCellFrame* aCellFrame);
nsFrameList& GetColGroups();

View File

@ -770,6 +770,7 @@ nsTableRowFrame::CalculateCellActualSize(nsIFrame* aCellFrame,
static void
CalcAvailWidth(nsTableFrame& aTableFrame,
nscoord aTableComputedWidth,
float aPixelToTwips,
nsTableCellFrame& aCellFrame,
nscoord aCellSpacingX,
nscoord& aColAvailWidth,
@ -805,11 +806,12 @@ CalcAvailWidth(nsTableFrame& aTableFrame,
aCellFrame.GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)cellPosition);
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
// need to add padding into fixed width
nsMargin padding(0,0,0,0);
nsMargin borderPadding(0,0,0,0);
if (NS_UNCONSTRAINEDSIZE != aTableComputedWidth) {
padding = nsTableFrame::GetPadding(nsSize(aTableComputedWidth, 0), &aCellFrame);
borderPadding = nsTableFrame::GetBorderPadding(nsSize(aTableComputedWidth, 0),
aPixelToTwips, &aCellFrame);
}
nscoord fixWidth = cellPosition->mWidth.GetCoordValue() + padding.left + padding.right;
nscoord fixWidth = cellPosition->mWidth.GetCoordValue() + borderPadding.left + borderPadding.right;
aCellAvailWidth = PR_MIN(aColAvailWidth, fixWidth);
}
}
@ -980,7 +982,7 @@ nsTableRowFrame::ReflowChildren(nsIPresContext* aPresContext,
}
// Calculate the available width for the table cell using the known column widths
nscoord availColWidth, availCellWidth;
CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame),
CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame), p2t,
*cellFrame, cellSpacingX, availColWidth, availCellWidth);
if (0 == availColWidth) availColWidth = NS_UNCONSTRAINEDSIZE;
if (0 == availCellWidth) availCellWidth = NS_UNCONSTRAINEDSIZE;
@ -1261,6 +1263,7 @@ nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
if (!aNextFrame) return NS_ERROR_NULL_POINTER;
nsresult rv = NS_OK;
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
PRBool isAutoLayout = aTableFrame.IsAutoLayout();
const nsStyleDisplay *childDisplay;
aNextFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
@ -1277,7 +1280,7 @@ nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
nscoord cellSpacingX = aTableFrame.GetCellSpacingX();
nscoord colAvailWidth, cellAvailWidth;
CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame),
CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame), p2t,
*cellFrame, cellSpacingX, colAvailWidth, cellAvailWidth);
// Always let the cell be as high as it wants. We ignore the height that's

View File

@ -614,9 +614,10 @@ BasicTableLayoutStrategy::ComputeNonPctColspanWidths(const nsHTMLReflowState& aR
const nsStylePosition* cellPosition;
cellFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)cellPosition);
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
// need to add padding into fixed width
nsMargin padding = nsTableFrame::GetPadding(nsSize(aReflowState.mComputedWidth, 0), cellFrame);
cellWidth = cellPosition->mWidth.GetCoordValue() + padding.left + padding.right;
// need to add borde and padding into fixed width
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(aReflowState.mComputedWidth, 0),
aPixelToTwips, cellFrame);
cellWidth = cellPosition->mWidth.GetCoordValue() + borderPadding.left + borderPadding.right;
cellWidth = PR_MAX(cellWidth, cellFrame->GetPass1MaxElementWidth());
}
}
@ -844,8 +845,8 @@ BasicTableLayoutStrategy::ComputeNonPctColspanWidths(PRInt32 aWidthInd
numeratorAutoDes = desWidth;
}
nscoord divisor;
nscoord numerator;
nscoord divisor = 0;
nscoord numerator = 0;
// let pct cols reach their target
if (LIMIT_PCT == aLimitType) {
@ -969,7 +970,6 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
#ifdef DEBUG_TABLE_STRATEGY
printf("AssignNonPctColWidths en max=%d count=%d \n", aMaxWidth, gsDebugCount++); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);
#endif
PRBool rv = PR_FALSE;
PRInt32 numRows = mTableFrame->GetRowCount();
PRInt32 numCols = mTableFrame->GetColCount();
nscoord spacingX = mTableFrame->GetCellSpacingX();
@ -1026,10 +1026,10 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
nscoord coordValue = cellPosition->mWidth.GetCoordValue();
if (coordValue > 0) { // ignore if width == 0
// need to add padding into fixed width
// need to add border and padding into fixed width
nsSize percentBase(aReflowState.mComputedWidth, 0);
nsMargin padding = nsTableFrame::GetPadding(percentBase, cellFrame);
nscoord newFixWidth = coordValue + padding.left + padding.right;
nsMargin borderPadding = nsTableFrame::GetBorderPadding(percentBase, aPixelToTwips, cellFrame);
nscoord newFixWidth = coordValue + borderPadding.left + borderPadding.right;
// 2nd part of condition is Nav/IE Quirk like below
if ((newFixWidth > fixWidth) || ((newFixWidth == fixWidth) && (desContributor == cellFrame))) {
fixWidth = newFixWidth;
@ -1225,7 +1225,6 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
PRInt32 numRows = mTableFrame->GetRowCount();
PRInt32 numCols = mTableFrame->GetColCount(); // consider cols at end without orig cells
nscoord spacingX = mTableFrame->GetCellSpacingX();
PRInt32 colX, rowX;
// For an auto table, determine the potentially new percent adjusted width based
@ -1295,7 +1294,6 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
} // end for (colX ..
float perTotal = 0.0f; // total of percentage constrained cols and/or cells in cols
nscoord fixWidthTotal = 0; // total of fixed widths of all cols
PRInt32 numPerCols = 0; // number of colums that have percentage constraints
nscoord fixDesTotal = 0; // total of fix or des widths of cols
nscoord fixDesTotalNoPct = 0; // total of fix or des widths of cols without pct
@ -1408,9 +1406,9 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(nsIPresContext& aPresCo
maxColPctWidth = nsTableFrame::RoundToPixel(NSToCoordRound( ((float)basis) * maxColPct ), aPixelToTwips);
percentContributor = cellFrame;
if (!mIsNavQuirksMode) {
// need to add padding
nsMargin padding = nsTableFrame::GetPadding(nsSize(basis, 0), cellFrame);
maxColPctWidth += padding.left + padding.right;
// need to add border and padding
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(basis, 0), aPixelToTwips, cellFrame);
maxColPctWidth += borderPadding.left + borderPadding.right;
}
}
}
@ -1516,9 +1514,9 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(nsIPresContext& aPresCo
cellPct = 1.0f; // overwrite spurious percent colspan width's - bug 46944
cellPctWidth = nsTableFrame::RoundToPixel(NSToCoordRound( ((float)basis) * cellPct ), aPixelToTwips);
if (!mIsNavQuirksMode) {
// need to add padding
nsMargin padding = nsTableFrame::GetPadding(nsSize(basis, 0), cellFrame);
cellPctWidth += padding.left + padding.right;
// need to add border and padding
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(basis, 0), aPixelToTwips, cellFrame);
cellPctWidth += borderPadding.left + borderPadding.right;
}
}
if (cellPctWidth > 0) {
@ -1637,7 +1635,6 @@ void BasicTableLayoutStrategy::CalculateTotals(PRInt32* aTotalCounts,
}
a0ProportionalCount = 0;
nscoord spacingX = mTableFrame->GetCellSpacingX();
PRInt32 numEffCols = mTableFrame->GetEffectiveColCount();
PRInt32 colX;

View File

@ -98,8 +98,6 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
delete [] colWidths;
return PR_FALSE;
}
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
memset(propInfo, 0, numCols*sizeof(nscoord));
nscoord propTotal = 0;
@ -143,16 +141,25 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
const nsStylePosition* cellPosition;
cellFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)cellPosition);
nscoord cellWidth = 0;
PRInt32 colSpan = mTableFrame->GetEffectiveColSpan(*cellFrame);
// Get fixed cell width if available
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
colWidths[colX] = nsTableFrame::RoundToPixel(cellPosition->mWidth.GetCoordValue() / colSpan, p2t);
// need to add border and padding into fixed width
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(aReflowState.mComputedWidth, 0),
aPixelToTwips, cellFrame);
cellWidth = cellPosition->mWidth.GetCoordValue() + borderPadding.left + borderPadding.right;
colWidths[colX] = nsTableFrame::RoundToPixel(cellWidth / (float) colSpan, aPixelToTwips);
colFrame->SetWidth(MIN_CON, colWidths[colX]);
}
else if ((eStyleUnit_Percent == cellPosition->mWidth.GetUnit()) &&
(aComputedWidth != NS_UNCONSTRAINEDSIZE)) {
float percent = cellPosition->mWidth.GetPercentValue();
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(percent * (float)availWidth / (float)colSpan), aPixelToTwips);
// need to add border and padding into percent width
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(aReflowState.mComputedWidth, 0),
aPixelToTwips, cellFrame);
cellWidth = percent * (float)availWidth + borderPadding.left + borderPadding.right;
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(cellWidth / (float)colSpan), aPixelToTwips);
colFrame->SetWidth(PCT, colWidths[colX]);
percTotal += colWidths[colX];
}

View File

@ -623,10 +623,7 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContex
(const nsStyleTextReset*)mStyleContext->GetStyleData(eStyleStruct_TextReset);
/* XXX: remove tableFrame when border-collapse inherits */
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
nsMargin borderPadding;
GetBorderWidth (p2t, borderPadding);
nsMargin padding = nsTableFrame::GetPadding(aReflowState, this);
borderPadding += padding;
nsMargin borderPadding = nsTableFrame::GetBorderPadding(aReflowState, p2t, this);
nscoord topInset = borderPadding.top;
nscoord bottomInset = borderPadding.bottom;

View File

@ -4045,7 +4045,8 @@ GetPaddingFor(const nsSize& aBasis,
}
nsMargin
nsTableFrame::GetPadding(const nsHTMLReflowState& aReflowState,
nsTableFrame::GetBorderPadding(const nsHTMLReflowState& aReflowState,
float aPixelToTwips,
const nsTableCellFrame* aCellFrame)
{
const nsStylePadding* paddingData;
@ -4066,11 +4067,15 @@ nsTableFrame::GetPadding(const nsHTMLReflowState& aReflowState,
parentRS = parentRS->parentReflowState;
}
}
nsMargin border;
aCellFrame->GetBorderWidth(aPixelToTwips, border);
padding += border;
return padding;
}
nsMargin
nsTableFrame::GetPadding(const nsSize& aBasis,
nsTableFrame::GetBorderPadding(const nsSize& aBasis,
float aPixelToTwips,
const nsTableCellFrame* aCellFrame)
{
const nsStylePadding* paddingData;
@ -4079,6 +4084,9 @@ nsTableFrame::GetPadding(const nsSize& aBasis,
if (!paddingData->GetPadding(padding)) {
GetPaddingFor(aBasis, *paddingData, padding);
}
nsMargin border;
aCellFrame->GetBorderWidth(aPixelToTwips, border);
padding += border;
return padding;
}

View File

@ -386,10 +386,12 @@ public:
PRBool& aDidBalance,
nsReflowStatus& aStatus);
static nsMargin GetPadding(const nsHTMLReflowState& aReflowState,
static nsMargin GetBorderPadding(const nsHTMLReflowState& aReflowState,
float aPixelToTwips,
const nsTableCellFrame* aCellFrame);
static nsMargin GetPadding(const nsSize& aBasis,
static nsMargin GetBorderPadding(const nsSize& aBasis,
float aPixelToTwips,
const nsTableCellFrame* aCellFrame);
nsFrameList& GetColGroups();

View File

@ -770,6 +770,7 @@ nsTableRowFrame::CalculateCellActualSize(nsIFrame* aCellFrame,
static void
CalcAvailWidth(nsTableFrame& aTableFrame,
nscoord aTableComputedWidth,
float aPixelToTwips,
nsTableCellFrame& aCellFrame,
nscoord aCellSpacingX,
nscoord& aColAvailWidth,
@ -805,11 +806,12 @@ CalcAvailWidth(nsTableFrame& aTableFrame,
aCellFrame.GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)cellPosition);
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
// need to add padding into fixed width
nsMargin padding(0,0,0,0);
nsMargin borderPadding(0,0,0,0);
if (NS_UNCONSTRAINEDSIZE != aTableComputedWidth) {
padding = nsTableFrame::GetPadding(nsSize(aTableComputedWidth, 0), &aCellFrame);
borderPadding = nsTableFrame::GetBorderPadding(nsSize(aTableComputedWidth, 0),
aPixelToTwips, &aCellFrame);
}
nscoord fixWidth = cellPosition->mWidth.GetCoordValue() + padding.left + padding.right;
nscoord fixWidth = cellPosition->mWidth.GetCoordValue() + borderPadding.left + borderPadding.right;
aCellAvailWidth = PR_MIN(aColAvailWidth, fixWidth);
}
}
@ -980,7 +982,7 @@ nsTableRowFrame::ReflowChildren(nsIPresContext* aPresContext,
}
// Calculate the available width for the table cell using the known column widths
nscoord availColWidth, availCellWidth;
CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame),
CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame), p2t,
*cellFrame, cellSpacingX, availColWidth, availCellWidth);
if (0 == availColWidth) availColWidth = NS_UNCONSTRAINEDSIZE;
if (0 == availCellWidth) availCellWidth = NS_UNCONSTRAINEDSIZE;
@ -1261,6 +1263,7 @@ nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
if (!aNextFrame) return NS_ERROR_NULL_POINTER;
nsresult rv = NS_OK;
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
PRBool isAutoLayout = aTableFrame.IsAutoLayout();
const nsStyleDisplay *childDisplay;
aNextFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
@ -1277,7 +1280,7 @@ nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
nscoord cellSpacingX = aTableFrame.GetCellSpacingX();
nscoord colAvailWidth, cellAvailWidth;
CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame),
CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame), p2t,
*cellFrame, cellSpacingX, colAvailWidth, cellAvailWidth);
// Always let the cell be as high as it wants. We ignore the height that's