Bug 815315 - Make nsTableFrame::RemoveFrame remove all continuations of the removed child frame too. r=bz
authorMats Palmgren <matspal@gmail.com>
Sat, 01 Dec 2012 01:10:40 +0100
changeset 114673 aabc7c735fb0a706ecd745ca41ebb447fab1b8dd
parent 114672 6e5da7fd674016db774bb3b62eb6498ec44041e7
child 114674 6bb1e540c73f6f6d14b49016429c881727838878
push id18915
push usermpalmgren@mozilla.com
push dateSat, 01 Dec 2012 00:10:33 +0000
treeherdermozilla-inbound@aabc7c735fb0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs815315
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 815315 - Make nsTableFrame::RemoveFrame remove all continuations of the removed child frame too. r=bz
layout/tables/nsTableFrame.cpp
layout/tables/nsTableFrame.h
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -2266,24 +2266,20 @@ nsTableFrame::HomogenousInsertFrames(Chi
   SetGeometryDirty();
 #ifdef DEBUG_TABLE_CELLMAP
   printf("=== TableFrame::InsertFrames\n");
   Dump(true, true, true);
 #endif
   return;
 }
 
-NS_IMETHODIMP
-nsTableFrame::RemoveFrame(ChildListID     aListID,
-                          nsIFrame*       aOldFrame)
-{
-  NS_ASSERTION(aListID == kColGroupList ||
-               NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP !=
-                 aOldFrame->GetStyleDisplay()->mDisplay,
-               "Wrong list name; use kColGroupList iff colgroup");
+void
+nsTableFrame::DoRemoveFrame(ChildListID     aListID,
+                            nsIFrame*       aOldFrame)
+{
   if (aListID == kColGroupList) {
     nsIFrame* nextColGroupFrame = aOldFrame->GetNextSibling();
     nsTableColGroupFrame* colGroup = (nsTableColGroupFrame*)aOldFrame;
     int32_t firstColIndex = colGroup->GetStartColumnIndex();
     int32_t lastColIndex  = firstColIndex + colGroup->GetColCount() - 1;
     mColGroups.DestroyFrame(aOldFrame);
     nsTableColGroupFrame::ResetColIndices(nextColGroupFrame, firstColIndex);
     // remove the cols from the table
@@ -2317,27 +2313,51 @@ nsTableFrame::RemoveFrame(ChildListID   
     // the removal of a row group changes the cellmap, the columns might change
     if (cellMap) {
       cellMap->Synchronize(this);
       // Create an empty slice
       ResetRowIndices(nsFrameList::Slice(mFrames, nullptr, nullptr));
       nsIntRect damageArea;
       cellMap->RebuildConsideringCells(nullptr, nullptr, 0, 0, false, damageArea);
 
-      MatchCellMapToColCache(cellMap);
-    }
-  }
-  // for now, just bail and recalc all of the collapsing borders
-  // as the cellmap changes we need to recalc
-  if (IsBorderCollapse()) {
-    SetFullBCDamageArea();
-  }
-  PresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange,
-                                               NS_FRAME_HAS_DIRTY_CHILDREN);
-  SetGeometryDirty();
+      ((nsTableFrame*)GetFirstInFlow())->MatchCellMapToColCache(cellMap);
+    }
+  }
+}
+
+NS_IMETHODIMP
+nsTableFrame::RemoveFrame(ChildListID     aListID,
+                          nsIFrame*       aOldFrame)
+{
+  NS_ASSERTION(aListID == kColGroupList ||
+               NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP !=
+                 aOldFrame->GetStyleDisplay()->mDisplay,
+               "Wrong list name; use kColGroupList iff colgroup");
+  nsIPresShell* shell = PresContext()->PresShell();
+  nsTableFrame* lastParent = nullptr;
+  while (aOldFrame) {
+    nsIFrame* oldFrameNextContinuation = aOldFrame->GetNextContinuation();
+    nsTableFrame* parent = static_cast<nsTableFrame*>(aOldFrame->GetParent());
+    if (parent != lastParent) {
+      parent->DrainSelfOverflowList();
+    }
+    parent->DoRemoveFrame(aListID, aOldFrame);
+    aOldFrame = oldFrameNextContinuation;
+    if (parent != lastParent) {
+      // for now, just bail and recalc all of the collapsing borders
+      // as the cellmap changes we need to recalc
+      if (parent->IsBorderCollapse()) {
+        parent->SetFullBCDamageArea();
+      }
+      parent->SetGeometryDirty();
+      shell->FrameNeedsReflow(parent, nsIPresShell::eTreeChange,
+                              NS_FRAME_HAS_DIRTY_CHILDREN);
+      lastParent = parent;
+    }
+  }
 #ifdef DEBUG_TABLE_CELLMAP
   printf("=== TableFrame::RemoveFrame\n");
   Dump(true, true, true);
 #endif
   return NS_OK;
 }
 
 /* virtual */ nsMargin
--- a/layout/tables/nsTableFrame.h
+++ b/layout/tables/nsTableFrame.h
@@ -736,16 +736,20 @@ public:
  
 #ifdef DEBUG
   void Dump(bool            aDumpRows,
             bool            aDumpCols, 
             bool            aDumpCellMap);
 #endif
 
 protected:
+  /**
+   * Helper method for RemoveFrame.
+   */
+  void DoRemoveFrame(ChildListID aListID, nsIFrame* aOldFrame);
 #ifdef DEBUG
   void DumpRowGroup(nsIFrame* aChildFrame);
 #endif
   // DATA MEMBERS
   nsAutoTArray<nsTableColFrame*, 8> mColFrames;
 
   struct TableBits {
     uint32_t mHaveReflowedColGroups:1; // have the col groups gotten their initial reflow