font-variant-* properties in @font-face declarations should be honored
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Nov 2015 20:31:33 +0000 (20:31 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Nov 2015 20:31:33 +0000 (20:31 +0000)
commit351f261d0571290760a3b5fedf984ba256af2a1c
treebec0741085a0d252de0c6350b6137e73963045a5
parentef40ed56ebb6bea6b1ecd1179feaabe4ae9c4ab6
font-variant-* properties in @font-face declarations should be honored
https://bugs.webkit.org/show_bug.cgi?id=149771

Reviewed by Simon Fraser.

Source/WebCore:

According to the CSS Fonts Level 3 spec, web authors are allowed to put
font-feature-settings / font-variant-* inside @font-face blocks. These
properties are supposed to be applied at a specific time during the
font selection algorithm.

This patch gives a FontFeatureSettings object and a FontVariantSettings
object to CSSFontFace, and moves common parsing logic from
StyleBuilderCustom to a shared location. Then, once the two properties
are parsed from the @font-face block, the relevant data structures are
passed down into the font selection algorithm. This algorithm then
consults with these values at the correct time (inside
preparePlatformFont()).

Tests: css3/font-feature-settings-font-face-rendering.html
       css3/font-variant-font-face-all.html
       css3/font-variant-font-face-override.html

* WebCore.xcodeproj/project.pbxproj: Add a header for the common
location of parsing font-variant-ligatures, font-variant-numeric,
and font-variant-east-asian.
* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::font): Pass the relevant data structures
into the font selection algorithm.
* css/CSSFontFace.h: Add FontFeatureSettings and FontVariantSettings
member variables.
(WebCore::CSSFontFace::insertFeature):
(WebCore::CSSFontFace::setVariantCommonLigatures):
(WebCore::CSSFontFace::setVariantDiscretionaryLigatures):
(WebCore::CSSFontFace::setVariantHistoricalLigatures):
(WebCore::CSSFontFace::setVariantContextualAlternates):
(WebCore::CSSFontFace::setVariantPosition):
(WebCore::CSSFontFace::setVariantCaps):
(WebCore::CSSFontFace::setVariantNumericFigure):
(WebCore::CSSFontFace::setVariantNumericSpacing):
(WebCore::CSSFontFace::setVariantNumericFraction):
(WebCore::CSSFontFace::setVariantNumericOrdinal):
(WebCore::CSSFontFace::setVariantNumericSlashedZero):
(WebCore::CSSFontFace::setVariantAlternates):
(WebCore::CSSFontFace::setVariantEastAsianVariant):
(WebCore::CSSFontFace::setVariantEastAsianWidth):
(WebCore::CSSFontFace::setVariantEastAsianRuby):
* css/CSSFontFaceSource.cpp:
(WebCore::CSSFontFaceSource::font): Pass the relevant data
structures into the font selection algorithm.
* css/CSSFontFaceSource.h: Ditto.
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule): Call the shared
parsing logic to populate the FontFeatureSettings and
FontVariantSettings members.
* css/FontVariantBuilder.h: Added. Destination for shared parsing
logic.
(WebCore::applyValueFontVariantLigatures):
(WebCore::applyValueFontVariantNumeric):
(WebCore::applyValueFontVariantEastAsian):
* css/StyleBuilderCustom.h: Source for shared parsing logic.
(WebCore::StyleBuilderCustom::applyValueFontVariantLigatures):
(WebCore::StyleBuilderCustom::applyValueFontVariantNumeric):
(WebCore::StyleBuilderCustom::applyValueFontVariantEastAsian):
* loader/cache/CachedFont.cpp: Pass the relevant data structures
into the font selection algorithm.
(WebCore::CachedFont::createFont):
(WebCore::CachedFont::platformDataFromCustomData):
* loader/cache/CachedFont.h: Ditto.
* loader/cache/CachedSVGFont.cpp: Ditto.
(WebCore::CachedSVGFont::createFont):
(WebCore::CachedSVGFont::platformDataFromCustomData):
* loader/cache/CachedSVGFont.h: Ditto.
* platform/graphics/FontCache.h: Ditto.
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::codePath): Adjust comment.
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::preparePlatformFont): Consult with the newly parsed values.
(WebCore::fontWithFamily): Pass the relevant data structures into the
font selection algorithm.
(WebCore::FontCache::systemFallbackForCharacters): Ditto.
* platform/graphics/mac/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData): Ditto.
* platform/graphics/mac/FontCustomPlatformData.h: Ditto.

LayoutTests:

* css3/font-variant-font-face-override-expected.html: Added
* css3/font-variant-font-face-override.html: Added
* css3/font-feature-settings-font-face-rendering-expected.html: Added.
* css3/font-feature-settings-font-face-rendering.html: Added.
* css3/font-variant-font-face-all-expected.html: Added.
* css3/font-variant-font-face-all.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191968 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/font-feature-settings-font-face-rendering-expected.html [new file with mode: 0644]
LayoutTests/css3/font-feature-settings-font-face-rendering.html [new file with mode: 0644]
LayoutTests/css3/font-variant-font-face-all-expected.html [new file with mode: 0644]
LayoutTests/css3/font-variant-font-face-all.html [new file with mode: 0644]
LayoutTests/css3/font-variant-font-face-override-expected.html [new file with mode: 0644]
LayoutTests/css3/font-variant-font-face-override.html [new file with mode: 0644]
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSFontFace.cpp
Source/WebCore/css/CSSFontFace.h
Source/WebCore/css/CSSFontFaceSource.cpp
Source/WebCore/css/CSSFontFaceSource.h
Source/WebCore/css/CSSFontSelector.cpp
Source/WebCore/css/FontVariantBuilder.h [new file with mode: 0644]
Source/WebCore/css/StyleBuilderCustom.h
Source/WebCore/loader/cache/CachedFont.cpp
Source/WebCore/loader/cache/CachedFont.h
Source/WebCore/loader/cache/CachedSVGFont.cpp
Source/WebCore/loader/cache/CachedSVGFont.h
Source/WebCore/platform/graphics/FontCache.h
Source/WebCore/platform/graphics/FontCascade.cpp
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h
Source/WebCore/platform/text/TextFlags.h
Source/WebCore/rendering/RenderThemeIOS.mm