make use of ScriptToConstellationChan

This commit is contained in:
Paul Rouget 2017-07-18 08:19:44 +02:00
parent 817de15735
commit d241389129
24 changed files with 285 additions and 280 deletions

View file

@ -31,6 +31,7 @@ use script_thread::MainThreadScriptMsg;
use script_thread::Runnable;
use script_thread::ScriptThread;
use script_traits::ScriptMsg;
use script_traits::ScriptToConstellationChan;
use script_traits::TimerSchedulerMsg;
use servo_url::ImmutableOrigin;
use servo_url::MutableOrigin;
@ -49,7 +50,7 @@ pub struct WorkletGlobalScope {
microtask_queue: MicrotaskQueue,
/// Sender back to the script thread
#[ignore_heap_size_of = "channels are hard"]
script_sender: Sender<MainThreadScriptMsg>,
to_script_thread_sender: Sender<MainThreadScriptMsg>,
/// Worklet task executor
executor: WorkletExecutor,
}
@ -63,19 +64,23 @@ impl WorkletGlobalScope {
-> WorkletGlobalScope {
// Any timer events fired on this global are ignored.
let (timer_event_chan, _) = ipc::channel().unwrap();
let script_to_constellation_chan = ScriptToConstellationChan {
sender: init.to_constellation_sender.clone(),
pipeline_id: pipeline_id,
};
WorkletGlobalScope {
globalscope: GlobalScope::new_inherited(pipeline_id,
init.devtools_chan.clone(),
init.mem_profiler_chan.clone(),
init.time_profiler_chan.clone(),
init.constellation_chan.clone(),
script_to_constellation_chan,
init.scheduler_chan.clone(),
init.resource_threads.clone(),
timer_event_chan,
MutableOrigin::new(ImmutableOrigin::new_opaque())),
base_url: base_url,
microtask_queue: MicrotaskQueue::default(),
script_sender: init.script_sender.clone(),
to_script_thread_sender: init.to_script_thread_sender.clone(),
executor: executor,
}
}
@ -98,7 +103,7 @@ impl WorkletGlobalScope {
{
let msg = CommonScriptMsg::RunnableMsg(ScriptThreadEventCategory::WorkletEvent, box runnable);
let msg = MainThreadScriptMsg::Common(msg);
self.script_sender.send(msg).expect("Worklet thread outlived script thread.");
self.to_script_thread_sender.send(msg).expect("Worklet thread outlived script thread.");
}
/// Send a message to layout.
@ -156,7 +161,7 @@ impl WorkletGlobalScope {
#[derive(Clone)]
pub struct WorkletGlobalScopeInit {
/// Channel to the main script thread
pub script_sender: Sender<MainThreadScriptMsg>,
pub to_script_thread_sender: Sender<MainThreadScriptMsg>,
/// Channel to a resource thread
pub resource_threads: ResourceThreads,
/// Channel to the memory profiler
@ -166,7 +171,7 @@ pub struct WorkletGlobalScopeInit {
/// Channel to devtools
pub devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
/// Messages to send to constellation
pub constellation_chan: IpcSender<ScriptMsg>,
pub to_constellation_sender: IpcSender<(PipelineId, ScriptMsg)>,
/// Message to send to the scheduler
pub scheduler_chan: IpcSender<TimerSchedulerMsg>,
/// The image cache