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

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

Issue 2614783003: Implements CSSPropertyAPI for the clip property. (Closed)
Patch Set: rebase Created 3 years, 11 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/parser/CSSPropertyParser.cpp ('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/CSSPropertyAPIClip.h"
6
7 #include "core/css/CSSQuadValue.h"
8 #include "core/css/parser/CSSParserContext.h"
9 #include "core/css/parser/CSSPropertyParserHelpers.h"
10
11 namespace blink {
12
13 namespace {
14
15 CSSValue* consumeClipComponent(CSSParserTokenRange& range,
16 CSSParserMode cssParserMode) {
17 if (range.peek().id() == CSSValueAuto)
18 return CSSPropertyParserHelpers::consumeIdent(range);
19 return CSSPropertyParserHelpers::consumeLength(
20 range, cssParserMode, ValueRangeAll,
21 CSSPropertyParserHelpers::UnitlessQuirk::Allow);
22 }
23 }
24
25 const CSSValue* CSSPropertyAPIClip::parseSingleValue(
26 CSSParserTokenRange& range,
27 const CSSParserContext& context) {
28 if (range.peek().id() == CSSValueAuto)
29 return CSSPropertyParserHelpers::consumeIdent(range);
30
31 if (range.peek().functionId() != CSSValueRect)
32 return nullptr;
33
34 CSSParserTokenRange args = CSSPropertyParserHelpers::consumeFunction(range);
35 // rect(t, r, b, l) || rect(t r b l)
36 CSSValue* top = consumeClipComponent(args, context.mode());
37 if (!top)
38 return nullptr;
39 bool needsComma =
40 CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args);
41 CSSValue* right = consumeClipComponent(args, context.mode());
42 if (!right ||
43 (needsComma &&
44 !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args)))
45 return nullptr;
46 CSSValue* bottom = consumeClipComponent(args, context.mode());
47 if (!bottom ||
48 (needsComma &&
49 !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args)))
50 return nullptr;
51 CSSValue* left = consumeClipComponent(args, context.mode());
52 if (!left || !args.atEnd())
53 return nullptr;
54 return CSSQuadValue::create(top, right, bottom, left,
55 CSSQuadValue::SerializeAsRect);
56 }
57
58 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698