diff --git a/layout/html/table/src/BasicTableLayoutStrategy.cpp b/layout/html/table/src/BasicTableLayoutStrategy.cpp index 7bc29c5e1a46..66f8502706b8 100644 --- a/layout/html/table/src/BasicTableLayoutStrategy.cpp +++ b/layout/html/table/src/BasicTableLayoutStrategy.cpp @@ -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; diff --git a/layout/html/table/src/FixedTableLayoutStrategy.cpp b/layout/html/table/src/FixedTableLayoutStrategy.cpp index 86f767f86809..e3febe4677d2 100644 --- a/layout/html/table/src/FixedTableLayoutStrategy.cpp +++ b/layout/html/table/src/FixedTableLayoutStrategy.cpp @@ -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]; } diff --git a/layout/html/table/src/nsTableCellFrame.cpp b/layout/html/table/src/nsTableCellFrame.cpp index 9133be839758..ae8f9f2fc522 100644 --- a/layout/html/table/src/nsTableCellFrame.cpp +++ b/layout/html/table/src/nsTableCellFrame.cpp @@ -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; diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp index a219d7ab967a..dbc100081e33 100644 --- a/layout/html/table/src/nsTableFrame.cpp +++ b/layout/html/table/src/nsTableFrame.cpp @@ -4045,8 +4045,9 @@ GetPaddingFor(const nsSize& aBasis, } nsMargin -nsTableFrame::GetPadding(const nsHTMLReflowState& aReflowState, - const nsTableCellFrame* aCellFrame) +nsTableFrame::GetBorderPadding(const nsHTMLReflowState& aReflowState, + float aPixelToTwips, + const nsTableCellFrame* aCellFrame) { const nsStylePadding* paddingData; aCellFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct *&)paddingData); @@ -4066,12 +4067,16 @@ nsTableFrame::GetPadding(const nsHTMLReflowState& aReflowState, parentRS = parentRS->parentReflowState; } } + nsMargin border; + aCellFrame->GetBorderWidth(aPixelToTwips, border); + padding += border; return padding; } nsMargin -nsTableFrame::GetPadding(const nsSize& aBasis, - const nsTableCellFrame* aCellFrame) +nsTableFrame::GetBorderPadding(const nsSize& aBasis, + float aPixelToTwips, + const nsTableCellFrame* aCellFrame) { const nsStylePadding* paddingData; aCellFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct *&)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; } diff --git a/layout/html/table/src/nsTableFrame.h b/layout/html/table/src/nsTableFrame.h index 6e084af087af..8e12f995cdd6 100644 --- a/layout/html/table/src/nsTableFrame.h +++ b/layout/html/table/src/nsTableFrame.h @@ -386,11 +386,13 @@ public: PRBool& aDidBalance, nsReflowStatus& aStatus); - static nsMargin GetPadding(const nsHTMLReflowState& aReflowState, - const nsTableCellFrame* aCellFrame); + static nsMargin GetBorderPadding(const nsHTMLReflowState& aReflowState, + float aPixelToTwips, + const nsTableCellFrame* aCellFrame); - static nsMargin GetPadding(const nsSize& aBasis, - const nsTableCellFrame* aCellFrame); + static nsMargin GetBorderPadding(const nsSize& aBasis, + float aPixelToTwips, + const nsTableCellFrame* aCellFrame); nsFrameList& GetColGroups(); diff --git a/layout/html/table/src/nsTableRowFrame.cpp b/layout/html/table/src/nsTableRowFrame.cpp index a68bc699873f..93cb1e5d5fd7 100644 --- a/layout/html/table/src/nsTableRowFrame.cpp +++ b/layout/html/table/src/nsTableRowFrame.cpp @@ -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 diff --git a/layout/tables/BasicTableLayoutStrategy.cpp b/layout/tables/BasicTableLayoutStrategy.cpp index 7bc29c5e1a46..66f8502706b8 100644 --- a/layout/tables/BasicTableLayoutStrategy.cpp +++ b/layout/tables/BasicTableLayoutStrategy.cpp @@ -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; diff --git a/layout/tables/FixedTableLayoutStrategy.cpp b/layout/tables/FixedTableLayoutStrategy.cpp index 86f767f86809..e3febe4677d2 100644 --- a/layout/tables/FixedTableLayoutStrategy.cpp +++ b/layout/tables/FixedTableLayoutStrategy.cpp @@ -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]; } diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index 9133be839758..ae8f9f2fc522 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -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; diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index a219d7ab967a..dbc100081e33 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -4045,8 +4045,9 @@ GetPaddingFor(const nsSize& aBasis, } nsMargin -nsTableFrame::GetPadding(const nsHTMLReflowState& aReflowState, - const nsTableCellFrame* aCellFrame) +nsTableFrame::GetBorderPadding(const nsHTMLReflowState& aReflowState, + float aPixelToTwips, + const nsTableCellFrame* aCellFrame) { const nsStylePadding* paddingData; aCellFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct *&)paddingData); @@ -4066,12 +4067,16 @@ nsTableFrame::GetPadding(const nsHTMLReflowState& aReflowState, parentRS = parentRS->parentReflowState; } } + nsMargin border; + aCellFrame->GetBorderWidth(aPixelToTwips, border); + padding += border; return padding; } nsMargin -nsTableFrame::GetPadding(const nsSize& aBasis, - const nsTableCellFrame* aCellFrame) +nsTableFrame::GetBorderPadding(const nsSize& aBasis, + float aPixelToTwips, + const nsTableCellFrame* aCellFrame) { const nsStylePadding* paddingData; aCellFrame->GetStyleData(eStyleStruct_Padding,(const nsStyleStruct *&)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; } diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index 6e084af087af..8e12f995cdd6 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -386,11 +386,13 @@ public: PRBool& aDidBalance, nsReflowStatus& aStatus); - static nsMargin GetPadding(const nsHTMLReflowState& aReflowState, - const nsTableCellFrame* aCellFrame); + static nsMargin GetBorderPadding(const nsHTMLReflowState& aReflowState, + float aPixelToTwips, + const nsTableCellFrame* aCellFrame); - static nsMargin GetPadding(const nsSize& aBasis, - const nsTableCellFrame* aCellFrame); + static nsMargin GetBorderPadding(const nsSize& aBasis, + float aPixelToTwips, + const nsTableCellFrame* aCellFrame); nsFrameList& GetColGroups(); diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index a68bc699873f..93cb1e5d5fd7 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -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