OLD | NEW |
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 22 matching lines...) Expand all Loading... |
33 #include "core/rendering/style/RenderStyleConstants.h" | 33 #include "core/rendering/style/RenderStyleConstants.h" |
34 #include "platform/Length.h" | 34 #include "platform/Length.h" |
35 #include "platform/graphics/WindRule.h" | 35 #include "platform/graphics/WindRule.h" |
36 #include "wtf/RefCounted.h" | 36 #include "wtf/RefCounted.h" |
37 #include "wtf/RefPtr.h" | 37 #include "wtf/RefPtr.h" |
38 #include "wtf/Vector.h" | 38 #include "wtf/Vector.h" |
39 | 39 |
40 namespace WebCore { | 40 namespace WebCore { |
41 | 41 |
42 class FloatRect; | 42 class FloatRect; |
| 43 class FloatSize; |
43 class Path; | 44 class Path; |
44 | 45 |
45 class BasicShape : public RefCounted<BasicShape> { | 46 class BasicShape : public RefCounted<BasicShape> { |
46 public: | 47 public: |
47 virtual ~BasicShape() { } | 48 virtual ~BasicShape() { } |
48 | 49 |
49 enum Type { | 50 enum Type { |
50 BasicShapeRectangleType, | 51 BasicShapeRectangleType, |
51 DeprecatedBasicShapeCircleType, | 52 DeprecatedBasicShapeCircleType, |
52 DeprecatedBasicShapeEllipseType, | 53 DeprecatedBasicShapeEllipseType, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 }; | 136 }; |
136 BasicShapeCenterCoordinate() : m_keyword(None), m_length(Undefined) { } | 137 BasicShapeCenterCoordinate() : m_keyword(None), m_length(Undefined) { } |
137 explicit BasicShapeCenterCoordinate(Length length) : m_keyword(None), m_leng
th(length) { } | 138 explicit BasicShapeCenterCoordinate(Length length) : m_keyword(None), m_leng
th(length) { } |
138 BasicShapeCenterCoordinate(Keyword keyword, Length length) : m_keyword(keywo
rd), m_length(length) { } | 139 BasicShapeCenterCoordinate(Keyword keyword, Length length) : m_keyword(keywo
rd), m_length(length) { } |
139 BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other) : m_keyw
ord(other.keyword()), m_length(other.length()) { } | 140 BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other) : m_keyw
ord(other.keyword()), m_length(other.length()) { } |
140 bool operator==(const BasicShapeCenterCoordinate& other) const { return m_ke
yword == other.m_keyword && m_length == other.m_length; } | 141 bool operator==(const BasicShapeCenterCoordinate& other) const { return m_ke
yword == other.m_keyword && m_length == other.m_length; } |
141 | 142 |
142 Keyword keyword() const { return m_keyword; } | 143 Keyword keyword() const { return m_keyword; } |
143 const Length& length() const { return m_length; } | 144 const Length& length() const { return m_length; } |
144 | 145 |
| 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 |
145 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, do
uble progress) const | 152 BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, do
uble progress) const |
146 { | 153 { |
147 if (m_keyword != None || other.keyword() != None) | 154 if (m_keyword != None || other.keyword() != None) |
148 return BasicShapeCenterCoordinate(other); | 155 return BasicShapeCenterCoordinate(other); |
149 | 156 |
150 return BasicShapeCenterCoordinate(m_length.blend(other.length(), progres
s, ValueRangeAll)); | 157 return BasicShapeCenterCoordinate(m_length.blend(other.length(), progres
s, ValueRangeAll)); |
151 } | 158 } |
152 | 159 |
153 private: | 160 private: |
154 Keyword m_keyword; | 161 Keyword m_keyword; |
155 Length m_length; | 162 Length m_length; |
156 }; | 163 }; |
157 | 164 |
158 class BasicShapeRadius { | 165 class BasicShapeRadius { |
159 public: | 166 public: |
160 enum Type { | 167 enum Type { |
161 Value, | 168 Value, |
162 ClosestSide, | 169 ClosestSide, |
163 FarthestSide | 170 FarthestSide |
164 }; | 171 }; |
165 BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { } | 172 BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { } |
166 explicit BasicShapeRadius(Length v) : m_value(v), m_type(Value) { } | 173 explicit BasicShapeRadius(Length v) : m_value(v), m_type(Value) { } |
167 explicit BasicShapeRadius(Type t) : m_value(Undefined), m_type(t) { } | 174 explicit BasicShapeRadius(Type t) : m_value(Undefined), m_type(t) { } |
168 BasicShapeRadius(const BasicShapeRadius& other) : m_value(other.value()), m_
type(other.type()) { } | 175 BasicShapeRadius(const BasicShapeRadius& other) : m_value(other.value()), m_
type(other.type()) { } |
169 bool operator==(const BasicShapeRadius& other) const { return m_type == othe
r.m_type && m_value == other.m_value; } | 176 bool operator==(const BasicShapeRadius& other) const { return m_type == othe
r.m_type && m_value == other.m_value; } |
170 | 177 |
171 const Length& value() const { return m_value; } | 178 const Length& value() const { return m_value; } |
172 Type type() const { return m_type; } | 179 Type type() const { return m_type; } |
173 | 180 |
| 181 bool canBlend(const BasicShapeRadius& other) const |
| 182 { |
| 183 // FIXME determine how to interpolate between keywords. See issue 330248
. |
| 184 return m_type == Value && other.type() == Value; |
| 185 } |
| 186 |
174 BasicShapeRadius blend(const BasicShapeRadius& other, double progress) const | 187 BasicShapeRadius blend(const BasicShapeRadius& other, double progress) const |
175 { | 188 { |
176 if (m_type != Value || other.type() != Value) | 189 if (m_type != Value || other.type() != Value) |
177 return BasicShapeRadius(other); | 190 return BasicShapeRadius(other); |
178 | 191 |
179 return BasicShapeRadius(m_value.blend(other.value(), progress, ValueRang
eAll)); | 192 return BasicShapeRadius(m_value.blend(other.value(), progress, ValueRang
eAll)); |
180 } | 193 } |
181 | 194 |
182 private: | 195 private: |
183 Length m_value; | 196 Length m_value; |
184 Type m_type; | 197 Type m_type; |
185 | 198 |
186 }; | 199 }; |
187 | 200 |
188 class BasicShapeCircle : public BasicShape { | 201 class BasicShapeCircle : public BasicShape { |
189 public: | 202 public: |
190 static PassRefPtr<BasicShapeCircle> create() { return adoptRef(new BasicShap
eCircle); } | 203 static PassRefPtr<BasicShapeCircle> create() { return adoptRef(new BasicShap
eCircle); } |
191 | 204 |
192 const BasicShapeCenterCoordinate& centerX() const { return m_centerX; } | 205 const BasicShapeCenterCoordinate& centerX() const { return m_centerX; } |
193 const BasicShapeCenterCoordinate& centerY() const { return m_centerY; } | 206 const BasicShapeCenterCoordinate& centerY() const { return m_centerY; } |
194 const BasicShapeRadius& radius() const { return m_radius; } | 207 const BasicShapeRadius& radius() const { return m_radius; } |
195 | 208 |
| 209 float floatValueForRadiusInBox(FloatSize) const; |
196 void setCenterX(BasicShapeCenterCoordinate centerX) { m_centerX = centerX; } | 210 void setCenterX(BasicShapeCenterCoordinate centerX) { m_centerX = centerX; } |
197 void setCenterY(BasicShapeCenterCoordinate centerY) { m_centerY = centerY; } | 211 void setCenterY(BasicShapeCenterCoordinate centerY) { m_centerY = centerY; } |
198 void setRadius(BasicShapeRadius radius) { m_radius = radius; } | 212 void setRadius(BasicShapeRadius radius) { m_radius = radius; } |
199 | 213 |
200 virtual void path(Path&, const FloatRect&) OVERRIDE; | 214 virtual void path(Path&, const FloatRect&) OVERRIDE; |
201 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI
DE; | 215 virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRI
DE; |
202 virtual bool operator==(const BasicShape&) const OVERRIDE; | 216 virtual bool operator==(const BasicShape&) const OVERRIDE; |
203 | 217 |
204 virtual Type type() const { return BasicShapeCircleType; } | 218 virtual Type type() const { return BasicShapeCircleType; } |
205 private: | 219 private: |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 Length m_bottom; | 379 Length m_bottom; |
366 Length m_left; | 380 Length m_left; |
367 Length m_cornerRadiusX; | 381 Length m_cornerRadiusX; |
368 Length m_cornerRadiusY; | 382 Length m_cornerRadiusY; |
369 }; | 383 }; |
370 | 384 |
371 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInsetRectangle); | 385 DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeInsetRectangle); |
372 | 386 |
373 } | 387 } |
374 #endif | 388 #endif |
OLD | NEW |