diff --git a/mozilla/layout/html/table/src/nsCellMap.cpp b/mozilla/layout/html/table/src/nsCellMap.cpp
index 19f7652e730..077cd9b0154 100644
--- a/mozilla/layout/html/table/src/nsCellMap.cpp
+++ b/mozilla/layout/html/table/src/nsCellMap.cpp
@@ -478,7 +478,9 @@ nsTableCellMap::InsertRows(nsTableRowGroupFrame& aParent,
cellMap->InsertRows(*this, aRows, rowIndex, aConsiderSpans, aDamageArea);
aDamageArea.y = aFirstRowIndex;
aDamageArea.height = PR_MAX(0, GetRowCount() - aFirstRowIndex);
- //Dump("after InsertRows");
+#ifdef DEBUG_TABLE_CELLMAP
+ Dump("after InsertRows");
+#endif
if (mBCInfo) {
BCData* bcData;
PRInt32 count = mBCInfo->mRightBorders.Count();
@@ -536,7 +538,9 @@ nsTableCellMap::RemoveRows(PRInt32 aFirstRowIndex,
rowIndex -= cellMap->GetRowCount();
cellMap = cellMap->GetNextSibling();
}
- //Dump("after RemoveRows");
+#ifdef DEBUG_TABLE_CELLMAP
+ Dump("after RemoveRows");
+#endif
}
PRInt32
@@ -582,7 +586,9 @@ nsTableCellMap::AppendCell(nsTableCellFrame& aCellFrame,
rowIndex -= cellMap->GetRowCount();
cellMap = cellMap->GetNextSibling();
}
- //Dump("after AppendCell");
+#ifdef DEBUG_TABLE_CELLMAP
+ Dump("after AppendCell");
+#endif
return result;
}
@@ -606,7 +612,9 @@ nsTableCellMap::InsertCells(nsVoidArray& aCellFrames,
rowIndex -= cellMap->GetRowCount();
cellMap = cellMap->GetNextSibling();
}
- //Dump("after InsertCells");
+#ifdef DEBUG_TABLE_CELLMAP
+ Dump("after InsertCells");
+#endif
}
@@ -628,7 +636,9 @@ nsTableCellMap::RemoveCell(nsTableCellFrame* aCellFrame,
PRInt32 colIndex;
aCellFrame->GetColIndex(colIndex);
aDamageArea.width = PR_MAX(0, GetColCount() - colIndex - 1);
- //Dump("after RemoveCell");
+#ifdef DEBUG_TABLE_CELLMAP
+ Dump("after RemoveCell");
+#endif
return;
}
rowIndex -= cellMap->GetRowCount();
@@ -1255,7 +1265,15 @@ nsCellMap::AppendCell(nsTableCellMap& aMap,
// Setup CellData for this cell
if (origData) {
+ NS_ASSERTION(origData->IsDead(), "replacing a non dead cell is a memory leak");
origData->Init(aCellFrame);
+ // we are replacing a dead cell, increase the number of cells
+ // originating at this column
+ nsColInfo* colInfo = aMap.GetColInfoAt(startColIndex);
+ NS_ASSERTION(colInfo, "access to a non existing column");
+ if (colInfo) {
+ colInfo->mNumCellsOrig++;
+ }
}
else {
origData = (aMap.mBCInfo) ? new BCCellData(aCellFrame) : new CellData(aCellFrame); if (!origData) ABORT1(origData);
@@ -1331,8 +1349,10 @@ nsCellMap::AppendCell(nsTableCellMap& aMap,
}
}
}
- //printf("appended cell=%p row=%d \n", aCellFrame, aRowIndex);
- //aMap.Dump();
+#ifdef DEBUG_TABLE_CELLMAP
+ printf("appended cell=%p row=%d \n", aCellFrame, aRowIndex);
+ aMap.Dump();
+#endif
return origData;
}
diff --git a/mozilla/layout/html/table/src/nsCellMap.h b/mozilla/layout/html/table/src/nsCellMap.h
index e337d74cbd0..e7696f89677 100644
--- a/mozilla/layout/html/table/src/nsCellMap.h
+++ b/mozilla/layout/html/table/src/nsCellMap.h
@@ -42,6 +42,8 @@
#include "nsVoidArray.h"
#include "nsRect.h"
+#undef DEBUG_TABLE_CELLMAP
+
class nsTableColFrame;
class nsTableCellFrame;
class nsTableRowGroupFrame;
diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp
index a656fbfda6c..6b9889f51c5 100644
--- a/mozilla/layout/html/table/src/nsTableFrame.cpp
+++ b/mozilla/layout/html/table/src/nsTableFrame.cpp
@@ -1121,8 +1121,10 @@ nsTableFrame::InsertRows(nsIPresContext& aPresContext,
PRInt32 aRowIndex,
PRBool aConsiderSpans)
{
- //printf("insertRowsBefore firstRow=%d \n", aRowIndex);
- //Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#ifdef DEBUG_TABLE_CELLMAP
+ printf("insertRowsBefore firstRow=%d \n", aRowIndex);
+ Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#endif
PRInt32 numColsToAdd = 0;
nsTableCellMap* cellMap = GetCellMap();
@@ -1152,9 +1154,10 @@ nsTableFrame::InsertRows(nsIPresContext& aPresContext,
SetBCDamageArea(aPresContext, damageArea);
}
}
-
- //printf("insertRowsAfter \n");
- //Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#ifdef DEBUG_TABLE_CELLMAP
+ printf("insertRowsAfter \n");
+ Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#endif
return numColsToAdd;
}
@@ -1165,10 +1168,6 @@ void nsTableFrame::RemoveRows(nsIPresContext& aPresContext,
PRInt32 aNumRowsToRemove,
PRBool aConsiderSpans)
{
- //printf("removeRowsBefore firstRow=%d numRows=%d\n", aFirstRowIndex, aNumRowsToRemove);
- //Dump(PR_TRUE, PR_FALSE, PR_TRUE);
-
-
#ifdef TBD_OPTIMIZATION
// decide if we need to rebalance. we have to do this here because the row group
// cannot do it when it gets the dirty reflow corresponding to the frame being destroyed
@@ -1186,6 +1185,10 @@ void nsTableFrame::RemoveRows(nsIPresContext& aPresContext,
#endif
PRInt32 firstRowIndex = aFirstRowFrame.GetRowIndex();
+#ifdef DEBUG_TABLE_CELLMAP
+ printf("removeRowsBefore firstRow=%d numRows=%d\n", firstRowIndex, aNumRowsToRemove);
+ Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#endif
nsTableCellMap* cellMap = GetCellMap();
if (cellMap) {
nsRect damageArea(0,0,0,0);
@@ -1207,8 +1210,10 @@ void nsTableFrame::RemoveRows(nsIPresContext& aPresContext,
}
}
AdjustRowIndices(firstRowIndex, -aNumRowsToRemove);
- //printf("removeRowsAfter\n");
- //Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#ifdef DEBUG_TABLE_CELLMAP
+ printf("removeRowsAfter\n");
+ Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#endif
}
void nsTableFrame::AppendRowGroups(nsIPresContext& aPresContext,
@@ -6056,7 +6061,9 @@ nsTableFrame::CalcBCBorders(nsIPresContext& aPresContext)
// reset the bc flag and damage area
SetNeedToCalcBCBorders(PR_FALSE);
propData->mDamageArea.x = propData->mDamageArea.y = propData->mDamageArea.width = propData->mDamageArea.height = 0;
- //mCellMap->Dump();
+#ifdef DEBUG_TABLE_CELLMAP
+ mCellMap->Dump();
+#endif
}
// Iterates over borders (left border, corner, top border) in the cell map within a damage area
diff --git a/mozilla/layout/tables/nsCellMap.cpp b/mozilla/layout/tables/nsCellMap.cpp
index 19f7652e730..077cd9b0154 100644
--- a/mozilla/layout/tables/nsCellMap.cpp
+++ b/mozilla/layout/tables/nsCellMap.cpp
@@ -478,7 +478,9 @@ nsTableCellMap::InsertRows(nsTableRowGroupFrame& aParent,
cellMap->InsertRows(*this, aRows, rowIndex, aConsiderSpans, aDamageArea);
aDamageArea.y = aFirstRowIndex;
aDamageArea.height = PR_MAX(0, GetRowCount() - aFirstRowIndex);
- //Dump("after InsertRows");
+#ifdef DEBUG_TABLE_CELLMAP
+ Dump("after InsertRows");
+#endif
if (mBCInfo) {
BCData* bcData;
PRInt32 count = mBCInfo->mRightBorders.Count();
@@ -536,7 +538,9 @@ nsTableCellMap::RemoveRows(PRInt32 aFirstRowIndex,
rowIndex -= cellMap->GetRowCount();
cellMap = cellMap->GetNextSibling();
}
- //Dump("after RemoveRows");
+#ifdef DEBUG_TABLE_CELLMAP
+ Dump("after RemoveRows");
+#endif
}
PRInt32
@@ -582,7 +586,9 @@ nsTableCellMap::AppendCell(nsTableCellFrame& aCellFrame,
rowIndex -= cellMap->GetRowCount();
cellMap = cellMap->GetNextSibling();
}
- //Dump("after AppendCell");
+#ifdef DEBUG_TABLE_CELLMAP
+ Dump("after AppendCell");
+#endif
return result;
}
@@ -606,7 +612,9 @@ nsTableCellMap::InsertCells(nsVoidArray& aCellFrames,
rowIndex -= cellMap->GetRowCount();
cellMap = cellMap->GetNextSibling();
}
- //Dump("after InsertCells");
+#ifdef DEBUG_TABLE_CELLMAP
+ Dump("after InsertCells");
+#endif
}
@@ -628,7 +636,9 @@ nsTableCellMap::RemoveCell(nsTableCellFrame* aCellFrame,
PRInt32 colIndex;
aCellFrame->GetColIndex(colIndex);
aDamageArea.width = PR_MAX(0, GetColCount() - colIndex - 1);
- //Dump("after RemoveCell");
+#ifdef DEBUG_TABLE_CELLMAP
+ Dump("after RemoveCell");
+#endif
return;
}
rowIndex -= cellMap->GetRowCount();
@@ -1255,7 +1265,15 @@ nsCellMap::AppendCell(nsTableCellMap& aMap,
// Setup CellData for this cell
if (origData) {
+ NS_ASSERTION(origData->IsDead(), "replacing a non dead cell is a memory leak");
origData->Init(aCellFrame);
+ // we are replacing a dead cell, increase the number of cells
+ // originating at this column
+ nsColInfo* colInfo = aMap.GetColInfoAt(startColIndex);
+ NS_ASSERTION(colInfo, "access to a non existing column");
+ if (colInfo) {
+ colInfo->mNumCellsOrig++;
+ }
}
else {
origData = (aMap.mBCInfo) ? new BCCellData(aCellFrame) : new CellData(aCellFrame); if (!origData) ABORT1(origData);
@@ -1331,8 +1349,10 @@ nsCellMap::AppendCell(nsTableCellMap& aMap,
}
}
}
- //printf("appended cell=%p row=%d \n", aCellFrame, aRowIndex);
- //aMap.Dump();
+#ifdef DEBUG_TABLE_CELLMAP
+ printf("appended cell=%p row=%d \n", aCellFrame, aRowIndex);
+ aMap.Dump();
+#endif
return origData;
}
diff --git a/mozilla/layout/tables/nsCellMap.h b/mozilla/layout/tables/nsCellMap.h
index e337d74cbd0..e7696f89677 100644
--- a/mozilla/layout/tables/nsCellMap.h
+++ b/mozilla/layout/tables/nsCellMap.h
@@ -42,6 +42,8 @@
#include "nsVoidArray.h"
#include "nsRect.h"
+#undef DEBUG_TABLE_CELLMAP
+
class nsTableColFrame;
class nsTableCellFrame;
class nsTableRowGroupFrame;
diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp
index a656fbfda6c..6b9889f51c5 100644
--- a/mozilla/layout/tables/nsTableFrame.cpp
+++ b/mozilla/layout/tables/nsTableFrame.cpp
@@ -1121,8 +1121,10 @@ nsTableFrame::InsertRows(nsIPresContext& aPresContext,
PRInt32 aRowIndex,
PRBool aConsiderSpans)
{
- //printf("insertRowsBefore firstRow=%d \n", aRowIndex);
- //Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#ifdef DEBUG_TABLE_CELLMAP
+ printf("insertRowsBefore firstRow=%d \n", aRowIndex);
+ Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#endif
PRInt32 numColsToAdd = 0;
nsTableCellMap* cellMap = GetCellMap();
@@ -1152,9 +1154,10 @@ nsTableFrame::InsertRows(nsIPresContext& aPresContext,
SetBCDamageArea(aPresContext, damageArea);
}
}
-
- //printf("insertRowsAfter \n");
- //Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#ifdef DEBUG_TABLE_CELLMAP
+ printf("insertRowsAfter \n");
+ Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#endif
return numColsToAdd;
}
@@ -1165,10 +1168,6 @@ void nsTableFrame::RemoveRows(nsIPresContext& aPresContext,
PRInt32 aNumRowsToRemove,
PRBool aConsiderSpans)
{
- //printf("removeRowsBefore firstRow=%d numRows=%d\n", aFirstRowIndex, aNumRowsToRemove);
- //Dump(PR_TRUE, PR_FALSE, PR_TRUE);
-
-
#ifdef TBD_OPTIMIZATION
// decide if we need to rebalance. we have to do this here because the row group
// cannot do it when it gets the dirty reflow corresponding to the frame being destroyed
@@ -1186,6 +1185,10 @@ void nsTableFrame::RemoveRows(nsIPresContext& aPresContext,
#endif
PRInt32 firstRowIndex = aFirstRowFrame.GetRowIndex();
+#ifdef DEBUG_TABLE_CELLMAP
+ printf("removeRowsBefore firstRow=%d numRows=%d\n", firstRowIndex, aNumRowsToRemove);
+ Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#endif
nsTableCellMap* cellMap = GetCellMap();
if (cellMap) {
nsRect damageArea(0,0,0,0);
@@ -1207,8 +1210,10 @@ void nsTableFrame::RemoveRows(nsIPresContext& aPresContext,
}
}
AdjustRowIndices(firstRowIndex, -aNumRowsToRemove);
- //printf("removeRowsAfter\n");
- //Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#ifdef DEBUG_TABLE_CELLMAP
+ printf("removeRowsAfter\n");
+ Dump(PR_TRUE, PR_FALSE, PR_TRUE);
+#endif
}
void nsTableFrame::AppendRowGroups(nsIPresContext& aPresContext,
@@ -6056,7 +6061,9 @@ nsTableFrame::CalcBCBorders(nsIPresContext& aPresContext)
// reset the bc flag and damage area
SetNeedToCalcBCBorders(PR_FALSE);
propData->mDamageArea.x = propData->mDamageArea.y = propData->mDamageArea.width = propData->mDamageArea.height = 0;
- //mCellMap->Dump();
+#ifdef DEBUG_TABLE_CELLMAP
+ mCellMap->Dump();
+#endif
}
// Iterates over borders (left border, corner, top border) in the cell map within a damage area