Index: third_party/WebKit/Source/modules/canvas2d/CanvasPathMethods.cpp |
diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasPathMethods.cpp b/third_party/WebKit/Source/modules/canvas2d/CanvasPathMethods.cpp |
index b47fd45f394068b20584fc61b03de8a069e2758d..371479370b970d109f24d4a38d6fcb3b01769488 100644 |
--- a/third_party/WebKit/Source/modules/canvas2d/CanvasPathMethods.cpp |
+++ b/third_party/WebKit/Source/modules/canvas2d/CanvasPathMethods.cpp |
@@ -1,5 +1,6 @@ |
/* |
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. |
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. |
+ * All rights reserved. |
* Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
* Copyright (C) 2007 Alp Toker <alp@atoker.com> |
* Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
@@ -147,26 +148,33 @@ namespace { |
float adjustEndAngle(float startAngle, float endAngle, bool anticlockwise) { |
float newEndAngle = endAngle; |
/* http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-arc |
- * If the anticlockwise argument is false and endAngle-startAngle is equal to or greater than 2pi, or, |
- * if the anticlockwise argument is true and startAngle-endAngle is equal to or greater than 2pi, |
- * then the arc is the whole circumference of this ellipse, and the point at startAngle along this circle's circumference, |
- * measured in radians clockwise from the ellipse's semi-major axis, acts as both the start point and the end point. |
- */ |
+ * If the anticlockwise argument is false and endAngle-startAngle is equal |
+ * to or greater than 2pi, or, |
+ * if the anticlockwise argument is true and startAngle-endAngle is equal to |
+ * or greater than 2pi, |
+ * then the arc is the whole circumference of this ellipse, and the point at |
+ * startAngle along this circle's circumference, measured in radians clockwise |
+ * from the ellipse's semi-major axis, acts as both the start point and the |
+ * end point. |
+ */ |
if (!anticlockwise && endAngle - startAngle >= twoPiFloat) |
newEndAngle = startAngle + twoPiFloat; |
else if (anticlockwise && startAngle - endAngle >= twoPiFloat) |
newEndAngle = startAngle - twoPiFloat; |
/* |
- * Otherwise, the arc is the path along the circumference of this ellipse from the start point to the end point, |
- * going anti-clockwise if the anticlockwise argument is true, and clockwise otherwise. |
- * Since the points are on the ellipse, as opposed to being simply angles from zero, |
- * the arc can never cover an angle greater than 2pi radians. |
- */ |
- /* NOTE: When startAngle = 0, endAngle = 2Pi and anticlockwise = true, the spec does not indicate clearly. |
- * We draw the entire circle, because some web sites use arc(x, y, r, 0, 2*Math.PI, true) to draw circle. |
- * We preserve backward-compatibility. |
- */ |
+ * Otherwise, the arc is the path along the circumference of this ellipse |
+ * from the start point to the end point, going anti-clockwise if the |
+ * anticlockwise argument is true, and clockwise otherwise. |
+ * Since the points are on the ellipse, as opposed to being simply angles |
+ * from zero, the arc can never cover an angle greater than 2pi radians. |
+ */ |
+ /* NOTE: When startAngle = 0, endAngle = 2Pi and anticlockwise = true, the |
+ * spec does not indicate clearly. |
+ * We draw the entire circle, because some web sites use arc(x, y, r, 0, |
+ * 2*Math.PI, true) to draw circle. |
+ * We preserve backward-compatibility. |
+ */ |
else if (!anticlockwise && startAngle > endAngle) |
newEndAngle = |
startAngle + (twoPiFloat - fmodf(startAngle - endAngle, twoPiFloat)); |
@@ -233,8 +241,10 @@ void canonicalizeAngle(float* startAngle, float* endAngle) { |
* ``P |
* Angles for P are 0 and Pi in the ellipse coordinates. |
* |
- * To handle both cases, degenerateEllipse() lines to start angle, local maximum points(every 0.5Pi), and end angle. |
- * NOTE: Before ellipse() calls this function, adjustEndAngle() is called, so endAngle - startAngle must be equal to or less than 2Pi. |
+ * To handle both cases, degenerateEllipse() lines to start angle, local maximum |
+ * points(every 0.5Pi), and end angle. |
+ * NOTE: Before ellipse() calls this function, adjustEndAngle() is called, so |
+ * endAngle - startAngle must be equal to or less than 2Pi. |
*/ |
void degenerateEllipse(CanvasPathMethods* path, |
float x, |
@@ -253,7 +263,9 @@ void degenerateEllipse(CanvasPathMethods* path, |
FloatPoint center(x, y); |
AffineTransform rotationMatrix; |
rotationMatrix.rotateRadians(rotation); |
- // First, if the object's path has any subpaths, then the method must add a straight line from the last point in the subpath to the start point of the arc. |
+ // First, if the object's path has any subpaths, then the method must add a |
+ // straight line from the last point in the subpath to the start point of the |
+ // arc. |
lineToFloatPoint(path, center + |
rotationMatrix.mapPoint(getPointOnEllipse( |
radiusX, radiusY, startAngle))); |
@@ -261,7 +273,8 @@ void degenerateEllipse(CanvasPathMethods* path, |
return; |
if (!anticlockwise) { |
- // startAngle - fmodf(startAngle, piOverTwoFloat) + piOverTwoFloat is the one of (0, 0.5Pi, Pi, 1.5Pi, 2Pi) |
+ // startAngle - fmodf(startAngle, piOverTwoFloat) + piOverTwoFloat is the |
+ // one of (0, 0.5Pi, Pi, 1.5Pi, 2Pi) |
// that is the closest to startAngle on the clockwise direction. |
for (float angle = |
startAngle - fmodf(startAngle, piOverTwoFloat) + piOverTwoFloat; |
@@ -350,7 +363,8 @@ void CanvasPathMethods::ellipse(float x, |
canonicalizeAngle(&startAngle, &endAngle); |
float adjustedEndAngle = adjustEndAngle(startAngle, endAngle, anticlockwise); |
if (!radiusX || !radiusY || startAngle == adjustedEndAngle) { |
- // The ellipse is empty but we still need to draw the connecting line to start point. |
+ // The ellipse is empty but we still need to draw the connecting line to |
+ // start point. |
degenerateEllipse(this, x, y, radiusX, radiusY, rotation, startAngle, |
adjustedEndAngle, anticlockwise); |
return; |