haikuwebkit/LayoutTests/css3/font-variant-parsing.html

110 lines
6.2 KiB
HTML
Raw Permalink Normal View History

[Cocoa] [Font Features] Implement font-variant-* https://bugs.webkit.org/show_bug.cgi?id=148413 Reviewed by Darin Adler. Source/WebCore: This patch is the first pass of implementing of the font-variant-* properties. Specifically, these properties are: font-variant-ligatures font-variant-position font-variant-caps font-variant-numeric font-variant-alternates font-variant-east-asian These new properties are held inside FontDescription as bit fields. At font creation time, we consult with the FontDescription to figure out which variants are specified. We then convert those variants to font features, and resolve these font features with the additional features specified by font-feature-settings (as the spec requires). This patch also makes our caches sensitive to these new properties of FontDescription so we don't look up cached, stale fonts. The implementation has some caveats, however. They are listed here: 1. These new properties need to interact correctly with @font-face declarations. In particular, only certain properties of the FontDescription should be considered when detecting if a @font-face declaration applies to a particular element. This discrimination does not happen correctly. In addition, any feature-specific CSS properties inside the @font-face declaration need to be consulted at a particular point during the feature resolve. This does not currently occur. 2. One of the properties, font-variant-alternates, has a few values which require custom CSS functions, which makes modeling the properties as bit fields tricky. These extra values need to be implemented. This patch implements all the values which do not require extra CSS features. 3. These new properties have a shorthand, font-variant, which is designed to be backward- compatible with CSS 2.1's concept of font-variant. In particular, CSS 2.1 allows you to use "normal" and "small-caps" with font-variant. Both of these values are values of the new property font-variant-caps. However, our existing implementation of small-caps does not use font features when they exist; instead, it simply draws text at a smaller font size and uses (effectively) text-transform to force capital letters. This implementation needs to be unified with the new font-variant-caps property so that we can expand font-variant to be a shorthand for the new properties. 4. font-variant-position and font-variant-caps should provide appropriate synthesis if no matching font-feature exists. 5. FontCascade::typesettingFeatures() is now no-longer accurate. Fixing this would be large enough to warrant its own patch. 6. These properties are not tested with TrueType fonts. Tests: css3/font-variant-all-webfont.html css3/font-variant-parsing.html * css/CSSComputedStyleDeclaration.cpp: Reconstruct StyleProperties from a RenderStyle. (WebCore::appendLigaturesValue): (WebCore::fontVariantLigaturesPropertyValue): (WebCore::fontVariantPositionPropertyValue): (WebCore::fontVariantCapsPropertyValue): (WebCore::fontVariantNumericPropertyValue): (WebCore::fontVariantAlternatesPropertyValue): (WebCore::fontVariantEastAsianPropertyValue): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSFontFeatureValue.cpp: Update to FontFeatureTag instead of WTF::String. (WebCore::CSSFontFeatureValue::CSSFontFeatureValue): (WebCore::CSSFontFeatureValue::customCSSText): * css/CSSFontFeatureValue.h: Ditto. (WebCore::CSSFontFeatureValue::create): (WebCore::CSSFontFeatureValue::tag): * css/CSSParser.cpp: Parse the new properties according to the CSS3 fonts spec. (WebCore::isValidKeywordPropertyAndValue): (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseFontFeatureTag): (WebCore::CSSParser::parseFontVariantLigatures): (WebCore::CSSParser::parseFontVariantNumeric): (WebCore::CSSParser::parseFontVariantEastAsian): * css/CSSParser.h: * css/CSSPrimitiveValueMappings.h: For the three properties which are simple keyword value properties, implement casting operators to automatically convert between RenderStyle objects and CSS property objects. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator FontVariantPosition): (WebCore::CSSPrimitiveValue::operator FontVariantCaps): (WebCore::CSSPrimitiveValue::operator FontVariantAlternates): * css/CSSPropertyNames.in: New properties. * css/CSSValueKeywords.in: New values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertFontFeatureSettings): Update to not use RefPtrs. * css/StyleBuilderCustom.h: Properties which are not simple keyword value properties are decomposed into multiple members of FontDescription. These properties exist to convert between these aggregate members and the CSS properties. (WebCore::StyleBuilderCustom::applyInheritFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInitialFontVariantLigatures): (WebCore::StyleBuilderCustom::applyValueFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInheritFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInitialFontVariantNumeric): (WebCore::StyleBuilderCustom::applyValueFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInheritFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyValueFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialWebkitFontVariantLigatures): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitFontVariantLigatures): Deleted. (WebCore::StyleBuilderCustom::applyValueWebkitFontVariantLigatures): Deleted. * editing/cocoa/HTMLConverter.mm: (HTMLConverter::computedAttributesForElement): Unprefix font-variant-ligatures. * platform/graphics/FontCache.h: Update cache to be sensitive to new state in FontDescription. (WebCore::FontDescriptionKey::FontDescriptionKey): (WebCore::FontDescriptionKey::operator==): (WebCore::FontDescriptionKey::computeHash): (WebCore::FontDescriptionKey::makeFlagsKey): (WebCore::FontDescriptionKey::makeFlagKey): Deleted. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::codePath): These new variants should trigger the complex text codepath. * platform/graphics/FontCascade.h: (WebCore::FontCascade::computeTypesettingFeatures): Update to use new state enum. * platform/graphics/FontDescription.cpp: Add state to hold new property values. (WebCore::FontDescription::FontDescription): (WebCore::FontCascadeDescription::FontCascadeDescription): Deleted. * platform/graphics/FontDescription.h: Add state to hold new property values. (WebCore::FontDescription::featureSettings): (WebCore::FontDescription::variantCommonLigatures): (WebCore::FontDescription::variantDiscretionaryLigatures): (WebCore::FontDescription::variantHistoricalLigatures): (WebCore::FontDescription::variantContextualAlternates): (WebCore::FontDescription::variantPosition): (WebCore::FontDescription::variantCaps): (WebCore::FontDescription::variantNumericFigure): (WebCore::FontDescription::variantNumericSpacing): (WebCore::FontDescription::variantNumericFraction): (WebCore::FontDescription::variantNumericOrdinal): (WebCore::FontDescription::variantNumericSlashedZero): (WebCore::FontDescription::variantAlternates): (WebCore::FontDescription::variantEastAsianVariant): (WebCore::FontDescription::variantEastAsianWidth): (WebCore::FontDescription::variantEastAsianRuby): (WebCore::FontDescription::variantSettings): (WebCore::FontDescription::setFeatureSettings): (WebCore::FontDescription::setVariantCommonLigatures): (WebCore::FontDescription::setVariantDiscretionaryLigatures): (WebCore::FontDescription::setVariantHistoricalLigatures): (WebCore::FontDescription::setVariantContextualAlternates): (WebCore::FontDescription::setVariantPosition): (WebCore::FontDescription::setVariantCaps): (WebCore::FontDescription::setVariantNumericFigure): (WebCore::FontDescription::setVariantNumericSpacing): (WebCore::FontDescription::setVariantNumericFraction): (WebCore::FontDescription::setVariantNumericOrdinal): (WebCore::FontDescription::setVariantNumericSlashedZero): (WebCore::FontDescription::setVariantAlternates): (WebCore::FontDescription::setVariantEastAsianVariant): (WebCore::FontDescription::setVariantEastAsianWidth): (WebCore::FontDescription::setVariantEastAsianRuby): (WebCore::FontDescription::operator==): (WebCore::FontCascadeDescription::initialVariantPosition): (WebCore::FontCascadeDescription::initialVariantCaps): (WebCore::FontCascadeDescription::initialVariantAlternates): (WebCore::FontCascadeDescription::commonLigaturesState): Deleted. (WebCore::FontCascadeDescription::discretionaryLigaturesState): Deleted. (WebCore::FontCascadeDescription::historicalLigaturesState): Deleted. (WebCore::FontCascadeDescription::setCommonLigaturesState): Deleted. (WebCore::FontCascadeDescription::setDiscretionaryLigaturesState): Deleted. (WebCore::FontCascadeDescription::setHistoricalLigaturesState): Deleted. (WebCore::FontCascadeDescription::operator==): Deleted. * platform/graphics/FontFeatureSettings.cpp: Update to use FontFeatureTag instead of WTF::String. (WebCore::FontFeature::FontFeature): (WebCore::FontFeature::operator==): (WebCore::FontFeature::operator<): (WebCore::FontFeatureSettings::hash): (WebCore::FontFeatureSettings::create): Deleted. * platform/graphics/FontFeatureSettings.h: Update to use FontFeatureTag instead of WTF::String. (WebCore::fontFeatureTag): (WebCore::FontFeatureTagHash::hash): (WebCore::FontFeatureTagHash::equal): (WebCore::FontFeatureTagHashTraits::constructDeletedValue): (WebCore::FontFeatureTagHashTraits::isDeletedValue): (WebCore::FontFeature::tag): (WebCore::FontFeatureSettings::operator==): (WebCore::FontFeatureSettings::begin): (WebCore::FontFeatureSettings::end): (WebCore::FontFeatureSettings::FontFeatureSettings): Deleted. * platform/graphics/cocoa/FontCacheCoreText.cpp: Ditto. Also, when computing font features, consult with the state inside FontDescription. (WebCore::tagEquals): (WebCore::appendTrueTypeFeature): (WebCore::appendOpenTypeFeature): (WebCore::computeFeatureSettingsFromVariants): (WebCore::preparePlatformFont): (WebCore::platformFontLookupWithFamily): (WebCore::fontWithFamily): (WebCore::FontCache::createFontPlatformData): (WebCore::FontCache::systemFallbackForCharacters): * platform/graphics/harfbuzz/HarfBuzzShaper.cpp: Update to use references instead of pointers. (WebCore::HarfBuzzShaper::setFontFeatures): * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamily): Ditto. * platform/graphics/mac/FontCustomPlatformData.cpp: (WebCore::FontCustomPlatformData::fontPlatformData): Be sensitive to new state inside FontDescription. * platform/text/TextFlags.h: (WebCore::FontVariantSettings::isAllNormal): New state enums. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::updateCachedSystemFontDescription): Be sensitive to new state inside FontDescription. * rendering/line/BreakingContext.h: Tools: Update test font to use "lnum" feature. * FontWithFeatures/FontWithFeatures/FontCreator.cpp: (Generator::appendGSUBTable): LayoutTests: Updating tests because font-variant-ligatures is being unprefixed. Also, update css3/resources/FontWithFeatures.otf to support "lnum" feature. * css3/font-feature-settings-rendering-2-expected.html: * css3/font-feature-settings-rendering-2.html: * css3/font-variant-all-webfont-expected.html: Added. * css3/font-variant-all-webfont.html: Added. * css3/font-variant-parsing-expected.txt: Added. * css3/font-variant-parsing.html: Added. * css3/resources/FontWithFeatures.otf: * fast/css/getComputedStyle/computed-style-expected.txt: * fast/css/getComputedStyle/computed-style-font-family-expected.txt: * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt: * fast/css/getComputedStyle/resources/property-names.js: * fast/css/parsing-font-variant-ligatures.html: * fast/text/font-variant-ligatures.html: * platform/mac/TestExpectations: * svg/css/getComputedStyle-basic-expected.txt: Canonical link: https://commits.webkit.org/167617@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-24 00:40:53 +00:00
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script>
function runTest(property, propertyText, expectedText) {
var element = document.createElement("span");
element.setAttribute("id", "testElement");
if (property != "")
element.setAttribute("style", property + ": " + propertyText + ";");
document.body.appendChild(element);
shouldBeEqualToString("window.getComputedStyle(document.getElementById('testElement')).getPropertyCSSValue('" + property + "').cssText", expectedText);
document.body.removeChild(element);
}
runTest("font-variant-ligatures", "", "normal");
runTest("font-variant-ligatures", "normal", "normal");
runTest("font-variant-ligatures", "normal common-ligatures", "normal");
runTest("font-variant-ligatures", "notavalidvalue", "normal");
runTest("font-variant-ligatures", "common-ligatures", "common-ligatures");
runTest("font-variant-ligatures", "common-ligatures common-ligatures", "normal");
[Cocoa] [Font Features] Implement font-variant-* https://bugs.webkit.org/show_bug.cgi?id=148413 Reviewed by Darin Adler. Source/WebCore: This patch is the first pass of implementing of the font-variant-* properties. Specifically, these properties are: font-variant-ligatures font-variant-position font-variant-caps font-variant-numeric font-variant-alternates font-variant-east-asian These new properties are held inside FontDescription as bit fields. At font creation time, we consult with the FontDescription to figure out which variants are specified. We then convert those variants to font features, and resolve these font features with the additional features specified by font-feature-settings (as the spec requires). This patch also makes our caches sensitive to these new properties of FontDescription so we don't look up cached, stale fonts. The implementation has some caveats, however. They are listed here: 1. These new properties need to interact correctly with @font-face declarations. In particular, only certain properties of the FontDescription should be considered when detecting if a @font-face declaration applies to a particular element. This discrimination does not happen correctly. In addition, any feature-specific CSS properties inside the @font-face declaration need to be consulted at a particular point during the feature resolve. This does not currently occur. 2. One of the properties, font-variant-alternates, has a few values which require custom CSS functions, which makes modeling the properties as bit fields tricky. These extra values need to be implemented. This patch implements all the values which do not require extra CSS features. 3. These new properties have a shorthand, font-variant, which is designed to be backward- compatible with CSS 2.1's concept of font-variant. In particular, CSS 2.1 allows you to use "normal" and "small-caps" with font-variant. Both of these values are values of the new property font-variant-caps. However, our existing implementation of small-caps does not use font features when they exist; instead, it simply draws text at a smaller font size and uses (effectively) text-transform to force capital letters. This implementation needs to be unified with the new font-variant-caps property so that we can expand font-variant to be a shorthand for the new properties. 4. font-variant-position and font-variant-caps should provide appropriate synthesis if no matching font-feature exists. 5. FontCascade::typesettingFeatures() is now no-longer accurate. Fixing this would be large enough to warrant its own patch. 6. These properties are not tested with TrueType fonts. Tests: css3/font-variant-all-webfont.html css3/font-variant-parsing.html * css/CSSComputedStyleDeclaration.cpp: Reconstruct StyleProperties from a RenderStyle. (WebCore::appendLigaturesValue): (WebCore::fontVariantLigaturesPropertyValue): (WebCore::fontVariantPositionPropertyValue): (WebCore::fontVariantCapsPropertyValue): (WebCore::fontVariantNumericPropertyValue): (WebCore::fontVariantAlternatesPropertyValue): (WebCore::fontVariantEastAsianPropertyValue): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSFontFeatureValue.cpp: Update to FontFeatureTag instead of WTF::String. (WebCore::CSSFontFeatureValue::CSSFontFeatureValue): (WebCore::CSSFontFeatureValue::customCSSText): * css/CSSFontFeatureValue.h: Ditto. (WebCore::CSSFontFeatureValue::create): (WebCore::CSSFontFeatureValue::tag): * css/CSSParser.cpp: Parse the new properties according to the CSS3 fonts spec. (WebCore::isValidKeywordPropertyAndValue): (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseFontFeatureTag): (WebCore::CSSParser::parseFontVariantLigatures): (WebCore::CSSParser::parseFontVariantNumeric): (WebCore::CSSParser::parseFontVariantEastAsian): * css/CSSParser.h: * css/CSSPrimitiveValueMappings.h: For the three properties which are simple keyword value properties, implement casting operators to automatically convert between RenderStyle objects and CSS property objects. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator FontVariantPosition): (WebCore::CSSPrimitiveValue::operator FontVariantCaps): (WebCore::CSSPrimitiveValue::operator FontVariantAlternates): * css/CSSPropertyNames.in: New properties. * css/CSSValueKeywords.in: New values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertFontFeatureSettings): Update to not use RefPtrs. * css/StyleBuilderCustom.h: Properties which are not simple keyword value properties are decomposed into multiple members of FontDescription. These properties exist to convert between these aggregate members and the CSS properties. (WebCore::StyleBuilderCustom::applyInheritFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInitialFontVariantLigatures): (WebCore::StyleBuilderCustom::applyValueFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInheritFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInitialFontVariantNumeric): (WebCore::StyleBuilderCustom::applyValueFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInheritFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyValueFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialWebkitFontVariantLigatures): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitFontVariantLigatures): Deleted. (WebCore::StyleBuilderCustom::applyValueWebkitFontVariantLigatures): Deleted. * editing/cocoa/HTMLConverter.mm: (HTMLConverter::computedAttributesForElement): Unprefix font-variant-ligatures. * platform/graphics/FontCache.h: Update cache to be sensitive to new state in FontDescription. (WebCore::FontDescriptionKey::FontDescriptionKey): (WebCore::FontDescriptionKey::operator==): (WebCore::FontDescriptionKey::computeHash): (WebCore::FontDescriptionKey::makeFlagsKey): (WebCore::FontDescriptionKey::makeFlagKey): Deleted. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::codePath): These new variants should trigger the complex text codepath. * platform/graphics/FontCascade.h: (WebCore::FontCascade::computeTypesettingFeatures): Update to use new state enum. * platform/graphics/FontDescription.cpp: Add state to hold new property values. (WebCore::FontDescription::FontDescription): (WebCore::FontCascadeDescription::FontCascadeDescription): Deleted. * platform/graphics/FontDescription.h: Add state to hold new property values. (WebCore::FontDescription::featureSettings): (WebCore::FontDescription::variantCommonLigatures): (WebCore::FontDescription::variantDiscretionaryLigatures): (WebCore::FontDescription::variantHistoricalLigatures): (WebCore::FontDescription::variantContextualAlternates): (WebCore::FontDescription::variantPosition): (WebCore::FontDescription::variantCaps): (WebCore::FontDescription::variantNumericFigure): (WebCore::FontDescription::variantNumericSpacing): (WebCore::FontDescription::variantNumericFraction): (WebCore::FontDescription::variantNumericOrdinal): (WebCore::FontDescription::variantNumericSlashedZero): (WebCore::FontDescription::variantAlternates): (WebCore::FontDescription::variantEastAsianVariant): (WebCore::FontDescription::variantEastAsianWidth): (WebCore::FontDescription::variantEastAsianRuby): (WebCore::FontDescription::variantSettings): (WebCore::FontDescription::setFeatureSettings): (WebCore::FontDescription::setVariantCommonLigatures): (WebCore::FontDescription::setVariantDiscretionaryLigatures): (WebCore::FontDescription::setVariantHistoricalLigatures): (WebCore::FontDescription::setVariantContextualAlternates): (WebCore::FontDescription::setVariantPosition): (WebCore::FontDescription::setVariantCaps): (WebCore::FontDescription::setVariantNumericFigure): (WebCore::FontDescription::setVariantNumericSpacing): (WebCore::FontDescription::setVariantNumericFraction): (WebCore::FontDescription::setVariantNumericOrdinal): (WebCore::FontDescription::setVariantNumericSlashedZero): (WebCore::FontDescription::setVariantAlternates): (WebCore::FontDescription::setVariantEastAsianVariant): (WebCore::FontDescription::setVariantEastAsianWidth): (WebCore::FontDescription::setVariantEastAsianRuby): (WebCore::FontDescription::operator==): (WebCore::FontCascadeDescription::initialVariantPosition): (WebCore::FontCascadeDescription::initialVariantCaps): (WebCore::FontCascadeDescription::initialVariantAlternates): (WebCore::FontCascadeDescription::commonLigaturesState): Deleted. (WebCore::FontCascadeDescription::discretionaryLigaturesState): Deleted. (WebCore::FontCascadeDescription::historicalLigaturesState): Deleted. (WebCore::FontCascadeDescription::setCommonLigaturesState): Deleted. (WebCore::FontCascadeDescription::setDiscretionaryLigaturesState): Deleted. (WebCore::FontCascadeDescription::setHistoricalLigaturesState): Deleted. (WebCore::FontCascadeDescription::operator==): Deleted. * platform/graphics/FontFeatureSettings.cpp: Update to use FontFeatureTag instead of WTF::String. (WebCore::FontFeature::FontFeature): (WebCore::FontFeature::operator==): (WebCore::FontFeature::operator<): (WebCore::FontFeatureSettings::hash): (WebCore::FontFeatureSettings::create): Deleted. * platform/graphics/FontFeatureSettings.h: Update to use FontFeatureTag instead of WTF::String. (WebCore::fontFeatureTag): (WebCore::FontFeatureTagHash::hash): (WebCore::FontFeatureTagHash::equal): (WebCore::FontFeatureTagHashTraits::constructDeletedValue): (WebCore::FontFeatureTagHashTraits::isDeletedValue): (WebCore::FontFeature::tag): (WebCore::FontFeatureSettings::operator==): (WebCore::FontFeatureSettings::begin): (WebCore::FontFeatureSettings::end): (WebCore::FontFeatureSettings::FontFeatureSettings): Deleted. * platform/graphics/cocoa/FontCacheCoreText.cpp: Ditto. Also, when computing font features, consult with the state inside FontDescription. (WebCore::tagEquals): (WebCore::appendTrueTypeFeature): (WebCore::appendOpenTypeFeature): (WebCore::computeFeatureSettingsFromVariants): (WebCore::preparePlatformFont): (WebCore::platformFontLookupWithFamily): (WebCore::fontWithFamily): (WebCore::FontCache::createFontPlatformData): (WebCore::FontCache::systemFallbackForCharacters): * platform/graphics/harfbuzz/HarfBuzzShaper.cpp: Update to use references instead of pointers. (WebCore::HarfBuzzShaper::setFontFeatures): * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamily): Ditto. * platform/graphics/mac/FontCustomPlatformData.cpp: (WebCore::FontCustomPlatformData::fontPlatformData): Be sensitive to new state inside FontDescription. * platform/text/TextFlags.h: (WebCore::FontVariantSettings::isAllNormal): New state enums. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::updateCachedSystemFontDescription): Be sensitive to new state inside FontDescription. * rendering/line/BreakingContext.h: Tools: Update test font to use "lnum" feature. * FontWithFeatures/FontWithFeatures/FontCreator.cpp: (Generator::appendGSUBTable): LayoutTests: Updating tests because font-variant-ligatures is being unprefixed. Also, update css3/resources/FontWithFeatures.otf to support "lnum" feature. * css3/font-feature-settings-rendering-2-expected.html: * css3/font-feature-settings-rendering-2.html: * css3/font-variant-all-webfont-expected.html: Added. * css3/font-variant-all-webfont.html: Added. * css3/font-variant-parsing-expected.txt: Added. * css3/font-variant-parsing.html: Added. * css3/resources/FontWithFeatures.otf: * fast/css/getComputedStyle/computed-style-expected.txt: * fast/css/getComputedStyle/computed-style-font-family-expected.txt: * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt: * fast/css/getComputedStyle/resources/property-names.js: * fast/css/parsing-font-variant-ligatures.html: * fast/text/font-variant-ligatures.html: * platform/mac/TestExpectations: * svg/css/getComputedStyle-basic-expected.txt: Canonical link: https://commits.webkit.org/167617@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-24 00:40:53 +00:00
runTest("font-variant-ligatures", "no-common-ligatures", "no-common-ligatures");
runTest("font-variant-ligatures", "discretionary-ligatures", "discretionary-ligatures");
runTest("font-variant-ligatures", "no-discretionary-ligatures", "no-discretionary-ligatures");
runTest("font-variant-ligatures", "historical-ligatures", "historical-ligatures");
runTest("font-variant-ligatures", "no-historical-ligatures", "no-historical-ligatures");
runTest("font-variant-ligatures", "contextual", "contextual");
runTest("font-variant-ligatures", "no-contextual", "no-contextual");
runTest("font-variant-ligatures", "common-ligatures no-contextual", "common-ligatures no-contextual");
runTest("font-variant-ligatures", "no-contextual common-ligatures", "common-ligatures no-contextual");
runTest("font-variant-ligatures", "no-contextual common-ligatures notavalidvalue", "normal");
runTest("font-variant-ligatures", "none", "none");
runTest("font-variant-ligatures", "no-common-ligatures no-discretionary-ligatures no-historical-ligatures no-contextual", "none");
runTest("font-variant-position", "", "normal");
runTest("font-variant-position", "normal", "normal");
runTest("font-variant-position", "notavalidvalue", "normal");
runTest("font-variant-position", "sub", "sub");
runTest("font-variant-position", "super", "super");
runTest("font-variant-position", "sub super", "normal");
runTest("font-variant-caps", "", "normal");
runTest("font-variant-caps", "normal", "normal");
runTest("font-variant-caps", "notavalidvalue", "normal");
runTest("font-variant-caps", "normal notavalidvalue", "normal");
runTest("font-variant-caps", "normal small-caps", "normal");
runTest("font-variant-caps", "small-caps", "small-caps");
runTest("font-variant-caps", "all-small-caps", "all-small-caps");
runTest("font-variant-caps", "petite-caps", "petite-caps");
runTest("font-variant-caps", "all-petite-caps", "all-petite-caps");
runTest("font-variant-caps", "unicase", "unicase");
runTest("font-variant-caps", "titling-caps", "titling-caps");
runTest("font-variant-caps", "unicase titling-caps", "normal");
runTest("font-variant-caps", "small-caps all-small-caps", "normal");
runTest("font-variant-numeric", "", "normal");
runTest("font-variant-numeric", "normal", "normal");
runTest("font-variant-numeric", "notavalidvalue", "normal");
runTest("font-variant-numeric", "normal notavalidvalue", "normal");
runTest("font-variant-numeric", "normal lining-nums", "normal");
runTest("font-variant-numeric", "lining-nums", "lining-nums");
runTest("font-variant-numeric", "oldstyle-nums", "oldstyle-nums");
runTest("font-variant-numeric", "proportional-nums", "proportional-nums");
runTest("font-variant-numeric", "tabular-nums", "tabular-nums");
runTest("font-variant-numeric", "diagonal-fractions", "diagonal-fractions");
runTest("font-variant-numeric", "stacked-fractions", "stacked-fractions");
runTest("font-variant-numeric", "ordinal", "ordinal");
runTest("font-variant-numeric", "slashed-zero", "slashed-zero");
runTest("font-variant-numeric", "lining-nums slashed-zero", "lining-nums slashed-zero");
runTest("font-variant-numeric", "lining-nums oldstyle-nums", "normal");
runTest("font-variant-numeric", "proportional-nums tabular-nums", "normal");
runTest("font-variant-numeric", "diagonal-fractions stacked-fractions", "normal");
[Cocoa] [Font Features] Implement font-variant-* https://bugs.webkit.org/show_bug.cgi?id=148413 Reviewed by Darin Adler. Source/WebCore: This patch is the first pass of implementing of the font-variant-* properties. Specifically, these properties are: font-variant-ligatures font-variant-position font-variant-caps font-variant-numeric font-variant-alternates font-variant-east-asian These new properties are held inside FontDescription as bit fields. At font creation time, we consult with the FontDescription to figure out which variants are specified. We then convert those variants to font features, and resolve these font features with the additional features specified by font-feature-settings (as the spec requires). This patch also makes our caches sensitive to these new properties of FontDescription so we don't look up cached, stale fonts. The implementation has some caveats, however. They are listed here: 1. These new properties need to interact correctly with @font-face declarations. In particular, only certain properties of the FontDescription should be considered when detecting if a @font-face declaration applies to a particular element. This discrimination does not happen correctly. In addition, any feature-specific CSS properties inside the @font-face declaration need to be consulted at a particular point during the feature resolve. This does not currently occur. 2. One of the properties, font-variant-alternates, has a few values which require custom CSS functions, which makes modeling the properties as bit fields tricky. These extra values need to be implemented. This patch implements all the values which do not require extra CSS features. 3. These new properties have a shorthand, font-variant, which is designed to be backward- compatible with CSS 2.1's concept of font-variant. In particular, CSS 2.1 allows you to use "normal" and "small-caps" with font-variant. Both of these values are values of the new property font-variant-caps. However, our existing implementation of small-caps does not use font features when they exist; instead, it simply draws text at a smaller font size and uses (effectively) text-transform to force capital letters. This implementation needs to be unified with the new font-variant-caps property so that we can expand font-variant to be a shorthand for the new properties. 4. font-variant-position and font-variant-caps should provide appropriate synthesis if no matching font-feature exists. 5. FontCascade::typesettingFeatures() is now no-longer accurate. Fixing this would be large enough to warrant its own patch. 6. These properties are not tested with TrueType fonts. Tests: css3/font-variant-all-webfont.html css3/font-variant-parsing.html * css/CSSComputedStyleDeclaration.cpp: Reconstruct StyleProperties from a RenderStyle. (WebCore::appendLigaturesValue): (WebCore::fontVariantLigaturesPropertyValue): (WebCore::fontVariantPositionPropertyValue): (WebCore::fontVariantCapsPropertyValue): (WebCore::fontVariantNumericPropertyValue): (WebCore::fontVariantAlternatesPropertyValue): (WebCore::fontVariantEastAsianPropertyValue): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSFontFeatureValue.cpp: Update to FontFeatureTag instead of WTF::String. (WebCore::CSSFontFeatureValue::CSSFontFeatureValue): (WebCore::CSSFontFeatureValue::customCSSText): * css/CSSFontFeatureValue.h: Ditto. (WebCore::CSSFontFeatureValue::create): (WebCore::CSSFontFeatureValue::tag): * css/CSSParser.cpp: Parse the new properties according to the CSS3 fonts spec. (WebCore::isValidKeywordPropertyAndValue): (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseFontFeatureTag): (WebCore::CSSParser::parseFontVariantLigatures): (WebCore::CSSParser::parseFontVariantNumeric): (WebCore::CSSParser::parseFontVariantEastAsian): * css/CSSParser.h: * css/CSSPrimitiveValueMappings.h: For the three properties which are simple keyword value properties, implement casting operators to automatically convert between RenderStyle objects and CSS property objects. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator FontVariantPosition): (WebCore::CSSPrimitiveValue::operator FontVariantCaps): (WebCore::CSSPrimitiveValue::operator FontVariantAlternates): * css/CSSPropertyNames.in: New properties. * css/CSSValueKeywords.in: New values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertFontFeatureSettings): Update to not use RefPtrs. * css/StyleBuilderCustom.h: Properties which are not simple keyword value properties are decomposed into multiple members of FontDescription. These properties exist to convert between these aggregate members and the CSS properties. (WebCore::StyleBuilderCustom::applyInheritFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInitialFontVariantLigatures): (WebCore::StyleBuilderCustom::applyValueFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInheritFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInitialFontVariantNumeric): (WebCore::StyleBuilderCustom::applyValueFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInheritFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyValueFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialWebkitFontVariantLigatures): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitFontVariantLigatures): Deleted. (WebCore::StyleBuilderCustom::applyValueWebkitFontVariantLigatures): Deleted. * editing/cocoa/HTMLConverter.mm: (HTMLConverter::computedAttributesForElement): Unprefix font-variant-ligatures. * platform/graphics/FontCache.h: Update cache to be sensitive to new state in FontDescription. (WebCore::FontDescriptionKey::FontDescriptionKey): (WebCore::FontDescriptionKey::operator==): (WebCore::FontDescriptionKey::computeHash): (WebCore::FontDescriptionKey::makeFlagsKey): (WebCore::FontDescriptionKey::makeFlagKey): Deleted. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::codePath): These new variants should trigger the complex text codepath. * platform/graphics/FontCascade.h: (WebCore::FontCascade::computeTypesettingFeatures): Update to use new state enum. * platform/graphics/FontDescription.cpp: Add state to hold new property values. (WebCore::FontDescription::FontDescription): (WebCore::FontCascadeDescription::FontCascadeDescription): Deleted. * platform/graphics/FontDescription.h: Add state to hold new property values. (WebCore::FontDescription::featureSettings): (WebCore::FontDescription::variantCommonLigatures): (WebCore::FontDescription::variantDiscretionaryLigatures): (WebCore::FontDescription::variantHistoricalLigatures): (WebCore::FontDescription::variantContextualAlternates): (WebCore::FontDescription::variantPosition): (WebCore::FontDescription::variantCaps): (WebCore::FontDescription::variantNumericFigure): (WebCore::FontDescription::variantNumericSpacing): (WebCore::FontDescription::variantNumericFraction): (WebCore::FontDescription::variantNumericOrdinal): (WebCore::FontDescription::variantNumericSlashedZero): (WebCore::FontDescription::variantAlternates): (WebCore::FontDescription::variantEastAsianVariant): (WebCore::FontDescription::variantEastAsianWidth): (WebCore::FontDescription::variantEastAsianRuby): (WebCore::FontDescription::variantSettings): (WebCore::FontDescription::setFeatureSettings): (WebCore::FontDescription::setVariantCommonLigatures): (WebCore::FontDescription::setVariantDiscretionaryLigatures): (WebCore::FontDescription::setVariantHistoricalLigatures): (WebCore::FontDescription::setVariantContextualAlternates): (WebCore::FontDescription::setVariantPosition): (WebCore::FontDescription::setVariantCaps): (WebCore::FontDescription::setVariantNumericFigure): (WebCore::FontDescription::setVariantNumericSpacing): (WebCore::FontDescription::setVariantNumericFraction): (WebCore::FontDescription::setVariantNumericOrdinal): (WebCore::FontDescription::setVariantNumericSlashedZero): (WebCore::FontDescription::setVariantAlternates): (WebCore::FontDescription::setVariantEastAsianVariant): (WebCore::FontDescription::setVariantEastAsianWidth): (WebCore::FontDescription::setVariantEastAsianRuby): (WebCore::FontDescription::operator==): (WebCore::FontCascadeDescription::initialVariantPosition): (WebCore::FontCascadeDescription::initialVariantCaps): (WebCore::FontCascadeDescription::initialVariantAlternates): (WebCore::FontCascadeDescription::commonLigaturesState): Deleted. (WebCore::FontCascadeDescription::discretionaryLigaturesState): Deleted. (WebCore::FontCascadeDescription::historicalLigaturesState): Deleted. (WebCore::FontCascadeDescription::setCommonLigaturesState): Deleted. (WebCore::FontCascadeDescription::setDiscretionaryLigaturesState): Deleted. (WebCore::FontCascadeDescription::setHistoricalLigaturesState): Deleted. (WebCore::FontCascadeDescription::operator==): Deleted. * platform/graphics/FontFeatureSettings.cpp: Update to use FontFeatureTag instead of WTF::String. (WebCore::FontFeature::FontFeature): (WebCore::FontFeature::operator==): (WebCore::FontFeature::operator<): (WebCore::FontFeatureSettings::hash): (WebCore::FontFeatureSettings::create): Deleted. * platform/graphics/FontFeatureSettings.h: Update to use FontFeatureTag instead of WTF::String. (WebCore::fontFeatureTag): (WebCore::FontFeatureTagHash::hash): (WebCore::FontFeatureTagHash::equal): (WebCore::FontFeatureTagHashTraits::constructDeletedValue): (WebCore::FontFeatureTagHashTraits::isDeletedValue): (WebCore::FontFeature::tag): (WebCore::FontFeatureSettings::operator==): (WebCore::FontFeatureSettings::begin): (WebCore::FontFeatureSettings::end): (WebCore::FontFeatureSettings::FontFeatureSettings): Deleted. * platform/graphics/cocoa/FontCacheCoreText.cpp: Ditto. Also, when computing font features, consult with the state inside FontDescription. (WebCore::tagEquals): (WebCore::appendTrueTypeFeature): (WebCore::appendOpenTypeFeature): (WebCore::computeFeatureSettingsFromVariants): (WebCore::preparePlatformFont): (WebCore::platformFontLookupWithFamily): (WebCore::fontWithFamily): (WebCore::FontCache::createFontPlatformData): (WebCore::FontCache::systemFallbackForCharacters): * platform/graphics/harfbuzz/HarfBuzzShaper.cpp: Update to use references instead of pointers. (WebCore::HarfBuzzShaper::setFontFeatures): * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamily): Ditto. * platform/graphics/mac/FontCustomPlatformData.cpp: (WebCore::FontCustomPlatformData::fontPlatformData): Be sensitive to new state inside FontDescription. * platform/text/TextFlags.h: (WebCore::FontVariantSettings::isAllNormal): New state enums. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::updateCachedSystemFontDescription): Be sensitive to new state inside FontDescription. * rendering/line/BreakingContext.h: Tools: Update test font to use "lnum" feature. * FontWithFeatures/FontWithFeatures/FontCreator.cpp: (Generator::appendGSUBTable): LayoutTests: Updating tests because font-variant-ligatures is being unprefixed. Also, update css3/resources/FontWithFeatures.otf to support "lnum" feature. * css3/font-feature-settings-rendering-2-expected.html: * css3/font-feature-settings-rendering-2.html: * css3/font-variant-all-webfont-expected.html: Added. * css3/font-variant-all-webfont.html: Added. * css3/font-variant-parsing-expected.txt: Added. * css3/font-variant-parsing.html: Added. * css3/resources/FontWithFeatures.otf: * fast/css/getComputedStyle/computed-style-expected.txt: * fast/css/getComputedStyle/computed-style-font-family-expected.txt: * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt: * fast/css/getComputedStyle/resources/property-names.js: * fast/css/parsing-font-variant-ligatures.html: * fast/text/font-variant-ligatures.html: * platform/mac/TestExpectations: * svg/css/getComputedStyle-basic-expected.txt: Canonical link: https://commits.webkit.org/167617@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-24 00:40:53 +00:00
runTest("font-variant-numeric", "lining-nums proportional-nums", "lining-nums proportional-nums");
runTest("font-variant-numeric", "lining-nums diagonal-fractions", "lining-nums diagonal-fractions");
runTest("font-variant-numeric", "ordinal slashed-zero", "ordinal slashed-zero");
runTest("font-variant-alternates", "", "normal");
runTest("font-variant-alternates", "normal", "normal");
runTest("font-variant-alternates", "notavalidvalue", "normal");
runTest("font-variant-alternates", "normal notavalidvalue", "normal");
runTest("font-variant-alternates", "historical-forms", "historical-forms");
runTest("font-variant-alternates", "normal historical-forms", "normal");
runTest("font-variant-east-asian", "", "normal");
runTest("font-variant-east-asian", "normal", "normal");
runTest("font-variant-east-asian", "notavalidvalue", "normal");
runTest("font-variant-east-asian", "normal notavalidvalue", "normal");
runTest("font-variant-east-asian", "jis78", "jis78");
runTest("font-variant-east-asian", "jis83", "jis83");
runTest("font-variant-east-asian", "jis90", "jis90");
runTest("font-variant-east-asian", "jis04", "jis04");
runTest("font-variant-east-asian", "simplified", "simplified");
runTest("font-variant-east-asian", "traditional", "traditional");
runTest("font-variant-east-asian", "full-width", "full-width");
runTest("font-variant-east-asian", "proportional-width", "proportional-width");
runTest("font-variant-east-asian", "ruby", "ruby");
runTest("font-variant-east-asian", "jis78 jis83", "normal");
runTest("font-variant-east-asian", "jis90 traditional", "normal");
[Cocoa] [Font Features] Implement font-variant-* https://bugs.webkit.org/show_bug.cgi?id=148413 Reviewed by Darin Adler. Source/WebCore: This patch is the first pass of implementing of the font-variant-* properties. Specifically, these properties are: font-variant-ligatures font-variant-position font-variant-caps font-variant-numeric font-variant-alternates font-variant-east-asian These new properties are held inside FontDescription as bit fields. At font creation time, we consult with the FontDescription to figure out which variants are specified. We then convert those variants to font features, and resolve these font features with the additional features specified by font-feature-settings (as the spec requires). This patch also makes our caches sensitive to these new properties of FontDescription so we don't look up cached, stale fonts. The implementation has some caveats, however. They are listed here: 1. These new properties need to interact correctly with @font-face declarations. In particular, only certain properties of the FontDescription should be considered when detecting if a @font-face declaration applies to a particular element. This discrimination does not happen correctly. In addition, any feature-specific CSS properties inside the @font-face declaration need to be consulted at a particular point during the feature resolve. This does not currently occur. 2. One of the properties, font-variant-alternates, has a few values which require custom CSS functions, which makes modeling the properties as bit fields tricky. These extra values need to be implemented. This patch implements all the values which do not require extra CSS features. 3. These new properties have a shorthand, font-variant, which is designed to be backward- compatible with CSS 2.1's concept of font-variant. In particular, CSS 2.1 allows you to use "normal" and "small-caps" with font-variant. Both of these values are values of the new property font-variant-caps. However, our existing implementation of small-caps does not use font features when they exist; instead, it simply draws text at a smaller font size and uses (effectively) text-transform to force capital letters. This implementation needs to be unified with the new font-variant-caps property so that we can expand font-variant to be a shorthand for the new properties. 4. font-variant-position and font-variant-caps should provide appropriate synthesis if no matching font-feature exists. 5. FontCascade::typesettingFeatures() is now no-longer accurate. Fixing this would be large enough to warrant its own patch. 6. These properties are not tested with TrueType fonts. Tests: css3/font-variant-all-webfont.html css3/font-variant-parsing.html * css/CSSComputedStyleDeclaration.cpp: Reconstruct StyleProperties from a RenderStyle. (WebCore::appendLigaturesValue): (WebCore::fontVariantLigaturesPropertyValue): (WebCore::fontVariantPositionPropertyValue): (WebCore::fontVariantCapsPropertyValue): (WebCore::fontVariantNumericPropertyValue): (WebCore::fontVariantAlternatesPropertyValue): (WebCore::fontVariantEastAsianPropertyValue): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSFontFeatureValue.cpp: Update to FontFeatureTag instead of WTF::String. (WebCore::CSSFontFeatureValue::CSSFontFeatureValue): (WebCore::CSSFontFeatureValue::customCSSText): * css/CSSFontFeatureValue.h: Ditto. (WebCore::CSSFontFeatureValue::create): (WebCore::CSSFontFeatureValue::tag): * css/CSSParser.cpp: Parse the new properties according to the CSS3 fonts spec. (WebCore::isValidKeywordPropertyAndValue): (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseFontFeatureTag): (WebCore::CSSParser::parseFontVariantLigatures): (WebCore::CSSParser::parseFontVariantNumeric): (WebCore::CSSParser::parseFontVariantEastAsian): * css/CSSParser.h: * css/CSSPrimitiveValueMappings.h: For the three properties which are simple keyword value properties, implement casting operators to automatically convert between RenderStyle objects and CSS property objects. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator FontVariantPosition): (WebCore::CSSPrimitiveValue::operator FontVariantCaps): (WebCore::CSSPrimitiveValue::operator FontVariantAlternates): * css/CSSPropertyNames.in: New properties. * css/CSSValueKeywords.in: New values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertFontFeatureSettings): Update to not use RefPtrs. * css/StyleBuilderCustom.h: Properties which are not simple keyword value properties are decomposed into multiple members of FontDescription. These properties exist to convert between these aggregate members and the CSS properties. (WebCore::StyleBuilderCustom::applyInheritFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInitialFontVariantLigatures): (WebCore::StyleBuilderCustom::applyValueFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInheritFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInitialFontVariantNumeric): (WebCore::StyleBuilderCustom::applyValueFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInheritFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyValueFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialWebkitFontVariantLigatures): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitFontVariantLigatures): Deleted. (WebCore::StyleBuilderCustom::applyValueWebkitFontVariantLigatures): Deleted. * editing/cocoa/HTMLConverter.mm: (HTMLConverter::computedAttributesForElement): Unprefix font-variant-ligatures. * platform/graphics/FontCache.h: Update cache to be sensitive to new state in FontDescription. (WebCore::FontDescriptionKey::FontDescriptionKey): (WebCore::FontDescriptionKey::operator==): (WebCore::FontDescriptionKey::computeHash): (WebCore::FontDescriptionKey::makeFlagsKey): (WebCore::FontDescriptionKey::makeFlagKey): Deleted. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::codePath): These new variants should trigger the complex text codepath. * platform/graphics/FontCascade.h: (WebCore::FontCascade::computeTypesettingFeatures): Update to use new state enum. * platform/graphics/FontDescription.cpp: Add state to hold new property values. (WebCore::FontDescription::FontDescription): (WebCore::FontCascadeDescription::FontCascadeDescription): Deleted. * platform/graphics/FontDescription.h: Add state to hold new property values. (WebCore::FontDescription::featureSettings): (WebCore::FontDescription::variantCommonLigatures): (WebCore::FontDescription::variantDiscretionaryLigatures): (WebCore::FontDescription::variantHistoricalLigatures): (WebCore::FontDescription::variantContextualAlternates): (WebCore::FontDescription::variantPosition): (WebCore::FontDescription::variantCaps): (WebCore::FontDescription::variantNumericFigure): (WebCore::FontDescription::variantNumericSpacing): (WebCore::FontDescription::variantNumericFraction): (WebCore::FontDescription::variantNumericOrdinal): (WebCore::FontDescription::variantNumericSlashedZero): (WebCore::FontDescription::variantAlternates): (WebCore::FontDescription::variantEastAsianVariant): (WebCore::FontDescription::variantEastAsianWidth): (WebCore::FontDescription::variantEastAsianRuby): (WebCore::FontDescription::variantSettings): (WebCore::FontDescription::setFeatureSettings): (WebCore::FontDescription::setVariantCommonLigatures): (WebCore::FontDescription::setVariantDiscretionaryLigatures): (WebCore::FontDescription::setVariantHistoricalLigatures): (WebCore::FontDescription::setVariantContextualAlternates): (WebCore::FontDescription::setVariantPosition): (WebCore::FontDescription::setVariantCaps): (WebCore::FontDescription::setVariantNumericFigure): (WebCore::FontDescription::setVariantNumericSpacing): (WebCore::FontDescription::setVariantNumericFraction): (WebCore::FontDescription::setVariantNumericOrdinal): (WebCore::FontDescription::setVariantNumericSlashedZero): (WebCore::FontDescription::setVariantAlternates): (WebCore::FontDescription::setVariantEastAsianVariant): (WebCore::FontDescription::setVariantEastAsianWidth): (WebCore::FontDescription::setVariantEastAsianRuby): (WebCore::FontDescription::operator==): (WebCore::FontCascadeDescription::initialVariantPosition): (WebCore::FontCascadeDescription::initialVariantCaps): (WebCore::FontCascadeDescription::initialVariantAlternates): (WebCore::FontCascadeDescription::commonLigaturesState): Deleted. (WebCore::FontCascadeDescription::discretionaryLigaturesState): Deleted. (WebCore::FontCascadeDescription::historicalLigaturesState): Deleted. (WebCore::FontCascadeDescription::setCommonLigaturesState): Deleted. (WebCore::FontCascadeDescription::setDiscretionaryLigaturesState): Deleted. (WebCore::FontCascadeDescription::setHistoricalLigaturesState): Deleted. (WebCore::FontCascadeDescription::operator==): Deleted. * platform/graphics/FontFeatureSettings.cpp: Update to use FontFeatureTag instead of WTF::String. (WebCore::FontFeature::FontFeature): (WebCore::FontFeature::operator==): (WebCore::FontFeature::operator<): (WebCore::FontFeatureSettings::hash): (WebCore::FontFeatureSettings::create): Deleted. * platform/graphics/FontFeatureSettings.h: Update to use FontFeatureTag instead of WTF::String. (WebCore::fontFeatureTag): (WebCore::FontFeatureTagHash::hash): (WebCore::FontFeatureTagHash::equal): (WebCore::FontFeatureTagHashTraits::constructDeletedValue): (WebCore::FontFeatureTagHashTraits::isDeletedValue): (WebCore::FontFeature::tag): (WebCore::FontFeatureSettings::operator==): (WebCore::FontFeatureSettings::begin): (WebCore::FontFeatureSettings::end): (WebCore::FontFeatureSettings::FontFeatureSettings): Deleted. * platform/graphics/cocoa/FontCacheCoreText.cpp: Ditto. Also, when computing font features, consult with the state inside FontDescription. (WebCore::tagEquals): (WebCore::appendTrueTypeFeature): (WebCore::appendOpenTypeFeature): (WebCore::computeFeatureSettingsFromVariants): (WebCore::preparePlatformFont): (WebCore::platformFontLookupWithFamily): (WebCore::fontWithFamily): (WebCore::FontCache::createFontPlatformData): (WebCore::FontCache::systemFallbackForCharacters): * platform/graphics/harfbuzz/HarfBuzzShaper.cpp: Update to use references instead of pointers. (WebCore::HarfBuzzShaper::setFontFeatures): * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamily): Ditto. * platform/graphics/mac/FontCustomPlatformData.cpp: (WebCore::FontCustomPlatformData::fontPlatformData): Be sensitive to new state inside FontDescription. * platform/text/TextFlags.h: (WebCore::FontVariantSettings::isAllNormal): New state enums. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::updateCachedSystemFontDescription): Be sensitive to new state inside FontDescription. * rendering/line/BreakingContext.h: Tools: Update test font to use "lnum" feature. * FontWithFeatures/FontWithFeatures/FontCreator.cpp: (Generator::appendGSUBTable): LayoutTests: Updating tests because font-variant-ligatures is being unprefixed. Also, update css3/resources/FontWithFeatures.otf to support "lnum" feature. * css3/font-feature-settings-rendering-2-expected.html: * css3/font-feature-settings-rendering-2.html: * css3/font-variant-all-webfont-expected.html: Added. * css3/font-variant-all-webfont.html: Added. * css3/font-variant-parsing-expected.txt: Added. * css3/font-variant-parsing.html: Added. * css3/resources/FontWithFeatures.otf: * fast/css/getComputedStyle/computed-style-expected.txt: * fast/css/getComputedStyle/computed-style-font-family-expected.txt: * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt: * fast/css/getComputedStyle/resources/property-names.js: * fast/css/parsing-font-variant-ligatures.html: * fast/text/font-variant-ligatures.html: * platform/mac/TestExpectations: * svg/css/getComputedStyle-basic-expected.txt: Canonical link: https://commits.webkit.org/167617@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-24 00:40:53 +00:00
runTest("font-variant-east-asian", "full-width traditional", "traditional full-width");
runTest("font-variant-east-asian", "jis04 proportional-width", "jis04 proportional-width");
runTest("font-variant-east-asian", "jis04 proportional-width ruby", "jis04 proportional-width ruby");
runTest("font-variant-east-asian", "jis83 ruby", "jis83 ruby");
runTest("font-variant-east-asian", "full-width proportional-width", "normal");
[Cocoa] [Font Features] Implement font-variant-* https://bugs.webkit.org/show_bug.cgi?id=148413 Reviewed by Darin Adler. Source/WebCore: This patch is the first pass of implementing of the font-variant-* properties. Specifically, these properties are: font-variant-ligatures font-variant-position font-variant-caps font-variant-numeric font-variant-alternates font-variant-east-asian These new properties are held inside FontDescription as bit fields. At font creation time, we consult with the FontDescription to figure out which variants are specified. We then convert those variants to font features, and resolve these font features with the additional features specified by font-feature-settings (as the spec requires). This patch also makes our caches sensitive to these new properties of FontDescription so we don't look up cached, stale fonts. The implementation has some caveats, however. They are listed here: 1. These new properties need to interact correctly with @font-face declarations. In particular, only certain properties of the FontDescription should be considered when detecting if a @font-face declaration applies to a particular element. This discrimination does not happen correctly. In addition, any feature-specific CSS properties inside the @font-face declaration need to be consulted at a particular point during the feature resolve. This does not currently occur. 2. One of the properties, font-variant-alternates, has a few values which require custom CSS functions, which makes modeling the properties as bit fields tricky. These extra values need to be implemented. This patch implements all the values which do not require extra CSS features. 3. These new properties have a shorthand, font-variant, which is designed to be backward- compatible with CSS 2.1's concept of font-variant. In particular, CSS 2.1 allows you to use "normal" and "small-caps" with font-variant. Both of these values are values of the new property font-variant-caps. However, our existing implementation of small-caps does not use font features when they exist; instead, it simply draws text at a smaller font size and uses (effectively) text-transform to force capital letters. This implementation needs to be unified with the new font-variant-caps property so that we can expand font-variant to be a shorthand for the new properties. 4. font-variant-position and font-variant-caps should provide appropriate synthesis if no matching font-feature exists. 5. FontCascade::typesettingFeatures() is now no-longer accurate. Fixing this would be large enough to warrant its own patch. 6. These properties are not tested with TrueType fonts. Tests: css3/font-variant-all-webfont.html css3/font-variant-parsing.html * css/CSSComputedStyleDeclaration.cpp: Reconstruct StyleProperties from a RenderStyle. (WebCore::appendLigaturesValue): (WebCore::fontVariantLigaturesPropertyValue): (WebCore::fontVariantPositionPropertyValue): (WebCore::fontVariantCapsPropertyValue): (WebCore::fontVariantNumericPropertyValue): (WebCore::fontVariantAlternatesPropertyValue): (WebCore::fontVariantEastAsianPropertyValue): (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSFontFeatureValue.cpp: Update to FontFeatureTag instead of WTF::String. (WebCore::CSSFontFeatureValue::CSSFontFeatureValue): (WebCore::CSSFontFeatureValue::customCSSText): * css/CSSFontFeatureValue.h: Ditto. (WebCore::CSSFontFeatureValue::create): (WebCore::CSSFontFeatureValue::tag): * css/CSSParser.cpp: Parse the new properties according to the CSS3 fonts spec. (WebCore::isValidKeywordPropertyAndValue): (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseFontFeatureTag): (WebCore::CSSParser::parseFontVariantLigatures): (WebCore::CSSParser::parseFontVariantNumeric): (WebCore::CSSParser::parseFontVariantEastAsian): * css/CSSParser.h: * css/CSSPrimitiveValueMappings.h: For the three properties which are simple keyword value properties, implement casting operators to automatically convert between RenderStyle objects and CSS property objects. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator FontVariantPosition): (WebCore::CSSPrimitiveValue::operator FontVariantCaps): (WebCore::CSSPrimitiveValue::operator FontVariantAlternates): * css/CSSPropertyNames.in: New properties. * css/CSSValueKeywords.in: New values. * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertFontFeatureSettings): Update to not use RefPtrs. * css/StyleBuilderCustom.h: Properties which are not simple keyword value properties are decomposed into multiple members of FontDescription. These properties exist to convert between these aggregate members and the CSS properties. (WebCore::StyleBuilderCustom::applyInheritFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInitialFontVariantLigatures): (WebCore::StyleBuilderCustom::applyValueFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInheritFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInitialFontVariantNumeric): (WebCore::StyleBuilderCustom::applyValueFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInheritFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyValueFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialWebkitFontVariantLigatures): Deleted. (WebCore::StyleBuilderCustom::applyInheritWebkitFontVariantLigatures): Deleted. (WebCore::StyleBuilderCustom::applyValueWebkitFontVariantLigatures): Deleted. * editing/cocoa/HTMLConverter.mm: (HTMLConverter::computedAttributesForElement): Unprefix font-variant-ligatures. * platform/graphics/FontCache.h: Update cache to be sensitive to new state in FontDescription. (WebCore::FontDescriptionKey::FontDescriptionKey): (WebCore::FontDescriptionKey::operator==): (WebCore::FontDescriptionKey::computeHash): (WebCore::FontDescriptionKey::makeFlagsKey): (WebCore::FontDescriptionKey::makeFlagKey): Deleted. * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::codePath): These new variants should trigger the complex text codepath. * platform/graphics/FontCascade.h: (WebCore::FontCascade::computeTypesettingFeatures): Update to use new state enum. * platform/graphics/FontDescription.cpp: Add state to hold new property values. (WebCore::FontDescription::FontDescription): (WebCore::FontCascadeDescription::FontCascadeDescription): Deleted. * platform/graphics/FontDescription.h: Add state to hold new property values. (WebCore::FontDescription::featureSettings): (WebCore::FontDescription::variantCommonLigatures): (WebCore::FontDescription::variantDiscretionaryLigatures): (WebCore::FontDescription::variantHistoricalLigatures): (WebCore::FontDescription::variantContextualAlternates): (WebCore::FontDescription::variantPosition): (WebCore::FontDescription::variantCaps): (WebCore::FontDescription::variantNumericFigure): (WebCore::FontDescription::variantNumericSpacing): (WebCore::FontDescription::variantNumericFraction): (WebCore::FontDescription::variantNumericOrdinal): (WebCore::FontDescription::variantNumericSlashedZero): (WebCore::FontDescription::variantAlternates): (WebCore::FontDescription::variantEastAsianVariant): (WebCore::FontDescription::variantEastAsianWidth): (WebCore::FontDescription::variantEastAsianRuby): (WebCore::FontDescription::variantSettings): (WebCore::FontDescription::setFeatureSettings): (WebCore::FontDescription::setVariantCommonLigatures): (WebCore::FontDescription::setVariantDiscretionaryLigatures): (WebCore::FontDescription::setVariantHistoricalLigatures): (WebCore::FontDescription::setVariantContextualAlternates): (WebCore::FontDescription::setVariantPosition): (WebCore::FontDescription::setVariantCaps): (WebCore::FontDescription::setVariantNumericFigure): (WebCore::FontDescription::setVariantNumericSpacing): (WebCore::FontDescription::setVariantNumericFraction): (WebCore::FontDescription::setVariantNumericOrdinal): (WebCore::FontDescription::setVariantNumericSlashedZero): (WebCore::FontDescription::setVariantAlternates): (WebCore::FontDescription::setVariantEastAsianVariant): (WebCore::FontDescription::setVariantEastAsianWidth): (WebCore::FontDescription::setVariantEastAsianRuby): (WebCore::FontDescription::operator==): (WebCore::FontCascadeDescription::initialVariantPosition): (WebCore::FontCascadeDescription::initialVariantCaps): (WebCore::FontCascadeDescription::initialVariantAlternates): (WebCore::FontCascadeDescription::commonLigaturesState): Deleted. (WebCore::FontCascadeDescription::discretionaryLigaturesState): Deleted. (WebCore::FontCascadeDescription::historicalLigaturesState): Deleted. (WebCore::FontCascadeDescription::setCommonLigaturesState): Deleted. (WebCore::FontCascadeDescription::setDiscretionaryLigaturesState): Deleted. (WebCore::FontCascadeDescription::setHistoricalLigaturesState): Deleted. (WebCore::FontCascadeDescription::operator==): Deleted. * platform/graphics/FontFeatureSettings.cpp: Update to use FontFeatureTag instead of WTF::String. (WebCore::FontFeature::FontFeature): (WebCore::FontFeature::operator==): (WebCore::FontFeature::operator<): (WebCore::FontFeatureSettings::hash): (WebCore::FontFeatureSettings::create): Deleted. * platform/graphics/FontFeatureSettings.h: Update to use FontFeatureTag instead of WTF::String. (WebCore::fontFeatureTag): (WebCore::FontFeatureTagHash::hash): (WebCore::FontFeatureTagHash::equal): (WebCore::FontFeatureTagHashTraits::constructDeletedValue): (WebCore::FontFeatureTagHashTraits::isDeletedValue): (WebCore::FontFeature::tag): (WebCore::FontFeatureSettings::operator==): (WebCore::FontFeatureSettings::begin): (WebCore::FontFeatureSettings::end): (WebCore::FontFeatureSettings::FontFeatureSettings): Deleted. * platform/graphics/cocoa/FontCacheCoreText.cpp: Ditto. Also, when computing font features, consult with the state inside FontDescription. (WebCore::tagEquals): (WebCore::appendTrueTypeFeature): (WebCore::appendOpenTypeFeature): (WebCore::computeFeatureSettingsFromVariants): (WebCore::preparePlatformFont): (WebCore::platformFontLookupWithFamily): (WebCore::fontWithFamily): (WebCore::FontCache::createFontPlatformData): (WebCore::FontCache::systemFallbackForCharacters): * platform/graphics/harfbuzz/HarfBuzzShaper.cpp: Update to use references instead of pointers. (WebCore::HarfBuzzShaper::setFontFeatures): * platform/graphics/mac/FontCacheMac.mm: (WebCore::platformFontWithFamily): Ditto. * platform/graphics/mac/FontCustomPlatformData.cpp: (WebCore::FontCustomPlatformData::fontPlatformData): Be sensitive to new state inside FontDescription. * platform/text/TextFlags.h: (WebCore::FontVariantSettings::isAllNormal): New state enums. * rendering/RenderThemeIOS.mm: (WebCore::RenderThemeIOS::updateCachedSystemFontDescription): Be sensitive to new state inside FontDescription. * rendering/line/BreakingContext.h: Tools: Update test font to use "lnum" feature. * FontWithFeatures/FontWithFeatures/FontCreator.cpp: (Generator::appendGSUBTable): LayoutTests: Updating tests because font-variant-ligatures is being unprefixed. Also, update css3/resources/FontWithFeatures.otf to support "lnum" feature. * css3/font-feature-settings-rendering-2-expected.html: * css3/font-feature-settings-rendering-2.html: * css3/font-variant-all-webfont-expected.html: Added. * css3/font-variant-all-webfont.html: Added. * css3/font-variant-parsing-expected.txt: Added. * css3/font-variant-parsing.html: Added. * css3/resources/FontWithFeatures.otf: * fast/css/getComputedStyle/computed-style-expected.txt: * fast/css/getComputedStyle/computed-style-font-family-expected.txt: * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt: * fast/css/getComputedStyle/resources/property-names.js: * fast/css/parsing-font-variant-ligatures.html: * fast/text/font-variant-ligatures.html: * platform/mac/TestExpectations: * svg/css/getComputedStyle-basic-expected.txt: Canonical link: https://commits.webkit.org/167617@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-09-24 00:40:53 +00:00
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>