1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 * The origin of this IDL file is
7 * http://www.whatwg.org/specs/web-apps/current-work/#the-canvas-element
8 * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
9 * Opera Software ASA. You are granted a license to use, reproduce
10 * and create derivative works of this document.
13 interface nsISupports;
17 interface HTMLCanvasElement : HTMLElement {
18 [HTMLConstructor] constructor();
20 [CEReactions, Pure, SetterThrows]
21 attribute unsigned long width;
22 [CEReactions, Pure, SetterThrows]
23 attribute unsigned long height;
26 nsISupports? getContext(DOMString contextId, optional any contextOptions = null);
28 [Throws, NeedsSubjectPrincipal]
29 DOMString toDataURL(optional DOMString type = "",
30 optional any encoderOptions);
31 [Throws, NeedsSubjectPrincipal]
32 void toBlob(BlobCallback callback,
33 optional DOMString type = "",
34 optional any encoderOptions);
37 // Mozilla specific bits
38 partial interface HTMLCanvasElement {
40 attribute boolean mozOpaque;
41 [Throws, NeedsSubjectPrincipal, Pref="canvas.mozgetasfile.enabled"]
42 File mozGetAsFile(DOMString name, optional DOMString? type = null);
43 // A Mozilla-only extension to get a canvas context backed by double-buffered
44 // shared memory. Only privileged callers can call this.
46 nsISupports? MozGetIPCContext(DOMString contextId);
48 attribute PrintCallback? mozPrintCallback;
50 [Throws, Pref="canvas.capturestream.enabled", NeedsSubjectPrincipal]
51 CanvasCaptureMediaStream captureStream(optional double frameRate);
54 // For OffscreenCanvas
55 // Reference: https://wiki.whatwg.org/wiki/OffscreenCanvas
56 partial interface HTMLCanvasElement {
57 [Pref="gfx.offscreencanvas.enabled", Throws]
58 OffscreenCanvas transferControlToOffscreen();
63 interface MozCanvasPrintState
65 // A canvas rendering context.
66 readonly attribute nsISupports context;
68 // To be called when rendering to the context is done.
72 callback PrintCallback = void(MozCanvasPrintState ctx);
74 callback BlobCallback = void(Blob? blob);