2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
#include "nsIVariant.idl"
|
|
|
|
|
|
|
|
interface nsIDOMWindow;
|
2009-08-10 07:41:12 -07:00
|
|
|
interface nsIDOMElement;
|
2007-03-22 10:30:00 -07:00
|
|
|
interface nsIDOMHTMLElement;
|
|
|
|
interface nsIDOMHTMLImageElement;
|
|
|
|
interface nsIDOMHTMLCanvasElement;
|
2009-10-29 10:58:31 -07:00
|
|
|
interface nsIDOMXULElement;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
[scriptable, uuid(bbb20a59-524e-4662-981e-5e142814b20c)]
|
|
|
|
interface nsIDOMCanvasGradient : nsISupports
|
|
|
|
{
|
|
|
|
void addColorStop(in float offset, in DOMString color);
|
|
|
|
};
|
|
|
|
|
|
|
|
[scriptable, uuid(21dea65c-5c08-4eb1-ac82-81fe95be77b8)]
|
|
|
|
interface nsIDOMCanvasPattern : nsISupports
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2008-06-10 16:16:59 -07:00
|
|
|
[scriptable, uuid(2d01715c-ec7d-424a-ab85-e0fd70c8665c)]
|
|
|
|
interface nsIDOMTextMetrics : nsISupports
|
|
|
|
{
|
|
|
|
readonly attribute float width;
|
|
|
|
};
|
|
|
|
|
2012-03-16 02:44:08 -07:00
|
|
|
[scriptable, builtinclass, uuid(1ea11207-b3e3-4ffc-a256-bf5c7011e806)]
|
|
|
|
interface nsIDOMImageData : nsISupports
|
|
|
|
{
|
|
|
|
readonly attribute unsigned long width;
|
|
|
|
readonly attribute unsigned long height;
|
2012-03-20 13:57:00 -07:00
|
|
|
[implicit_jscontext] readonly attribute jsval data;
|
2012-03-16 02:44:08 -07:00
|
|
|
};
|
|
|
|
|
2012-03-16 02:48:55 -07:00
|
|
|
[scriptable, uuid(c835c768-2dcc-461c-82f5-3653710d2942)]
|
2007-03-22 10:30:00 -07:00
|
|
|
interface nsIDOMCanvasRenderingContext2D : nsISupports
|
|
|
|
{
|
|
|
|
// back-reference to the canvas element for which
|
|
|
|
// this context was created
|
|
|
|
readonly attribute nsIDOMHTMLCanvasElement canvas;
|
|
|
|
|
|
|
|
// state
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(MozSave)]
|
2007-03-22 10:30:00 -07:00
|
|
|
void save();
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(MozRestore)]
|
2007-03-22 10:30:00 -07:00
|
|
|
void restore();
|
|
|
|
|
|
|
|
// transformations
|
|
|
|
void scale(in float x, in float y);
|
|
|
|
void rotate(in float angle);
|
|
|
|
void translate(in float x, in float y);
|
|
|
|
void transform(in float m11, in float m12, in float m21, in float m22, in float dx, in float dy);
|
|
|
|
void setTransform(in float m11, in float m12, in float m21, in float m22, in float dx, in float dy);
|
2011-06-29 14:34:58 -07:00
|
|
|
[implicit_jscontext]
|
|
|
|
attribute jsval mozCurrentTransform; // [ m11, m12, m21, m22, dx, dy ], i.e. row major
|
|
|
|
[implicit_jscontext]
|
|
|
|
attribute jsval mozCurrentTransformInverse;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// compositing
|
|
|
|
attribute float globalAlpha; /* default 1.0 -- opaque */
|
|
|
|
attribute DOMString globalCompositeOperation; /* default "over" */
|
|
|
|
|
2010-03-03 16:40:25 -08:00
|
|
|
// Colors and Styles
|
|
|
|
|
|
|
|
// These attributes work, but are quickstubbed for JS code. Native
|
|
|
|
// code should use the _multi variants below.
|
2007-03-22 10:30:00 -07:00
|
|
|
attribute nsIVariant strokeStyle;
|
|
|
|
attribute nsIVariant fillStyle;
|
|
|
|
|
2010-03-03 16:40:25 -08:00
|
|
|
// These do the actual work. Use these from c++ -- only one of str or iface
|
|
|
|
// should be specified; the one that's not null/void is used. For the getter,
|
|
|
|
// ifaceType is 0 if it's a string, 1 if it's a pattern, or 2 if it's a gradient
|
|
|
|
%{C++
|
|
|
|
enum CanvasMultiGetterType {
|
|
|
|
CMG_STYLE_STRING = 0,
|
|
|
|
CMG_STYLE_PATTERN = 1,
|
|
|
|
CMG_STYLE_GRADIENT = 2
|
|
|
|
};
|
|
|
|
%}
|
|
|
|
[noscript] void setStrokeStyle_multi(in DOMString str, in nsISupports iface);
|
|
|
|
[noscript] void getStrokeStyle_multi(out DOMString str, out nsISupports iface, out long type);
|
|
|
|
[noscript] void setFillStyle_multi(in DOMString str, in nsISupports iface);
|
|
|
|
[noscript] void getFillStyle_multi(out DOMString str, out nsISupports iface, out long type);
|
|
|
|
|
2011-06-09 19:15:13 -07:00
|
|
|
//attribute DOMString fillRule;
|
|
|
|
attribute DOMString mozFillRule; /* "evenodd", "nonzero" (default) */
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIDOMCanvasGradient createLinearGradient (in float x0, in float y0, in float x1, in float y1);
|
|
|
|
nsIDOMCanvasGradient createRadialGradient(in float x0, in float y0, in float r0, in float x1, in float y1, in float r1);
|
2012-08-23 12:23:23 -07:00
|
|
|
nsIDOMCanvasPattern createPattern(in nsIDOMHTMLElement image, in DOMString repetition);
|
2007-03-22 10:30:00 -07:00
|
|
|
attribute float lineWidth; /* default 1 */
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(MozLineCap)]
|
2007-03-22 10:30:00 -07:00
|
|
|
attribute DOMString lineCap; /* "butt", "round", "square" (default) */
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(MozLineJoin)]
|
2007-03-22 10:30:00 -07:00
|
|
|
attribute DOMString lineJoin; /* "round", "bevel", "miter" (default) */
|
|
|
|
attribute float miterLimit; /* default 10 */
|
|
|
|
|
2011-06-29 14:34:58 -07:00
|
|
|
[implicit_jscontext]
|
|
|
|
attribute jsval mozDash; /* default |null| */
|
|
|
|
attribute float mozDashOffset; /* default 0.0 */
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// shadows
|
|
|
|
attribute float shadowOffsetX;
|
|
|
|
attribute float shadowOffsetY;
|
|
|
|
attribute float shadowBlur;
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(MozShadowColor)]
|
2007-03-22 10:30:00 -07:00
|
|
|
attribute DOMString shadowColor;
|
|
|
|
|
|
|
|
// rects
|
|
|
|
void clearRect(in float x, in float y, in float w, in float h);
|
|
|
|
void fillRect(in float x, in float y, in float w, in float h);
|
|
|
|
void strokeRect(in float x, in float y, in float w, in float h);
|
|
|
|
|
|
|
|
// path API
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(MozBeginPath)]
|
2007-03-22 10:30:00 -07:00
|
|
|
void beginPath();
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(MozClosePath)]
|
2007-03-22 10:30:00 -07:00
|
|
|
void closePath();
|
|
|
|
|
|
|
|
void moveTo(in float x, in float y);
|
|
|
|
void lineTo(in float x, in float y);
|
|
|
|
void quadraticCurveTo(in float cpx, in float cpy, in float x, in float y);
|
|
|
|
void bezierCurveTo(in float cp1x, in float cp1y, in float cp2x, in float cp2y, in float x, in float y);
|
|
|
|
void arcTo(in float x1, in float y1, in float x2, in float y2, in float radius);
|
2010-12-08 07:56:01 -08:00
|
|
|
void arc(in float x, in float y, in float r, in float startAngle, in float endAngle, [optional] in boolean anticlockwise);
|
2007-03-22 10:30:00 -07:00
|
|
|
void rect(in float x, in float y, in float w, in float h);
|
|
|
|
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(MozFill)]
|
2007-03-22 10:30:00 -07:00
|
|
|
void fill();
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(MozStroke)]
|
2007-03-22 10:30:00 -07:00
|
|
|
void stroke();
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(MozClip)]
|
2007-03-22 10:30:00 -07:00
|
|
|
void clip();
|
|
|
|
|
2007-07-25 11:21:34 -07:00
|
|
|
// text api
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(MozFont)]
|
2008-06-10 16:16:59 -07:00
|
|
|
attribute DOMString font; /* default "10px sans-serif" */
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(MozTextAlign)]
|
2008-06-10 16:16:59 -07:00
|
|
|
attribute DOMString textAlign; /* "start" (default), "end", "left", "right",
|
|
|
|
"center" */
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(MozTextBaseline)]
|
2008-06-10 16:16:59 -07:00
|
|
|
attribute DOMString textBaseline; /* "alphabetic" (default), "top", "hanging",
|
|
|
|
"middle", "ideographic", "bottom" */
|
|
|
|
|
|
|
|
void fillText(in DOMString text, in float x, in float y, [optional] in float maxWidth);
|
|
|
|
void strokeText(in DOMString text, in float x, in float y, [optional] in float maxWidth);
|
|
|
|
nsIDOMTextMetrics measureText(in DOMString text);
|
|
|
|
|
2012-06-13 08:14:15 -07:00
|
|
|
[binaryname(TextStyle)]
|
2011-07-05 03:15:17 -07:00
|
|
|
attribute DOMString mozTextStyle;
|
2007-07-25 11:21:34 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// image api
|
2009-08-10 07:41:12 -07:00
|
|
|
|
|
|
|
[optional_argc] void drawImage(in nsIDOMElement image,
|
|
|
|
in float a1, in float a2,
|
|
|
|
[optional] in float a3,
|
|
|
|
[optional] in float a4,
|
|
|
|
[optional] in float a5,
|
|
|
|
[optional] in float a6,
|
|
|
|
[optional] in float a7,
|
|
|
|
[optional] in float a8);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
void drawImage(in HTMLImageElement image, in float dx, in float dy);
|
|
|
|
void drawImage(in HTMLImageElement image, in float dx, in float dy, in float sw, in float sh);
|
|
|
|
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);
|
|
|
|
*/
|
|
|
|
|
|
|
|
// point-membership test
|
|
|
|
boolean isPointInPath(in float x, in float y);
|
|
|
|
|
|
|
|
// pixel manipulation
|
|
|
|
// ImageData getImageData (in float x, in float y, in float width, in float height);
|
|
|
|
// void putImageData (in ImageData d, in float x, in float y);
|
|
|
|
// ImageData = { width: #, height: #, data: [r, g, b, a, ...] }
|
|
|
|
|
2012-03-16 02:48:55 -07:00
|
|
|
[implicit_jscontext]
|
|
|
|
nsIDOMImageData getImageData(in double sx, in double sy, in double sw, in double sh);
|
|
|
|
|
2012-07-31 08:35:25 -07:00
|
|
|
|
|
|
|
// void putImageData(ImageData imagedata, double dx, double dy);
|
|
|
|
// void putImageDataHD(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
|
|
|
|
// We use jsval for the imageData because that's what our C++ code wants
|
|
|
|
[implicit_jscontext, optional_argc]
|
|
|
|
void putImageData(in jsval imageData, in double dx, in double dy,
|
|
|
|
[optional] in double dirtyX, [optional] in double dirtyY,
|
|
|
|
[optional] in double dirtyWidth,
|
|
|
|
[optional] in double dirtyHeight);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-16 02:48:55 -07:00
|
|
|
// dataLen must be == width*height*4 in this call
|
2010-03-03 16:40:27 -08:00
|
|
|
[noscript] void putImageData_explicit(in long x, in long y, in unsigned long width, in unsigned long height,
|
2010-12-04 07:44:26 -08:00
|
|
|
[array, size_is(dataLen)] in octet dataPtr, in unsigned long dataLen, in boolean hasDirtyRect,
|
|
|
|
in long dirtyX, in long dirtyY, in long dirtyWidth, in long dirtyHeight);
|
2010-03-03 16:40:27 -08:00
|
|
|
|
2012-07-31 08:35:25 -07:00
|
|
|
// ImageData createImageData(double w, double h);
|
|
|
|
// ImageData createImageData(ImageData data);
|
|
|
|
[implicit_jscontext, optional_argc]
|
|
|
|
nsIDOMImageData createImageData(in jsval arg1, [optional] in jsval arg2);
|
2008-09-02 10:52:22 -07:00
|
|
|
|
2009-04-07 12:05:41 -07:00
|
|
|
// image smoothing mode -- if disabled, images won't be smoothed
|
|
|
|
// if scaled.
|
|
|
|
attribute boolean mozImageSmoothingEnabled;
|
|
|
|
|
2008-10-13 23:29:30 -07:00
|
|
|
// Show the caret if appropriate when drawing
|
|
|
|
const unsigned long DRAWWINDOW_DRAW_CARET = 0x01;
|
|
|
|
// Don't flush pending layout notifications that could otherwise
|
|
|
|
// be batched up
|
|
|
|
const unsigned long DRAWWINDOW_DO_NOT_FLUSH = 0x02;
|
2009-07-21 15:45:21 -07:00
|
|
|
// Draw scrollbars and scroll the viewport if they are present
|
|
|
|
const unsigned long DRAWWINDOW_DRAW_VIEW = 0x04;
|
2010-03-01 00:03:49 -08:00
|
|
|
// Use the widget layer manager if available. This means hardware
|
|
|
|
// acceleration may be used, but it might actually be slower or
|
|
|
|
// lower quality than normal. It will however more accurately reflect
|
|
|
|
// the pixels rendered to the screen.
|
|
|
|
const unsigned long DRAWWINDOW_USE_WIDGET_LAYERS = 0x08;
|
2010-07-26 14:20:45 -07:00
|
|
|
// Don't synchronously decode images - draw what we have
|
|
|
|
const unsigned long DRAWWINDOW_ASYNC_DECODE_IMAGES = 0x10;
|
2009-07-21 15:45:21 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Renders a region of a window into the canvas. The contents of
|
|
|
|
* the window's viewport are rendered, ignoring viewport clipping
|
|
|
|
* and scrolling.
|
|
|
|
*
|
|
|
|
* @param x
|
|
|
|
* @param y
|
|
|
|
* @param w
|
|
|
|
* @param h specify the area of the window to render, in CSS
|
|
|
|
* pixels.
|
|
|
|
*
|
|
|
|
* @param backgroundColor the canvas is filled with this color
|
|
|
|
* before we render the window into it. This color may be
|
|
|
|
* transparent/translucent. It is given as a CSS color string
|
|
|
|
* (e.g., rgb() or rgba()).
|
|
|
|
*
|
2012-02-22 20:16:29 -08:00
|
|
|
* @param flags Used to better control the drawWindow call.
|
2008-10-13 23:29:30 -07:00
|
|
|
* Flags can be ORed together.
|
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* Of course, the rendering obeys the current scale, transform and
|
|
|
|
* globalAlpha values.
|
|
|
|
*
|
|
|
|
* Hints:
|
|
|
|
* -- If 'rgba(0,0,0,0)' is used for the background color, the
|
|
|
|
* drawing will be transparent wherever the window is transparent.
|
|
|
|
* -- Top-level browsed documents are usually not transparent
|
|
|
|
* because the user's background-color preference is applied,
|
|
|
|
* but IFRAMEs are transparent if the page doesn't set a background.
|
|
|
|
* -- If an opaque color is used for the background color, rendering
|
|
|
|
* will be faster because we won't have to compute the window's
|
|
|
|
* transparency.
|
|
|
|
*
|
|
|
|
* This API cannot currently be used by Web content. It is chrome
|
|
|
|
* only.
|
|
|
|
*/
|
2009-01-07 00:31:36 -08:00
|
|
|
void drawWindow(in nsIDOMWindow window, in float x, in float y,
|
|
|
|
in float w, in float h, in DOMString bgColor,
|
2008-10-13 23:29:30 -07:00
|
|
|
[optional] in unsigned long flags);
|
2009-10-29 10:58:31 -07:00
|
|
|
void asyncDrawXULElement(in nsIDOMXULElement elem, in float x, in float y,
|
|
|
|
in float w, in float h, in DOMString bgColor,
|
|
|
|
[optional] in unsigned long flags);
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|