Title: [226371] trunk
- Revision
- 226371
- Author
- commit-qu...@webkit.org
- Date
- 2018-01-03 12:17:12 -0800 (Wed, 03 Jan 2018)
Log Message
Web Inspector: Slow open time enumerating system fonts (FontCache::systemFontFamilies)
https://bugs.webkit.org/show_bug.cgi?id=180979
<rdar://problem/36146670>
Patch by Joseph Pecoraro <pecor...@apple.com> on 2018-01-03
Reviewed by Matt Baker.
Source/WebCore:
* 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.
LayoutTests:
* inspector/css/get-system-fonts.html:
Cleanup the test a bit.
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (226370 => 226371)
--- trunk/LayoutTests/ChangeLog 2018-01-03 20:16:04 UTC (rev 226370)
+++ trunk/LayoutTests/ChangeLog 2018-01-03 20:17:12 UTC (rev 226371)
@@ -1,3 +1,14 @@
+2018-01-03 Joseph Pecoraro <pecor...@apple.com>
+
+ 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-03 Simon Fraser <simon.fra...@apple.com>
SVG lighting filter lights are in the wrong coordinate system
Modified: trunk/LayoutTests/inspector/css/get-system-fonts.html (226370 => 226371)
--- trunk/LayoutTests/inspector/css/get-system-fonts.html 2018-01-03 20:16:04 UTC (rev 226370)
+++ trunk/LayoutTests/inspector/css/get-system-fonts.html 2018-01-03 20:17:12 UTC (rev 226371)
@@ -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: trunk/Source/WebCore/ChangeLog (226370 => 226371)
--- trunk/Source/WebCore/ChangeLog 2018-01-03 20:16:04 UTC (rev 226370)
+++ trunk/Source/WebCore/ChangeLog 2018-01-03 20:17:12 UTC (rev 226371)
@@ -1,3 +1,20 @@
+2018-01-03 Joseph Pecoraro <pecor...@apple.com>
+
+ 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-03 Michael Catanzaro <mcatanz...@igalia.com>
ASSERTION FAILED: !source || is<Target>(*source) in CoordinatedGraphicsLayer::removeFromParent
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (226370 => 226371)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2018-01-03 20:16:04 UTC (rev 226370)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2018-01-03 20:17:12 UTC (rev 226371)
@@ -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
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes