From 46dd9c0c1635e8abd73040c1a71cc0ed3c27cd50 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 23 Nov 2024 04:26:52 +0800 Subject: [PATCH] Add exception info for `HTMLCanvasElement.transferControlToOffscreen()` and `OffscreenCanvas.transferToImageBitmap()` (#36631) * Add exception info for `HTMLCanvasElement.transferControlToOffscreen()` and `OffscreenCanvas.transferToImageBitmap()` * Update files/en-us/web/api/htmlcanvaselement/getcontext/index.md * Update files/en-us/web/api/htmlcanvaselement/transfercontroltooffscreen/index.md * Update files/en-us/web/api/offscreencanvas/transfertoimagebitmap/index.md Co-authored-by: wbamberg * Update files/en-us/web/api/htmlcanvaselement/transfercontroltooffscreen/index.md * Update files/en-us/web/api/offscreencanvas/transfertoimagebitmap/index.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update files/en-us/web/api/htmlcanvaselement/transfercontroltooffscreen/index.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: wbamberg Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- files/en-us/web/api/htmlcanvaselement/getcontext/index.md | 2 +- .../htmlcanvaselement/transfercontroltooffscreen/index.md | 7 +++++++ .../web/api/offscreencanvas/transfertoimagebitmap/index.md | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/files/en-us/web/api/htmlcanvaselement/getcontext/index.md b/files/en-us/web/api/htmlcanvaselement/getcontext/index.md index 61f380b965726a0..1dcee3b5636a75c 100644 --- a/files/en-us/web/api/htmlcanvaselement/getcontext/index.md +++ b/files/en-us/web/api/htmlcanvaselement/getcontext/index.md @@ -117,7 +117,7 @@ If the context identifier is not supported, or the canvas has already been set t ### Exceptions - `InvalidStateError` {{domxref("DOMException")}} - - : Throws if the canvas has transferred its control to offscreen via calling `HTMLCanvasElement.transferControlToOffscreen()`. + - : Throws if the canvas has transferred its control to offscreen by calling {{domxref("HTMLCanvasElement.transferControlToOffscreen()")}}. ## Examples diff --git a/files/en-us/web/api/htmlcanvaselement/transfercontroltooffscreen/index.md b/files/en-us/web/api/htmlcanvaselement/transfercontroltooffscreen/index.md index 755d15c1a1da2ee..623c0125c0c8b94 100644 --- a/files/en-us/web/api/htmlcanvaselement/transfercontroltooffscreen/index.md +++ b/files/en-us/web/api/htmlcanvaselement/transfercontroltooffscreen/index.md @@ -24,6 +24,13 @@ None. An {{domxref("OffscreenCanvas")}} object. +### Exceptions + +- `InvalidStateError` {{domxref("DOMException")}} + - : Throws if: + - the canvas has been set a context mode by calling {{domxref("HTMLCanvasElement.getContext()")}} + - the canvas has transferred its control to offscreen by calling {{domxref("HTMLCanvasElement.transferControlToOffscreen()")}}. + ## Examples The following example shows how to transfer control to an {{domxref("OffscreenCanvas")}} object on the main thread. diff --git a/files/en-us/web/api/offscreencanvas/transfertoimagebitmap/index.md b/files/en-us/web/api/offscreencanvas/transfertoimagebitmap/index.md index d395bca00e8b0c5..98fce4b5a958724 100644 --- a/files/en-us/web/api/offscreencanvas/transfertoimagebitmap/index.md +++ b/files/en-us/web/api/offscreencanvas/transfertoimagebitmap/index.md @@ -32,6 +32,13 @@ If your goal is to pass the `ImageBitmap` to other web APIs which do not consume If you call `transferToImageBitmap()` and don't intend to pass it to {{domxref("ImageBitmapRenderingContext.transferFromImageBitmap()")}}, consider whether you need to call `transferToImageBitmap()` at all. Many web APIs which accept `ImageBitmap` also accept `OffscreenCanvas` as an argument. +### Exceptions + +- `InvalidStateError` {{domxref("DOMException")}} + - : Throws if: + - the canvas has transferred to another context scope, such as a worker + - the canvas context mode has not been set by calling {{domxref("OffscreenCanvas.getContext()")}}. + ## Examples ```js