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

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

Issue 115253003: Layout support for new circle shape syntax (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add misisng test change for animations/interpolation/shape-outside.html 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
« no previous file with comments | « Source/core/rendering/shapes/Shape.cpp ('k') | Source/core/rendering/style/BasicShapes.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 }; 134 };
135 BasicShapeCenterCoordinate() : m_keyword(None), m_length(Undefined) { } 135 BasicShapeCenterCoordinate() : m_keyword(None), m_length(Undefined) { }
136 explicit BasicShapeCenterCoordinate(Length length) : m_keyword(None), m_leng th(length) { } 136 explicit BasicShapeCenterCoordinate(Length length) : m_keyword(None), m_leng th(length) { }
137 BasicShapeCenterCoordinate(Keyword keyword, Length length) : m_keyword(keywo rd), m_length(length) { } 137 BasicShapeCenterCoordinate(Keyword keyword, Length length) : m_keyword(keywo rd), m_length(length) { }
138 BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other) : m_keyw ord(other.keyword()), m_length(other.length()) { } 138 BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other) : m_keyw ord(other.keyword()), m_length(other.length()) { }
139 bool operator==(const BasicShapeCenterCoordinate& other) const { return m_ke yword == other.m_keyword && m_length == other.m_length; } 139 bool operator==(const BasicShapeCenterCoordinate& other) const { return m_ke yword == other.m_keyword && m_length == other.m_length; }
140 140
141 Keyword keyword() const { return m_keyword; } 141 Keyword keyword() const { return m_keyword; }
142 const Length& length() const { return m_length; } 142 const Length& length() const { return m_length; }
143 143
144 bool canBlend(const BasicShapeCenterCoordinate& other) const
145 {
146 // FIXME determine how to interpolate between keywords. See bug 125108.
Bem Jones-Bey (adobe) 2013/12/19 23:08:48 You could merge in the interpolation patch to this
147 return m_keyword == None && other.keyword() == None;
148 }
149
144 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, do uble progress) const 150 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, do uble progress) const
145 { 151 {
146 if (m_keyword != None || other.keyword() != None) 152 if (m_keyword != None || other.keyword() != None)
147 return BasicShapeCenterCoordinate(other); 153 return BasicShapeCenterCoordinate(other);
148 154
149 return BasicShapeCenterCoordinate(m_length.blend(other.length(), progres s, ValueRangeAll)); 155 return BasicShapeCenterCoordinate(m_length.blend(other.length(), progres s, ValueRangeAll));
150 } 156 }
151 157
152 private: 158 private:
153 Keyword m_keyword; 159 Keyword m_keyword;
154 Length m_length; 160 Length m_length;
155 }; 161 };
156 162
157 class BasicShapeRadius { 163 class BasicShapeRadius {
158 public: 164 public:
159 enum Type { 165 enum Type {
160 Value, 166 Value,
161 ClosestSide, 167 ClosestSide,
162 FarthestSide 168 FarthestSide
163 }; 169 };
164 BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { } 170 BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { }
165 explicit BasicShapeRadius(Length v) : m_value(v), m_type(Value) { } 171 explicit BasicShapeRadius(Length v) : m_value(v), m_type(Value) { }
166 explicit BasicShapeRadius(Type t) : m_value(Undefined), m_type(t) { } 172 explicit BasicShapeRadius(Type t) : m_value(Undefined), m_type(t) { }
167 BasicShapeRadius(const BasicShapeRadius& other) : m_value(other.value()), m_ type(other.type()) { } 173 BasicShapeRadius(const BasicShapeRadius& other) : m_value(other.value()), m_ type(other.type()) { }
168 bool operator==(const BasicShapeRadius& other) const { return m_type == othe r.m_type && m_value == other.m_value; } 174 bool operator==(const BasicShapeRadius& other) const { return m_type == othe r.m_type && m_value == other.m_value; }
169 175
170 const Length& value() const { return m_value; } 176 const Length& value() const { return m_value; }
171 Type type() const { return m_type; } 177 Type type() const { return m_type; }
172 178
179 bool canBlend(const BasicShapeRadius& other) const
180 {
181 // FIXME determine how to interpolate between keywords. See bug 125108.
Bem Jones-Bey (adobe) 2013/12/19 23:08:48 Ditto.
182 return m_type == Value && other.type() == Value;
183 }
184
173 BasicShapeRadius blend(const BasicShapeRadius& other, double progress) const 185 BasicShapeRadius blend(const BasicShapeRadius& other, double progress) const
174 { 186 {
175 if (m_type != Value || other.type() != Value) 187 if (m_type != Value || other.type() != Value)
176 return BasicShapeRadius(other); 188 return BasicShapeRadius(other);
177 189
178 return BasicShapeRadius(m_value.blend(other.value(), progress, ValueRang eAll)); 190 return BasicShapeRadius(m_value.blend(other.value(), progress, ValueRang eAll));
179 } 191 }
180 192
181 private: 193 private:
182 Length m_value; 194 Length m_value;
183 Type m_type; 195 Type m_type;
184 196
185 }; 197 };
186 198
187 class BasicShapeCircle : public BasicShape { 199 class BasicShapeCircle : public BasicShape {
188 public: 200 public:
189 static PassRefPtr<BasicShapeCircle> create() { return adoptRef(new BasicShap eCircle); } 201 static PassRefPtr<BasicShapeCircle> create() { return adoptRef(new BasicShap eCircle); }
190 202
191 const BasicShapeCenterCoordinate& centerX() const { return m_centerX; } 203 const BasicShapeCenterCoordinate& centerX() const { return m_centerX; }
192 const BasicShapeCenterCoordinate& centerY() const { return m_centerY; } 204 const BasicShapeCenterCoordinate& centerY() const { return m_centerY; }
193 const BasicShapeRadius& radius() const { return m_radius; } 205 const BasicShapeRadius& radius() const { return m_radius; }
194 206
207 float floatValueForRadiusInBox(float boxWidth, float boxHeight) const;
195 void setCenterX(BasicShapeCenterCoordinate centerX) { m_centerX = centerX; } 208 void setCenterX(BasicShapeCenterCoordinate centerX) { m_centerX = centerX; }
196 void setCenterY(BasicShapeCenterCoordinate centerY) { m_centerY = centerY; } 209 void setCenterY(BasicShapeCenterCoordinate centerY) { m_centerY = centerY; }
197 void setRadius(BasicShapeRadius radius) { m_radius = radius; } 210 void setRadius(BasicShapeRadius radius) { m_radius = radius; }
198 211
199 virtual void path(Path&, const FloatRect&) OVERRIDE; 212 virtual void path(Path&, const FloatRect&) OVERRIDE;
200 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE; 213 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI DE;
201 virtual bool operator==(const BasicShape&) const OVERRIDE; 214 virtual bool operator==(const BasicShape&) const OVERRIDE;
202 215
203 virtual Type type() const { return BasicShapeCircleType; } 216 virtual Type type() const { return BasicShapeCircleType; }
204 private: 217 private:
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 Length m_bottom; 347 Length m_bottom;
335 Length m_left; 348 Length m_left;
336 Length m_cornerRadiusX; 349 Length m_cornerRadiusX;
337 Length m_cornerRadiusY; 350 Length m_cornerRadiusY;
338 }; 351 };
339 352
340 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInsetRectangle); 353 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInsetRectangle);
341 354
342 } 355 }
343 #endif 356 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/shapes/Shape.cpp ('k') | Source/core/rendering/style/BasicShapes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698