Bug 1031187 - Part 1: Set mFamilyName eagerly on proxy and non-proxy gfxFontEntrys. r=jdaggett
authorCameron McCormack <cam@mcc.id.au>
Wed, 09 Jul 2014 17:08:54 +1000
changeset 193239 9ec5db6a1684276d922d3a640dc809c952959870
parent 193238 6131c6ac70cbc72d7f6a183dd8aaebd8a0f372a9
child 193240 df4473d66d3845ae7afc2e83bdab41202f8ba088
push id27112
push usercbook@mozilla.com
push dateThu, 10 Jul 2014 12:47:23 +0000
treeherdermozilla-central@6e9f72bdd32e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett
bugs1031187
milestone33.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 1031187 - Part 1: Set mFamilyName eagerly on proxy and non-proxy gfxFontEntrys. r=jdaggett
gfx/thebes/gfxFont.h
gfx/thebes/gfxUserFontSet.cpp
gfx/thebes/gfxUserFontSet.h
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -813,17 +813,21 @@ public:
     void AddFontEntry(nsRefPtr<gfxFontEntry> aFontEntry) {
         // bug 589682 - set the IgnoreGDEF flag on entries for Italic faces
         // of Times New Roman, because of buggy table in those fonts
         if (aFontEntry->IsItalic() && !aFontEntry->IsUserFont() &&
             Name().EqualsLiteral("Times New Roman"))
         {
             aFontEntry->mIgnoreGDEF = true;
         }
-        aFontEntry->mFamilyName = Name();
+        if (aFontEntry->mFamilyName.IsEmpty()) {
+            aFontEntry->mFamilyName = Name();
+        } else {
+            MOZ_ASSERT(aFontEntry->mFamilyName.Equals(Name()));
+        }
         aFontEntry->mSkipDefaultFeatureSpaceCheck = mSkipDefaultFeatureSpaceCheck;
         mAvailableFonts.AppendElement(aFontEntry);
     }
 
     // note that the styles for this family have been added
     bool HasStyles() { return mHasStyles; }
     void SetHasStyles(bool aHasStyles) { mHasStyles = aHasStyles; }
 
--- a/gfx/thebes/gfxUserFontSet.cpp
+++ b/gfx/thebes/gfxUserFontSet.cpp
@@ -350,16 +350,17 @@ gfxProxyFontEntry::LoadNext(gfxMixedFont
             if (fe) {
                 LOG(("fontset (%p) [src %d] loaded local: (%s) for (%s) gen: %8.8x\n",
                      mFontSet, mSrcIndex,
                      NS_ConvertUTF16toUTF8(currSrc.mLocalName).get(),
                      NS_ConvertUTF16toUTF8(aFamily->Name()).get(),
                      uint32_t(mFontSet->mGeneration)));
                 fe->mFeatureSettings.AppendElements(mFeatureSettings);
                 fe->mLanguageOverride = mLanguageOverride;
+                fe->mFamilyName = mFamilyName;
                 // For src:local(), we don't care whether the request is from
                 // a private window as there's no issue of caching resources;
                 // local fonts are just available all the time.
                 StoreUserFontData(fe, false, nsString(), nullptr, 0);
                 mFontSet->ReplaceFontEntry(aFamily, this, fe);
                 return STATUS_LOADED;
             } else {
                 LOG(("fontset (%p) [src %d] failed local: (%s) for (%s)\n",
@@ -523,16 +524,17 @@ gfxProxyFontEntry::LoadFont(gfxMixedFont
         if (fontType == GFX_USERFONT_WOFF) {
             CopyWOFFMetadata(aFontData, aLength, &metadata, &metaOrigLen);
         }
 
         // copy OpenType feature/language settings from the proxy to the
         // newly-created font entry
         fe->mFeatureSettings.AppendElements(mFeatureSettings);
         fe->mLanguageOverride = mLanguageOverride;
+        fe->mFamilyName = mFamilyName;
         StoreUserFontData(fe, mFontSet->GetPrivateBrowsing(), originalFullName,
                           &metadata, metaOrigLen);
 #ifdef PR_LOGGING
         if (LOG_ENABLED()) {
             nsAutoCString fontURI;
             mSrcList[mSrcIndex].mURI->GetSpec(fontURI);
             LOG(("userfonts (%p) [src %d] loaded uri: (%s) for (%s) gen: %8.8x\n",
                  this, mSrcIndex, fontURI.get(),
@@ -637,16 +639,17 @@ gfxUserFontSet::AddFontFace(const nsAStr
     // construct a new face and add it into the family
     gfxProxyFontEntry *proxyEntry =
         new gfxProxyFontEntry(this, aFontFaceSrcList,
                               aWeight, aStretch,
                               aItalicStyle,
                               aFeatureSettings,
                               aLanguageOverride,
                               aUnicodeRanges);
+    proxyEntry->mFamilyName = aFamilyName;
     family->AddFontEntry(proxyEntry);
 #ifdef PR_LOGGING
     if (LOG_ENABLED()) {
         LOG(("userfonts (%p) added (%s) with style: %s weight: %d stretch: %d",
              this, NS_ConvertUTF16toUTF8(aFamilyName).get(),
              (aItalicStyle & NS_FONT_STYLE_ITALIC ? "italic" :
                  (aItalicStyle & NS_FONT_STYLE_OBLIQUE ? "oblique" : "normal")),
              aWeight, aStretch));
--- a/gfx/thebes/gfxUserFontSet.h
+++ b/gfx/thebes/gfxUserFontSet.h
@@ -98,32 +98,40 @@ public:
         mAvailableFonts.AppendElement(aFontEntry);
         uint32_t i = mAvailableFonts.Length() - 1;
         while (i > 0) {
             if (mAvailableFonts[--i] == aFontEntry) {
                 mAvailableFonts.RemoveElementAt(i);
                 break;
             }
         }
-        aFontEntry->mFamilyName = Name();
+        if (aFontEntry->mFamilyName.IsEmpty()) {
+            aFontEntry->mFamilyName = Name();
+        } else {
+            MOZ_ASSERT(aFontEntry->mFamilyName.Equals(Name()));
+        }
         ResetCharacterMap();
     }
 
     // Replace aProxyFontEntry in the family's list with aRealFontEntry.
     void ReplaceFontEntry(gfxFontEntry *aProxyFontEntry,
                           gfxFontEntry *aRealFontEntry) {
         uint32_t numFonts = mAvailableFonts.Length();
         uint32_t i;
         for (i = 0; i < numFonts; i++) {
             gfxFontEntry *fe = mAvailableFonts[i];
             if (fe == aProxyFontEntry) {
                 // Note that this may delete aProxyFontEntry, if there's no
                 // other reference to it except from its family.
                 mAvailableFonts[i] = aRealFontEntry;
-                aRealFontEntry->mFamilyName = Name();
+                if (aRealFontEntry->mFamilyName.IsEmpty()) {
+                    aRealFontEntry->mFamilyName = Name();
+                } else {
+                    MOZ_ASSERT(aRealFontEntry->mFamilyName.Equals(Name()));
+                }
                 break;
             }
         }
         NS_ASSERTION(i < numFonts, "font entry not found in family!");
         ResetCharacterMap();
     }
 
     // Remove all font entries from the family