auto merge of #5455 : mmatyas/servo/canvas_arc_negativeradius, r=Ms2ger

"Negative values for radius must cause the implementation to throw an IndexSizeError exception."
This commit is contained in:
bors-servo 2015-03-30 04:16:04 -06:00
commit 1bd8e18d92
3 changed files with 8 additions and 6 deletions

View file

@ -460,15 +460,21 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
Point2D(x as f32, y as f32))).unwrap(); Point2D(x as f32, y as f32))).unwrap();
} }
fn Arc(self, x: Finite<f64>, y: Finite<f64>, r: Finite<f64>, start: Finite<f64>, end: Finite<f64>, ccw: bool) { fn Arc(self, x: Finite<f64>, y: Finite<f64>, r: Finite<f64>,
start: Finite<f64>, end: Finite<f64>, ccw: bool) -> Fallible<()> {
let x = *x; let x = *x;
let y = *y; let y = *y;
let r = *r; let r = *r;
let start = *start; let start = *start;
let end = *end; let end = *end;
if r < 0.0 {
return Err(IndexSize);
}
self.renderer.send(CanvasMsg::Arc(Point2D(x as f32, y as f32), r as f32, self.renderer.send(CanvasMsg::Arc(Point2D(x as f32, y as f32), r as f32,
start as f32, end as f32, ccw)).unwrap(); start as f32, end as f32, ccw)).unwrap();
Ok(())
} }
// https://html.spec.whatwg.org/#dom-context-2d-imagesmoothingenabled // https://html.spec.whatwg.org/#dom-context-2d-imagesmoothingenabled

View file

@ -150,6 +150,7 @@ interface CanvasPathMethods {
//void rect(double x, double y, double w, double h); //void rect(double x, double y, double w, double h);
[Throws]
void arc(double x, double y, double radius, double startAngle, double endAngle, optional boolean anticlockwise = false); void arc(double x, double y, double radius, double startAngle, double endAngle, optional boolean anticlockwise = false);
// NOT IMPLEMENTED [LenientFloat] void ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle, boolean anticlockwise); // NOT IMPLEMENTED [LenientFloat] void ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle, boolean anticlockwise);
}; };

View file

@ -1,5 +0,0 @@
[2d.path.arc.negative.html]
type: testharness
[arc() with negative radius throws INDEX_SIZE_ERR]
expected: FAIL