Skip to content

Commit

Permalink
Re-sync Canvas API in html/dom/interfaces.html
Browse files Browse the repository at this point in the history
Re-sync Canvas API in html/dom/interfaces.html with the latest HTML specification.
  • Loading branch information
cdumez committed Aug 19, 2016
1 parent 2f92336 commit bd93d26
Showing 1 changed file with 129 additions and 60 deletions.
189 changes: 129 additions & 60 deletions html/dom/interfaces.html
Original file line number Diff line number Diff line change
Expand Up @@ -1944,150 +1944,228 @@ <h1>HTML IDL tests</h1>
};

typedef (CanvasRenderingContext2D or WebGLRenderingContext) RenderingContext;
callback BlobCallback = void (Blob? blob);

interface HTMLCanvasElement : HTMLElement {
attribute unsigned long width;
attribute unsigned long height;

RenderingContext? getContext(DOMString contextId, any... arguments);
boolean probablySupportsContext(DOMString contextId, any... arguments);

DOMString toDataURL(optional DOMString type, any... arguments);
void toBlob(FileCallback? _callback, optional DOMString type, any... arguments);
void toBlob(BlobCallback _callback, optional DOMString type, any... arguments);
};

typedef (HTMLImageElement or
SVGImageElement) HTMLOrSVGImageElement;

typedef (HTMLOrSVGImageElement or
HTMLVideoElement or
HTMLCanvasElement or
CanvasRenderingContext2D or
ImageBitmap) CanvasImageSource;

enum CanvasFillRule { "nonzero", "evenodd" };

interface CanvasRenderingContext2D {
dictionary CanvasRenderingContext2DSettings {
boolean alpha = true;
};

enum ImageSmoothingQuality { "low", "medium", "high" };

interface CanvasRenderingContext2D {
// back-reference to the canvas
readonly attribute HTMLCanvasElement canvas;
};
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 CanvasHitRegion;
CanvasRenderingContext2D implements CanvasImageData;
CanvasRenderingContext2D implements CanvasPathDrawingStyles;
CanvasRenderingContext2D implements CanvasTextDrawingStyles;
CanvasRenderingContext2D implements CanvasPath;

// canvas dimensions
attribute unsigned long width;
attribute unsigned long height;

[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)
attribute SVGMatrix currentTransform;
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);

[NewObject] DOMMatrix getTransform();
void setTransform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
void setTransform(optional DOMMatrixInit transform);
void resetTransform();

};

[NoInterfaceObject]
interface CanvasCompositing {
// compositing
attribute unrestricted double globalAlpha; // (default 1.0)
attribute DOMString globalCompositeOperation; // (default source-over)
attribute unrestricted double globalAlpha; // (default 1.0)
attribute DOMString globalCompositeOperation; // (default source-over)
};

[NoInterfaceObject]
interface CanvasImageSmoothing {
// image smoothing
attribute boolean imageSmoothingEnabled; // (default true)
attribute boolean imageSmoothingEnabled; // (default true)
attribute ImageSmoothingQuality imageSmoothingQuality; // (default low)

// 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)
};

[NoInterfaceObject]
interface CanvasFillStrokeStyles {
// colours and styles (see also the CanvasPathDrawingStyles and CanvasTextDrawingStyles interfaces)
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);
CanvasPattern? createPattern(CanvasImageSource image, [TreatNullAs=EmptyString] DOMString repetition);

};

[NoInterfaceObject]
interface CanvasShadowStyles {
// shadows
attribute unrestricted double shadowOffsetX; // (default 0)
attribute unrestricted double shadowOffsetY; // (default 0)
attribute unrestricted double shadowBlur; // (default 0)
attribute DOMString shadowColor; // (default transparent black)
attribute unrestricted double shadowOffsetX; // (default 0)
attribute unrestricted double shadowOffsetY; // (default 0)
attribute unrestricted double shadowBlur; // (default 0)
attribute DOMString shadowColor; // (default transparent black)
};

[NoInterfaceObject]
interface CanvasFilters {
// filters
attribute DOMString filter; // (default "none")
};

[NoInterfaceObject]
interface CanvasRect {
// rects
void clearRect(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);
void strokeRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
};

// path API (see also CanvasPathMethods)
[NoInterfaceObject]
interface CanvasDrawPath {
// path API (see also CanvasPath)
void beginPath();
void fill(optional CanvasFillRule fillRule = "nonzero");
void fill(Path2D path, optional CanvasFillRule fillRule = "nonzero");
void stroke();
void stroke(Path2D path);
void drawSystemFocusRing(Element element);
void drawSystemFocusRing(Path2D path, Element element);
boolean drawCustomFocusRing(Element element);
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 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 isPointInStroke(unrestricted double x, unrestricted double y);
boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y);
};

[NoInterfaceObject]
interface CanvasUserInterface {
void drawFocusIfNeeded(Element element);
void drawFocusIfNeeded(Path2D path, Element element);
void scrollPathIntoView();
void scrollPathIntoView(Path2D path);
};

// text (see also the CanvasDrawingStyles interface)
[NoInterfaceObject]
interface CanvasText {
// text (see also the CanvasPathDrawingStyles and CanvasTextDrawingStyles interfaces)
void fillText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
void strokeText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
TextMetrics measureText(DOMString text);
};

[NoInterfaceObject]
interface CanvasDrawImage {
// drawing images
void drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy);
void drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy, unrestricted double dw, unrestricted double dh);
void drawImage(CanvasImageSource image, unrestricted double sx, unrestricted double sy, unrestricted double sw, unrestricted double sh, unrestricted double dx, unrestricted double dy, unrestricted double dw, unrestricted double dh);
};

[NoInterfaceObject]
interface CanvasHitRegion {
// hit regions
void addHitRegion(optional HitRegionOptions options);
void removeHitRegion(DOMString id);
void clearHitRegions();
};

[NoInterfaceObject]
interface CanvasImageData {
// pixel manipulation
ImageData createImageData(double sw, double sh);
ImageData createImageData(ImageData imagedata);
ImageData getImageData(double sx, double sy, double sw, double sh);
void putImageData(ImageData imagedata, double dx, double dy);
void putImageData(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
};
CanvasRenderingContext2D implements CanvasDrawingStyles;
CanvasRenderingContext2D implements CanvasPathMethods;

enum CanvasLineCap { "butt", "round", "square" };
enum CanvasLineJoin { "round", "bevel", "miter"};
enum CanvasTextAlign { "start", "end", "left", "right", "center" };
enum CanvasTextBaseline { "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" };
enum CanvasDirection { "ltr", "rtl", "inherit" };

[NoInterfaceObject]
interface CanvasDrawingStyles {
interface CanvasPathDrawingStyles {
// line caps/joins
attribute unrestricted double lineWidth; // (default 1)
attribute DOMString lineCap; // "butt", "round", "square" (default "butt")
attribute DOMString lineJoin; // "round", "bevel", "miter" (default "miter")
attribute unrestricted double miterLimit; // (default 10)
attribute unrestricted double lineWidth; // (default 1)
attribute CanvasLineCap lineCap; // (default "butt")
attribute CanvasLineJoin lineJoin; // (default "miter")
attribute unrestricted double miterLimit; // (default 10)

// dashed lines
void setLineDash(sequence<unrestricted double> segments); // default empty
sequence<unrestricted double> getLineDash();
attribute unrestricted double lineDashOffset;
attribute unrestricted double lineDashOffset;
};

[NoInterfaceObject]
interface CanvasTextDrawingStyles {
// text
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")
attribute DOMString direction; // "ltr", "rtl", "inherit" (default: "inherit")
attribute DOMString font; // (default 10px sans-serif)
attribute CanvasTextAlign textAlign; // (default: "start")
attribute CanvasTextBaseline textBaseline; // (default: "alphabetic")
attribute CanvasDirection direction; // (default: "inherit")
};

[NoInterfaceObject, Exposed=(Window,Worker)]
interface CanvasPathMethods {
interface CanvasPath {
// shared path API methods
void closePath();
void moveTo(unrestricted double x, unrestricted double y);
void lineTo(unrestricted double x, unrestricted double y);
void quadraticCurveTo(unrestricted double cpx, unrestricted double cpy, unrestricted double x, unrestricted double y);
void bezierCurveTo(unrestricted double cp1x, unrestricted double cp1y, unrestricted double cp2x, unrestricted double cp2y, unrestricted double x, unrestricted double y);
void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radius);
void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation);
void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radius);
void arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation);
void rect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
void arc(unrestricted double x, unrestricted double y, unrestricted double radius, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false);
void ellipse(unrestricted double x, unrestricted double y, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false);
void arc(unrestricted double x, unrestricted double y, unrestricted double radius, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false);
void ellipse(unrestricted double x, unrestricted double y, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false);
};

interface CanvasGradient {
Expand All @@ -2097,7 +2175,7 @@ <h1>HTML IDL tests</h1>

interface CanvasPattern {
// opaque object
void setTransform(SVGMatrix transform);
void setTransform(optional DOMMatrixInit transform);
};

interface TextMetrics {
Expand All @@ -2121,7 +2199,7 @@ <h1>HTML IDL tests</h1>
dictionary HitRegionOptions {
Path2D? path = null;
CanvasFillRule fillRule = "nonzero";
DOMString id = "";
DOMString id = "";
DOMString? parentID = null;
DOMString cursor = "inherit";
// for control-backed regions:
Expand All @@ -2140,23 +2218,14 @@ <h1>HTML IDL tests</h1>
readonly attribute Uint8ClampedArray data;
};

[Constructor(optional Element scope), Exposed=(Window,Worker)]
interface DrawingStyle { };
DrawingStyle implements CanvasDrawingStyles;

[Constructor,
Constructor(Path2D path),
Constructor(Path2D[] paths, optional CanvasFillRule fillRule = "nonzero"),
Constructor(sequence<Path2D> paths, optional CanvasFillRule fillRule = "nonzero"),
Constructor(DOMString d), Exposed=(Window,Worker)]
interface Path2D {
void addPath(Path2D path, optional SVGMatrix? transformation = null);
void addPathByStrokingPath(Path2D path, CanvasDrawingStyles styles, optional SVGMatrix? transformation = null);
void addText(DOMString text, CanvasDrawingStyles styles, SVGMatrix? transformation, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
void addPathByStrokingText(DOMString text, CanvasDrawingStyles styles, SVGMatrix? transformation, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
void addText(DOMString text, CanvasDrawingStyles styles, SVGMatrix? transformation, Path2D path, optional unrestricted double maxWidth);
void addPathByStrokingText(DOMString text, CanvasDrawingStyles styles, SVGMatrix? transformation, Path2D path, optional unrestricted double maxWidth);
};
Path2D implements CanvasPathMethods;
void addPath(Path2D path, optional DOMMatrixInit transform);
};
Path2D implements CanvasPath;

partial interface MouseEvent {
readonly attribute DOMString? region;
Expand Down

0 comments on commit bd93d26

Please sign in to comment.