Bug 1509972 part 3: Use UniquePtr (not nsAutoPtr) for mNext pointers in StaticPresData's "LangGroupFontPrefs" list. r=TYLin
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 26 Nov 2018 22:24:36 +0000
changeset 504637 025e1c8e3cf86a8ec5779fa057d48bec7c984c13
parent 504636 01ef9c6e724f9b5f5f62b471a56321bd1d6f7332
child 504638 ffbdfd28202f40c0bc360758504cb98cc4ad9264
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersTYLin
bugs1509972
milestone65.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 1509972 part 3: Use UniquePtr (not nsAutoPtr) for mNext pointers in StaticPresData's "LangGroupFontPrefs" list. r=TYLin Depends on D12994 Differential Revision: https://phabricator.services.mozilla.com/D12995
layout/base/StaticPresData.cpp
layout/base/StaticPresData.h
--- a/layout/base/StaticPresData.cpp
+++ b/layout/base/StaticPresData.cpp
@@ -254,25 +254,26 @@ StaticPresData::GetFontPrefsForLangHelpe
     for (;;) {
       NS_ASSERTION(++count < 35, "Lang group count exceeded!!!");
       if (prefs->mLangGroup == langGroupAtom) {
         return prefs;
       }
       if (!prefs->mNext) {
         break;
       }
-      prefs = prefs->mNext;
+      prefs = prefs->mNext.get();
     }
     if (aNeedsToCache) {
       *aNeedsToCache = true;
       return nullptr;
     }
     AssertIsMainThreadOrServoFontMetricsLocked();
     // nothing cached, so go on and fetch the prefs for this lang group:
-    prefs = prefs->mNext = new LangGroupFontPrefs;
+    prefs->mNext = MakeUnique<LangGroupFontPrefs>();
+    prefs = prefs->mNext.get();
   }
 
   if (aNeedsToCache) {
     *aNeedsToCache = true;
     return nullptr;
   }
 
   AssertIsMainThreadOrServoFontMetricsLocked();
--- a/layout/base/StaticPresData.h
+++ b/layout/base/StaticPresData.h
@@ -2,17 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_StaticPresData_h
 #define mozilla_StaticPresData_h
 
-#include "nsAutoPtr.h"
+#include "mozilla/UniquePtr.h"
 #include "nsCoord.h"
 #include "nsCOMPtr.h"
 #include "nsFont.h"
 #include "nsAtom.h"
 #include "nsLanguageAtomService.h"
 
 namespace mozilla {
 
@@ -41,43 +41,43 @@ struct LangGroupFontPrefs {
     mNext = nullptr;
 
     // Make GetFontPreferences reinitialize mLangGroupFontPrefs:
     mLangGroup = nullptr;
   }
 
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
     size_t n = 0;
-    LangGroupFontPrefs* curr = mNext;
+    LangGroupFontPrefs* curr = mNext.get();
     while (curr) {
       n += aMallocSizeOf(curr);
 
       // Measurement of the following members may be added later if DMD finds
       // it is worthwhile:
       // - mLangGroup
       // - mDefault*Font
 
-      curr = curr->mNext;
+      curr = curr->mNext.get();
     }
     return n;
   }
 
   // Initialize this with the data for a given language
   void Initialize(nsAtom* aLangGroupAtom);
 
   RefPtr<nsAtom> mLangGroup;
   nscoord mMinimumFontSize;
   nsFont mDefaultVariableFont;
   nsFont mDefaultFixedFont;
   nsFont mDefaultSerifFont;
   nsFont mDefaultSansSerifFont;
   nsFont mDefaultMonospaceFont;
   nsFont mDefaultCursiveFont;
   nsFont mDefaultFantasyFont;
-  nsAutoPtr<LangGroupFontPrefs> mNext;
+  mozilla::UniquePtr<LangGroupFontPrefs> mNext;
 };
 
 /**
  * Some functionality that has historically lived on nsPresContext does not
  * actually need to be per-document. This singleton class serves as a host
  * for that functionality. We delegate to it from nsPresContext where
  * appropriate, and use it standalone in some cases as well.
  */