Unify (Offscreen)CanvasRenderingContext2d and make PaintRenderingContext2D standalone (#35619)

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2025-02-23 17:31:06 +01:00 committed by GitHub
parent 6199099d12
commit 1d7bb1337d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 237 additions and 290 deletions

View file

@ -123,12 +123,7 @@ impl OffscreenCanvas {
OffscreenCanvasContext::OffscreenContext2d(ref ctx) => Some(DomRoot::from_ref(ctx)),
};
}
let context = OffscreenCanvasRenderingContext2D::new(
&self.global(),
self,
self.placeholder.as_deref(),
CanGc::note(),
);
let context = OffscreenCanvasRenderingContext2D::new(&self.global(), self, CanGc::note());
*self.context.borrow_mut() = Some(OffscreenCanvasContext::OffscreenContext2d(
Dom::from_ref(&*context),
));
@ -138,6 +133,10 @@ impl OffscreenCanvas {
pub(crate) fn is_valid(&self) -> bool {
self.Width() != 0 && self.Height() != 0
}
pub(crate) fn placeholder(&self) -> Option<&HTMLCanvasElement> {
self.placeholder.as_deref()
}
}
impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {