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/CSSPropertyCounterUtils.h" | |
6 | |
7 #include "core/css/CSSValueList.h" | |
8 #include "core/css/CSSValuePair.h" | |
9 #include "core/css/parser/CSSParserTokenRange.h" | |
10 #include "core/css/parser/CSSPropertyParserHelpers.h" | |
11 | |
12 namespace blink { | |
13 | |
14 CSSValue* CSSPropertyCounterUtils::consumeCounter( | |
15 CSSParserTokenRange& range, | |
16 CounterDefaultValue defaultValue) { | |
17 if (range.peek().id() == CSSValueNone) | |
18 return CSSPropertyParserHelpers::consumeIdent(range); | |
19 | |
20 CSSValueList* list = CSSValueList::createSpaceSeparated(); | |
21 do { | |
22 CSSCustomIdentValue* counterName = | |
23 CSSPropertyParserHelpers::consumeCustomIdent(range); | |
24 if (!counterName) | |
25 return nullptr; | |
26 int i = static_cast<int>(defaultValue); | |
shend
2017/03/28 01:58:48
Could we change 'i' to a more informative name e.g
| |
27 if (CSSPrimitiveValue* counterValue = | |
28 CSSPropertyParserHelpers::consumeInteger(range)) | |
29 i = clampTo<int>(counterValue->getDoubleValue()); | |
30 list->append(*CSSValuePair::create( | |
31 counterName, | |
32 CSSPrimitiveValue::create(i, CSSPrimitiveValue::UnitType::Integer), | |
33 CSSValuePair::DropIdenticalValues)); | |
34 } while (!range.atEnd()); | |
35 return list; | |
36 } | |
37 | |
38 } // namespace blink | |
OLD | NEW |