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

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

Issue 200633005: [CSS Shapes] Remove deprecated shapes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix test expectations Created 6 years, 9 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 /* 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 class FloatRect; 43 class FloatRect;
44 class FloatSize; 44 class FloatSize;
45 class Path; 45 class Path;
46 46
47 class BasicShape : public RefCounted<BasicShape> { 47 class BasicShape : public RefCounted<BasicShape> {
48 public: 48 public:
49 virtual ~BasicShape() { } 49 virtual ~BasicShape() { }
50 50
51 enum Type { 51 enum Type {
52 BasicShapeRectangleType,
53 DeprecatedBasicShapeCircleType,
54 DeprecatedBasicShapeEllipseType,
55 BasicShapeEllipseType, 52 BasicShapeEllipseType,
56 BasicShapePolygonType, 53 BasicShapePolygonType,
57 BasicShapeInsetRectangleType,
58 BasicShapeCircleType, 54 BasicShapeCircleType,
59 BasicShapeInsetType 55 BasicShapeInsetType
60 }; 56 };
61 57
62 bool canBlend(const BasicShape*) const; 58 bool canBlend(const BasicShape*) const;
63 bool isSameType(const BasicShape& other) const { return type() == other.type (); } 59 bool isSameType(const BasicShape& other) const { return type() == other.type (); }
64 60
65 virtual void path(Path&, const FloatRect&) = 0; 61 virtual void path(Path&, const FloatRect&) = 0;
66 virtual WindRule windRule() const { return RULE_NONZERO; } 62 virtual WindRule windRule() const { return RULE_NONZERO; }
67 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const = 0; 63 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const = 0;
68 virtual bool operator==(const BasicShape&) const = 0; 64 virtual bool operator==(const BasicShape&) const = 0;
69 65
70 virtual Type type() const = 0; 66 virtual Type type() const = 0;
71 67
72 protected: 68 protected:
73 BasicShape() 69 BasicShape()
74 { 70 {
75 } 71 }
76 72
77 }; 73 };
78 74
79 #define DEFINE_BASICSHAPE_TYPE_CASTS(thisType) \ 75 #define DEFINE_BASICSHAPE_TYPE_CASTS(thisType) \
80 DEFINE_TYPE_CASTS(thisType, BasicShape, value, value->type() == BasicShape:: thisType##Type, value.type() == BasicShape::thisType##Type) 76 DEFINE_TYPE_CASTS(thisType, BasicShape, value, value->type() == BasicShape:: thisType##Type, value.type() == BasicShape::thisType##Type)
81 77
82 class BasicShapeRectangle FINAL : public BasicShape {
83 public:
84 static PassRefPtr<BasicShapeRectangle> create() { return adoptRef(new BasicS hapeRectangle); }
85
86 Length x() const { return m_x; }
87 Length y() const { return m_y; }
88 Length width() const { return m_width; }
89 Length height() const { return m_height; }
90 Length cornerRadiusX() const { return m_cornerRadiusX; }
91 Length cornerRadiusY() const { return m_cornerRadiusY; }
92
93 void setX(Length x) { m_x = x; }
94 void setY(Length y) { m_y = y; }
95 void setWidth(Length width) { m_width = width; }
96 void setHeight(Length height) { m_height = height; }
97 void setCornerRadiusX(Length radiusX)
98 {
99 m_cornerRadiusX = radiusX;
100 }
101 void setCornerRadiusY(Length radiusY)
102 {
103 m_cornerRadiusY = radiusY;
104 }
105
106 virtual void path(Path&, const FloatRect&) OVERRIDE;
107 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE;
108 virtual bool operator==(const BasicShape&) const OVERRIDE;
109
110 virtual Type type() const OVERRIDE { return BasicShapeRectangleType; }
111 private:
112 BasicShapeRectangle() { }
113
114 Length m_y;
115 Length m_x;
116 Length m_width;
117 Length m_height;
118 Length m_cornerRadiusX;
119 Length m_cornerRadiusY;
120 };
121
122 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeRectangle);
123
124 class BasicShapeCenterCoordinate { 78 class BasicShapeCenterCoordinate {
125 public: 79 public:
126 enum Direction { 80 enum Direction {
127 TopLeft, 81 TopLeft,
128 BottomRight 82 BottomRight
129 }; 83 };
130 BasicShapeCenterCoordinate() 84 BasicShapeCenterCoordinate()
131 : m_direction(TopLeft) 85 : m_direction(TopLeft)
132 , m_length(Undefined) 86 , m_length(Undefined)
133 { 87 {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 { 141 {
188 // FIXME determine how to interpolate between keywords. See issue 330248 . 142 // FIXME determine how to interpolate between keywords. See issue 330248 .
189 return m_type == Value && other.type() == Value; 143 return m_type == Value && other.type() == Value;
190 } 144 }
191 145
192 BasicShapeRadius blend(const BasicShapeRadius& other, double progress) const 146 BasicShapeRadius blend(const BasicShapeRadius& other, double progress) const
193 { 147 {
194 if (m_type != Value || other.type() != Value) 148 if (m_type != Value || other.type() != Value)
195 return BasicShapeRadius(other); 149 return BasicShapeRadius(other);
196 150
197 return BasicShapeRadius(m_value.blend(other.value(), progress, ValueRang eAll)); 151 return BasicShapeRadius(m_value.blend(other.value(), progress, ValueRang eNonNegative));
198 } 152 }
199 153
200 private: 154 private:
201 Length m_value; 155 Length m_value;
202 Type m_type; 156 Type m_type;
203 157
204 }; 158 };
205 159
206 class BasicShapeCircle FINAL : public BasicShape { 160 class BasicShapeCircle FINAL : public BasicShape {
207 public: 161 public:
(...skipping 16 matching lines...) Expand all
224 private: 178 private:
225 BasicShapeCircle() { } 179 BasicShapeCircle() { }
226 180
227 BasicShapeCenterCoordinate m_centerX; 181 BasicShapeCenterCoordinate m_centerX;
228 BasicShapeCenterCoordinate m_centerY; 182 BasicShapeCenterCoordinate m_centerY;
229 BasicShapeRadius m_radius; 183 BasicShapeRadius m_radius;
230 }; 184 };
231 185
232 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeCircle); 186 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeCircle);
233 187
234 class DeprecatedBasicShapeCircle FINAL : public BasicShape {
235 public:
236 static PassRefPtr<DeprecatedBasicShapeCircle> create() { return adoptRef(new DeprecatedBasicShapeCircle); }
237
238 Length centerX() const { return m_centerX; }
239 Length centerY() const { return m_centerY; }
240 Length radius() const { return m_radius; }
241
242 void setCenterX(Length centerX) { m_centerX = centerX; }
243 void setCenterY(Length centerY) { m_centerY = centerY; }
244 void setRadius(Length radius) { m_radius = radius; }
245
246 virtual void path(Path&, const FloatRect&) OVERRIDE;
247 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE;
248 virtual bool operator==(const BasicShape&) const OVERRIDE;
249
250 virtual Type type() const OVERRIDE { return DeprecatedBasicShapeCircleType; }
251 private:
252 DeprecatedBasicShapeCircle() { }
253
254 Length m_centerX;
255 Length m_centerY;
256 Length m_radius;
257 };
258
259 DEFINE_BASICSHAPE_TYPE_CASTS(DeprecatedBasicShapeCircle);
260
261 class BasicShapeEllipse FINAL : public BasicShape { 188 class BasicShapeEllipse FINAL : public BasicShape {
262 public: 189 public:
263 static PassRefPtr<BasicShapeEllipse> create() { return adoptRef(new BasicSha peEllipse); } 190 static PassRefPtr<BasicShapeEllipse> create() { return adoptRef(new BasicSha peEllipse); }
264 191
265 const BasicShapeCenterCoordinate& centerX() const { return m_centerX; } 192 const BasicShapeCenterCoordinate& centerX() const { return m_centerX; }
266 const BasicShapeCenterCoordinate& centerY() const { return m_centerY; } 193 const BasicShapeCenterCoordinate& centerY() const { return m_centerY; }
267 const BasicShapeRadius& radiusX() const { return m_radiusX; } 194 const BasicShapeRadius& radiusX() const { return m_radiusX; }
268 const BasicShapeRadius& radiusY() const { return m_radiusY; } 195 const BasicShapeRadius& radiusY() const { return m_radiusY; }
269 float floatValueForRadiusInBox(const BasicShapeRadius&, float center, float boxWidthOrHeight) const; 196 float floatValueForRadiusInBox(const BasicShapeRadius&, float center, float boxWidthOrHeight) const;
270 197
(...skipping 11 matching lines...) Expand all
282 BasicShapeEllipse() { } 209 BasicShapeEllipse() { }
283 210
284 BasicShapeCenterCoordinate m_centerX; 211 BasicShapeCenterCoordinate m_centerX;
285 BasicShapeCenterCoordinate m_centerY; 212 BasicShapeCenterCoordinate m_centerY;
286 BasicShapeRadius m_radiusX; 213 BasicShapeRadius m_radiusX;
287 BasicShapeRadius m_radiusY; 214 BasicShapeRadius m_radiusY;
288 }; 215 };
289 216
290 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeEllipse); 217 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeEllipse);
291 218
292 class DeprecatedBasicShapeEllipse FINAL : public BasicShape {
293 public:
294 static PassRefPtr<DeprecatedBasicShapeEllipse> create() { return adoptRef(ne w DeprecatedBasicShapeEllipse); }
295
296 Length centerX() const { return m_centerX; }
297 Length centerY() const { return m_centerY; }
298 Length radiusX() const { return m_radiusX; }
299 Length radiusY() const { return m_radiusY; }
300
301 void setCenterX(Length centerX) { m_centerX = centerX; }
302 void setCenterY(Length centerY) { m_centerY = centerY; }
303 void setRadiusX(Length radiusX) { m_radiusX = radiusX; }
304 void setRadiusY(Length radiusY) { m_radiusY = radiusY; }
305
306 virtual void path(Path&, const FloatRect&) OVERRIDE;
307 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE;
308 virtual bool operator==(const BasicShape&) const OVERRIDE;
309
310 virtual Type type() const OVERRIDE { return DeprecatedBasicShapeEllipseType; }
311 private:
312 DeprecatedBasicShapeEllipse() { }
313
314 Length m_centerX;
315 Length m_centerY;
316 Length m_radiusX;
317 Length m_radiusY;
318 };
319
320 DEFINE_BASICSHAPE_TYPE_CASTS(DeprecatedBasicShapeEllipse);
321
322 class BasicShapePolygon FINAL : public BasicShape { 219 class BasicShapePolygon FINAL : public BasicShape {
323 public: 220 public:
324 static PassRefPtr<BasicShapePolygon> create() { return adoptRef(new BasicSha pePolygon); } 221 static PassRefPtr<BasicShapePolygon> create() { return adoptRef(new BasicSha pePolygon); }
325 222
326 const Vector<Length>& values() const { return m_values; } 223 const Vector<Length>& values() const { return m_values; }
327 Length getXAt(unsigned i) const { return m_values.at(2 * i); } 224 Length getXAt(unsigned i) const { return m_values.at(2 * i); }
328 Length getYAt(unsigned i) const { return m_values.at(2 * i + 1); } 225 Length getYAt(unsigned i) const { return m_values.at(2 * i + 1); }
329 226
330 void setWindRule(WindRule windRule) { m_windRule = windRule; } 227 void setWindRule(WindRule windRule) { m_windRule = windRule; }
331 void appendPoint(Length x, Length y) { m_values.append(x); m_values.append(y ); } 228 void appendPoint(Length x, Length y) { m_values.append(x); m_values.append(y ); }
332 229
333 virtual void path(Path&, const FloatRect&) OVERRIDE; 230 virtual void path(Path&, const FloatRect&) OVERRIDE;
334 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE; 231 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE;
335 virtual bool operator==(const BasicShape&) const OVERRIDE; 232 virtual bool operator==(const BasicShape&) const OVERRIDE;
336 233
337 virtual WindRule windRule() const OVERRIDE { return m_windRule; } 234 virtual WindRule windRule() const OVERRIDE { return m_windRule; }
338 235
339 virtual Type type() const OVERRIDE { return BasicShapePolygonType; } 236 virtual Type type() const OVERRIDE { return BasicShapePolygonType; }
340 private: 237 private:
341 BasicShapePolygon() 238 BasicShapePolygon()
342 : m_windRule(RULE_NONZERO) 239 : m_windRule(RULE_NONZERO)
343 { } 240 { }
344 241
345 WindRule m_windRule; 242 WindRule m_windRule;
346 Vector<Length> m_values; 243 Vector<Length> m_values;
347 }; 244 };
348 245
349 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapePolygon); 246 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapePolygon);
350 247
351 class BasicShapeInsetRectangle FINAL : public BasicShape {
352 public:
353 static PassRefPtr<BasicShapeInsetRectangle> create() { return adoptRef(new B asicShapeInsetRectangle); }
354
355 Length top() const { return m_top; }
356 Length right() const { return m_right; }
357 Length bottom() const { return m_bottom; }
358 Length left() const { return m_left; }
359 Length cornerRadiusX() const { return m_cornerRadiusX; }
360 Length cornerRadiusY() const { return m_cornerRadiusY; }
361
362 void setTop(Length top) { m_top = top; }
363 void setRight(Length right) { m_right = right; }
364 void setBottom(Length bottom) { m_bottom = bottom; }
365 void setLeft(Length left) { m_left = left; }
366 void setCornerRadiusX(Length radiusX)
367 {
368 m_cornerRadiusX = radiusX;
369 }
370 void setCornerRadiusY(Length radiusY)
371 {
372 m_cornerRadiusY = radiusY;
373 }
374
375 virtual void path(Path&, const FloatRect&) OVERRIDE;
376 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE;
377 virtual bool operator==(const BasicShape&) const OVERRIDE;
378
379 virtual Type type() const OVERRIDE { return BasicShapeInsetRectangleType; }
380 private:
381 BasicShapeInsetRectangle() { }
382
383 Length m_right;
384 Length m_top;
385 Length m_bottom;
386 Length m_left;
387 Length m_cornerRadiusX;
388 Length m_cornerRadiusY;
389 };
390
391 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInsetRectangle);
392
393 class BasicShapeInset : public BasicShape { 248 class BasicShapeInset : public BasicShape {
394 public: 249 public:
395 static PassRefPtr<BasicShapeInset> create() { return adoptRef(new BasicShape Inset); } 250 static PassRefPtr<BasicShapeInset> create() { return adoptRef(new BasicShape Inset); }
396 251
397 const Length& top() const { return m_top; } 252 const Length& top() const { return m_top; }
398 const Length& right() const { return m_right; } 253 const Length& right() const { return m_right; }
399 const Length& bottom() const { return m_bottom; } 254 const Length& bottom() const { return m_bottom; }
400 const Length& left() const { return m_left; } 255 const Length& left() const { return m_left; }
401 256
402 const LengthSize& topLeftRadius() const { return m_topLeftRadius; } 257 const LengthSize& topLeftRadius() const { return m_topLeftRadius; }
(...skipping 27 matching lines...) Expand all
430 LengthSize m_topLeftRadius; 285 LengthSize m_topLeftRadius;
431 LengthSize m_topRightRadius; 286 LengthSize m_topRightRadius;
432 LengthSize m_bottomRightRadius; 287 LengthSize m_bottomRightRadius;
433 LengthSize m_bottomLeftRadius; 288 LengthSize m_bottomLeftRadius;
434 }; 289 };
435 290
436 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInset); 291 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInset);
437 292
438 } 293 }
439 #endif 294 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/shapes/ShapeInsideInfo.cpp ('k') | Source/core/rendering/style/BasicShapes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698