mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
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:
parent
d2afe00f7b
commit
dc0e7587bf
5 changed files with 65 additions and 30 deletions
|
@ -24,12 +24,20 @@ use crate::dom::htmlcanvaselement::HTMLCanvasElement;
|
|||
use crate::dom::offscreencanvasrenderingcontext2d::OffscreenCanvasRenderingContext2D;
|
||||
use crate::script_runtime::{CanGc, JSContext};
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#offscreencanvas>
|
||||
#[dom_struct]
|
||||
pub(crate) struct OffscreenCanvas {
|
||||
eventtarget: EventTarget,
|
||||
width: Cell<u64>,
|
||||
height: Cell<u64>,
|
||||
|
||||
/// Represents both the [bitmap] and the [context mode] of the canvas.
|
||||
///
|
||||
/// [bitmap]: https://html.spec.whatwg.org/multipage/#offscreencanvas-bitmap
|
||||
/// [context mode]: https://html.spec.whatwg.org/multipage/#offscreencanvas-context-mode
|
||||
context: DomRefCell<Option<OffscreenRenderingContext>>,
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#offscreencanvas-placeholder>
|
||||
placeholder: Option<Dom<HTMLCanvasElement>>,
|
||||
}
|
||||
|
||||
|
@ -119,7 +127,7 @@ impl OffscreenCanvas {
|
|||
}
|
||||
|
||||
impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-offscreencanvas>
|
||||
fn Constructor(
|
||||
global: &GlobalScope,
|
||||
proto: Option<HandleObject>,
|
||||
|
@ -131,7 +139,7 @@ impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {
|
|||
Ok(offscreencanvas)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-getcontext
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-getcontext>
|
||||
fn GetContext(
|
||||
&self,
|
||||
_cx: JSContext,
|
||||
|
@ -155,12 +163,12 @@ impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {
|
|||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width>
|
||||
fn Width(&self) -> u64 {
|
||||
self.width.get()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width>
|
||||
fn SetWidth(&self, value: u64, can_gc: CanGc) {
|
||||
self.width.set(value);
|
||||
|
||||
|
@ -173,12 +181,12 @@ impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {
|
|||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height>
|
||||
fn Height(&self) -> u64 {
|
||||
self.height.get()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height>
|
||||
fn SetHeight(&self, value: u64, can_gc: CanGc) {
|
||||
self.height.set(value);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue