diff --git a/layout/html/table/src/nsCellMap.cpp b/layout/html/table/src/nsCellMap.cpp
index 5645d8b89fab..4c84f1208899 100644
--- a/layout/html/table/src/nsCellMap.cpp
+++ b/layout/html/table/src/nsCellMap.cpp
@@ -311,10 +311,16 @@ nsTableCellMap::AppendCell(nsTableCellFrame& aCellFrame,
PRBool aRebuildIfNecessary)
{
NS_ASSERTION(&aCellFrame == aCellFrame.GetFirstInFlow(), "invalid call on continuing frame");
+ nsIFrame* rgFrame = nsnull;
+ aCellFrame.GetParent(&rgFrame); // get the row
+ if (!rgFrame) return 0;
+ rgFrame->GetParent(&rgFrame); // get the row group
+ if (!rgFrame) return 0;
+
PRInt32 rowIndex = aRowIndex;
nsCellMap* cellMap = mFirstMap;
while (cellMap) {
- if (cellMap->GetRowCount() > rowIndex) {
+ if (cellMap->GetRowGroup() == rgFrame) {
return cellMap->AppendCell(*this, aCellFrame, rowIndex, aRebuildIfNecessary);
}
rowIndex -= cellMap->GetRowCount();
diff --git a/layout/html/table/src/nsCellMap.h b/layout/html/table/src/nsCellMap.h
index c24cf0cf98b3..02612ba14eec 100644
--- a/layout/html/table/src/nsCellMap.h
+++ b/layout/html/table/src/nsCellMap.h
@@ -211,8 +211,8 @@ public:
PRInt32 GetNumCellsOriginatingInRow(PRInt32 aRowIndex) const;
PRInt32 GetNumCellsOriginatingInCol(PRInt32 aColIndex) const;
- /** return the actual number of rows in the table represented by this CellMap */
- PRInt32 GetRowCount() const;
+ /** return the number of rows in the table represented by this CellMap */
+ PRInt32 GetRowCount(PRBool aConsiderDeadRowSpanRows = PR_FALSE) const;
nsTableCellFrame* GetCellInfoAt(nsTableCellMap& aMap,
PRInt32 aRowX,
@@ -374,9 +374,10 @@ inline nsTableRowGroupFrame* nsCellMap::GetRowGroup() const
return mRowGroupFrame;
}
-inline PRInt32 nsCellMap::GetRowCount() const
+inline PRInt32 nsCellMap::GetRowCount(PRBool aConsiderDeadRowSpanRows) const
{
- return mRowCount;
+ PRInt32 rowCount = (aConsiderDeadRowSpanRows) ? mRows.Count() : mRowCount;
+ return rowCount;
}
// nsColInfo
diff --git a/layout/tables/nsCellMap.cpp b/layout/tables/nsCellMap.cpp
index 5645d8b89fab..4c84f1208899 100644
--- a/layout/tables/nsCellMap.cpp
+++ b/layout/tables/nsCellMap.cpp
@@ -311,10 +311,16 @@ nsTableCellMap::AppendCell(nsTableCellFrame& aCellFrame,
PRBool aRebuildIfNecessary)
{
NS_ASSERTION(&aCellFrame == aCellFrame.GetFirstInFlow(), "invalid call on continuing frame");
+ nsIFrame* rgFrame = nsnull;
+ aCellFrame.GetParent(&rgFrame); // get the row
+ if (!rgFrame) return 0;
+ rgFrame->GetParent(&rgFrame); // get the row group
+ if (!rgFrame) return 0;
+
PRInt32 rowIndex = aRowIndex;
nsCellMap* cellMap = mFirstMap;
while (cellMap) {
- if (cellMap->GetRowCount() > rowIndex) {
+ if (cellMap->GetRowGroup() == rgFrame) {
return cellMap->AppendCell(*this, aCellFrame, rowIndex, aRebuildIfNecessary);
}
rowIndex -= cellMap->GetRowCount();
diff --git a/layout/tables/nsCellMap.h b/layout/tables/nsCellMap.h
index c24cf0cf98b3..02612ba14eec 100644
--- a/layout/tables/nsCellMap.h
+++ b/layout/tables/nsCellMap.h
@@ -211,8 +211,8 @@ public:
PRInt32 GetNumCellsOriginatingInRow(PRInt32 aRowIndex) const;
PRInt32 GetNumCellsOriginatingInCol(PRInt32 aColIndex) const;
- /** return the actual number of rows in the table represented by this CellMap */
- PRInt32 GetRowCount() const;
+ /** return the number of rows in the table represented by this CellMap */
+ PRInt32 GetRowCount(PRBool aConsiderDeadRowSpanRows = PR_FALSE) const;
nsTableCellFrame* GetCellInfoAt(nsTableCellMap& aMap,
PRInt32 aRowX,
@@ -374,9 +374,10 @@ inline nsTableRowGroupFrame* nsCellMap::GetRowGroup() const
return mRowGroupFrame;
}
-inline PRInt32 nsCellMap::GetRowCount() const
+inline PRInt32 nsCellMap::GetRowCount(PRBool aConsiderDeadRowSpanRows) const
{
- return mRowCount;
+ PRInt32 rowCount = (aConsiderDeadRowSpanRows) ? mRows.Count() : mRowCount;
+ return rowCount;
}
// nsColInfo