servo/components/script_bindings/webidls/OffscreenCanvas.webidl
Andrei Volykhin 4054f9a5a0
canvas: Make OffscreenCanvas transferable (without placeholder) (#37872)
Follow the specification and make OffscreenCanvas objects are
transferable,
but not in case if there are a weak reference to placeholder canvas
element.
To handle it properly need to implement dedicated frame
provider/dispatcher
between canvas element (script thread) and offscreen canvas (dedicated
worker thread).

https://html.spec.whatwg.org/multipage/#the-offscreencanvas-interface:transferable-objects

Testing: Improvements in the following tests
-
html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.detachedcanvas.html
-
html/canvas/offscreen/manual/convert-to-blob/offscreencanvas.convert.to.blob*
-
html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transfer*
-
html/infrastructure/safe-passing-of-structured-data/transfer-errors.window.js

Part of #24276

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-07-08 14:47:29 +00:00

25 lines
1.1 KiB
Text

/* 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 https://mozilla.org/MPL/2.0/. */
// https://html.spec.whatwg.org/multipage/#the-offscreencanvas-interface
typedef (OffscreenCanvasRenderingContext2D or WebGLRenderingContext or WebGL2RenderingContext)
OffscreenRenderingContext;
dictionary ImageEncodeOptions {
DOMString type = "image/png";
unrestricted double quality;
};
//enum OffscreenRenderingContextId { "2d", "webgl", "webgl2" };
[Exposed=(Window,Worker), Transferable, Pref="dom_offscreen_canvas_enabled"]
interface OffscreenCanvas : EventTarget {
[Throws] constructor([EnforceRange] unsigned long long width, [EnforceRange] unsigned long long height);
attribute [EnforceRange] unsigned long long width;
attribute [EnforceRange] unsigned long long height;
[Throws] OffscreenRenderingContext? getContext(DOMString contextId, optional any options = null);
[Throws] ImageBitmap transferToImageBitmap();
Promise<Blob> convertToBlob(optional ImageEncodeOptions options = {});
};