diff --git a/mozilla/layout/html/table/src/nsCellMap.cpp b/mozilla/layout/html/table/src/nsCellMap.cpp
index 1dd660e64a8..57c0734c953 100644
--- a/mozilla/layout/html/table/src/nsCellMap.cpp
+++ b/mozilla/layout/html/table/src/nsCellMap.cpp
@@ -26,7 +26,6 @@
#include "nsTableFrame.h"
#include "nsTableCellFrame.h"
-#define kIsCollapsedRowsGrowSize 5
// CellData
MOZ_DECL_CTOR_COUNTER(CellData);
@@ -60,17 +59,10 @@ MOZ_DECL_CTOR_COUNTER(nsCellMap);
// nsCellMap
nsCellMap::nsCellMap(int aRowCount, int aColCount)
- : mIsCollapsedRowsSize(0),
- mNumCollapsedRows(0),
- mNumCollapsedCols(0),
- mRowCount(0),
+ : mRowCount(0),
mNextAvailRowIndex(0)
{
MOZ_COUNT_CTOR(nsCellMap);
-
- mIsCollapsedRows = nsnull;
- mIsCollapsedCols = nsnull;
-
Grow(aRowCount, aColCount);
}
@@ -97,18 +89,7 @@ nsCellMap::~nsCellMap()
delete colInfo;
}
}
-
- if (nsnull != mIsCollapsedRows) {
- delete [] mIsCollapsedRows;
- mIsCollapsedRows = nsnull;
- mNumCollapsedRows = 0;
- }
- if (nsnull != mIsCollapsedCols) {
- delete [] mIsCollapsedCols;
- mIsCollapsedCols = nsnull;
- mNumCollapsedCols = 0;
- }
-};
+}
void nsCellMap::AddColsAtEnd(PRUint32 aNumCols)
{
@@ -454,9 +435,6 @@ nsCellMap::CreateEmptyRow(PRInt32 aRowIndex,
}
mRows.InsertElementAt(row, aRowIndex);
- if(mIsCollapsedRows) {
- InsertIntoCollapsedRows(aRowIndex);
- }
return PR_TRUE;
}
@@ -626,9 +604,6 @@ void nsCellMap::ShrinkWithoutRows(PRInt32 aStartRowIndex,
mRows.RemoveElementAt(rowX);
delete row;
- if(mIsCollapsedRows) {
- RemoveFromCollapsedRows(rowX);
- }
// Decrement our row and next available index counts.
mRowCount--;
@@ -1145,118 +1120,6 @@ nsTableCellFrame* nsCellMap::GetCellInfoAt(PRInt32 aRowX,
return cellFrame;
}
-PRInt32 nsCellMap::GetNumCollapsedRows() const
-{
- return mNumCollapsedRows;
-}
-
-PRBool nsCellMap::IsRowCollapsedAt(PRInt32 aRow) const
-{
- if ((aRow >= 0) && (aRow < mRowCount)) {
- if (mIsCollapsedRows) {
- return mIsCollapsedRows[aRow];
- }
- }
- return PR_FALSE;
-}
-
-void nsCellMap::SetRowCollapsedAt(PRInt32 aRow, PRBool aValue)
-{
- if ((aRow >= 0) && (aRow < mRowCount)) {
- if (nsnull == mIsCollapsedRows) {
- mIsCollapsedRows = new PRPackedBool[mRowCount];
- mIsCollapsedRowsSize = mRowCount;
- for (PRInt32 i = 0; i < mRowCount; i++) {
- mIsCollapsedRows[i] = PR_FALSE;
- }
- }
- if (mIsCollapsedRows[aRow] != aValue) {
- if (PR_TRUE == aValue) {
- mNumCollapsedRows++;
- } else {
- mNumCollapsedRows--;
- }
- mIsCollapsedRows[aRow] = aValue;
- }
- }
-}
-
-void nsCellMap::InsertIntoCollapsedRows(PRInt32 aRow)
-{
- if (mIsCollapsedRows) {
- if ((mRowCount + 1) > mIsCollapsedRowsSize){
- PRInt32 newSize = mRowCount + kIsCollapsedRowsGrowSize;
- PRPackedBool * newIsCollapsedRows = new PRPackedBool[newSize];
- if(!newIsCollapsedRows)
- return;
- if(aRow != 0)
- nsCRT::memcpy(newIsCollapsedRows, mIsCollapsedRows, aRow * sizeof (PRPackedBool));
- if(aRow != mRowCount)
- nsCRT::memcpy(newIsCollapsedRows + aRow + 1, mIsCollapsedRows + aRow,
- (mRowCount - aRow) * sizeof(PRPackedBool));
-
- delete[] mIsCollapsedRows;
- mIsCollapsedRows = newIsCollapsedRows;
- mIsCollapsedRowsSize = newSize;
- }
- else {
- if(aRow != mRowCount)
- nsCRT::memmove(mIsCollapsedRows + aRow + 1, mIsCollapsedRows + aRow,
- (mRowCount - aRow) * sizeof(PRPackedBool));
- }
- mIsCollapsedRows[aRow] = PR_FALSE;
- }
-}
-
-void nsCellMap::RemoveFromCollapsedRows(PRInt32 aRow)
-{
- //If the row we're removing was collapsed, decrement mNumCollapsedRows
- if(mIsCollapsedRows[aRow])
- mNumCollapsedRows--;
-
- //Don't need to move if last element in array
- if(aRow < (mRowCount - 1))
- nsCRT::memmove(mIsCollapsedRows + aRow, mIsCollapsedRows + aRow + 1,
- (mRowCount - 1 - aRow) * sizeof(PRPackedBool));
-
-}
-
-PRInt32 nsCellMap::GetNumCollapsedCols() const
-{
- return mNumCollapsedCols;
-}
-
-PRBool nsCellMap::IsColCollapsedAt(PRInt32 aCol) const
-{
- PRInt32 colCount = mCols.Count();
- if ((aCol >= 0) && (aCol < colCount)) {
- if (mIsCollapsedCols) {
- return mIsCollapsedCols[aCol];
- }
- }
- return PR_FALSE;
-}
-
-void nsCellMap::SetColCollapsedAt(PRInt32 aCol, PRBool aValue)
-{
- PRInt32 colCount = mCols.Count();
- if ((aCol >= 0) && (aCol < colCount)) {
- if (nsnull == mIsCollapsedCols) {
- mIsCollapsedCols = new PRPackedBool[colCount];
- for (PRInt32 i = 0; i < colCount; i++) {
- mIsCollapsedCols[i] = PR_FALSE;
- }
- }
- if (mIsCollapsedCols[aCol] != aValue) {
- if (PR_TRUE == aValue) {
- mNumCollapsedCols++;
- } else {
- mNumCollapsedCols--;
- }
- mIsCollapsedCols[aCol] = aValue;
- }
- }
-}
PRBool nsCellMap::RowIsSpannedInto(PRInt32 aRowIndex) const
{
@@ -1351,15 +1214,6 @@ void nsCellMap::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
mCols.SizeOf(aHandler, &voidArraySize);
sum += voidArraySize - sizeof(mCols);
- // Add in the size of the collapsed rows and collapsed column
- // packed bool arrays
- if (mIsCollapsedRows) {
- sum += mRowCount * sizeof(PRPackedBool);
- }
- if (mIsCollapsedCols) {
- sum += mCols.Count() * sizeof(PRPackedBool);
- }
-
*aResult = sum;
}
#endif
diff --git a/mozilla/layout/html/table/src/nsCellMap.h b/mozilla/layout/html/table/src/nsCellMap.h
index 4d84149c90a..5670d30aa7f 100644
--- a/mozilla/layout/html/table/src/nsCellMap.h
+++ b/mozilla/layout/html/table/src/nsCellMap.h
@@ -29,11 +29,6 @@ class nsTableColFrame;
class nsTableCellFrame;
class nsIPresContext;
-// XXX the collapsing row and col data structures need to be moved
-// into nsTableFrame. Collapsing cols are broken due to the recent
-// incremental cell map methods which don't attempt to update
-// collapsing col info here.
-
struct nsColInfo
{
PRInt32 mNumCellsOrig; // number of cells originating in the col
@@ -108,16 +103,6 @@ public:
PRInt32 GetNumCellsOriginatingInRow(PRInt32 aRowIndex) const;
PRInt32 GetNumCellsOriginatingInCol(PRInt32 aColIndex) const;
- PRInt32 GetNumCollapsedRows() const;
- PRBool IsRowCollapsedAt(PRInt32 aRowIndex) const;
- void SetRowCollapsedAt(PRInt32 aRowIndex,
- PRBool aValue);
-
- PRInt32 GetNumCollapsedCols() const;
- PRBool IsColCollapsedAt(PRInt32 aColIndex) const;
- void SetColCollapsedAt(PRInt32 aColIndex,
- PRBool aValue);
-
/** return the total number of columns in the table represented by this CellMap */
PRInt32 GetColCount() const;
@@ -155,11 +140,6 @@ protected:
void Grow(PRInt32 aNumMapRows,
PRInt32 aNumCols);
- /** insert a new entry into the mIsCollapsedRows */
- void InsertIntoCollapsedRows(PRInt32 aRow);
- /** remove an entry from mIsCollapsedRows */
- void RemoveFromCollapsedRows(PRInt32 aRow);
-
/** assign aCellData to the cell at (aRow,aColumn) */
void SetMapCellAt(CellData& aCellData,
PRInt32 aMapRowIndex,
@@ -211,16 +191,6 @@ protected:
* cells originating and spanning each col. */
nsVoidArray mCols;
- // an array of booleans where the ith element indicates if the ith row is collapsed
- PRPackedBool* mIsCollapsedRows;
- PRInt32 mIsCollapsedRowsSize;
- PRInt32 mNumCollapsedRows;
-
-
- // an array of booleans where the ith element indicates if the ith col is collapsed
- PRPackedBool* mIsCollapsedCols;
- PRInt32 mNumCollapsedCols;
-
/** the number of rows in the table which is <= the number of rows in the cell map
* due to row spans extending beyond the end of the table (dead rows) */
PRInt32 mRowCount;
diff --git a/mozilla/layout/html/table/src/nsTableColFrame.cpp b/mozilla/layout/html/table/src/nsTableColFrame.cpp
index e4cceb6f942..55bea8a6e68 100644
--- a/mozilla/layout/html/table/src/nsTableColFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableColFrame.cpp
@@ -30,12 +30,16 @@
#include "nsHTMLAtoms.h"
#include "nsCSSRendering.h"
#include "nsLayoutAtoms.h"
+#include "nsIContent.h"
+#include "nsIDOMHTMLTableColElement.h"
#define COL_TYPE_CONTENT 0x0
#define COL_TYPE_ANONYMOUS_COL 0x1
#define COL_TYPE_ANONYMOUS_COLGROUP 0x2
#define COL_TYPE_ANONYMOUS_CELL 0x3
+static NS_DEFINE_IID(kIDOMHTMLTableColElementIID, NS_IDOMHTMLTABLECOLELEMENT_IID);
+
nsTableColFrame::nsTableColFrame()
: nsFrame(),
mProportion(WIDTH_NOT_SET),
@@ -145,6 +149,7 @@ NS_METHOD nsTableColFrame::Reflow(nsIPresContext* aPresContext,
PRInt32 nsTableColFrame::GetSpan()
{
+ PRInt32 span = 1;
const nsStyleTable* tableStyle;
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
return tableStyle->mSpan;
diff --git a/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp
index 00ed27bcb09..8db871e7b85 100644
--- a/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp
@@ -656,7 +656,7 @@ nsTableColFrame * nsTableColGroupFrame::GetColumnAt (PRInt32 aColIndex)
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
if (NS_STYLE_DISPLAY_TABLE_COLUMN == childDisplay->mDisplay) {
nsTableColFrame *col = (nsTableColFrame *)childFrame;
- count += col->GetSpan();
+ count++;
if (aColIndex<=count) {
result = col;
}
diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp
index 199efa39f3b..df140c11dae 100644
--- a/mozilla/layout/html/table/src/nsTableFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableFrame.cpp
@@ -1885,41 +1885,11 @@ void nsTableFrame::ComputePercentBasisForRows(const nsHTMLReflowState& aReflowSt
mPercentBasisForRows = height;
}
-// collapsing row groups, rows, col groups and cols are accounted for after both passes of
-// reflow so that it has no effect on the calculations of reflow.
-NS_METHOD nsTableFrame::AdjustForCollapsingRowGroup(nsIFrame* aRowGroupFrame,
- PRInt32& aRowX)
-{
- nsCellMap* cellMap = GetCellMap(); // XXX is this right
- const nsStyleDisplay* groupDisplay;
- aRowGroupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
- PRBool groupIsCollapsed = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
-
- nsTableRowFrame* rowFrame = nsnull;
- aRowGroupFrame->FirstChild(nsnull, (nsIFrame**)&rowFrame);
- while (nsnull != rowFrame) {
- const nsStyleDisplay *rowDisplay;
- rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
- if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
- if (groupIsCollapsed || (NS_STYLE_VISIBILITY_COLLAPSE == rowDisplay->mVisible)) {
- cellMap->SetRowCollapsedAt(aRowX, PR_TRUE);
- }
- aRowX++;
- }
- else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {
- AdjustForCollapsingRowGroup(rowFrame, aRowX);
- }
-
- rowFrame->GetNextSibling((nsIFrame**)&rowFrame);
- }
-
- return NS_OK;
-}
-
-NS_METHOD nsTableFrame::CollapseRowGroup(nsIPresContext* aPresContext,
- nsIFrame* aRowGroupFrame,
- const nscoord& aYTotalOffset,
- nscoord& aYGroupOffset, PRInt32& aRowX)
+NS_METHOD
+nsTableFrame::CollapseRowGroupIfNecessary(nsIPresContext* aPresContext,
+ nsIFrame* aRowGroupFrame,
+ const nscoord& aYTotalOffset,
+ nscoord& aYGroupOffset, PRInt32& aRowX)
{
const nsStyleDisplay* groupDisplay;
aRowGroupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
@@ -1932,7 +1902,7 @@ NS_METHOD nsTableFrame::CollapseRowGroup(nsIPresContext* aPresContext,
const nsStyleDisplay* rowDisplay;
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {
- CollapseRowGroup(aPresContext, rowFrame, aYTotalOffset, aYGroupOffset, aRowX);
+ CollapseRowGroupIfNecessary(aPresContext, rowFrame, aYTotalOffset, aYGroupOffset, aRowX);
}
else if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
nsRect rowRect;
@@ -1995,42 +1965,27 @@ NS_METHOD nsTableFrame::CollapseRowGroup(nsIPresContext* aPresContext,
return NS_OK;
}
+// collapsing row groups, rows, col groups and cols are accounted for after both passes of
+// reflow so that it has no effect on the calculations of reflow.
NS_METHOD nsTableFrame::AdjustForCollapsingRows(nsIPresContext* aPresContext,
nscoord& aHeight)
{
- // determine which row groups and rows are collapsed
- PRInt32 rowX = 0;
- nsIFrame* childFrame;
- FirstChild(nsnull, &childFrame);
- while (nsnull != childFrame) {
- const nsStyleDisplay* groupDisplay;
- childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
- if (IsRowGroup(groupDisplay->mDisplay)) {
- AdjustForCollapsingRowGroup(childFrame, rowX);
- }
- childFrame->GetNextSibling(&childFrame);
- }
-
- if (mCellMap->GetNumCollapsedRows() <= 0) {
- return NS_OK; // no collapsed rows, we're done
- }
-
- // collapse the rows and/or row groups
nsIFrame* groupFrame = mFrames.FirstChild();
nscoord yGroupOffset = 0; // total offset among rows within a single row group
nscoord yTotalOffset = 0; // total offset among all rows in all row groups
- rowX = 0;
-
+ PRInt32 rowIndex = 0;
+
+ // collapse the rows and/or row groups as necessary
while (nsnull != groupFrame) {
const nsStyleDisplay* groupDisplay;
groupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
if (IsRowGroup(groupDisplay->mDisplay)) {
- CollapseRowGroup(aPresContext, groupFrame, yTotalOffset, yGroupOffset, rowX);
+ CollapseRowGroupIfNecessary(aPresContext, groupFrame, yTotalOffset, yGroupOffset, rowIndex);
}
yTotalOffset += yGroupOffset;
yGroupOffset = 0;
groupFrame->GetNextSibling(&groupFrame);
- } // end group frame while
+ }
aHeight -= yTotalOffset;
@@ -2040,93 +1995,63 @@ NS_METHOD nsTableFrame::AdjustForCollapsingRows(nsIPresContext* aPresContext,
NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext* aPresContext,
nscoord& aWidth)
{
- // determine which col groups and cols are collapsed
- nsIFrame* childFrame = mColGroups.FirstChild();
- PRInt32 numCols = 0;
- while (nsnull != childFrame) {
- const nsStyleDisplay* groupDisplay;
- GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
- PRBool groupIsCollapsed = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
-
- nsTableColFrame* colFrame = nsnull;
- childFrame->FirstChild(nsnull, (nsIFrame**)&colFrame);
- while (nsnull != colFrame) {
- const nsStyleDisplay *colDisplay;
- colFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)colDisplay));
- if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay) {
- if (groupIsCollapsed || (NS_STYLE_VISIBILITY_COLLAPSE == colDisplay->mVisible)) {
- mCellMap->SetColCollapsedAt(numCols, PR_TRUE);
- }
- numCols++;
- }
- colFrame->GetNextSibling((nsIFrame**)&colFrame);
- }
- childFrame->GetNextSibling(&childFrame);
- }
-
- if (mCellMap->GetNumCollapsedCols() <= 0) {
- return NS_OK; // no collapsed cols, we're done
- }
-
- // collapse the cols and/or col groups
PRInt32 numRows = mCellMap->GetRowCount();
nsTableIterator groupIter(mColGroups, eTableDIR);
nsIFrame* groupFrame = groupIter.First();
nscoord cellSpacingX = GetCellSpacingX();
nscoord xOffset = 0;
- PRInt32 colX = (groupIter.IsLeftToRight()) ? 0 : numCols - 1;
+ PRInt32 colX = (groupIter.IsLeftToRight()) ? 0 : GetColCount() - 1;
PRInt32 direction = (groupIter.IsLeftToRight()) ? 1 : -1;
+ // iterate over the col groups
while (nsnull != groupFrame) {
const nsStyleDisplay* groupDisplay;
groupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
nsTableIterator colIter(*groupFrame, eTableDIR);
nsIFrame* colFrame = colIter.First();
+ // iterate over the cols in the col group
while (nsnull != colFrame) {
const nsStyleDisplay* colDisplay;
colFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)colDisplay));
if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay) {
PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colDisplay->mVisible);
- PRInt32 colSpan = ((nsTableColFrame*)colFrame)->GetSpan();
- for (PRInt32 spanX = 0; spanX < colSpan; spanX++) {
- PRInt32 col2X = colX + (direction * spanX);
- PRInt32 colWidth = GetColumnWidth(col2X);
- if (collapseGroup || collapseCol) {
- xOffset += colWidth + cellSpacingX;
- }
- nsTableCellFrame* lastCell = nsnull;
- nsTableCellFrame* cellFrame = nsnull;
- for (PRInt32 rowX = 0; rowX < numRows; rowX++) {
- CellData* cellData = mCellMap->GetCellAt(rowX, col2X);
- nsRect cellRect;
- if (cellData) {
- cellFrame = cellData->mOrigCell;
- if (cellFrame) { // the cell originates at (rowX, colX)
- cellFrame->GetRect(cellRect);
- if (collapseGroup || collapseCol) {
- if (lastCell != cellFrame) { // do it only once if there is a row span
- cellRect.width -= colWidth;
- cellFrame->SetCollapseOffsetX(aPresContext, -xOffset);
- }
- } else { // the cell is not in a collapsed col but needs to move
- cellRect.x -= xOffset;
+ PRInt32 colWidth = GetColumnWidth(colX);
+ if (collapseGroup || collapseCol) {
+ xOffset += colWidth + cellSpacingX;
+ }
+ nsTableCellFrame* lastCell = nsnull;
+ nsTableCellFrame* cellFrame = nsnull;
+ for (PRInt32 rowX = 0; rowX < numRows; rowX++) {
+ CellData* cellData = mCellMap->GetCellAt(rowX, colX);
+ nsRect cellRect;
+ if (cellData) {
+ cellFrame = cellData->mOrigCell;
+ if (cellFrame) { // the cell originates at (rowX, colX)
+ cellFrame->GetRect(cellRect);
+ if (collapseGroup || collapseCol) {
+ if (lastCell != cellFrame) { // do it only once if there is a row span
+ cellRect.width -= colWidth;
+ cellFrame->SetCollapseOffsetX(aPresContext, -xOffset);
}
- cellFrame->SetRect(aPresContext, cellRect);
+ } else { // the cell is not in a collapsed col but needs to move
+ cellRect.x -= xOffset;
+ }
+ cellFrame->SetRect(aPresContext, cellRect);
// if the cell does not originate at (rowX, colX), adjust the real cells width
- } else if (collapseGroup || collapseCol) {
- if (cellData->mColSpanData)
- cellFrame = cellData->mColSpanData->mOrigCell;
- if ((cellFrame) && (lastCell != cellFrame)) {
- cellFrame->GetRect(cellRect);
- cellRect.width -= colWidth + cellSpacingX;
- cellFrame->SetRect(aPresContext, cellRect);
- }
+ } else if (collapseGroup || collapseCol) {
+ if (cellData->mColSpanData) {
+ cellFrame = cellData->mColSpanData->mOrigCell;
+ }
+ if ((cellFrame) && (lastCell != cellFrame)) {
+ cellFrame->GetRect(cellRect);
+ cellRect.width -= colWidth + cellSpacingX;
+ cellFrame->SetRect(aPresContext, cellRect);
}
}
- lastCell = cellFrame;
}
+ lastCell = cellFrame;
}
- colX += direction * colSpan;
+ colX += direction;
}
colFrame = colIter.Next();
} // inner while
@@ -3557,42 +3482,9 @@ void nsTableFrame::AdjustColumnsForCOLSAttribute()
}
-/* there's an easy way and a hard way. The easy way is to look in our
- * cache and pull the frame from there.
- * If the cache isn't built yet, then we have to go hunting.
- */
NS_METHOD nsTableFrame::GetColumnFrame(PRInt32 aColIndex, nsTableColFrame *&aColFrame)
{
- aColFrame = nsnull; // initialize out parameter
- nsCellMap *cellMap = GetCellMap();
- if (nsnull!=cellMap)
- { // hooray, we get to do this the easy way because the info is cached
- aColFrame = (nsTableColFrame *)mColFrames.ElementAt(aColIndex);
- }
- // XXX this should go away with the new synchronized col cache.
- else
- { // ah shucks, we have to go hunt for the column frame brute-force style
- nsIFrame *childFrame = mColGroups.FirstChild();
- for (;;)
- {
- if (nsnull==childFrame)
- {
- NS_ASSERTION (PR_FALSE, "scanned the frame hierarchy and no column frame could be found.");
- break;
- }
- PRInt32 colGroupStartingIndex = ((nsTableColGroupFrame *)childFrame)->GetStartColumnIndex();
- if (aColIndex >= colGroupStartingIndex)
- { // the cell's col might be in this col group
- PRInt32 colCount = ((nsTableColGroupFrame *)childFrame)->GetColCount();
- if (aColIndex < colGroupStartingIndex + colCount)
- { // yep, we've found it. GetColumnAt gives us the column at the offset colCount, not the absolute colIndex for the whole table
- aColFrame = ((nsTableColGroupFrame *)childFrame)->GetColumnAt(colCount);
- break;
- }
- }
- childFrame->GetNextSibling(&childFrame);
- }
- }
+ aColFrame = (nsTableColFrame *)mColFrames.ElementAt(aColIndex);
return NS_OK;
}
diff --git a/mozilla/layout/html/table/src/nsTableFrame.h b/mozilla/layout/html/table/src/nsTableFrame.h
index 19b98f36950..c444d34d270 100644
--- a/mozilla/layout/html/table/src/nsTableFrame.h
+++ b/mozilla/layout/html/table/src/nsTableFrame.h
@@ -527,13 +527,10 @@ protected:
nsIFrame* aKidFrame,
nsSize* aMaxElementSize);
- NS_METHOD AdjustForCollapsingRowGroup(nsIFrame* aRowGroupFrame,
- PRInt32& aRowX);
-
- NS_METHOD CollapseRowGroup(nsIPresContext* aPresContext,
- nsIFrame* aRowGroupFrame,
- const nscoord& aYTotalOffset,
- nscoord& aYGroupOffset, PRInt32& aRowX);
+ NS_METHOD CollapseRowGroupIfNecessary(nsIPresContext* aPresContext,
+ nsIFrame* aRowGroupFrame,
+ const nscoord& aYTotalOffset,
+ nscoord& aYGroupOffset, PRInt32& aRowX);
NS_METHOD AdjustForCollapsingRows(nsIPresContext* aPresContext,
nscoord& aHeight);
diff --git a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp
index 0fd47dc9301..17b3b0965d7 100644
--- a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp
@@ -602,7 +602,7 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext* aPresContext,
rowHeights = new nscoord[numRows];
if (!rowHeights) return;
nsCRT::memset (rowHeights, 0, numRows*sizeof(nscoord));
- }
+ } // else - tree row groups need not have rows directly beneath them
/* Step 1: get the height of the tallest cell in the row and save it for
* pass 2. This height is for table cells that originate in this
diff --git a/mozilla/layout/tables/nsCellMap.cpp b/mozilla/layout/tables/nsCellMap.cpp
index 1dd660e64a8..57c0734c953 100644
--- a/mozilla/layout/tables/nsCellMap.cpp
+++ b/mozilla/layout/tables/nsCellMap.cpp
@@ -26,7 +26,6 @@
#include "nsTableFrame.h"
#include "nsTableCellFrame.h"
-#define kIsCollapsedRowsGrowSize 5
// CellData
MOZ_DECL_CTOR_COUNTER(CellData);
@@ -60,17 +59,10 @@ MOZ_DECL_CTOR_COUNTER(nsCellMap);
// nsCellMap
nsCellMap::nsCellMap(int aRowCount, int aColCount)
- : mIsCollapsedRowsSize(0),
- mNumCollapsedRows(0),
- mNumCollapsedCols(0),
- mRowCount(0),
+ : mRowCount(0),
mNextAvailRowIndex(0)
{
MOZ_COUNT_CTOR(nsCellMap);
-
- mIsCollapsedRows = nsnull;
- mIsCollapsedCols = nsnull;
-
Grow(aRowCount, aColCount);
}
@@ -97,18 +89,7 @@ nsCellMap::~nsCellMap()
delete colInfo;
}
}
-
- if (nsnull != mIsCollapsedRows) {
- delete [] mIsCollapsedRows;
- mIsCollapsedRows = nsnull;
- mNumCollapsedRows = 0;
- }
- if (nsnull != mIsCollapsedCols) {
- delete [] mIsCollapsedCols;
- mIsCollapsedCols = nsnull;
- mNumCollapsedCols = 0;
- }
-};
+}
void nsCellMap::AddColsAtEnd(PRUint32 aNumCols)
{
@@ -454,9 +435,6 @@ nsCellMap::CreateEmptyRow(PRInt32 aRowIndex,
}
mRows.InsertElementAt(row, aRowIndex);
- if(mIsCollapsedRows) {
- InsertIntoCollapsedRows(aRowIndex);
- }
return PR_TRUE;
}
@@ -626,9 +604,6 @@ void nsCellMap::ShrinkWithoutRows(PRInt32 aStartRowIndex,
mRows.RemoveElementAt(rowX);
delete row;
- if(mIsCollapsedRows) {
- RemoveFromCollapsedRows(rowX);
- }
// Decrement our row and next available index counts.
mRowCount--;
@@ -1145,118 +1120,6 @@ nsTableCellFrame* nsCellMap::GetCellInfoAt(PRInt32 aRowX,
return cellFrame;
}
-PRInt32 nsCellMap::GetNumCollapsedRows() const
-{
- return mNumCollapsedRows;
-}
-
-PRBool nsCellMap::IsRowCollapsedAt(PRInt32 aRow) const
-{
- if ((aRow >= 0) && (aRow < mRowCount)) {
- if (mIsCollapsedRows) {
- return mIsCollapsedRows[aRow];
- }
- }
- return PR_FALSE;
-}
-
-void nsCellMap::SetRowCollapsedAt(PRInt32 aRow, PRBool aValue)
-{
- if ((aRow >= 0) && (aRow < mRowCount)) {
- if (nsnull == mIsCollapsedRows) {
- mIsCollapsedRows = new PRPackedBool[mRowCount];
- mIsCollapsedRowsSize = mRowCount;
- for (PRInt32 i = 0; i < mRowCount; i++) {
- mIsCollapsedRows[i] = PR_FALSE;
- }
- }
- if (mIsCollapsedRows[aRow] != aValue) {
- if (PR_TRUE == aValue) {
- mNumCollapsedRows++;
- } else {
- mNumCollapsedRows--;
- }
- mIsCollapsedRows[aRow] = aValue;
- }
- }
-}
-
-void nsCellMap::InsertIntoCollapsedRows(PRInt32 aRow)
-{
- if (mIsCollapsedRows) {
- if ((mRowCount + 1) > mIsCollapsedRowsSize){
- PRInt32 newSize = mRowCount + kIsCollapsedRowsGrowSize;
- PRPackedBool * newIsCollapsedRows = new PRPackedBool[newSize];
- if(!newIsCollapsedRows)
- return;
- if(aRow != 0)
- nsCRT::memcpy(newIsCollapsedRows, mIsCollapsedRows, aRow * sizeof (PRPackedBool));
- if(aRow != mRowCount)
- nsCRT::memcpy(newIsCollapsedRows + aRow + 1, mIsCollapsedRows + aRow,
- (mRowCount - aRow) * sizeof(PRPackedBool));
-
- delete[] mIsCollapsedRows;
- mIsCollapsedRows = newIsCollapsedRows;
- mIsCollapsedRowsSize = newSize;
- }
- else {
- if(aRow != mRowCount)
- nsCRT::memmove(mIsCollapsedRows + aRow + 1, mIsCollapsedRows + aRow,
- (mRowCount - aRow) * sizeof(PRPackedBool));
- }
- mIsCollapsedRows[aRow] = PR_FALSE;
- }
-}
-
-void nsCellMap::RemoveFromCollapsedRows(PRInt32 aRow)
-{
- //If the row we're removing was collapsed, decrement mNumCollapsedRows
- if(mIsCollapsedRows[aRow])
- mNumCollapsedRows--;
-
- //Don't need to move if last element in array
- if(aRow < (mRowCount - 1))
- nsCRT::memmove(mIsCollapsedRows + aRow, mIsCollapsedRows + aRow + 1,
- (mRowCount - 1 - aRow) * sizeof(PRPackedBool));
-
-}
-
-PRInt32 nsCellMap::GetNumCollapsedCols() const
-{
- return mNumCollapsedCols;
-}
-
-PRBool nsCellMap::IsColCollapsedAt(PRInt32 aCol) const
-{
- PRInt32 colCount = mCols.Count();
- if ((aCol >= 0) && (aCol < colCount)) {
- if (mIsCollapsedCols) {
- return mIsCollapsedCols[aCol];
- }
- }
- return PR_FALSE;
-}
-
-void nsCellMap::SetColCollapsedAt(PRInt32 aCol, PRBool aValue)
-{
- PRInt32 colCount = mCols.Count();
- if ((aCol >= 0) && (aCol < colCount)) {
- if (nsnull == mIsCollapsedCols) {
- mIsCollapsedCols = new PRPackedBool[colCount];
- for (PRInt32 i = 0; i < colCount; i++) {
- mIsCollapsedCols[i] = PR_FALSE;
- }
- }
- if (mIsCollapsedCols[aCol] != aValue) {
- if (PR_TRUE == aValue) {
- mNumCollapsedCols++;
- } else {
- mNumCollapsedCols--;
- }
- mIsCollapsedCols[aCol] = aValue;
- }
- }
-}
PRBool nsCellMap::RowIsSpannedInto(PRInt32 aRowIndex) const
{
@@ -1351,15 +1214,6 @@ void nsCellMap::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
mCols.SizeOf(aHandler, &voidArraySize);
sum += voidArraySize - sizeof(mCols);
- // Add in the size of the collapsed rows and collapsed column
- // packed bool arrays
- if (mIsCollapsedRows) {
- sum += mRowCount * sizeof(PRPackedBool);
- }
- if (mIsCollapsedCols) {
- sum += mCols.Count() * sizeof(PRPackedBool);
- }
-
*aResult = sum;
}
#endif
diff --git a/mozilla/layout/tables/nsCellMap.h b/mozilla/layout/tables/nsCellMap.h
index 4d84149c90a..5670d30aa7f 100644
--- a/mozilla/layout/tables/nsCellMap.h
+++ b/mozilla/layout/tables/nsCellMap.h
@@ -29,11 +29,6 @@ class nsTableColFrame;
class nsTableCellFrame;
class nsIPresContext;
-// XXX the collapsing row and col data structures need to be moved
-// into nsTableFrame. Collapsing cols are broken due to the recent
-// incremental cell map methods which don't attempt to update
-// collapsing col info here.
-
struct nsColInfo
{
PRInt32 mNumCellsOrig; // number of cells originating in the col
@@ -108,16 +103,6 @@ public:
PRInt32 GetNumCellsOriginatingInRow(PRInt32 aRowIndex) const;
PRInt32 GetNumCellsOriginatingInCol(PRInt32 aColIndex) const;
- PRInt32 GetNumCollapsedRows() const;
- PRBool IsRowCollapsedAt(PRInt32 aRowIndex) const;
- void SetRowCollapsedAt(PRInt32 aRowIndex,
- PRBool aValue);
-
- PRInt32 GetNumCollapsedCols() const;
- PRBool IsColCollapsedAt(PRInt32 aColIndex) const;
- void SetColCollapsedAt(PRInt32 aColIndex,
- PRBool aValue);
-
/** return the total number of columns in the table represented by this CellMap */
PRInt32 GetColCount() const;
@@ -155,11 +140,6 @@ protected:
void Grow(PRInt32 aNumMapRows,
PRInt32 aNumCols);
- /** insert a new entry into the mIsCollapsedRows */
- void InsertIntoCollapsedRows(PRInt32 aRow);
- /** remove an entry from mIsCollapsedRows */
- void RemoveFromCollapsedRows(PRInt32 aRow);
-
/** assign aCellData to the cell at (aRow,aColumn) */
void SetMapCellAt(CellData& aCellData,
PRInt32 aMapRowIndex,
@@ -211,16 +191,6 @@ protected:
* cells originating and spanning each col. */
nsVoidArray mCols;
- // an array of booleans where the ith element indicates if the ith row is collapsed
- PRPackedBool* mIsCollapsedRows;
- PRInt32 mIsCollapsedRowsSize;
- PRInt32 mNumCollapsedRows;
-
-
- // an array of booleans where the ith element indicates if the ith col is collapsed
- PRPackedBool* mIsCollapsedCols;
- PRInt32 mNumCollapsedCols;
-
/** the number of rows in the table which is <= the number of rows in the cell map
* due to row spans extending beyond the end of the table (dead rows) */
PRInt32 mRowCount;
diff --git a/mozilla/layout/tables/nsTableColFrame.cpp b/mozilla/layout/tables/nsTableColFrame.cpp
index e4cceb6f942..55bea8a6e68 100644
--- a/mozilla/layout/tables/nsTableColFrame.cpp
+++ b/mozilla/layout/tables/nsTableColFrame.cpp
@@ -30,12 +30,16 @@
#include "nsHTMLAtoms.h"
#include "nsCSSRendering.h"
#include "nsLayoutAtoms.h"
+#include "nsIContent.h"
+#include "nsIDOMHTMLTableColElement.h"
#define COL_TYPE_CONTENT 0x0
#define COL_TYPE_ANONYMOUS_COL 0x1
#define COL_TYPE_ANONYMOUS_COLGROUP 0x2
#define COL_TYPE_ANONYMOUS_CELL 0x3
+static NS_DEFINE_IID(kIDOMHTMLTableColElementIID, NS_IDOMHTMLTABLECOLELEMENT_IID);
+
nsTableColFrame::nsTableColFrame()
: nsFrame(),
mProportion(WIDTH_NOT_SET),
@@ -145,6 +149,7 @@ NS_METHOD nsTableColFrame::Reflow(nsIPresContext* aPresContext,
PRInt32 nsTableColFrame::GetSpan()
{
+ PRInt32 span = 1;
const nsStyleTable* tableStyle;
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
return tableStyle->mSpan;
diff --git a/mozilla/layout/tables/nsTableColGroupFrame.cpp b/mozilla/layout/tables/nsTableColGroupFrame.cpp
index 00ed27bcb09..8db871e7b85 100644
--- a/mozilla/layout/tables/nsTableColGroupFrame.cpp
+++ b/mozilla/layout/tables/nsTableColGroupFrame.cpp
@@ -656,7 +656,7 @@ nsTableColFrame * nsTableColGroupFrame::GetColumnAt (PRInt32 aColIndex)
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
if (NS_STYLE_DISPLAY_TABLE_COLUMN == childDisplay->mDisplay) {
nsTableColFrame *col = (nsTableColFrame *)childFrame;
- count += col->GetSpan();
+ count++;
if (aColIndex<=count) {
result = col;
}
diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp
index 199efa39f3b..df140c11dae 100644
--- a/mozilla/layout/tables/nsTableFrame.cpp
+++ b/mozilla/layout/tables/nsTableFrame.cpp
@@ -1885,41 +1885,11 @@ void nsTableFrame::ComputePercentBasisForRows(const nsHTMLReflowState& aReflowSt
mPercentBasisForRows = height;
}
-// collapsing row groups, rows, col groups and cols are accounted for after both passes of
-// reflow so that it has no effect on the calculations of reflow.
-NS_METHOD nsTableFrame::AdjustForCollapsingRowGroup(nsIFrame* aRowGroupFrame,
- PRInt32& aRowX)
-{
- nsCellMap* cellMap = GetCellMap(); // XXX is this right
- const nsStyleDisplay* groupDisplay;
- aRowGroupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
- PRBool groupIsCollapsed = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
-
- nsTableRowFrame* rowFrame = nsnull;
- aRowGroupFrame->FirstChild(nsnull, (nsIFrame**)&rowFrame);
- while (nsnull != rowFrame) {
- const nsStyleDisplay *rowDisplay;
- rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
- if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
- if (groupIsCollapsed || (NS_STYLE_VISIBILITY_COLLAPSE == rowDisplay->mVisible)) {
- cellMap->SetRowCollapsedAt(aRowX, PR_TRUE);
- }
- aRowX++;
- }
- else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {
- AdjustForCollapsingRowGroup(rowFrame, aRowX);
- }
-
- rowFrame->GetNextSibling((nsIFrame**)&rowFrame);
- }
-
- return NS_OK;
-}
-
-NS_METHOD nsTableFrame::CollapseRowGroup(nsIPresContext* aPresContext,
- nsIFrame* aRowGroupFrame,
- const nscoord& aYTotalOffset,
- nscoord& aYGroupOffset, PRInt32& aRowX)
+NS_METHOD
+nsTableFrame::CollapseRowGroupIfNecessary(nsIPresContext* aPresContext,
+ nsIFrame* aRowGroupFrame,
+ const nscoord& aYTotalOffset,
+ nscoord& aYGroupOffset, PRInt32& aRowX)
{
const nsStyleDisplay* groupDisplay;
aRowGroupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
@@ -1932,7 +1902,7 @@ NS_METHOD nsTableFrame::CollapseRowGroup(nsIPresContext* aPresContext,
const nsStyleDisplay* rowDisplay;
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {
- CollapseRowGroup(aPresContext, rowFrame, aYTotalOffset, aYGroupOffset, aRowX);
+ CollapseRowGroupIfNecessary(aPresContext, rowFrame, aYTotalOffset, aYGroupOffset, aRowX);
}
else if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
nsRect rowRect;
@@ -1995,42 +1965,27 @@ NS_METHOD nsTableFrame::CollapseRowGroup(nsIPresContext* aPresContext,
return NS_OK;
}
+// collapsing row groups, rows, col groups and cols are accounted for after both passes of
+// reflow so that it has no effect on the calculations of reflow.
NS_METHOD nsTableFrame::AdjustForCollapsingRows(nsIPresContext* aPresContext,
nscoord& aHeight)
{
- // determine which row groups and rows are collapsed
- PRInt32 rowX = 0;
- nsIFrame* childFrame;
- FirstChild(nsnull, &childFrame);
- while (nsnull != childFrame) {
- const nsStyleDisplay* groupDisplay;
- childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
- if (IsRowGroup(groupDisplay->mDisplay)) {
- AdjustForCollapsingRowGroup(childFrame, rowX);
- }
- childFrame->GetNextSibling(&childFrame);
- }
-
- if (mCellMap->GetNumCollapsedRows() <= 0) {
- return NS_OK; // no collapsed rows, we're done
- }
-
- // collapse the rows and/or row groups
nsIFrame* groupFrame = mFrames.FirstChild();
nscoord yGroupOffset = 0; // total offset among rows within a single row group
nscoord yTotalOffset = 0; // total offset among all rows in all row groups
- rowX = 0;
-
+ PRInt32 rowIndex = 0;
+
+ // collapse the rows and/or row groups as necessary
while (nsnull != groupFrame) {
const nsStyleDisplay* groupDisplay;
groupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
if (IsRowGroup(groupDisplay->mDisplay)) {
- CollapseRowGroup(aPresContext, groupFrame, yTotalOffset, yGroupOffset, rowX);
+ CollapseRowGroupIfNecessary(aPresContext, groupFrame, yTotalOffset, yGroupOffset, rowIndex);
}
yTotalOffset += yGroupOffset;
yGroupOffset = 0;
groupFrame->GetNextSibling(&groupFrame);
- } // end group frame while
+ }
aHeight -= yTotalOffset;
@@ -2040,93 +1995,63 @@ NS_METHOD nsTableFrame::AdjustForCollapsingRows(nsIPresContext* aPresContext,
NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext* aPresContext,
nscoord& aWidth)
{
- // determine which col groups and cols are collapsed
- nsIFrame* childFrame = mColGroups.FirstChild();
- PRInt32 numCols = 0;
- while (nsnull != childFrame) {
- const nsStyleDisplay* groupDisplay;
- GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
- PRBool groupIsCollapsed = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
-
- nsTableColFrame* colFrame = nsnull;
- childFrame->FirstChild(nsnull, (nsIFrame**)&colFrame);
- while (nsnull != colFrame) {
- const nsStyleDisplay *colDisplay;
- colFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)colDisplay));
- if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay) {
- if (groupIsCollapsed || (NS_STYLE_VISIBILITY_COLLAPSE == colDisplay->mVisible)) {
- mCellMap->SetColCollapsedAt(numCols, PR_TRUE);
- }
- numCols++;
- }
- colFrame->GetNextSibling((nsIFrame**)&colFrame);
- }
- childFrame->GetNextSibling(&childFrame);
- }
-
- if (mCellMap->GetNumCollapsedCols() <= 0) {
- return NS_OK; // no collapsed cols, we're done
- }
-
- // collapse the cols and/or col groups
PRInt32 numRows = mCellMap->GetRowCount();
nsTableIterator groupIter(mColGroups, eTableDIR);
nsIFrame* groupFrame = groupIter.First();
nscoord cellSpacingX = GetCellSpacingX();
nscoord xOffset = 0;
- PRInt32 colX = (groupIter.IsLeftToRight()) ? 0 : numCols - 1;
+ PRInt32 colX = (groupIter.IsLeftToRight()) ? 0 : GetColCount() - 1;
PRInt32 direction = (groupIter.IsLeftToRight()) ? 1 : -1;
+ // iterate over the col groups
while (nsnull != groupFrame) {
const nsStyleDisplay* groupDisplay;
groupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
nsTableIterator colIter(*groupFrame, eTableDIR);
nsIFrame* colFrame = colIter.First();
+ // iterate over the cols in the col group
while (nsnull != colFrame) {
const nsStyleDisplay* colDisplay;
colFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)colDisplay));
if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay) {
PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colDisplay->mVisible);
- PRInt32 colSpan = ((nsTableColFrame*)colFrame)->GetSpan();
- for (PRInt32 spanX = 0; spanX < colSpan; spanX++) {
- PRInt32 col2X = colX + (direction * spanX);
- PRInt32 colWidth = GetColumnWidth(col2X);
- if (collapseGroup || collapseCol) {
- xOffset += colWidth + cellSpacingX;
- }
- nsTableCellFrame* lastCell = nsnull;
- nsTableCellFrame* cellFrame = nsnull;
- for (PRInt32 rowX = 0; rowX < numRows; rowX++) {
- CellData* cellData = mCellMap->GetCellAt(rowX, col2X);
- nsRect cellRect;
- if (cellData) {
- cellFrame = cellData->mOrigCell;
- if (cellFrame) { // the cell originates at (rowX, colX)
- cellFrame->GetRect(cellRect);
- if (collapseGroup || collapseCol) {
- if (lastCell != cellFrame) { // do it only once if there is a row span
- cellRect.width -= colWidth;
- cellFrame->SetCollapseOffsetX(aPresContext, -xOffset);
- }
- } else { // the cell is not in a collapsed col but needs to move
- cellRect.x -= xOffset;
+ PRInt32 colWidth = GetColumnWidth(colX);
+ if (collapseGroup || collapseCol) {
+ xOffset += colWidth + cellSpacingX;
+ }
+ nsTableCellFrame* lastCell = nsnull;
+ nsTableCellFrame* cellFrame = nsnull;
+ for (PRInt32 rowX = 0; rowX < numRows; rowX++) {
+ CellData* cellData = mCellMap->GetCellAt(rowX, colX);
+ nsRect cellRect;
+ if (cellData) {
+ cellFrame = cellData->mOrigCell;
+ if (cellFrame) { // the cell originates at (rowX, colX)
+ cellFrame->GetRect(cellRect);
+ if (collapseGroup || collapseCol) {
+ if (lastCell != cellFrame) { // do it only once if there is a row span
+ cellRect.width -= colWidth;
+ cellFrame->SetCollapseOffsetX(aPresContext, -xOffset);
}
- cellFrame->SetRect(aPresContext, cellRect);
+ } else { // the cell is not in a collapsed col but needs to move
+ cellRect.x -= xOffset;
+ }
+ cellFrame->SetRect(aPresContext, cellRect);
// if the cell does not originate at (rowX, colX), adjust the real cells width
- } else if (collapseGroup || collapseCol) {
- if (cellData->mColSpanData)
- cellFrame = cellData->mColSpanData->mOrigCell;
- if ((cellFrame) && (lastCell != cellFrame)) {
- cellFrame->GetRect(cellRect);
- cellRect.width -= colWidth + cellSpacingX;
- cellFrame->SetRect(aPresContext, cellRect);
- }
+ } else if (collapseGroup || collapseCol) {
+ if (cellData->mColSpanData) {
+ cellFrame = cellData->mColSpanData->mOrigCell;
+ }
+ if ((cellFrame) && (lastCell != cellFrame)) {
+ cellFrame->GetRect(cellRect);
+ cellRect.width -= colWidth + cellSpacingX;
+ cellFrame->SetRect(aPresContext, cellRect);
}
}
- lastCell = cellFrame;
}
+ lastCell = cellFrame;
}
- colX += direction * colSpan;
+ colX += direction;
}
colFrame = colIter.Next();
} // inner while
@@ -3557,42 +3482,9 @@ void nsTableFrame::AdjustColumnsForCOLSAttribute()
}
-/* there's an easy way and a hard way. The easy way is to look in our
- * cache and pull the frame from there.
- * If the cache isn't built yet, then we have to go hunting.
- */
NS_METHOD nsTableFrame::GetColumnFrame(PRInt32 aColIndex, nsTableColFrame *&aColFrame)
{
- aColFrame = nsnull; // initialize out parameter
- nsCellMap *cellMap = GetCellMap();
- if (nsnull!=cellMap)
- { // hooray, we get to do this the easy way because the info is cached
- aColFrame = (nsTableColFrame *)mColFrames.ElementAt(aColIndex);
- }
- // XXX this should go away with the new synchronized col cache.
- else
- { // ah shucks, we have to go hunt for the column frame brute-force style
- nsIFrame *childFrame = mColGroups.FirstChild();
- for (;;)
- {
- if (nsnull==childFrame)
- {
- NS_ASSERTION (PR_FALSE, "scanned the frame hierarchy and no column frame could be found.");
- break;
- }
- PRInt32 colGroupStartingIndex = ((nsTableColGroupFrame *)childFrame)->GetStartColumnIndex();
- if (aColIndex >= colGroupStartingIndex)
- { // the cell's col might be in this col group
- PRInt32 colCount = ((nsTableColGroupFrame *)childFrame)->GetColCount();
- if (aColIndex < colGroupStartingIndex + colCount)
- { // yep, we've found it. GetColumnAt gives us the column at the offset colCount, not the absolute colIndex for the whole table
- aColFrame = ((nsTableColGroupFrame *)childFrame)->GetColumnAt(colCount);
- break;
- }
- }
- childFrame->GetNextSibling(&childFrame);
- }
- }
+ aColFrame = (nsTableColFrame *)mColFrames.ElementAt(aColIndex);
return NS_OK;
}
diff --git a/mozilla/layout/tables/nsTableFrame.h b/mozilla/layout/tables/nsTableFrame.h
index 19b98f36950..c444d34d270 100644
--- a/mozilla/layout/tables/nsTableFrame.h
+++ b/mozilla/layout/tables/nsTableFrame.h
@@ -527,13 +527,10 @@ protected:
nsIFrame* aKidFrame,
nsSize* aMaxElementSize);
- NS_METHOD AdjustForCollapsingRowGroup(nsIFrame* aRowGroupFrame,
- PRInt32& aRowX);
-
- NS_METHOD CollapseRowGroup(nsIPresContext* aPresContext,
- nsIFrame* aRowGroupFrame,
- const nscoord& aYTotalOffset,
- nscoord& aYGroupOffset, PRInt32& aRowX);
+ NS_METHOD CollapseRowGroupIfNecessary(nsIPresContext* aPresContext,
+ nsIFrame* aRowGroupFrame,
+ const nscoord& aYTotalOffset,
+ nscoord& aYGroupOffset, PRInt32& aRowX);
NS_METHOD AdjustForCollapsingRows(nsIPresContext* aPresContext,
nscoord& aHeight);
diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.cpp b/mozilla/layout/tables/nsTableRowGroupFrame.cpp
index 0fd47dc9301..17b3b0965d7 100644
--- a/mozilla/layout/tables/nsTableRowGroupFrame.cpp
+++ b/mozilla/layout/tables/nsTableRowGroupFrame.cpp
@@ -602,7 +602,7 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext* aPresContext,
rowHeights = new nscoord[numRows];
if (!rowHeights) return;
nsCRT::memset (rowHeights, 0, numRows*sizeof(nscoord));
- }
+ } // else - tree row groups need not have rows directly beneath them
/* Step 1: get the height of the tallest cell in the row and save it for
* pass 2. This height is for table cells that originate in this