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;
}
nsStyleCoord coord;
// border-spacing-x: length, inherit
if (SetCoord(tableData.mBorderSpacing.mXValue, coord, coord, SETCOORD_LENGTH, aContext, mPresContext, inherited)) {
table->mBorderSpacingX = coord.GetCoordValue();
}
else if (eCSSUnit_Inherit == tableData.mBorderSpacing.mXValue.GetUnit()) {
inherited = PR_TRUE;
table->mBorderSpacingX = parentTable->mBorderSpacingX;
}
SetCoord(tableData.mBorderSpacing.mXValue, table->mBorderSpacingX,
parentTable->mBorderSpacingX, SETCOORD_LH,
aContext, mPresContext, inherited);
// border-spacing-y: length, inherit
if (SetCoord(tableData.mBorderSpacing.mYValue, coord, coord, SETCOORD_LENGTH, aContext, mPresContext, inherited)) {
table->mBorderSpacingY = coord.GetCoordValue();
}
else if (eCSSUnit_Inherit == tableData.mBorderSpacing.mYValue.GetUnit()) {
inherited = PR_TRUE;
table->mBorderSpacingY = parentTable->mBorderSpacingY;
}
SetCoord(tableData.mBorderSpacing.mYValue, table->mBorderSpacingY,
parentTable->mBorderSpacingY, SETCOORD_LH,
aContext, mPresContext, inherited);
// caption-side: enum, inherit
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;
mCaptionSide = NS_SIDE_TOP;
mBorderSpacingX.Reset();
mBorderSpacingY.Reset();
mBorderSpacingX.SetCoordValue(0);
mBorderSpacingY.SetCoordValue(0);
}
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!
nscoord nsTableFrame::GetCellSpacingX()
{
nscoord cellSpacing = 0;
if (!IsBorderCollapse()) {
const nsStyleTableBorder* tableStyle = GetStyleTableBorder();
if (tableStyle->mBorderSpacingX.GetUnit() == eStyleUnit_Coord) {
cellSpacing = tableStyle->mBorderSpacingX.GetCoordValue();
}
}
return cellSpacing;
if (IsBorderCollapse())
return 0;
NS_ASSERTION(GetStyleTableBorder()->mBorderSpacingX.GetUnit() == eStyleUnit_Coord,
"Not a coord value!");
return GetStyleTableBorder()->mBorderSpacingX.GetCoordValue();
}
// XXX: could cache this. But be sure to check style changes if you do!
nscoord nsTableFrame::GetCellSpacingY()
{
nscoord cellSpacing = 0;
if (!IsBorderCollapse()) {
const nsStyleTableBorder* tableStyle = GetStyleTableBorder();
if (tableStyle->mBorderSpacingY.GetUnit() == eStyleUnit_Coord) {
cellSpacing = tableStyle->mBorderSpacingY.GetCoordValue();
}
}
return cellSpacing;
if (IsBorderCollapse())
return 0;
NS_ASSERTION(GetStyleTableBorder()->mBorderSpacingY.GetUnit() == eStyleUnit_Coord,
"Not a coord value!");
return GetStyleTableBorder()->mBorderSpacingY.GetCoordValue();
}
/* ----- global methods ----- */

View File

@ -3841,24 +3841,14 @@ nsRuleNode::ComputeTableBorderData(nsStyleStruct* aStartStruct,
table->mBorderCollapse = parentTable->mBorderCollapse;
}
nsStyleCoord coord;
// border-spacing-x: length, inherit
if (SetCoord(tableData.mBorderSpacing.mXValue, coord, coord, SETCOORD_LENGTH, aContext, mPresContext, inherited)) {
table->mBorderSpacingX = coord.GetCoordValue();
}
else if (eCSSUnit_Inherit == tableData.mBorderSpacing.mXValue.GetUnit()) {
inherited = PR_TRUE;
table->mBorderSpacingX = parentTable->mBorderSpacingX;
}
SetCoord(tableData.mBorderSpacing.mXValue, table->mBorderSpacingX,
parentTable->mBorderSpacingX, SETCOORD_LH,
aContext, mPresContext, inherited);
// border-spacing-y: length, inherit
if (SetCoord(tableData.mBorderSpacing.mYValue, coord, coord, SETCOORD_LENGTH, aContext, mPresContext, inherited)) {
table->mBorderSpacingY = coord.GetCoordValue();
}
else if (eCSSUnit_Inherit == tableData.mBorderSpacing.mYValue.GetUnit()) {
inherited = PR_TRUE;
table->mBorderSpacingY = parentTable->mBorderSpacingY;
}
SetCoord(tableData.mBorderSpacing.mYValue, table->mBorderSpacingY,
parentTable->mBorderSpacingY, SETCOORD_LH,
aContext, mPresContext, inherited);
// caption-side: enum, inherit
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;
mCaptionSide = NS_SIDE_TOP;
mBorderSpacingX.Reset();
mBorderSpacingY.Reset();
mBorderSpacingX.SetCoordValue(0);
mBorderSpacingY.SetCoordValue(0);
}
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!
nscoord nsTableFrame::GetCellSpacingX()
{
nscoord cellSpacing = 0;
if (!IsBorderCollapse()) {
const nsStyleTableBorder* tableStyle = GetStyleTableBorder();
if (tableStyle->mBorderSpacingX.GetUnit() == eStyleUnit_Coord) {
cellSpacing = tableStyle->mBorderSpacingX.GetCoordValue();
}
}
return cellSpacing;
if (IsBorderCollapse())
return 0;
NS_ASSERTION(GetStyleTableBorder()->mBorderSpacingX.GetUnit() == eStyleUnit_Coord,
"Not a coord value!");
return GetStyleTableBorder()->mBorderSpacingX.GetCoordValue();
}
// XXX: could cache this. But be sure to check style changes if you do!
nscoord nsTableFrame::GetCellSpacingY()
{
nscoord cellSpacing = 0;
if (!IsBorderCollapse()) {
const nsStyleTableBorder* tableStyle = GetStyleTableBorder();
if (tableStyle->mBorderSpacingY.GetUnit() == eStyleUnit_Coord) {
cellSpacing = tableStyle->mBorderSpacingY.GetCoordValue();
}
}
return cellSpacing;
if (IsBorderCollapse())
return 0;
NS_ASSERTION(GetStyleTableBorder()->mBorderSpacingY.GetUnit() == eStyleUnit_Coord,
"Not a coord value!");
return GetStyleTableBorder()->mBorderSpacingY.GetCoordValue();
}
/* ----- global methods ----- */