Chromium Code Reviews| Index: Source/core/css/resolver/StyleBuilderConverter.cpp | 
| diff --git a/Source/core/css/resolver/StyleBuilderConverter.cpp b/Source/core/css/resolver/StyleBuilderConverter.cpp | 
| index 75b3a6c10977c0ee2f40c4b100cec5a181b02f35..bbf6b7f57fc376fd85ee333ac4f25dbf936ce633 100644 | 
| --- a/Source/core/css/resolver/StyleBuilderConverter.cpp | 
| +++ b/Source/core/css/resolver/StyleBuilderConverter.cpp | 
| @@ -59,6 +59,31 @@ static GridLength convertGridTrackBreadth(const StyleResolverState& state, CSSPr | 
| return StyleBuilderConverter::convertLengthOrAuto(state, primitiveValue); | 
| } | 
| +template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> | 
| +static Length convertPositionLength(StyleResolverState& state, CSSPrimitiveValue* primitiveValue) | 
| +{ | 
| + if (Pair* pair = primitiveValue->getPairValue()) { | 
| + Length length = StyleBuilderConverter::convertLength(state, pair->second()); | 
| + if (pair->first()->getValueID() == cssValueFor0) | 
| + return length; | 
| + ASSERT(pair->first()->getValueID() == cssValueFor100); | 
| + return length.subtractFromOneHundredPercent(); | 
| + } | 
| + | 
| + return StyleBuilderConverter::convertLength(state, primitiveValue); | 
| +} | 
| + | 
| +static LengthSize convertSnapCoordinatePair(StyleResolverState& state, CSSValue* value) | 
| 
 
Timothy Loh
2015/05/28 07:09:27
I don't think anyone on Blink feels strongly about
 
majidvp
2015/06/01 20:06:37
Used convertPosition for both.
 
 | 
| +{ | 
| + CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 
| + Pair* pair = primitiveValue->getPairValue(); | 
| + return LengthSize( | 
| + convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair->first()), | 
| + convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair->second()) | 
| + ); | 
| +} | 
| + | 
| + | 
| } // namespace | 
| PassRefPtr<StyleReflection> StyleBuilderConverter::convertBoxReflect(StyleResolverState& state, CSSValue* value) | 
| @@ -635,20 +660,6 @@ float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state | 
| return primitiveValue->getFloatValue() / 100.0f; | 
| } | 
| -template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> | 
| -static Length convertPositionLength(StyleResolverState& state, CSSPrimitiveValue* primitiveValue) | 
| -{ | 
| - if (Pair* pair = primitiveValue->getPairValue()) { | 
| - Length length = StyleBuilderConverter::convertLength(state, pair->second()); | 
| - if (pair->first()->getValueID() == cssValueFor0) | 
| - return length; | 
| - ASSERT(pair->first()->getValueID() == cssValueFor100); | 
| - return length.subtractFromOneHundredPercent(); | 
| - } | 
| - | 
| - return StyleBuilderConverter::convertLength(state, primitiveValue); | 
| -} | 
| - | 
| LengthPoint StyleBuilderConverter::convertObjectPosition(StyleResolverState& state, CSSValue* value) | 
| { | 
| CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 
| @@ -901,4 +912,46 @@ TransformOrigin StyleBuilderConverter::convertTransformOrigin(StyleResolverState | 
| ); | 
| } | 
| +ScrollSnapPoints StyleBuilderConverter::convertSnapPoints(StyleResolverState& state, CSSValue* value) | 
| +{ | 
| + // Handles: none | repeat(<length>) | 
| + ScrollSnapPoints points; | 
| + points.hasRepeat = false; | 
| + | 
| + if (!value->isFunctionValue()) { | 
| + return points; | 
| + } | 
| 
 
Timothy Loh
2015/05/28 07:09:27
Nit: No need for braces on single-line ifs
 
majidvp
2015/06/01 20:06:37
Done.
 
 | 
| + | 
| + if (CSSFunctionValue* repeatFunction = toCSSFunctionValue(value)) { | 
| 
 
Timothy Loh
2015/05/28 07:09:27
I don't think the condition is ever false here?
 
majidvp
2015/06/01 20:06:37
Done.
 
 | 
| + ASSERT_WITH_SECURITY_IMPLICATION(repeatFunction->length() == 1); | 
| + points.repeatOffset = convertLength(state, toCSSPrimitiveValue(repeatFunction->item(0))); | 
| + points.hasRepeat = true; | 
| + } | 
| + | 
| + return points; | 
| +} | 
| + | 
| +Vector<LengthSize> StyleBuilderConverter::convertSnapCoordinates(StyleResolverState& state, CSSValue* value) | 
| +{ | 
| + // Handles: none | <position># | 
| + Vector<LengthSize> coordinates; | 
| + | 
| + if (!value->isValueList()) | 
| + return coordinates; | 
| + | 
| + CSSValueList* valueList = toCSSValueList(value); | 
| + coordinates.reserveInitialCapacity(valueList->length()); | 
| + for (auto& snapCoordinate : *valueList) { | 
| + coordinates.uncheckedAppend(convertSnapCoordinatePair(state, snapCoordinate.get())); | 
| + } | 
| + | 
| + return coordinates; | 
| +} | 
| + | 
| +LengthSize StyleBuilderConverter::convertSnapDestination(StyleResolverState& state, CSSValue* value) | 
| +{ | 
| + return convertSnapCoordinatePair(state, value); | 
| +} | 
| + | 
| + | 
| } // namespace blink |