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

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp

Issue 1398553002: Move counter-increment/counter-reset handling into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work around ::lowest problem Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
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 aaec7b836d0bf41a224eb9fc49b96912aba03c01..40ef3b88d61ac53915a02cbddf325afe72601d35 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<double>::max())
{
const CSSParserToken& token = range.peek();
if (token.type() == NumberToken) {
@@ -641,6 +642,27 @@ 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);
+
+ // TODO(rwlbuis): should be space separated list.
+ RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
+ do {
+ RefPtrWillBeRawPtr<CSSCustomIdentValue> counterName = consumeCustomIdent(range);
+ if (!counterName)
+ return nullptr;
+ int i = defaultValue;
+ if (RefPtrWillBeRawPtr<CSSPrimitiveValue> counterValue = consumeInteger(range, cssParserMode))
+ 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();
@@ -677,6 +699,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;
}

Powered by Google App Engine
This is Rietveld 408576698