canvas: Update the image as part of update the rendering (#35996)

* Create `update_rendering` in `CanvasState` instead of manually updating in layout

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Mark as dirty and do flushes

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* fixup rebase

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Update components/script/dom/htmlcanvaselement.rs

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
sagudev 2025-03-25 07:38:02 +01:00 committed by GitHub
parent ed995e61a6
commit 62737b3830
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 72 additions and 51 deletions

View file

@ -180,6 +180,21 @@ impl HTMLCanvasElement {
}
}
pub(crate) fn mark_as_dirty(&self) {
if let Some(ref context) = *self.context.borrow() {
match *context {
CanvasContext::Context2d(ref context) => context.mark_as_dirty(),
CanvasContext::WebGL(ref context) => context.mark_as_dirty(),
CanvasContext::WebGL2(ref context) => context.mark_as_dirty(),
#[cfg(feature = "webgpu")]
CanvasContext::WebGPU(ref context) => context.mark_as_dirty(),
CanvasContext::Placeholder(ref _context) => {
// TODO: Should this be marked as dirty?
},
}
}
}
pub(crate) fn set_natural_width(&self, value: u32, can_gc: CanGc) {
let value = if value > UNSIGNED_LONG_MAX {
DEFAULT_WIDTH