Bug 1397292 - Activate all fonts from the "Language Support" folder in a single batch instead of individually, to reduce font-list churn. r=jrmuizel
authorJonathan Kew <jkew@mozilla.com>
Wed, 06 Sep 2017 17:05:26 +0100
changeset 428841 799fd39912bd9e2919377adfa18c3df963c4388e
parent 428840 716bb5054bc71fb77d0014f5d24f959b4e8977b0
child 428842 6dada8a78fd1e84b8bc4ccc791a4f9cf5ccfe105
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1397292
milestone57.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 1397292 - Activate all fonts from the "Language Support" folder in a single batch instead of individually, to reduce font-list churn. r=jrmuizel
gfx/thebes/gfxMacPlatformFontList.mm
--- a/gfx/thebes/gfxMacPlatformFontList.mm
+++ b/gfx/thebes/gfxMacPlatformFontList.mm
@@ -1547,16 +1547,19 @@ gfxMacPlatformFontList::ActivateFontsFro
         return;
     }
 
     nsCOMPtr<nsISimpleEnumerator> e;
     if (NS_FAILED(aDir->GetDirectoryEntries(getter_AddRefs(e)))) {
         return;
     }
 
+    CFMutableArrayRef urls =
+        ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
+
     bool hasMore;
     while (NS_SUCCEEDED(e->HasMoreElements(&hasMore)) && hasMore) {
         nsCOMPtr<nsISupports> entry;
         if (NS_FAILED(e->GetNext(getter_AddRefs(entry)))) {
             break;
         }
         nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
         if (!file) {
@@ -1567,23 +1570,25 @@ gfxMacPlatformFontList::ActivateFontsFro
             continue;
         }
         CFURLRef fontURL =
             ::CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
                                                       (uint8_t*)path.get(),
                                                       path.Length(),
                                                       false);
         if (fontURL) {
-            CFErrorRef error = nullptr;
-            ::CTFontManagerRegisterFontsForURL(fontURL,
-                                               kCTFontManagerScopeProcess,
-                                               &error);
+            ::CFArrayAppendValue(urls, fontURL);
             ::CFRelease(fontURL);
         }
     }
+
+    ::CTFontManagerRegisterFontsForURLs(urls,
+                                        kCTFontManagerScopeProcess,
+                                        nullptr);
+    ::CFRelease(urls);
 }
 
 #ifdef MOZ_BUNDLED_FONTS
 
 void
 gfxMacPlatformFontList::ActivateBundledFonts()
 {
     nsCOMPtr<nsIFile> localDir;