Title: [226359] trunk
Revision
226359
Author
[email protected]
Date
2018-01-03 09:05:12 -0800 (Wed, 03 Jan 2018)

Log Message

Unreviewed, rolling out r226352.

Breaks Sierra and El Capitan builds.

Reverted changeset:

"Web Inspector: Slow open time enumerating system fonts
(FontCache::systemFontFamilies)"
https://bugs.webkit.org/show_bug.cgi?id=180979
https://trac.webkit.org/changeset/226352

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (226358 => 226359)


--- trunk/LayoutTests/ChangeLog	2018-01-03 11:01:32 UTC (rev 226358)
+++ trunk/LayoutTests/ChangeLog	2018-01-03 17:05:12 UTC (rev 226359)
@@ -1,3 +1,16 @@
+2018-01-03  Ryan Haddad  <[email protected]>
+
+        Unreviewed, rolling out r226352.
+
+        Breaks Sierra and El Capitan builds.
+
+        Reverted changeset:
+
+        "Web Inspector: Slow open time enumerating system fonts
+        (FontCache::systemFontFamilies)"
+        https://bugs.webkit.org/show_bug.cgi?id=180979
+        https://trac.webkit.org/changeset/226352
+
 2018-01-03  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Crash destroying WebCore::FileMonitor

Modified: trunk/LayoutTests/inspector/css/get-system-fonts.html (226358 => 226359)


--- trunk/LayoutTests/inspector/css/get-system-fonts.html	2018-01-03 11:01:32 UTC (rev 226358)
+++ trunk/LayoutTests/inspector/css/get-system-fonts.html	2018-01-03 17:05:12 UTC (rev 226359)
@@ -28,6 +28,7 @@
 </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: trunk/Source/WebCore/ChangeLog (226358 => 226359)


--- trunk/Source/WebCore/ChangeLog	2018-01-03 11:01:32 UTC (rev 226358)
+++ trunk/Source/WebCore/ChangeLog	2018-01-03 17:05:12 UTC (rev 226359)
@@ -1,3 +1,16 @@
+2018-01-03  Ryan Haddad  <[email protected]>
+
+        Unreviewed, rolling out r226352.
+
+        Breaks Sierra and El Capitan builds.
+
+        Reverted changeset:
+
+        "Web Inspector: Slow open time enumerating system fonts
+        (FontCache::systemFontFamilies)"
+        https://bugs.webkit.org/show_bug.cgi?id=180979
+        https://trac.webkit.org/changeset/226352
+
 2018-01-03  Philippe Normand  <[email protected]>
 
         [GStreamer] The bus synchronous handler should be in the base player class

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (226358 => 226359)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2018-01-03 11:01:32 UTC (rev 226358)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2018-01-03 17:05:12 UTC (rev 226359)
@@ -413,18 +413,12 @@
     return result;
 }
 
-static inline bool fontNameIsSystemFont(CFStringRef fontName)
-{
-    return CFStringGetLength(fontName) > 0 && CFStringGetCharacterAtIndex(fontName, 0) == '.';
-}
-
 static inline bool fontIsSystemFont(CTFontRef font)
 {
     if (CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get()))
         return true;
-
     auto name = adoptCF(CTFontCopyPostScriptName(font));
-    return fontNameIsSystemFont(name.get());
+    return CFStringGetLength(name.get()) > 0 && CFStringGetCharacterAtIndex(name.get(), 0) == '.';
 }
 
 // These values were calculated by performing a linear regression on the CSS weights/widths/slopes and Core Text weights/widths/slopes of San Francisco.
@@ -737,24 +731,25 @@
 
 Vector<String> FontCache::systemFontFamilies()
 {
-    Vector<String> fontFamilies;
+    // 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 { };
 
-    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;
-        }
+    CFIndex numMatches = CFArrayGetCount(matchedDescriptors.get());
+    if (!numMatches)
+        return { };
 
-        if (fontNameIsSystemFont(fontName))
-            continue;
-
-        fontFamilies.append(fontName);
+    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());
     }
 
-    return fontFamilies;
+    return copyToVector(visited);
 }
 
 static CTFontSymbolicTraits computeTraits(const FontDescription& fontDescription)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to