From 0d297aea9b135aae42e0618233d0f215d4a0736b Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Mon, 19 Jan 2015 11:30:04 -0800 Subject: [PATCH] Fix set_ids naming in Constellation The set_ids name is a holdover from a previous design and no longer reflects what this method does. Instead move the content into grant_paint_permission and rename it to send_frame_tree_and_grant_paint_permission. Also move out the handling of evicted iframes into its own method. --- components/compositing/constellation.rs | 54 ++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index fca671550b1..febc1f884d7 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -872,7 +872,7 @@ impl Constellation { for frame in destination_frame.iter() { frame.pipeline.borrow().load(); } - self.grant_paint_permission(destination_frame, NavigationType::Navigate); + self.send_frame_tree_and_grant_paint_permission(destination_frame); } @@ -978,7 +978,9 @@ impl Constellation { } } - self.grant_paint_permission(next_frame_tree, frame_change.navigation_type); + self.send_frame_tree_and_grant_paint_permission(next_frame_tree.clone()); + self.handle_evicted_frames_for_load_navigation(next_frame_tree, + frame_change.navigation_type); }, None => (), } @@ -1032,8 +1034,8 @@ impl Constellation { } } - fn handle_evicted_frames(&mut self, evicted: Vec>) { - for frame_tree in evicted.into_iter() { + fn handle_evicted_frames(&mut self, evicted_frames: Vec>) { + for frame_tree in evicted_frames.into_iter() { if !self.navigation_context.contains(frame_tree.pipeline.borrow().id) { self.close_pipelines(frame_tree); } else { @@ -1044,41 +1046,39 @@ impl Constellation { } } - // Grants a frame tree permission to paint; optionally updates navigation to reflect a new page - fn grant_paint_permission(&mut self, frame_tree: Rc, navigation_type: NavigationType) { - // Give permission to paint to the new frame and all child frames - self.set_ids(&frame_tree); + fn handle_evicted_frames_for_load_navigation(&mut self, + frame_tree: Rc, + navigation_type: NavigationType) { // Don't call navigation_context.load() on a Navigate type (or None, as in the case of - // parsed iframes that finish loading) + // parsed iframes that finish loading). match navigation_type { NavigationType::Load => { - debug!("evicting old frames due to load"); - let evicted = self.navigation_context.load(frame_tree, - &mut *self.compositor_proxy); - self.handle_evicted_frames(evicted); - } - _ => { - debug!("ignoring non-load navigation type"); + debug!("Evicting frames for NavigationType::Load"); + let evicted_frames = self.navigation_context.load(frame_tree, + &mut *self.compositor_proxy); + self.handle_evicted_frames(evicted_frames); } + _ => {} } } - fn set_ids(&mut self, frame_tree: &Rc) { - let (chan, port) = channel(); + // Grants a frame tree permission to paint; optionally updates navigation to reflect a new page + fn send_frame_tree_and_grant_paint_permission(&mut self, frame_tree: Rc) { debug!("Constellation sending SetFrameTree"); + let (chan, port) = channel(); self.compositor_proxy.send(CompositorMsg::SetFrameTree(frame_tree.to_sendable(), chan, self.chan.clone())); - match port.recv_opt() { - Ok(()) => { - let mut iter = frame_tree.iter(); - for frame in iter { - frame.has_compositor_layer.set(true); - frame.pipeline.borrow().grant_paint_permission(); - } - } - Err(()) => {} // message has been discarded, probably shutting down + if port.recv_opt().is_err() { + debug!("Compositor has discarded SetFrameTree"); + return; // Our message has been discarded, probably shutting down. + } + + let mut iter = frame_tree.iter(); + for frame in iter { + frame.has_compositor_layer.set(true); + frame.pipeline.borrow().grant_paint_permission(); } }