OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/css/properties/CSSPropertyAPIClip.h" | 5 #include "core/css/properties/CSSPropertyAPIClip.h" |
6 | 6 |
7 #include "core/css/CSSQuadValue.h" | 7 #include "core/css/CSSQuadValue.h" |
8 #include "core/css/parser/CSSParserContext.h" | 8 #include "core/css/parser/CSSParserContext.h" |
9 #include "core/css/parser/CSSPropertyParserHelpers.h" | 9 #include "core/css/parser/CSSPropertyParserHelpers.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 CSSValue* consumeClipComponent(CSSParserTokenRange& range, | 15 CSSValue* consumeClipComponent(CSSParserTokenRange& range, |
16 CSSParserMode cssParserMode) { | 16 CSSParserMode cssParserMode) { |
17 if (range.peek().id() == CSSValueAuto) | 17 if (range.peek().id() == CSSValueAuto) |
18 return CSSPropertyParserHelpers::consumeIdent(range); | 18 return CSSPropertyParserHelpers::consumeIdent(range); |
19 return CSSPropertyParserHelpers::consumeLength( | 19 return CSSPropertyParserHelpers::consumeLength( |
20 range, cssParserMode, ValueRangeAll, | 20 range, cssParserMode, ValueRangeAll, |
21 CSSPropertyParserHelpers::UnitlessQuirk::Allow); | 21 CSSPropertyParserHelpers::UnitlessQuirk::Allow); |
22 } | 22 } |
23 | 23 |
24 } // namespace | 24 } // namespace |
25 | 25 |
26 const CSSValue* CSSPropertyAPIClip::parseSingleValue( | 26 const CSSValue* CSSPropertyAPIClip::parseSingleValue( |
27 CSSParserTokenRange& range, | 27 CSSParserTokenRange& range, |
28 const CSSParserContext& context) { | 28 const CSSParserContext* context) { |
29 if (range.peek().id() == CSSValueAuto) | 29 if (range.peek().id() == CSSValueAuto) |
30 return CSSPropertyParserHelpers::consumeIdent(range); | 30 return CSSPropertyParserHelpers::consumeIdent(range); |
31 | 31 |
32 if (range.peek().functionId() != CSSValueRect) | 32 if (range.peek().functionId() != CSSValueRect) |
33 return nullptr; | 33 return nullptr; |
34 | 34 |
35 CSSParserTokenRange args = CSSPropertyParserHelpers::consumeFunction(range); | 35 CSSParserTokenRange args = CSSPropertyParserHelpers::consumeFunction(range); |
36 // rect(t, r, b, l) || rect(t r b l) | 36 // rect(t, r, b, l) || rect(t r b l) |
37 CSSValue* top = consumeClipComponent(args, context.mode()); | 37 CSSValue* top = consumeClipComponent(args, context->mode()); |
38 if (!top) | 38 if (!top) |
39 return nullptr; | 39 return nullptr; |
40 bool needsComma = | 40 bool needsComma = |
41 CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args); | 41 CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args); |
42 CSSValue* right = consumeClipComponent(args, context.mode()); | 42 CSSValue* right = consumeClipComponent(args, context->mode()); |
43 if (!right || | 43 if (!right || |
44 (needsComma && | 44 (needsComma && |
45 !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args))) | 45 !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args))) |
46 return nullptr; | 46 return nullptr; |
47 CSSValue* bottom = consumeClipComponent(args, context.mode()); | 47 CSSValue* bottom = consumeClipComponent(args, context->mode()); |
48 if (!bottom || | 48 if (!bottom || |
49 (needsComma && | 49 (needsComma && |
50 !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args))) | 50 !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args))) |
51 return nullptr; | 51 return nullptr; |
52 CSSValue* left = consumeClipComponent(args, context.mode()); | 52 CSSValue* left = consumeClipComponent(args, context->mode()); |
53 if (!left || !args.atEnd()) | 53 if (!left || !args.atEnd()) |
54 return nullptr; | 54 return nullptr; |
55 return CSSQuadValue::create(top, right, bottom, left, | 55 return CSSQuadValue::create(top, right, bottom, left, |
56 CSSQuadValue::SerializeAsRect); | 56 CSSQuadValue::SerializeAsRect); |
57 } | 57 } |
58 | 58 |
59 } // namespace blink | 59 } // namespace blink |
OLD | NEW |