Bug 1189156 (part 5) - Add FontEntryTable typedef and factor out some related code. r=jfkthame.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 04 Aug 2015 18:05:19 -0700
changeset 288464 4a62230eaed4b52e09e53fba5280162f6f51f609
parent 288463 7115a03c413af932ac5d0821c853f474f5a6b438
child 288465 3d180b8dcf42562916e112c55e771c505f4d2f3f
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1189156
milestone42.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 1189156 (part 5) - Add FontEntryTable typedef and factor out some related code. r=jfkthame.
gfx/thebes/gfxPlatformFontList.cpp
gfx/thebes/gfxPlatformFontList.h
--- a/gfx/thebes/gfxPlatformFontList.cpp
+++ b/gfx/thebes/gfxPlatformFontList.cpp
@@ -1055,51 +1055,52 @@ gfxPlatformFontList::SizeOfFontFamilyTab
         // We don't count the size of the family here, because this is an
         // *extra* reference to a family that will have already been counted in
         // the main list.
         n += iter.Key().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
     }
     return n;
 }
 
+/*static*/ size_t
+gfxPlatformFontList::SizeOfFontEntryTableExcludingThis(
+    const FontEntryTable& aTable,
+    MallocSizeOf aMallocSizeOf)
+{
+    size_t n = aTable.ShallowSizeOfExcludingThis(aMallocSizeOf);
+    for (auto iter = aTable.ConstIter(); !iter.Done(); iter.Next()) {
+        // The font itself is counted by its owning family; here we only care
+        // about the names stored in the hashtable keys.
+        n += iter.Key().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
+    }
+    return n;
+}
+
 void
 gfxPlatformFontList::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
                                             FontListSizes* aSizes) const
 {
     aSizes->mFontListSize +=
         mFontFamilies.ShallowSizeOfExcludingThis(aMallocSizeOf);
     for (auto iter = mFontFamilies.ConstIter(); !iter.Done(); iter.Next()) {
         aSizes->mFontListSize +=
             iter.Key().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
         iter.Data()->AddSizeOfIncludingThis(aMallocSizeOf, aSizes);
     }
 
     aSizes->mFontListSize +=
         SizeOfFontFamilyTableExcludingThis(mOtherFamilyNames, aMallocSizeOf);
 
     if (mExtraNames) {
-        // For these two tables, the font itself is counted by its owning
-        // family; here we only care about the names stored in the hashtable
-        // keys.
         aSizes->mFontListSize +=
-            mExtraNames->mFullnames.ShallowSizeOfExcludingThis(aMallocSizeOf);
-        for (auto iter = mExtraNames->mFullnames.ConstIter();
-             !iter.Done();
-             iter.Next()) {
-            aSizes->mFontListSize +=
-                iter.Key().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
-        }
+            SizeOfFontEntryTableExcludingThis(mExtraNames->mFullnames,
+                                              aMallocSizeOf);
         aSizes->mFontListSize +=
-            mExtraNames->mPostscriptNames.ShallowSizeOfExcludingThis(aMallocSizeOf);
-        for (auto iter = mExtraNames->mPostscriptNames.ConstIter();
-             !iter.Done();
-             iter.Next()) {
-            aSizes->mFontListSize +=
-                iter.Key().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
-        }
+            SizeOfFontEntryTableExcludingThis(mExtraNames->mPostscriptNames,
+                                              aMallocSizeOf);
     }
 
     aSizes->mFontListSize +=
         mCodepointsWithNoFonts.SizeOfExcludingThis(aMallocSizeOf);
     aSizes->mFontListSize +=
         mFontFamiliesToLoad.ShallowSizeOfExcludingThis(aMallocSizeOf);
 
     aSizes->mFontListSize +=
--- a/gfx/thebes/gfxPlatformFontList.h
+++ b/gfx/thebes/gfxPlatformFontList.h
@@ -297,21 +297,25 @@ protected:
     void GetPrefsAndStartLoader();
 
     // for font list changes that affect all documents
     void ForceGlobalReflow();
 
     void RebuildLocalFonts();
 
     typedef nsRefPtrHashtable<nsStringHashKey, gfxFontFamily> FontFamilyTable;
+    typedef nsRefPtrHashtable<nsStringHashKey, gfxFontEntry> FontEntryTable;
 
     // used by memory reporter to accumulate sizes of family names in the table
     static size_t
     SizeOfFontFamilyTableExcludingThis(const FontFamilyTable& aTable,
                                        mozilla::MallocSizeOf aMallocSizeOf);
+    static size_t
+    SizeOfFontEntryTableExcludingThis(const FontEntryTable& aTable,
+                                      mozilla::MallocSizeOf aMallocSizeOf);
 
     // canonical family name ==> family entry (unique, one name per family entry)
     FontFamilyTable mFontFamilies;
 
 #if defined(XP_MACOSX)
     // hidden system fonts used within UI elements
     FontFamilyTable mSystemFontFamilies;
 #endif
@@ -323,20 +327,21 @@ protected:
     // flag set after InitOtherFamilyNames is called upon first name lookup miss
     bool mOtherFamilyNamesInitialized;
 
     // flag set after fullname and Postcript name lists are populated
     bool mFaceNameListsInitialized;
 
     struct ExtraNames {
       ExtraNames() : mFullnames(64), mPostscriptNames(64) {}
+
       // fullname ==> font entry (unique, one name per font entry)
-      nsRefPtrHashtable<nsStringHashKey, gfxFontEntry> mFullnames;
+      FontEntryTable mFullnames;
       // Postscript name ==> font entry (unique, one name per font entry)
-      nsRefPtrHashtable<nsStringHashKey, gfxFontEntry> mPostscriptNames;
+      FontEntryTable mPostscriptNames;
     };
     nsAutoPtr<ExtraNames> mExtraNames;
 
     // face names missed when face name loading takes a long time
     nsAutoPtr<nsTHashtable<nsStringHashKey> > mFaceNamesMissed;
 
     // localized family names missed when face name loading takes a long time
     nsAutoPtr<nsTHashtable<nsStringHashKey> > mOtherNamesMissed;