diff --git a/Cargo.lock b/Cargo.lock index 1448f451d4b..d5185e43c91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,8 +109,8 @@ dependencies = [ [[package]] name = "azure" -version = "0.20.1" -source = "git+https://github.com/servo/rust-azure#ca851788b3bc1f1034d4d899da66faf78e420c5e" +version = "0.21.0" +source = "git+https://github.com/servo/rust-azure#dea0d6ebf4603771740acf2cebceab88f2efcc5e" dependencies = [ "cmake 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -324,7 +324,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "canvas" version = "0.0.1" dependencies = [ - "azure 0.20.1 (git+https://github.com/servo/rust-azure)", + "azure 0.21.0 (git+https://github.com/servo/rust-azure)", "canvas_traits 0.0.1", "compositing 0.0.1", "cssparser 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3724,7 +3724,7 @@ dependencies = [ "checksum aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfdf7355d9db158df68f976ed030ab0f6578af811f5a7bb6dcf221ec24e0e0" "checksum atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb2dcb6e6d35f20276943cc04bb98e538b348d525a04ac79c10021561d202f21" "checksum audio-video-metadata 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3b6ef29ee98ad95a37f34547fd7fb40724772294110ed6ca0445fc2e964c29d1" -"checksum azure 0.20.1 (git+https://github.com/servo/rust-azure)" = "" +"checksum azure 0.21.0 (git+https://github.com/servo/rust-azure)" = "" "checksum backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72f9b4182546f4b04ebc4ab7f84948953a118bd6021a1b6a6c909e3e94f6be76" "checksum backtrace-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3a0d842ea781ce92be2bf78a9b38883948542749640b8378b3b2f03d1fd9f1ff" "checksum base64 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "30e93c03064e7590d0466209155251b90c22e37fab1daf2771582598b5827557" diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs index deba49262c8..28b7fec5413 100644 --- a/components/canvas/canvas_paint_thread.rs +++ b/components/canvas/canvas_paint_thread.rs @@ -173,6 +173,9 @@ impl<'a> CanvasPaintThread<'a> { Canvas2dMsg::ArcTo(ref cp1, ref cp2, radius) => { painter.arc_to(cp1, cp2, radius) } + Canvas2dMsg::Ellipse(ref center, radius_x, radius_y, rotation, start, end, ccw) => { + painter.ellipse(center, radius_x, radius_y, rotation, start, end, ccw) + } Canvas2dMsg::RestoreContext => painter.restore_context_state(), Canvas2dMsg::SaveContext => painter.save_context_state(), Canvas2dMsg::SetFillStyle(style) => painter.set_fill_style(style), @@ -501,6 +504,17 @@ impl<'a> CanvasPaintThread<'a> { } } + fn ellipse(&mut self, + center: &Point2D, + radius_x: AzFloat, + radius_y: AzFloat, + rotation_angle: AzFloat, + start_angle: AzFloat, + end_angle: AzFloat, + ccw: bool) { + self.path_builder.ellipse(*center, radius_x, radius_y, rotation_angle, start_angle, end_angle, ccw); + } + fn set_fill_style(&mut self, style: FillOrStrokeStyle) { if let Some(pattern) = style.to_azure_pattern(&self.drawtarget) { self.state.fill_style = pattern diff --git a/components/canvas_traits/canvas.rs b/components/canvas_traits/canvas.rs index 841b81534b6..06194052b88 100644 --- a/components/canvas_traits/canvas.rs +++ b/components/canvas_traits/canvas.rs @@ -42,6 +42,7 @@ pub enum Canvas2dMsg { ClearRect(Rect), Clip, ClosePath, + Ellipse(Point2D, f32, f32, f32, f32, f32, bool), Fill, FillText(String, f64, f64, Option), FillRect(Rect), diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 399c1faf30f..e6007c8b6ee 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -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(); diff --git a/components/script/dom/paintrenderingcontext2d.rs b/components/script/dom/paintrenderingcontext2d.rs index c6b62b50e15..5a269eaf37a 100644 --- a/components/script/dom/paintrenderingcontext2d.rs +++ b/components/script/dom/paintrenderingcontext2d.rs @@ -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() diff --git a/components/script/dom/webidls/CanvasRenderingContext2D.webidl b/components/script/dom/webidls/CanvasRenderingContext2D.webidl index b77706332d3..ccf637865cb 100644 --- a/components/script/dom/webidls/CanvasRenderingContext2D.webidl +++ b/components/script/dom/webidls/CanvasRenderingContext2D.webidl @@ -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); }; diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini index dc075e84954..ffac7447111 100644 --- a/tests/wpt/metadata/html/dom/interfaces.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.html.ini @@ -3927,9 +3927,6 @@ [CanvasRenderingContext2D interface: attribute direction] expected: FAIL - [CanvasRenderingContext2D interface: operation ellipse(unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double,boolean)] - expected: FAIL - [CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "width" with the proper type (1)] expected: FAIL @@ -4050,12 +4047,6 @@ [CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "direction" with the proper type (69)] expected: FAIL - [CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "ellipse" with the proper type (79)] - expected: FAIL - - [CanvasRenderingContext2D interface: calling ellipse(unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double,boolean) on document.createElement("canvas").getContext("2d") with too few arguments must throw TypeError] - expected: FAIL - [CanvasPattern interface: operation setTransform(SVGMatrix)] expected: FAIL @@ -9591,9 +9582,6 @@ [CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "direction" with the proper type (68)] expected: FAIL - [CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "ellipse" with the proper type (78)] - expected: FAIL - [CanvasPattern interface: operation setTransform(DOMMatrixInit)] expected: FAIL diff --git a/tests/wpt/mozilla/meta/mozilla/css-paint-api/background-image-tiled.html.ini b/tests/wpt/mozilla/meta/mozilla/css-paint-api/background-image-tiled.html.ini new file mode 100644 index 00000000000..f988ff2fdbe --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/css-paint-api/background-image-tiled.html.ini @@ -0,0 +1,3 @@ +[background-image-tiled.html] + type: reftest + expected: FAIL