bug 10636, 15499(partial) - correctly get margin,border,padding from reflow info. calculate it for percentage padding when reflow state not available. r=troy

This commit is contained in:
karnaze@netscape.com
2000-02-12 01:55:40 +00:00
parent 8a6e3141ac
commit ee63354f10
27 changed files with 586 additions and 498 deletions

View File

@@ -56,8 +56,10 @@ PRBool FixedTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aP
* otherwise the cell get a proportion of the remaining space
* as determined by the table width attribute. If no table width attribute, it gets 0 width
*/
PRBool FixedTableLayoutStrategy::AssignPreliminaryColumnWidths(nsIPresContext* aPresContext,
nscoord aComputedWidth)
PRBool
FixedTableLayoutStrategy::AssignPreliminaryColumnWidths(nsIPresContext* aPresContext,
nscoord aComputedWidth,
const nsHTMLReflowState& aReflowState)
{
// NS_ASSERTION(aComputedWidth != NS_UNCONSTRAINEDSIZE, "bad computed width");
const nsStylePosition* tablePosition;
@@ -65,17 +67,15 @@ PRBool FixedTableLayoutStrategy::AssignPreliminaryColumnWidths(nsIPresContext* a
PRBool tableIsFixedWidth = eStyleUnit_Coord == tablePosition->mWidth.GetUnit() ||
eStyleUnit_Percent == tablePosition->mWidth.GetUnit();
const nsStyleSpacing* tableSpacing;
mTableFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)tableSpacing);
nsMargin borderPadding;
tableSpacing->CalcBorderPaddingFor(mTableFrame, borderPadding);
PRInt32 numCols = mTableFrame->GetColCount();
PRInt32 colX;
// availWidth is used as the basis for percentage width columns. It is aComputedWidth
// minus table border, padding, & cellspacing
nscoord availWidth = aComputedWidth - borderPadding.left - borderPadding.right -
((numCols + 1) * mTableFrame->GetCellSpacingX());
nscoord availWidth = (NS_UNCONSTRAINEDSIZE == aComputedWidth)
? NS_UNCONSTRAINEDSIZE
: aComputedWidth - aReflowState.mComputedBorderPadding.left -
aReflowState.mComputedBorderPadding.right -
((numCols + 1) * mTableFrame->GetCellSpacingX());
PRInt32 specifiedCols = 0; // the number of columns whose width is given
nscoord totalColWidth = 0; // the sum of the widths of the columns
@@ -106,7 +106,7 @@ PRBool FixedTableLayoutStrategy::AssignPreliminaryColumnWidths(nsIPresContext* a
} // get the percentage width
else if ((eStyleUnit_Percent == colPosition->mWidth.GetUnit()) &&
(aComputedWidth != NS_UNCONSTRAINEDSIZE)) {
// Only apply percentages if we're unconstrained.
// Only apply percentages if we're constrained.
float percent = colPosition->mWidth.GetPercentValue();
colWidths[colX] = NSToCoordRound(percent * (float)availWidth);
}