Chromium Code Reviews| Index: Source/core/css/parser/CSSPropertyParser.cpp | 
| diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp | 
| index a7170fdd2247855c091cedce0ce9daf81274f9ac..6ab509776d7bf74497792a6ade65f0074598fb66 100644 | 
| --- a/Source/core/css/parser/CSSPropertyParser.cpp | 
| +++ b/Source/core/css/parser/CSSPropertyParser.cpp | 
| @@ -1495,6 +1495,17 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import | 
| validPrimitive = false; | 
| break; | 
| + case CSSPropertyScrollSnapPointsX: | 
| + case CSSPropertyScrollSnapPointsY: | 
| + parsedValue = parseScrollSnapPoints(); | 
| + break; | 
| + case CSSPropertyScrollSnapCoordinate: | 
| + parsedValue = parseScrollSnapCoordinate(); | 
| + break; | 
| + case CSSPropertyScrollSnapDestination: | 
| + parsedValue = parseScrollSnapDestination(); | 
| + break; | 
| + | 
| default: | 
| return parseSVGValue(propId, important); | 
| } | 
| @@ -2008,6 +2019,75 @@ bool CSSPropertyParser::parse4Values(CSSPropertyID propId, const CSSPropertyID * | 
| return true; | 
| } | 
| +PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapPoints() | 
| +{ | 
| + CSSParserValue* value = m_valueList->current(); | 
| + | 
| + if (value->id == CSSValueNone) { | 
| + m_valueList->next(); | 
| + return cssValuePool().createIdentifierValue(CSSValueNone); | 
| + } | 
| + | 
| + if (value->unit == CSSParserValue::Function && value->function->id == CSSValueRepeat) { | 
| + // The spec defines the following grammar: repeat( <length>) | 
| + CSSParserValueList* arguments = value->function->args.get(); | 
| + if (!arguments || arguments->size() != 1) | 
| + return nullptr; | 
| + | 
| + CSSParserValue* repeatValue = arguments->valueAt(0); | 
| + if (!validUnit(repeatValue, FNonNeg | FLength | FPercent)) | 
| + return nullptr; | 
| + | 
| + RefPtrWillBeRawPtr<CSSFunctionValue> result = CSSFunctionValue::create(CSSValueRepeat); | 
| + result->append(createPrimitiveNumericValue(repeatValue)); | 
| + m_valueList->next(); | 
| + return result.release(); | 
| + } | 
| + | 
| + return nullptr; | 
| +} | 
| + | 
| +PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapDestination() | 
| +{ | 
| + return parseScrollSnapPosition(); | 
| +} | 
| + | 
| +PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapCoordinate() | 
| +{ | 
| + if (m_valueList->current()->id == CSSValueNone) { | 
| + m_valueList->next(); | 
| + return cssValuePool().createIdentifierValue(CSSValueNone); | 
| + } | 
| + | 
| + RefPtrWillBeRawPtr<CSSValueList> positions = CSSValueList::createSpaceSeparated(); | 
| + // TODO(majidvp): parse comma separated position lists correctly | 
| 
 
Timothy Loh
2015/05/28 07:09:26
Can we just do this properly in this patch? Should
 
majidvp
2015/06/01 20:06:37
Done. I added a parsePositionList which can be use
 
 | 
| + while (m_valueList->current()) { | 
| + // parseScrollSnapPosition advances the value list | 
| + RefPtrWillBeRawPtr<CSSValue> position = parseScrollSnapPosition(); | 
| + if (!position) | 
| + return nullptr; | 
| + | 
| + positions->append(position); | 
| + } | 
| + | 
| + if (positions->length()) { | 
| 
 
Timothy Loh
2015/05/28 07:09:27
Pretty sure this is unnecessary
 
majidvp
2015/06/01 20:06:37
Done.
 
 | 
| + return positions.release(); | 
| + } | 
| + return nullptr; | 
| +} | 
| + | 
| +PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseScrollSnapPosition() | 
| +{ | 
| + RefPtrWillBeRawPtr<CSSValue> xValue = nullptr; | 
| + RefPtrWillBeRawPtr<CSSValue> yValue = nullptr; | 
| + parseFillPosition(m_valueList, xValue, yValue); | 
| + if (!xValue || !yValue) | 
| + return nullptr; | 
| + | 
| + return createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrimitiveValue(yValue.get()), Pair::KeepIdenticalValues); | 
| +} | 
| + | 
| +// auto | <identifier> | 
| 
 
Timothy Loh
2015/05/28 07:09:27
I wouldn't bother with these sorts of comments (es
 
majidvp
2015/06/01 20:06:37
Done.
 
 | 
| PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parsePage() | 
| { | 
| CSSParserValue* value = m_valueList->current(); | 
| @@ -7155,6 +7235,7 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFilter() | 
| return list.release(); | 
| } | 
| + | 
| PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin() | 
| { | 
| CSSParserValue* value = m_valueList->current(); |