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

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

Issue 913313002: Use isComma more in CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Handle stroke-dasharray trailing comma Created 5 years, 10 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
« no previous file with comments | « LayoutTests/svg/custom/invalid-dasharray.svg ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp
index e70d834aea288bd5d0871a543bff547ab6db5068..40769d3b6b5f666ef4b72c90b94146d527b0e442 100644
--- a/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/Source/core/css/parser/CSSPropertyParser.cpp
@@ -335,12 +335,14 @@ inline PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::createCSSImageValueWi
static inline bool isComma(CSSParserValue* value)
{
- return value && value->unit == CSSParserValue::Operator && value->iValue == ',';
+ ASSERT(value);
+ return value->unit == CSSParserValue::Operator && value->iValue == ',';
}
static bool consumeComma(CSSParserValueList* valueList)
{
- if (!isComma(valueList->current()))
+ CSSParserValue* value = valueList->current();
+ if (!value || !isComma(value))
return false;
valueList->next();
return true;
@@ -1605,7 +1607,7 @@ bool CSSPropertyParser::parseFillShorthand(CSSPropertyID propId, const CSSProper
while (m_valueList->current()) {
CSSParserValue* val = m_valueList->current();
- if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
+ if (isComma(val)) {
// We hit the end. Fill in all remaining values with the initial value.
m_valueList->next();
for (i = 0; i < numProperties; ++i) {
@@ -2533,7 +2535,7 @@ void CSSPropertyParser::parseFillPosition(CSSParserValueList* valueList, RefPtrW
unsigned numberOfValues = 0;
for (unsigned i = valueList->currentIndex(); i < valueList->size(); ++i, ++numberOfValues) {
CSSParserValue* current = valueList->valueAt(i);
- if (isComma(current) || !current || isForwardSlashOperator(current) || !isPotentialPositionValue(current))
+ if (!current || isComma(current) || isForwardSlashOperator(current) || !isPotentialPositionValue(current))
break;
}
@@ -2607,7 +2609,7 @@ void CSSPropertyParser::parse2ValuesFillPosition(CSSParserValueList* valueList,
CSSParserValue* value = valueList->next();
// First check for the comma. If so, we are finished parsing this value or value pair.
- if (isComma(value))
+ if (value && isComma(value))
value = 0;
if (value) {
@@ -4611,8 +4613,7 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFamily()
while (value) {
CSSParserValue* nextValue = m_valueList->next();
- bool nextValBreaksFont = !nextValue ||
- (nextValue->unit == CSSParserValue::Operator && nextValue->iValue == ',');
+ bool nextValBreaksFont = !nextValue || isComma(nextValue);
bool nextValIsFontName = nextValue &&
((nextValue->id >= CSSValueSerif && nextValue->id <= CSSValueWebkitBody) ||
(nextValue->unit == CSSPrimitiveValue::CSS_STRING || nextValue->unit == CSSPrimitiveValue::CSS_IDENT));
@@ -8169,8 +8170,10 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSVGStrokeDasharray()
else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
ret->append(CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitType) value->unit));
value = m_valueList->next();
- if (value && value->unit == CSSParserValue::Operator && value->iValue == ',')
- value = m_valueList->next();
+ bool commaConsumed = consumeComma(m_valueList);
+ value = m_valueList->current();
+ if (commaConsumed && !value)
+ return nullptr;
}
if (!validPrimitive)
return nullptr;
@@ -8410,7 +8413,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTransformValue(CSSPrope
a = args->next();
if (!a)
break;
- if (a->unit != CSSParserValue::Operator || a->iValue != ',')
+ if (!isComma(a))
return nullptr;
a = args->next();
« no previous file with comments | « LayoutTests/svg/custom/invalid-dasharray.svg ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698