Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/css/properties/CSSShorthandPropertyAPIFontVariant.h" | |
| 6 | |
| 7 #include "core/css/CSSIdentifierValue.h" | |
| 8 #include "core/css/parser/CSSPropertyParserHelpers.h" | |
| 9 #include "core/css/parser/FontVariantLigaturesParser.h" | |
| 10 #include "core/css/parser/FontVariantNumericParser.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 class CSSParserContext; | |
|
Bugs Nash
2017/06/16 03:51:51
as above, these class declarations are guaranteed
Jia
2017/06/19 03:54:41
Done.
| |
| 15 class CSSParserLocalContext; | |
| 16 | |
| 17 bool CSSShorthandPropertyAPIFontVariant::parseShorthand( | |
| 18 bool important, | |
| 19 CSSParserTokenRange& range, | |
| 20 const CSSParserContext*, | |
| 21 const CSSParserLocalContext&, | |
| 22 HeapVector<CSSProperty, 256>& properties) { | |
| 23 if (CSSPropertyParserHelpers::IdentMatches<CSSValueNormal, CSSValueNone>( | |
| 24 range.Peek().Id())) { | |
| 25 CSSPropertyParserHelpers::AddProperty( | |
| 26 CSSPropertyFontVariantLigatures, CSSPropertyFontVariant, | |
| 27 *CSSPropertyParserHelpers::ConsumeIdent(range), important, | |
| 28 false /* implicit */, properties); | |
| 29 CSSPropertyParserHelpers::AddProperty( | |
| 30 CSSPropertyFontVariantCaps, CSSPropertyFontVariant, | |
| 31 *CSSIdentifierValue::Create(CSSValueNormal), important, | |
| 32 false /* implicit */, properties); | |
| 33 return range.AtEnd(); | |
| 34 } | |
| 35 | |
| 36 CSSIdentifierValue* caps_value = nullptr; | |
| 37 FontVariantLigaturesParser ligatures_parser; | |
| 38 FontVariantNumericParser numeric_parser; | |
| 39 do { | |
| 40 FontVariantLigaturesParser::ParseResult ligatures_parse_result = | |
| 41 ligatures_parser.ConsumeLigature(range); | |
| 42 FontVariantNumericParser::ParseResult numeric_parse_result = | |
| 43 numeric_parser.ConsumeNumeric(range); | |
| 44 if (ligatures_parse_result == | |
| 45 FontVariantLigaturesParser::ParseResult::kConsumedValue || | |
| 46 numeric_parse_result == | |
| 47 FontVariantNumericParser::ParseResult::kConsumedValue) | |
| 48 continue; | |
| 49 | |
| 50 if (ligatures_parse_result == | |
| 51 FontVariantLigaturesParser::ParseResult::kDisallowedValue || | |
| 52 numeric_parse_result == | |
| 53 FontVariantNumericParser::ParseResult::kDisallowedValue) | |
| 54 return false; | |
| 55 | |
| 56 CSSValueID id = range.Peek().Id(); | |
| 57 switch (id) { | |
| 58 case CSSValueSmallCaps: | |
| 59 case CSSValueAllSmallCaps: | |
| 60 case CSSValuePetiteCaps: | |
| 61 case CSSValueAllPetiteCaps: | |
| 62 case CSSValueUnicase: | |
| 63 case CSSValueTitlingCaps: | |
| 64 // Only one caps value permitted in font-variant grammar. | |
| 65 if (caps_value) | |
| 66 return false; | |
| 67 caps_value = CSSPropertyParserHelpers::ConsumeIdent(range); | |
| 68 break; | |
| 69 default: | |
| 70 return false; | |
| 71 } | |
| 72 } while (!range.AtEnd()); | |
| 73 | |
| 74 CSSPropertyParserHelpers::AddProperty( | |
| 75 CSSPropertyFontVariantLigatures, CSSPropertyFontVariant, | |
| 76 *ligatures_parser.FinalizeValue(), important, false /* implicit */, | |
| 77 properties); | |
| 78 CSSPropertyParserHelpers::AddProperty( | |
| 79 CSSPropertyFontVariantNumeric, CSSPropertyFontVariant, | |
| 80 *numeric_parser.FinalizeValue(), important, false /* implicit */, | |
| 81 properties); | |
| 82 CSSPropertyParserHelpers::AddProperty( | |
| 83 CSSPropertyFontVariantCaps, CSSPropertyFontVariant, | |
| 84 caps_value ? *caps_value : *CSSIdentifierValue::Create(CSSValueNormal), | |
| 85 important, false /* implicit */, properties); | |
| 86 return true; | |
| 87 } | |
| 88 } // namespace blink | |
| OLD | NEW |