Changeset 252806 in webkit
- Timestamp:
- Nov 22, 2019 2:49:10 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252805 r252806 1 2019-11-22 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Rename some internal names for system fonts 4 https://bugs.webkit.org/show_bug.cgi?id=204486 5 6 Reviewed by Simon Fraser. 7 8 designSystemUI -> systemDesign (because https://developer.apple.com/documentation/appkit/nsfontdescriptorsystemdesign?language=objc) 9 SystemFontDatabaseCoreText::ClientUse -> SystemFontKind 10 ForSystemUI -> SystemUI (because https://drafts.csswg.org/css-fonts-4/#system-ui-def) 11 ForSystemUISerif -> UISerif (because https://drafts.csswg.org/css-fonts-4/#ui-serif-def) 12 ForSystemUIMonospace -> UIMonospace (because https://drafts.csswg.org/css-fonts-4/#ui-monospace-def) 13 ForSystemUIRounded -> UIRounded (because https://drafts.csswg.org/css-fonts-4/#ui-rounded-def) 14 ForTextStyle -> TextStyle (because CTFontDescriptorCreateWithTextStyle()) 15 16 No new tests because there is no behavior change. 17 18 * platform/graphics/cocoa/FontCacheCoreText.cpp: 19 (WebCore::fontWithFamilySpecialCase): 20 * platform/graphics/cocoa/FontDescriptionCocoa.cpp: 21 (WebCore::matchSystemFontUse): 22 (WebCore::systemFontCascadeList): 23 * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp: 24 (WebCore::SystemFontDatabaseCoreText::createSystemDesignFont): 25 (WebCore::SystemFontDatabaseCoreText::cascadeList): 26 (WebCore::SystemFontDatabaseCoreText::systemFontParameters): 27 (WebCore::SystemFontDatabaseCoreText::createDesignSystemUIFont): Deleted. 28 * platform/graphics/cocoa/SystemFontDatabaseCoreText.h: 29 1 30 2019-11-22 Sihui Liu <sihui_liu@apple.com> 2 31 -
trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
r252760 r252806 1268 1268 static RetainPtr<CTFontRef> fontWithFamilySpecialCase(const AtomString& family, const FontDescription& fontDescription, float size, AllowUserInstalledFonts allowUserInstalledFonts) 1269 1269 { 1270 Optional<SystemFont DatabaseCoreText::ClientUse> designSystemUI;1270 Optional<SystemFontKind> systemDesign; 1271 1271 1272 1272 #if HAVE(DESIGN_SYSTEM_UI_FONTS) 1273 1273 if (equalLettersIgnoringASCIICase(family, "ui-serif")) 1274 designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUISerif;1274 systemDesign = SystemFontKind::UISerif; 1275 1275 else if (equalLettersIgnoringASCIICase(family, "ui-monospace")) 1276 designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUIMonospace;1276 systemDesign = SystemFontKind::UIMonospace; 1277 1277 else if (equalLettersIgnoringASCIICase(family, "ui-rounded")) 1278 designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUIRounded;1278 systemDesign = SystemFontKind::UIRounded; 1279 1279 #endif 1280 1280 1281 1281 if (equalLettersIgnoringASCIICase(family, "ui-sans-serif")) { 1282 ASSERT(! designSystemUI);1283 designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUI;1284 } 1285 1286 if ( designSystemUI) {1287 auto cascadeList = SystemFontDatabaseCoreText::singleton().cascadeList(fontDescription, family, * designSystemUI, allowUserInstalledFonts);1282 ASSERT(!systemDesign); 1283 systemDesign = SystemFontKind::SystemUI; 1284 } 1285 1286 if (systemDesign) { 1287 auto cascadeList = SystemFontDatabaseCoreText::singleton().cascadeList(fontDescription, family, *systemDesign, allowUserInstalledFonts); 1288 1288 if (!cascadeList.isEmpty()) 1289 1289 return createFontForInstalledFonts(cascadeList[0].get(), size, allowUserInstalledFonts); -
trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp
r252710 r252806 48 48 #endif 49 49 50 static inline Optional<SystemFont DatabaseCoreText::ClientUse> matchSystemFontUse(const AtomString& string)50 static inline Optional<SystemFontKind> matchSystemFontUse(const AtomString& string) 51 51 { 52 52 if (equalLettersIgnoringASCIICase(string, "-webkit-system-font") … … 55 55 || equalLettersIgnoringASCIICase(string, "system-ui") 56 56 || equalLettersIgnoringASCIICase(string, "ui-sans-serif")) 57 return SystemFont DatabaseCoreText::ClientUse::ForSystemUI;57 return SystemFontKind::SystemUI; 58 58 59 59 #if HAVE(DESIGN_SYSTEM_UI_FONTS) 60 60 if (equalLettersIgnoringASCIICase(string, "ui-serif")) 61 return SystemFont DatabaseCoreText::ClientUse::ForSystemUISerif;61 return SystemFontKind::UISerif; 62 62 if (equalLettersIgnoringASCIICase(string, "ui-monospace")) 63 return SystemFont DatabaseCoreText::ClientUse::ForSystemUIMonospace;63 return SystemFontKind::UIMonospace; 64 64 if (equalLettersIgnoringASCIICase(string, "ui-rounded")) 65 return SystemFont DatabaseCoreText::ClientUse::ForSystemUIRounded;65 return SystemFontKind::UIRounded; 66 66 #endif 67 67 … … 91 91 static auto strings { makeNeverDestroyed(convertArray<AtomString>(styles)) }; 92 92 if (std::find(strings.get().begin(), strings.get().end(), string) != strings.get().end()) 93 return SystemFont DatabaseCoreText::ClientUse::ForTextStyle;93 return SystemFontKind::TextStyle; 94 94 #endif 95 95 … … 97 97 } 98 98 99 static inline Vector<RetainPtr<CTFontDescriptorRef>> systemFontCascadeList(const FontDescription& description, const AtomString& cssFamily, SystemFont DatabaseCoreText::ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)99 static inline Vector<RetainPtr<CTFontDescriptorRef>> systemFontCascadeList(const FontDescription& description, const AtomString& cssFamily, SystemFontKind systemFontKind, AllowUserInstalledFonts allowUserInstalledFonts) 100 100 { 101 return SystemFontDatabaseCoreText::singleton().cascadeList(description, cssFamily, clientUse, allowUserInstalledFonts);101 return SystemFontDatabaseCoreText::singleton().cascadeList(description, cssFamily, systemFontKind, allowUserInstalledFonts); 102 102 } 103 103 -
trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp
r252034 r252806 62 62 63 63 #if HAVE(DESIGN_SYSTEM_UI_FONTS) 64 RetainPtr<CTFontRef> SystemFontDatabaseCoreText::create DesignSystemUIFont(ClientUse clientUse, const CascadeListParameters& parameters)64 RetainPtr<CTFontRef> SystemFontDatabaseCoreText::createSystemDesignFont(SystemFontKind systemFontKind, const CascadeListParameters& parameters) 65 65 { 66 66 CFStringRef design = kCTFontUIFontDesignDefault; 67 switch ( clientUse) {68 case ClientUse::ForSystemUISerif:67 switch (systemFontKind) { 68 case SystemFontKind::UISerif: 69 69 design = kCTFontUIFontDesignSerif; 70 70 break; 71 case ClientUse::ForSystemUIMonospace:71 case SystemFontKind::UIMonospace: 72 72 design = kCTFontUIFontDesignMonospaced; 73 73 break; 74 case ClientUse::ForSystemUIRounded:74 case SystemFontKind::UIRounded: 75 75 design = kCTFontUIFontDesignRounded; 76 76 break; … … 98 98 } 99 99 100 Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const CascadeListParameters& parameters, ClientUse clientUse)100 Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const CascadeListParameters& parameters, SystemFontKind systemFontKind) 101 101 { 102 102 ASSERT(!parameters.fontName.isNull()); … … 104 104 auto localeString = parameters.locale.string().createCFString(); 105 105 RetainPtr<CTFontRef> systemFont; 106 switch ( clientUse) {107 case ClientUse::ForSystemUI:106 switch (systemFontKind) { 107 case SystemFontKind::SystemUI: 108 108 systemFont = createSystemUIFont(parameters, localeString.get()); 109 109 break; 110 case ClientUse::ForSystemUISerif:111 case ClientUse::ForSystemUIMonospace:112 case ClientUse::ForSystemUIRounded:110 case SystemFontKind::UISerif: 111 case SystemFontKind::UIMonospace: 112 case SystemFontKind::UIRounded: 113 113 #if HAVE(DESIGN_SYSTEM_UI_FONTS) 114 systemFont = create DesignSystemUIFont(clientUse, parameters);114 systemFont = createSystemDesignFont(systemFontKind, parameters); 115 115 #endif 116 116 break; 117 case ClientUse::ForTextStyle:117 case SystemFontKind::TextStyle: 118 118 systemFont = createTextStyleFont(parameters); 119 119 break; … … 180 180 } 181 181 182 SystemFontDatabaseCoreText::CascadeListParameters SystemFontDatabaseCoreText::systemFontParameters(const FontDescription& description, const AtomString& familyName, ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)182 SystemFontDatabaseCoreText::CascadeListParameters SystemFontDatabaseCoreText::systemFontParameters(const FontDescription& description, const AtomString& familyName, SystemFontKind systemFontKind, AllowUserInstalledFonts allowUserInstalledFonts) 183 183 { 184 184 CascadeListParameters result; … … 211 211 result.weight = kCTFontWeightBlack; 212 212 213 switch ( clientUse) {214 case ClientUse::ForSystemUI: {213 switch (systemFontKind) { 214 case SystemFontKind::SystemUI: { 215 215 static NeverDestroyed<AtomString> systemUI = AtomString("system-ui", AtomString::ConstructFromLiteral); 216 216 result.fontName = systemUI.get(); 217 217 break; 218 218 } 219 case ClientUse::ForSystemUISerif: {219 case SystemFontKind::UISerif: { 220 220 static NeverDestroyed<AtomString> systemUISerif = AtomString("ui-serif", AtomString::ConstructFromLiteral); 221 221 result.fontName = systemUISerif.get(); 222 222 break; 223 223 } 224 case ClientUse::ForSystemUIMonospace: {224 case SystemFontKind::UIMonospace: { 225 225 static NeverDestroyed<AtomString> systemUIMonospace = AtomString("ui-monospace", AtomString::ConstructFromLiteral); 226 226 result.fontName = systemUIMonospace.get(); 227 227 break; 228 228 } 229 case ClientUse::ForSystemUIRounded: {229 case SystemFontKind::UIRounded: { 230 230 static NeverDestroyed<AtomString> systemUIRounded = AtomString("ui-rounded", AtomString::ConstructFromLiteral); 231 231 result.fontName = systemUIRounded.get(); 232 232 break; 233 233 } 234 case ClientUse::ForTextStyle:234 case SystemFontKind::TextStyle: 235 235 result.fontName = familyName; 236 236 break; … … 240 240 } 241 241 242 Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const FontDescription& description, const AtomString& cssFamily, ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)243 { 244 return cascadeList(systemFontParameters(description, cssFamily, clientUse, allowUserInstalledFonts), clientUse);242 Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const FontDescription& description, const AtomString& cssFamily, SystemFontKind systemFontKind, AllowUserInstalledFonts allowUserInstalledFonts) 243 { 244 return cascadeList(systemFontParameters(description, cssFamily, systemFontKind, allowUserInstalledFonts), systemFontKind); 245 245 } 246 246 -
trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h
r252034 r252806 34 34 35 35 namespace WebCore { 36 37 enum class SystemFontKind : uint8_t { 38 SystemUI, 39 UISerif, 40 UIMonospace, 41 UIRounded, 42 TextStyle 43 }; 36 44 37 45 class SystemFontDatabaseCoreText { … … 97 105 static SystemFontDatabaseCoreText& singleton(); 98 106 99 enum class ClientUse : uint8_t { 100 ForSystemUI, 101 ForSystemUISerif, 102 ForSystemUIMonospace, 103 ForSystemUIRounded, 104 ForTextStyle 105 }; 106 107 Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const FontDescription&, const AtomString& cssFamily, ClientUse, AllowUserInstalledFonts); 107 Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const FontDescription&, const AtomString& cssFamily, SystemFontKind, AllowUserInstalledFonts); 108 108 109 109 String serifFamily(const String& locale); … … 118 118 SystemFontDatabaseCoreText(); 119 119 120 Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const CascadeListParameters&, ClientUse);120 Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const CascadeListParameters&, SystemFontKind); 121 121 122 122 RetainPtr<CTFontRef> createSystemUIFont(const CascadeListParameters&, CFStringRef locale); 123 RetainPtr<CTFontRef> create DesignSystemUIFont(ClientUse, const CascadeListParameters&);123 RetainPtr<CTFontRef> createSystemDesignFont(SystemFontKind, const CascadeListParameters&); 124 124 RetainPtr<CTFontRef> createTextStyleFont(const CascadeListParameters&); 125 125 … … 127 127 static RetainPtr<CTFontDescriptorRef> removeCascadeList(CTFontDescriptorRef); 128 128 static Vector<RetainPtr<CTFontDescriptorRef>> computeCascadeList(CTFontRef, CFStringRef locale); 129 static CascadeListParameters systemFontParameters(const FontDescription&, const AtomString& familyName, ClientUse, AllowUserInstalledFonts);129 static CascadeListParameters systemFontParameters(const FontDescription&, const AtomString& familyName, SystemFontKind, AllowUserInstalledFonts); 130 130 131 131 HashMap<CascadeListParameters, Vector<RetainPtr<CTFontDescriptorRef>>, CascadeListParameters::CascadeListParametersHash, SimpleClassHashTraits<CascadeListParameters>> m_systemFontCache;
Note: See TracChangeset
for help on using the changeset viewer.