mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Implement cancellable runnables.
Additionally, make image load events cancellable. Resolves #7731.
This commit is contained in:
parent
9fea6d2e46
commit
989e80036e
4 changed files with 62 additions and 8 deletions
|
@ -110,13 +110,16 @@ impl HTMLImageElement {
|
|||
let trusted_node = Trusted::new(window.get_cx(), self, window.script_chan());
|
||||
let (responder_sender, responder_receiver) = ipc::channel().unwrap();
|
||||
let script_chan = window.script_chan();
|
||||
let wrapper = window.get_runnable_wrapper();
|
||||
ROUTER.add_route(responder_receiver.to_opaque(), box move |message| {
|
||||
// Return the image via a message to the script task, which marks the element
|
||||
// as dirty and triggers a reflow.
|
||||
let image_response = message.to().unwrap();
|
||||
script_chan.send(CommonScriptMsg::RunnableMsg(UpdateReplacedElement,
|
||||
box ImageResponseHandlerRunnable::new(
|
||||
trusted_node.clone(), image_response))).unwrap();
|
||||
let runnable = ImageResponseHandlerRunnable::new(
|
||||
trusted_node.clone(), image_response);
|
||||
let runnable = wrapper.wrap_runnable(runnable);
|
||||
script_chan.send(CommonScriptMsg::RunnableMsg(
|
||||
UpdateReplacedElement, runnable)).unwrap();
|
||||
});
|
||||
|
||||
image_cache.request_image(img_url,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue