From 6806ca190004b542322dd7440d0bfdf6843967ce Mon Sep 17 00:00:00 2001 From: Alan Jeffrey Date: Fri, 28 Oct 2016 13:42:01 -0500 Subject: [PATCH] Tidying up constellation. --- components/constellation/constellation.rs | 35 +++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index ea815debf89..ecc85944023 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -641,6 +641,11 @@ impl Constellation future } + fn joint_session_future_is_empty(&self, frame_id_root: FrameId) -> bool { + self.full_frame_tree_iter(frame_id_root) + .all(|frame| frame.next.is_empty()) + } + fn joint_session_past(&self, frame_id_root: FrameId) -> Vec<(Instant, FrameId, PipelineId)> { let mut past = vec!(); for frame in self.full_frame_tree_iter(frame_id_root) { @@ -655,6 +660,11 @@ impl Constellation past } + fn joint_session_past_is_empty(&self, frame_id_root: FrameId) -> bool { + self.full_frame_tree_iter(frame_id_root) + .all(|frame| frame.prev.is_empty()) + } + // Create a new frame and update the internal bookkeeping. fn new_frame(&mut self, frame_id: FrameId, pipeline_id: PipelineId) { let frame = Frame::new(frame_id, pipeline_id); @@ -1375,6 +1385,7 @@ impl Constellation } fn load_url(&mut self, source_id: PipelineId, load_data: LoadData, replace: bool) -> Option { + debug!("Loading {} in pipeline {}.", load_data.url, source_id); // If this load targets an iframe, its framing element may exist // in a separate script thread than the framed document that initiated // the new load. The framing element must be notified about the @@ -1446,8 +1457,8 @@ impl Constellation fn handle_load_start_msg(&mut self, pipeline_id: PipelineId) { let frame_id = self.get_top_level_frame_for_pipeline(Some(pipeline_id)); - let forward = !self.joint_session_future(frame_id).is_empty(); - let back = !self.joint_session_past(frame_id).is_empty(); + let forward = !self.joint_session_future_is_empty(frame_id); + let back = !self.joint_session_past_is_empty(frame_id); self.compositor_proxy.send(ToCompositorMsg::LoadStart(back, forward)); } @@ -1464,8 +1475,8 @@ impl Constellation self.webdriver.load_channel = None; } let frame_id = self.get_top_level_frame_for_pipeline(Some(pipeline_id)); - let forward = !self.joint_session_future(frame_id).is_empty(); - let back = !self.joint_session_past(frame_id).is_empty(); + let forward = !self.joint_session_future_is_empty(frame_id); + let back = !self.joint_session_past_is_empty(frame_id); let root = self.root_frame_id == frame_id; self.compositor_proxy.send(ToCompositorMsg::LoadComplete(back, forward, root)); self.handle_subframe_loaded(pipeline_id); @@ -1788,12 +1799,10 @@ impl Constellation let prev_pipeline_id = match self.frames.get_mut(&frame_id) { Some(frame) => { let prev = frame.current.pipeline_id; + // Check that this frame contains the pipeline passed in, so that this does not // change Frame's state before realizing `next_pipeline_id` is invalid. - let mut contains_pipeline = false; - if frame.next.iter().find(|entry| next_pipeline_id == entry.pipeline_id).is_some() { - contains_pipeline = true; frame.prev.push(frame.current.clone()); while let Some(entry) = frame.next.pop() { if entry.pipeline_id == next_pipeline_id { @@ -1803,11 +1812,7 @@ impl Constellation frame.prev.push(entry); } } - } - - if !contains_pipeline && - frame.prev.iter().find(|entry| next_pipeline_id == entry.pipeline_id).is_some() { - contains_pipeline = true; + } else if frame.prev.iter().find(|entry| next_pipeline_id == entry.pipeline_id).is_some() { frame.next.push(frame.current.clone()); while let Some(entry) = frame.prev.pop() { if entry.pipeline_id == next_pipeline_id { @@ -1817,9 +1822,7 @@ impl Constellation frame.next.push(entry); } } - } - - if !contains_pipeline { + } else if prev != next_pipeline_id { return warn!("Tried to traverse frame {:?} to pipeline {:?} it does not contain.", frame_id, next_pipeline_id); } @@ -1893,6 +1896,8 @@ impl Constellation } fn add_or_replace_pipeline_in_frame_tree(&mut self, frame_change: FrameChange) { + debug!("Setting frame {} to be pipeline {}.", frame_change.frame_id, frame_change.new_pipeline_id); + // If the currently focused pipeline is the one being changed (or a child // of the pipeline being changed) then update the focus pipeline to be // the replacement.