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

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

Issue 1420003005: Parse motion shorthand in CSSPropertyParser with CSSParserTokens (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 5 years, 1 month 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
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 304d82fbd3b8b1c4e6423f95f2c05fca79e6325e..c88a0d6d0cfd4fc5ce29a4254c316d41aeeb7329 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);
@@ -1505,6 +1507,49 @@ static PassRefPtrWillBeRawPtr<CSSValue> consumeTextDecorationLine(CSSParserToken
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 PassRefPtrWillBeRawPtr<CSSValue> consumeMotionRotation(CSSParserTokenRange& range, CSSParserMode cssParserMode)
+{
+ RefPtrWillBeRawPtr<CSSValue> angle = consumeAngle(range, cssParserMode);
+ RefPtrWillBeRawPtr<CSSValue> keyword = consumeIdent<CSSValueAuto, CSSValueReverse>(range);
+ if (!angle && !keyword)
+ return nullptr;
+
+ if (!angle)
+ angle = consumeAngle(range, cssParserMode);
+
+ RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+ 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);
@@ -1621,6 +1666,15 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
case CSSPropertyWebkitTextDecorationsInEffect:
case CSSPropertyTextDecorationLine:
return consumeTextDecorationLine(m_range);
+ 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;
}
@@ -2092,6 +2146,9 @@ bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool im
addProperty(CSSPropertyTextDecoration, textDecoration.release(), important);
return true;
}
+ case CSSPropertyMotion:
+ ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled());
+ return consumeShorthandGreedily(motionShorthand(), important);
default:
m_currentShorthand = oldShorthand;
return false;

Powered by Google App Engine
This is Rietveld 408576698