Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| index 8d4a1d8431d6d933f8e953af5627b2b2bc82b5ff..f5bda4bdfbc5f642daad397edc54bb8218563e6b 100644 |
| --- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| +++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
| @@ -14,6 +14,7 @@ |
| #include "core/css/CSSStringValue.h" |
| #include "core/css/CSSURIValue.h" |
| #include "core/css/CSSUnicodeRangeValue.h" |
| +#include "core/css/CSSValuePair.h" |
| #include "core/css/CSSValuePool.h" |
| #include "core/css/FontFace.h" |
| #include "core/css/parser/CSSParserFastPaths.h" |
| @@ -168,7 +169,7 @@ private: |
| RefPtrWillBeMember<CSSCalcValue> m_calcValue; |
| }; |
| -static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeInteger(CSSParserTokenRange& range, CSSParserMode cssParserMode, double minimumValue = std::numeric_limits<int>::min()) |
| +static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeInteger(CSSParserTokenRange& range, CSSParserMode cssParserMode, double minimumValue = std::numeric_limits<int>::lowest()) |
| { |
| const CSSParserToken& token = range.peek(); |
| if (token.type() == NumberToken) { |
| @@ -628,6 +629,26 @@ static PassRefPtrWillBeRawPtr<CSSValueList> consumeRotation(CSSParserTokenRange& |
| return list.release(); |
| } |
| +static PassRefPtrWillBeRawPtr<CSSValue> consumeCounter(CSSParserTokenRange& range, CSSParserMode cssParserMode, int defaultValue) |
| +{ |
| + if (range.peek().id() == CSSValueNone) |
| + return consumeIdent(range); |
| + |
| + RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
|
Timothy Loh
2015/10/08 23:13:56
TODO to create a space-separated value list here :
|
| + do { |
| + if (range.peek().type() != IdentToken) |
|
Timothy Loh
2015/10/08 23:13:56
btw I'd prefer this as follows
RefPtr..<CSSCustom
|
| + return nullptr; |
| + RefPtrWillBeRawPtr<CSSCustomIdentValue> counterName = consumeCustomIdent(range); |
| + int i = defaultValue; |
| + if (RefPtrWillBeRawPtr<CSSPrimitiveValue> counterValue = consumeInteger(range, cssParserMode, std::numeric_limits<double>::lowest())) |
|
Timothy Loh
2015/10/08 23:13:56
How about (don't need to pass in the limit if it's
rwlbuis
2015/10/09 02:31:12
Sorry, should have mentioned the s/min/lowest chan
|
| + i = clampTo<int>(counterValue->getDoubleValue()); |
| + list->append(CSSValuePair::create(counterName.release(), |
| + cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Number), |
| + CSSValuePair::DropIdenticalValues)); |
| + } while (!range.atEnd()); |
| + return list.release(); |
| +} |
| + |
| PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID propId) |
| { |
| m_range.consumeWhitespace(); |
| @@ -664,6 +685,9 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty |
| case CSSPropertyWebkitBorderHorizontalSpacing: |
| case CSSPropertyWebkitBorderVerticalSpacing: |
| return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative); |
| + case CSSPropertyCounterIncrement: |
| + case CSSPropertyCounterReset: |
| + return consumeCounter(m_range, m_context.mode(), propId == CSSPropertyCounterIncrement ? 1 : 0); |
| default: |
| return nullptr; |
| } |