limit search for real table cells to place where they can be expected, bug 313295 r/sr=bzbarsky

This commit is contained in:
bmlk%gmx.de 2005-11-04 18:41:32 +00:00
Родитель 1907c176b9
Коммит 6083aa28af
5 изменённых файлов: 39 добавлений и 30 удалений

Просмотреть файл

@ -768,13 +768,13 @@ nsTableCellMap::GetCellInfoAt(PRInt32 aRowIndex,
}
PRBool nsTableCellMap::RowIsSpannedInto(PRInt32 aRowIndex)
PRBool nsTableCellMap::RowIsSpannedInto(PRInt32 aRowIndex, PRInt32 aNumEffCols)
{
PRInt32 rowIndex = aRowIndex;
nsCellMap* cellMap = mFirstMap;
while (cellMap) {
if (cellMap->GetRowCount() > rowIndex) {
return cellMap->RowIsSpannedInto(*this, rowIndex);
return cellMap->RowIsSpannedInto(*this, rowIndex, aNumEffCols);
}
rowIndex -= cellMap->GetRowCount();
cellMap = cellMap->GetNextSibling();
@ -782,13 +782,14 @@ PRBool nsTableCellMap::RowIsSpannedInto(PRInt32 aRowIndex)
return PR_FALSE;
}
PRBool nsTableCellMap::RowHasSpanningCells(PRInt32 aRowIndex)
PRBool nsTableCellMap::RowHasSpanningCells(PRInt32 aRowIndex,
PRInt32 aNumEffCols)
{
PRInt32 rowIndex = aRowIndex;
nsCellMap* cellMap = mFirstMap;
while (cellMap) {
if (cellMap->GetRowCount() > rowIndex) {
return cellMap->RowHasSpanningCells(*this, rowIndex);
return cellMap->RowHasSpanningCells(*this, rowIndex, aNumEffCols);
}
rowIndex -= cellMap->GetRowCount();
cellMap = cellMap->GetNextSibling();
@ -2413,13 +2414,13 @@ nsCellMap::GetCellInfoAt(nsTableCellMap& aMap,
PRBool nsCellMap::RowIsSpannedInto(nsTableCellMap& aMap,
PRInt32 aRowIndex)
PRInt32 aRowIndex,
PRInt32 aNumEffCols)
{
PRInt32 numColsInTable = aMap.GetColCount();
if ((0 > aRowIndex) || (aRowIndex >= mRowCount)) {
return PR_FALSE;
}
for (PRInt32 colIndex = 0; colIndex < numColsInTable; colIndex++) {
for (PRInt32 colIndex = 0; colIndex < aNumEffCols; colIndex++) {
CellData* cd = GetDataAt(aMap, aRowIndex, colIndex, PR_TRUE);
if (cd) { // there's really a cell at (aRowIndex, colIndex)
if (cd->IsSpan()) { // the cell at (aRowIndex, colIndex) is the result of a span
@ -2433,15 +2434,15 @@ PRBool nsCellMap::RowIsSpannedInto(nsTableCellMap& aMap,
}
PRBool nsCellMap::RowHasSpanningCells(nsTableCellMap& aMap,
PRInt32 aRowIndex)
PRInt32 aRowIndex,
PRInt32 aNumEffCols)
{
PRInt32 numColsInTable = aMap.GetColCount();
if ((0 > aRowIndex) || (aRowIndex >= mRowCount)) {
return PR_FALSE;
}
if (aRowIndex != mRowCount - 1) {
// aRowIndex is not the last row, so we check the next row after aRowIndex for spanners
for (PRInt32 colIndex = 0; colIndex < numColsInTable; colIndex++) {
for (PRInt32 colIndex = 0; colIndex < aNumEffCols; colIndex++) {
CellData* cd = GetDataAt(aMap, aRowIndex, colIndex, PR_TRUE);
if (cd && (cd->IsOrig())) { // cell originates
CellData* cd2 = GetDataAt(aMap, aRowIndex + 1, colIndex, PR_TRUE);

Просмотреть файл

@ -160,8 +160,8 @@ public:
void AddColsAtEnd(PRUint32 aNumCols);
void RemoveColsAtEnd();
PRBool RowIsSpannedInto(PRInt32 aRowIndex);
PRBool RowHasSpanningCells(PRInt32 aRowIndex);
PRBool RowIsSpannedInto(PRInt32 aRowIndex, PRInt32 aNumEffCols);
PRBool RowHasSpanningCells(PRInt32 aRowIndex, PRInt32 aNumEffCols);
PRBool ColIsSpannedInto(PRInt32 aColIndex);
PRBool ColHasSpanningCells(PRInt32 aColIndex);
@ -312,10 +312,12 @@ public:
PRInt32* aColSpan = nsnull);
PRBool RowIsSpannedInto(nsTableCellMap& aMap,
PRInt32 aRowIndex);
PRInt32 aRowIndex,
PRInt32 aNumEffCols);
PRBool RowHasSpanningCells(nsTableCellMap& aMap,
PRInt32 aRowIndex);
PRInt32 aRowIndex,
PRInt32 aNumEffCols);
PRBool ColHasSpanningCells(nsTableCellMap& aMap,
PRInt32 aColIndex);

Просмотреть файл

@ -7537,24 +7537,24 @@ void nsTableFrame::DebugReflowDone(nsIFrame* aFrame)
#endif //DEBUG_TABLE_REFLOW_TIMING
PRBool nsTableFrame::RowHasSpanningCells(PRInt32 aRowIndex)
PRBool nsTableFrame::RowHasSpanningCells(PRInt32 aRowIndex, PRInt32 aNumEffCols)
{
PRBool result = PR_FALSE;
nsTableCellMap* cellMap = GetCellMap();
NS_PRECONDITION (cellMap, "bad call, cellMap not yet allocated.");
if (cellMap) {
result = cellMap->RowHasSpanningCells(aRowIndex);
result = cellMap->RowHasSpanningCells(aRowIndex, aNumEffCols);
}
return result;
}
PRBool nsTableFrame::RowIsSpannedInto(PRInt32 aRowIndex)
PRBool nsTableFrame::RowIsSpannedInto(PRInt32 aRowIndex, PRInt32 aNumEffCols)
{
PRBool result = PR_FALSE;
nsTableCellMap* cellMap = GetCellMap();
NS_PRECONDITION (cellMap, "bad call, cellMap not yet allocated.");
if (cellMap) {
result = cellMap->RowIsSpannedInto(aRowIndex);
result = cellMap->RowIsSpannedInto(aRowIndex, aNumEffCols);
}
return result;
}

Просмотреть файл

@ -698,12 +698,14 @@ public:
nsTableRowGroupFrame** aFoot = nsnull) const;
// Returns PR_TRUE if there are any cells above the row at
// aRowIndex and spanning into the row at aRowIndex
PRBool RowIsSpannedInto(PRInt32 aRowIndex);
// aRowIndex and spanning into the row at aRowIndex, the number of
// effective columns limits the search up to that column
PRBool RowIsSpannedInto(PRInt32 aRowIndex, PRInt32 aNumEffCols);
// Returns PR_TRUE if there is a cell originating in aRowIndex
// which spans into the next row
PRBool RowHasSpanningCells(PRInt32 aRowIndex);
// which spans into the next row, the number of effective
// columns limits the search up to that column
PRBool RowHasSpanningCells(PRInt32 aRowIndex, PRInt32 aNumEffCols);
// Returns PR_TRUE if there are any cells to the left of the column at
// aColIndex and spanning into the column at aColIndex

Просмотреть файл

@ -523,6 +523,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
float p2t;
p2t = aPresContext->PixelsToTwips();
PRInt32 numEffCols = tableFrame->GetEffectiveColCount();
// find the nearest row index at or before aStartRowFrameIn that isn't spanned into.
// If we have a computed height, then we can't compute the heights
@ -535,7 +536,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
}
else {
while (startRowIndex > rgStart) {
if (!tableFrame->RowIsSpannedInto(startRowIndex))
if (!tableFrame->RowIsSpannedInto(startRowIndex, numEffCols))
break;
startRowIndex--;
}
@ -607,7 +608,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
}
// See if a cell spans into the row. If so we'll have to do the next step
if (!hasRowSpanningCell) {
if (tableFrame->RowIsSpannedInto(rowIndex + startRowIndex)) {
if (tableFrame->RowIsSpannedInto(rowIndex + startRowIndex, numEffCols)) {
hasRowSpanningCell = PR_TRUE;
}
}
@ -620,7 +621,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
// See if the row has an originating cell with rowspan > 1. We cannot determine this for a row in a
// continued row group by calling RowHasSpanningCells, because the row's fif may not have any originating
// cells yet the row may have a continued cell which originates in it.
if (mPrevInFlow || tableFrame->RowHasSpanningCells(startRowIndex + rowIndex)) {
if (mPrevInFlow || tableFrame->RowHasSpanningCells(startRowIndex + rowIndex, numEffCols)) {
nsTableCellFrame* cellFrame = rowFrame->GetFirstCell();
// iteratate the row's cell frames
while (cellFrame) {
@ -1349,7 +1350,8 @@ nsTableRowGroupFrame::AppendFrames(nsIAtom* aListName,
// Reflow the new frames. They're already marked dirty, so generate a reflow
// command that tells us to reflow our dirty child frames
nsTableFrame::AppendDirtyReflowCommand(this);
if (tableFrame->RowIsSpannedInto(rowIndex)) {
if (tableFrame->RowIsSpannedInto(rowIndex, tableFrame->GetEffectiveColCount())) {
tableFrame->SetNeedStrategyInit(PR_TRUE);
}
else if (!tableFrame->IsAutoHeight()) {
@ -1406,8 +1408,9 @@ nsTableRowGroupFrame::InsertFrames(nsIAtom* aListName,
// Reflow the new frames. They're already marked dirty, so generate a reflow
// command that tells us to reflow our dirty child frames
nsTableFrame::AppendDirtyReflowCommand(this);
if (tableFrame->RowIsSpannedInto(rowIndex) ||
tableFrame->RowHasSpanningCells(rowIndex + numRows - 1)) {
PRInt32 numEffCols = tableFrame->GetEffectiveColCount();
if (tableFrame->RowIsSpannedInto(rowIndex, numEffCols) ||
tableFrame->RowHasSpanningCells(rowIndex + numRows - 1, numEffCols)) {
tableFrame->SetNeedStrategyInit(PR_TRUE);
}
else if (!tableFrame->IsAutoHeight()) {
@ -1580,8 +1583,9 @@ nsTableRowGroupFrame::IsSimpleRowFrame(nsTableFrame* aTableFrame,
// It's a simple row frame if there are no cells that span into or
// across the row
if (!aTableFrame->RowIsSpannedInto(rowIndex) &&
!aTableFrame->RowHasSpanningCells(rowIndex)) {
PRInt32 numEffCols = aTableFrame->GetEffectiveColCount();
if (!aTableFrame->RowIsSpannedInto(rowIndex, numEffCols) &&
!aTableFrame->RowHasSpanningCells(rowIndex, numEffCols)) {
return PR_TRUE;
}
}