Fix asserts by making sure that border-spacing is always computed to coord

values.  Bug 270325, r+sr=dbaron
This commit is contained in:
bzbarsky%mit.edu 2004-11-30 18:30:58 +00:00
parent 99d2eadca6
commit da145480c7
6 changed files with 40 additions and 68 deletions

View File

@ -3841,24 +3841,14 @@ nsRuleNode::ComputeTableBorderData(nsStyleStruct* aStartStruct,
table->mBorderCollapse = parentTable->mBorderCollapse; table->mBorderCollapse = parentTable->mBorderCollapse;
} }
nsStyleCoord coord;
// border-spacing-x: length, inherit // border-spacing-x: length, inherit
if (SetCoord(tableData.mBorderSpacing.mXValue, coord, coord, SETCOORD_LENGTH, aContext, mPresContext, inherited)) { SetCoord(tableData.mBorderSpacing.mXValue, table->mBorderSpacingX,
table->mBorderSpacingX = coord.GetCoordValue(); parentTable->mBorderSpacingX, SETCOORD_LH,
} aContext, mPresContext, inherited);
else if (eCSSUnit_Inherit == tableData.mBorderSpacing.mXValue.GetUnit()) {
inherited = PR_TRUE;
table->mBorderSpacingX = parentTable->mBorderSpacingX;
}
// border-spacing-y: length, inherit // border-spacing-y: length, inherit
if (SetCoord(tableData.mBorderSpacing.mYValue, coord, coord, SETCOORD_LENGTH, aContext, mPresContext, inherited)) { SetCoord(tableData.mBorderSpacing.mYValue, table->mBorderSpacingY,
table->mBorderSpacingY = coord.GetCoordValue(); parentTable->mBorderSpacingY, SETCOORD_LH,
} aContext, mPresContext, inherited);
else if (eCSSUnit_Inherit == tableData.mBorderSpacing.mYValue.GetUnit()) {
inherited = PR_TRUE;
table->mBorderSpacingY = parentTable->mBorderSpacingY;
}
// caption-side: enum, inherit // caption-side: enum, inherit
if (eCSSUnit_Enumerated == tableData.mCaptionSide.GetUnit()) { if (eCSSUnit_Enumerated == tableData.mCaptionSide.GetUnit()) {

View File

@ -1101,8 +1101,8 @@ nsStyleTableBorder::nsStyleTableBorder(nsPresContext* aPresContext)
? NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND ? NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND
: NS_STYLE_TABLE_EMPTY_CELLS_SHOW; : NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
mCaptionSide = NS_SIDE_TOP; mCaptionSide = NS_SIDE_TOP;
mBorderSpacingX.Reset(); mBorderSpacingX.SetCoordValue(0);
mBorderSpacingY.Reset(); mBorderSpacingY.SetCoordValue(0);
} }
nsStyleTableBorder::~nsStyleTableBorder(void) nsStyleTableBorder::~nsStyleTableBorder(void)

View File

@ -4026,27 +4026,23 @@ nsTableFrame::GetBorderPadding(const nsSize& aBasis,
// XXX: could cache this. But be sure to check style changes if you do! // XXX: could cache this. But be sure to check style changes if you do!
nscoord nsTableFrame::GetCellSpacingX() nscoord nsTableFrame::GetCellSpacingX()
{ {
nscoord cellSpacing = 0; if (IsBorderCollapse())
if (!IsBorderCollapse()) { return 0;
const nsStyleTableBorder* tableStyle = GetStyleTableBorder();
if (tableStyle->mBorderSpacingX.GetUnit() == eStyleUnit_Coord) { NS_ASSERTION(GetStyleTableBorder()->mBorderSpacingX.GetUnit() == eStyleUnit_Coord,
cellSpacing = tableStyle->mBorderSpacingX.GetCoordValue(); "Not a coord value!");
} return GetStyleTableBorder()->mBorderSpacingX.GetCoordValue();
}
return cellSpacing;
} }
// XXX: could cache this. But be sure to check style changes if you do! // XXX: could cache this. But be sure to check style changes if you do!
nscoord nsTableFrame::GetCellSpacingY() nscoord nsTableFrame::GetCellSpacingY()
{ {
nscoord cellSpacing = 0; if (IsBorderCollapse())
if (!IsBorderCollapse()) { return 0;
const nsStyleTableBorder* tableStyle = GetStyleTableBorder();
if (tableStyle->mBorderSpacingY.GetUnit() == eStyleUnit_Coord) { NS_ASSERTION(GetStyleTableBorder()->mBorderSpacingY.GetUnit() == eStyleUnit_Coord,
cellSpacing = tableStyle->mBorderSpacingY.GetCoordValue(); "Not a coord value!");
} return GetStyleTableBorder()->mBorderSpacingY.GetCoordValue();
}
return cellSpacing;
} }
/* ----- global methods ----- */ /* ----- global methods ----- */

View File

@ -3841,24 +3841,14 @@ nsRuleNode::ComputeTableBorderData(nsStyleStruct* aStartStruct,
table->mBorderCollapse = parentTable->mBorderCollapse; table->mBorderCollapse = parentTable->mBorderCollapse;
} }
nsStyleCoord coord;
// border-spacing-x: length, inherit // border-spacing-x: length, inherit
if (SetCoord(tableData.mBorderSpacing.mXValue, coord, coord, SETCOORD_LENGTH, aContext, mPresContext, inherited)) { SetCoord(tableData.mBorderSpacing.mXValue, table->mBorderSpacingX,
table->mBorderSpacingX = coord.GetCoordValue(); parentTable->mBorderSpacingX, SETCOORD_LH,
} aContext, mPresContext, inherited);
else if (eCSSUnit_Inherit == tableData.mBorderSpacing.mXValue.GetUnit()) {
inherited = PR_TRUE;
table->mBorderSpacingX = parentTable->mBorderSpacingX;
}
// border-spacing-y: length, inherit // border-spacing-y: length, inherit
if (SetCoord(tableData.mBorderSpacing.mYValue, coord, coord, SETCOORD_LENGTH, aContext, mPresContext, inherited)) { SetCoord(tableData.mBorderSpacing.mYValue, table->mBorderSpacingY,
table->mBorderSpacingY = coord.GetCoordValue(); parentTable->mBorderSpacingY, SETCOORD_LH,
} aContext, mPresContext, inherited);
else if (eCSSUnit_Inherit == tableData.mBorderSpacing.mYValue.GetUnit()) {
inherited = PR_TRUE;
table->mBorderSpacingY = parentTable->mBorderSpacingY;
}
// caption-side: enum, inherit // caption-side: enum, inherit
if (eCSSUnit_Enumerated == tableData.mCaptionSide.GetUnit()) { if (eCSSUnit_Enumerated == tableData.mCaptionSide.GetUnit()) {

View File

@ -1101,8 +1101,8 @@ nsStyleTableBorder::nsStyleTableBorder(nsPresContext* aPresContext)
? NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND ? NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND
: NS_STYLE_TABLE_EMPTY_CELLS_SHOW; : NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
mCaptionSide = NS_SIDE_TOP; mCaptionSide = NS_SIDE_TOP;
mBorderSpacingX.Reset(); mBorderSpacingX.SetCoordValue(0);
mBorderSpacingY.Reset(); mBorderSpacingY.SetCoordValue(0);
} }
nsStyleTableBorder::~nsStyleTableBorder(void) nsStyleTableBorder::~nsStyleTableBorder(void)

View File

@ -4026,27 +4026,23 @@ nsTableFrame::GetBorderPadding(const nsSize& aBasis,
// XXX: could cache this. But be sure to check style changes if you do! // XXX: could cache this. But be sure to check style changes if you do!
nscoord nsTableFrame::GetCellSpacingX() nscoord nsTableFrame::GetCellSpacingX()
{ {
nscoord cellSpacing = 0; if (IsBorderCollapse())
if (!IsBorderCollapse()) { return 0;
const nsStyleTableBorder* tableStyle = GetStyleTableBorder();
if (tableStyle->mBorderSpacingX.GetUnit() == eStyleUnit_Coord) { NS_ASSERTION(GetStyleTableBorder()->mBorderSpacingX.GetUnit() == eStyleUnit_Coord,
cellSpacing = tableStyle->mBorderSpacingX.GetCoordValue(); "Not a coord value!");
} return GetStyleTableBorder()->mBorderSpacingX.GetCoordValue();
}
return cellSpacing;
} }
// XXX: could cache this. But be sure to check style changes if you do! // XXX: could cache this. But be sure to check style changes if you do!
nscoord nsTableFrame::GetCellSpacingY() nscoord nsTableFrame::GetCellSpacingY()
{ {
nscoord cellSpacing = 0; if (IsBorderCollapse())
if (!IsBorderCollapse()) { return 0;
const nsStyleTableBorder* tableStyle = GetStyleTableBorder();
if (tableStyle->mBorderSpacingY.GetUnit() == eStyleUnit_Coord) { NS_ASSERTION(GetStyleTableBorder()->mBorderSpacingY.GetUnit() == eStyleUnit_Coord,
cellSpacing = tableStyle->mBorderSpacingY.GetCoordValue(); "Not a coord value!");
} return GetStyleTableBorder()->mBorderSpacingY.GetCoordValue();
}
return cellSpacing;
} }
/* ----- global methods ----- */ /* ----- global methods ----- */