Don't attempt to resize Offscreencanvas without a rendering context (#36855)

When the canvas context mode is a placeholder then we shouldn't resize
the context.

Testing: Includes a new test
Fixes: https://github.com/servo/servo/issues/36846

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2025-05-11 17:27:33 +02:00 committed by GitHub
parent d2afe00f7b
commit dc0e7587bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 65 additions and 30 deletions

View file

@ -125,7 +125,11 @@ impl CanvasContext for RenderingContext {
fn resize(&self) {
match self {
RenderingContext::Placeholder(context) => (*context.context().unwrap()).resize(),
RenderingContext::Placeholder(offscreen_canvas) => {
if let Some(context) = offscreen_canvas.context() {
context.resize()
}
},
RenderingContext::Context2d(context) => context.resize(),
RenderingContext::WebGL(context) => context.resize(),
RenderingContext::WebGL2(context) => context.resize(),