Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp

Issue 1955723004: Implement font-variant-numeric (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: eae@'s review comments addressed Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
diff --git a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
index ef5a94faa76f2664b79b92fb27c25bd10a306b1d..bdc60df09a1e702aeaca8239bf3e9138458baaab 100644
--- a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
+++ b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
@@ -678,6 +678,28 @@ static CSSValue* valueForFontVariantLigatures(const ComputedStyle& style)
return valueList;
}
+static CSSValue* valueForFontVariantNumeric(const ComputedStyle& style)
+{
+ FontVariantNumeric variantNumeric = style.getFontDescription().variantNumeric();
+ if (variantNumeric.isAllNormal())
+ return cssValuePool().createIdentifierValue(CSSValueNormal);
+
+ CSSValueList* valueList = CSSValueList::createSpaceSeparated();
+ if (variantNumeric.numericFigureValue() != FontVariantNumeric::NormalFigure)
+ valueList->append(cssValuePool().createIdentifierValue(variantNumeric.numericFigureValue() == FontVariantNumeric::LiningNums ? CSSValueLiningNums : CSSValueOldstyleNums));
+ if (variantNumeric.numericSpacingValue() != FontVariantNumeric::NormalSpacing)
+ valueList->append(cssValuePool().createIdentifierValue(variantNumeric.numericSpacingValue() == FontVariantNumeric::ProportionalNums ? CSSValueProportionalNums : CSSValueTabularNums));
+ if (variantNumeric.numericFractionValue() != FontVariantNumeric::NormalFraction)
+ valueList->append(cssValuePool().createIdentifierValue(variantNumeric.numericFractionValue() == FontVariantNumeric::DiagonalFractions ? CSSValueDiagonalFractions : CSSValueStackedFractions));
+ if (variantNumeric.ordinalValue() == FontVariantNumeric::OrdinalOn)
+ valueList->append(cssValuePool().createIdentifierValue(CSSValueOrdinal));
+ if (variantNumeric.slashedZeroValue() == FontVariantNumeric::SlashedZeroOn)
+ valueList->append(cssValuePool().createIdentifierValue(CSSValueSlashedZero));
+
+ return valueList;
+}
+
+
static CSSValue* specifiedValueForGridTrackBreadth(const GridLength& trackBreadth, const ComputedStyle& style)
{
if (!trackBreadth.isLength())
@@ -1438,7 +1460,9 @@ CSSValue* ComputedStyleCSSValueMapping::valueForFont(const ComputedStyle& style)
// Check that non-initial font-variant subproperties are not conflicting with this serialization.
CSSValue* ligaturesValue = valueForFontVariantLigatures(style);
- if (!ligaturesValue->equals(*cssValuePool().createIdentifierValue(CSSValueNormal)))
+ CSSValue* numericValue = valueForFontVariantNumeric(style);
+ if (!ligaturesValue->equals(*cssValuePool().createIdentifierValue(CSSValueNormal))
+ || !numericValue->equals(*cssValuePool().createIdentifierValue(CSSValueNormal)))
return nullptr;
CSSPrimitiveValue* capsValue = valueForFontVariantCaps(style);
@@ -2261,6 +2285,8 @@ CSSValue* ComputedStyleCSSValueMapping::get(CSSPropertyID propertyID, const Comp
return valueForFontVariantLigatures(style);
case CSSPropertyFontVariantCaps:
return valueForFontVariantCaps(style);
+ case CSSPropertyFontVariantNumeric:
+ return valueForFontVariantNumeric(style);
case CSSPropertyZIndex:
if (style.hasAutoZIndex())
return cssValuePool().createIdentifierValue(CSSValueAuto);

Powered by Google App Engine
This is Rietveld 408576698