Bug 499607. Stop leaking nsBlockFrame's overflow nsLineList's. r=fantasai sr=dbaron
authorTimothy Nikkel <tnikkel@gmail.com>
Mon, 28 Sep 2009 20:23:33 -0500
changeset 33259 21d443acefc521162c272cee0c420a313e4eb2da
parent 33258 890e35aa6a46c57f794f55962c649839b4c19302
child 33260 790211c5a8ddbc5c34e4728e1745520a93946d7b
push id9390
push usertnikkel@gmail.com
push dateTue, 29 Sep 2009 02:54:56 +0000
treeherdermozilla-central@1deff8db4352 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfantasai, dbaron
bugs499607
milestone1.9.3a1pre
Bug 499607. Stop leaking nsBlockFrame's overflow nsLineList's. r=fantasai sr=dbaron
layout/generic/nsBlockFrame.cpp
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -299,16 +299,17 @@ nsBlockFrame::Destroy()
   nsPresContext* presContext = PresContext();
 
   nsLineBox::DeleteLineList(presContext, mLines);
 
   // destroy overflow lines now
   nsLineList* overflowLines = RemoveOverflowLines();
   if (overflowLines) {
     nsLineBox::DeleteLineList(presContext, *overflowLines);
+    delete overflowLines;
   }
 
   {
     nsAutoOOFFrameList oofs(this);
     oofs.mList.DestroyFrames();
     // oofs is now empty and will remove the frame list property
   }
 
@@ -2112,16 +2113,18 @@ nsBlockFrame::ReflowDirtyLines(nsBlockRe
         nextInFlow->RemoveOverflowLines();
         nifLine = overflowLines->erase(nifLine);
         if (nifLine != overflowLines->end()) {
           // We need to this remove-and-put-back dance because we want
           // to avoid making the overflow line list empty while it's
           // stored in the property (because the property has the
           // invariant that the list is never empty).
           nextInFlow->SetOverflowLines(overflowLines);
+        } else {
+          delete overflowLines;
         }
         collectOverflowFloats = PR_TRUE;
       }
 
       if (0 == toMove->GetChildCount()) {
         // The line is empty. Try the next one.
         NS_ASSERTION(nsnull == toMove->mFirstChild, "bad empty line");
         aState.FreeLineBox(toMove);
@@ -2547,18 +2550,22 @@ nsBlockFrame::PullFrameFrom(nsBlockReflo
         aFromLine.next()->MarkPreviousMarginDirty();
 
       Invalidate(fromLine->GetCombinedArea());
       fromLineList->erase(aFromLine);
       // Note that aFromLine just got incremented, so don't use it again here!
       aState.FreeLineBox(fromLine);
 
       // Put any remaining overflow lines back.
-      if (aFromOverflowLine && !fromLineList->empty()) {
-        aFromContainer->SetOverflowLines(fromLineList);
+      if (aFromOverflowLine) {
+        if (!fromLineList->empty()) {
+          aFromContainer->SetOverflowLines(fromLineList);
+        } else {
+          delete fromLineList;
+        }
       }
     }
 
     // Change geometric parents
     if (aFromContainer != this) {
       // When pushing and pulling frames we need to check for whether any
       // views need to be reparented
       NS_ASSERTION(frame->GetParent() == aFromContainer, "unexpected parent frame");
@@ -5307,16 +5314,18 @@ found_frame:;
                lineCombinedArea.width, lineCombinedArea.height);
 #endif
         Invalidate(lineCombinedArea);
       } else {
         nsLineList* lineList = RemoveOverflowLines();
         line = lineList->erase(line);
         if (!lineList->empty()) {
           SetOverflowLines(lineList);
+        } else {
+          delete lineList;
         }
       }
       cur->Destroy(presShell);
 
       // If we're removing a line, ReflowDirtyLines isn't going to
       // know that it needs to slide lines unless something is marked
       // dirty.  So mark the previous margin of the next line dirty if
       // there is one.
@@ -5443,16 +5452,18 @@ nsBlockFrame::StealFrame(nsPresContext* 
           nsLineBox* lineBox = line;
           if (searchingOverflowList) {
             // Erase line, but avoid making the overflow line list empty
             nsLineList* lineList = RemoveOverflowLines();
             lineList->erase(line);
             if (!lineList->empty()) {
               nsresult rv = SetOverflowLines(lineList);
               NS_ENSURE_SUCCESS(rv, rv);
+            } else {
+              delete lineList;
             }
           }
           else {
             mLines.erase(line);
           }
           lineBox->Destroy(aPresContext->PresShell());
           if (line != line_end) {
             // Line disappeared, so tell next line it may have to change position