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

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

Issue 144373002: [CSS Shapes] Basic shapes' computed position should be a horizontal and vertical offset (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Try to fix tests Created 6 years, 11 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 LayoutBox m_layoutBox; 80 LayoutBox m_layoutBox;
81 }; 81 };
82 82
83 #define DEFINE_BASICSHAPE_TYPE_CASTS(thisType) \ 83 #define DEFINE_BASICSHAPE_TYPE_CASTS(thisType) \
84 DEFINE_TYPE_CASTS(thisType, BasicShape, value, value->type() == BasicShape:: thisType##Type, value.type() == BasicShape::thisType##Type) 84 DEFINE_TYPE_CASTS(thisType, BasicShape, value, value->type() == BasicShape:: thisType##Type, value.type() == BasicShape::thisType##Type)
85 85
86 class BasicShapeRectangle FINAL : public BasicShape { 86 class BasicShapeRectangle FINAL : public BasicShape {
87 public: 87 public:
88 static PassRefPtr<BasicShapeRectangle> create() { return adoptRef(new BasicS hapeRectangle); } 88 static PassRefPtr<BasicShapeRectangle> create() { return adoptRef(new BasicS hapeRectangle); }
89 89
90 Length x() const { return m_x; } 90 const Length& x() const { return m_x; }
Bear Travis 2014/01/23 22:04:42 Is this change necessary to this patch? It feels l
91 Length y() const { return m_y; } 91 const Length& y() const { return m_y; }
92 Length width() const { return m_width; } 92 const Length& width() const { return m_width; }
93 Length height() const { return m_height; } 93 const Length& height() const { return m_height; }
94 Length cornerRadiusX() const { return m_cornerRadiusX; } 94 const Length& cornerRadiusX() const { return m_cornerRadiusX; }
95 Length cornerRadiusY() const { return m_cornerRadiusY; } 95 const Length& cornerRadiusY() const { return m_cornerRadiusY; }
96 96
97 void setX(Length x) { m_x = x; } 97 void setX(Length x) { m_x = x; }
98 void setY(Length y) { m_y = y; } 98 void setY(Length y) { m_y = y; }
99 void setWidth(Length width) { m_width = width; } 99 void setWidth(Length width) { m_width = width; }
100 void setHeight(Length height) { m_height = height; } 100 void setHeight(Length height) { m_height = height; }
101 void setCornerRadiusX(Length radiusX) 101 void setCornerRadiusX(Length radiusX)
102 { 102 {
103 m_cornerRadiusX = radiusX; 103 m_cornerRadiusX = radiusX;
104 } 104 }
105 void setCornerRadiusY(Length radiusY) 105 void setCornerRadiusY(Length radiusY)
(...skipping 14 matching lines...) Expand all
120 Length m_width; 120 Length m_width;
121 Length m_height; 121 Length m_height;
122 Length m_cornerRadiusX; 122 Length m_cornerRadiusX;
123 Length m_cornerRadiusY; 123 Length m_cornerRadiusY;
124 }; 124 };
125 125
126 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeRectangle); 126 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeRectangle);
127 127
128 class BasicShapeCenterCoordinate { 128 class BasicShapeCenterCoordinate {
129 public: 129 public:
130 enum Keyword { 130 enum Direction {
131 None, 131 TopLeft,
132 Top, 132 BottomRight
133 Right,
134 Bottom,
135 Left
136 }; 133 };
137 BasicShapeCenterCoordinate() : m_keyword(None), m_length(Undefined) { } 134 BasicShapeCenterCoordinate()
138 explicit BasicShapeCenterCoordinate(Length length) : m_keyword(None), m_leng th(length) { } 135 : m_direction(TopLeft)
139 BasicShapeCenterCoordinate(Keyword keyword, Length length) : m_keyword(keywo rd), m_length(length) { } 136 , m_length(Undefined)
140 BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other) : m_keyw ord(other.keyword()), m_length(other.length()) { } 137 {
141 bool operator==(const BasicShapeCenterCoordinate& other) const { return m_ke yword == other.m_keyword && m_length == other.m_length; } 138 updateComputedLength();
139 }
142 140
143 Keyword keyword() const { return m_keyword; } 141 BasicShapeCenterCoordinate(Direction direction, Length length)
142 : m_direction(direction)
143 , m_length(length)
144 {
145 updateComputedLength();
146 }
147
148 BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other)
149 : m_direction(other.direction())
150 , m_length(other.length())
151 , m_computedLength(other.m_computedLength)
152 {
153 }
154
155 bool operator==(const BasicShapeCenterCoordinate& other) const { return m_di rection == other.m_direction && m_length == other.m_length && m_computedLength = = other.m_computedLength; }
156
157 Direction direction() const { return m_direction; }
144 const Length& length() const { return m_length; } 158 const Length& length() const { return m_length; }
145 159 const Length& computedLength() const { return m_computedLength; }
146 bool canBlend(const BasicShapeCenterCoordinate& other) const
147 {
148 // FIXME determine how to interpolate between keywords. See issue 330248 .
149 return m_keyword == None && other.keyword() == None;
150 }
151 160
152 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, do uble progress) const 161 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, do uble progress) const
153 { 162 {
154 if (m_keyword != None || other.keyword() != None) 163 return BasicShapeCenterCoordinate(TopLeft, m_computedLength.blend(other. m_computedLength, progress, ValueRangeAll));
155 return BasicShapeCenterCoordinate(other);
156
157 return BasicShapeCenterCoordinate(m_length.blend(other.length(), progres s, ValueRangeAll));
158 } 164 }
159 165
160 private: 166 private:
161 Keyword m_keyword; 167 Direction m_direction;
162 Length m_length; 168 Length m_length;
169 Length m_computedLength;
170
171 void updateComputedLength();
163 }; 172 };
164 173
165 class BasicShapeRadius { 174 class BasicShapeRadius {
166 public: 175 public:
167 enum Type { 176 enum Type {
168 Value, 177 Value,
169 ClosestSide, 178 ClosestSide,
170 FarthestSide 179 FarthestSide
171 }; 180 };
172 BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { } 181 BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 BasicShapeCenterCoordinate m_centerY; 232 BasicShapeCenterCoordinate m_centerY;
224 BasicShapeRadius m_radius; 233 BasicShapeRadius m_radius;
225 }; 234 };
226 235
227 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeCircle); 236 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeCircle);
228 237
229 class DeprecatedBasicShapeCircle FINAL : public BasicShape { 238 class DeprecatedBasicShapeCircle FINAL : public BasicShape {
230 public: 239 public:
231 static PassRefPtr<DeprecatedBasicShapeCircle> create() { return adoptRef(new DeprecatedBasicShapeCircle); } 240 static PassRefPtr<DeprecatedBasicShapeCircle> create() { return adoptRef(new DeprecatedBasicShapeCircle); }
232 241
233 Length centerX() const { return m_centerX; } 242 const Length& centerX() const { return m_centerX; }
234 Length centerY() const { return m_centerY; } 243 const Length& centerY() const { return m_centerY; }
235 Length radius() const { return m_radius; } 244 const Length& radius() const { return m_radius; }
236 245
237 void setCenterX(Length centerX) { m_centerX = centerX; } 246 void setCenterX(Length centerX) { m_centerX = centerX; }
238 void setCenterY(Length centerY) { m_centerY = centerY; } 247 void setCenterY(Length centerY) { m_centerY = centerY; }
239 void setRadius(Length radius) { m_radius = radius; } 248 void setRadius(Length radius) { m_radius = radius; }
240 249
241 virtual void path(Path&, const FloatRect&) OVERRIDE; 250 virtual void path(Path&, const FloatRect&) OVERRIDE;
242 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE; 251 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE;
243 virtual bool operator==(const BasicShape&) const OVERRIDE; 252 virtual bool operator==(const BasicShape&) const OVERRIDE;
244 253
245 virtual Type type() const OVERRIDE { return DeprecatedBasicShapeCircleType; } 254 virtual Type type() const OVERRIDE { return DeprecatedBasicShapeCircleType; }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 WindRule m_windRule; 349 WindRule m_windRule;
341 Vector<Length> m_values; 350 Vector<Length> m_values;
342 }; 351 };
343 352
344 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapePolygon); 353 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapePolygon);
345 354
346 class BasicShapeInsetRectangle FINAL : public BasicShape { 355 class BasicShapeInsetRectangle FINAL : public BasicShape {
347 public: 356 public:
348 static PassRefPtr<BasicShapeInsetRectangle> create() { return adoptRef(new B asicShapeInsetRectangle); } 357 static PassRefPtr<BasicShapeInsetRectangle> create() { return adoptRef(new B asicShapeInsetRectangle); }
349 358
350 Length top() const { return m_top; } 359 const Length& top() const { return m_top; }
351 Length right() const { return m_right; } 360 const Length& right() const { return m_right; }
352 Length bottom() const { return m_bottom; } 361 const Length& bottom() const { return m_bottom; }
353 Length left() const { return m_left; } 362 const Length& left() const { return m_left; }
354 Length cornerRadiusX() const { return m_cornerRadiusX; } 363 const Length& cornerRadiusX() const { return m_cornerRadiusX; }
355 Length cornerRadiusY() const { return m_cornerRadiusY; } 364 const Length& cornerRadiusY() const { return m_cornerRadiusY; }
356 365
357 void setTop(Length top) { m_top = top; } 366 void setTop(Length top) { m_top = top; }
358 void setRight(Length right) { m_right = right; } 367 void setRight(Length right) { m_right = right; }
359 void setBottom(Length bottom) { m_bottom = bottom; } 368 void setBottom(Length bottom) { m_bottom = bottom; }
360 void setLeft(Length left) { m_left = left; } 369 void setLeft(Length left) { m_left = left; }
361 void setCornerRadiusX(Length radiusX) 370 void setCornerRadiusX(Length radiusX)
362 { 371 {
363 m_cornerRadiusX = radiusX; 372 m_cornerRadiusX = radiusX;
364 } 373 }
365 void setCornerRadiusY(Length radiusY) 374 void setCornerRadiusY(Length radiusY)
(...skipping 14 matching lines...) Expand all
380 Length m_bottom; 389 Length m_bottom;
381 Length m_left; 390 Length m_left;
382 Length m_cornerRadiusX; 391 Length m_cornerRadiusX;
383 Length m_cornerRadiusY; 392 Length m_cornerRadiusY;
384 }; 393 };
385 394
386 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInsetRectangle); 395 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInsetRectangle);
387 396
388 } 397 }
389 #endif 398 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698