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 a3a7a792ef2a36e75b92d9eea80146b68c8e4390..a5685def2b53dbab2dfc2167b982c25260b7a4dd 100644 |
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
@@ -43,6 +43,7 @@ |
#include "core/css/parser/FontVariantLigaturesParser.h" |
#include "core/css/properties/CSSPropertyAlignmentUtils.h" |
#include "core/css/properties/CSSPropertyDescriptor.h" |
+#include "core/css/properties/CSSPropertyPositionUtils.h" |
#include "core/frame/UseCounter.h" |
#include "core/layout/LayoutTheme.h" |
#include "core/svg/SVGPathUtilities.h" |
@@ -1391,39 +1392,6 @@ static CSSValue* consumeTransform(CSSParserTokenRange& range, |
return list; |
} |
-template <CSSValueID start, CSSValueID end> |
-static CSSValue* consumePositionLonghand(CSSParserTokenRange& range, |
- CSSParserMode cssParserMode) { |
- if (range.peek().type() == IdentToken) { |
- CSSValueID id = range.peek().id(); |
- int percent; |
- if (id == start) |
- percent = 0; |
- else if (id == CSSValueCenter) |
- percent = 50; |
- else if (id == end) |
- percent = 100; |
- else |
- return nullptr; |
- range.consumeIncludingWhitespace(); |
- return CSSPrimitiveValue::create(percent, |
- CSSPrimitiveValue::UnitType::Percentage); |
- } |
- return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll); |
-} |
- |
-static CSSValue* consumePositionX(CSSParserTokenRange& range, |
- CSSParserMode cssParserMode) { |
- return consumePositionLonghand<CSSValueLeft, CSSValueRight>(range, |
- cssParserMode); |
-} |
- |
-static CSSValue* consumePositionY(CSSParserTokenRange& range, |
- CSSParserMode cssParserMode) { |
- return consumePositionLonghand<CSSValueTop, CSSValueBottom>(range, |
- cssParserMode); |
-} |
- |
static CSSValue* consumeNoneOrURI(CSSParserTokenRange& range, |
const CSSParserContext* context) { |
if (range.peek().id() == CSSValueNone) |
@@ -2051,10 +2019,14 @@ static CSSValue* consumeBackgroundComponent(CSSPropertyID unresolvedProperty, |
return consumeImageOrNone(range, context); |
case CSSPropertyBackgroundPositionX: |
case CSSPropertyWebkitMaskPositionX: |
- return consumePositionX(range, context->mode()); |
+ return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueLeft, |
+ CSSValueRight>( |
+ range, context->mode()); |
case CSSPropertyBackgroundPositionY: |
case CSSPropertyWebkitMaskPositionY: |
- return consumePositionY(range, context->mode()); |
+ return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueTop, |
+ CSSValueBottom>( |
+ range, context->mode()); |
case CSSPropertyBackgroundSize: |
case CSSPropertyAliasWebkitBackgroundSize: |
case CSSPropertyWebkitMaskSize: |
@@ -2792,10 +2764,14 @@ const CSSValue* CSSPropertyParser::parseSingleValue( |
unresolvedProperty == CSSPropertyAliasWebkitTransform); |
case CSSPropertyWebkitTransformOriginX: |
case CSSPropertyWebkitPerspectiveOriginX: |
- return consumePositionX(m_range, m_context->mode()); |
+ return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueLeft, |
+ CSSValueRight>( |
+ m_range, m_context->mode()); |
case CSSPropertyWebkitTransformOriginY: |
case CSSPropertyWebkitPerspectiveOriginY: |
- return consumePositionY(m_range, m_context->mode()); |
+ return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueTop, |
+ CSSValueBottom>( |
+ m_range, m_context->mode()); |
case CSSPropertyMarkerStart: |
case CSSPropertyMarkerMid: |
case CSSPropertyMarkerEnd: |