Changeset 242038 in webkit


Ignore:
Timestamp:
Feb 25, 2019 6:39:10 AM (5 years ago)
Author:
Darin Adler
Message:

Incorrect use of String::foldCase for font family names
https://bugs.webkit.org/show_bug.cgi?id=194895

Reviewed by Myles C. Maxfield.

  • platform/graphics/FontCascadeDescription.cpp:

(WebCore::FontCascadeDescription::familiesEqualForTextAutoSizing): Use
familyNamesAreEqual instead of calling convertToASCIILowercase directly.
(WebCore::FontCascadeDescription::familyNamesAreEqual): Use AtomicString's
operator== when we want case sensitive family name comparisons. This is a special
case to accomodate CoreText, which uses "."-prefix names for internal fonts that
are treated case sensitively. (Ideally webpages would not use these fonts at all.)
(WebCore::FontCascadeDescription::familyNameHash): Use AtomicString's existingHash
when we want case sensitive family name hashing.
(WebCore::FontCascadeDescription::foldedFamilyName): Take a String instead of an
AtomicString so we can use this at an additional call site. Converting from an
AtomicString to a String if free and automatic at the existing call sites. Use
convertToASCIILowercase instead of foldCase for three reasons: 1) Other functions
here are folding only ASCII case by using ASCIICaseInsensitiveHash, and this one
must be consistent. 2) this is considerably faster, and 3) font family names don't
need arbitrary Unicode case folding, it's only A-Z that should be folded.

  • platform/graphics/FontCascadeDescription.h: Take a String instead of AtomicString

in the foldedFamilyName function.

  • platform/graphics/cocoa/FontCacheCoreText.cpp:

(WebCore::FontDatabase::collectionForFamily): Instead of calling foldCase, use
FontCascadeDescription::foldedFamilyName to correctly fold font family names.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242035 r242038  
     12019-02-20  Darin Adler  <darin@apple.com>
     2
     3        Incorrect use of String::foldCase for font family names
     4        https://bugs.webkit.org/show_bug.cgi?id=194895
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        * platform/graphics/FontCascadeDescription.cpp:
     9        (WebCore::FontCascadeDescription::familiesEqualForTextAutoSizing): Use
     10        familyNamesAreEqual instead of calling convertToASCIILowercase directly.
     11        (WebCore::FontCascadeDescription::familyNamesAreEqual): Use AtomicString's
     12        operator== when we want case sensitive family name comparisons. This is a special
     13        case to accomodate CoreText, which uses "."-prefix names for internal fonts that
     14        are treated case sensitively. (Ideally webpages would not use these fonts at all.)
     15        (WebCore::FontCascadeDescription::familyNameHash): Use AtomicString's existingHash
     16        when we want case sensitive family name hashing.
     17        (WebCore::FontCascadeDescription::foldedFamilyName): Take a String instead of an
     18        AtomicString so we can use this at an additional call site. Converting from an
     19        AtomicString to a String if free and automatic at the existing call sites. Use
     20        convertToASCIILowercase instead of foldCase for three reasons: 1) Other functions
     21        here are folding only ASCII case by using ASCIICaseInsensitiveHash, and this one
     22        must be consistent. 2) this is considerably faster, and 3) font family names don't
     23        need arbitrary Unicode case folding, it's only A-Z that should be folded.
     24        * platform/graphics/FontCascadeDescription.h: Take a String instead of AtomicString
     25        in the foldedFamilyName function.
     26
     27        * platform/graphics/cocoa/FontCacheCoreText.cpp:
     28        (WebCore::FontDatabase::collectionForFamily): Instead of calling foldCase, use
     29        FontCascadeDescription::foldedFamilyName to correctly fold font family names.
     30
    1312019-02-25  Charlie Turner  <cturner@igalia.com>
    232
  • trunk/Source/WebCore/platform/graphics/FontCascadeDescription.cpp

    r236914 r242038  
    6464
    6565#if !USE_PLATFORM_SYSTEM_FALLBACK_LIST
     66
    6667unsigned FontCascadeDescription::effectiveFamilyCount() const
    6768{
     
    7374    return familyAt(i);
    7475}
     76
    7577#endif
    7678
     
    108110
    109111    for (unsigned i = 0; i < thisFamilyCount; ++i) {
    110         if (!equalIgnoringASCIICase(familyAt(i), other.familyAt(i)))
     112        if (!familyNamesAreEqual(familyAt(i), other.familyAt(i)))
    111113            return false;
    112114    }
     
    119121bool FontCascadeDescription::familyNamesAreEqual(const AtomicString& family1, const AtomicString& family2)
    120122{
    121     // FIXME: <rdar://problem/33594253> CoreText matches dot-prefixed font names case sensitively. We should
    122     // always take the case insensitive patch once this radar is fixed.
     123#if PLATFORM(COCOA)
    123124    if (family1.startsWith('.'))
    124         return StringHash::equal(family1.string(), family2.string());
     125        return family1 == family2;
     126#endif
    125127    return ASCIICaseInsensitiveHash::equal(family1, family2);
    126128}
     
    128130unsigned FontCascadeDescription::familyNameHash(const AtomicString& family)
    129131{
    130     // FIXME: <rdar://problem/33594253> CoreText matches dot-prefixed font names case sensitively. We should
    131     // always take the case insensitive patch once this radar is fixed.
     132#if PLATFORM(COCOA)
    132133    if (family.startsWith('.'))
    133         return StringHash::hash(family.string());
     134        return family.existingHash();
     135#endif
    134136    return ASCIICaseInsensitiveHash::hash(family);
    135137}
    136138
    137 String FontCascadeDescription::foldedFamilyName(const AtomicString& family)
     139String FontCascadeDescription::foldedFamilyName(const String& family)
    138140{
    139     // FIXME: <rdar://problem/33594253> CoreText matches dot-prefixed font names case sensitively. We should
    140     // always take the case insensitive patch once this radar is fixed.
     141#if PLATFORM(COCOA)
    141142    if (family.startsWith('.'))
    142         return family.string();
    143     return family.string().foldCase();
     143        return family;
     144#endif
     145    return family.convertToASCIILowercase();
    144146}
    145147
  • trunk/Source/WebCore/platform/graphics/FontCascadeDescription.h

    r239427 r242038  
    6060    static bool familyNamesAreEqual(const AtomicString&, const AtomicString&);
    6161    static unsigned familyNameHash(const AtomicString&);
    62     static String foldedFamilyName(const AtomicString&);
     62    static String foldedFamilyName(const String&);
    6363
    6464    unsigned effectiveFamilyCount() const;
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp

    r239822 r242038  
    888888    const InstalledFontFamily& collectionForFamily(const String& familyName)
    889889    {
    890         auto folded = familyName.foldCase();
     890        auto folded = FontCascadeDescription::foldedFamilyName(familyName);
    891891        {
    892892            std::lock_guard<Lock> locker(m_familyNameToFontDescriptorsLock);
Note: See TracChangeset for help on using the changeset viewer.