Title: [226522] tags/Safari-605.1.19.1

Diff

Modified: tags/Safari-605.1.19.1/LayoutTests/ChangeLog (226521 => 226522)


--- tags/Safari-605.1.19.1/LayoutTests/ChangeLog	2018-01-08 18:47:26 UTC (rev 226521)
+++ tags/Safari-605.1.19.1/LayoutTests/ChangeLog	2018-01-08 18:54:53 UTC (rev 226522)
@@ -1,3 +1,18 @@
+2018-01-08  Jason Marcell  <[email protected]>
+
+        Cherry-pick r226371. rdar://problem/36146670
+
+    2018-01-03  Joseph Pecoraro  <[email protected]>
+
+            Web Inspector: Slow open time enumerating system fonts (FontCache::systemFontFamilies)
+            https://bugs.webkit.org/show_bug.cgi?id=180979
+            <rdar://problem/36146670>
+
+            Reviewed by Matt Baker.
+
+            * inspector/css/get-system-fonts.html:
+            Cleanup the test a bit.
+
 2018-01-07  Jason Marcell  <[email protected]>
 
         Cherry-pick r226359. rdar://problem/36146670

Modified: tags/Safari-605.1.19.1/LayoutTests/inspector/css/get-system-fonts.html (226521 => 226522)


--- tags/Safari-605.1.19.1/LayoutTests/inspector/css/get-system-fonts.html	2018-01-08 18:47:26 UTC (rev 226521)
+++ tags/Safari-605.1.19.1/LayoutTests/inspector/css/get-system-fonts.html	2018-01-08 18:54:53 UTC (rev 226522)
@@ -28,7 +28,6 @@
 </script>
 </head>
 <body _onload_="runTest()">
-  <p>This test ensures that the inspector can enumerate system font families, and checks for the
-     existence of common fonts.</p>
+<p>This test ensures that the inspector can enumerate system font families, and checks for the existence of common fonts.</p>
 </body>
 </html>

Modified: tags/Safari-605.1.19.1/Source/WebCore/ChangeLog (226521 => 226522)


--- tags/Safari-605.1.19.1/Source/WebCore/ChangeLog	2018-01-08 18:47:26 UTC (rev 226521)
+++ tags/Safari-605.1.19.1/Source/WebCore/ChangeLog	2018-01-08 18:54:53 UTC (rev 226522)
@@ -1,3 +1,24 @@
+2018-01-08  Jason Marcell  <[email protected]>
+
+        Cherry-pick r226371. rdar://problem/36146670
+
+    2018-01-03  Joseph Pecoraro  <[email protected]>
+
+            Web Inspector: Slow open time enumerating system fonts (FontCache::systemFontFamilies)
+            https://bugs.webkit.org/show_bug.cgi?id=180979
+            <rdar://problem/36146670>
+
+            Reviewed by Matt Baker.
+
+            * platform/graphics/cocoa/FontCacheCoreText.cpp:
+            (fontNameIsSystemFont):
+            (WebCore::FontCache::systemFontFamilies):
+            Switch to the original Mac algorithm before r180979 that uses
+            CTFontManagerCopyAvailableFontFamilyNames. Previously this wasn't
+            available on iOS but now it is. This is a performance improvement on
+            both platforms, but significantly so on macOS. It also finds more,
+            valid, family names.
+
 2018-01-07  Jason Marcell  <[email protected]>
 
         Cherry-pick r226359. rdar://problem/36146670

Modified: tags/Safari-605.1.19.1/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (226521 => 226522)


--- tags/Safari-605.1.19.1/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2018-01-08 18:47:26 UTC (rev 226521)
+++ tags/Safari-605.1.19.1/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2018-01-08 18:54:53 UTC (rev 226522)
@@ -367,6 +367,11 @@
     return result;
 }
 
+static inline bool fontNameIsSystemFont(CFStringRef fontName)
+{
+    return CFStringGetLength(fontName) > 0 && CFStringGetCharacterAtIndex(fontName, 0) == '.';
+}
+
 #if ENABLE(VARIATION_FONTS)
 struct VariationDefaults {
     float defaultValue;
@@ -417,8 +422,9 @@
 {
     if (CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get()))
         return true;
+
     auto name = adoptCF(CTFontCopyPostScriptName(font));
-    return CFStringGetLength(name.get()) > 0 && CFStringGetCharacterAtIndex(name.get(), 0) == '.';
+    return fontNameIsSystemFont(name.get());
 }
 
 // These values were calculated by performing a linear regression on the CSS weights/widths/slopes and Core Text weights/widths/slopes of San Francisco.
@@ -731,25 +737,24 @@
 
 Vector<String> FontCache::systemFontFamilies()
 {
-    // FIXME: <rdar://problem/21890188>
-    auto attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, nullptr, nullptr, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
-    auto emptyFontDescriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
-    auto matchedDescriptors = adoptCF(CTFontDescriptorCreateMatchingFontDescriptors(emptyFontDescriptor.get(), nullptr));
-    if (!matchedDescriptors)
-        return { };
+    Vector<String> fontFamilies;
 
-    CFIndex numMatches = CFArrayGetCount(matchedDescriptors.get());
-    if (!numMatches)
-        return { };
+    auto availableFontFamilies = adoptCF(CTFontManagerCopyAvailableFontFamilyNames());
+    CFIndex count = CFArrayGetCount(availableFontFamilies.get());
+    for (CFIndex i = 0; i < count; ++i) {
+        CFStringRef fontName = static_cast<CFStringRef>(CFArrayGetValueAtIndex(availableFontFamilies.get(), i));
+        if (CFGetTypeID(fontName) != CFStringGetTypeID()) {
+            ASSERT_NOT_REACHED();
+            continue;
+        }
 
-    HashSet<String> visited;
-    for (CFIndex i = 0; i < numMatches; ++i) {
-        auto fontDescriptor = static_cast<CTFontDescriptorRef>(CFArrayGetValueAtIndex(matchedDescriptors.get(), i));
-        if (auto familyName = adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontFamilyNameAttribute))))
-            visited.add(familyName.get());
+        if (fontNameIsSystemFont(fontName))
+            continue;
+
+        fontFamilies.append(fontName);
     }
 
-    return copyToVector(visited);
+    return fontFamilies;
 }
 
 static CTFontSymbolicTraits computeTraits(const FontDescription& fontDescription)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to