Auto merge of #12692 - Ms2ger:add_or_replace_pipeline_in_frame_tree, r=metajack

Simplify add_or_replace_pipeline_in_frame_tree.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12692)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-08-02 11:30:20 -05:00 committed by GitHub
commit e43d0e45d5

View file

@ -1886,18 +1886,16 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
// Remove paint permissions for the pipeline being replaced.
self.revoke_paint_permission(old_pipeline_id);
// Add new pipeline to navigation frame, and return frames evicted from history.
self.pipelines
.get(&old_pipeline_id)
.and_then(|pipeline| pipeline.frame)
.map(|frame_id| {
self.pipelines.get_mut(&frame_change.new_pipeline_id)
.map(|pipeline| pipeline.frame = Some(frame_id));
self.frames.get_mut(&frame_id).map(|frame| frame.load(frame_change.new_pipeline_id));
frame_id
})
self.pipelines.get(&old_pipeline_id).and_then(|pipeline| pipeline.frame)
});
if let Some(frame_id) = frame_id {
// Add new pipeline to navigation frame, and return frames evicted from history.
self.pipelines.get_mut(&frame_change.new_pipeline_id)
.map(|pipeline| pipeline.frame = Some(frame_id));
self.frames.get_mut(&frame_id).map(|frame| frame.load(frame_change.new_pipeline_id));
}
if let None = frame_id {
// The new pipeline is in a new frame with no history
let frame_id = self.new_frame(frame_change.new_pipeline_id);