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;
15 typedef (HTMLCanvasElement or OffscreenCanvas) CanvasSource;
18 interface HTMLCanvasElement : HTMLElement {
19 [HTMLConstructor] constructor();
21 [CEReactions, Pure, SetterThrows]
22 attribute unsigned long width;
23 [CEReactions, Pure, SetterThrows]
24 attribute unsigned long height;
27 nsISupports? getContext(DOMString contextId, optional any contextOptions = null);
29 [Throws, NeedsSubjectPrincipal]
30 DOMString toDataURL(optional DOMString type = "",
31 optional any encoderOptions);
32 [Throws, NeedsSubjectPrincipal]
33 undefined toBlob(BlobCallback callback,
34 optional DOMString type = "",
35 optional any encoderOptions);
38 // Mozilla specific bits
39 partial interface HTMLCanvasElement {
41 attribute boolean mozOpaque;
43 attribute PrintCallback? mozPrintCallback;
45 [Throws, Pref="canvas.capturestream.enabled", NeedsSubjectPrincipal]
46 CanvasCaptureMediaStream captureStream(optional double frameRate);
49 // For OffscreenCanvas
50 // Reference: https://wiki.whatwg.org/wiki/OffscreenCanvas
51 partial interface HTMLCanvasElement {
52 [Pref="gfx.offscreencanvas.enabled", Throws]
53 OffscreenCanvas transferControlToOffscreen();
58 interface MozCanvasPrintState
60 // A canvas rendering context.
61 readonly attribute nsISupports context;
63 // To be called when rendering to the context is done.
67 callback PrintCallback = undefined(MozCanvasPrintState ctx);
69 callback BlobCallback = undefined(Blob? blob);