--- a/dom/webidl/CanvasRenderingContext2D.webidl
+++ b/dom/webidl/CanvasRenderingContext2D.webidl
@@ -32,125 +32,16 @@ typedef (HTMLImageElement or
ImageBitmap) CanvasImageSource;
interface CanvasRenderingContext2D {
// back-reference to the canvas. Might be null if we're not
// associated with a canvas.
readonly attribute HTMLCanvasElement? canvas;
- // state
- void save(); // push state on state stack
- void restore(); // pop state stack and restore state
-
- // transformations (default transform is the identity matrix)
-// NOT IMPLEMENTED attribute SVGMatrix currentTransform;
- [Throws, LenientFloat]
- void scale(double x, double y);
- [Throws, LenientFloat]
- void rotate(double angle);
- [Throws, LenientFloat]
- void translate(double x, double y);
- [Throws, LenientFloat]
- void transform(double a, double b, double c, double d, double e, double f);
- [Throws, LenientFloat]
- void setTransform(double a, double b, double c, double d, double e, double f);
- [Throws]
- void resetTransform();
-
- // compositing
- attribute unrestricted double globalAlpha; // (default 1.0)
- [Throws]
- attribute DOMString globalCompositeOperation; // (default source-over)
-
- // colors 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)
- [NewObject]
- CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
- [NewObject, Throws]
- CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
- [NewObject, Throws]
- CanvasPattern? createPattern(CanvasImageSource image, [TreatNullAs=EmptyString] DOMString repetition);
-
- // shadows
- [LenientFloat]
- attribute double shadowOffsetX; // (default 0)
- [LenientFloat]
- attribute double shadowOffsetY; // (default 0)
- [LenientFloat]
- attribute double shadowBlur; // (default 0)
- attribute DOMString shadowColor; // (default transparent black)
-
- [Pref="canvas.filters.enabled", SetterThrows]
- attribute DOMString filter; // (default empty string = no filter)
-
- // rects
- [LenientFloat]
- void clearRect(double x, double y, double w, double h);
- [LenientFloat]
- void fillRect(double x, double y, double w, double h);
- [LenientFloat]
- void strokeRect(double x, double y, double w, double h);
-
- // path API (see also CanvasPathMethods)
- void beginPath();
- void fill(optional CanvasWindingRule winding = "nonzero");
- void fill(Path2D path, optional CanvasWindingRule winding = "nonzero");
- void stroke();
- void stroke(Path2D path);
- [Pref="canvas.focusring.enabled", Throws] void drawFocusIfNeeded(Element element);
-// NOT IMPLEMENTED void drawSystemFocusRing(Path path, HTMLElement element);
- [Pref="canvas.customfocusring.enabled"] boolean drawCustomFocusRing(Element element);
-// NOT IMPLEMENTED boolean drawCustomFocusRing(Path path, HTMLElement element);
-// NOT IMPLEMENTED void scrollPathIntoView();
-// NOT IMPLEMENTED void scrollPathIntoView(Path path);
- void clip(optional CanvasWindingRule winding = "nonzero");
- void clip(Path2D path, optional CanvasWindingRule winding = "nonzero");
-// NOT IMPLEMENTED void resetClip();
- boolean isPointInPath(unrestricted double x, unrestricted double y, optional CanvasWindingRule winding = "nonzero");
- boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y, optional CanvasWindingRule winding = "nonzero");
- boolean isPointInStroke(double x, double y);
- boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y);
-
- // text (see also the CanvasDrawingStyles interface)
- [Throws, LenientFloat]
- void fillText(DOMString text, double x, double y, optional double maxWidth);
- [Throws, LenientFloat]
- void strokeText(DOMString text, double x, double y, optional double maxWidth);
- [NewObject, Throws]
- TextMetrics measureText(DOMString text);
-
- // drawing images
- attribute boolean imageSmoothingEnabled;
-
- [Throws, LenientFloat]
- void drawImage(CanvasImageSource image, double dx, double dy);
- [Throws, LenientFloat]
- void drawImage(CanvasImageSource image, double dx, double dy, double dw, double dh);
- [Throws, LenientFloat]
- void drawImage(CanvasImageSource image, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh);
-
- // hit regions
- [Pref="canvas.hitregions.enabled", Throws] void addHitRegion(optional HitRegionOptions options);
- [Pref="canvas.hitregions.enabled"] void removeHitRegion(DOMString id);
- [Pref="canvas.hitregions.enabled"] void clearHitRegions();
-
- // pixel manipulation
- [NewObject, Throws]
- ImageData createImageData(double sw, double sh);
- [NewObject, Throws]
- ImageData createImageData(ImageData imagedata);
- [NewObject, Throws]
- ImageData getImageData(double sx, double sy, double sw, double sh);
- [Throws]
- void putImageData(ImageData imagedata, double dx, double dy);
- [Throws]
- void putImageData(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
-
// Mozilla-specific stuff
// FIXME Bug 768048 mozCurrentTransform/mozCurrentTransformInverse should return a WebIDL array.
[Throws]
attribute object mozCurrentTransform; // [ m11, m12, m21, m22, dx, dy ], i.e. row major
[Throws]
attribute object mozCurrentTransformInverse;
[SetterThrows]
@@ -226,40 +117,201 @@ interface CanvasRenderingContext2D {
/**
* This causes a context that is currently using a hardware-accelerated
* backend to fallback to a software one. All state should be preserved.
*/
[ChromeOnly]
void demote();
};
-CanvasRenderingContext2D implements CanvasDrawingStyles;
+
+CanvasRenderingContext2D implements CanvasState;
+CanvasRenderingContext2D implements CanvasTransform;
+CanvasRenderingContext2D implements CanvasCompositing;
+CanvasRenderingContext2D implements CanvasImageSmoothing;
+CanvasRenderingContext2D implements CanvasFillStrokeStyles;
+CanvasRenderingContext2D implements CanvasShadowStyles;
+CanvasRenderingContext2D implements CanvasFilters;
+CanvasRenderingContext2D implements CanvasRect;
+CanvasRenderingContext2D implements CanvasDrawPath;
+CanvasRenderingContext2D implements CanvasUserInterface;
+CanvasRenderingContext2D implements CanvasText;
+CanvasRenderingContext2D implements CanvasDrawImage;
+CanvasRenderingContext2D implements CanvasImageData;
+CanvasRenderingContext2D implements CanvasPathDrawingStyles;
+CanvasRenderingContext2D implements CanvasTextDrawingStyles;
CanvasRenderingContext2D implements CanvasPathMethods;
+CanvasRenderingContext2D implements CanvasHitRegions;
+
+
+[NoInterfaceObject]
+interface CanvasState {
+ // state
+ void save(); // push state on state stack
+ void restore(); // pop state stack and restore state
+};
+
+[NoInterfaceObject]
+interface CanvasTransform {
+ // transformations (default transform is the identity matrix)
+// NOT IMPLEMENTED attribute SVGMatrix currentTransform;
+ [Throws, LenientFloat]
+ void scale(double x, double y);
+ [Throws, LenientFloat]
+ void rotate(double angle);
+ [Throws, LenientFloat]
+ void translate(double x, double y);
+ [Throws, LenientFloat]
+ void transform(double a, double b, double c, double d, double e, double f);
+ [Throws, LenientFloat]
+ void setTransform(double a, double b, double c, double d, double e, double f);
+ [Throws]
+ void resetTransform();
+};
+
+[NoInterfaceObject]
+interface CanvasCompositing {
+ attribute unrestricted double globalAlpha; // (default 1.0)
+ [Throws]
+ attribute DOMString globalCompositeOperation; // (default source-over)
+};
+
+[NoInterfaceObject]
+interface CanvasImageSmoothing {
+ // drawing images
+ attribute boolean imageSmoothingEnabled;
+};
+
+[NoInterfaceObject]
+interface CanvasFillStrokeStyles {
+ // colors and styles (see also the CanvasPathDrawingStyles interface)
+ attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black)
+ attribute (DOMString or CanvasGradient or CanvasPattern) fillStyle; // (default black)
+ [NewObject]
+ CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
+ [NewObject, Throws]
+ CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
+ [NewObject, Throws]
+ CanvasPattern? createPattern(CanvasImageSource image, [TreatNullAs=EmptyString] DOMString repetition);
+};
+
+[NoInterfaceObject]
+interface CanvasShadowStyles {
+ [LenientFloat]
+ attribute double shadowOffsetX; // (default 0)
+ [LenientFloat]
+ attribute double shadowOffsetY; // (default 0)
+ [LenientFloat]
+ attribute double shadowBlur; // (default 0)
+ attribute DOMString shadowColor; // (default transparent black)
+};
+
+[NoInterfaceObject]
+interface CanvasFilters {
+ [Pref="canvas.filters.enabled", SetterThrows]
+ attribute DOMString filter; // (default empty string = no filter)
+};
[NoInterfaceObject]
-interface CanvasDrawingStyles {
+interface CanvasRect {
+ [LenientFloat]
+ void clearRect(double x, double y, double w, double h);
+ [LenientFloat]
+ void fillRect(double x, double y, double w, double h);
+ [LenientFloat]
+ void strokeRect(double x, double y, double w, double h);
+};
+
+[NoInterfaceObject]
+interface CanvasDrawPath {
+ // path API (see also CanvasPathMethods)
+ void beginPath();
+ void fill(optional CanvasWindingRule winding = "nonzero");
+ void fill(Path2D path, optional CanvasWindingRule winding = "nonzero");
+ void stroke();
+ void stroke(Path2D path);
+ void clip(optional CanvasWindingRule winding = "nonzero");
+ void clip(Path2D path, optional CanvasWindingRule winding = "nonzero");
+// NOT IMPLEMENTED void resetClip();
+ boolean isPointInPath(unrestricted double x, unrestricted double y, optional CanvasWindingRule winding = "nonzero");
+ boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y, optional CanvasWindingRule winding = "nonzero");
+ boolean isPointInStroke(double x, double y);
+ boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y);
+};
+
+[NoInterfaceObject]
+interface CanvasUserInterface {
+ [Pref="canvas.focusring.enabled", Throws] void drawFocusIfNeeded(Element element);
+// NOT IMPLEMENTED void drawSystemFocusRing(Path path, HTMLElement element);
+ [Pref="canvas.customfocusring.enabled"] boolean drawCustomFocusRing(Element element);
+// NOT IMPLEMENTED boolean drawCustomFocusRing(Path path, HTMLElement element);
+// NOT IMPLEMENTED void scrollPathIntoView();
+// NOT IMPLEMENTED void scrollPathIntoView(Path path);
+};
+
+[NoInterfaceObject]
+interface CanvasText {
+ // text (see also the CanvasPathDrawingStyles interface)
+ [Throws, LenientFloat]
+ void fillText(DOMString text, double x, double y, optional double maxWidth);
+ [Throws, LenientFloat]
+ void strokeText(DOMString text, double x, double y, optional double maxWidth);
+ [NewObject, Throws]
+ TextMetrics measureText(DOMString text);
+};
+
+[NoInterfaceObject]
+interface CanvasDrawImage {
+ [Throws, LenientFloat]
+ void drawImage(CanvasImageSource image, double dx, double dy);
+ [Throws, LenientFloat]
+ void drawImage(CanvasImageSource image, double dx, double dy, double dw, double dh);
+ [Throws, LenientFloat]
+ void drawImage(CanvasImageSource image, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh);
+};
+
+[NoInterfaceObject]
+interface CanvasImageData {
+ // pixel manipulation
+ [NewObject, Throws]
+ ImageData createImageData(double sw, double sh);
+ [NewObject, Throws]
+ ImageData createImageData(ImageData imagedata);
+ [NewObject, Throws]
+ ImageData getImageData(double sx, double sy, double sw, double sh);
+ [Throws]
+ void putImageData(ImageData imagedata, double dx, double dy);
+ [Throws]
+ void putImageData(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
+};
+
+[NoInterfaceObject]
+interface CanvasPathDrawingStyles {
// line caps/joins
- [LenientFloat]
- attribute double lineWidth; // (default 1)
- attribute DOMString lineCap; // "butt", "round", "square" (default "butt")
- [GetterThrows]
- attribute DOMString lineJoin; // "round", "bevel", "miter" (default "miter")
- [LenientFloat]
- attribute double miterLimit; // (default 10)
+ [LenientFloat]
+ attribute double lineWidth; // (default 1)
+ attribute DOMString lineCap; // "butt", "round", "square" (default "butt")
+ [GetterThrows]
+ attribute DOMString lineJoin; // "round", "bevel", "miter" (default "miter")
+ [LenientFloat]
+ attribute double miterLimit; // (default 10)
// dashed lines
- [LenientFloat, Throws] void setLineDash(sequence<double> segments); // default empty
- sequence<double> getLineDash();
- [LenientFloat] attribute double lineDashOffset;
+ [LenientFloat, Throws] void setLineDash(sequence<double> segments); // default empty
+ sequence<double> getLineDash();
+ [LenientFloat] attribute double lineDashOffset;
+};
+[NoInterfaceObject]
+interface CanvasTextDrawingStyles {
// text
- [SetterThrows]
- attribute DOMString font; // (default 10px sans-serif)
- attribute DOMString textAlign; // "start", "end", "left", "right", "center" (default: "start")
- attribute DOMString textBaseline; // "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" (default: "alphabetic")
+ [SetterThrows]
+ attribute DOMString font; // (default 10px sans-serif)
+ attribute DOMString textAlign; // "start", "end", "left", "right", "center" (default: "start")
+ attribute DOMString textBaseline; // "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" (default: "alphabetic")
};
[NoInterfaceObject]
interface CanvasPathMethods {
// shared path API methods
void closePath();
[LenientFloat]
void moveTo(double x, double y);
@@ -280,16 +332,24 @@ interface CanvasPathMethods {
[Throws, LenientFloat]
void arc(double x, double y, double radius, double startAngle, double endAngle, optional boolean anticlockwise = false);
[Throws, LenientFloat]
void ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle, optional boolean anticlockwise = false);
};
+[NoInterfaceObject]
+interface CanvasHitRegions {
+ // hit regions
+ [Pref="canvas.hitregions.enabled", Throws] void addHitRegion(optional HitRegionOptions options);
+ [Pref="canvas.hitregions.enabled"] void removeHitRegion(DOMString id);
+ [Pref="canvas.hitregions.enabled"] void clearHitRegions();
+};
+
interface CanvasGradient {
// opaque object
[Throws]
// addColorStop should take a double
void addColorStop(float offset, DOMString color);
};
interface CanvasPattern {