diff options
Diffstat (limited to 'components/script/dom/bindings')
-rw-r--r-- | components/script/dom/bindings/global.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs index 233143851e6..bff4c66f89b 100644 --- a/components/script/dom/bindings/global.rs +++ b/components/script/dom/bindings/global.rs @@ -12,8 +12,8 @@ use dom::bindings::js::{JS, JSRef, Root, Unrooted}; use dom::bindings::utils::{Reflectable, Reflector}; use dom::workerglobalscope::{WorkerGlobalScope, WorkerGlobalScopeHelpers}; use dom::window::{self, WindowHelpers}; -use script_task::ScriptChan; use devtools_traits::DevtoolsControlChan; +use script_task::{ScriptChan, ScriptPort, ScriptMsg, ScriptTask}; use msg::constellation_msg::{PipelineId, WorkerId}; use net_traits::ResourceTask; @@ -129,6 +129,24 @@ impl<'a> GlobalRef<'a> { GlobalRef::Worker(ref worker) => worker.script_chan(), } } + + /// `ScriptChan` used to send messages to the event loop of this global's + /// thread. + pub fn new_script_pair(&self) -> (Box<ScriptChan+Send>, Box<ScriptPort+Send>) { + match *self { + GlobalRef::Window(ref window) => window.new_script_pair(), + GlobalRef::Worker(ref worker) => worker.new_script_pair(), + } + } + + /// Process a single event as if it were the next event in the task queue for + /// this global. + pub fn process_event(&self, msg: ScriptMsg) { + match *self { + GlobalRef::Window(_) => ScriptTask::process_event(msg), + GlobalRef::Worker(ref worker) => worker.process_event(msg), + } + } } impl<'a> Reflectable for GlobalRef<'a> { |