Auto merge of #18242 - joone:ellipse, r=jdm

Implement Ellipse Canvas 2D API

This patch needs to update rust-azure to 0.21.0.

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #17598

<!-- Either: -->
- [] There are tests for these changes OR
- [] These changes do not require tests because _____

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18242)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-09-01 20:25:57 -05:00 committed by GitHub
commit 3a4b98ad38
8 changed files with 52 additions and 16 deletions

View file

@ -957,6 +957,26 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
Ok(())
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-ellipse
fn Ellipse(&self, x: f64, y: f64, rx: f64, ry: f64, rotation: f64, start: f64, end: f64, ccw: bool) -> ErrorResult {
if !([x, y, rx, ry, rotation, start, end].iter().all(|x| x.is_finite())) {
return Ok(());
}
if rx < 0.0 || ry < 0.0 {
return Err(Error::IndexSize);
}
let msg = CanvasMsg::Canvas2d(Canvas2dMsg::Ellipse(Point2D::new(x as f32, y as f32),
rx as f32,
ry as f32,
rotation as f32,
start as f32,
end as f32,
ccw));
self.ipc_renderer.send(msg).unwrap();
Ok(())
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-imagesmoothingenabled
fn ImageSmoothingEnabled(&self) -> bool {
let state = self.state.borrow();

View file

@ -263,6 +263,11 @@ impl PaintRenderingContext2DMethods for PaintRenderingContext2D {
self.context.ArcTo(cp1x, cp1y, cp2x, cp2y, r)
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-ellipse
fn Ellipse(&self, x: f64, y: f64, rx: f64, ry: f64, rotation: f64, start: f64, end: f64, ccw: bool) -> ErrorResult {
self.context.Ellipse(x, y, rx, ry, rotation, start, end, ccw)
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-imagesmoothingenabled
fn ImageSmoothingEnabled(&self) -> bool {
self.context.ImageSmoothingEnabled()

View file

@ -264,4 +264,9 @@ interface CanvasPath {
// [LenientFloat] void ellipse(double x, double y, double radiusX, double radiusY,
// double rotation, double startAngle, double endAngle,
// boolean anticlockwise);
[Throws]
void ellipse(unrestricted double x, unrestricted double y, unrestricted double radius_x,
unrestricted double radius_y, unrestricted double rotation, unrestricted double startAngle,
unrestricted double endAngle, optional boolean anticlockwise = false);
};