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

Unified Diff: third_party/WebKit/Source/core/css/properties/CSSPropertyOffsetPathUtils.cpp

Issue 2881673003: CSS Motion Path: Support parsing of ray(<angle>) paths (Closed)
Patch Set: size contain? Created 3 years, 7 months 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/properties/CSSPropertyOffsetPathUtils.cpp
diff --git a/third_party/WebKit/Source/core/css/properties/CSSPropertyOffsetPathUtils.cpp b/third_party/WebKit/Source/core/css/properties/CSSPropertyOffsetPathUtils.cpp
index e129977ff7f7f2f7e03a435338a9af2cc6b13968..369ece4eceace380b6c2b53f0725f0578a569a93 100644
--- a/third_party/WebKit/Source/core/css/properties/CSSPropertyOffsetPathUtils.cpp
+++ b/third_party/WebKit/Source/core/css/properties/CSSPropertyOffsetPathUtils.cpp
@@ -4,7 +4,11 @@
#include "core/css/properties/CSSPropertyOffsetPathUtils.h"
+#include "core/css/CSSIdentifierValue.h"
#include "core/css/CSSPathValue.h"
+#include "core/css/CSSPrimitiveValue.h"
+#include "core/css/CSSRayValue.h"
+#include "core/css/CSSValueList.h"
#include "core/css/parser/CSSParserContext.h"
#include "core/css/parser/CSSPropertyParserHelpers.h"
#include "core/svg/SVGPathByteStream.h"
@@ -41,12 +45,51 @@ CSSValue* ConsumePath(CSSParserTokenRange& range) {
return CSSPathValue::Create(std::move(byte_stream));
}
+CSSValue* ConsumeRay(CSSParserTokenRange& range) {
+ DCHECK(range.Peek().FunctionId() == CSSValueRay);
+ CSSParserTokenRange function_range = range;
+ CSSParserTokenRange function_args =
+ CSSPropertyParserHelpers::ConsumeFunction(function_range);
+ CSSValueList* arguments = CSSValueList::CreateSpaceSeparated();
fs 2017/05/15 09:18:14 Rather than constructing a temporary list, could t
Eric Willigers 2017/05/15 10:52:23 Done.
+
+ CSSPrimitiveValue* angle = nullptr;
+ CSSIdentifierValue* size = nullptr;
+ CSSIdentifierValue* contain = nullptr;
+ while (!function_args.AtEnd()) {
+ if (!angle &&
+ (angle = CSSPropertyParserHelpers::ConsumeAngle(function_args)))
+ arguments->Append(*angle);
+ else if (!size && (size = CSSPropertyParserHelpers::ConsumeIdent<
+ CSSValueClosestSide, CSSValueClosestCorner,
+ CSSValueFarthestSide, CSSValueFarthestCorner,
+ CSSValueSides, CSSValueCover>(function_args)))
fs 2017/05/15 09:18:14 I didn't see 'cover' in <size>? C'n'P?
Eric Willigers 2017/05/15 10:52:23 Oops. Fixed.
+ arguments->Append(*size);
+ else if (RuntimeEnabledFeatures::cssOffsetPathRayContainEnabled() &&
+ !contain &&
+ (contain = CSSPropertyParserHelpers::ConsumeIdent<CSSValueContain>(
+ function_args)))
+ arguments->Append(*contain);
+ else
+ return nullptr;
+ }
+ if (!angle || !size)
+ return nullptr;
+ DCHECK_LE(arguments->length(), 3U);
+ range = function_range;
+ return CSSRayValue::Create(arguments);
+}
+
} // namespace
CSSValue* CSSPropertyOffsetPathUtils::ConsumeOffsetPath(
CSSParserTokenRange& range,
const CSSParserContext* context) {
- CSSValue* value = ConsumePathOrNone(range);
+ CSSValue* value = nullptr;
+ if (RuntimeEnabledFeatures::cssOffsetPathRayEnabled() &&
+ range.Peek().FunctionId() == CSSValueRay)
+ value = ConsumeRay(range);
+ else
+ value = ConsumePathOrNone(range);
// Count when we receive a valid path other than 'none'.
if (value && !value->IsIdentifierValue())

Powered by Google App Engine
This is Rietveld 408576698