⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 196969 in webkit


Ignore:
Timestamp:
Feb 22, 2016, 11:17:29 PM (11 years ago)
Author:
mmaxfield@apple.com
Message:

Font features specified in @font-face blocks don't apply to local() families
​https://bugs.webkit.org/show_bug.cgi?id=154554

Reviewed by Dean Jackson.

Source/WebCore:

The correct variables just need to be wired up. In addition, our caches need to be sensitive
to the new data.

Test: css3/font-feature-font-face-local.html

  • css/CSSFontFaceSource.cpp:

(WebCore::CSSFontFaceSource::font):

  • platform/graphics/FontCache.cpp:

(WebCore::FontPlatformDataCacheKey::FontPlatformDataCacheKey):
(WebCore::FontPlatformDataCacheKey::operator==):
(WebCore::FontPlatformDataCacheKeyHash::hash):
(WebCore::FontCache::getCachedFontPlatformData):
(WebCore::FontCache::fontForFamily):

  • platform/graphics/FontCache.h:
  • platform/graphics/FontFeatureSettings.h:

(WebCore::FontFeature::operator!=):
(WebCore::FontFeatureSettings::operator!=):

  • platform/graphics/cocoa/FontCacheCoreText.cpp:

(WebCore::fontWithFamily):
(WebCore::FontCache::createFontPlatformData):

  • platform/graphics/mac/ComplexTextControllerCoreText.mm:

(WebCore::ComplexTextController::collectComplexTextRunsForCharacters):

  • platform/graphics/mac/FontCacheMac.mm:

(WebCore::FontCache::lastResortFallbackFont):

  • platform/text/TextFlags.h:

(WebCore::FontVariantSettings::operator==):
(WebCore::FontVariantSettings::operator!=):
(WebCore::FontVariantSettings::uniqueValue):

LayoutTests:

  • css3/font-feature-font-face-local-expected.html: Added.
  • css3/font-feature-font-face-local.html: Added.
Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r196961 r196969  
     12016-02-22  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Font features specified in @font-face blocks don't apply to local() families
     4        https://bugs.webkit.org/show_bug.cgi?id=154554
     5
     6        Reviewed by Dean Jackson.
     7
     8        * css3/font-feature-font-face-local-expected.html: Added.
     9        * css3/font-feature-font-face-local.html: Added.
     10
    1112016-02-22  Chris Dumez  <cdumez@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r196965 r196969  
     12016-02-22  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Font features specified in @font-face blocks don't apply to local() families
     4        https://bugs.webkit.org/show_bug.cgi?id=154554
     5
     6        Reviewed by Dean Jackson.
     7
     8        The correct variables just need to be wired up. In addition, our caches need to be sensitive
     9        to the new data.
     10
     11        Test: css3/font-feature-font-face-local.html
     12
     13        * css/CSSFontFaceSource.cpp:
     14        (WebCore::CSSFontFaceSource::font):
     15        * platform/graphics/FontCache.cpp:
     16        (WebCore::FontPlatformDataCacheKey::FontPlatformDataCacheKey):
     17        (WebCore::FontPlatformDataCacheKey::operator==):
     18        (WebCore::FontPlatformDataCacheKeyHash::hash):
     19        (WebCore::FontCache::getCachedFontPlatformData):
     20        (WebCore::FontCache::fontForFamily):
     21        * platform/graphics/FontCache.h:
     22        * platform/graphics/FontFeatureSettings.h:
     23        (WebCore::FontFeature::operator!=):
     24        (WebCore::FontFeatureSettings::operator!=):
     25        * platform/graphics/cocoa/FontCacheCoreText.cpp:
     26        (WebCore::fontWithFamily):
     27        (WebCore::FontCache::createFontPlatformData):
     28        * platform/graphics/mac/ComplexTextControllerCoreText.mm:
     29        (WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
     30        * platform/graphics/mac/FontCacheMac.mm:
     31        (WebCore::FontCache::lastResortFallbackFont):
     32        * platform/text/TextFlags.h:
     33        (WebCore::FontVariantSettings::operator==):
     34        (WebCore::FontVariantSettings::operator!=):
     35        (WebCore::FontVariantSettings::uniqueValue):
     36
    1372016-02-22  Daniel Bates  <dabates@apple.com>
    238
  • trunk/Source/WebCore/css/CSSFontFaceSource.cpp

    r196835 r196969  
    138138        // We're local. Just return a Font from the normal cache.
    139139        // We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter.
    140         return FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, true);
     140        return FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, &fontFaceFeatures, &fontFaceVariantSettings, true);
    141141    }
    142142
  • trunk/Source/WebCore/platform/graphics/FontCache.cpp

    r196393 r196969  
    101101public:
    102102    FontPlatformDataCacheKey() { }
    103     FontPlatformDataCacheKey(const AtomicString& family, const FontDescription& description)
     103    FontPlatformDataCacheKey(const AtomicString& family, const FontDescription& description, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings)
    104104        : m_fontDescriptionKey(description)
    105105        , m_family(family)
     106        , m_fontFaceFeatures(fontFaceFeatures ? *fontFaceFeatures : FontFeatureSettings())
     107        , m_fontFaceVariantSettings(fontFaceVariantSettings ? *fontFaceVariantSettings : FontVariantSettings())
    106108    { }
    107109
    … …  
    114116    bool operator==(const FontPlatformDataCacheKey& other) const
    115117    {
    116         if (m_fontDescriptionKey != other.m_fontDescriptionKey)
     118        if (m_fontDescriptionKey != other.m_fontDescriptionKey
     119            || m_fontFaceFeatures != other.m_fontFaceFeatures
     120            || m_fontFaceVariantSettings != other.m_fontFaceVariantSettings)
    117121            return false;
    118122        if (m_family.impl() == other.m_family.impl())
    … …  
    125129    FontDescriptionKey m_fontDescriptionKey;
    126130    AtomicString m_family;
     131    FontFeatureSettings m_fontFaceFeatures;
     132    FontVariantSettings m_fontFaceVariantSettings;
    127133};
    128134
    … …  
    130136    static unsigned hash(const FontPlatformDataCacheKey& fontKey)
    131137    {
    132         return pairIntHash(ASCIICaseInsensitiveHash::hash(fontKey.m_family), fontKey.m_fontDescriptionKey.computeHash());
     138        IntegerHasher hasher;
     139        hasher.add(ASCIICaseInsensitiveHash::hash(fontKey.m_family));
     140        hasher.add(fontKey.m_fontDescriptionKey.computeHash());
     141        hasher.add(fontKey.m_fontFaceFeatures.hash());
     142        hasher.add(fontKey.m_fontFaceVariantSettings.uniqueValue());
     143        return hasher.hash();
    133144    }
    134145         
    … …  
    208219}
    209220
    210 FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fontDescription,
    211                                                        const AtomicString& passedFamilyName,
    212                                                        bool checkingAlternateName)
     221FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fontDescription, const AtomicString& passedFamilyName,
     222    const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, bool checkingAlternateName)
    213223{
    214224#if PLATFORM(IOS)
    … …  
    232242    }
    233243
    234     FontPlatformDataCacheKey key(familyName, fontDescription);
     244    FontPlatformDataCacheKey key(familyName, fontDescription, fontFaceFeatures, fontFaceVariantSettings);
    235245
    236246    auto addResult = fontPlatformDataCache().add(key, nullptr);
    237247    FontPlatformDataCache::iterator it = addResult.iterator;
    238248    if (addResult.isNewEntry) {
    239         it->value = createFontPlatformData(fontDescription, familyName);
     249        it->value = createFontPlatformData(fontDescription, familyName, fontFaceFeatures, fontFaceVariantSettings);
    240250
    241251        if (!it->value && !checkingAlternateName) {
    … …  
    244254            const AtomicString alternateName = alternateFamilyName(familyName);
    245255            if (!alternateName.isNull()) {
    246                 FontPlatformData* fontPlatformDataForAlternateName = getCachedFontPlatformData(fontDescription, alternateName, true);
     256                FontPlatformData* fontPlatformDataForAlternateName = getCachedFontPlatformData(fontDescription, alternateName, fontFaceFeatures, fontFaceVariantSettings, true);
    247257                // Lookup the key in the hash table again as the previous iterator may have
    248258                // been invalidated by the recursive call to getCachedFontPlatformData().
    … …  
    365375const unsigned cTargetUnderMemoryPressureInactiveFontData = 30;
    366376
    367 RefPtr<Font> FontCache::fontForFamily(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName)
     377RefPtr<Font> FontCache::fontForFamily(const FontDescription& fontDescription, const AtomicString& family, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, bool checkingAlternateName)
    368378{
    369379    if (!m_purgeTimer.isActive())
    370380        m_purgeTimer.startOneShot(std::chrono::milliseconds::zero());
    371381
    372     FontPlatformData* platformData = getCachedFontPlatformData(fontDescription, family, checkingAlternateName);
     382    FontPlatformData* platformData = getCachedFontPlatformData(fontDescription, family, fontFaceFeatures, fontFaceVariantSettings, checkingAlternateName);
    373383    if (!platformData)
    374384        return nullptr;
  • trunk/Source/WebCore/platform/graphics/FontCache.h

    r196393 r196969  
    189189    Vector<FontTraitsMask> getTraitsInFamily(const AtomicString&);
    190190
    191     WEBCORE_EXPORT RefPtr<Font> fontForFamily(const FontDescription&, const AtomicString&, bool checkingAlternateName = false);
     191    WEBCORE_EXPORT RefPtr<Font> fontForFamily(const FontDescription&, const AtomicString&, const FontFeatureSettings* fontFaceFeatures = nullptr, const FontVariantSettings* fontFaceVariantSettings = nullptr, bool checkingAlternateName = false);
    192192    WEBCORE_EXPORT Ref<Font> lastResortFallbackFont(const FontDescription&);
    193193    WEBCORE_EXPORT Ref<Font> fontForPlatformData(const FontPlatformData&);
    … …  
    221221
    222222    // FIXME: This method should eventually be removed.
    223     FontPlatformData* getCachedFontPlatformData(const FontDescription&, const AtomicString& family, bool checkingAlternateName = false);
     223    FontPlatformData* getCachedFontPlatformData(const FontDescription&, const AtomicString& family, const FontFeatureSettings* fontFaceFeatures = nullptr, const FontVariantSettings* fontFaceVariantSettings = nullptr, bool checkingAlternateName = false);
    224224
    225225    // These methods are implemented by each platform.
    … …  
    227227    FontPlatformData* getCustomFallbackFont(const UInt32, const FontDescription&);
    228228#endif
    229     std::unique_ptr<FontPlatformData> createFontPlatformData(const FontDescription&, const AtomicString& family);
     229    std::unique_ptr<FontPlatformData> createFontPlatformData(const FontDescription&, const AtomicString& family, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings);
    230230
    231231    Timer m_purgeTimer;
  • trunk/Source/WebCore/platform/graphics/FontFeatureSettings.h

    r190402 r196969  
    6161
    6262    bool operator==(const FontFeature& other) const;
     63    bool operator!=(const FontFeature& other) const { return !(*this == other); }
    6364    bool operator<(const FontFeature& other) const;
    6465
    … …  
    7677    void insert(FontFeature&&);
    7778    bool operator==(const FontFeatureSettings& other) const { return m_list == other.m_list; }
     79    bool operator!=(const FontFeatureSettings& other) const { return !(*this == other); }
    7880
    7981    size_t size() const { return m_list.size(); }
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp

    r195928 r196969  
    672672#endif
    673673
    674 static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, CTFontSymbolicTraits desiredTraits, FontWeight weight, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const TextRenderingMode& textRenderingMode, float size)
     674static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, CTFontSymbolicTraits desiredTraits, FontWeight weight, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const TextRenderingMode& textRenderingMode, float size)
    675675{
    676676    if (family.isEmpty())
    … …  
    685685#endif
    686686    }
    687     return preparePlatformFont(foundFont.get(), textRenderingMode, nullptr, nullptr, featureSettings, variantSettings);
     687    return preparePlatformFont(foundFont.get(), textRenderingMode, fontFaceFeatures, fontFaceVariantSettings, featureSettings, variantSettings);
    688688}
    689689
    … …  
    720720#endif
    721721
    722 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
     722std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings)
    723723{
    724724    CTFontSymbolicTraits traits = computeTraits(fontDescription);
    725725    float size = fontDescription.computedPixelSize();
    726726
    727     RetainPtr<CTFontRef> font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.textRenderingMode(), size);
     727    RetainPtr<CTFontRef> font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), size);
    728728
    729729#if PLATFORM(MAC)
    … …  
    736736        autoActivateFont(family.string(), size);
    737737
    738         font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.textRenderingMode(), size);
     738        font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), size);
    739739    }
    740740#endif
  • trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp

    r195743 r196969  
    135135    // matches for non-fallback fonts might return 0. See isFallbackFontAllowed.
    136136    static AtomicString timesStr("serif");
    137     return *fontForFamily(fontDescription, timesStr, false);
     137    return *fontForFamily(fontDescription, timesStr);
    138138}
    139139
    … …  
    327327}
    328328
    329 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
     329std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family, const FontFeatureSettings*, const FontVariantSettings*)
    330330{
    331331    // The CSS font matching algorithm (http://www.w3.org/TR/css3-fonts/#font-matching-algorithm)
  • trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm

    r195452 r196969  
    121121Ref<Font> FontCache::lastResortFallbackFont(const FontDescription& fontDescription)
    122122{
    123     return *fontForFamily(fontDescription, AtomicString(".PhoneFallback", AtomicString::ConstructFromLiteral), false);
     123    return *fontForFamily(fontDescription, AtomicString(".PhoneFallback", AtomicString::ConstructFromLiteral));
    124124}
    125125
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm

    r191331 r196969  
    287287                    }
    288288                    auto& fontCache = FontCache::singleton();
    289                     runFont = fontCache.fontForFamily(m_font.fontDescription(), fontName.get(), false).get();
     289                    runFont = fontCache.fontForFamily(m_font.fontDescription(), fontName.get()).get();
    290290                    // Core Text may have used a font that our font lookup path cannot find. In that case, fall back on
    291291                    // using the font as returned.
  • trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm

    r195452 r196969  
    396396    // FIXME: Would be even better to somehow get the user's default font here.  For now we'll pick
    397397    // the default that the user would get without changing any prefs.
    398     if (RefPtr<Font> font = fontForFamily(fontDescription, AtomicString("Times", AtomicString::ConstructFromLiteral), false))
     398    if (RefPtr<Font> font = fontForFamily(fontDescription, AtomicString("Times", AtomicString::ConstructFromLiteral)))
    399399        return *font;
    400400
    … …  
    403403    // guaranteed to be there, according to Nathan Taylor. This is good enough
    404404    // to avoid a crash at least.
    405     return *fontForFamily(fontDescription, AtomicString("Lucida Grande", AtomicString::ConstructFromLiteral), false);
     405    return *fontForFamily(fontDescription, AtomicString("Lucida Grande", AtomicString::ConstructFromLiteral), nullptr, nullptr, false);
    406406}
    407407
  • trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp

    r195743 r196969  
    561561}
    562562
    563 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
     563std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family, const FontFeatureSettings*, const FontVariantSettings*)
    564564{
    565565    bool isLucidaGrande = equalLettersIgnoringASCIICase(family, "lucida grande");
  • trunk/Source/WebCore/platform/text/TextFlags.h

    r196510 r196969  
    213213    }
    214214
    215     bool operator==(const FontVariantSettings& other)
     215    bool operator==(const FontVariantSettings& other) const
    216216    {
    217217        return commonLigatures == other.commonLigatures
    … …  
    232232    }
    233233
     234    bool operator!=(const FontVariantSettings& other) const { return !(*this == other); }
     235
     236    unsigned uniqueValue() const
     237    {
     238        return static_cast<unsigned>(commonLigatures) << 26
     239            | static_cast<unsigned>(discretionaryLigatures) << 24
     240            | static_cast<unsigned>(historicalLigatures) << 22
     241            | static_cast<unsigned>(contextualAlternates) << 20
     242            | static_cast<unsigned>(position) << 18
     243            | static_cast<unsigned>(caps) << 15
     244            | static_cast<unsigned>(numericFigure) << 13
     245            | static_cast<unsigned>(numericSpacing) << 11
     246            | static_cast<unsigned>(numericFraction) << 9
     247            | static_cast<unsigned>(numericOrdinal) << 8
     248            | static_cast<unsigned>(numericSlashedZero) << 7
     249            | static_cast<unsigned>(alternates) << 6
     250            | static_cast<unsigned>(eastAsianVariant) << 3
     251            | static_cast<unsigned>(eastAsianWidth) << 1
     252            | static_cast<unsigned>(eastAsianRuby) << 0;
     253    }
     254
    234255    FontVariantLigatures commonLigatures;
    235256    FontVariantLigatures discretionaryLigatures;
Note: See TracChangeset for help on using the changeset viewer.