bug 128876 - expanded border collapse damage area to include spanners. sr=roc, r=bernd, a=asa
git-svn-id: svn://10.0.0.236/trunk@116060 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1686,12 +1686,12 @@ void BasicTableLayoutStrategy::CalculateTotals(PRInt32* aTotalCounts,
|
||||
}
|
||||
|
||||
|
||||
struct nsColInfo {
|
||||
nsColInfo(nsTableColFrame* aFrame,
|
||||
PRInt32 aIndex,
|
||||
PRInt32 aMinWidth,
|
||||
PRInt32 aWidth,
|
||||
PRInt32 aMaxWidth)
|
||||
struct ColInfo {
|
||||
ColInfo(nsTableColFrame* aFrame,
|
||||
PRInt32 aIndex,
|
||||
PRInt32 aMinWidth,
|
||||
PRInt32 aWidth,
|
||||
PRInt32 aMaxWidth)
|
||||
: mFrame(aFrame), mIndex(aIndex), mMinWidth(aMinWidth),
|
||||
mWidth(aWidth), mMaxWidth(aMaxWidth), mWeight(0)
|
||||
{}
|
||||
@@ -1706,7 +1706,7 @@ struct nsColInfo {
|
||||
void
|
||||
AC_Wrapup(nsTableFrame* aTableFrame,
|
||||
PRInt32 aNumItems,
|
||||
nsColInfo** aColInfo,
|
||||
ColInfo** aColInfo,
|
||||
PRBool aAbort = PR_FALSE)
|
||||
{
|
||||
if (aColInfo) {
|
||||
@@ -1724,7 +1724,7 @@ AC_Wrapup(nsTableFrame* aTableFrame,
|
||||
|
||||
void
|
||||
AC_Increase(PRInt32 aNumAutoCols,
|
||||
nsColInfo** aColInfo,
|
||||
ColInfo** aColInfo,
|
||||
PRInt32 aDivisor,
|
||||
PRInt32& aAvailWidth,
|
||||
float aPixelToTwips)
|
||||
@@ -1753,7 +1753,7 @@ AC_Increase(PRInt32 aNumAutoCols,
|
||||
|
||||
void
|
||||
AC_Decrease(PRInt32 aNumAutoCols,
|
||||
nsColInfo** aColInfo,
|
||||
ColInfo** aColInfo,
|
||||
PRInt32 aDivisor,
|
||||
PRInt32& aExcess,
|
||||
float aPixelToTwips)
|
||||
@@ -1779,15 +1779,15 @@ AC_Decrease(PRInt32 aNumAutoCols,
|
||||
}
|
||||
|
||||
void
|
||||
AC_Sort(nsColInfo** aColInfo, PRInt32 aNumCols)
|
||||
AC_Sort(ColInfo** aColInfo, PRInt32 aNumCols)
|
||||
{
|
||||
// sort the cols based on the Weight
|
||||
for (PRInt32 j = aNumCols - 1; j > 0; j--) {
|
||||
for (PRInt32 i = 0; i < j; i++) {
|
||||
if (aColInfo[i]->mWeight < aColInfo[i+1]->mWeight) { // swap them
|
||||
nsColInfo* save = aColInfo[i];
|
||||
aColInfo[i] = aColInfo[i+1];
|
||||
aColInfo[i+1] = save;
|
||||
ColInfo* save = aColInfo[i];
|
||||
aColInfo[i] = aColInfo[i+1];
|
||||
aColInfo[i+1] = save;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1840,9 +1840,9 @@ void BasicTableLayoutStrategy::AllocateConstrained(PRInt32 aAvailWidth,
|
||||
}
|
||||
|
||||
// allocate storage for the constrained cols. Only they get adjusted.
|
||||
nsColInfo** colInfo = new nsColInfo*[numConstrainedCols];
|
||||
ColInfo** colInfo = new ColInfo*[numConstrainedCols];
|
||||
if (!colInfo) return;
|
||||
memset(colInfo, 0, numConstrainedCols * sizeof(nsColInfo *));
|
||||
memset(colInfo, 0, numConstrainedCols * sizeof(ColInfo *));
|
||||
|
||||
PRInt32 maxMinDiff = 0;
|
||||
PRInt32 constrColX = 0;
|
||||
@@ -1873,7 +1873,7 @@ void BasicTableLayoutStrategy::AllocateConstrained(PRInt32 aAvailWidth,
|
||||
maxWidth = PR_MAX(maxWidth, minWidth);
|
||||
maxMinDiff += maxWidth - minWidth;
|
||||
nscoord startWidth = (aStartAtMin) ? minWidth : maxWidth;
|
||||
colInfo[constrColX] = new nsColInfo(colFrame, colX, minWidth, startWidth, maxWidth);
|
||||
colInfo[constrColX] = new ColInfo(colFrame, colX, minWidth, startWidth, maxWidth);
|
||||
if (!colInfo[constrColX]) {
|
||||
AC_Wrapup(mTableFrame, numConstrainedCols, colInfo, PR_TRUE);
|
||||
return;
|
||||
|
||||
@@ -1741,8 +1741,9 @@ void nsCellMap::ShrinkWithoutCell(nsTableCellMap& aMap,
|
||||
// update the row and col info due to shifting
|
||||
for (rowX = aRowIndex; rowX <= endRowIndex; rowX++) {
|
||||
nsVoidArray* row = (nsVoidArray *)mRows.ElementAt(rowX);
|
||||
PRInt32 rowCount = row->Count();
|
||||
for (colX = aColIndex; colX < numCols - colSpan; colX++) {
|
||||
CellData* data = (CellData*) row->ElementAt(colX);
|
||||
CellData* data = (colX < rowCount) ? (CellData*)row->ElementAt(colX) : nsnull;
|
||||
if (data) {
|
||||
if (data->IsOrig()) {
|
||||
// a cell that gets moved to the left needs adjustment in its new location
|
||||
|
||||
@@ -4978,26 +4978,14 @@ BCMapCellIterator::First(BCMapCellInfo& aMapInfo)
|
||||
while (!mAtEnd) {
|
||||
if ((mAreaStart.y >= mRowGroupStart) && (mAreaStart.y <= mRowGroupEnd)) {
|
||||
CellData* cellData = mCellMap->GetDataAt(*mTableCellMap, mAreaStart.y - mRowGroupStart, mAreaStart.x, PR_FALSE);
|
||||
if (cellData) {
|
||||
if (!cellData->IsOrig()) {
|
||||
// if the start data does not have an originating cell, adjust it to have one
|
||||
if (cellData->IsRowSpan()) {
|
||||
mAreaStart.y -= cellData->GetRowSpanOffset();
|
||||
NS_ASSERTION(mAreaStart.y >= 0, "program error");
|
||||
}
|
||||
if (cellData->IsColSpan()) {
|
||||
mAreaStart.x -= cellData->GetColSpanOffset();
|
||||
NS_ASSERTION(mAreaStart.x >= 0, "program error");
|
||||
}
|
||||
cellData = mCellMap->GetDataAt(*mTableCellMap, mAreaStart.y - mRowGroupStart, mAreaStart.x, PR_FALSE);
|
||||
}
|
||||
if (cellData && cellData->IsOrig()) {
|
||||
SetInfo(mRow, mAreaStart.x, cellData, aMapInfo);
|
||||
break;
|
||||
}
|
||||
else mAtEnd = PR_TRUE;
|
||||
if (cellData && cellData->IsOrig()) {
|
||||
SetInfo(mRow, mAreaStart.x, cellData, aMapInfo);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(PR_FALSE, "damage area expanded incorrectly");
|
||||
mAtEnd = PR_TRUE;
|
||||
}
|
||||
else mAtEnd = PR_TRUE;
|
||||
}
|
||||
SetNewRowGroup(); // could set mAtEnd
|
||||
}
|
||||
@@ -5610,9 +5598,9 @@ nsTableFrame::ExpandBCDamageArea(nsRect& aRect) const
|
||||
// to rebuild versus expand. This could be optimized to expand to the smallest area that contains
|
||||
// no spanners, but it may not be worth the effort in general, and it would need to be done in the
|
||||
// cell map as well.
|
||||
PRBool haveSpanner = PR_FALSE;
|
||||
if ((dStartX > 0) || (dEndX < (numCols - 1)) || (dStartY > 0) || (dEndY < (numRows - 1))) {
|
||||
nsTableCellMap* tableCellMap = GetCellMap(); if (!tableCellMap) ABORT0();
|
||||
PRBool haveSpanner = PR_FALSE;
|
||||
// Get the ordered row groups
|
||||
PRUint32 numRowGroups;
|
||||
nsVoidArray rowGroups;
|
||||
@@ -5683,10 +5671,19 @@ nsTableFrame::ExpandBCDamageArea(nsRect& aRect) const
|
||||
}
|
||||
}
|
||||
}
|
||||
aRect.x = dStartX;
|
||||
aRect.y = dStartY;
|
||||
aRect.width = 1 + dEndX - dStartX;
|
||||
aRect.height = 1 + dEndY - dStartY;
|
||||
if (haveSpanner) {
|
||||
// make the damage area the whole table
|
||||
aRect.x = 0;
|
||||
aRect.y = 0;
|
||||
aRect.width = numCols;
|
||||
aRect.height = numRows;
|
||||
}
|
||||
else {
|
||||
aRect.x = dStartX;
|
||||
aRect.y = dStartY;
|
||||
aRect.width = 1 + dEndX - dStartX;
|
||||
aRect.height = 1 + dEndY - dStartY;
|
||||
}
|
||||
}
|
||||
|
||||
#define MAX_TABLE_BORDER_WIDTH 256
|
||||
|
||||
@@ -1686,12 +1686,12 @@ void BasicTableLayoutStrategy::CalculateTotals(PRInt32* aTotalCounts,
|
||||
}
|
||||
|
||||
|
||||
struct nsColInfo {
|
||||
nsColInfo(nsTableColFrame* aFrame,
|
||||
PRInt32 aIndex,
|
||||
PRInt32 aMinWidth,
|
||||
PRInt32 aWidth,
|
||||
PRInt32 aMaxWidth)
|
||||
struct ColInfo {
|
||||
ColInfo(nsTableColFrame* aFrame,
|
||||
PRInt32 aIndex,
|
||||
PRInt32 aMinWidth,
|
||||
PRInt32 aWidth,
|
||||
PRInt32 aMaxWidth)
|
||||
: mFrame(aFrame), mIndex(aIndex), mMinWidth(aMinWidth),
|
||||
mWidth(aWidth), mMaxWidth(aMaxWidth), mWeight(0)
|
||||
{}
|
||||
@@ -1706,7 +1706,7 @@ struct nsColInfo {
|
||||
void
|
||||
AC_Wrapup(nsTableFrame* aTableFrame,
|
||||
PRInt32 aNumItems,
|
||||
nsColInfo** aColInfo,
|
||||
ColInfo** aColInfo,
|
||||
PRBool aAbort = PR_FALSE)
|
||||
{
|
||||
if (aColInfo) {
|
||||
@@ -1724,7 +1724,7 @@ AC_Wrapup(nsTableFrame* aTableFrame,
|
||||
|
||||
void
|
||||
AC_Increase(PRInt32 aNumAutoCols,
|
||||
nsColInfo** aColInfo,
|
||||
ColInfo** aColInfo,
|
||||
PRInt32 aDivisor,
|
||||
PRInt32& aAvailWidth,
|
||||
float aPixelToTwips)
|
||||
@@ -1753,7 +1753,7 @@ AC_Increase(PRInt32 aNumAutoCols,
|
||||
|
||||
void
|
||||
AC_Decrease(PRInt32 aNumAutoCols,
|
||||
nsColInfo** aColInfo,
|
||||
ColInfo** aColInfo,
|
||||
PRInt32 aDivisor,
|
||||
PRInt32& aExcess,
|
||||
float aPixelToTwips)
|
||||
@@ -1779,15 +1779,15 @@ AC_Decrease(PRInt32 aNumAutoCols,
|
||||
}
|
||||
|
||||
void
|
||||
AC_Sort(nsColInfo** aColInfo, PRInt32 aNumCols)
|
||||
AC_Sort(ColInfo** aColInfo, PRInt32 aNumCols)
|
||||
{
|
||||
// sort the cols based on the Weight
|
||||
for (PRInt32 j = aNumCols - 1; j > 0; j--) {
|
||||
for (PRInt32 i = 0; i < j; i++) {
|
||||
if (aColInfo[i]->mWeight < aColInfo[i+1]->mWeight) { // swap them
|
||||
nsColInfo* save = aColInfo[i];
|
||||
aColInfo[i] = aColInfo[i+1];
|
||||
aColInfo[i+1] = save;
|
||||
ColInfo* save = aColInfo[i];
|
||||
aColInfo[i] = aColInfo[i+1];
|
||||
aColInfo[i+1] = save;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1840,9 +1840,9 @@ void BasicTableLayoutStrategy::AllocateConstrained(PRInt32 aAvailWidth,
|
||||
}
|
||||
|
||||
// allocate storage for the constrained cols. Only they get adjusted.
|
||||
nsColInfo** colInfo = new nsColInfo*[numConstrainedCols];
|
||||
ColInfo** colInfo = new ColInfo*[numConstrainedCols];
|
||||
if (!colInfo) return;
|
||||
memset(colInfo, 0, numConstrainedCols * sizeof(nsColInfo *));
|
||||
memset(colInfo, 0, numConstrainedCols * sizeof(ColInfo *));
|
||||
|
||||
PRInt32 maxMinDiff = 0;
|
||||
PRInt32 constrColX = 0;
|
||||
@@ -1873,7 +1873,7 @@ void BasicTableLayoutStrategy::AllocateConstrained(PRInt32 aAvailWidth,
|
||||
maxWidth = PR_MAX(maxWidth, minWidth);
|
||||
maxMinDiff += maxWidth - minWidth;
|
||||
nscoord startWidth = (aStartAtMin) ? minWidth : maxWidth;
|
||||
colInfo[constrColX] = new nsColInfo(colFrame, colX, minWidth, startWidth, maxWidth);
|
||||
colInfo[constrColX] = new ColInfo(colFrame, colX, minWidth, startWidth, maxWidth);
|
||||
if (!colInfo[constrColX]) {
|
||||
AC_Wrapup(mTableFrame, numConstrainedCols, colInfo, PR_TRUE);
|
||||
return;
|
||||
|
||||
@@ -1741,8 +1741,9 @@ void nsCellMap::ShrinkWithoutCell(nsTableCellMap& aMap,
|
||||
// update the row and col info due to shifting
|
||||
for (rowX = aRowIndex; rowX <= endRowIndex; rowX++) {
|
||||
nsVoidArray* row = (nsVoidArray *)mRows.ElementAt(rowX);
|
||||
PRInt32 rowCount = row->Count();
|
||||
for (colX = aColIndex; colX < numCols - colSpan; colX++) {
|
||||
CellData* data = (CellData*) row->ElementAt(colX);
|
||||
CellData* data = (colX < rowCount) ? (CellData*)row->ElementAt(colX) : nsnull;
|
||||
if (data) {
|
||||
if (data->IsOrig()) {
|
||||
// a cell that gets moved to the left needs adjustment in its new location
|
||||
|
||||
@@ -4978,26 +4978,14 @@ BCMapCellIterator::First(BCMapCellInfo& aMapInfo)
|
||||
while (!mAtEnd) {
|
||||
if ((mAreaStart.y >= mRowGroupStart) && (mAreaStart.y <= mRowGroupEnd)) {
|
||||
CellData* cellData = mCellMap->GetDataAt(*mTableCellMap, mAreaStart.y - mRowGroupStart, mAreaStart.x, PR_FALSE);
|
||||
if (cellData) {
|
||||
if (!cellData->IsOrig()) {
|
||||
// if the start data does not have an originating cell, adjust it to have one
|
||||
if (cellData->IsRowSpan()) {
|
||||
mAreaStart.y -= cellData->GetRowSpanOffset();
|
||||
NS_ASSERTION(mAreaStart.y >= 0, "program error");
|
||||
}
|
||||
if (cellData->IsColSpan()) {
|
||||
mAreaStart.x -= cellData->GetColSpanOffset();
|
||||
NS_ASSERTION(mAreaStart.x >= 0, "program error");
|
||||
}
|
||||
cellData = mCellMap->GetDataAt(*mTableCellMap, mAreaStart.y - mRowGroupStart, mAreaStart.x, PR_FALSE);
|
||||
}
|
||||
if (cellData && cellData->IsOrig()) {
|
||||
SetInfo(mRow, mAreaStart.x, cellData, aMapInfo);
|
||||
break;
|
||||
}
|
||||
else mAtEnd = PR_TRUE;
|
||||
if (cellData && cellData->IsOrig()) {
|
||||
SetInfo(mRow, mAreaStart.x, cellData, aMapInfo);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(PR_FALSE, "damage area expanded incorrectly");
|
||||
mAtEnd = PR_TRUE;
|
||||
}
|
||||
else mAtEnd = PR_TRUE;
|
||||
}
|
||||
SetNewRowGroup(); // could set mAtEnd
|
||||
}
|
||||
@@ -5610,9 +5598,9 @@ nsTableFrame::ExpandBCDamageArea(nsRect& aRect) const
|
||||
// to rebuild versus expand. This could be optimized to expand to the smallest area that contains
|
||||
// no spanners, but it may not be worth the effort in general, and it would need to be done in the
|
||||
// cell map as well.
|
||||
PRBool haveSpanner = PR_FALSE;
|
||||
if ((dStartX > 0) || (dEndX < (numCols - 1)) || (dStartY > 0) || (dEndY < (numRows - 1))) {
|
||||
nsTableCellMap* tableCellMap = GetCellMap(); if (!tableCellMap) ABORT0();
|
||||
PRBool haveSpanner = PR_FALSE;
|
||||
// Get the ordered row groups
|
||||
PRUint32 numRowGroups;
|
||||
nsVoidArray rowGroups;
|
||||
@@ -5683,10 +5671,19 @@ nsTableFrame::ExpandBCDamageArea(nsRect& aRect) const
|
||||
}
|
||||
}
|
||||
}
|
||||
aRect.x = dStartX;
|
||||
aRect.y = dStartY;
|
||||
aRect.width = 1 + dEndX - dStartX;
|
||||
aRect.height = 1 + dEndY - dStartY;
|
||||
if (haveSpanner) {
|
||||
// make the damage area the whole table
|
||||
aRect.x = 0;
|
||||
aRect.y = 0;
|
||||
aRect.width = numCols;
|
||||
aRect.height = numRows;
|
||||
}
|
||||
else {
|
||||
aRect.x = dStartX;
|
||||
aRect.y = dStartY;
|
||||
aRect.width = 1 + dEndX - dStartX;
|
||||
aRect.height = 1 + dEndY - dStartY;
|
||||
}
|
||||
}
|
||||
|
||||
#define MAX_TABLE_BORDER_WIDTH 256
|
||||
|
||||
Reference in New Issue
Block a user