diff options
Diffstat (limited to 'components/script/task_source')
-rw-r--r-- | components/script/task_source/dom_manipulation.rs | 12 | ||||
-rw-r--r-- | components/script/task_source/file_reading.rs | 12 | ||||
-rw-r--r-- | components/script/task_source/mod.rs | 12 | ||||
-rw-r--r-- | components/script/task_source/networking.rs | 17 | ||||
-rw-r--r-- | components/script/task_source/performance_timeline.rs | 10 | ||||
-rw-r--r-- | components/script/task_source/user_interaction.rs | 10 |
6 files changed, 38 insertions, 35 deletions
diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs index f5f38e68044..30dd3df8851 100644 --- a/components/script/task_source/dom_manipulation.rs +++ b/components/script/task_source/dom_manipulation.rs @@ -13,7 +13,7 @@ use servo_atoms::Atom; use std::fmt; use std::result::Result; use std::sync::mpsc::Sender; -use task::{TaskBox, TaskCanceller}; +use task::{TaskCanceller, TaskOnce}; use task_source::TaskSource; #[derive(Clone, JSTraceable)] @@ -28,15 +28,15 @@ impl fmt::Debug for DOMManipulationTaskSource { impl TaskSource for DOMManipulationTaskSource { fn queue_with_canceller<T>( &self, - msg: Box<T>, + task: T, canceller: &TaskCanceller, ) -> Result<(), ()> where - T: TaskBox + 'static, + T: TaskOnce + 'static, { let msg = MainThreadScriptMsg::Common(CommonScriptMsg::Task( ScriptThreadEventCategory::ScriptEvent, - canceller.wrap_task(msg), + box canceller.wrap_task(task), )); self.0.send(msg).map_err(|_| ()) } @@ -50,7 +50,7 @@ impl DOMManipulationTaskSource { cancelable: EventCancelable, window: &Window) { let target = Trusted::new(target); - let task = box EventTask { + let task = EventTask { target: target, name: name, bubbles: bubbles, @@ -61,6 +61,6 @@ impl DOMManipulationTaskSource { pub fn queue_simple_event(&self, target: &EventTarget, name: Atom, window: &Window) { let target = Trusted::new(target); - let _ = self.queue(box SimpleEventTask { target, name }, window.upcast()); + let _ = self.queue(SimpleEventTask { target, name }, window.upcast()); } } diff --git a/components/script/task_source/file_reading.rs b/components/script/task_source/file_reading.rs index 2ed44165b92..fc9af75794c 100644 --- a/components/script/task_source/file_reading.rs +++ b/components/script/task_source/file_reading.rs @@ -6,7 +6,7 @@ use dom::domexception::DOMErrorName; use dom::filereader::{FileReader, TrustedFileReader, GenerationId, ReadMetaData}; use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory, ScriptChan}; use std::sync::Arc; -use task::{TaskBox, TaskCanceller}; +use task::{TaskCanceller, TaskOnce}; use task_source::TaskSource; #[derive(JSTraceable)] @@ -21,21 +21,21 @@ impl Clone for FileReadingTaskSource { impl TaskSource for FileReadingTaskSource { fn queue_with_canceller<T>( &self, - msg: Box<T>, + task: T, canceller: &TaskCanceller, ) -> Result<(), ()> where - T: TaskBox + 'static, + T: TaskOnce + 'static, { self.0.send(CommonScriptMsg::Task( ScriptThreadEventCategory::FileRead, - canceller.wrap_task(msg), + box canceller.wrap_task(task), )) } } -impl TaskBox for FileReadingTask { - fn run_box(self: Box<Self>) { +impl TaskOnce for FileReadingTask { + fn run_once(self) { self.handle_task(); } } diff --git a/components/script/task_source/mod.rs b/components/script/task_source/mod.rs index e361ccf2d99..4818ba2c80c 100644 --- a/components/script/task_source/mod.rs +++ b/components/script/task_source/mod.rs @@ -11,21 +11,21 @@ pub mod user_interaction; use dom::globalscope::GlobalScope; use std::result::Result; -use task::{TaskBox, TaskCanceller}; +use task::{TaskCanceller, TaskOnce}; pub trait TaskSource { fn queue_with_canceller<T>( &self, - msg: Box<T>, + task: T, canceller: &TaskCanceller, ) -> Result<(), ()> where - T: TaskBox + 'static; + T: TaskOnce + 'static; - fn queue<T>(&self, msg: Box<T>, global: &GlobalScope) -> Result<(), ()> + fn queue<T>(&self, task: T, global: &GlobalScope) -> Result<(), ()> where - T: TaskBox + 'static, + T: TaskOnce + 'static, { - self.queue_with_canceller(msg, &global.task_canceller()) + self.queue_with_canceller(task, &global.task_canceller()) } } diff --git a/components/script/task_source/networking.rs b/components/script/task_source/networking.rs index 80acc324f52..8b167c5d905 100644 --- a/components/script/task_source/networking.rs +++ b/components/script/task_source/networking.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; -use task::{TaskBox, TaskCanceller}; +use task::{TaskCanceller, TaskOnce}; use task_source::TaskSource; #[derive(JSTraceable)] @@ -18,15 +18,15 @@ impl Clone for NetworkingTaskSource { impl TaskSource for NetworkingTaskSource { fn queue_with_canceller<T>( &self, - msg: Box<T>, + task: T, canceller: &TaskCanceller, ) -> Result<(), ()> where - T: TaskBox + 'static, + T: TaskOnce + 'static, { self.0.send(CommonScriptMsg::Task( ScriptThreadEventCategory::NetworkEvent, - canceller.wrap_task(msg), + box canceller.wrap_task(task), )) } } @@ -34,10 +34,13 @@ impl TaskSource for NetworkingTaskSource { impl NetworkingTaskSource { /// This queues a task that will not be cancelled when its associated /// global scope gets destroyed. - pub fn queue_unconditionally<T>(&self, msg: Box<T>) -> Result<(), ()> + pub fn queue_unconditionally<T>(&self, task: T) -> Result<(), ()> where - T: TaskBox + 'static, + T: TaskOnce + 'static, { - self.0.send(CommonScriptMsg::Task(ScriptThreadEventCategory::NetworkEvent, msg)) + self.0.send(CommonScriptMsg::Task( + ScriptThreadEventCategory::NetworkEvent, + box task, + )) } } diff --git a/components/script/task_source/performance_timeline.rs b/components/script/task_source/performance_timeline.rs index 3c77c1527fd..1a3ffeb7fc7 100644 --- a/components/script/task_source/performance_timeline.rs +++ b/components/script/task_source/performance_timeline.rs @@ -11,7 +11,7 @@ use dom::globalscope::GlobalScope; use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; use std::fmt; use std::result::Result; -use task::{TaskBox, TaskCanceller}; +use task::{TaskCanceller, TaskOnce}; use task_source::TaskSource; #[derive(JSTraceable)] @@ -32,15 +32,15 @@ impl fmt::Debug for PerformanceTimelineTaskSource { impl TaskSource for PerformanceTimelineTaskSource { fn queue_with_canceller<T>( &self, - msg: Box<T>, + task: T, canceller: &TaskCanceller, ) -> Result<(), ()> where - T: TaskBox + 'static, + T: TaskOnce + 'static, { let msg = CommonScriptMsg::Task( ScriptThreadEventCategory::PerformanceTimelineTask, - canceller.wrap_task(msg) + box canceller.wrap_task(task) ); self.0.send(msg).map_err(|_| ()) } @@ -51,7 +51,7 @@ impl PerformanceTimelineTaskSource { let owner = Trusted::new(&*global.performance()); // FIXME(nox): Why are errors silenced here? let _ = self.queue( - box task!(notify_performance_observers: move || { + task!(notify_performance_observers: move || { owner.root().notify_observers(); }), global, diff --git a/components/script/task_source/user_interaction.rs b/components/script/task_source/user_interaction.rs index 0ca5687fe46..9891f474529 100644 --- a/components/script/task_source/user_interaction.rs +++ b/components/script/task_source/user_interaction.rs @@ -13,7 +13,7 @@ use servo_atoms::Atom; use std::fmt; use std::result::Result; use std::sync::mpsc::Sender; -use task::{TaskBox, TaskCanceller}; +use task::{TaskCanceller, TaskOnce}; use task_source::TaskSource; #[derive(Clone, JSTraceable)] @@ -28,15 +28,15 @@ impl fmt::Debug for UserInteractionTaskSource { impl TaskSource for UserInteractionTaskSource { fn queue_with_canceller<T>( &self, - msg: Box<T>, + task: T, canceller: &TaskCanceller, ) -> Result<(), ()> where - T: TaskBox + 'static, + T: TaskOnce + 'static, { let msg = MainThreadScriptMsg::Common(CommonScriptMsg::Task( ScriptThreadEventCategory::InputEvent, - canceller.wrap_task(msg), + box canceller.wrap_task(task), )); self.0.send(msg).map_err(|_| ()) } @@ -50,7 +50,7 @@ impl UserInteractionTaskSource { cancelable: EventCancelable, window: &Window) { let target = Trusted::new(target); - let task = box EventTask { target, name, bubbles, cancelable }; + let task = EventTask { target, name, bubbles, cancelable }; let _ = self.queue(task, window.upcast()); } } |