PRInt32 numColsNotRemoved = DestroyAnonymousColFrames(*aPresContext, numColsInCache - numColsInMap);  if (numColsNotRemoved > 0) { cellMap->AddColsAtEnd(numColsNotRemoved);
if (numColsInCache > numColsInMap) { PRInt32 numColsNotRemoved = DestroyAnonymousColFrames(*aPresContext, numColsInCache - numColsInMap);  if (numColsNotRemoved > 0) { cellMap->AddColsAtEnd(numColsNotRemoved); }
nsTableFrame::RemoveFrame(nsIPresContext* aPresContext,                          nsIPresShell&   aPresShell,                          nsIAtom*        aListName,                          nsIFrame*       aOldFrame){  // See what kind of frame we have  const nsStyleDisplay *display=nsnull;  aOldFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));  if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == display->mDisplay) {    nsIFrame* nextColGroupFrame;    aOldFrame->GetNextSibling(&nextColGroupFrame);    nsTableColGroupFrame* colGroup = (nsTableColGroupFrame*)aOldFrame;    PRInt32 firstColIndex = colGroup->GetStartColumnIndex();    PRInt32 lastColIndex  = firstColIndex + colGroup->GetColCount() - 1;    // remove the col frames, the colGroup frame and reset col indices    colGroup->RemoveChildrenAtEnd(*aPresContext, colGroup->GetColCount());    mColGroups.DestroyFrame(aPresContext, aOldFrame);    nsTableColGroupFrame::ResetColIndices(aPresContext, nextColGroupFrame, firstColIndex);     // remove the cols from the table    PRInt32 colX;    for (colX = lastColIndex; colX >= firstColIndex; colX--) {      nsTableColFrame* colFrame = (nsTableColFrame*)mColFrames.ElementAt(colX);      if (colFrame) {        RemoveCol(*aPresContext, colGroup, colX, PR_TRUE, PR_FALSE);      }    }    for (colX = lastColIndex; colX >= firstColIndex; colX--) {      nsTableColFrame* colFrame = (nsTableColFrame*)mColFrames.ElementAt(colX);      if (colFrame) {        RemoveCol(*aPresContext, colGroup, colX, PR_FALSE, PR_TRUE);      }    }    PRInt32 numAnonymousColsToAdd = GetColCount() - mColFrames.Count();    if (numAnonymousColsToAdd > 0) {      // this sets the child list, updates the col cache and cell map      CreateAnonymousColFrames(*aPresContext, numAnonymousColsToAdd,                               eColAnonymousCell, PR_TRUE);    }    InvalidateColumnWidths();    AddTableDirtyReflowCommand(aPresContext, this);  } else {    nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(aOldFrame);    if (rgFrame) {      PRInt32 startRowIndex = rgFrame->GetStartRowIndex();      PRInt32 numRows;      rgFrame->GetRowCount(numRows, PR_TRUE);      // remove the row group from the cell map      nsTableCellMap* cellMap = GetCellMap();      if (cellMap) {        cellMap->RemoveGroupCellMap(rgFrame);      }      // only remove cols that are of type eTypeAnonymous cell (they are at the end)      PRInt32 numColsInMap = GetColCount(); // cell map's notion of num cols      PRInt32 numColsInCache = mColFrames.Count();      PRInt32 numColsNotRemoved = DestroyAnonymousColFrames(*aPresContext, numColsInCache - numColsInMap);      // if the cell map has fewer cols than the cache, correct it      if (numColsNotRemoved > 0) {        cellMap->AddColsAtEnd(numColsNotRemoved);      }      AdjustRowIndices(aPresContext, startRowIndex, -numRows);      // remove the row group frame from the sibling chain      mFrames.DestroyFrame(aPresContext, aOldFrame);      InvalidateColumnWidths();      AddTableDirtyReflowCommand(aPresContext, this);    } else {      // Just remove the frame      mFrames.DestroyFrame(aPresContext, aOldFrame);      return NS_OK;    }  }  return NS_OK;}