Make all task source runnables cancellable

Implement all Runnable methods on CancellableRunnable to redirect to their inner runnable
This commit is contained in:
Connor Brewster 2016-07-11 22:59:53 -06:00
parent afc0ccb48d
commit 5f7324a9a5
14 changed files with 69 additions and 58 deletions

View file

@ -189,10 +189,16 @@ pub struct CancellableRunnable<T: Runnable + Send> {
}
impl<T: Runnable + Send> Runnable for CancellableRunnable<T> {
fn name(&self) -> &'static str { self.inner.name() }
fn is_cancelled(&self) -> bool {
self.cancelled.load(Ordering::SeqCst)
}
fn main_thread_handler(self: Box<CancellableRunnable<T>>, script_thread: &ScriptThread) {
self.inner.main_thread_handler(script_thread);
}
fn handler(self: Box<CancellableRunnable<T>>) {
self.inner.handler()
}
@ -1220,8 +1226,8 @@ impl ScriptThread {
doc.mut_loader().inhibit_events();
// https://html.spec.whatwg.org/multipage/#the-end step 7
let handler = box DocumentProgressHandler::new(Trusted::new(doc));
self.dom_manipulation_task_source.queue(DOMManipulationTask(handler)).unwrap();
let handler = DocumentProgressHandler::new(Trusted::new(doc));
self.dom_manipulation_task_source.queue(handler, doc.window()).unwrap();
self.constellation_chan.send(ConstellationMsg::LoadComplete(pipeline)).unwrap();
}