bug 950590 - part 1 - use nsRefPtr instead of manual addref/release calls for gfxFontGroup's reference to the user font set. r=roc a=lsblakk
authorJonathan Kew <jkew@mozilla.com>
Sun, 22 Dec 2013 19:25:53 +0000
changeset 175462 4b603966034c44a3be217fc3525da95ffd758fb3
parent 175461 dbde477a0625cfc164a60787387b19179bfc7b05
child 175463 af28fe58e2637d734dd6cba1b9f15e8061995f15
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, lsblakk
bugs950590
milestone28.0a2
bug 950590 - part 1 - use nsRefPtr instead of manual addref/release calls for gfxFontGroup's reference to the user font set. r=roc a=lsblakk
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -4056,23 +4056,20 @@ gfxGlyphExtents::SizeOfIncludingThis(Mal
 gfxFontGroup::gfxFontGroup(const nsAString& aFamilies,
                            const gfxFontStyle *aStyle,
                            gfxUserFontSet *aUserFontSet)
     : mFamilies(aFamilies)
     , mStyle(*aStyle)
     , mUnderlineOffset(UNDERLINE_OFFSET_NOT_SET)
     , mHyphenWidth(-1)
     , mTextPerf(nullptr)
-{
-    mUserFontSet = nullptr;
+    , mPageLang(gfxPlatform::GetFontPrefLangFor(aStyle->language))
+    , mSkipDrawing(false)
+{
     SetUserFontSet(aUserFontSet);
-
-    mSkipDrawing = false;
-
-    mPageLang = gfxPlatform::GetFontPrefLangFor(mStyle.language);
     BuildFontList();
 }
 
 void
 gfxFontGroup::BuildFontList()
 {
 // "#if" to be removed once all platforms are moved to gfxPlatformFontList interface
 // and subclasses of gfxFontGroup eliminated
@@ -4210,17 +4207,16 @@ gfxFontGroup::HasFont(const gfxFontEntry
             return true;
     }
     return false;
 }
 
 gfxFontGroup::~gfxFontGroup()
 {
     mFonts.Clear();
-    SetUserFontSet(nullptr);
 }
 
 gfxFontGroup *
 gfxFontGroup::Copy(const gfxFontStyle *aStyle)
 {
     gfxFontGroup *fg = new gfxFontGroup(mFamilies, aStyle, mUserFontSet);
     fg->SetTextPerfMetrics(mTextPerf);
     return fg;
@@ -5105,19 +5101,17 @@ gfxUserFontSet*
 gfxFontGroup::GetUserFontSet()
 {
     return mUserFontSet;
 }
 
 void 
 gfxFontGroup::SetUserFontSet(gfxUserFontSet *aUserFontSet)
 {
-    NS_IF_RELEASE(mUserFontSet);
     mUserFontSet = aUserFontSet;
-    NS_IF_ADDREF(mUserFontSet);
     mCurrGeneration = GetGeneration();
 }
 
 uint64_t
 gfxFontGroup::GetGeneration()
 {
     if (!mUserFontSet)
         return 0;
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -3535,17 +3535,17 @@ public:
 
 protected:
     nsString mFamilies;
     gfxFontStyle mStyle;
     nsTArray<FamilyFace> mFonts;
     gfxFloat mUnderlineOffset;
     gfxFloat mHyphenWidth;
 
-    gfxUserFontSet* mUserFontSet;
+    nsRefPtr<gfxUserFontSet> mUserFontSet;
     uint64_t mCurrGeneration;  // track the current user font set generation, rebuild font list if needed
 
     gfxTextPerfMetrics *mTextPerf;
 
     // Cache a textrun representing an ellipsis (useful for CSS text-overflow)
     // at a specific appUnitsPerDevPixel size
     nsAutoPtr<gfxTextRun>   mCachedEllipsisTextRun;