mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Introduce GlobalScope::process_event
This commit is contained in:
parent
cdf3ef05e7
commit
ca15dd5eea
3 changed files with 14 additions and 13 deletions
|
@ -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> {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue