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(CSSParserTokenRange& range, |
| 15 int defaultValue) { |
| 16 if (range.peek().id() == CSSValueNone) |
| 17 return CSSPropertyParserHelpers::consumeIdent(range); |
| 18 |
| 19 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
| 20 do { |
| 21 CSSCustomIdentValue* counterName = |
| 22 CSSPropertyParserHelpers::consumeCustomIdent(range); |
| 23 if (!counterName) |
| 24 return nullptr; |
| 25 int value = defaultValue; |
| 26 if (CSSPrimitiveValue* counterValue = |
| 27 CSSPropertyParserHelpers::consumeInteger(range)) |
| 28 value = clampTo<int>(counterValue->getDoubleValue()); |
| 29 list->append(*CSSValuePair::create( |
| 30 counterName, |
| 31 CSSPrimitiveValue::create(value, CSSPrimitiveValue::UnitType::Integer), |
| 32 CSSValuePair::DropIdenticalValues)); |
| 33 } while (!range.atEnd()); |
| 34 return list; |
| 35 } |
| 36 |
| 37 } // namespace blink |
OLD | NEW |