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

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: Remove whitespace and clarified TODOs 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.numericFigure() != FontVariantNumeric::NormalFigure)
689 valueList->append(cssValuePool().createIdentifierValue(variantNumeric.nu mericFigure() == FontVariantNumeric::LiningNums ? CSSValueLiningNums : CSSValueO ldstyleNums));
690 if (variantNumeric.numericSpacing() != FontVariantNumeric::NormalSpacing)
691 valueList->append(cssValuePool().createIdentifierValue(variantNumeric.nu mericSpacing() == FontVariantNumeric::ProportionalNums ? CSSValueProportionalNum s : CSSValueTabularNums));
692 if (variantNumeric.numericFraction() != FontVariantNumeric::NormalFraction)
693 valueList->append(cssValuePool().createIdentifierValue(variantNumeric.nu mericFraction() == FontVariantNumeric::DiagonalFractions ? CSSValueDiagonalFract ions : CSSValueStackedFractions));
694 if (variantNumeric.ordinal() == FontVariantNumeric::OrdinalOn)
695 valueList->append(cssValuePool().createIdentifierValue(CSSValueOrdinal)) ;
696 if (variantNumeric.slashedZero() == 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 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 case CSSPropertyResize: 2279 case CSSPropertyResize:
2256 return cssValuePool().createValue(style.resize()); 2280 return cssValuePool().createValue(style.resize());
2257 case CSSPropertyFontKerning: 2281 case CSSPropertyFontKerning:
2258 return cssValuePool().createValue(style.getFontDescription().getKerning( )); 2282 return cssValuePool().createValue(style.getFontDescription().getKerning( ));
2259 case CSSPropertyWebkitFontSmoothing: 2283 case CSSPropertyWebkitFontSmoothing:
2260 return cssValuePool().createValue(style.getFontDescription().fontSmoothi ng()); 2284 return cssValuePool().createValue(style.getFontDescription().fontSmoothi ng());
2261 case CSSPropertyFontVariantLigatures: 2285 case CSSPropertyFontVariantLigatures:
2262 return valueForFontVariantLigatures(style); 2286 return valueForFontVariantLigatures(style);
2263 case CSSPropertyFontVariantCaps: 2287 case CSSPropertyFontVariantCaps:
2264 return valueForFontVariantCaps(style); 2288 return valueForFontVariantCaps(style);
2289 case CSSPropertyFontVariantNumeric:
2290 return valueForFontVariantNumeric(style);
2265 case CSSPropertyZIndex: 2291 case CSSPropertyZIndex:
2266 if (style.hasAutoZIndex()) 2292 if (style.hasAutoZIndex())
2267 return cssValuePool().createIdentifierValue(CSSValueAuto); 2293 return cssValuePool().createIdentifierValue(CSSValueAuto);
2268 return cssValuePool().createValue(style.zIndex(), CSSPrimitiveValue::Uni tType::Integer); 2294 return cssValuePool().createValue(style.zIndex(), CSSPrimitiveValue::Uni tType::Integer);
2269 case CSSPropertyZoom: 2295 case CSSPropertyZoom:
2270 return cssValuePool().createValue(style.zoom(), CSSPrimitiveValue::UnitT ype::Number); 2296 return cssValuePool().createValue(style.zoom(), CSSPrimitiveValue::UnitT ype::Number);
2271 case CSSPropertyBoxSizing: 2297 case CSSPropertyBoxSizing:
2272 if (style.boxSizing() == BoxSizingContentBox) 2298 if (style.boxSizing() == BoxSizingContentBox)
2273 return cssValuePool().createIdentifierValue(CSSValueContentBox); 2299 return cssValuePool().createIdentifierValue(CSSValueContentBox);
2274 return cssValuePool().createIdentifierValue(CSSValueBorderBox); 2300 return cssValuePool().createIdentifierValue(CSSValueBorderBox);
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
2911 case CSSPropertyAll: 2937 case CSSPropertyAll:
2912 return nullptr; 2938 return nullptr;
2913 default: 2939 default:
2914 break; 2940 break;
2915 } 2941 }
2916 ASSERT_NOT_REACHED(); 2942 ASSERT_NOT_REACHED();
2917 return nullptr; 2943 return nullptr;
2918 } 2944 }
2919 2945
2920 } // namespace blink 2946 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698