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

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

Issue 2614783003: Implements CSSPropertyAPI for the clip property. (Closed)
Patch Set: upstream 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 static CSSValue* consumeClipComponent(CSSParserTokenRange& range,
sashab 2017/01/09 03:42:21 What Eddy said - anonymous namespace ;) ie names
14 CSSParserMode cssParserMode) {
15 if (range.peek().id() == CSSValueAuto)
16 return CSSPropertyParserHelpers::consumeIdent(range);
17 return CSSPropertyParserHelpers::consumeLength(
18 range, cssParserMode, ValueRangeAll,
19 CSSPropertyParserHelpers::UnitlessQuirk::Allow);
20 }
21
22 const CSSValue* CSSPropertyAPIClip::parseSingleValue(
23 CSSParserTokenRange& range,
24 const CSSParserContext& context) {
25 if (range.peek().id() == CSSValueAuto)
26 return CSSPropertyParserHelpers::consumeIdent(range);
27
28 if (range.peek().functionId() != CSSValueRect)
29 return nullptr;
30
31 CSSParserTokenRange args = CSSPropertyParserHelpers::consumeFunction(range);
32 // rect(t, r, b, l) || rect(t r b l)
33 CSSValue* top = consumeClipComponent(args, context.mode());
34 if (!top)
35 return nullptr;
36 bool needsComma =
37 CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args);
38 CSSValue* right = consumeClipComponent(args, context.mode());
39 if (!right ||
40 (needsComma &&
41 !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args)))
42 return nullptr;
43 CSSValue* bottom = consumeClipComponent(args, context.mode());
44 if (!bottom ||
45 (needsComma &&
46 !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args)))
47 return nullptr;
48 CSSValue* left = consumeClipComponent(args, context.mode());
49 if (!left || !args.atEnd())
50 return nullptr;
51 return CSSQuadValue::create(top, right, bottom, left,
52 CSSQuadValue::SerializeAsRect);
53 }
54
55 } // 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