summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrob.buis <rob.buis@samsung.com>2015-10-09 15:13:55 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-09 22:16:29 +0000
commitf4b4583bcc7ccb6b0191f5b4c72b94154a78bdd1 (patch)
tree8995939183594d76646ce37246423558ddeaf39c
parente678358ec6614eeacd3d862ebe2f4d235411e87e (diff)
downloadchromium_src-f4b4583bcc7ccb6b0191f5b4c72b94154a78bdd1.zip
chromium_src-f4b4583bcc7ccb6b0191f5b4c72b94154a78bdd1.tar.gz
chromium_src-f4b4583bcc7ccb6b0191f5b4c72b94154a78bdd1.tar.bz2
Move counter-increment/counter-reset handling into CSSPropertyParser
Move counter-increment/counter-reset handling from LegacyCSSPropertyParser into CSSPropertyParser. BUG=499780 Review URL: https://codereview.chromium.org/1398553002 Cr-Commit-Position: refs/heads/master@{#353400}
-rw-r--r--third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp27
-rw-r--r--third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h1
-rw-r--r--third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp43
3 files changed, 28 insertions, 43 deletions
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
index aaec7b8..40ef3b8 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;
}
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h
index 7a1ab9e..eea06fb 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.h
@@ -200,7 +200,6 @@ private:
bool consumeBorderSpacing(bool important);
- PassRefPtrWillBeRawPtr<CSSValue> parseCounter(int defaultValue);
PassRefPtrWillBeRawPtr<CSSValue> parseCounterContent(CSSParserValueList* args, bool counters);
bool parseColorParameters(const CSSParserValue*, int* colorValues, bool parseAlpha);
diff --git a/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
index 6c21acf..ed0bab9 100644
--- a/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
@@ -750,19 +750,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
}
break;
- case CSSPropertyCounterIncrement:
- if (id == CSSValueNone)
- validPrimitive = true;
- else
- parsedValue = parseCounter(1);
- break;
- case CSSPropertyCounterReset:
- if (id == CSSValueNone)
- validPrimitive = true;
- else
- parsedValue = parseCounter(0);
- break;
-
case CSSPropertyTextDecoration:
// Fall through 'text-decoration-line' parsing if CSS 3 Text Decoration
// is disabled to match CSS 2.1 rules for parsing 'text-decoration'.
@@ -1368,6 +1355,8 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
case CSSPropertyWebkitBorderHorizontalSpacing:
case CSSPropertyWebkitBorderVerticalSpacing:
case CSSPropertyBorderSpacing:
+ case CSSPropertyCounterIncrement:
+ case CSSPropertyCounterReset:
validPrimitive = false;
break;
@@ -5288,34 +5277,6 @@ bool CSSPropertyParser::parseBorderRadius(CSSPropertyID unresolvedProperty, bool
return true;
}
-PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValue)
-{
- RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
-
- while (m_valueList->current()) {
- CSSParserValue* val = m_valueList->current();
- if (val->m_unit != CSSParserValue::Identifier)
- return nullptr;
- RefPtrWillBeRawPtr<CSSCustomIdentValue> counterName = createPrimitiveCustomIdentValue(val);
- m_valueList->next();
-
- val = m_valueList->current();
- int i = defaultValue;
- if (val && validUnit(val, FInteger)) {
- i = clampTo<int>(val->fValue);
- m_valueList->next();
- }
-
- list->append(CSSValuePair::create(counterName.release(),
- cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Number),
- CSSValuePair::DropIdenticalValues));
- }
-
- if (!list->length())
- return nullptr;
- return list.release();
-}
-
// This should go away once we drop support for -webkit-gradient
static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CSSParserValue* a, bool horizontal)
{