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

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

Issue 2816903003: Added CSSPropertyOffsetPathUtils which holds shared parsing logic. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/properties/CSSPropertyOffsetPathUtils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/css/properties/CSSPropertyOffsetPathUtils.h"
6
7 #include "core/css/CSSPathValue.h"
8 #include "core/css/parser/CSSParserContext.h"
9 #include "core/css/parser/CSSPropertyParserHelpers.h"
10 #include "core/svg/SVGPathByteStream.h"
11 #include "core/svg/SVGPathUtilities.h"
12
13 namespace blink {
14
15 namespace {
16
17 CSSValue* ConsumePath(CSSParserTokenRange& range) {
18 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>.
19 if (range.Peek().FunctionId() != CSSValuePath)
20 return nullptr;
21
22 CSSParserTokenRange function_range = range;
23 CSSParserTokenRange function_args =
24 CSSPropertyParserHelpers::ConsumeFunction(function_range);
25
26 if (function_args.Peek().GetType() != kStringToken)
27 return nullptr;
28 String path_string =
29 function_args.ConsumeIncludingWhitespace().Value().ToString();
30
31 std::unique_ptr<SVGPathByteStream> byte_stream = SVGPathByteStream::Create();
32 if (BuildByteStreamFromString(path_string, *byte_stream) !=
33 SVGParseStatus::kNoError ||
34 !function_args.AtEnd())
35 return nullptr;
Eric Willigers 2017/04/13 21:18:12 I'd wrap this line in { } as the condition is spre
Bugs Nash 2017/04/17 23:17:36 done
36
37 range = function_range;
38 if (byte_stream->IsEmpty())
39 return CSSIdentifierValue::Create(CSSValueNone);
40 return CSSPathValue::Create(std::move(byte_stream));
41 }
42
43 } // namespace
44
45 CSSValue* CSSPropertyOffsetPathUtils::ConsumeOffsetPath(
46 CSSParserTokenRange& range,
47 const CSSParserContext* context,
48 bool is_motion_path) {
49 CSSValue* value = ConsumePathOrNone(range);
50
51 // Count when we receive a valid path other than 'none'.
52 if (value && !value->IsIdentifierValue()) {
53 if (is_motion_path) {
54 context->Count(UseCounter::kCSSMotionInEffect);
55 } else {
56 context->Count(UseCounter::kCSSOffsetInEffect);
57 }
58 }
59 return value;
60 }
61
62 CSSValue* CSSPropertyOffsetPathUtils::ConsumePathOrNone(
63 CSSParserTokenRange& range) {
64 CSSValueID id = range.Peek().Id();
65 if (id == CSSValueNone)
66 return CSSPropertyParserHelpers::ConsumeIdent(range);
67
68 return ConsumePath(range);
69 }
70
71 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/properties/CSSPropertyOffsetPathUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698