updating the CanvasRenderingContext2D to match the spec

- fixes #9443
This commit is contained in:
Gregory Malecha 2016-03-01 08:13:50 -08:00
parent 00628704ca
commit 2c6636129d

View file

@ -24,11 +24,33 @@ interface CanvasRenderingContext2D {
// for contexts that aren't directly fixed to a specific canvas // for contexts that aren't directly fixed to a specific canvas
//void commit(); // push the image to the output bitmap //void commit(); // push the image to the output bitmap
};
CanvasRenderingContext2D implements CanvasState;
CanvasRenderingContext2D implements CanvasTransform;
CanvasRenderingContext2D implements CanvasCompositing;
CanvasRenderingContext2D implements CanvasImageSmoothing;
CanvasRenderingContext2D implements CanvasFillStrokeStyles;
CanvasRenderingContext2D implements CanvasShadowStyles;
CanvasRenderingContext2D implements CanvasRect;
CanvasRenderingContext2D implements CanvasDrawPath;
CanvasRenderingContext2D implements CanvasUserInterface;
CanvasRenderingContext2D implements CanvasText;
CanvasRenderingContext2D implements CanvasDrawImage;
CanvasRenderingContext2D implements CanvasHitRegion;
CanvasRenderingContext2D implements CanvasImageData;
CanvasRenderingContext2D implements CanvasPathDrawingStyles;
CanvasRenderingContext2D implements CanvasTextDrawingStyles;
CanvasRenderingContext2D implements CanvasPath;
[NoInterfaceObject]//,Exposed=(Window,Worker)]
interface CanvasState {
// state // state
void save(); // push state on state stack void save(); // push state on state stack
void restore(); // pop state stack and restore state void restore(); // pop state stack and restore state
};
[NoInterfaceObject]//,Exposed=(Window,Worker)]
interface CanvasTransform {
// transformations (default transform is the identity matrix) // transformations (default transform is the identity matrix)
void scale(unrestricted double x, unrestricted double y); void scale(unrestricted double x, unrestricted double y);
void rotate(unrestricted double angle); void rotate(unrestricted double angle);
@ -49,14 +71,24 @@ interface CanvasRenderingContext2D {
unrestricted double f); unrestricted double f);
// void setTransform(optional DOMMatrixInit matrix); // void setTransform(optional DOMMatrixInit matrix);
void resetTransform(); void resetTransform();
};
[NoInterfaceObject]//,Exposed=(Window,Worker)]
interface CanvasCompositing {
// compositing // compositing
attribute unrestricted double globalAlpha; // (default 1.0) attribute unrestricted double globalAlpha; // (default 1.0)
attribute DOMString globalCompositeOperation; // (default source-over) attribute DOMString globalCompositeOperation; // (default source-over)
};
[NoInterfaceObject]//,Exposed=(Window,Worker)]
interface CanvasImageSmoothing {
// image smoothing // image smoothing
attribute boolean imageSmoothingEnabled; // (default true) attribute boolean imageSmoothingEnabled; // (default true)
// attribute ImageSmoothingQuality imageSmoothingQuality; // (default low) // attribute ImageSmoothingQuality imageSmoothingQuality; // (default low)
};
[NoInterfaceObject]//,Exposed=(Window,Worker)]
interface CanvasFillStrokeStyles {
// colours and styles (see also the CanvasDrawingStyles interface) // colours and styles (see also the CanvasDrawingStyles interface)
attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black) attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black)
@ -66,13 +98,19 @@ interface CanvasRenderingContext2D {
CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1); CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
[Throws] [Throws]
CanvasPattern createPattern(CanvasImageSource image, [TreatNullAs=EmptyString] DOMString repetition); CanvasPattern createPattern(CanvasImageSource image, [TreatNullAs=EmptyString] DOMString repetition);
};
[NoInterfaceObject]//,Exposed=(Window,Worker)]
interface CanvasShadowStyles {
// shadows // shadows
attribute unrestricted double shadowOffsetX; // (default 0) attribute unrestricted double shadowOffsetX; // (default 0)
attribute unrestricted double shadowOffsetY; // (default 0) attribute unrestricted double shadowOffsetY; // (default 0)
attribute unrestricted double shadowBlur; // (default 0) attribute unrestricted double shadowBlur; // (default 0)
attribute DOMString shadowColor; // (default transparent black) attribute DOMString shadowColor; // (default transparent black)
};
[NoInterfaceObject]//,Exposed=(Window,Worker)]
interface CanvasRect {
// rects // rects
//[LenientFloat] //[LenientFloat]
void clearRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h); void clearRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
@ -80,7 +118,10 @@ interface CanvasRenderingContext2D {
void fillRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h); void fillRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
//[LenientFloat] //[LenientFloat]
void strokeRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h); void strokeRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
};
[NoInterfaceObject]//,Exposed=(Window,Worker)]
interface CanvasDrawPath {
// path API (see also CanvasPathMethods) // path API (see also CanvasPathMethods)
void beginPath(); void beginPath();
void fill(optional CanvasFillRule fillRule = "nonzero"); void fill(optional CanvasFillRule fillRule = "nonzero");
@ -100,14 +141,25 @@ interface CanvasRenderingContext2D {
// optional CanvasFillRule fillRule = "nonzero"); // optional CanvasFillRule fillRule = "nonzero");
//boolean isPointInStroke(unrestricted double x, unrestricted double y); //boolean isPointInStroke(unrestricted double x, unrestricted double y);
//boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y); //boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y);
};
[NoInterfaceObject]//,Exposed=(Window,Worker)]
interface CanvasUserInterface {
// TODO?
};
[NoInterfaceObject]//,Exposed=(Window,Worker)]
interface CanvasText {
// text (see also the CanvasDrawingStyles interface) // text (see also the CanvasDrawingStyles interface)
//void fillText(DOMString text, unrestricted double x, unrestricted double y, //void fillText(DOMString text, unrestricted double x, unrestricted double y,
// optional unrestricted double maxWidth); // optional unrestricted double maxWidth);
//void strokeText(DOMString text, unrestricted double x, unrestricted double y, //void strokeText(DOMString text, unrestricted double x, unrestricted double y,
// optional unrestricted double maxWidth); // optional unrestricted double maxWidth);
//TextMetrics measureText(DOMString text); //TextMetrics measureText(DOMString text);
};
[NoInterfaceObject]//,Exposed=(Window,Worker)]
interface CanvasDrawImage {
// drawing images // drawing images
[Throws] [Throws]
void drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy); void drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy);
@ -119,12 +171,18 @@ interface CanvasRenderingContext2D {
unrestricted double sw, unrestricted double sh, unrestricted double sw, unrestricted double sh,
unrestricted double dx, unrestricted double dy, unrestricted double dx, unrestricted double dy,
unrestricted double dw, unrestricted double dh); unrestricted double dw, unrestricted double dh);
};
[NoInterfaceObject]//,Exposed=(Window,Worker)]
interface CanvasHitRegion {
// hit regions // hit regions
//void addHitRegion(optional HitRegionOptions options); //void addHitRegion(optional HitRegionOptions options);
//void removeHitRegion(DOMString id); //void removeHitRegion(DOMString id);
//void clearHitRegions(); //void clearHitRegions();
};
[NoInterfaceObject]//,Exposed=(Window,Worker)]
interface CanvasImageData {
// pixel manipulation // pixel manipulation
[Throws] [Throws]
ImageData createImageData(double sw, double sh); ImageData createImageData(double sw, double sh);
@ -138,8 +196,9 @@ interface CanvasRenderingContext2D {
double dirtyX, double dirtyY, double dirtyX, double dirtyY,
double dirtyWidth, double dirtyHeight); double dirtyWidth, double dirtyHeight);
}; };
CanvasRenderingContext2D implements CanvasDrawingStyles; CanvasRenderingContext2D implements CanvasPathDrawingStyles;
CanvasRenderingContext2D implements CanvasPathMethods; CanvasRenderingContext2D implements CanvasTextDrawingStyles;
CanvasRenderingContext2D implements CanvasPath;
enum CanvasLineCap { "butt", "round", "square" }; enum CanvasLineCap { "butt", "round", "square" };
enum CanvasLineJoin { "round", "bevel", "miter"}; enum CanvasLineJoin { "round", "bevel", "miter"};
@ -148,7 +207,7 @@ enum CanvasTextBaseline { "top", "hanging", "middle", "alphabetic", "ideographic
enum CanvasDirection { "ltr", "rtl", "inherit" }; enum CanvasDirection { "ltr", "rtl", "inherit" };
[NoInterfaceObject] [NoInterfaceObject]
interface CanvasDrawingStyles { interface CanvasPathDrawingStyles {
// line caps/joins // line caps/joins
attribute unrestricted double lineWidth; // (default 1) attribute unrestricted double lineWidth; // (default 1)
attribute CanvasLineCap lineCap; // "butt", "round", "square" (default "butt") attribute CanvasLineCap lineCap; // "butt", "round", "square" (default "butt")
@ -159,7 +218,10 @@ interface CanvasDrawingStyles {
//void setLineDash(sequence<unrestricted double> segments); // default empty //void setLineDash(sequence<unrestricted double> segments); // default empty
//sequence<unrestricted double> getLineDash(); //sequence<unrestricted double> getLineDash();
//attribute unrestricted double lineDashOffset; //attribute unrestricted double lineDashOffset;
};
[NoInterfaceObject]
interface CanvasTextDrawingStyles {
// text // text
//attribute DOMString font; // (default 10px sans-serif) //attribute DOMString font; // (default 10px sans-serif)
//attribute CanvasTextAlign textAlign; // "start", "end", "left", "right", "center" (default: "start") //attribute CanvasTextAlign textAlign; // "start", "end", "left", "right", "center" (default: "start")
@ -169,7 +231,7 @@ interface CanvasDrawingStyles {
}; };
[NoInterfaceObject] [NoInterfaceObject]
interface CanvasPathMethods { interface CanvasPath {
// shared path API methods // shared path API methods
void closePath(); void closePath();
void moveTo(unrestricted double x, unrestricted double y); void moveTo(unrestricted double x, unrestricted double y);