aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webidls
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2015-02-22 12:35:52 -0500
committerJosh Matthews <josh@joshmatthews.net>2015-02-22 22:29:58 -0500
commit55a0ee6ec75960879c20aea7d4b68a8bbdda1560 (patch)
tree716dd5e78d47d2015526865487ef1f57531ee6ce /components/script/dom/webidls
parent287f390c4a56dd8c5960df699d45653227b25d6f (diff)
downloadservo-55a0ee6ec75960879c20aea7d4b68a8bbdda1560.tar.gz
servo-55a0ee6ec75960879c20aea7d4b68a8bbdda1560.zip
script: Implement enough 2D canvas support to render basic SVGs such as the tiger.
Diffstat (limited to 'components/script/dom/webidls')
-rw-r--r--components/script/dom/webidls/CanvasGradient.webidl12
-rw-r--r--components/script/dom/webidls/CanvasPattern.webidl9
-rw-r--r--components/script/dom/webidls/CanvasRenderingContext2D.webidl66
3 files changed, 74 insertions, 13 deletions
diff --git a/components/script/dom/webidls/CanvasGradient.webidl b/components/script/dom/webidls/CanvasGradient.webidl
new file mode 100644
index 00000000000..1dc1ac4c1f0
--- /dev/null
+++ b/components/script/dom/webidls/CanvasGradient.webidl
@@ -0,0 +1,12 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+interface CanvasGradient {
+ // opaque object
+ // addColorStop should take a double
+ //void addColorStop(float offset, DOMString color);
+};
+
+
diff --git a/components/script/dom/webidls/CanvasPattern.webidl b/components/script/dom/webidls/CanvasPattern.webidl
new file mode 100644
index 00000000000..06a77d0a62d
--- /dev/null
+++ b/components/script/dom/webidls/CanvasPattern.webidl
@@ -0,0 +1,9 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+interface CanvasPattern {
+ //void setTransform(SVGMatrix matrix);
+};
+
diff --git a/components/script/dom/webidls/CanvasRenderingContext2D.webidl b/components/script/dom/webidls/CanvasRenderingContext2D.webidl
index 6cef3012c25..21925c2448f 100644
--- a/components/script/dom/webidls/CanvasRenderingContext2D.webidl
+++ b/components/script/dom/webidls/CanvasRenderingContext2D.webidl
@@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+enum CanvasWindingRule { "nonzero", "evenodd" };
+
// http://www.whatwg.org/html/#2dcontext
//[Constructor(optional unsigned long width, unsigned long height), Exposed=Window,Worker]
interface CanvasRenderingContext2D {
@@ -23,11 +25,21 @@ interface CanvasRenderingContext2D {
// transformations (default transform is the identity matrix)
// attribute SVGMatrix currentTransform;
- //void scale(unrestricted double x, unrestricted double y);
+ void scale(/*unrestricted*/ double x, /*unrestricted*/ double y);
//void rotate(unrestricted double angle);
- //void translate(unrestricted double x, unrestricted double y);
- //void transform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
- //void setTransform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
+ void translate(/*unrestricted*/ double x, /*unrestricted*/ double y);
+ void transform(/*unrestricted*/ double a,
+ /*unrestricted*/ double b,
+ /*unrestricted*/ double c,
+ /*unrestricted*/ double d,
+ /*unrestricted*/ double e,
+ /*unrestricted*/ double f);
+ void setTransform(/*unrestricted*/ double a,
+ /*unrestricted*/ double b,
+ /*unrestricted*/ double c,
+ /*unrestricted*/ double d,
+ /*unrestricted*/ double e,
+ /*unrestricted*/ double f);
//void resetTransform();
// compositing
@@ -38,8 +50,8 @@ interface CanvasRenderingContext2D {
// attribute boolean imageSmoothingEnabled; // (default true)
// colours and styles (see also the CanvasDrawingStyles interface)
- // attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black)
- // attribute (DOMString or CanvasGradient or CanvasPattern) fillStyle; // (default black)
+ attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black)
+ attribute (DOMString or CanvasGradient or CanvasPattern) fillStyle; // (default black)
//CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
//CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
//CanvasPattern createPattern(CanvasImageSource image, [TreatNullAs=EmptyString] DOMString repetition);
@@ -62,9 +74,9 @@ interface CanvasRenderingContext2D {
void strokeRect(double x, double y, double w, double h);
// path API (see also CanvasPathMethods)
- //void beginPath();
- //void fill(optional CanvasFillRule fillRule = "nonzero");
- //void fill(Path2D path, optional CanvasFillRule fillRule = "nonzero");
+ void beginPath();
+ void fill(optional CanvasWindingRule fillRule = "nonzero");
+ //void fill(Path2D path, optional CanvasWindingRule fillRule = "nonzero");
//void stroke();
//void stroke(Path2D path);
//void drawSystemFocusRing(Element element);
@@ -73,11 +85,11 @@ interface CanvasRenderingContext2D {
//boolean drawCustomFocusRing(Path2D path, Element element);
//void scrollPathIntoView();
//void scrollPathIntoView(Path2D path);
- //void clip(optional CanvasFillRule fillRule = "nonzero");
- //void clip(Path2D path, optional CanvasFillRule fillRule = "nonzero");
+ //void clip(optional CanvasWindingRule fillRule = "nonzero");
+ //void clip(Path2D path, optional CanvasWindingRule fillRule = "nonzero");
//void resetClip();
- //boolean isPointInPath(unrestricted double x, unrestricted double y, optional CanvasFillRule fillRule = "nonzero");
- //boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y, optional CanvasFillRule fillRule = "nonzero");
+ //boolean isPointInPath(unrestricted double x, unrestricted double y, optional CanvasWindingRule fillRule = "nonzero");
+ //boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y, optional CanvasWindingRule fillRule = "nonzero");
//boolean isPointInStroke(unrestricted double x, unrestricted double y);
//boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y);
@@ -105,3 +117,31 @@ interface CanvasRenderingContext2D {
void putImageData(ImageData imagedata, double dx, double dy);
void putImageData(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
};
+
+[NoInterfaceObject]
+interface CanvasPathMethods {
+ // shared path API methods
+ void closePath();
+ void moveTo(/*unrestricted*/ double x, /*unrestricted*/ double y);
+ //void lineTo(double x, double y);
+ //void quadraticCurveTo(double cpx, double cpy, double x, double y);
+
+ void bezierCurveTo(/*unrestricted*/ double cp1x,
+ /*unrestricted*/ double cp1y,
+ /*unrestricted*/ double cp2x,
+ /*unrestricted*/ double cp2y,
+ /*unrestricted*/ double x,
+ /*unrestricted*/ double y);
+
+ //void arcTo(double x1, double y1, double x2, double y2, 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 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);
+};
+
+
+CanvasRenderingContext2D implements CanvasPathMethods;
+