Changeset 252806 in webkit


Ignore:
Timestamp:
Nov 22, 2019 2:49:10 PM (4 years ago)
Author:
mmaxfield@apple.com
Message:

[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:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r252805 r252806  
     12019-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
    1302019-11-22  Sihui Liu  <sihui_liu@apple.com>
    231
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp

    r252760 r252806  
    12681268static RetainPtr<CTFontRef> fontWithFamilySpecialCase(const AtomString& family, const FontDescription& fontDescription, float size, AllowUserInstalledFonts allowUserInstalledFonts)
    12691269{
    1270     Optional<SystemFontDatabaseCoreText::ClientUse> designSystemUI;
     1270    Optional<SystemFontKind> systemDesign;
    12711271
    12721272#if HAVE(DESIGN_SYSTEM_UI_FONTS)
    12731273    if (equalLettersIgnoringASCIICase(family, "ui-serif"))
    1274         designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUISerif;
     1274        systemDesign = SystemFontKind::UISerif;
    12751275    else if (equalLettersIgnoringASCIICase(family, "ui-monospace"))
    1276         designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUIMonospace;
     1276        systemDesign = SystemFontKind::UIMonospace;
    12771277    else if (equalLettersIgnoringASCIICase(family, "ui-rounded"))
    1278         designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUIRounded;
     1278        systemDesign = SystemFontKind::UIRounded;
    12791279#endif
    12801280
    12811281    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);
    12881288        if (!cascadeList.isEmpty())
    12891289            return createFontForInstalledFonts(cascadeList[0].get(), size, allowUserInstalledFonts);
  • trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp

    r252710 r252806  
    4848#endif
    4949
    50 static inline Optional<SystemFontDatabaseCoreText::ClientUse> matchSystemFontUse(const AtomString& string)
     50static inline Optional<SystemFontKind> matchSystemFontUse(const AtomString& string)
    5151{
    5252    if (equalLettersIgnoringASCIICase(string, "-webkit-system-font")
     
    5555        || equalLettersIgnoringASCIICase(string, "system-ui")
    5656        || equalLettersIgnoringASCIICase(string, "ui-sans-serif"))
    57         return SystemFontDatabaseCoreText::ClientUse::ForSystemUI;
     57        return SystemFontKind::SystemUI;
    5858
    5959#if HAVE(DESIGN_SYSTEM_UI_FONTS)
    6060    if (equalLettersIgnoringASCIICase(string, "ui-serif"))
    61         return SystemFontDatabaseCoreText::ClientUse::ForSystemUISerif;
     61        return SystemFontKind::UISerif;
    6262    if (equalLettersIgnoringASCIICase(string, "ui-monospace"))
    63         return SystemFontDatabaseCoreText::ClientUse::ForSystemUIMonospace;
     63        return SystemFontKind::UIMonospace;
    6464    if (equalLettersIgnoringASCIICase(string, "ui-rounded"))
    65         return SystemFontDatabaseCoreText::ClientUse::ForSystemUIRounded;
     65        return SystemFontKind::UIRounded;
    6666#endif
    6767
     
    9191    static auto strings { makeNeverDestroyed(convertArray<AtomString>(styles)) };
    9292    if (std::find(strings.get().begin(), strings.get().end(), string) != strings.get().end())
    93         return SystemFontDatabaseCoreText::ClientUse::ForTextStyle;
     93        return SystemFontKind::TextStyle;
    9494#endif
    9595
     
    9797}
    9898
    99 static inline Vector<RetainPtr<CTFontDescriptorRef>> systemFontCascadeList(const FontDescription& description, const AtomString& cssFamily, SystemFontDatabaseCoreText::ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)
     99static inline Vector<RetainPtr<CTFontDescriptorRef>> systemFontCascadeList(const FontDescription& description, const AtomString& cssFamily, SystemFontKind systemFontKind, AllowUserInstalledFonts allowUserInstalledFonts)
    100100{
    101     return SystemFontDatabaseCoreText::singleton().cascadeList(description, cssFamily, clientUse, allowUserInstalledFonts);
     101    return SystemFontDatabaseCoreText::singleton().cascadeList(description, cssFamily, systemFontKind, allowUserInstalledFonts);
    102102}
    103103
  • trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp

    r252034 r252806  
    6262
    6363#if HAVE(DESIGN_SYSTEM_UI_FONTS)
    64 RetainPtr<CTFontRef> SystemFontDatabaseCoreText::createDesignSystemUIFont(ClientUse clientUse, const CascadeListParameters& parameters)
     64RetainPtr<CTFontRef> SystemFontDatabaseCoreText::createSystemDesignFont(SystemFontKind systemFontKind, const CascadeListParameters& parameters)
    6565{
    6666    CFStringRef design = kCTFontUIFontDesignDefault;
    67     switch (clientUse) {
    68     case ClientUse::ForSystemUISerif:
     67    switch (systemFontKind) {
     68    case SystemFontKind::UISerif:
    6969        design = kCTFontUIFontDesignSerif;
    7070        break;
    71     case ClientUse::ForSystemUIMonospace:
     71    case SystemFontKind::UIMonospace:
    7272        design = kCTFontUIFontDesignMonospaced;
    7373        break;
    74     case ClientUse::ForSystemUIRounded:
     74    case SystemFontKind::UIRounded:
    7575        design = kCTFontUIFontDesignRounded;
    7676        break;
     
    9898}
    9999
    100 Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const CascadeListParameters& parameters, ClientUse clientUse)
     100Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const CascadeListParameters& parameters, SystemFontKind systemFontKind)
    101101{
    102102    ASSERT(!parameters.fontName.isNull());
     
    104104        auto localeString = parameters.locale.string().createCFString();
    105105        RetainPtr<CTFontRef> systemFont;
    106         switch (clientUse) {
    107         case ClientUse::ForSystemUI:
     106        switch (systemFontKind) {
     107        case SystemFontKind::SystemUI:
    108108            systemFont = createSystemUIFont(parameters, localeString.get());
    109109            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:
    113113#if HAVE(DESIGN_SYSTEM_UI_FONTS)
    114             systemFont = createDesignSystemUIFont(clientUse, parameters);
     114            systemFont = createSystemDesignFont(systemFontKind, parameters);
    115115#endif
    116116            break;
    117         case ClientUse::ForTextStyle:
     117        case SystemFontKind::TextStyle:
    118118            systemFont = createTextStyleFont(parameters);
    119119            break;
     
    180180}
    181181
    182 SystemFontDatabaseCoreText::CascadeListParameters SystemFontDatabaseCoreText::systemFontParameters(const FontDescription& description, const AtomString& familyName, ClientUse clientUse, AllowUserInstalledFonts allowUserInstalledFonts)
     182SystemFontDatabaseCoreText::CascadeListParameters SystemFontDatabaseCoreText::systemFontParameters(const FontDescription& description, const AtomString& familyName, SystemFontKind systemFontKind, AllowUserInstalledFonts allowUserInstalledFonts)
    183183{
    184184    CascadeListParameters result;
     
    211211        result.weight = kCTFontWeightBlack;
    212212
    213     switch (clientUse) {
    214     case ClientUse::ForSystemUI: {
     213    switch (systemFontKind) {
     214    case SystemFontKind::SystemUI: {
    215215        static NeverDestroyed<AtomString> systemUI = AtomString("system-ui", AtomString::ConstructFromLiteral);
    216216        result.fontName = systemUI.get();
    217217        break;
    218218    }
    219     case ClientUse::ForSystemUISerif: {
     219    case SystemFontKind::UISerif: {
    220220        static NeverDestroyed<AtomString> systemUISerif = AtomString("ui-serif", AtomString::ConstructFromLiteral);
    221221        result.fontName = systemUISerif.get();
    222222        break;
    223223    }
    224     case ClientUse::ForSystemUIMonospace: {
     224    case SystemFontKind::UIMonospace: {
    225225        static NeverDestroyed<AtomString> systemUIMonospace = AtomString("ui-monospace", AtomString::ConstructFromLiteral);
    226226        result.fontName = systemUIMonospace.get();
    227227        break;
    228228    }
    229     case ClientUse::ForSystemUIRounded: {
     229    case SystemFontKind::UIRounded: {
    230230        static NeverDestroyed<AtomString> systemUIRounded = AtomString("ui-rounded", AtomString::ConstructFromLiteral);
    231231        result.fontName = systemUIRounded.get();
    232232        break;
    233233    }
    234     case ClientUse::ForTextStyle:
     234    case SystemFontKind::TextStyle:
    235235        result.fontName = familyName;
    236236        break;
     
    240240}
    241241
    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);
     242Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const FontDescription& description, const AtomString& cssFamily, SystemFontKind systemFontKind, AllowUserInstalledFonts allowUserInstalledFonts)
     243{
     244    return cascadeList(systemFontParameters(description, cssFamily, systemFontKind, allowUserInstalledFonts), systemFontKind);
    245245}
    246246
  • trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h

    r252034 r252806  
    3434
    3535namespace WebCore {
     36
     37enum class SystemFontKind : uint8_t {
     38    SystemUI,
     39    UISerif,
     40    UIMonospace,
     41    UIRounded,
     42    TextStyle
     43};
    3644
    3745class SystemFontDatabaseCoreText {
     
    97105    static SystemFontDatabaseCoreText& singleton();
    98106
    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);
    108108
    109109    String serifFamily(const String& locale);
     
    118118    SystemFontDatabaseCoreText();
    119119
    120     Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const CascadeListParameters&, ClientUse);
     120    Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const CascadeListParameters&, SystemFontKind);
    121121
    122122    RetainPtr<CTFontRef> createSystemUIFont(const CascadeListParameters&, CFStringRef locale);
    123     RetainPtr<CTFontRef> createDesignSystemUIFont(ClientUse, const CascadeListParameters&);
     123    RetainPtr<CTFontRef> createSystemDesignFont(SystemFontKind, const CascadeListParameters&);
    124124    RetainPtr<CTFontRef> createTextStyleFont(const CascadeListParameters&);
    125125
     
    127127    static RetainPtr<CTFontDescriptorRef> removeCascadeList(CTFontDescriptorRef);
    128128    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);
    130130
    131131    HashMap<CascadeListParameters, Vector<RetainPtr<CTFontDescriptorRef>>, CascadeListParameters::CascadeListParametersHash, SimpleClassHashTraits<CascadeListParameters>> m_systemFontCache;
Note: See TracChangeset for help on using the changeset viewer.