aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2016-10-05 09:44:11 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2016-10-06 21:35:56 +0200
commitca15dd5eeabf49a69207c69db939cc419c69bbf2 (patch)
tree3a1ba2820db6daf0321b9f0ceb8ee52d9d3af75e
parentcdf3ef05e78b3947cc7f29240106982f1c45d96b (diff)
downloadservo-ca15dd5eeabf49a69207c69db939cc419c69bbf2.tar.gz
servo-ca15dd5eeabf49a69207c69db939cc419c69bbf2.zip
Introduce GlobalScope::process_event
-rw-r--r--components/script/dom/bindings/global.rs11
-rw-r--r--components/script/dom/globalscope.rs14
-rw-r--r--components/script/dom/xmlhttprequest.rs2
3 files changed, 14 insertions, 13 deletions
diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs
index 26d7c061503..051a28439bd 100644
--- a/components/script/dom/bindings/global.rs
+++ b/components/script/dom/bindings/global.rs
@@ -18,8 +18,6 @@ use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
use js::glue::{IsWrapper, UnwrapObject};
use js::jsapi::{CurrentGlobalOrNull, GetGlobalForObjectCrossCompartment};
use js::jsapi::{JSContext, JSObject, JS_GetClass};
-use script_runtime::CommonScriptMsg;
-use script_thread::ScriptThread;
use task_source::file_reading::FileReadingTaskSource;
/// A freely-copyable reference to a rooted global object.
@@ -65,15 +63,6 @@ impl<'a> GlobalRef<'a> {
GlobalRef::Worker(ref worker) => worker.file_reading_task_source(),
}
}
-
- /// Process a single event as if it were the next event in the thread queue for
- /// this global.
- pub fn process_event(&self, msg: CommonScriptMsg) {
- match *self {
- GlobalRef::Window(_) => ScriptThread::process_event(msg),
- GlobalRef::Worker(ref worker) => worker.process_event(msg),
- }
- }
}
impl<'a> Reflectable for GlobalRef<'a> {
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs
index 0b3b609d54b..fd5046c64c6 100644
--- a/components/script/dom/globalscope.rs
+++ b/components/script/dom/globalscope.rs
@@ -26,7 +26,7 @@ use libc;
use msg::constellation_msg::PipelineId;
use net_traits::{CoreResourceThread, ResourceThreads, IpcSend};
use profile_traits::{mem, time};
-use script_runtime::{EnqueuedPromiseCallback, ScriptChan};
+use script_runtime::{CommonScriptMsg, EnqueuedPromiseCallback, ScriptChan};
use script_runtime::{ScriptPort, maybe_take_panic_result};
use script_thread::{MainThreadScriptChan, RunnableWrapper, ScriptThread};
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEvent};
@@ -445,6 +445,18 @@ impl GlobalScope {
}
unreachable!();
}
+
+ /// Process a single event as if it were the next event
+ /// in the thread queue for this global scope.
+ pub fn process_event(&self, msg: CommonScriptMsg) {
+ if self.is::<Window>() {
+ return ScriptThread::process_event(msg);
+ }
+ if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
+ return worker.process_event(msg);
+ }
+ unreachable!();
+ }
}
fn timestamp_in_ms(time: Timespec) -> u64 {
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index e8254be3e70..4429ec71380 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -1309,7 +1309,7 @@ impl XMLHttpRequest {
if let Some(script_port) = script_port {
loop {
- global.process_event(script_port.recv().unwrap());
+ global_scope.process_event(script_port.recv().unwrap());
let context = context.lock().unwrap();
let sync_status = context.sync_status.borrow();
if let Some(ref status) = *sync_status {