diff options
author | Lucas Montenegro <40044087+lucasMontenegro@users.noreply.github.com> | 2023-12-20 02:57:48 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-20 05:57:48 +0000 |
commit | 256ab5353b9145dbda103ec48cf4d10f32f6912a (patch) | |
tree | 8ac740b2c48d64d86b65ece9e7e60a0c7506e24d /components/script | |
parent | 8bbcf0abafc22cd840cd03f36b5b3b7d2d815493 (diff) | |
download | servo-256ab5353b9145dbda103ec48cf4d10f32f6912a.tar.gz servo-256ab5353b9145dbda103ec48cf4d10f32f6912a.zip |
These changes fix #30843 (#30888)
Signed-off-by: Lucas Fabián Montenegro <40044087+lucasMontenegro@users.noreply.github.com>
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/htmlcanvaselement.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index bb35853f706..e412457753a 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -269,11 +269,15 @@ impl HTMLCanvasElement { .global() .script_to_constellation_chan() .send(ScriptMsg::GetWebGPUChan(sender)); - let window = window_from_node(self); - let channel = receiver.recv().expect("Failed to get WebGPU channel"); - let context = GPUCanvasContext::new(window.upcast::<GlobalScope>(), self, channel); - *self.context.borrow_mut() = Some(CanvasContext::WebGPU(Dom::from_ref(&*context))); - Some(context) + receiver + .recv() + .expect("Failed to get WebGPU channel") + .map(|channel| { + let window = window_from_node(self); + let context = GPUCanvasContext::new(window.upcast::<GlobalScope>(), self, channel); + *self.context.borrow_mut() = Some(CanvasContext::WebGPU(Dom::from_ref(&*context))); + context + }) } /// Gets the base WebGLRenderingContext for WebGL or WebGL 2, if exists. |