diff options
34 files changed, 21 insertions, 155 deletions
diff --git a/components/canvas/canvas_msg.rs b/components/canvas/canvas_msg.rs index 3d21da3ae0a..86e1dcc6f81 100644 --- a/components/canvas/canvas_msg.rs +++ b/components/canvas/canvas_msg.rs @@ -33,6 +33,7 @@ pub enum Canvas2dMsg { MoveTo(Point2D<f32>), PutImageData(Vec<u8>, Rect<f64>, Option<Rect<f64>>), QuadraticCurveTo(Point2D<f32>, Point2D<f32>), + Rect(Rect<f32>), RestoreContext, SaveContext, StrokeRect(Rect<f32>), diff --git a/components/canvas/canvas_paint_task.rs b/components/canvas/canvas_paint_task.rs index bbce09cea23..2eceb25331f 100644 --- a/components/canvas/canvas_paint_task.rs +++ b/components/canvas/canvas_paint_task.rs @@ -220,6 +220,7 @@ impl<'a> CanvasPaintTask<'a> { } Canvas2dMsg::MoveTo(ref point) => painter.move_to(point), Canvas2dMsg::LineTo(ref point) => painter.line_to(point), + Canvas2dMsg::Rect(ref rect) => painter.rect(rect), Canvas2dMsg::QuadraticCurveTo(ref cp, ref pt) => { painter.quadratic_curve_to(cp, pt) } @@ -351,6 +352,15 @@ impl<'a> CanvasPaintTask<'a> { self.path_builder.line_to(*point) } + fn rect(&self, rect: &Rect<f32>) { + self.path_builder.move_to(Point2D(rect.origin.x, rect.origin.y)); + self.path_builder.line_to(Point2D(rect.origin.x + rect.size.width, rect.origin.y)); + self.path_builder.line_to(Point2D(rect.origin.x + rect.size.width, + rect.origin.y + rect.size.height)); + self.path_builder.line_to(Point2D(rect.origin.x, rect.origin.y + rect.size.height)); + self.path_builder.close(); + } + fn quadratic_curve_to(&self, cp: &Point2D<AzFloat>, endpoint: &Point2D<AzFloat>) { diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index f21d23cd073..5c89b58f276 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -640,6 +640,15 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D> self.renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::LineTo(Point2D(x as f32, y as f32)))).unwrap(); } + // https://html.spec.whatwg.org/multipage/#dom-context-2d-rect + fn Rect(self, x: f64, y: f64, width: f64, height: f64) { + if [x, y, width, height].iter().all(|val| val.is_finite()) { + let rect = Rect(Point2D(x as f32, y as f32), + Size2D(width as f32, height as f32)); + self.renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::Rect(rect))).unwrap(); + } + } + // https://html.spec.whatwg.org/multipage/#dom-context-2d-quadraticcurveto fn QuadraticCurveTo(self, cpx: f64, cpy: f64, x: f64, y: f64) { if !(cpx.is_finite() && cpy.is_finite() && diff --git a/components/script/dom/webidls/CanvasRenderingContext2D.webidl b/components/script/dom/webidls/CanvasRenderingContext2D.webidl index e1d5416f13e..44f9c707600 100644 --- a/components/script/dom/webidls/CanvasRenderingContext2D.webidl +++ b/components/script/dom/webidls/CanvasRenderingContext2D.webidl @@ -171,7 +171,7 @@ interface CanvasPathMethods { unrestricted double radius); // NOT IMPLEMENTED [LenientFloat] void arcTo(double x1, double y1, double x2, double y2, double radiusX, double radiusY, double rotation); - //void rect(double x, double y, double w, double h); + void rect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h); [Throws] void arc(double x, double y, double radius, double startAngle, double endAngle, optional boolean anticlockwise = false); diff --git a/tests/wpt/metadata/2dcontext/drawing-images-to-the-canvas/2d.drawImage.path.html.ini b/tests/wpt/metadata/2dcontext/drawing-images-to-the-canvas/2d.drawImage.path.html.ini deleted file mode 100644 index 90e93b43b2d..00000000000 --- a/tests/wpt/metadata/2dcontext/drawing-images-to-the-canvas/2d.drawImage.path.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.drawImage.path.html] - type: testharness - [Canvas test: 2d.drawImage.path] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/drawing-rectangles-to-the-canvas/2d.clearRect.path.html.ini b/tests/wpt/metadata/2dcontext/drawing-rectangles-to-the-canvas/2d.clearRect.path.html.ini deleted file mode 100644 index 615202eb6b5..00000000000 --- a/tests/wpt/metadata/2dcontext/drawing-rectangles-to-the-canvas/2d.clearRect.path.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.clearRect.path.html] - type: testharness - [clearRect does not affect the current path] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/drawing-rectangles-to-the-canvas/2d.fillRect.path.html.ini b/tests/wpt/metadata/2dcontext/drawing-rectangles-to-the-canvas/2d.fillRect.path.html.ini deleted file mode 100644 index b3bd1685ad2..00000000000 --- a/tests/wpt/metadata/2dcontext/drawing-rectangles-to-the-canvas/2d.fillRect.path.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.fillRect.path.html] - type: testharness - [fillRect does not affect the current path] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/drawing-rectangles-to-the-canvas/2d.strokeRect.path.html.ini b/tests/wpt/metadata/2dcontext/drawing-rectangles-to-the-canvas/2d.strokeRect.path.html.ini deleted file mode 100644 index 3fb4bbb762f..00000000000 --- a/tests/wpt/metadata/2dcontext/drawing-rectangles-to-the-canvas/2d.strokeRect.path.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.strokeRect.path.html] - type: testharness - [strokeRect does not affect the current path] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.gradient.interpolate.zerosize.fill.html.ini b/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.gradient.interpolate.zerosize.fill.html.ini deleted file mode 100644 index 4e811b1293f..00000000000 --- a/tests/wpt/metadata/2dcontext/fill-and-stroke-styles/2d.gradient.interpolate.zerosize.fill.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.gradient.interpolate.zerosize.fill.html] - type: testharness - [Canvas test: 2d.gradient.interpolate.zerosize.fill] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.arcTo.shape.curve1.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.arcTo.shape.curve1.html.ini deleted file mode 100644 index 170abb8500e..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.arcTo.shape.curve1.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.arcTo.shape.curve1.html] - type: testharness - [arcTo() curves in the right kind of shape] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.arcTo.shape.curve2.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.arcTo.shape.curve2.html.ini deleted file mode 100644 index 3ceefeb7d1a..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.arcTo.shape.curve2.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.arcTo.shape.curve2.html] - type: testharness - [arcTo() curves in the right kind of shape] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.beginPath.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.beginPath.html.ini deleted file mode 100644 index 9dba6a39c78..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.beginPath.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.beginPath.html] - type: testharness - [Canvas test: 2d.path.beginPath] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.fill.overlap.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.fill.overlap.html.ini deleted file mode 100644 index ed2f2f9b29a..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.fill.overlap.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.fill.overlap.html] - type: testharness - [Canvas test: 2d.path.fill.overlap] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.moveTo.basic.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.moveTo.basic.html.ini deleted file mode 100644 index 09fcdf36b81..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.moveTo.basic.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.moveTo.basic.html] - type: testharness - [Canvas test: 2d.path.moveTo.basic] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.basic.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.basic.html.ini deleted file mode 100644 index 0abc294400a..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.basic.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.basic.html] - type: testharness - [Canvas test: 2d.path.rect.basic] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.closed.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.closed.html.ini deleted file mode 100644 index 998dd532bc5..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.closed.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.closed.html] - type: testharness - [Canvas test: 2d.path.rect.closed] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.end.1.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.end.1.html.ini deleted file mode 100644 index 24ffbf09995..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.end.1.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.end.1.html] - type: testharness - [Canvas test: 2d.path.rect.end.1] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.end.2.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.end.2.html.ini deleted file mode 100644 index c1fc1a7218a..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.end.2.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.end.2.html] - type: testharness - [Canvas test: 2d.path.rect.end.2] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.negative.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.negative.html.ini deleted file mode 100644 index 9abbc1efdae..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.negative.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.negative.html] - type: testharness - [Canvas test: 2d.path.rect.negative] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.newsubpath.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.newsubpath.html.ini deleted file mode 100644 index a686aeaa694..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.newsubpath.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.newsubpath.html] - type: testharness - [Canvas test: 2d.path.rect.newsubpath] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.nonfinite.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.nonfinite.html.ini deleted file mode 100644 index 3e9d98ef623..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.nonfinite.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.nonfinite.html] - type: testharness - [rect() with Infinity/NaN is ignored] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.selfintersect.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.selfintersect.html.ini deleted file mode 100644 index ba5026a5284..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.selfintersect.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.selfintersect.html] - type: testharness - [Canvas test: 2d.path.rect.selfintersect] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.winding.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.winding.html.ini deleted file mode 100644 index 9d513c9678f..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.winding.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.winding.html] - type: testharness - [Canvas test: 2d.path.rect.winding] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.1.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.1.html.ini deleted file mode 100644 index 4d0ceb9e0a0..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.1.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.zero.1.html] - type: testharness - [Canvas test: 2d.path.rect.zero.1] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.2.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.2.html.ini deleted file mode 100644 index 62cf2bed704..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.2.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.zero.2.html] - type: testharness - [Canvas test: 2d.path.rect.zero.2] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.3.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.3.html.ini deleted file mode 100644 index ba8f7d7aee6..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.3.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.zero.3.html] - type: testharness - [Canvas test: 2d.path.rect.zero.3] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.4.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.4.html.ini deleted file mode 100644 index 510e9f6960e..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.4.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.zero.4.html] - type: testharness - [Canvas test: 2d.path.rect.zero.4] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.5.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.5.html.ini deleted file mode 100644 index b35c28f56d9..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.5.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.zero.5.html] - type: testharness - [Canvas test: 2d.path.rect.zero.5] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.6.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.6.html.ini deleted file mode 100644 index 89e66cb7e8e..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.rect.zero.6.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.rect.zero.6.html] - type: testharness - [Canvas test: 2d.path.rect.zero.6] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.stroke.prune.rect.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.stroke.prune.rect.html.ini deleted file mode 100644 index 129a2d6d000..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.stroke.prune.rect.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.stroke.prune.rect.html] - type: testharness - [Zero-length line segments from rect and strokeRect are removed before stroking] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/path-objects/2d.path.transformation.multiple.html.ini b/tests/wpt/metadata/2dcontext/path-objects/2d.path.transformation.multiple.html.ini deleted file mode 100644 index b59844f2c8c..00000000000 --- a/tests/wpt/metadata/2dcontext/path-objects/2d.path.transformation.multiple.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.path.transformation.multiple.html] - type: testharness - [Transformations are applied while building paths, not when drawing] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.put.path.html.ini b/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.put.path.html.ini deleted file mode 100644 index ac486347a73..00000000000 --- a/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.put.path.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.imageData.put.path.html] - type: testharness - [putImageData() does not affect the current path] - expected: FAIL - diff --git a/tests/wpt/metadata/2dcontext/the-canvas-state/2d.state.saverestore.path.html.ini b/tests/wpt/metadata/2dcontext/the-canvas-state/2d.state.saverestore.path.html.ini deleted file mode 100644 index 7050240d9bf..00000000000 --- a/tests/wpt/metadata/2dcontext/the-canvas-state/2d.state.saverestore.path.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.state.saverestore.path.html] - type: testharness - [save()/restore() does not affect the current path] - expected: FAIL - diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini index 6fb44abfea5..62800c0b7e8 100644 --- a/tests/wpt/metadata/html/dom/interfaces.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.html.ini @@ -6993,9 +6993,6 @@ [CanvasRenderingContext2D interface: operation arcTo(unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double)] expected: FAIL - [CanvasRenderingContext2D interface: operation rect(unrestricted double,unrestricted double,unrestricted double,unrestricted double)] - expected: FAIL - [CanvasRenderingContext2D interface: operation arc(unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double,boolean)] expected: FAIL @@ -7191,12 +7188,6 @@ [CanvasRenderingContext2D interface: calling arcTo(unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double,unrestricted double) on document.createElement("canvas").getContext("2d") with too few arguments must throw TypeError] expected: FAIL - [CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "rect" with the proper type (77)] - expected: FAIL - - [CanvasRenderingContext2D interface: calling rect(unrestricted double,unrestricted double,unrestricted double,unrestricted double) on document.createElement("canvas").getContext("2d") with too few arguments must throw TypeError] - expected: FAIL - [CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "ellipse" with the proper type (79)] expected: FAIL |