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 171269f4704087fde1e30b4b2bd7421fe71b7abd..32eedcbad1f186b8017d9128f3d02da49f956ae1 100644 |
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
@@ -11,6 +11,7 @@ |
#include "core/css/CSSFontFaceSrcValue.h" |
#include "core/css/CSSFontFeatureValue.h" |
#include "core/css/CSSFunctionValue.h" |
+#include "core/css/CSSPathValue.h" |
#include "core/css/CSSPrimitiveValueMappings.h" |
#include "core/css/CSSQuadValue.h" |
#include "core/css/CSSSVGDocumentValue.h" |
@@ -26,6 +27,7 @@ |
#include "core/css/parser/CSSParserValues.h" |
#include "core/frame/UseCounter.h" |
#include "core/layout/LayoutTheme.h" |
+#include "core/svg/SVGPathUtilities.h" |
#include "wtf/text/StringBuilder.h" |
namespace blink { |
@@ -1422,7 +1424,7 @@ static PassRefPtrWillBeRawPtr<CSSValue> consumeShadow(CSSParserTokenRange& range |
return shadowValueList; |
} |
-static PassRefPtrWillBeRawPtr<CSSFunctionValue> consumeFilterFunction(CSSParserTokenRange& range, const CSSParserContext& context) |
+static PassRefPtrWillBeRawPtr<CSSFunctionValue> consumeFilterFunction(CSSParserTokenRange& range, const CSSParserContext& context) |
{ |
CSSValueID filterType = range.peek().functionId(); |
if (filterType < CSSValueInvert || filterType > CSSValueDropShadow) |
@@ -1464,7 +1466,7 @@ static PassRefPtrWillBeRawPtr<CSSFunctionValue> consumeFilterFunction(CSSParserT |
return filterValue.release(); |
} |
-static PassRefPtrWillBeRawPtr<CSSValue> consumeFilter(CSSParserTokenRange& range, const CSSParserContext& context) |
+static PassRefPtrWillBeRawPtr<CSSValue> consumeFilter(CSSParserTokenRange& range, const CSSParserContext& context) |
{ |
if (range.peek().id() == CSSValueNone) |
return consumeIdent(range); |
@@ -1487,6 +1489,60 @@ static PassRefPtrWillBeRawPtr<CSSValue> consumeFilter(CSSParserTokenRange& range |
return list.release(); |
} |
+static PassRefPtrWillBeRawPtr<CSSValue> consumeMotionPath(CSSParserTokenRange& range) |
+{ |
+ CSSValueID id = range.peek().id(); |
+ if (id == CSSValueNone) |
+ return consumeIdent(range); |
+ |
+ // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. |
+ if (range.peek().functionId() != CSSValuePath) |
+ return nullptr; |
+ |
+ // FIXME: Add support for <fill-rule>. |
+ CSSParserTokenRange functionRange = range; |
+ CSSParserTokenRange functionArgs = consumeFunction(functionRange); |
+ |
+ if (functionArgs.peek().type() != StringToken) |
+ return nullptr; |
+ String pathString = functionArgs.consumeIncludingWhitespace().value(); |
+ Path path; |
+ if (!buildPathFromString(pathString, path) || !functionArgs.atEnd()) |
+ return nullptr; |
+ |
+ range = functionRange; |
+ return CSSPathValue::create(pathString); |
+} |
+ |
+static bool consumeMotionKeywordOrAngle(CSSParserTokenRange& range, CSSParserMode cssParserMode, RefPtrWillBeRawPtr<CSSValue>& keyword, RefPtrWillBeRawPtr<CSSValue>& angle) |
+{ |
+ CSSValueID id = range.peek().id(); |
+ if ((id == CSSValueAuto || id == CSSValueReverse) && !keyword) |
+ keyword = consumeIdent(range); |
+ else if (!angle) |
+ angle = consumeAngle(range, cssParserMode); |
+ else |
+ return false; |
Timothy Loh
2015/11/04 04:18:28
btw we'd never actually get here on the first call
|
+ return true; |
+} |
+ |
+static PassRefPtrWillBeRawPtr<CSSValue> consumeMotionRotation(CSSParserTokenRange& range, CSSParserMode cssParserMode) |
+{ |
+ RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
Timothy Loh
2015/11/04 04:18:27
let's define this where it's used instead of at th
|
+ |
+ RefPtrWillBeRawPtr<CSSValue> keyword = nullptr; |
Timothy Loh
2015/11/04 04:18:27
Another option, WDYT?
RefPtrWillBeRawPtr<CSSValue
|
+ RefPtrWillBeRawPtr<CSSValue> angle = nullptr; |
+ if (!consumeMotionKeywordOrAngle(range, cssParserMode, keyword, angle)) |
+ return nullptr; |
+ consumeMotionKeywordOrAngle(range, cssParserMode, keyword, angle); |
+ |
+ if (keyword) |
+ list->append(keyword.release()); |
+ if (angle) |
+ list->append(angle.release()); |
+ return list.release(); |
+} |
+ |
PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedProperty) |
{ |
CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
@@ -1597,6 +1653,15 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty |
case CSSPropertyWebkitFilter: |
case CSSPropertyBackdropFilter: |
return consumeFilter(m_range, m_context); |
+ case CSSPropertyMotionPath: |
+ ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); |
+ return consumeMotionPath(m_range); |
+ case CSSPropertyMotionOffset: |
+ ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); |
+ return consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeAll); |
+ case CSSPropertyMotionRotation: |
+ ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); |
+ return consumeMotionRotation(m_range, m_context.mode()); |
default: |
return nullptr; |
} |
@@ -2023,6 +2088,9 @@ bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool im |
return consumeAnimationShorthand(animationShorthandForParsing(), unresolvedProperty == CSSPropertyAliasWebkitAnimation, important); |
case CSSPropertyTransition: |
return consumeAnimationShorthand(transitionShorthandForParsing(), false, important); |
+ case CSSPropertyMotion: |
+ ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); |
+ return consumeShorthandGreedily(motionShorthand(), important); |
default: |
m_currentShorthand = oldShorthand; |
return false; |