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

Side by Side Diff: Source/core/rendering/style/BasicShapes.h

Issue 103413006: Implement parsing of the new ellipse shape syntax. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years 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 /* 1 /*
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above 8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following 9 * copyright notice, this list of conditions and the following
10 * disclaimer. 10 * disclaimer.
(...skipping 29 matching lines...) Expand all
40 40
41 class FloatRect; 41 class FloatRect;
42 class Path; 42 class Path;
43 43
44 class BasicShape : public RefCounted<BasicShape> { 44 class BasicShape : public RefCounted<BasicShape> {
45 public: 45 public:
46 virtual ~BasicShape() { } 46 virtual ~BasicShape() { }
47 47
48 enum Type { 48 enum Type {
49 BasicShapeRectangleType = 1, 49 BasicShapeRectangleType = 1,
50 BasicShapeCircleType = 2, 50 DeprecatedBasicShapeCircleType = 2,
51 BasicShapeEllipseType = 3, 51 DeprecatedBasicShapeEllipseType = 3,
52 BasicShapePolygonType = 4, 52 BasicShapeEllipseType = 4,
53 BasicShapeInsetRectangleType = 5 53 BasicShapePolygonType = 5,
54 BasicShapeInsetRectangleType = 6,
55 BasicShapeCircleType = 7
bemjb 2013/12/07 00:05:32 Do you want to remove these explicit numbers in th
54 }; 56 };
55 57
56 bool canBlend(const BasicShape*) const; 58 bool canBlend(const BasicShape*) const;
57 59
58 virtual void path(Path&, const FloatRect&) = 0; 60 virtual void path(Path&, const FloatRect&) = 0;
59 virtual WindRule windRule() const { return RULE_NONZERO; } 61 virtual WindRule windRule() const { return RULE_NONZERO; }
60 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const = 0; 62 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const = 0;
61 63
62 virtual Type type() const = 0; 64 virtual Type type() const = 0;
63 protected: 65 protected:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 BasicShapeRectangle() { } 100 BasicShapeRectangle() { }
99 101
100 Length m_y; 102 Length m_y;
101 Length m_x; 103 Length m_x;
102 Length m_width; 104 Length m_width;
103 Length m_height; 105 Length m_height;
104 Length m_cornerRadiusX; 106 Length m_cornerRadiusX;
105 Length m_cornerRadiusY; 107 Length m_cornerRadiusY;
106 }; 108 };
107 109
110 class BasicShapeCenterCoordinate {
111 public:
112 enum Keyword {
113 None,
114 Top,
115 Right,
116 Bottom,
117 Left
118 };
119 BasicShapeCenterCoordinate() : m_keyword(None), m_length(Undefined) { }
120 explicit BasicShapeCenterCoordinate(Length length) : m_keyword(None), m_leng th(length) { }
121 BasicShapeCenterCoordinate(Keyword keyword, Length length) : m_keyword(keywo rd), m_length(length) { }
122 BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other) : m_keyw ord(other.keyword()), m_length(other.length()) { }
123
124 Keyword keyword() const { return m_keyword; }
125 const Length& length() const { return m_length; }
126
127 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, do uble progress) const
128 {
129 if (m_keyword != None || other.keyword() != None)
130 return BasicShapeCenterCoordinate(other);
131
132 return BasicShapeCenterCoordinate(m_length.blend(other.length(), progres s, ValueRangeAll));
133 }
134
135 private:
136 Keyword m_keyword;
137 Length m_length;
138 };
139
140 class BasicShapeRadius {
141 public:
142 enum Type {
143 Value,
144 ClosestSide,
145 FarthestSide
146 };
147 BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { }
148 explicit BasicShapeRadius(Length v) : m_value(v), m_type(Value) { }
149 explicit BasicShapeRadius(Type t) : m_value(Undefined), m_type(t) { }
150 BasicShapeRadius(const BasicShapeRadius& other) : m_value(other.value()), m_ type(other.type()) { }
151
152 const Length& value() const { return m_value; }
153 Type type() const { return m_type; }
154
155 BasicShapeRadius blend(const BasicShapeRadius& other, double progress) const
156 {
157 if (m_type != Value || other.type() != Value)
158 return BasicShapeRadius(other);
159
160 return BasicShapeRadius(m_value.blend(other.value(), progress, ValueRang eAll));
161 }
162
163 private:
164 Length m_value;
165 Type m_type;
166
167 };
168
108 class BasicShapeCircle : public BasicShape { 169 class BasicShapeCircle : public BasicShape {
109 public: 170 public:
110 static PassRefPtr<BasicShapeCircle> create() { return adoptRef(new BasicShap eCircle); } 171 static PassRefPtr<BasicShapeCircle> create() { return adoptRef(new BasicShap eCircle); }
111 172
173 const BasicShapeCenterCoordinate& centerX() const { return m_centerX; }
174 const BasicShapeCenterCoordinate& centerY() const { return m_centerY; }
175 const BasicShapeRadius& radius() const { return m_radius; }
176
177 void setCenterX(BasicShapeCenterCoordinate centerX) { m_centerX = centerX; }
178 void setCenterY(BasicShapeCenterCoordinate centerY) { m_centerY = centerY; }
179 void setRadius(BasicShapeRadius radius) { m_radius = radius; }
180
181 virtual void path(Path&, const FloatRect&) OVERRIDE;
182 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE;
183
184 virtual Type type() const { return BasicShapeCircleType; }
185 private:
186 BasicShapeCircle() { }
187
188 BasicShapeCenterCoordinate m_centerX;
189 BasicShapeCenterCoordinate m_centerY;
190 BasicShapeRadius m_radius;
191 };
192
193 class DeprecatedBasicShapeCircle : public BasicShape {
194 public:
195 static PassRefPtr<DeprecatedBasicShapeCircle> create() { return adoptRef(new DeprecatedBasicShapeCircle); }
196
112 Length centerX() const { return m_centerX; } 197 Length centerX() const { return m_centerX; }
113 Length centerY() const { return m_centerY; } 198 Length centerY() const { return m_centerY; }
114 Length radius() const { return m_radius; } 199 Length radius() const { return m_radius; }
115 200
116 void setCenterX(Length centerX) { m_centerX = centerX; } 201 void setCenterX(Length centerX) { m_centerX = centerX; }
117 void setCenterY(Length centerY) { m_centerY = centerY; } 202 void setCenterY(Length centerY) { m_centerY = centerY; }
118 void setRadius(Length radius) { m_radius = radius; } 203 void setRadius(Length radius) { m_radius = radius; }
119 204
120 virtual void path(Path&, const FloatRect&) OVERRIDE; 205 virtual void path(Path&, const FloatRect&) OVERRIDE;
121 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE; 206 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE;
122 207
123 virtual Type type() const { return BasicShapeCircleType; } 208 virtual Type type() const { return DeprecatedBasicShapeCircleType; }
124 private: 209 private:
125 BasicShapeCircle() { } 210 DeprecatedBasicShapeCircle() { }
126 211
127 Length m_centerX; 212 Length m_centerX;
128 Length m_centerY; 213 Length m_centerY;
129 Length m_radius; 214 Length m_radius;
130 }; 215 };
131 216
132 class BasicShapeEllipse : public BasicShape { 217 class BasicShapeEllipse : public BasicShape {
133 public: 218 public:
134 static PassRefPtr<BasicShapeEllipse> create() { return adoptRef(new BasicSha peEllipse); } 219 static PassRefPtr<BasicShapeEllipse> create() { return adoptRef(new BasicSha peEllipse); }
135 220
221 const BasicShapeCenterCoordinate& centerX() const { return m_centerX; }
222 const BasicShapeCenterCoordinate& centerY() const { return m_centerY; }
223 const BasicShapeRadius& radiusX() const { return m_radiusX; }
224 const BasicShapeRadius& radiusY() const { return m_radiusY; }
225
226 void setCenterX(BasicShapeCenterCoordinate centerX) { m_centerX = centerX; }
227 void setCenterY(BasicShapeCenterCoordinate centerY) { m_centerY = centerY; }
228 void setRadiusX(BasicShapeRadius radiusX) { m_radiusX = radiusX; }
229 void setRadiusY(BasicShapeRadius radiusY) { m_radiusY = radiusY; }
230
231 virtual void path(Path&, const FloatRect&) OVERRIDE;
232 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE;
233
234 virtual Type type() const { return BasicShapeEllipseType; }
235 private:
236 BasicShapeEllipse() { }
237
238 BasicShapeCenterCoordinate m_centerX;
239 BasicShapeCenterCoordinate m_centerY;
240 BasicShapeRadius m_radiusX;
241 BasicShapeRadius m_radiusY;
242 };
243
244 class DeprecatedBasicShapeEllipse : public BasicShape {
245 public:
246 static PassRefPtr<DeprecatedBasicShapeEllipse> create() { return adoptRef(ne w DeprecatedBasicShapeEllipse); }
247
136 Length centerX() const { return m_centerX; } 248 Length centerX() const { return m_centerX; }
137 Length centerY() const { return m_centerY; } 249 Length centerY() const { return m_centerY; }
138 Length radiusX() const { return m_radiusX; } 250 Length radiusX() const { return m_radiusX; }
139 Length radiusY() const { return m_radiusY; } 251 Length radiusY() const { return m_radiusY; }
140 252
141 void setCenterX(Length centerX) { m_centerX = centerX; } 253 void setCenterX(Length centerX) { m_centerX = centerX; }
142 void setCenterY(Length centerY) { m_centerY = centerY; } 254 void setCenterY(Length centerY) { m_centerY = centerY; }
143 void setRadiusX(Length radiusX) { m_radiusX = radiusX; } 255 void setRadiusX(Length radiusX) { m_radiusX = radiusX; }
144 void setRadiusY(Length radiusY) { m_radiusY = radiusY; } 256 void setRadiusY(Length radiusY) { m_radiusY = radiusY; }
145 257
146 virtual void path(Path&, const FloatRect&) OVERRIDE; 258 virtual void path(Path&, const FloatRect&) OVERRIDE;
147 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE; 259 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE;
148 260
149 virtual Type type() const { return BasicShapeEllipseType; } 261 virtual Type type() const { return DeprecatedBasicShapeEllipseType; }
150 private: 262 private:
151 BasicShapeEllipse() { } 263 DeprecatedBasicShapeEllipse() { }
152 264
153 Length m_centerX; 265 Length m_centerX;
154 Length m_centerY; 266 Length m_centerY;
155 Length m_radiusX; 267 Length m_radiusX;
156 Length m_radiusY; 268 Length m_radiusY;
157 }; 269 };
158 270
159 class BasicShapePolygon : public BasicShape { 271 class BasicShapePolygon : public BasicShape {
160 public: 272 public:
161 static PassRefPtr<BasicShapePolygon> create() { return adoptRef(new BasicSha pePolygon); } 273 static PassRefPtr<BasicShapePolygon> create() { return adoptRef(new BasicSha pePolygon); }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 329
218 Length m_right; 330 Length m_right;
219 Length m_top; 331 Length m_top;
220 Length m_bottom; 332 Length m_bottom;
221 Length m_left; 333 Length m_left;
222 Length m_cornerRadiusX; 334 Length m_cornerRadiusX;
223 Length m_cornerRadiusY; 335 Length m_cornerRadiusY;
224 }; 336 };
225 } 337 }
226 #endif 338 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698