OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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/CSSValueList.h" | |
9 #include "core/css/parser/CSSParserTokenRange.h" | |
10 #include "core/css/parser/CSSPropertyParser.h" | |
11 #include "core/css/parser/CSSPropertyParserHelpers.h" | |
12 | |
13 namespace blink { | |
14 | |
15 static CSSValue* consumeClipComponent(CSSParserTokenRange& range, | |
meade_UTC10
2017/01/05 04:10:22
You could make this helper method more private by
| |
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 const CSSValue* CSSPropertyAPIClip::parseSingleValue( | |
25 CSSParserTokenRange& range, | |
26 const CSSParserContext& context) { | |
27 if (range.peek().id() == CSSValueAuto) | |
28 return CSSPropertyParserHelpers::consumeIdent(range); | |
29 | |
30 if (range.peek().functionId() != CSSValueRect) | |
31 return nullptr; | |
32 | |
33 CSSParserTokenRange args = CSSPropertyParserHelpers::consumeFunction(range); | |
34 // rect(t, r, b, l) || rect(t r b l) | |
35 CSSValue* top = consumeClipComponent(args, context.mode()); | |
36 if (!top) | |
37 return nullptr; | |
38 bool needsComma = | |
39 CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args); | |
40 CSSValue* right = consumeClipComponent(args, context.mode()); | |
41 if (!right || | |
42 (needsComma && | |
43 !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args))) | |
44 return nullptr; | |
45 CSSValue* bottom = consumeClipComponent(args, context.mode()); | |
46 if (!bottom || | |
47 (needsComma && | |
48 !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args))) | |
49 return nullptr; | |
50 CSSValue* left = consumeClipComponent(args, context.mode()); | |
51 if (!left || !args.atEnd()) | |
52 return nullptr; | |
53 return CSSQuadValue::create(top, right, bottom, left, | |
54 CSSQuadValue::SerializeAsRect); | |
55 } | |
56 | |
57 } // namespace blink | |
OLD | NEW |