canvas: Do not update ImageKey during canvas layout (#35719)

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2025-03-12 16:36:52 +01:00 committed by GitHub
parent f31043602a
commit 6f6840d63c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 90 additions and 126 deletions

View file

@ -34,6 +34,7 @@ use style::values::specified::color::Color;
use style_traits::values::ToCss;
use style_traits::{CssWriter, ParsingMode};
use url::Url;
use webrender_api::ImageKey;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::{
@ -145,6 +146,8 @@ pub(crate) struct CanvasState {
ipc_renderer: IpcSender<CanvasMsg>,
#[no_trace]
canvas_id: CanvasId,
#[no_trace]
image_key: ImageKey,
state: DomRefCell<CanvasContextState>,
origin_clean: Cell<bool>,
#[ignore_malloc_size_of = "Arc"]
@ -172,7 +175,7 @@ impl CanvasState {
script_to_constellation_chan
.send(ScriptMsg::CreateCanvasPaintThread(size, sender))
.unwrap();
let (ipc_renderer, canvas_id) = receiver.recv().unwrap();
let (ipc_renderer, canvas_id, image_key) = receiver.recv().unwrap();
debug!("Done.");
// Worklets always receive a unique origin. This messes with fetching
// cached images in the case of paint worklets, since the image cache
@ -191,6 +194,7 @@ impl CanvasState {
base_url: global.api_base_url(),
missing_image_urls: DomRefCell::new(Vec::new()),
saved_states: DomRefCell::new(Vec::new()),
image_key,
origin,
}
}
@ -199,6 +203,10 @@ impl CanvasState {
&self.ipc_renderer
}
pub(crate) fn image_key(&self) -> ImageKey {
self.image_key
}
pub(crate) fn get_missing_image_urls(&self) -> &DomRefCell<Vec<ServoUrl>> {
&self.missing_image_urls
}