[Cocoa] Rename some internal names for system fonts
https://bugs.webkit.org/show_bug.cgi?id=204486

Reviewed by Simon Fraser.

designSystemUI -> systemDesign (because https://developer.apple.com/documentation/appkit/nsfontdescriptorsystemdesign?language=objc)
SystemFontDatabaseCoreText::ClientUse -> SystemFontKind
ForSystemUI -> SystemUI (because https://drafts.csswg.org/css-fonts-4/#system-ui-def)
ForSystemUISerif -> UISerif (because https://drafts.csswg.org/css-fonts-4/#ui-serif-def)
ForSystemUIMonospace -> UIMonospace (because https://drafts.csswg.org/css-fonts-4/#ui-monospace-def)
ForSystemUIRounded -> UIRounded (because https://drafts.csswg.org/css-fonts-4/#ui-rounded-def)
ForTextStyle -> TextStyle (because CTFontDescriptorCreateWithTextStyle())

No new tests because there is no behavior change.

* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::fontWithFamilySpecialCase):
* platform/graphics/cocoa/FontDescriptionCocoa.cpp:
(WebCore::matchSystemFontUse):
(WebCore::systemFontCascadeList):
* platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp:
(WebCore::SystemFontDatabaseCoreText::createSystemDesignFont):
(WebCore::SystemFontDatabaseCoreText::cascadeList):
(WebCore::SystemFontDatabaseCoreText::systemFontParameters):
(WebCore::SystemFontDatabaseCoreText::createDesignSystemUIFont): Deleted.
* platform/graphics/cocoa/SystemFontDatabaseCoreText.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@252806 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 53130b1..2111f67 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2019-11-22  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [Cocoa] Rename some internal names for system fonts
+        https://bugs.webkit.org/show_bug.cgi?id=204486
+
+        Reviewed by Simon Fraser.
+
+        designSystemUI -> systemDesign (because https://developer.apple.com/documentation/appkit/nsfontdescriptorsystemdesign?language=objc)
+        SystemFontDatabaseCoreText::ClientUse -> SystemFontKind
+        ForSystemUI -> SystemUI (because https://drafts.csswg.org/css-fonts-4/#system-ui-def)
+        ForSystemUISerif -> UISerif (because https://drafts.csswg.org/css-fonts-4/#ui-serif-def)
+        ForSystemUIMonospace -> UIMonospace (because https://drafts.csswg.org/css-fonts-4/#ui-monospace-def)
+        ForSystemUIRounded -> UIRounded (because https://drafts.csswg.org/css-fonts-4/#ui-rounded-def)
+        ForTextStyle -> TextStyle (because CTFontDescriptorCreateWithTextStyle())
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::fontWithFamilySpecialCase):
+        * platform/graphics/cocoa/FontDescriptionCocoa.cpp:
+        (WebCore::matchSystemFontUse):
+        (WebCore::systemFontCascadeList):
+        * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp:
+        (WebCore::SystemFontDatabaseCoreText::createSystemDesignFont):
+        (WebCore::SystemFontDatabaseCoreText::cascadeList):
+        (WebCore::SystemFontDatabaseCoreText::systemFontParameters):
+        (WebCore::SystemFontDatabaseCoreText::createDesignSystemUIFont): Deleted.
+        * platform/graphics/cocoa/SystemFontDatabaseCoreText.h:
+
 2019-11-22  Sihui Liu  <sihui_liu@apple.com>
 
         Cross-thread version StorageQuotaManager
diff --git a/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp b/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
index a0252c5..52f19f9 100644
--- a/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
+++ b/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
@@ -1267,24 +1267,24 @@
 
 static RetainPtr<CTFontRef> fontWithFamilySpecialCase(const AtomString& family, const FontDescription& fontDescription, float size, AllowUserInstalledFonts allowUserInstalledFonts)
 {
-    Optional<SystemFontDatabaseCoreText::ClientUse> designSystemUI;
+    Optional<SystemFontKind> systemDesign;
 
 #if HAVE(DESIGN_SYSTEM_UI_FONTS)
     if (equalLettersIgnoringASCIICase(family, "ui-serif"))
-        designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUISerif;
+        systemDesign = SystemFontKind::UISerif;
     else if (equalLettersIgnoringASCIICase(family, "ui-monospace"))
-        designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUIMonospace;
+        systemDesign = SystemFontKind::UIMonospace;
     else if (equalLettersIgnoringASCIICase(family, "ui-rounded"))
-        designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUIRounded;
+        systemDesign = SystemFontKind::UIRounded;
 #endif
 
     if (equalLettersIgnoringASCIICase(family, "ui-sans-serif")) {
-        ASSERT(!designSystemUI);
-        designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUI;
+        ASSERT(!systemDesign);
+        systemDesign = SystemFontKind::SystemUI;
     }
 
-    if (designSystemUI) {
-        auto cascadeList = SystemFontDatabaseCoreText::singleton().cascadeList(fontDescription, family, *designSystemUI, allowUserInstalledFonts);
+    if (systemDesign) {
+        auto cascadeList = SystemFontDatabaseCoreText::singleton().cascadeList(fontDescription, family, *systemDesign, allowUserInstalledFonts);
         if (!cascadeList.isEmpty())
             return createFontForInstalledFonts(cascadeList[0].get(), size, allowUserInstalledFonts);
     }
diff --git a/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp b/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp
index 0d88169..31c67e9 100644
--- a/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp
+++ b/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp
@@ -47,22 +47,22 @@
 }
 #endif
 
-static inline Optional<SystemFontDatabaseCoreText::ClientUse> matchSystemFontUse(const AtomString& string)
+static inline Optional<SystemFontKind> matchSystemFontUse(const AtomString& string)
 {
     if (equalLettersIgnoringASCIICase(string, "-webkit-system-font")
         || equalLettersIgnoringASCIICase(string, "-apple-system")
         || equalLettersIgnoringASCIICase(string, "-apple-system-font")
         || equalLettersIgnoringASCIICase(string, "system-ui")
         || equalLettersIgnoringASCIICase(string, "ui-sans-serif"))
-        return SystemFontDatabaseCoreText::ClientUse::ForSystemUI;
+        return SystemFontKind::SystemUI;
 
 #if HAVE(DESIGN_SYSTEM_UI_FONTS)
     if (equalLettersIgnoringASCIICase(string, "ui-serif"))
-        return SystemFontDatabaseCoreText::ClientUse::ForSystemUISerif;
+        return SystemFontKind::UISerif;
     if (equalLettersIgnoringASCIICase(string, "ui-monospace"))
-        return SystemFontDatabaseCoreText::ClientUse::ForSystemUIMonospace;
+        return SystemFontKind::UIMonospace;
     if (equalLettersIgnoringASCIICase(string, "ui-rounded"))
-        return SystemFontDatabaseCoreText::ClientUse::ForSystemUIRounded;
+        return SystemFontKind::UIRounded;
 #endif
 
 #if PLATFORM(IOS_FAMILY)
@@ -90,15 +90,15 @@
     
     static auto strings { makeNeverDestroyed(convertArray<AtomString>(styles)) };
     if (std::find(strings.get().begin(), strings.get().end(), string) != strings.get().end())
-        return SystemFontDatabaseCoreText::ClientUse::ForTextStyle;
+        return SystemFontKind::TextStyle;
 #endif
 
     return WTF::nullopt;
 }
 
-static inline Vector<RetainPtr<CTFontDescriptorRef>> systemFontCascadeList(const FontDescription& description, const AtomString& cssFamily, SystemFontDatabaseCoreText::ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)
+static inline Vector<RetainPtr<CTFontDescriptorRef>> systemFontCascadeList(const FontDescription& description, const AtomString& cssFamily, SystemFontKind systemFontKind, AllowUserInstalledFonts allowUserInstalledFonts)
 {
-    return SystemFontDatabaseCoreText::singleton().cascadeList(description, cssFamily, clientUse, allowUserInstalledFonts);
+    return SystemFontDatabaseCoreText::singleton().cascadeList(description, cssFamily, systemFontKind, allowUserInstalledFonts);
 }
 
 unsigned FontCascadeDescription::effectiveFamilyCount() const
diff --git a/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp b/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp
index 5fe8851..7e563e8 100644
--- a/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp
+++ b/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp
@@ -61,17 +61,17 @@
 }
 
 #if HAVE(DESIGN_SYSTEM_UI_FONTS)
-RetainPtr<CTFontRef> SystemFontDatabaseCoreText::createDesignSystemUIFont(ClientUse clientUse, const CascadeListParameters& parameters)
+RetainPtr<CTFontRef> SystemFontDatabaseCoreText::createSystemDesignFont(SystemFontKind systemFontKind, const CascadeListParameters& parameters)
 {
     CFStringRef design = kCTFontUIFontDesignDefault;
-    switch (clientUse) {
-    case ClientUse::ForSystemUISerif:
+    switch (systemFontKind) {
+    case SystemFontKind::UISerif:
         design = kCTFontUIFontDesignSerif;
         break;
-    case ClientUse::ForSystemUIMonospace:
+    case SystemFontKind::UIMonospace:
         design = kCTFontUIFontDesignMonospaced;
         break;
-    case ClientUse::ForSystemUIRounded:
+    case SystemFontKind::UIRounded:
         design = kCTFontUIFontDesignRounded;
         break;
     default:
@@ -97,24 +97,24 @@
 #endif
 }
 
-Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const CascadeListParameters& parameters, ClientUse clientUse)
+Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const CascadeListParameters& parameters, SystemFontKind systemFontKind)
 {
     ASSERT(!parameters.fontName.isNull());
     return m_systemFontCache.ensure(parameters, [&] {
         auto localeString = parameters.locale.string().createCFString();
         RetainPtr<CTFontRef> systemFont;
-        switch (clientUse) {
-        case ClientUse::ForSystemUI:
+        switch (systemFontKind) {
+        case SystemFontKind::SystemUI:
             systemFont = createSystemUIFont(parameters, localeString.get());
             break;
-        case ClientUse::ForSystemUISerif:
-        case ClientUse::ForSystemUIMonospace:
-        case ClientUse::ForSystemUIRounded:
+        case SystemFontKind::UISerif:
+        case SystemFontKind::UIMonospace:
+        case SystemFontKind::UIRounded:
 #if HAVE(DESIGN_SYSTEM_UI_FONTS)
-            systemFont = createDesignSystemUIFont(clientUse, parameters);
+            systemFont = createSystemDesignFont(systemFontKind, parameters);
 #endif
             break;
-        case ClientUse::ForTextStyle:
+        case SystemFontKind::TextStyle:
             systemFont = createTextStyleFont(parameters);
             break;
         }
@@ -179,7 +179,7 @@
     return result;
 }
 
-SystemFontDatabaseCoreText::CascadeListParameters SystemFontDatabaseCoreText::systemFontParameters(const FontDescription& description, const AtomString& familyName, ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)
+SystemFontDatabaseCoreText::CascadeListParameters SystemFontDatabaseCoreText::systemFontParameters(const FontDescription& description, const AtomString& familyName, SystemFontKind systemFontKind, AllowUserInstalledFonts allowUserInstalledFonts)
 {
     CascadeListParameters result;
     result.locale = description.locale();
@@ -210,28 +210,28 @@
     else
         result.weight = kCTFontWeightBlack;
 
-    switch (clientUse) {
-    case ClientUse::ForSystemUI: {
+    switch (systemFontKind) {
+    case SystemFontKind::SystemUI: {
         static NeverDestroyed<AtomString> systemUI = AtomString("system-ui", AtomString::ConstructFromLiteral);
         result.fontName = systemUI.get();
         break;
     }
-    case ClientUse::ForSystemUISerif: {
+    case SystemFontKind::UISerif: {
         static NeverDestroyed<AtomString> systemUISerif = AtomString("ui-serif", AtomString::ConstructFromLiteral);
         result.fontName = systemUISerif.get();
         break;
     }
-    case ClientUse::ForSystemUIMonospace: {
+    case SystemFontKind::UIMonospace: {
         static NeverDestroyed<AtomString> systemUIMonospace = AtomString("ui-monospace", AtomString::ConstructFromLiteral);
         result.fontName = systemUIMonospace.get();
         break;
     }
-    case ClientUse::ForSystemUIRounded: {
+    case SystemFontKind::UIRounded: {
         static NeverDestroyed<AtomString> systemUIRounded = AtomString("ui-rounded", AtomString::ConstructFromLiteral);
         result.fontName = systemUIRounded.get();
         break;
     }
-    case ClientUse::ForTextStyle:
+    case SystemFontKind::TextStyle:
         result.fontName = familyName;
         break;
     }
@@ -239,9 +239,9 @@
     return result;
 }
 
-Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const FontDescription& description, const AtomString& cssFamily, ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)
+Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const FontDescription& description, const AtomString& cssFamily, SystemFontKind systemFontKind, AllowUserInstalledFonts allowUserInstalledFonts)
 {
-    return cascadeList(systemFontParameters(description, cssFamily, clientUse, allowUserInstalledFonts), clientUse);
+    return cascadeList(systemFontParameters(description, cssFamily, systemFontKind, allowUserInstalledFonts), systemFontKind);
 }
 
 #endif // USE(PLATFORM_SYSTEM_FALLBACK_LIST)
diff --git a/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h b/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h
index 8c09c31..f360f3c 100644
--- a/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h
+++ b/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h
@@ -34,6 +34,14 @@
 
 namespace WebCore {
 
+enum class SystemFontKind : uint8_t {
+    SystemUI,
+    UISerif,
+    UIMonospace,
+    UIRounded,
+    TextStyle
+};
+
 class SystemFontDatabaseCoreText {
 public:
     struct CascadeListParameters {
@@ -96,15 +104,7 @@
 
     static SystemFontDatabaseCoreText& singleton();
 
-    enum class ClientUse : uint8_t {
-        ForSystemUI,
-        ForSystemUISerif,
-        ForSystemUIMonospace,
-        ForSystemUIRounded,
-        ForTextStyle
-    };
-
-    Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const FontDescription&, const AtomString& cssFamily, ClientUse, AllowUserInstalledFonts);
+    Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const FontDescription&, const AtomString& cssFamily, SystemFontKind, AllowUserInstalledFonts);
 
     String serifFamily(const String& locale);
     String sansSerifFamily(const String& locale);
@@ -117,16 +117,16 @@
 private:
     SystemFontDatabaseCoreText();
 
-    Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const CascadeListParameters&, ClientUse);
+    Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const CascadeListParameters&, SystemFontKind);
 
     RetainPtr<CTFontRef> createSystemUIFont(const CascadeListParameters&, CFStringRef locale);
-    RetainPtr<CTFontRef> createDesignSystemUIFont(ClientUse, const CascadeListParameters&);
+    RetainPtr<CTFontRef> createSystemDesignFont(SystemFontKind, const CascadeListParameters&);
     RetainPtr<CTFontRef> createTextStyleFont(const CascadeListParameters&);
 
     static RetainPtr<CTFontRef> createFontByApplyingWeightItalicsAndFallbackBehavior(CTFontRef, CGFloat weight, bool italic, float size, AllowUserInstalledFonts, CFStringRef design = nullptr);
     static RetainPtr<CTFontDescriptorRef> removeCascadeList(CTFontDescriptorRef);
     static Vector<RetainPtr<CTFontDescriptorRef>> computeCascadeList(CTFontRef, CFStringRef locale);
-    static CascadeListParameters systemFontParameters(const FontDescription&, const AtomString& familyName, ClientUse, AllowUserInstalledFonts);
+    static CascadeListParameters systemFontParameters(const FontDescription&, const AtomString& familyName, SystemFontKind, AllowUserInstalledFonts);
 
     HashMap<CascadeListParameters, Vector<RetainPtr<CTFontDescriptorRef>>, CascadeListParameters::CascadeListParametersHash, SimpleClassHashTraits<CascadeListParameters>> m_systemFontCache;