Ignore:
Timestamp:
Apr 12, 2017, 1:54:02 PM (8 years ago)
Author:
[email protected]
Message:

Well-known variations should clamp to the values listed in the @font-face block
https://bugs.webkit.org/show_bug.cgi?id=169260

Reviewed by Dean Jackson.

Source/WebCore:

Most of this patch is plumbing the variation ranges from the CSSFontFace object
to preparePlatformFont() where variation values get applied.

Beyond that, there is one other piece of this patch - a nonspecified value in an
@font-face block shouldn't perform any clamping, but a specified value should be
clamped. This means that we need to retain whether or not a value is specified.
This patch does this by migrating CSSFontFace from using FontSelectionCapabilities
to using FontSelectionSpecifiedCapabilities, which has its internals behind
std::optionals which represent whether or not the value was specified. For the
purposes of font selection, these unspecified values are replaced with default
values.

Test: fast/text/variations/font-face-clamp.html

  • css/CSSFontFace.cpp:

(WebCore::CSSFontFace::font):

  • css/CSSFontFace.h:
  • css/CSSFontFaceSource.cpp:

(WebCore::CSSFontFaceSource::font):

  • css/CSSFontFaceSource.h:
  • css/CSSFontSelector.cpp:

(WebCore::CSSFontSelector::addFontFaceRule):

  • loader/cache/CachedFont.cpp:

(WebCore::CachedFont::createFont):
(WebCore::CachedFont::platformDataFromCustomData):

  • loader/cache/CachedFont.h:
  • loader/cache/CachedSVGFont.cpp:

(WebCore::CachedSVGFont::createFont):
(WebCore::CachedSVGFont::platformDataFromCustomData):

  • loader/cache/CachedSVGFont.h:
  • platform/graphics/FontCache.cpp:

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

  • platform/graphics/FontCache.h:

(WebCore::FontCache::fontForFamily):
(WebCore::FontCache::getCachedFontPlatformData):
(WebCore::FontCache::createFontPlatformDataForTesting):

  • platform/graphics/FontSelectionAlgorithm.h:

(WebCore::FontSelectionRange::uniqueValue):
(WebCore::FontSelectionCapabilities::operator==):
(WebCore::FontSelectionCapabilities::operator!=):
(WebCore::FontSelectionSpecifiedCapabilities::computeFontSelectionCapabilities):
(WebCore::FontSelectionSpecifiedCapabilities::operator==):
(WebCore::FontSelectionSpecifiedCapabilities::operator!=):
(WebCore::FontSelectionSpecifiedCapabilities::operator=):
(WebCore::FontSelectionSpecifiedCapabilities::computeWeight):
(WebCore::FontSelectionSpecifiedCapabilities::computeWidth):
(WebCore::FontSelectionSpecifiedCapabilities::computeSlope):

  • platform/graphics/cocoa/FontCacheCoreText.cpp:

(WebCore::preparePlatformFont):
(WebCore::fontWithFamily):
(WebCore::FontCache::createFontPlatformData):
(WebCore::FontCache::systemFallbackForCharacters):

  • platform/graphics/mac/FontCacheMac.mm:

(WebCore::FontCache::lastResortFallbackFont):

  • platform/graphics/mac/FontCustomPlatformData.cpp:

(WebCore::FontCustomPlatformData::fontPlatformData):

  • platform/graphics/mac/FontCustomPlatformData.h:

LayoutTests:

  • fast/text/variations/font-face-clamp-expected.html: Added.
  • fast/text/variations/font-face-clamp.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSFontFaceSource.cpp

    r215262 r215287  
    137137}
    138138
    139 RefPtr<Font> CSSFontFaceSource::font(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings)
     139RefPtr<Font> CSSFontFaceSource::font(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
    140140{
    141141    ASSERT(status() == Status::Success);
     
    155155            } if (!m_immediateFontCustomPlatformData)
    156156                return nullptr;
    157             return Font::create(CachedFont::platformDataFromCustomData(*m_immediateFontCustomPlatformData, fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings), true);
     157            return Font::create(CachedFont::platformDataFromCustomData(*m_immediateFontCustomPlatformData, fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities), true);
    158158        }
    159159
    160160        // We're local. Just return a Font from the normal cache.
    161161        // We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter.
    162         return FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, &fontFaceFeatures, &fontFaceVariantSettings, true);
     162        return FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, &fontFaceFeatures, &fontFaceVariantSettings, fontFaceCapabilities, true);
    163163    }
    164164
     
    167167            return nullptr;
    168168
    169         return m_font->createFont(fontDescription, m_familyNameOrURI, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings);
     169        return m_font->createFont(fontDescription, m_familyNameOrURI, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities);
    170170    }
    171171
     
    188188        return nullptr;
    189189#if PLATFORM(COCOA)
    190     return Font::create(m_inDocumentCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings), true, false);
     190    return Font::create(m_inDocumentCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities), true, false);
    191191#else
    192192    return Font::create(m_inDocumentCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic), true, false);
Note: See TracChangeset for help on using the changeset viewer.