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

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

Issue 2888283006: CSS: Use count position values with 3 parts (Closed)
Patch Set: use count in the property APIs Created 3 years, 7 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
OLDNEW
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
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 auto syntax = CSSPropertyParserHelpers::PositionSyntax::kPermitThreeValues;
38 center_y)) 38 if (!ConsumePosition(args, context, UnitlessQuirk::kForbid, syntax,
39 center_x, center_y))
39 return nullptr; 40 return nullptr;
41 if (syntax == CSSPropertyParserHelpers::PositionSyntax::kCountThreeValues)
42 context.Count(UseCounter::kThreeValuedPositionBasicShape);
40 shape->SetCenterX(center_x); 43 shape->SetCenterX(center_x);
41 shape->SetCenterY(center_y); 44 shape->SetCenterY(center_y);
42 } 45 }
43 return shape; 46 return shape;
44 } 47 }
45 48
46 static CSSBasicShapeEllipseValue* ConsumeBasicShapeEllipse( 49 static CSSBasicShapeEllipseValue* ConsumeBasicShapeEllipse(
47 CSSParserTokenRange& args, 50 CSSParserTokenRange& args,
48 const CSSParserContext& context) { 51 const CSSParserContext& context) {
49 // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes 52 // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes
50 // ellipse( [<shape-radius>{2}]? [at <position>]? ) 53 // ellipse( [<shape-radius>{2}]? [at <position>]? )
51 CSSBasicShapeEllipseValue* shape = CSSBasicShapeEllipseValue::Create(); 54 CSSBasicShapeEllipseValue* shape = CSSBasicShapeEllipseValue::Create();
52 if (CSSValue* radius_x = ConsumeShapeRadius(args, context.Mode())) { 55 if (CSSValue* radius_x = ConsumeShapeRadius(args, context.Mode())) {
53 shape->SetRadiusX(radius_x); 56 shape->SetRadiusX(radius_x);
54 if (CSSValue* radius_y = ConsumeShapeRadius(args, context.Mode())) 57 if (CSSValue* radius_y = ConsumeShapeRadius(args, context.Mode()))
55 shape->SetRadiusY(radius_y); 58 shape->SetRadiusY(radius_y);
56 } 59 }
57 if (ConsumeIdent<CSSValueAt>(args)) { 60 if (ConsumeIdent<CSSValueAt>(args)) {
58 CSSValue* center_x = nullptr; 61 CSSValue* center_x = nullptr;
59 CSSValue* center_y = nullptr; 62 CSSValue* center_y = nullptr;
60 if (!ConsumePosition(args, context.Mode(), UnitlessQuirk::kForbid, center_x, 63 auto syntax = CSSPropertyParserHelpers::PositionSyntax::kPermitThreeValues;
61 center_y)) 64 if (!ConsumePosition(args, context, UnitlessQuirk::kForbid, syntax,
65 center_x, center_y))
62 return nullptr; 66 return nullptr;
67 if (syntax == CSSPropertyParserHelpers::PositionSyntax::kCountThreeValues)
68 context.Count(UseCounter::kThreeValuedPositionBasicShape);
63 shape->SetCenterX(center_x); 69 shape->SetCenterX(center_x);
64 shape->SetCenterY(center_y); 70 shape->SetCenterY(center_y);
65 } 71 }
66 return shape; 72 return shape;
67 } 73 }
68 74
69 static CSSBasicShapePolygonValue* ConsumeBasicShapePolygon( 75 static CSSBasicShapePolygonValue* ConsumeBasicShapePolygon(
70 CSSParserTokenRange& args, 76 CSSParserTokenRange& args,
71 const CSSParserContext& context) { 77 const CSSParserContext& context) {
72 CSSBasicShapePolygonValue* shape = CSSBasicShapePolygonValue::Create(); 78 CSSBasicShapePolygonValue* shape = CSSBasicShapePolygonValue::Create();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 shape = ConsumeBasicShapePolygon(args, context); 209 shape = ConsumeBasicShapePolygon(args, context);
204 else if (id == CSSValueInset) 210 else if (id == CSSValueInset)
205 shape = ConsumeBasicShapeInset(args, context); 211 shape = ConsumeBasicShapeInset(args, context);
206 if (!shape || !args.AtEnd()) 212 if (!shape || !args.AtEnd())
207 return nullptr; 213 return nullptr;
208 range = range_copy; 214 range = range_copy;
209 return shape; 215 return shape;
210 } 216 }
211 217
212 } // namespace blink 218 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698