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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasPath.cpp

Issue 2826773002: Rename CanvasPathMethods to CanvasPath (Closed)
Patch Set: x Created 3 years, 8 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) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
5 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> 7 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
8 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 8 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
9 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved.
10 * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved. 10 * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved.
(...skipping 15 matching lines...) Expand all
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
31 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 31 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
32 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE. 33 * SUCH DAMAGE.
34 */ 34 */
35 35
36 #include "modules/canvas2d/CanvasPathMethods.h" 36 #include "modules/canvas2d/CanvasPath.h"
37 37
38 #include "bindings/core/v8/ExceptionState.h" 38 #include "bindings/core/v8/ExceptionState.h"
39 #include "core/dom/ExceptionCode.h" 39 #include "core/dom/ExceptionCode.h"
40 #include "platform/geometry/FloatRect.h" 40 #include "platform/geometry/FloatRect.h"
41 #include "platform/transforms/AffineTransform.h" 41 #include "platform/transforms/AffineTransform.h"
42 #include "platform/wtf/MathExtras.h" 42 #include "platform/wtf/MathExtras.h"
43 43
44 namespace blink { 44 namespace blink {
45 45
46 void CanvasPathMethods::closePath() { 46 void CanvasPath::closePath() {
47 if (path_.IsEmpty()) 47 if (path_.IsEmpty())
48 return; 48 return;
49 49
50 FloatRect bound_rect = path_.BoundingRect(); 50 FloatRect bound_rect = path_.BoundingRect();
51 if (bound_rect.Width() || bound_rect.Height()) 51 if (bound_rect.Width() || bound_rect.Height())
52 path_.CloseSubpath(); 52 path_.CloseSubpath();
53 } 53 }
54 54
55 void CanvasPathMethods::moveTo(float x, float y) { 55 void CanvasPath::moveTo(float x, float y) {
56 if (!std::isfinite(x) || !std::isfinite(y)) 56 if (!std::isfinite(x) || !std::isfinite(y))
57 return; 57 return;
58 if (!IsTransformInvertible()) 58 if (!IsTransformInvertible())
59 return; 59 return;
60 path_.MoveTo(FloatPoint(x, y)); 60 path_.MoveTo(FloatPoint(x, y));
61 } 61 }
62 62
63 void CanvasPathMethods::lineTo(float x, float y) { 63 void CanvasPath::lineTo(float x, float y) {
64 if (!std::isfinite(x) || !std::isfinite(y)) 64 if (!std::isfinite(x) || !std::isfinite(y))
65 return; 65 return;
66 if (!IsTransformInvertible()) 66 if (!IsTransformInvertible())
67 return; 67 return;
68 68
69 FloatPoint p1 = FloatPoint(x, y); 69 FloatPoint p1 = FloatPoint(x, y);
70 if (!path_.HasCurrentPoint()) 70 if (!path_.HasCurrentPoint())
71 path_.MoveTo(p1); 71 path_.MoveTo(p1);
72 72
73 path_.AddLineTo(p1); 73 path_.AddLineTo(p1);
74 } 74 }
75 75
76 void CanvasPathMethods::quadraticCurveTo(float cpx, 76 void CanvasPath::quadraticCurveTo(float cpx, float cpy, float x, float y) {
77 float cpy,
78 float x,
79 float y) {
80 if (!std::isfinite(cpx) || !std::isfinite(cpy) || !std::isfinite(x) || 77 if (!std::isfinite(cpx) || !std::isfinite(cpy) || !std::isfinite(x) ||
81 !std::isfinite(y)) 78 !std::isfinite(y))
82 return; 79 return;
83 if (!IsTransformInvertible()) 80 if (!IsTransformInvertible())
84 return; 81 return;
85 if (!path_.HasCurrentPoint()) 82 if (!path_.HasCurrentPoint())
86 path_.MoveTo(FloatPoint(cpx, cpy)); 83 path_.MoveTo(FloatPoint(cpx, cpy));
87 84
88 FloatPoint p1 = FloatPoint(x, y); 85 FloatPoint p1 = FloatPoint(x, y);
89 FloatPoint cp = FloatPoint(cpx, cpy); 86 FloatPoint cp = FloatPoint(cpx, cpy);
90 87
91 path_.AddQuadCurveTo(cp, p1); 88 path_.AddQuadCurveTo(cp, p1);
92 } 89 }
93 90
94 void CanvasPathMethods::bezierCurveTo(float cp1x, 91 void CanvasPath::bezierCurveTo(float cp1x,
95 float cp1y, 92 float cp1y,
96 float cp2x, 93 float cp2x,
97 float cp2y, 94 float cp2y,
98 float x, 95 float x,
99 float y) { 96 float y) {
100 if (!std::isfinite(cp1x) || !std::isfinite(cp1y) || !std::isfinite(cp2x) || 97 if (!std::isfinite(cp1x) || !std::isfinite(cp1y) || !std::isfinite(cp2x) ||
101 !std::isfinite(cp2y) || !std::isfinite(x) || !std::isfinite(y)) 98 !std::isfinite(cp2y) || !std::isfinite(x) || !std::isfinite(y))
102 return; 99 return;
103 if (!IsTransformInvertible()) 100 if (!IsTransformInvertible())
104 return; 101 return;
105 if (!path_.HasCurrentPoint()) 102 if (!path_.HasCurrentPoint())
106 path_.MoveTo(FloatPoint(cp1x, cp1y)); 103 path_.MoveTo(FloatPoint(cp1x, cp1y));
107 104
108 FloatPoint p1 = FloatPoint(x, y); 105 FloatPoint p1 = FloatPoint(x, y);
109 FloatPoint cp1 = FloatPoint(cp1x, cp1y); 106 FloatPoint cp1 = FloatPoint(cp1x, cp1y);
110 FloatPoint cp2 = FloatPoint(cp2x, cp2y); 107 FloatPoint cp2 = FloatPoint(cp2x, cp2y);
111 108
112 path_.AddBezierCurveTo(cp1, cp2, p1); 109 path_.AddBezierCurveTo(cp1, cp2, p1);
113 } 110 }
114 111
115 void CanvasPathMethods::arcTo(float x1, 112 void CanvasPath::arcTo(float x1,
116 float y1, 113 float y1,
117 float x2, 114 float x2,
118 float y2, 115 float y2,
119 float r, 116 float r,
120 ExceptionState& exception_state) { 117 ExceptionState& exception_state) {
121 if (!std::isfinite(x1) || !std::isfinite(y1) || !std::isfinite(x2) || 118 if (!std::isfinite(x1) || !std::isfinite(y1) || !std::isfinite(x2) ||
122 !std::isfinite(y2) || !std::isfinite(r)) 119 !std::isfinite(y2) || !std::isfinite(r))
123 return; 120 return;
124 121
125 if (r < 0) { 122 if (r < 0) {
126 exception_state.ThrowDOMException( 123 exception_state.ThrowDOMException(
127 kIndexSizeError, 124 kIndexSizeError,
128 "The radius provided (" + String::Number(r) + ") is negative."); 125 "The radius provided (" + String::Number(r) + ") is negative.");
129 return; 126 return;
130 } 127 }
(...skipping 19 matching lines...) Expand all
150 /* http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-elem ent.html#dom-context-2d-arc 147 /* http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-elem ent.html#dom-context-2d-arc
151 * If the anticlockwise argument is false and endAngle-startAngle is equal 148 * If the anticlockwise argument is false and endAngle-startAngle is equal
152 * to or greater than 2pi, or, 149 * to or greater than 2pi, or,
153 * if the anticlockwise argument is true and startAngle-endAngle is equal to 150 * if the anticlockwise argument is true and startAngle-endAngle is equal to
154 * or greater than 2pi, 151 * or greater than 2pi,
155 * then the arc is the whole circumference of this ellipse, and the point at 152 * then the arc is the whole circumference of this ellipse, and the point at
156 * startAngle along this circle's circumference, measured in radians clockwise 153 * startAngle along this circle's circumference, measured in radians clockwise
157 * from the ellipse's semi-major axis, acts as both the start point and the 154 * from the ellipse's semi-major axis, acts as both the start point and the
158 * end point. 155 * end point.
159 */ 156 */
160 if (!anticlockwise && end_angle - start_angle >= twoPiFloat) 157 if (!anticlockwise && end_angle - start_angle >= twoPiFloat) {
161 new_end_angle = start_angle + twoPiFloat; 158 new_end_angle = start_angle + twoPiFloat;
162 else if (anticlockwise && start_angle - end_angle >= twoPiFloat) 159 } else if (anticlockwise && start_angle - end_angle >= twoPiFloat) {
163 new_end_angle = start_angle - twoPiFloat; 160 new_end_angle = start_angle - twoPiFloat;
164 161
165 /* 162 /*
166 * Otherwise, the arc is the path along the circumference of this ellipse 163 * Otherwise, the arc is the path along the circumference of this ellipse
167 * from the start point to the end point, going anti-clockwise if the 164 * from the start point to the end point, going anti-clockwise if the
168 * anticlockwise argument is true, and clockwise otherwise. 165 * anticlockwise argument is true, and clockwise otherwise.
169 * Since the points are on the ellipse, as opposed to being simply angles 166 * Since the points are on the ellipse, as opposed to being simply angles
170 * from zero, the arc can never cover an angle greater than 2pi radians. 167 * from zero, the arc can never cover an angle greater than 2pi radians.
171 */ 168 */
172 /* NOTE: When startAngle = 0, endAngle = 2Pi and anticlockwise = true, the 169 /* NOTE: When startAngle = 0, endAngle = 2Pi and anticlockwise = true, the
173 * spec does not indicate clearly. 170 * spec does not indicate clearly.
174 * We draw the entire circle, because some web sites use arc(x, y, r, 0, 171 * We draw the entire circle, because some web sites use arc(x, y, r, 0,
175 * 2*Math.PI, true) to draw circle. 172 * 2*Math.PI, true) to draw circle.
176 * We preserve backward-compatibility. 173 * We preserve backward-compatibility.
177 */ 174 */
178 else if (!anticlockwise && start_angle > end_angle) 175 } else if (!anticlockwise && start_angle > end_angle) {
179 new_end_angle = 176 new_end_angle =
180 start_angle + (twoPiFloat - fmodf(start_angle - end_angle, twoPiFloat)); 177 start_angle + (twoPiFloat - fmodf(start_angle - end_angle, twoPiFloat));
181 else if (anticlockwise && start_angle < end_angle) 178 } else if (anticlockwise && start_angle < end_angle) {
182 new_end_angle = 179 new_end_angle =
183 start_angle - (twoPiFloat - fmodf(end_angle - start_angle, twoPiFloat)); 180 start_angle - (twoPiFloat - fmodf(end_angle - start_angle, twoPiFloat));
181 }
184 182
185 ASSERT(EllipseIsRenderable(start_angle, new_end_angle)); 183 DCHECK(EllipseIsRenderable(start_angle, new_end_angle));
186 return new_end_angle; 184 return new_end_angle;
187 } 185 }
188 186
189 inline void LineToFloatPoint(CanvasPathMethods* path, const FloatPoint& p) { 187 inline void LineToFloatPoint(CanvasPath* path, const FloatPoint& p) {
190 path->lineTo(p.X(), p.Y()); 188 path->lineTo(p.X(), p.Y());
191 } 189 }
192 190
193 inline FloatPoint GetPointOnEllipse(float radius_x, 191 inline FloatPoint GetPointOnEllipse(float radius_x,
194 float radius_y, 192 float radius_y,
195 float theta) { 193 float theta) {
196 return FloatPoint(radius_x * cosf(theta), radius_y * sinf(theta)); 194 return FloatPoint(radius_x * cosf(theta), radius_y * sinf(theta));
197 } 195 }
198 196
199 void CanonicalizeAngle(float* start_angle, float* end_angle) { 197 void CanonicalizeAngle(float* start_angle, float* end_angle) {
200 // Make 0 <= startAngle < 2*PI 198 // Make 0 <= startAngle < 2*PI
201 float new_start_angle = fmodf(*start_angle, twoPiFloat); 199 float new_start_angle = fmodf(*start_angle, twoPiFloat);
202 200
203 if (new_start_angle < 0) { 201 if (new_start_angle < 0) {
204 new_start_angle += twoPiFloat; 202 new_start_angle += twoPiFloat;
205 // Check for possible catastrophic cancellation in cases where 203 // Check for possible catastrophic cancellation in cases where
206 // newStartAngle was a tiny negative number (c.f. crbug.com/503422) 204 // newStartAngle was a tiny negative number (c.f. crbug.com/503422)
207 if (new_start_angle >= twoPiFloat) 205 if (new_start_angle >= twoPiFloat)
208 new_start_angle -= twoPiFloat; 206 new_start_angle -= twoPiFloat;
209 } 207 }
210 208
211 float delta = new_start_angle - *start_angle; 209 float delta = new_start_angle - *start_angle;
212 *start_angle = new_start_angle; 210 *start_angle = new_start_angle;
213 *end_angle = *end_angle + delta; 211 *end_angle = *end_angle + delta;
214 212
215 ASSERT(new_start_angle >= 0 && new_start_angle < twoPiFloat); 213 DCHECK(new_start_angle >= 0 && new_start_angle < twoPiFloat);
216 } 214 }
217 215
218 /* 216 /*
219 * degenerateEllipse() handles a degenerated ellipse using several lines. 217 * degenerateEllipse() handles a degenerated ellipse using several lines.
220 * 218 *
221 * Let's see a following example: line to ellipse to line. 219 * Let's see a following example: line to ellipse to line.
222 * _--^\ 220 * _--^\
223 * ( ) 221 * ( )
224 * -----( ) 222 * -----( )
225 * ) 223 * )
(...skipping 15 matching lines...) Expand all
241 * --_ 239 * --_
242 * ---------- 240 * ----------
243 * ``P 241 * ``P
244 * Angles for P are 0 and Pi in the ellipse coordinates. 242 * Angles for P are 0 and Pi in the ellipse coordinates.
245 * 243 *
246 * To handle both cases, degenerateEllipse() lines to start angle, local maximum 244 * To handle both cases, degenerateEllipse() lines to start angle, local maximum
247 * points(every 0.5Pi), and end angle. 245 * points(every 0.5Pi), and end angle.
248 * NOTE: Before ellipse() calls this function, adjustEndAngle() is called, so 246 * NOTE: Before ellipse() calls this function, adjustEndAngle() is called, so
249 * endAngle - startAngle must be equal to or less than 2Pi. 247 * endAngle - startAngle must be equal to or less than 2Pi.
250 */ 248 */
251 void DegenerateEllipse(CanvasPathMethods* path, 249 void DegenerateEllipse(CanvasPath* path,
252 float x, 250 float x,
253 float y, 251 float y,
254 float radius_x, 252 float radius_x,
255 float radius_y, 253 float radius_y,
256 float rotation, 254 float rotation,
257 float start_angle, 255 float start_angle,
258 float end_angle, 256 float end_angle,
259 bool anticlockwise) { 257 bool anticlockwise) {
260 ASSERT(EllipseIsRenderable(start_angle, end_angle)); 258 DCHECK(EllipseIsRenderable(start_angle, end_angle));
261 ASSERT(start_angle >= 0 && start_angle < twoPiFloat); 259 DCHECK(start_angle >= 0 && start_angle < twoPiFloat);
262 ASSERT((anticlockwise && (start_angle - end_angle) >= 0) || 260 DCHECK((anticlockwise && (start_angle - end_angle) >= 0) ||
263 (!anticlockwise && (end_angle - start_angle) >= 0)); 261 (!anticlockwise && (end_angle - start_angle) >= 0));
264 262
265 FloatPoint center(x, y); 263 FloatPoint center(x, y);
266 AffineTransform rotation_matrix; 264 AffineTransform rotation_matrix;
267 rotation_matrix.RotateRadians(rotation); 265 rotation_matrix.RotateRadians(rotation);
268 // First, if the object's path has any subpaths, then the method must add a 266 // First, if the object's path has any subpaths, then the method must add a
269 // straight line from the last point in the subpath to the start point of the 267 // straight line from the last point in the subpath to the start point of the
270 // arc. 268 // arc.
271 LineToFloatPoint(path, center + rotation_matrix.MapPoint(GetPointOnEllipse( 269 LineToFloatPoint(path, center + rotation_matrix.MapPoint(GetPointOnEllipse(
272 radius_x, radius_y, start_angle))); 270 radius_x, radius_y, start_angle)));
273 if ((!radius_x && !radius_y) || start_angle == end_angle) 271 if ((!radius_x && !radius_y) || start_angle == end_angle)
274 return; 272 return;
275 273
276 if (!anticlockwise) { 274 if (!anticlockwise) {
277 // startAngle - fmodf(startAngle, piOverTwoFloat) + piOverTwoFloat is the 275 // startAngle - fmodf(startAngle, piOverTwoFloat) + piOverTwoFloat is the
278 // one of (0, 0.5Pi, Pi, 1.5Pi, 2Pi) that is the closest to startAngle on 276 // one of (0, 0.5Pi, Pi, 1.5Pi, 2Pi) that is the closest to startAngle on
279 // the clockwise direction. 277 // the clockwise direction.
280 for (float angle = 278 for (float angle =
281 start_angle - fmodf(start_angle, piOverTwoFloat) + piOverTwoFloat; 279 start_angle - fmodf(start_angle, piOverTwoFloat) + piOverTwoFloat;
282 angle < end_angle; angle += piOverTwoFloat) 280 angle < end_angle; angle += piOverTwoFloat) {
283 LineToFloatPoint( 281 LineToFloatPoint(
284 path, center + rotation_matrix.MapPoint( 282 path, center + rotation_matrix.MapPoint(
285 GetPointOnEllipse(radius_x, radius_y, angle))); 283 GetPointOnEllipse(radius_x, radius_y, angle)));
284 }
286 } else { 285 } else {
287 for (float angle = start_angle - fmodf(start_angle, piOverTwoFloat); 286 for (float angle = start_angle - fmodf(start_angle, piOverTwoFloat);
288 angle > end_angle; angle -= piOverTwoFloat) 287 angle > end_angle; angle -= piOverTwoFloat) {
289 LineToFloatPoint( 288 LineToFloatPoint(
290 path, center + rotation_matrix.MapPoint( 289 path, center + rotation_matrix.MapPoint(
291 GetPointOnEllipse(radius_x, radius_y, angle))); 290 GetPointOnEllipse(radius_x, radius_y, angle)));
291 }
292 } 292 }
293 293
294 LineToFloatPoint(path, center + rotation_matrix.MapPoint(GetPointOnEllipse( 294 LineToFloatPoint(path, center + rotation_matrix.MapPoint(GetPointOnEllipse(
295 radius_x, radius_y, end_angle))); 295 radius_x, radius_y, end_angle)));
296 } 296 }
297 297
298 } // namespace 298 } // namespace
299 299
300 void CanvasPathMethods::arc(float x, 300 void CanvasPath::arc(float x,
301 float y, 301 float y,
302 float radius, 302 float radius,
303 float start_angle, 303 float start_angle,
304 float end_angle, 304 float end_angle,
305 bool anticlockwise, 305 bool anticlockwise,
306 ExceptionState& exception_state) { 306 ExceptionState& exception_state) {
307 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(radius) || 307 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(radius) ||
308 !std::isfinite(start_angle) || !std::isfinite(end_angle)) 308 !std::isfinite(start_angle) || !std::isfinite(end_angle))
309 return; 309 return;
310 310
311 if (radius < 0) { 311 if (radius < 0) {
312 exception_state.ThrowDOMException( 312 exception_state.ThrowDOMException(
313 kIndexSizeError, 313 kIndexSizeError,
314 "The radius provided (" + String::Number(radius) + ") is negative."); 314 "The radius provided (" + String::Number(radius) + ") is negative.");
315 return; 315 return;
316 } 316 }
317 317
318 if (!IsTransformInvertible()) 318 if (!IsTransformInvertible())
319 return; 319 return;
320 320
321 if (!radius || start_angle == end_angle) { 321 if (!radius || start_angle == end_angle) {
322 // The arc is empty but we still need to draw the connecting line. 322 // The arc is empty but we still need to draw the connecting line.
323 lineTo(x + radius * cosf(start_angle), y + radius * sinf(start_angle)); 323 lineTo(x + radius * cosf(start_angle), y + radius * sinf(start_angle));
324 return; 324 return;
325 } 325 }
326 326
327 CanonicalizeAngle(&start_angle, &end_angle); 327 CanonicalizeAngle(&start_angle, &end_angle);
328 float adjusted_end_angle = 328 float adjusted_end_angle =
329 AdjustEndAngle(start_angle, end_angle, anticlockwise); 329 AdjustEndAngle(start_angle, end_angle, anticlockwise);
330 path_.AddArc(FloatPoint(x, y), radius, start_angle, adjusted_end_angle, 330 path_.AddArc(FloatPoint(x, y), radius, start_angle, adjusted_end_angle,
331 anticlockwise); 331 anticlockwise);
332 } 332 }
333 333
334 void CanvasPathMethods::ellipse(float x, 334 void CanvasPath::ellipse(float x,
335 float y, 335 float y,
336 float radius_x, 336 float radius_x,
337 float radius_y, 337 float radius_y,
338 float rotation, 338 float rotation,
339 float start_angle, 339 float start_angle,
340 float end_angle, 340 float end_angle,
341 bool anticlockwise, 341 bool anticlockwise,
342 ExceptionState& exception_state) { 342 ExceptionState& exception_state) {
343 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(radius_x) || 343 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(radius_x) ||
344 !std::isfinite(radius_y) || !std::isfinite(rotation) || 344 !std::isfinite(radius_y) || !std::isfinite(rotation) ||
345 !std::isfinite(start_angle) || !std::isfinite(end_angle)) 345 !std::isfinite(start_angle) || !std::isfinite(end_angle))
346 return; 346 return;
347 347
348 if (radius_x < 0) { 348 if (radius_x < 0) {
349 exception_state.ThrowDOMException( 349 exception_state.ThrowDOMException(
350 kIndexSizeError, "The major-axis radius provided (" + 350 kIndexSizeError, "The major-axis radius provided (" +
351 String::Number(radius_x) + ") is negative."); 351 String::Number(radius_x) + ") is negative.");
352 return; 352 return;
(...skipping 16 matching lines...) Expand all
369 // start point. 369 // start point.
370 DegenerateEllipse(this, x, y, radius_x, radius_y, rotation, start_angle, 370 DegenerateEllipse(this, x, y, radius_x, radius_y, rotation, start_angle,
371 adjusted_end_angle, anticlockwise); 371 adjusted_end_angle, anticlockwise);
372 return; 372 return;
373 } 373 }
374 374
375 path_.AddEllipse(FloatPoint(x, y), radius_x, radius_y, rotation, start_angle, 375 path_.AddEllipse(FloatPoint(x, y), radius_x, radius_y, rotation, start_angle,
376 adjusted_end_angle, anticlockwise); 376 adjusted_end_angle, anticlockwise);
377 } 377 }
378 378
379 void CanvasPathMethods::rect(float x, float y, float width, float height) { 379 void CanvasPath::rect(float x, float y, float width, float height) {
380 if (!IsTransformInvertible()) 380 if (!IsTransformInvertible())
381 return; 381 return;
382 382
383 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(width) || 383 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(width) ||
384 !std::isfinite(height)) 384 !std::isfinite(height))
385 return; 385 return;
386 386
387 path_.AddRect(FloatRect(x, y, width, height)); 387 path_.AddRect(FloatRect(x, y, width, height));
388 } 388 }
389 } // namespace blink 389 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/canvas2d/CanvasPath.h ('k') | third_party/WebKit/Source/modules/canvas2d/CanvasPath.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698