Do not assume OffscreenCanvasContext to be 2d (#35629)

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2025-02-24 15:06:08 +01:00 committed by GitHub
parent 6062995636
commit e887e621f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 18 deletions

View file

@ -127,6 +127,19 @@ impl OffscreenCanvas {
pub(crate) fn placeholder(&self) -> Option<&HTMLCanvasElement> {
self.placeholder.as_deref()
}
pub(crate) fn resize(&self, size: Size2D<u64>) {
self.width.set(size.width);
self.height.set(size.height);
if let Some(canvas_context) = self.context() {
match &*canvas_context {
OffscreenCanvasContext::OffscreenContext2d(rendering_context) => {
rendering_context.set_canvas_bitmap_dimensions(self.get_size());
},
}
}
}
}
impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {