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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
7 * Copyright (C) 2015 Google Inc. All rights reserved. 7 * Copyright (C) 2015 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public 10 * modify it under the terms of the GNU Lesser General Public
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 valueList->append(cssValuePool().createIdentifierValue(commonLigaturesSt ate == FontDescription::DisabledLigaturesState ? CSSValueNoCommonLigatures : CSS ValueCommonLigatures)); 671 valueList->append(cssValuePool().createIdentifierValue(commonLigaturesSt ate == FontDescription::DisabledLigaturesState ? CSSValueNoCommonLigatures : CSS ValueCommonLigatures));
672 if (discretionaryLigaturesState != FontDescription::NormalLigaturesState) 672 if (discretionaryLigaturesState != FontDescription::NormalLigaturesState)
673 valueList->append(cssValuePool().createIdentifierValue(discretionaryLiga turesState == FontDescription::DisabledLigaturesState ? CSSValueNoDiscretionaryL igatures : CSSValueDiscretionaryLigatures)); 673 valueList->append(cssValuePool().createIdentifierValue(discretionaryLiga turesState == FontDescription::DisabledLigaturesState ? CSSValueNoDiscretionaryL igatures : CSSValueDiscretionaryLigatures));
674 if (historicalLigaturesState != FontDescription::NormalLigaturesState) 674 if (historicalLigaturesState != FontDescription::NormalLigaturesState)
675 valueList->append(cssValuePool().createIdentifierValue(historicalLigatur esState == FontDescription::DisabledLigaturesState ? CSSValueNoHistoricalLigatur es : CSSValueHistoricalLigatures)); 675 valueList->append(cssValuePool().createIdentifierValue(historicalLigatur esState == FontDescription::DisabledLigaturesState ? CSSValueNoHistoricalLigatur es : CSSValueHistoricalLigatures));
676 if (contextualLigaturesState != FontDescription::NormalLigaturesState) 676 if (contextualLigaturesState != FontDescription::NormalLigaturesState)
677 valueList->append(cssValuePool().createIdentifierValue(contextualLigatur esState == FontDescription::DisabledLigaturesState ? CSSValueNoContextual : CSSV alueContextual)); 677 valueList->append(cssValuePool().createIdentifierValue(contextualLigatur esState == FontDescription::DisabledLigaturesState ? CSSValueNoContextual : CSSV alueContextual));
678 return valueList; 678 return valueList;
679 } 679 }
680 680
681 static CSSValue* valueForFontVariantNumeric(const ComputedStyle& style)
682 {
683 FontVariantNumeric variantNumeric = style.getFontDescription().variantNumeri c();
684 if (variantNumeric.isAllNormal())
685 return cssValuePool().createIdentifierValue(CSSValueNormal);
686
687 CSSValueList* valueList = CSSValueList::createSpaceSeparated();
688 if (variantNumeric.numericFigureValue() != FontVariantNumeric::NormalFigure)
689 valueList->append(cssValuePool().createIdentifierValue(variantNumeric.nu mericFigureValue() == FontVariantNumeric::LiningNums ? CSSValueLiningNums : CSSV alueOldstyleNums));
690 if (variantNumeric.numericSpacingValue() != FontVariantNumeric::NormalSpacin g)
691 valueList->append(cssValuePool().createIdentifierValue(variantNumeric.nu mericSpacingValue() == FontVariantNumeric::ProportionalNums ? CSSValueProportion alNums : CSSValueTabularNums));
692 if (variantNumeric.numericFractionValue() != FontVariantNumeric::NormalFract ion)
693 valueList->append(cssValuePool().createIdentifierValue(variantNumeric.nu mericFractionValue() == FontVariantNumeric::DiagonalFractions ? CSSValueDiagonal Fractions : CSSValueStackedFractions));
694 if (variantNumeric.ordinalValue() == FontVariantNumeric::OrdinalOn)
695 valueList->append(cssValuePool().createIdentifierValue(CSSValueOrdinal)) ;
696 if (variantNumeric.slashedZeroValue() == FontVariantNumeric::SlashedZeroOn)
697 valueList->append(cssValuePool().createIdentifierValue(CSSValueSlashedZe ro));
698
699 return valueList;
700 }
701
702
681 static CSSValue* specifiedValueForGridTrackBreadth(const GridLength& trackBreadt h, const ComputedStyle& style) 703 static CSSValue* specifiedValueForGridTrackBreadth(const GridLength& trackBreadt h, const ComputedStyle& style)
682 { 704 {
683 if (!trackBreadth.isLength()) 705 if (!trackBreadth.isLength())
684 return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue ::UnitType::Fraction); 706 return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue ::UnitType::Fraction);
685 707
686 const Length& trackBreadthLength = trackBreadth.length(); 708 const Length& trackBreadthLength = trackBreadth.length();
687 if (trackBreadthLength.isAuto()) 709 if (trackBreadthLength.isAuto())
688 return cssValuePool().createIdentifierValue(CSSValueAuto); 710 return cssValuePool().createIdentifierValue(CSSValueAuto);
689 return zoomAdjustedPixelValueForLength(trackBreadthLength, style); 711 return zoomAdjustedPixelValueForLength(trackBreadthLength, style);
690 } 712 }
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 // Add a slash between size and line-height. 1453 // Add a slash between size and line-height.
1432 CSSValueList* sizeAndLineHeight = CSSValueList::createSlashSeparated(); 1454 CSSValueList* sizeAndLineHeight = CSSValueList::createSlashSeparated();
1433 sizeAndLineHeight->append(valueForFontSize(style)); 1455 sizeAndLineHeight->append(valueForFontSize(style));
1434 sizeAndLineHeight->append(valueForLineHeight(style)); 1456 sizeAndLineHeight->append(valueForLineHeight(style));
1435 1457
1436 CSSValueList* list = CSSValueList::createSpaceSeparated(); 1458 CSSValueList* list = CSSValueList::createSpaceSeparated();
1437 list->append(valueForFontStyle(style)); 1459 list->append(valueForFontStyle(style));
1438 1460
1439 // Check that non-initial font-variant subproperties are not conflicting wit h this serialization. 1461 // Check that non-initial font-variant subproperties are not conflicting wit h this serialization.
1440 CSSValue* ligaturesValue = valueForFontVariantLigatures(style); 1462 CSSValue* ligaturesValue = valueForFontVariantLigatures(style);
1441 if (!ligaturesValue->equals(*cssValuePool().createIdentifierValue(CSSValueNo rmal))) 1463 CSSValue* numericValue = valueForFontVariantNumeric(style);
1464 if (!ligaturesValue->equals(*cssValuePool().createIdentifierValue(CSSValueNo rmal))
1465 || !numericValue->equals(*cssValuePool().createIdentifierValue(CSSValueN ormal)))
1442 return nullptr; 1466 return nullptr;
1443 1467
1444 CSSPrimitiveValue* capsValue = valueForFontVariantCaps(style); 1468 CSSPrimitiveValue* capsValue = valueForFontVariantCaps(style);
1445 if (!capsValue->equals(*cssValuePool().createIdentifierValue(CSSValueNormal) ) 1469 if (!capsValue->equals(*cssValuePool().createIdentifierValue(CSSValueNormal) )
1446 && !capsValue->equals(*cssValuePool().createIdentifierValue(CSSValueSmal lCaps))) 1470 && !capsValue->equals(*cssValuePool().createIdentifierValue(CSSValueSmal lCaps)))
1447 return nullptr; 1471 return nullptr;
1448 list->append(capsValue); 1472 list->append(capsValue);
1449 1473
1450 list->append(valueForFontWeight(style)); 1474 list->append(valueForFontWeight(style));
1451 list->append(valueForFontStretch(style)); 1475 list->append(valueForFontStretch(style));
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 case CSSPropertyResize: 2278 case CSSPropertyResize:
2255 return cssValuePool().createValue(style.resize()); 2279 return cssValuePool().createValue(style.resize());
2256 case CSSPropertyFontKerning: 2280 case CSSPropertyFontKerning:
2257 return cssValuePool().createValue(style.getFontDescription().getKerning( )); 2281 return cssValuePool().createValue(style.getFontDescription().getKerning( ));
2258 case CSSPropertyWebkitFontSmoothing: 2282 case CSSPropertyWebkitFontSmoothing:
2259 return cssValuePool().createValue(style.getFontDescription().fontSmoothi ng()); 2283 return cssValuePool().createValue(style.getFontDescription().fontSmoothi ng());
2260 case CSSPropertyFontVariantLigatures: 2284 case CSSPropertyFontVariantLigatures:
2261 return valueForFontVariantLigatures(style); 2285 return valueForFontVariantLigatures(style);
2262 case CSSPropertyFontVariantCaps: 2286 case CSSPropertyFontVariantCaps:
2263 return valueForFontVariantCaps(style); 2287 return valueForFontVariantCaps(style);
2288 case CSSPropertyFontVariantNumeric:
2289 return valueForFontVariantNumeric(style);
2264 case CSSPropertyZIndex: 2290 case CSSPropertyZIndex:
2265 if (style.hasAutoZIndex()) 2291 if (style.hasAutoZIndex())
2266 return cssValuePool().createIdentifierValue(CSSValueAuto); 2292 return cssValuePool().createIdentifierValue(CSSValueAuto);
2267 return cssValuePool().createValue(style.zIndex(), CSSPrimitiveValue::Uni tType::Integer); 2293 return cssValuePool().createValue(style.zIndex(), CSSPrimitiveValue::Uni tType::Integer);
2268 case CSSPropertyZoom: 2294 case CSSPropertyZoom:
2269 return cssValuePool().createValue(style.zoom(), CSSPrimitiveValue::UnitT ype::Number); 2295 return cssValuePool().createValue(style.zoom(), CSSPrimitiveValue::UnitT ype::Number);
2270 case CSSPropertyBoxSizing: 2296 case CSSPropertyBoxSizing:
2271 if (style.boxSizing() == BoxSizingContentBox) 2297 if (style.boxSizing() == BoxSizingContentBox)
2272 return cssValuePool().createIdentifierValue(CSSValueContentBox); 2298 return cssValuePool().createIdentifierValue(CSSValueContentBox);
2273 return cssValuePool().createIdentifierValue(CSSValueBorderBox); 2299 return cssValuePool().createIdentifierValue(CSSValueBorderBox);
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
2910 case CSSPropertyAll: 2936 case CSSPropertyAll:
2911 return nullptr; 2937 return nullptr;
2912 default: 2938 default:
2913 break; 2939 break;
2914 } 2940 }
2915 ASSERT_NOT_REACHED(); 2941 ASSERT_NOT_REACHED();
2916 return nullptr; 2942 return nullptr;
2917 } 2943 }
2918 2944
2919 } // namespace blink 2945 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698