HTMLCanvasElement.webidl (2138B)
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/. 5 * 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. 11 */ 12 13 interface nsISupports; 14 15 typedef (HTMLCanvasElement or OffscreenCanvas) CanvasSource; 16 17 [Exposed=Window] 18 interface HTMLCanvasElement : HTMLElement { 19 [HTMLConstructor] constructor(); 20 21 [CEReactions, Pure, SetterThrows] 22 attribute unsigned long width; 23 [CEReactions, Pure, SetterThrows] 24 attribute unsigned long height; 25 26 [Throws] 27 nsISupports? getContext(DOMString contextId, optional any contextOptions = null); 28 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); 36 }; 37 38 // Mozilla specific bits 39 partial interface HTMLCanvasElement { 40 [Pure, SetterThrows] 41 attribute boolean mozOpaque; 42 43 attribute PrintCallback? mozPrintCallback; 44 45 [Throws, NeedsSubjectPrincipal] 46 CanvasCaptureMediaStream captureStream(optional double frameRate); 47 }; 48 49 // For OffscreenCanvas 50 // Reference: https://wiki.whatwg.org/wiki/OffscreenCanvas 51 partial interface HTMLCanvasElement { 52 [Throws] 53 OffscreenCanvas transferControlToOffscreen(); 54 }; 55 56 [ChromeOnly, 57 Exposed=Window] 58 interface MozCanvasPrintState 59 { 60 // A canvas rendering context. 61 readonly attribute nsISupports context; 62 63 // To be called when rendering to the context is done. 64 undefined done(); 65 }; 66 67 callback PrintCallback = undefined(MozCanvasPrintState ctx); 68 69 callback BlobCallback = undefined(Blob? blob);