servo: Merge #12692 - Simplify add_or_replace_pipeline_in_frame_tree (from Ms2ger:add_or_replace_pipeline_in_frame_tree); r=metajack
authorMs2ger <Ms2ger@gmail.com>
Tue, 02 Aug 2016 11:30:20 -0500
changeset 339420 cf3c934f0b9904f3ea3531de0673441a8059a5ae
parent 339419 c7f7e82aff1879dbeaf4a74e960874122b8cdb1e
child 339421 fd4b3b2bc96a3ea88d74bcabb3c0f201ea015878
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmetajack
servo: Merge #12692 - Simplify add_or_replace_pipeline_in_frame_tree (from Ms2ger:add_or_replace_pipeline_in_frame_tree); r=metajack Source-Repo: https://github.com/servo/servo Source-Revision: e43d0e45d53800421b6c7d6b46ab2511a4758056
servo/components/constellation/constellation.rs
--- a/servo/components/constellation/constellation.rs
+++ b/servo/components/constellation/constellation.rs
@@ -1881,27 +1881,25 @@ impl<Message, LTF, STF> Constellation<Me
             }
         }
 
         let frame_id = frame_change.old_pipeline_id.and_then(|old_pipeline_id| {
             // The new pipeline is replacing an old one.
             // Remove paint permissions for the pipeline being replaced.
             self.revoke_paint_permission(old_pipeline_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(&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_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);
 
             // If a child frame, add it to the parent pipeline. Otherwise
             // it must surely be the root frame being created!
             match self.pipelines.get(&frame_change.new_pipeline_id).and_then(|pipeline| pipeline.parent_info) {