Bug 1265648 followup - Use an array of UniquePtr<> for mTextRunsToDelete. r=mats
authorJonathan Kew <jkew@mozilla.com>
Wed, 20 Apr 2016 10:55:15 +0100
changeset 331892 20956a16ffb857176bf34571d277b81685d0200c
parent 331891 77ba0dcb977a5accadbdefe0563f2ee9940ce6a8
child 331893 beca0a8904718c01dfe57a758ce2ceccc028dc2b
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1265648
milestone48.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 1265648 followup - Use an array of UniquePtr<> for mTextRunsToDelete. r=mats
layout/generic/nsTextFrame.cpp
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -954,17 +954,17 @@ public:
     DrawTarget*  mDrawTarget;
     uint32_t     mOffsetIntoTextRun;
   };
 
 private:
   AutoTArray<MappedFlow,10>   mMappedFlows;
   AutoTArray<nsTextFrame*,50> mLineBreakBeforeFrames;
   AutoTArray<nsAutoPtr<BreakSink>,10> mBreakSinks;
-  AutoTArray<gfxTextRun*,5>   mTextRunsToDelete;
+  AutoTArray<UniquePtr<gfxTextRun>,5> mTextRunsToDelete;
   nsLineBreaker                 mLineBreaker;
   gfxTextRun*                   mCurrentFramesAllSameTextRun;
   DrawTarget*                   mDrawTarget;
   nsIFrame*                     mLineContainer;
   nsTextFrame*                  mLastFrame;
   // The common ancestor of the current frame and the previous leaf frame
   // on the line, or null if there was no previous leaf frame.
   nsIFrame*                     mCommonAncestorWithLastFrame;
@@ -1468,21 +1468,16 @@ void BuildTextRunsScanner::FlushLineBrea
   }
 
   for (uint32_t i = 0; i < mBreakSinks.Length(); ++i) {
     // TODO cause frames associated with the textrun to be reflowed, if they
     // aren't being reflowed already!
     mBreakSinks[i]->Finish(mMissingFonts);
   }
   mBreakSinks.Clear();
-
-  for (uint32_t i = 0; i < mTextRunsToDelete.Length(); ++i) {
-    gfxTextRun* deleteTextRun = mTextRunsToDelete[i];
-    delete deleteTextRun;
-  }
   mTextRunsToDelete.Clear();
 }
 
 void BuildTextRunsScanner::AccumulateRunInfo(nsTextFrame* aFrame)
 {
   if (mMaxTextLength != UINT32_MAX) {
     NS_ASSERTION(mMaxTextLength < UINT32_MAX - aFrame->GetContentLength(), "integer overflow");
     if (mMaxTextLength >= UINT32_MAX - aFrame->GetContentLength()) {
@@ -2212,17 +2207,17 @@ BuildTextRunsScanner::BuildTextRunForFra
     // pointer. Strictly speaking we don't need to do this since it should
     // not be used (since this textrun will not be used and will be
     // itself deleted soon), but it's always better to not have dangling
     // pointers around.
     textRun->SetUserData(nullptr);
     DestroyUserData(userDataToDestroy);
     // Arrange for this textrun to be deleted the next time the linebreaker
     // is flushed out
-    mTextRunsToDelete.AppendElement(textRun.release());
+    mTextRunsToDelete.AppendElement(Move(textRun));
     return nullptr;
   }
 
   // Actually wipe out the textruns associated with the mapped frames and associate
   // those frames with this text run.
   AssignTextRun(textRun.get(), fontInflation);
   return textRun.release();
 }