aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/task_source
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/task_source')
-rw-r--r--components/script/task_source/dom_manipulation.rs15
-rw-r--r--components/script/task_source/mod.rs13
-rw-r--r--components/script/task_source/user_interaction.rs13
3 files changed, 29 insertions, 12 deletions
diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs
index b8bad662353..4f5384ae2ed 100644
--- a/components/script/task_source/dom_manipulation.rs
+++ b/components/script/task_source/dom_manipulation.rs
@@ -2,11 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use dom::bindings::global::GlobalRef;
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 script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread};
use std::result::Result;
use std::sync::mpsc::Sender;
use string_cache::Atom;
@@ -16,8 +17,12 @@ use task_source::TaskSource;
pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>);
impl TaskSource for DOMManipulationTaskSource {
- fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, window: &Window) -> Result<(), ()> {
- let msg = DOMManipulationTask(window.get_runnable_wrapper().wrap_runnable(msg));
+ fn queue_with_wrapper<T>(&self,
+ msg: Box<T>,
+ wrapper: &RunnableWrapper)
+ -> Result<(), ()>
+ where T: Runnable + Send + 'static {
+ let msg = DOMManipulationTask(wrapper.wrap_runnable(msg));
self.0.send(MainThreadScriptMsg::DOMManipulation(msg)).map_err(|_| ())
}
}
@@ -36,7 +41,7 @@ impl DOMManipulationTaskSource {
bubbles: bubbles,
cancelable: cancelable,
};
- let _ = self.queue(runnable, window);
+ let _ = self.queue(runnable, GlobalRef::Window(window));
}
pub fn queue_simple_event(&self, target: &EventTarget, name: Atom, window: &Window) {
@@ -45,7 +50,7 @@ impl DOMManipulationTaskSource {
target: target,
name: name,
};
- let _ = self.queue(runnable, window);
+ let _ = self.queue(runnable, GlobalRef::Window(window));
}
}
diff --git a/components/script/task_source/mod.rs b/components/script/task_source/mod.rs
index 48fc775d959..cb607c57acb 100644
--- a/components/script/task_source/mod.rs
+++ b/components/script/task_source/mod.rs
@@ -8,10 +8,17 @@ pub mod history_traversal;
pub mod networking;
pub mod user_interaction;
-use dom::window::Window;
-use script_thread::Runnable;
+use dom::bindings::global::GlobalRef;
+use script_thread::{Runnable, RunnableWrapper};
use std::result::Result;
pub trait TaskSource {
- fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, window: &Window) -> Result<(), ()>;
+ fn queue_with_wrapper<T>(&self,
+ msg: Box<T>,
+ wrapper: &RunnableWrapper)
+ -> Result<(), ()>
+ where T: Runnable + Send + 'static;
+ fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, global: GlobalRef) -> Result<(), ()> {
+ self.queue_with_wrapper(msg, &global.get_runnable_wrapper())
+ }
}
diff --git a/components/script/task_source/user_interaction.rs b/components/script/task_source/user_interaction.rs
index 2f4c0923801..cddafb80ee4 100644
--- a/components/script/task_source/user_interaction.rs
+++ b/components/script/task_source/user_interaction.rs
@@ -2,11 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use dom::bindings::global::GlobalRef;
use dom::bindings::refcounted::Trusted;
use dom::event::{EventBubbles, EventCancelable, EventRunnable};
use dom::eventtarget::EventTarget;
use dom::window::Window;
-use script_thread::{MainThreadScriptMsg, Runnable, ScriptThread};
+use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread};
use std::result::Result;
use std::sync::mpsc::Sender;
use string_cache::Atom;
@@ -16,8 +17,12 @@ use task_source::TaskSource;
pub struct UserInteractionTaskSource(pub Sender<MainThreadScriptMsg>);
impl TaskSource for UserInteractionTaskSource {
- fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, window: &Window) -> Result<(), ()> {
- let msg = UserInteractionTask(window.get_runnable_wrapper().wrap_runnable(msg));
+ fn queue_with_wrapper<T>(&self,
+ msg: Box<T>,
+ wrapper: &RunnableWrapper)
+ -> Result<(), ()>
+ where T: Runnable + Send + 'static {
+ let msg = UserInteractionTask(wrapper.wrap_runnable(msg));
self.0.send(MainThreadScriptMsg::UserInteraction(msg)).map_err(|_| ())
}
}
@@ -36,7 +41,7 @@ impl UserInteractionTaskSource {
bubbles: bubbles,
cancelable: cancelable,
};
- let _ = self.queue(runnable, window);
+ let _ = self.queue(runnable, GlobalRef::Window(window));
}
}