blob: 60baf9b4a6cad2ec5a88b370fd14a738f8190a0d [file] [log] [blame]
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
enum CanvasWindingRule { "nonzero", "evenodd" };
[
TypeChecking=Unrestricted,
WillBeGarbageCollected,
] interface CanvasRenderingContext2D {
readonly attribute HTMLCanvasElement canvas;
void save();
void restore();
[TypeChecking=Interface|Nullable, RuntimeEnabled=ExperimentalCanvasFeatures] attribute SVGMatrix currentTransform;
void scale(unrestricted float sx, unrestricted float sy);
void rotate(unrestricted float angle);
void translate(unrestricted float tx, unrestricted float ty);
void transform(unrestricted float m11, unrestricted float m12, unrestricted float m21, unrestricted float m22, unrestricted float dx, unrestricted float dy);
void setTransform(unrestricted float m11, unrestricted float m12, unrestricted float m21, unrestricted float m22, unrestricted float dx, unrestricted float dy);
void resetTransform();
attribute unrestricted float globalAlpha;
[TreatNullAs=NullString] attribute DOMString globalCompositeOperation;
CanvasGradient createLinearGradient(float x0, float y0, float x1, float y1);
[RaisesException] CanvasGradient createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1);
attribute unrestricted float lineWidth;
[TreatNullAs=NullString] attribute DOMString lineCap;
[TreatNullAs=NullString] attribute DOMString lineJoin;
attribute unrestricted float miterLimit;
attribute unrestricted float shadowOffsetX;
attribute unrestricted float shadowOffsetY;
attribute unrestricted float shadowBlur;
[TreatNullAs=NullString] attribute DOMString shadowColor;
void setLineDash(sequence<unrestricted float> dash);
sequence<unrestricted float> getLineDash();
attribute unrestricted float lineDashOffset;
void clearRect(unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height);
void fillRect(unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height);
void beginPath();
attribute Path2D currentPath;
// FIXME: Simplify these using optional CanvasWindingRule once crbug.com/339000 gets fixed.
void fill();
[RuntimeEnabled=Path2D, TypeChecking=Interface|Nullable] void fill(Path2D path);
[TypeChecking=Interface|Nullable] void fill(CanvasWindingRule winding);
[RuntimeEnabled=Path2D, TypeChecking=Interface|Nullable] void fill(Path2D path, CanvasWindingRule winding);
void stroke();
[RuntimeEnabled=Path2D, TypeChecking=Interface|Nullable] void stroke(Path2D path);
// FIXME: Simplify these using optional CanvasWindingRule once crbug.com/339000 gets fixed.
void clip();
[RuntimeEnabled=Path2D, TypeChecking=Interface|Nullable] void clip(Path2D path);
[TypeChecking=Interface|Nullable] void clip(CanvasWindingRule winding);
[RuntimeEnabled=Path2D, TypeChecking=Interface|Nullable] void clip(Path2D path, CanvasWindingRule winding);
// FIXME: Simplify these using optional CanvasWindingRule once crbug.com/339000 gets fixed.
boolean isPointInPath(unrestricted float x, unrestricted float y);
[RuntimeEnabled=Path2D, TypeChecking=Interface|Nullable] boolean isPointInPath(Path2D path, unrestricted float x, unrestricted float y);
[TypeChecking=Interface|Nullable] boolean isPointInPath(unrestricted float x, unrestricted float y, CanvasWindingRule winding);
[RuntimeEnabled=Path2D, TypeChecking=Interface|Nullable] boolean isPointInPath(Path2D path, unrestricted float x, unrestricted float y, CanvasWindingRule winding);
boolean isPointInStroke(unrestricted float x, unrestricted float y);
[RuntimeEnabled=Path2D, TypeChecking=Interface|Nullable] boolean isPointInStroke(Path2D path, unrestricted float x, unrestricted float y);
[RuntimeEnabled=ExperimentalCanvasFeatures] void scrollPathIntoView();
[RuntimeEnabled=ExperimentalCanvasFeatures, TypeChecking=Interface|Nullable] void scrollPathIntoView(Path2D path);
// text
attribute DOMString font;
attribute DOMString textAlign;
attribute DOMString textBaseline;
void fillText(DOMString text, unrestricted float x, unrestricted float y, optional unrestricted float maxWidth);
void strokeText(DOMString text, unrestricted float x, unrestricted float y, optional unrestricted float maxWidth);
TextMetrics measureText(DOMString text);
// Context state
// Should be merged with WebGL counterpart in CanvasRenderingContext, once no-longer experimental
[RuntimeEnabled=ExperimentalCanvasFeatures] boolean isContextLost();
void strokeRect(unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height);
[RaisesException, TypeChecking=Interface|Nullable] void drawImage(HTMLImageElement image, unrestricted float x, unrestricted float y);
[RaisesException, TypeChecking=Interface|Nullable] void drawImage(HTMLImageElement image, unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height);
[RaisesException, TypeChecking=Interface|Nullable] void drawImage(HTMLImageElement image, unrestricted float sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh);
[RaisesException, TypeChecking=Interface|Nullable] void drawImage(HTMLCanvasElement canvas, unrestricted float x, unrestricted float y);
[RaisesException, TypeChecking=Interface|Nullable] void drawImage(HTMLCanvasElement canvas, unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height);
[RaisesException, TypeChecking=Interface|Nullable] void drawImage(HTMLCanvasElement canvas, unrestricted float sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh);
[RaisesException, TypeChecking=Interface|Nullable] void drawImage(HTMLVideoElement video, unrestricted float x, unrestricted float y);
[RaisesException, TypeChecking=Interface|Nullable] void drawImage(HTMLVideoElement video, unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height);
[RaisesException, TypeChecking=Interface|Nullable] void drawImage(HTMLVideoElement video, unrestricted float sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh);
[RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException, TypeChecking=Interface|Nullable] void drawImage(ImageBitmap imageBitmap, unrestricted float x, unrestricted float y);
[RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException, TypeChecking=Interface|Nullable] void drawImage(ImageBitmap imageBitmap, unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height);
[RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException, TypeChecking=Interface|Nullable] void drawImage(ImageBitmap imageBitmap, unrestricted float sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh);
[TypeChecking=Interface|Nullable] void putImageData(ImageData imagedata, float dx, float dy);
[TypeChecking=Interface|Nullable] void putImageData(ImageData imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
[RaisesException, TypeChecking=Interface|Nullable] CanvasPattern createPattern(HTMLCanvasElement canvas, [TreatNullAs=NullString] DOMString repetitionType);
[RaisesException, TypeChecking=Interface|Nullable] CanvasPattern createPattern(HTMLImageElement image, [TreatNullAs=NullString] DOMString repetitionType);
[RaisesException, TypeChecking=Interface|Nullable] CanvasPattern createPattern(HTMLVideoElement image, [TreatNullAs=NullString] DOMString repetitionType);
[TypeChecking=Interface|Nullable] ImageData createImageData(ImageData imagedata);
[RaisesException] ImageData createImageData(float sw, float sh);
[Custom] attribute object strokeStyle;
[Custom] attribute object fillStyle;
// pixel manipulation
[RaisesException] ImageData getImageData(float sx, float sy, float sw, float sh);
// Focus rings
[RuntimeEnabled=ExperimentalCanvasFeatures, TypeChecking=Interface|Nullable] void drawFocusIfNeeded(Element element);
[RuntimeEnabled=ExperimentalCanvasFeatures, TypeChecking=Interface|Nullable] void drawFocusIfNeeded(Path2D path, Element element);
[RuntimeEnabled=ExperimentalCanvasFeatures, TypeChecking=Interface|Nullable] boolean drawCustomFocusRing(Element element);
[ImplementedAs=imageSmoothingEnabled, MeasureAs=PrefixedImageSmoothingEnabled] attribute boolean webkitImageSmoothingEnabled;
[MeasureAs=UnprefixedImageSmoothingEnabled] attribute boolean imageSmoothingEnabled;
Canvas2DContextAttributes getContextAttributes();
// Non-standard APIs. Candidates for deprecation
[MeasureAs=CanvasRenderingContext2DSetAlpha] void setAlpha(unrestricted float alpha);
[MeasureAs=CanvasRenderingContext2DSetCompositeOperation] void setCompositeOperation(DOMString compositeOperation);
[MeasureAs=CanvasRenderingContext2DSetLineWidth] void setLineWidth(unrestricted float width);
[MeasureAs=CanvasRenderingContext2DSetLineCap] void setLineCap(DOMString cap);
[MeasureAs=CanvasRenderingContext2DSetLineJoin] void setLineJoin(DOMString join);
[MeasureAs=CanvasRenderingContext2DSetMiterLimit] void setMiterLimit(unrestricted float limit);
[MeasureAs=CanvasRenderingContext2DClearShadow] void clearShadow();
[MeasureAs=CanvasRenderingContext2DSetStrokeColor] void setStrokeColor([LegacyOverloadString] DOMString color, optional unrestricted float alpha);
[MeasureAs=CanvasRenderingContext2DSetStrokeColor] void setStrokeColor(unrestricted float grayLevel, optional unrestricted float alpha);
[MeasureAs=CanvasRenderingContext2DSetStrokeColor] void setStrokeColor(unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a);
[MeasureAs=CanvasRenderingContext2DSetStrokeColor] void setStrokeColor(unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a);
[MeasureAs=CanvasRenderingContext2DSetFillColor] void setFillColor([LegacyOverloadString] DOMString color, optional unrestricted float alpha);
[MeasureAs=CanvasRenderingContext2DSetFillColor] void setFillColor(unrestricted float grayLevel, optional unrestricted float alpha);
[MeasureAs=CanvasRenderingContext2DSetFillColor] void setFillColor(unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a);
[MeasureAs=CanvasRenderingContext2DSetFillColor] void setFillColor(unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a);
[TypeChecking=Interface|Nullable, MeasureAs=CanvasRenderingContext2DDrawImageFromRect] void drawImageFromRect(
HTMLImageElement? image, optional unrestricted float sx, optional unrestricted float sy, optional unrestricted float sw, optional unrestricted float sh,
optional unrestricted float dx, optional unrestricted float dy, optional unrestricted float dw, optional unrestricted float dh, optional DOMString compositeOperation);
[MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, [LegacyOverloadString] optional DOMString color, optional unrestricted float alpha);
[MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, unrestricted float grayLevel, optional unrestricted float alpha);
[MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a);
[MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a);
};
CanvasRenderingContext2D implements CanvasPathMethods;