From 739509e13ec870df126c18e54b0af89009efb27e Mon Sep 17 00:00:00 2001 From: "karnaze%netscape.com" Date: Sat, 6 Apr 2002 22:56:45 +0000 Subject: [PATCH] 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 --- layout/html/table/src/nsCellMap.cpp | 4 ++-- layout/html/table/src/nsTableFrame.cpp | 19 +++++++++++++++++++ layout/tables/nsCellMap.cpp | 4 ++-- layout/tables/nsTableFrame.cpp | 19 +++++++++++++++++++ 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/layout/html/table/src/nsCellMap.cpp b/layout/html/table/src/nsCellMap.cpp index 15704a74974c..3c0cd65fdc31 100644 --- a/layout/html/table/src/nsCellMap.cpp +++ b/layout/html/table/src/nsCellMap.cpp @@ -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(); diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp index 6bf77ec4f02b..315d33442e5f 100644 --- a/layout/html/table/src/nsTableFrame.cpp +++ b/layout/html/table/src/nsTableFrame.cpp @@ -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); diff --git a/layout/tables/nsCellMap.cpp b/layout/tables/nsCellMap.cpp index 15704a74974c..3c0cd65fdc31 100644 --- a/layout/tables/nsCellMap.cpp +++ b/layout/tables/nsCellMap.cpp @@ -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(); diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 6bf77ec4f02b..315d33442e5f 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -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);