Changeset 226352 in webkit
- Timestamp:
- Jan 2, 2018 8:16:06 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r226346 r226352 1 2018-01-02 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: Slow open time enumerating system fonts (FontCache::systemFontFamilies) 4 https://bugs.webkit.org/show_bug.cgi?id=180979 5 <rdar://problem/36146670> 6 7 Reviewed by Matt Baker. 8 9 * inspector/css/get-system-fonts.html: 10 Cleanup the test a bit. 11 1 12 2018-01-02 Michael Catanzaro <mcatanzaro@igalia.com> 2 13 -
trunk/LayoutTests/inspector/css/get-system-fonts.html
r210062 r226352 29 29 </head> 30 30 <body onload="runTest()"> 31 <p>This test ensures that the inspector can enumerate system font families, and checks for the 32 existence of common fonts.</p> 31 <p>This test ensures that the inspector can enumerate system font families, and checks for the existence of common fonts.</p> 33 32 </body> 34 33 </html> -
trunk/Source/WebCore/ChangeLog
r226350 r226352 1 2018-01-02 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: Slow open time enumerating system fonts (FontCache::systemFontFamilies) 4 https://bugs.webkit.org/show_bug.cgi?id=180979 5 <rdar://problem/36146670> 6 7 Reviewed by Matt Baker. 8 9 * platform/graphics/cocoa/FontCacheCoreText.cpp: 10 (WebCore::FontCache::systemFontFamilies): 11 Switch to the original Mac algorithm before r180979 that uses 12 CTFontManagerCopyAvailableFontFamilyNames. Previously this wasn't 13 available on iOS but now it is. This is a performance improvement on 14 both platforms, but significantly so on macOS. It also finds more, 15 valid, family names. 16 1 17 2018-01-02 Yusuke Suzuki <utatane.tea@gmail.com> 2 18 -
trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
r226191 r226352 414 414 } 415 415 416 static inline bool fontNameIsSystemFont(CFStringRef fontName) 417 { 418 return CFStringGetLength(fontName) > 0 && CFStringGetCharacterAtIndex(fontName, 0) == '.'; 419 } 420 416 421 static inline bool fontIsSystemFont(CTFontRef font) 417 422 { 418 423 if (CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get())) 419 424 return true; 425 420 426 auto name = adoptCF(CTFontCopyPostScriptName(font)); 421 return CFStringGetLength(name.get()) > 0 && CFStringGetCharacterAtIndex(name.get(), 0) == '.';427 return fontNameIsSystemFont(name.get()); 422 428 } 423 429 … … 732 738 Vector<String> FontCache::systemFontFamilies() 733 739 { 734 // FIXME: <rdar://problem/21890188> 735 auto attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, nullptr, nullptr, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 736 auto emptyFontDescriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get())); 737 auto matchedDescriptors = adoptCF(CTFontDescriptorCreateMatchingFontDescriptors(emptyFontDescriptor.get(), nullptr)); 738 if (!matchedDescriptors) 739 return { }; 740 741 CFIndex numMatches = CFArrayGetCount(matchedDescriptors.get()); 742 if (!numMatches) 743 return { }; 744 745 HashSet<String> visited; 746 for (CFIndex i = 0; i < numMatches; ++i) { 747 auto fontDescriptor = static_cast<CTFontDescriptorRef>(CFArrayGetValueAtIndex(matchedDescriptors.get(), i)); 748 if (auto familyName = adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontFamilyNameAttribute)))) 749 visited.add(familyName.get()); 750 } 751 752 return copyToVector(visited); 740 Vector<String> fontFamilies; 741 742 auto availableFontFamilies = adoptCF(CTFontManagerCopyAvailableFontFamilyNames()); 743 CFIndex count = CFArrayGetCount(availableFontFamilies.get()); 744 for (CFIndex i = 0; i < count; ++i) { 745 CFStringRef fontName = static_cast<CFStringRef>(CFArrayGetValueAtIndex(availableFontFamilies.get(), i)); 746 if (CFGetTypeID(fontName) != CFStringGetTypeID()) { 747 ASSERT_NOT_REACHED(); 748 continue; 749 } 750 751 if (fontNameIsSystemFont(fontName)) 752 continue; 753 754 fontFamilies.append(fontName); 755 } 756 757 return fontFamilies; 753 758 } 754 759
Note: See TracChangeset
for help on using the changeset viewer.