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

Side by Side Diff: third_party/WebKit/Source/core/css/properties/CSSPropertyAPIFontVariationSettings.cpp

Issue 2613723003: Implements CSSPropertyAPI for the font-variation-settings property. (Closed)
Patch Set: dependencies Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/CSSPropertyAPIFontVariationSettings.h"
6
7 #include "core/css/CSSFontVariationValue.h"
8 #include "core/css/CSSValueList.h"
9 #include "core/css/parser/CSSParserContext.h"
10 #include "core/css/parser/CSSPropertyParserHelpers.h"
11 #include "platform/RuntimeEnabledFeatures.h"
12
13 namespace blink {
14
15 static CSSFontVariationValue* consumeFontVariationTag(
sashab 2017/01/09 05:15:21 Change static to anonymous namespace :)
16 CSSParserTokenRange& range) {
17 // Feature tag name consists of 4-letter characters.
18 static const unsigned tagNameLength = 4;
19
20 const CSSParserToken& token = range.consumeIncludingWhitespace();
21 // Feature tag name comes first
22 if (token.type() != StringToken)
23 return nullptr;
24 if (token.value().length() != tagNameLength)
25 return nullptr;
26 AtomicString tag = token.value().toAtomicString();
27 for (unsigned i = 0; i < tagNameLength; ++i) {
28 // Limits the range of characters to 0x20-0x7E, following the tag name rules
29 // defined in the OpenType specification.
30 UChar character = tag[i];
31 if (character < 0x20 || character > 0x7E)
32 return nullptr;
33 }
34
35 double tagValue = 0;
36 if (!CSSPropertyParserHelpers::consumeNumberRaw(range, tagValue))
37 return nullptr;
38 return CSSFontVariationValue::create(tag, clampTo<float>(tagValue));
39 }
40
41 const CSSValue* CSSPropertyAPIFontVariationSettings::parseSingleValue(
42 CSSParserTokenRange& range,
43 const CSSParserContext& context) {
44 DCHECK(RuntimeEnabledFeatures::cssVariableFontsEnabled());
45 if (range.peek().id() == CSSValueNormal)
46 return CSSPropertyParserHelpers::consumeIdent(range);
47 CSSValueList* variationSettings = CSSValueList::createCommaSeparated();
48 do {
49 CSSFontVariationValue* fontVariationValue = consumeFontVariationTag(range);
50 if (!fontVariationValue)
51 return nullptr;
52 variationSettings->append(*fontVariationValue);
53 } while (CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(range));
54 return variationSettings;
55 }
56
57 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698