Changeset 220009 in webkit


Ignore:
Timestamp:
Jul 28, 2017 11:36:37 AM (7 years ago)
Author:
mmaxfield@apple.com
Message:

[macOS] Reeder's defaults font is Times instead of San Francisco
https://bugs.webkit.org/show_bug.cgi?id=174885
<rdar://problem/33462483>

Reviewed by Simon Fraser.

Source/WebCore:

Reeder uses explicit dot-prefixed names in its source code. Within Core Text,
dot-prefixed names cannot be matched case insensitively. The solution is to
not case-fold these family names, and to make our caches case sensitive for
these special names.

Tests: fast/text/font-lookup-dot-prefix-case-sensitive-2.html

fast/text/font-lookup-dot-prefix-case-sensitive.html

  • platform/graphics/FontCache.cpp:

(WebCore::FontPlatformDataCacheKey::operator==):
(WebCore::FontPlatformDataCacheKeyHash::hash):

  • platform/graphics/FontCascade.cpp:

(WebCore::keysMatch):
(WebCore::computeFontCascadeCacheHash):

  • platform/graphics/FontDescription.cpp:

(WebCore::FontCascadeDescription::familyNamesAreEqual):
(WebCore::FontCascadeDescription::familyNameHash):
(WebCore::FontCascadeDescription::foldedFamilyName):

  • platform/graphics/FontDescription.h:
  • platform/graphics/cocoa/FontCacheCoreText.cpp:

(WebCore::FontDatabase::fontForPostScriptName):

LayoutTests:

  • fast/text/font-lookup-dot-prefix-case-sensitive-2-expected.html: Added.
  • fast/text/font-lookup-dot-prefix-case-sensitive-2.html: Added.
  • fast/text/font-lookup-dot-prefix-case-sensitive-expected-mismatch.html: Added.
  • fast/text/font-lookup-dot-prefix-case-sensitive.html: Added.
Location:
trunk
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r220008 r220009  
     12017-07-28  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [macOS] Reeder's defaults font is Times instead of San Francisco
     4        https://bugs.webkit.org/show_bug.cgi?id=174885
     5        <rdar://problem/33462483>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * fast/text/font-lookup-dot-prefix-case-sensitive-2-expected.html: Added.
     10        * fast/text/font-lookup-dot-prefix-case-sensitive-2.html: Added.
     11        * fast/text/font-lookup-dot-prefix-case-sensitive-expected-mismatch.html: Added.
     12        * fast/text/font-lookup-dot-prefix-case-sensitive.html: Added.
     13
    1142017-07-28  Devin Rousso  <drousso@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r220008 r220009  
     12017-07-28  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [macOS] Reeder's defaults font is Times instead of San Francisco
     4        https://bugs.webkit.org/show_bug.cgi?id=174885
     5        <rdar://problem/33462483>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Reeder uses explicit dot-prefixed names in its source code. Within Core Text,
     10        dot-prefixed names cannot be matched case insensitively. The solution is to
     11        not case-fold these family names, and to make our caches case sensitive for
     12        these special names.
     13
     14        Tests: fast/text/font-lookup-dot-prefix-case-sensitive-2.html
     15               fast/text/font-lookup-dot-prefix-case-sensitive.html
     16
     17        * platform/graphics/FontCache.cpp:
     18        (WebCore::FontPlatformDataCacheKey::operator==):
     19        (WebCore::FontPlatformDataCacheKeyHash::hash):
     20        * platform/graphics/FontCascade.cpp:
     21        (WebCore::keysMatch):
     22        (WebCore::computeFontCascadeCacheHash):
     23        * platform/graphics/FontDescription.cpp:
     24        (WebCore::FontCascadeDescription::familyNamesAreEqual):
     25        (WebCore::FontCascadeDescription::familyNameHash):
     26        (WebCore::FontCascadeDescription::foldedFamilyName):
     27        * platform/graphics/FontDescription.h:
     28        * platform/graphics/cocoa/FontCacheCoreText.cpp:
     29        (WebCore::FontDatabase::fontForPostScriptName):
     30
    1312017-07-28  Devin Rousso  <drousso@apple.com>
    232
  • trunk/Source/WebCore/platform/graphics/FontCache.cpp

    r219237 r220009  
    128128        if (m_family.isNull() || other.m_family.isNull())
    129129            return false;
    130         return ASCIICaseInsensitiveHash::equal(m_family, other.m_family);
     130        return FontCascadeDescription::familyNamesAreEqual(m_family, other.m_family);
    131131    }
    132132
     
    142142    {
    143143        IntegerHasher hasher;
    144         hasher.add(ASCIICaseInsensitiveHash::hash(fontKey.m_family));
     144        hasher.add(FontCascadeDescription::familyNameHash(fontKey.m_family));
    145145        hasher.add(fontKey.m_fontDescriptionKey.computeHash());
    146146        hasher.add(fontKey.m_fontFaceFeatures.hash());
  • trunk/Source/WebCore/platform/graphics/FontCascade.cpp

    r219858 r220009  
    186186        return false;
    187187    for (unsigned i = 0; i < size; ++i) {
    188         if (!equalIgnoringASCIICase(a.families[i], b.families[i]))
     188        if (!FontCascadeDescription::familyNamesAreEqual(a.families[i], b.families[i]))
    189189            return false;
    190190    }
     
    230230    hasher.add(key.fontSelectorVersion);
    231231    for (unsigned i = 0; i < key.families.size(); ++i) {
    232         StringImpl* family = key.families[i].impl();
    233         hasher.add(family ? ASCIICaseInsensitiveHash::hash(family) : 0);
     232        auto& family = key.families[i];
     233        hasher.add(family.isNull() ? 0 : FontCascadeDescription::familyNameHash(family));
    234234    }
    235235    return hasher.hash();
  • trunk/Source/WebCore/platform/graphics/FontDescription.cpp

    r218372 r220009  
    3232
    3333#include "LocaleToScriptMapping.h"
     34#include <wtf/text/StringHash.h>
    3435
    3536namespace WebCore {
     
    156157#endif // ENABLE(TEXT_AUTOSIZING)
    157158
     159bool FontCascadeDescription::familyNamesAreEqual(const AtomicString& family1, const AtomicString& family2)
     160{
     161    // FIXME: <rdar://problem/33594253> CoreText matches dot-prefixed font names case sensitively. We should
     162    // always take the case insensitive patch once this radar is fixed.
     163    if (family1.startsWith('.'))
     164        return StringHash::equal(family1.string(), family2.string());
     165    return ASCIICaseInsensitiveHash::equal(family1, family2);
     166}
     167
     168unsigned FontCascadeDescription::familyNameHash(const AtomicString& family)
     169{
     170    // FIXME: <rdar://problem/33594253> CoreText matches dot-prefixed font names case sensitively. We should
     171    // always take the case insensitive patch once this radar is fixed.
     172    if (family.startsWith('.'))
     173        return StringHash::hash(family.string());
     174    return ASCIICaseInsensitiveHash::hash(family);
     175}
     176
     177String FontCascadeDescription::foldedFamilyName(const AtomicString& family)
     178{
     179    // FIXME: <rdar://problem/33594253> CoreText matches dot-prefixed font names case sensitively. We should
     180    // always take the case insensitive patch once this radar is fixed.
     181    if (family.startsWith('.'))
     182        return family.string();
     183    return family.string().foldCase();
     184}
     185
    158186} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/FontDescription.h

    r219544 r220009  
    233233    const RefCountedArray<AtomicString>& families() const { return m_families; }
    234234
     235    static bool familyNamesAreEqual(const AtomicString&, const AtomicString&);
     236    static unsigned familyNameHash(const AtomicString&);
     237    static String foldedFamilyName(const AtomicString&);
     238
    235239    unsigned effectiveFamilyCount() const;
    236240    FontFamilySpecification effectiveFamilyAt(unsigned) const;
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp

    r219237 r220009  
    908908    const InstalledFont& fontForPostScriptName(const AtomicString& postScriptName)
    909909    {
    910         auto folded = postScriptName.string().foldCase();
     910        const auto& folded = FontCascadeDescription::foldedFamilyName(postScriptName);
    911911        return m_postScriptNameToFontDescriptors.ensure(folded, [&] {
    912912            auto postScriptNameString = folded.createCFString();
Note: See TracChangeset for help on using the changeset viewer.