diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-02-28 09:25:18 +0530 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2016-02-28 09:25:18 +0530 |
commit | 39502d6bed76343930b9d6409203e9c2e9ff09fc (patch) | |
tree | 965a92cd0cd19b89685cb8e31d38806ea0b1b26a | |
parent | 5b8041147d81f56c908080c6da36d206bdc3debe (diff) | |
parent | f5697b1c39bc8503d1de048799727f58d5d6dea2 (diff) | |
download | servo-39502d6bed76343930b9d6409203e9c2e9ff09fc.tar.gz servo-39502d6bed76343930b9d6409203e9c2e9ff09fc.zip |
Auto merge of #9789 - frewsxcv:constellation-cleanup, r=nox
Minor constellation refactoring.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9789)
<!-- Reviewable:end -->
-rw-r--r-- | components/compositing/constellation.rs | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index b7a57f7069e..32c8170c5a6 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -471,12 +471,8 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF> // Get an iterator for the current frame tree. Specify self.root_frame_id to // iterate the entire tree, or a specific frame id to iterate only that sub-tree. fn current_frame_tree_iter(&self, frame_id_root: Option<FrameId>) -> FrameTreeIterator { - let mut stack = vec!(); - if let Some(frame_id_root) = frame_id_root { - stack.push(frame_id_root); - } FrameTreeIterator { - stack: stack, + stack: frame_id_root.into_iter().collect(), pipelines: &self.pipelines, frames: &self.frames, } @@ -973,8 +969,7 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF> self.push_pending_frame(new_pipeline_id, Some(source_id)); // Send message to ScriptThread that will suspend all timers - let old_pipeline = self.pipelines.get(&source_id).unwrap(); - old_pipeline.freeze(); + self.pipeline(source_id).freeze(); Some(new_pipeline_id) } } @@ -1146,10 +1141,8 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF> fn handle_get_pipeline(&mut self, frame_id: Option<FrameId>, resp_chan: IpcSender<Option<PipelineId>>) { - let current_pipeline_id = frame_id.or(self.root_frame_id).map(|frame_id| { - let frame = self.frames.get(&frame_id).unwrap(); - frame.current - }); + let current_pipeline_id = frame_id.or(self.root_frame_id) + .map(|frame_id| self.frame(frame_id).current); let pipeline_id = self.pending_frames.iter().rev() .find(|x| x.old_pipeline_id == current_pipeline_id) .map(|x| x.new_pipeline_id).or(current_pipeline_id); @@ -1257,10 +1250,8 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF> } }, WebDriverCommandMsg::TakeScreenshot(pipeline_id, reply) => { - let current_pipeline_id = self.root_frame_id.map(|frame_id| { - let frame = self.frames.get(&frame_id).unwrap(); - frame.current - }); + let current_pipeline_id = self.root_frame_id + .map(|frame_id| self.frame(frame_id).current); if Some(pipeline_id) == current_pipeline_id { self.compositor_proxy.send(ToCompositorMsg::CreatePng(reply)); } else { @@ -1398,20 +1389,20 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF> if let Some(root_frame_id) = self.root_frame_id { // Send Resize (or ResizeInactive) messages to each // pipeline in the frame tree. - let frame = self.frames.get(&root_frame_id).unwrap(); + let frame = self.frame(root_frame_id); - let pipeline = self.pipelines.get(&frame.current).unwrap(); + let pipeline = self.pipeline(frame.current); let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size)); for pipeline_id in frame.prev.iter().chain(&frame.next) { - let pipeline = self.pipelines.get(pipeline_id).unwrap(); + let pipeline = self.pipeline(*pipeline_id); let _ = pipeline.script_chan.send(ConstellationControlMsg::ResizeInactive(pipeline.id, new_size)); } } // Send resize message to any pending pipelines that aren't loaded yet. for pending_frame in &self.pending_frames { - let pipeline = self.pipelines.get(&pending_frame.new_pipeline_id).unwrap(); + let pipeline = self.pipeline(pending_frame.new_pipeline_id); if pipeline.parent_info.is_none() { let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size)); |