ladybird/Libraries/LibWeb/HTML/OffscreenCanvas.idl
Shannon Booth c1d022523b LibWeb/HTML: Enforce width and height range for OffscreenCanvas
We should be throwing a TypeError on values outside of the range
for an unsigned long instead of the default modulo behaviour.
2025-09-22 12:37:30 +01:00

32 lines
1.3 KiB
Text

#import <DOM/EventTarget.idl>
#import <HTML/OffscreenCanvasRenderingContext2D.idl>
#import <HTML/Canvas/OffscreenCanvasBase.idl>
// FIXME: This should be in OffscreenCanvasBase.idl but then it is not exported
// https://html.spec.whatwg.org/multipage/canvas.html#imageencodeoptions
dictionary ImageEncodeOptions {
DOMString type = "image/png";
unrestricted double quality;
};
// FIXME: This should be in OffscreenCanvasBase.idl but then it is not exported
// https://html.spec.whatwg.org/multipage/canvas.html#offscreenrenderingcontextid
enum OffscreenRenderingContextId { "2d", "bitmaprenderer", "webgl", "webgl2", "webgpu" };
// https://html.spec.whatwg.org/multipage/canvas.html#offscreencanvas
[Exposed=(Window,Worker), Transferable]
interface OffscreenCanvas : EventTarget {
constructor([EnforceRange] unsigned long long width, [EnforceRange] unsigned long long height);
[EnforceRange] attribute unsigned long long width;
[EnforceRange] attribute unsigned long long height;
OffscreenRenderingContext? getContext(OffscreenRenderingContextId contextId, optional any options = null);
ImageBitmap transferToImageBitmap();
Promise<Blob> convertToBlob(optional ImageEncodeOptions options = {});
attribute EventHandler oncontextlost;
attribute EventHandler oncontextrestored;
};