mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
canvas: Make 2D context state creation failable and use dom_canvas_backend
pref for backend selection (#38310)
Before script just crashed in those cases because IPCSender was dropped, now we send `None` to tell script about the failure and fail getContext or registerPainter accordingly. This PR also unifies `dom_canvas_{backends}_enabled` prefs into `dom_canvas_backend` which is more flexible in multi-backends scenarios. Reviewable per commit. Testing: Added servo specific WPT test. --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
93d234d270
commit
ae69646371
17 changed files with 116 additions and 61 deletions
|
@ -39,29 +39,31 @@ pub(crate) struct OffscreenCanvasRenderingContext2D {
|
|||
}
|
||||
|
||||
impl OffscreenCanvasRenderingContext2D {
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
fn new_inherited(
|
||||
global: &GlobalScope,
|
||||
canvas: &OffscreenCanvas,
|
||||
) -> OffscreenCanvasRenderingContext2D {
|
||||
) -> Option<OffscreenCanvasRenderingContext2D> {
|
||||
let size = canvas.get_size().cast();
|
||||
OffscreenCanvasRenderingContext2D {
|
||||
Some(OffscreenCanvasRenderingContext2D {
|
||||
context: CanvasRenderingContext2D::new_inherited(
|
||||
global,
|
||||
HTMLCanvasElementOrOffscreenCanvas::OffscreenCanvas(DomRoot::from_ref(canvas)),
|
||||
size,
|
||||
),
|
||||
}
|
||||
)?,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) fn new(
|
||||
global: &GlobalScope,
|
||||
canvas: &OffscreenCanvas,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<OffscreenCanvasRenderingContext2D> {
|
||||
) -> Option<DomRoot<OffscreenCanvasRenderingContext2D>> {
|
||||
let boxed = Box::new(OffscreenCanvasRenderingContext2D::new_inherited(
|
||||
global, canvas,
|
||||
));
|
||||
reflect_dom_object(boxed, global, can_gc)
|
||||
)?);
|
||||
Some(reflect_dom_object(boxed, global, can_gc))
|
||||
}
|
||||
|
||||
pub(crate) fn send_canvas_2d_msg(&self, msg: Canvas2dMsg) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue