1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Vladimir Vukicevic <vladimir@pobox.com>
19 * Portions created by the Initial Developer are Copyright (C) 2005
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #include
"nsISupports.idl"
39 #include
"nsIVariant.idl"
41 interface nsIDOMWindow
;
42 interface nsIDOMHTMLElement
;
43 interface nsIDOMHTMLImageElement
;
44 interface nsIDOMHTMLCanvasElement
;
46 [scriptable
, uuid(bbb20a59
-524e-4662-981e-5e142814b20c
)]
47 interface nsIDOMCanvasGradient
: nsISupports
49 void addColorStop
(in float offset
, in DOMString color
);
52 [scriptable
, uuid(21dea65c
-5c08
-4eb1
-ac82
-81fe95be77b8
)]
53 interface nsIDOMCanvasPattern
: nsISupports
57 [scriptable
, uuid(2d01715c
-ec7d
-424a
-ab85
-e0fd70c8665c
)]
58 interface nsIDOMTextMetrics
: nsISupports
60 readonly attribute
float width
;
63 [scriptable
, uuid(66e6d87c
-759c
-43a7
-b3d3
-3348180b35df
)]
64 interface nsIDOMCanvasRenderingContext2D
: nsISupports
66 // back-reference to the canvas element for which
67 // this context was created
68 readonly attribute nsIDOMHTMLCanvasElement canvas
;
75 void scale
(in float x
, in float y
);
76 void rotate
(in float angle
);
77 void translate
(in float x
, in float y
);
78 void transform
(in float m11
, in float m12
, in float m21
, in float m22
, in float dx
, in float dy
);
79 void setTransform
(in float m11
, in float m12
, in float m21
, in float m22
, in float dx
, in float dy
);
82 attribute
float globalAlpha
; /* default 1.0 -- opaque */
83 attribute DOMString globalCompositeOperation
; /* default "over" */
86 attribute nsIVariant strokeStyle
;
87 attribute nsIVariant fillStyle
;
89 nsIDOMCanvasGradient createLinearGradient
(in float x0
, in float y0
, in float x1
, in float y1
);
90 nsIDOMCanvasGradient createRadialGradient
(in float x0
, in float y0
, in float r0
, in float x1
, in float y1
, in float r1
);
91 //nsIDOMCanvasPattern createPattern(in nsIDOMHTMLImageElement image, in DOMString repetition);
92 nsIDOMCanvasPattern createPattern
(in nsIDOMHTMLElement image
, in DOMString repetition
);
93 attribute
float lineWidth
; /* default 1 */
94 attribute DOMString lineCap
; /* "butt", "round", "square" (default) */
95 attribute DOMString lineJoin
; /* "round", "bevel", "miter" (default) */
96 attribute
float miterLimit
; /* default 10 */
99 attribute
float shadowOffsetX
;
100 attribute
float shadowOffsetY
;
101 attribute
float shadowBlur
;
102 attribute DOMString shadowColor
;
105 void clearRect
(in float x
, in float y
, in float w
, in float h
);
106 void fillRect
(in float x
, in float y
, in float w
, in float h
);
107 void strokeRect
(in float x
, in float y
, in float w
, in float h
);
113 void moveTo
(in float x
, in float y
);
114 void lineTo
(in float x
, in float y
);
115 void quadraticCurveTo
(in float cpx
, in float cpy
, in float x
, in float y
);
116 void bezierCurveTo
(in float cp1x
, in float cp1y
, in float cp2x
, in float cp2y
, in float x
, in float y
);
117 void arcTo
(in float x1
, in float y1
, in float x2
, in float y2
, in float radius
);
118 void arc
(in float x
, in float y
, in float r
, in float startAngle
, in float endAngle
, in boolean clockwise
);
119 void rect
(in float x
, in float y
, in float w
, in float h
);
126 attribute DOMString font
; /* default "10px sans-serif" */
127 attribute DOMString textAlign
; /* "start" (default), "end", "left", "right",
129 attribute DOMString textBaseline
; /* "alphabetic" (default), "top", "hanging",
130 "middle", "ideographic", "bottom" */
132 void fillText
(in DOMString text
, in float x
, in float y
, [optional] in float maxWidth
);
133 void strokeText
(in DOMString text
, in float x
, in float y
, [optional] in float maxWidth
);
134 nsIDOMTextMetrics measureText
(in DOMString text
);
136 attribute DOMString mozTextStyle
;
137 void mozDrawText
(in DOMString textToDraw
);
138 float mozMeasureText
(in DOMString textToMeasure
);
139 void mozPathText
(in DOMString textToPath
);
140 void mozTextAlongPath
(in DOMString textToDraw
, in boolean stroke
);
145 void drawImage(in HTMLImageElement image, in float dx, in float dy);
146 void drawImage(in HTMLImageElement image, in float dx, in float dy, in float sw, in float sh);
147 void drawImage(in HTMLImageElement image, in float sx, in float sy, in float sw, in float sh, in float dx, in float dy, in float dw, in float dh);
150 // point-membership test
151 boolean isPointInPath
(in float x
, in float y
);
153 // pixel manipulation
154 // ImageData getImageData (in float x, in float y, in float width, in float height);
155 // void putImageData (in ImageData d, in float x, in float y);
156 // ImageData = { width: #, height: #, data: [r, g, b, a, ...] }
161 // ImageData createImageData(in float w, in float h);
162 void createImageData
();
164 // Show the caret if appropriate when drawing
165 const unsigned long DRAWWINDOW_DRAW_CARET
= 0x01;
166 // Don't flush pending layout notifications that could otherwise
168 const unsigned long DRAWWINDOW_DO_NOT_FLUSH
= 0x02;
171 * Renders a region of a window into the canvas. The contents of
172 * the window's viewport are rendered, ignoring viewport clipping
178 * @param h specify the area of the window to render, in CSS
181 * @param backgroundColor the canvas is filled with this color
182 * before we render the window into it. This color may be
183 * transparent/translucent. It is given as a CSS color string
184 * (e.g., rgb() or rgba()).
186 * @param flags Uused to better control the drawWindow call.
187 * Flags can be ORed together.
189 * Of course, the rendering obeys the current scale, transform and
190 * globalAlpha values.
193 * -- If 'rgba(0,0,0,0)' is used for the background color, the
194 * drawing will be transparent wherever the window is transparent.
195 * -- Top-level browsed documents are usually not transparent
196 * because the user's background-color preference is applied,
197 * but IFRAMEs are transparent if the page doesn't set a background.
198 * -- If an opaque color is used for the background color, rendering
199 * will be faster because we won't have to compute the window's
202 * This API cannot currently be used by Web content. It is chrome
205 void drawWindow
(in nsIDOMWindow window
, in long x
, in long y
,
206 in long w
, in long h
, in DOMString bgColor
,
207 [optional] in unsigned long flags
);