aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/task_source/dom_manipulation.rs
diff options
context:
space:
mode:
authorConnor Brewster <connor.brewster@eagles.oc.edu>2016-07-11 22:59:53 -0600
committerConnor Brewster <connor.brewster@eagles.oc.edu>2016-07-13 09:59:51 -0600
commit5f7324a9a5fbc5ecf8a348a5e9e238aacfd6f3d9 (patch)
treebf0e8ffcff9acc0a8bbd342ecc16ba2acde2f78b /components/script/task_source/dom_manipulation.rs
parentafc0ccb48d03cfacec06b9c6d6be3626b46ff793 (diff)
downloadservo-5f7324a9a5fbc5ecf8a348a5e9e238aacfd6f3d9.tar.gz
servo-5f7324a9a5fbc5ecf8a348a5e9e238aacfd6f3d9.zip
Make all task source runnables cancellable
Implement all Runnable methods on CancellableRunnable to redirect to their inner runnable
Diffstat (limited to 'components/script/task_source/dom_manipulation.rs')
-rw-r--r--components/script/task_source/dom_manipulation.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs
index 3cb08055446..5deef052c3e 100644
--- a/components/script/task_source/dom_manipulation.rs
+++ b/components/script/task_source/dom_manipulation.rs
@@ -5,6 +5,7 @@
use dom::bindings::refcounted::Trusted;
use dom::event::{EventBubbles, EventCancelable, EventRunnable, SimpleEventRunnable};
use dom::eventtarget::EventTarget;
+use dom::window::Window;
use script_thread::{MainThreadScriptMsg, Runnable, ScriptThread};
use std::result::Result;
use std::sync::mpsc::Sender;
@@ -14,8 +15,9 @@ use task_source::TaskSource;
#[derive(JSTraceable, Clone)]
pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>);
-impl TaskSource<DOMManipulationTask> for DOMManipulationTaskSource {
- fn queue(&self, msg: DOMManipulationTask) -> Result<(), ()> {
+impl TaskSource for DOMManipulationTaskSource {
+ fn queue<T: Runnable + Send + 'static>(&self, msg: T, window: &Window) -> Result<(), ()> {
+ let msg = DOMManipulationTask(window.get_runnable_wrapper().wrap_runnable(msg));
self.0.send(MainThreadScriptMsg::DOMManipulation(msg)).map_err(|_| ())
}
}
@@ -25,24 +27,25 @@ impl DOMManipulationTaskSource {
target: &EventTarget,
name: Atom,
bubbles: EventBubbles,
- cancelable: EventCancelable) {
+ cancelable: EventCancelable,
+ window: &Window) {
let target = Trusted::new(target);
- let runnable = box EventRunnable {
+ let runnable = EventRunnable {
target: target,
name: name,
bubbles: bubbles,
cancelable: cancelable,
};
- let _ = self.queue(DOMManipulationTask(runnable));
+ let _ = self.queue(runnable, window);
}
- pub fn queue_simple_event(&self, target: &EventTarget, name: Atom) {
+ pub fn queue_simple_event(&self, target: &EventTarget, name: Atom, window: &Window) {
let target = Trusted::new(target);
- let runnable = box SimpleEventRunnable {
+ let runnable = SimpleEventRunnable {
target: target,
name: name,
};
- let _ = self.queue(DOMManipulationTask(runnable));
+ let _ = self.queue(runnable, window);
}
}