bug 135112 - correctly set border collapse damage area and fix it if incorrect when borders are calculated. a=asa, adt=jaimejr, sr=attinasi, r=bernd

This commit is contained in:
karnaze%netscape.com 2002-04-06 22:56:45 +00:00
parent ece225e1cc
commit 739509e13e
4 changed files with 42 additions and 4 deletions

View File

@ -564,7 +564,7 @@ nsTableCellMap::InsertCells(nsVoidArray& aCellFrames,
cellMap->InsertCells(*this, aCellFrames, rowIndex, aColIndexBefore, aDamageArea);
nsTableRowGroupFrame* rg = cellMap->GetRowGroup();
aDamageArea.y += (rg) ? rg->GetStartRowIndex() : 0;
aDamageArea.width = PR_MAX(0, GetColCount() - aColIndexBefore);
aDamageArea.width = PR_MAX(0, GetColCount() - aColIndexBefore - 1);
break;
}
rowIndex -= cellMap->GetRowCount();
@ -591,7 +591,7 @@ nsTableCellMap::RemoveCell(nsTableCellFrame* aCellFrame,
aDamageArea.y += (rg) ? rg->GetStartRowIndex() : 0;
PRInt32 colIndex;
aCellFrame->GetColIndex(colIndex);
aDamageArea.width = PR_MAX(0, GetColCount() - colIndex);
aDamageArea.width = PR_MAX(0, GetColCount() - colIndex - 1);
break;
}
rowIndex -= cellMap->GetRowCount();

View File

@ -4824,6 +4824,22 @@ PRInt32 nsTableFrame::GetNumCellsOriginatingInRow(PRInt32 aRowIndex) const
return 0;
}
static void
CheckFixDamageArea(PRInt32 aNumRows,
PRInt32 aNumCols,
nsRect& aDamageArea)
{
if (((aDamageArea.XMost() > aNumCols) && (aDamageArea.width != 1) & (aNumCols != 0)) ||
((aDamageArea.YMost() > aNumRows) && (aDamageArea.height != 1) & (aNumRows != 0))) {
// the damage area was set incorrectly, just be safe and make it the entire table
NS_ASSERTION(PR_FALSE, "invalid BC damage area");
aDamageArea.x = 0;
aDamageArea.y = 0;
aDamageArea.width = aNumCols;
aDamageArea.height = aNumRows;
}
}
/********************************************************************************
* Collapsing Borders
*
@ -4855,6 +4871,7 @@ nsTableFrame::SetBCDamageArea(nsIPresContext& aPresContext,
if (value) {
// for now just construct a union of the new and old damage areas
value->mDamageArea.UnionRect(value->mDamageArea, newRect);
CheckFixDamageArea(GetRowCount(), GetColCount(), value->mDamageArea);
}
}
/*****************************************************************
@ -5926,6 +5943,8 @@ nsTableFrame::CalcBCBorders(nsIPresContext& aPresContext)
BCPropertyData* propData =
(BCPropertyData*)nsTableFrame::GetProperty(&aPresContext, this, nsLayoutAtoms::tableBCProperty, PR_FALSE);
if (!propData) ABORT0();
CheckFixDamageArea(numRows, numCols, propData->mDamageArea);
// calculate an expanded damage area
nsRect damageArea(propData->mDamageArea);
ExpandBCDamageArea(damageArea);

View File

@ -564,7 +564,7 @@ nsTableCellMap::InsertCells(nsVoidArray& aCellFrames,
cellMap->InsertCells(*this, aCellFrames, rowIndex, aColIndexBefore, aDamageArea);
nsTableRowGroupFrame* rg = cellMap->GetRowGroup();
aDamageArea.y += (rg) ? rg->GetStartRowIndex() : 0;
aDamageArea.width = PR_MAX(0, GetColCount() - aColIndexBefore);
aDamageArea.width = PR_MAX(0, GetColCount() - aColIndexBefore - 1);
break;
}
rowIndex -= cellMap->GetRowCount();
@ -591,7 +591,7 @@ nsTableCellMap::RemoveCell(nsTableCellFrame* aCellFrame,
aDamageArea.y += (rg) ? rg->GetStartRowIndex() : 0;
PRInt32 colIndex;
aCellFrame->GetColIndex(colIndex);
aDamageArea.width = PR_MAX(0, GetColCount() - colIndex);
aDamageArea.width = PR_MAX(0, GetColCount() - colIndex - 1);
break;
}
rowIndex -= cellMap->GetRowCount();

View File

@ -4824,6 +4824,22 @@ PRInt32 nsTableFrame::GetNumCellsOriginatingInRow(PRInt32 aRowIndex) const
return 0;
}
static void
CheckFixDamageArea(PRInt32 aNumRows,
PRInt32 aNumCols,
nsRect& aDamageArea)
{
if (((aDamageArea.XMost() > aNumCols) && (aDamageArea.width != 1) & (aNumCols != 0)) ||
((aDamageArea.YMost() > aNumRows) && (aDamageArea.height != 1) & (aNumRows != 0))) {
// the damage area was set incorrectly, just be safe and make it the entire table
NS_ASSERTION(PR_FALSE, "invalid BC damage area");
aDamageArea.x = 0;
aDamageArea.y = 0;
aDamageArea.width = aNumCols;
aDamageArea.height = aNumRows;
}
}
/********************************************************************************
* Collapsing Borders
*
@ -4855,6 +4871,7 @@ nsTableFrame::SetBCDamageArea(nsIPresContext& aPresContext,
if (value) {
// for now just construct a union of the new and old damage areas
value->mDamageArea.UnionRect(value->mDamageArea, newRect);
CheckFixDamageArea(GetRowCount(), GetColCount(), value->mDamageArea);
}
}
/*****************************************************************
@ -5926,6 +5943,8 @@ nsTableFrame::CalcBCBorders(nsIPresContext& aPresContext)
BCPropertyData* propData =
(BCPropertyData*)nsTableFrame::GetProperty(&aPresContext, this, nsLayoutAtoms::tableBCProperty, PR_FALSE);
if (!propData) ABORT0();
CheckFixDamageArea(numRows, numCols, propData->mDamageArea);
// calculate an expanded damage area
nsRect damageArea(propData->mDamageArea);
ExpandBCDamageArea(damageArea);