Bug 1509972 part 2: Use UniquePtr (not nsAutoPtr) to store nsPresContext members mTextPerf and mMissingFonts. r=TYLin
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 26 Nov 2018 22:19:01 +0000
changeset 504636 01ef9c6e724f9b5f5f62b471a56321bd1d6f7332
parent 504635 79ccc954153606b9ebd60003b6fd6330216c4c4a
child 504637 025e1c8e3cf86a8ec5779fa057d48bec7c984c13
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 2: Use UniquePtr (not nsAutoPtr) to store nsPresContext members mTextPerf and mMissingFonts. r=TYLin Depends on D12993 Differential Revision: https://phabricator.services.mozilla.com/D12994
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -268,21 +268,21 @@ nsPresContext::nsPresContext(nsIDocument
   } else {
     mImageAnimationMode = imgIContainer::kNormalAnimMode;
     mNeverAnimate = false;
   }
   NS_ASSERTION(mDocument, "Null document");
 
   // if text perf logging enabled, init stats struct
   if (MOZ_LOG_TEST(gfxPlatform::GetLog(eGfxLog_textperf), LogLevel::Warning)) {
-    mTextPerf = new gfxTextPerfMetrics();
+    mTextPerf = MakeUnique<gfxTextPerfMetrics>();
   }
 
   if (Preferences::GetBool(GFX_MISSING_FONTS_NOTIFY_PREF)) {
-    mMissingFonts = new gfxMissingFontRecorder();
+    mMissingFonts = MakeUnique<gfxMissingFontRecorder>();
   }
 }
 
 static const char* gExactCallbackPrefs[] = {
   "browser.underline_anchors",
   "browser.anchor_color",
   "browser.active_color",
   "browser.visited_color",
@@ -669,17 +669,17 @@ nsPresContext::PreferenceChanged(const c
       nscoord height = NSToCoordRound(oldHeightDevPixels * AppUnitsPerDevPixel());
       vm->SetWindowDimensions(width, height);
     }
     return;
   }
   if (prefName.EqualsLiteral(GFX_MISSING_FONTS_NOTIFY_PREF)) {
     if (Preferences::GetBool(GFX_MISSING_FONTS_NOTIFY_PREF)) {
       if (!mMissingFonts) {
-        mMissingFonts = new gfxMissingFontRecorder();
+        mMissingFonts = MakeUnique<gfxMissingFontRecorder>();
         // trigger reflow to detect missing fonts on the current page
         mPrefChangePendingNeedsReflow = true;
       }
     } else {
       if (mMissingFonts) {
         mMissingFonts->Clear();
       }
       mMissingFonts = nullptr;
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -31,17 +31,16 @@
 #include "nsLanguageAtomService.h"
 #include "nsGkAtoms.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsChangeHint.h"
 #include <algorithm>
 #include "gfxTypes.h"
 #include "gfxRect.h"
 #include "nsTArray.h"
-#include "nsAutoPtr.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/AppUnits.h"
 #include "prclist.h"
 #include "nsThreadUtils.h"
 #include "nsIMessageManager.h"
 #include "Units.h"
 #include "prenv.h"
@@ -946,17 +945,17 @@ public:
       CSSPixelsToAppUnits(3),
       CSSPixelsToAppUnits(5)
     };
     MOZ_ASSERT(size_t(aBorderWidthKeyword) < mozilla::ArrayLength(kBorderWidths));
 
     return kBorderWidths[aBorderWidthKeyword];
   }
 
-  gfxTextPerfMetrics *GetTextPerfMetrics() { return mTextPerf; }
+  gfxTextPerfMetrics* GetTextPerfMetrics() { return mTextPerf.get(); }
 
   bool IsDynamic() { return (mType == eContext_PageLayout || mType == eContext_Galley); }
   bool IsScreen() { return (mMedium == nsGkAtoms::screen ||
                               mType == eContext_PageLayout ||
                               mType == eContext_PrintPreview); }
   bool IsPrintingOrPrintPreview() { return (mType == eContext_Print || mType == eContext_PrintPreview); }
 
   // Is this presentation in a chrome docshell?
@@ -989,17 +988,18 @@ public:
 
   gfxUserFontSet* GetUserFontSet(bool aFlushUserFontSet = true);
 
   // Should be called whenever the set of fonts available in the user
   // font set changes (e.g., because a new font loads, or because the
   // user font set is changed and fonts become unavailable).
   void UserFontSetUpdated(gfxUserFontEntry* aUpdatedFont = nullptr);
 
-  gfxMissingFontRecorder *MissingFontRecorder() { return mMissingFonts; }
+  gfxMissingFontRecorder* MissingFontRecorder() { return mMissingFonts.get(); }
+
   void NotifyMissingFonts();
 
   void FlushCounterStyles();
   void MarkCounterStylesDirty();
 
   void FlushFontFeatureValues();
   void MarkFontFeatureValuesDirty()
   {
@@ -1332,19 +1332,19 @@ protected:
   nsLanguageAtomService* mLangService;
   nsCOMPtr<nsIPrintSettings> mPrintSettings;
 
   mozilla::UniquePtr<nsBidi> mBidiEngine;
 
   AutoTArray<TransactionInvalidations, 4> mTransactions;
 
   // text performance metrics
-  nsAutoPtr<gfxTextPerfMetrics>   mTextPerf;
+  mozilla::UniquePtr<gfxTextPerfMetrics> mTextPerf;
 
-  nsAutoPtr<gfxMissingFontRecorder> mMissingFonts;
+  mozilla::UniquePtr<gfxMissingFontRecorder> mMissingFonts;
 
   nsRect                mVisibleArea;
   nsRect                mLastResizeEventVisibleArea;
   nsSize                mPageSize;
   float                 mPageScale;
   float                 mPPScale;
 
   nscolor               mDefaultColor;