Bug 1265452 followup - Make mGlyphExtentsArray an array of UniquePtr. r=jrmuizel
authorJonathan Kew <jkew@mozilla.com>
Tue, 19 Apr 2016 17:13:28 +0100
changeset 331788 1d5416c99477d004ade3de1bc4a7171b613acd0f
parent 331787 9d396d690080bef8191a1e8525cca2593051b338
child 331789 3e61ba81ac8c2cb687dc905298b4390086ce2f83
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)
reviewersjrmuizel
bugs1265452
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 1265452 followup - Make mGlyphExtentsArray an array of UniquePtr. r=jrmuizel
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -851,24 +851,16 @@ gfxFont::gfxFont(gfxFontEntry *aFontEntr
 #ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
     ++gFontCount;
 #endif
     mKerningSet = HasFeatureSet(HB_TAG('k','e','r','n'), mKerningEnabled);
 }
 
 gfxFont::~gfxFont()
 {
-    uint32_t i, count = mGlyphExtentsArray.Length();
-    // We destroy the contents of mGlyphExtentsArray explicitly instead of
-    // using UniquePtr because VC++ can't deal with nsTArrays of UniquePtrs
-    // of classes that lack a proper copy constructor
-    for (i = 0; i < count; ++i) {
-        delete mGlyphExtentsArray[i];
-    }
-
     mFontEntry->NotifyFontDestroyed(this);
 
     if (mGlyphChangeObservers) {
         for (auto it = mGlyphChangeObservers->Iter(); !it.Done(); it.Next()) {
             it.Get()->GetKey()->ForgetFont();
         }
     }
 }
@@ -3299,17 +3291,17 @@ gfxFont::RefCairo(DrawTarget* aDT)
   return refCairo;
 }
 
 gfxGlyphExtents *
 gfxFont::GetOrCreateGlyphExtents(int32_t aAppUnitsPerDevUnit) {
     uint32_t i, count = mGlyphExtentsArray.Length();
     for (i = 0; i < count; ++i) {
         if (mGlyphExtentsArray[i]->GetAppUnitsPerDevUnit() == aAppUnitsPerDevUnit)
-            return mGlyphExtentsArray[i];
+            return mGlyphExtentsArray[i].get();
     }
     gfxGlyphExtents *glyphExtents = new gfxGlyphExtents(aAppUnitsPerDevUnit);
     if (glyphExtents) {
         mGlyphExtentsArray.AppendElement(glyphExtents);
         // Initialize the extents of a space glyph, assuming that spaces don't
         // render anything!
         glyphExtents->SetContainedGlyphWidthAppUnits(GetSpaceGlyph(), 0);
     }
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -2078,17 +2078,17 @@ protected:
     // by the platform
     bool                       mApplySyntheticBold;
 
     bool                       mKerningSet;     // kerning explicitly set?
     bool                       mKerningEnabled; // if set, on or off?
 
     nsExpirationState          mExpirationState;
     gfxFontStyle               mStyle;
-    AutoTArray<gfxGlyphExtents*,1> mGlyphExtentsArray;
+    nsTArray<mozilla::UniquePtr<gfxGlyphExtents>> mGlyphExtentsArray;
     mozilla::UniquePtr<nsTHashtable<nsPtrHashKey<GlyphChangeObserver>>>
                                mGlyphChangeObservers;
 
     gfxFloat                   mAdjustedSize;
 
     // Conversion factor from font units to dev units; note that this may be
     // zero (in the degenerate case where mAdjustedSize has become zero).
     // This is OK because we only multiply by this factor, never divide.