From 9d73b869dbf69693bcb6ce860c42305dc123b61a Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 26 Nov 2015 10:23:11 +0100 Subject: [PATCH] Consume self in PrivilegedPipelineContent methods. This leads to a little bit of copy/paste, but the resulting code should be quite a bit more efficient. --- components/compositing/constellation.rs | 2 +- components/compositing/pipeline.rs | 49 +++++++++++++++---------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 002db169222..3abb1d5a54e 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -362,7 +362,7 @@ impl Constellation { script_channel: Option>, load_data: LoadData) { let spawning_paint_only = script_channel.is_some(); - let (pipeline, unprivileged_pipeline_content, mut privileged_pipeline_content) = + let (pipeline, unprivileged_pipeline_content, privileged_pipeline_content) = Pipeline::create::(InitialPipelineState { id: pipeline_id, parent_info: parent_info, diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index bdb9b9def53..c32e1f12cd0 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -235,9 +235,9 @@ impl Pipeline { mem_profiler_chan: state.mem_profiler_chan, load_data: state.load_data, failure: failure, - layout_to_paint_port: Some(layout_to_paint_port), + layout_to_paint_port: layout_to_paint_port, chrome_to_paint_chan: chrome_to_paint_chan, - chrome_to_paint_port: Some(chrome_to_paint_port), + chrome_to_paint_port: chrome_to_paint_port, paint_shutdown_chan: paint_shutdown_chan, script_to_compositor_port: script_to_compositor_port, }; @@ -384,7 +384,7 @@ impl UnprivilegedPipelineContent { ScriptTaskFactory::create(None::<&mut STF>, InitialScriptState { id: self.id, parent_info: self.parent_info, - compositor: self.script_to_compositor_chan.clone(), + compositor: self.script_to_compositor_chan, control_chan: self.script_chan.clone(), control_port: mem::replace(&mut self.script_port, None).unwrap(), constellation_chan: self.constellation_chan.clone(), @@ -439,15 +439,26 @@ pub struct PrivilegedPipelineContent { mem_profiler_chan: profile_mem::ProfilerChan, load_data: LoadData, failure: Failure, - layout_to_paint_port: Option>, + layout_to_paint_port: Receiver, chrome_to_paint_chan: Sender, - chrome_to_paint_port: Option>, + chrome_to_paint_port: Receiver, paint_shutdown_chan: IpcSender<()>, } impl PrivilegedPipelineContent { - pub fn start_all(mut self) { - self.start_paint_task(); + pub fn start_all(self) { + PaintTask::create(self.id, + self.load_data.url, + self.chrome_to_paint_chan, + self.layout_to_paint_port, + self.chrome_to_paint_port, + self.compositor_proxy.clone_compositor_proxy(), + self.painter_chan, + self.font_cache_task, + self.failure, + self.time_profiler_chan, + self.mem_profiler_chan, + self.paint_shutdown_chan); let compositor_proxy_for_script_listener_thread = self.compositor_proxy.clone_compositor_proxy(); @@ -459,19 +470,19 @@ impl PrivilegedPipelineContent { }); } - pub fn start_paint_task(&mut self) { + pub fn start_paint_task(self) { PaintTask::create(self.id, - self.load_data.url.clone(), - self.chrome_to_paint_chan.clone(), - mem::replace(&mut self.layout_to_paint_port, None).unwrap(), - mem::replace(&mut self.chrome_to_paint_port, None).unwrap(), - self.compositor_proxy.clone_compositor_proxy(), - self.painter_chan.clone(), - self.font_cache_task.clone(), - self.failure.clone(), - self.time_profiler_chan.clone(), - self.mem_profiler_chan.clone(), - self.paint_shutdown_chan.clone()); + self.load_data.url, + self.chrome_to_paint_chan, + self.layout_to_paint_port, + self.chrome_to_paint_port, + self.compositor_proxy, + self.painter_chan, + self.font_cache_task, + self.failure, + self.time_profiler_chan, + self.mem_profiler_chan, + self.paint_shutdown_chan); } }