-
Notifications
You must be signed in to change notification settings - Fork 22.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add exception info for HTMLCanvasElement.transferControlToOffscreen()
and OffscreenCanvas.transferToImageBitmap()
#36631
Conversation
…)` and `OffscreenCanvas.transferToImageBitmap()`
Preview URLs
(comment last updated: 2024-11-16 12:16:05) |
files/en-us/web/api/htmlcanvaselement/transfercontroltooffscreen/index.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to be slow to review this @skyclouds2001 .
### Exceptions | ||
|
||
- `InvalidStateError` {{domxref("DOMException")}} | ||
- : Throws if the canvas has been set to a context mode via calling {{domxref("HTMLCanvasElement.getContext()")}} or has transferred its control to offscreen via calling {{domxref("HTMLCanvasElement.transferControlToOffscreen()")}}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see in https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-transfercontroltooffscreen where we throw an exception if the canvas "has transferred its control to offscreen via calling {{domxref("HTMLCanvasElement.transferControlToOffscreen()")}}", can you point to it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The transferControlToOffscreen() method, when invoked, must run these steps:
If this canvas element's context mode is not set to none, throw an "InvalidStateError" DOMException.
Let offscreenCanvas be a new OffscreenCanvas object with its width and height equal to the values of the width and height content attributes of this canvas element.
Set the placeholder canvas element of offscreenCanvas to a weak reference to this canvas element.
Set this canvas element's context mode to placeholder.
Return offscreenCanvas.The transferControlToOffscreen() method, when invoked, must run these steps:
If this canvas element's context mode is not set to none, throw an "InvalidStateError" DOMException.
Let offscreenCanvas be a new OffscreenCanvas object with its width and height equal to the values of the width and height content attributes of this canvas element.
Set the placeholder canvas element of offscreenCanvas to a weak reference to this canvas element.
Set this canvas element's context mode to placeholder.
Return offscreenCanvas.
After calling transferControlToOffscreen()
, the canvas's context mode will be set to "placeholder"; so if calling transferControlToOffscreen()
again, it will fail at the first step.
Sample code is as follows:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! (I didn't doubt you were right here, I just couldn't see it!)
files/en-us/web/api/offscreencanvas/transfertoimagebitmap/index.md
Outdated
Show resolved
Hide resolved
…x.md Co-authored-by: wbamberg <will@bootbonnet.ca>
files/en-us/web/api/htmlcanvaselement/transfercontroltooffscreen/index.md
Outdated
Show resolved
Hide resolved
…x.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
files/en-us/web/api/htmlcanvaselement/transfercontroltooffscreen/index.md
Outdated
Show resolved
Hide resolved
…en/index.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thank you @skyclouds2001 !
Description
https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-transfercontroltooffscreen
https://html.spec.whatwg.org/multipage/canvas.html#dom-offscreencanvas-transfertoimagebitmap
Motivation
Additional details
Related issues and pull requests