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/CSSPropertyShapeUtils.h" | 5 #include "core/css/properties/CSSPropertyShapeUtils.h" |
6 | 6 |
7 #include "core/css/CSSBasicShapeValues.h" | 7 #include "core/css/CSSBasicShapeValues.h" |
8 #include "core/css/parser/CSSParserContext.h" | 8 #include "core/css/parser/CSSParserContext.h" |
9 #include "core/css/parser/CSSParserMode.h" | 9 #include "core/css/parser/CSSParserMode.h" |
10 #include "core/css/parser/CSSParserTokenRange.h" | 10 #include "core/css/parser/CSSParserTokenRange.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 CSSParserTokenRange& args, | 27 CSSParserTokenRange& args, |
28 const CSSParserContext& context) { | 28 const CSSParserContext& context) { |
29 // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes | 29 // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes |
30 // circle( [<shape-radius>]? [at <position>]? ) | 30 // circle( [<shape-radius>]? [at <position>]? ) |
31 CSSBasicShapeCircleValue* shape = CSSBasicShapeCircleValue::Create(); | 31 CSSBasicShapeCircleValue* shape = CSSBasicShapeCircleValue::Create(); |
32 if (CSSValue* radius = ConsumeShapeRadius(args, context.Mode())) | 32 if (CSSValue* radius = ConsumeShapeRadius(args, context.Mode())) |
33 shape->SetRadius(radius); | 33 shape->SetRadius(radius); |
34 if (ConsumeIdent<CSSValueAt>(args)) { | 34 if (ConsumeIdent<CSSValueAt>(args)) { |
35 CSSValue* center_x = nullptr; | 35 CSSValue* center_x = nullptr; |
36 CSSValue* center_y = nullptr; | 36 CSSValue* center_y = nullptr; |
37 if (!ConsumePosition(args, context.Mode(), UnitlessQuirk::kForbid, center_x, | 37 if (!ConsumePosition(args, context, UnitlessQuirk::kForbid, |
38 center_y)) | 38 PositionSyntax::kBasicShape, center_x, center_y)) |
39 return nullptr; | 39 return nullptr; |
40 shape->SetCenterX(center_x); | 40 shape->SetCenterX(center_x); |
41 shape->SetCenterY(center_y); | 41 shape->SetCenterY(center_y); |
42 } | 42 } |
43 return shape; | 43 return shape; |
44 } | 44 } |
45 | 45 |
46 static CSSBasicShapeEllipseValue* ConsumeBasicShapeEllipse( | 46 static CSSBasicShapeEllipseValue* ConsumeBasicShapeEllipse( |
47 CSSParserTokenRange& args, | 47 CSSParserTokenRange& args, |
48 const CSSParserContext& context) { | 48 const CSSParserContext& context) { |
49 // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes | 49 // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes |
50 // ellipse( [<shape-radius>{2}]? [at <position>]? ) | 50 // ellipse( [<shape-radius>{2}]? [at <position>]? ) |
51 CSSBasicShapeEllipseValue* shape = CSSBasicShapeEllipseValue::Create(); | 51 CSSBasicShapeEllipseValue* shape = CSSBasicShapeEllipseValue::Create(); |
52 if (CSSValue* radius_x = ConsumeShapeRadius(args, context.Mode())) { | 52 if (CSSValue* radius_x = ConsumeShapeRadius(args, context.Mode())) { |
53 shape->SetRadiusX(radius_x); | 53 shape->SetRadiusX(radius_x); |
54 if (CSSValue* radius_y = ConsumeShapeRadius(args, context.Mode())) | 54 if (CSSValue* radius_y = ConsumeShapeRadius(args, context.Mode())) |
55 shape->SetRadiusY(radius_y); | 55 shape->SetRadiusY(radius_y); |
56 } | 56 } |
57 if (ConsumeIdent<CSSValueAt>(args)) { | 57 if (ConsumeIdent<CSSValueAt>(args)) { |
58 CSSValue* center_x = nullptr; | 58 CSSValue* center_x = nullptr; |
59 CSSValue* center_y = nullptr; | 59 CSSValue* center_y = nullptr; |
60 if (!ConsumePosition(args, context.Mode(), UnitlessQuirk::kForbid, center_x, | 60 if (!ConsumePosition(args, context, UnitlessQuirk::kForbid, |
61 center_y)) | 61 PositionSyntax::kBasicShape, center_x, center_y)) |
62 return nullptr; | 62 return nullptr; |
63 shape->SetCenterX(center_x); | 63 shape->SetCenterX(center_x); |
64 shape->SetCenterY(center_y); | 64 shape->SetCenterY(center_y); |
65 } | 65 } |
66 return shape; | 66 return shape; |
67 } | 67 } |
68 | 68 |
69 static CSSBasicShapePolygonValue* ConsumeBasicShapePolygon( | 69 static CSSBasicShapePolygonValue* ConsumeBasicShapePolygon( |
70 CSSParserTokenRange& args, | 70 CSSParserTokenRange& args, |
71 const CSSParserContext& context) { | 71 const CSSParserContext& context) { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 shape = ConsumeBasicShapePolygon(args, context); | 203 shape = ConsumeBasicShapePolygon(args, context); |
204 else if (id == CSSValueInset) | 204 else if (id == CSSValueInset) |
205 shape = ConsumeBasicShapeInset(args, context); | 205 shape = ConsumeBasicShapeInset(args, context); |
206 if (!shape || !args.AtEnd()) | 206 if (!shape || !args.AtEnd()) |
207 return nullptr; | 207 return nullptr; |
208 range = range_copy; | 208 range = range_copy; |
209 return shape; | 209 return shape; |
210 } | 210 } |
211 | 211 |
212 } // namespace blink | 212 } // namespace blink |
OLD | NEW |