Skip to content
Permalink
Browse files

move navigation_type from Pipeline to FrameChange

  • Loading branch information
Tim Kuehn
Tim Kuehn committed Aug 19, 2013
1 parent 8993434 commit f2c00f7e2870c05573c18713d0d33f025d66010a
@@ -339,7 +339,8 @@ impl CompositorLayer {

// Add new tiles.
let quadtree = match self.quadtree {
NoTree(_, _) => fail!("CompositorLayer: cannot get buffer request, no quadtree initialized"),
NoTree(_, _) => fail!("CompositorLayer: cannot get buffer request for %?,
no quadtree initialized", self.pipeline.id),
Tree(ref mut quadtree) => quadtree,
};

@@ -384,7 +385,8 @@ impl CompositorLayer {
if self.pipeline.id == pipeline_id {
{ // block here to prevent double mutable borrow of self
let quadtree = match self.quadtree {
NoTree(_, _) => fail!("CompositorLayer: cannot get buffer request, no quadtree initialized"),
NoTree(_, _) => fail!("CompositorLayer: cannot get buffer request for %?,
no quadtree initialized", self.pipeline.id),
Tree(ref mut quadtree) => quadtree,
};

@@ -299,6 +299,7 @@ impl CompositorTask {
}

SetLayerPageSize(id, new_size) => {
println(fmt!("Compositor: id %? sent new layer of size %?", id, new_size));
match compositor_layer {
Some(ref mut layer) => {
let page_window = Size2D(window_size.width as f32 / world_zoom,
@@ -15,7 +15,7 @@ use gfx::opts::Opts;
use pipeline::Pipeline;
use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, FrameRectMsg};
use servo_msg::constellation_msg::{InitLoadUrlMsg, LoadIframeUrlMsg, LoadUrlMsg};
use servo_msg::constellation_msg::{Msg, NavigateMsg};
use servo_msg::constellation_msg::{Msg, NavigateMsg, NavigationType};
use servo_msg::constellation_msg::{PipelineId, RendererReadyMsg, ResizedWindowMsg, SubpageId};
use servo_msg::constellation_msg;
use script::script_task::{SendEventMsg, ResizeInactiveMsg, ExecuteMsg};
@@ -157,6 +157,9 @@ impl ChildFrameTree {
}
}

/// An iterator over a frame tree, returning nodes in depth-first order.
/// Note that this iterator should _not_ be used to mutate nodes _during_
/// iteration. Mutating nodes once the iterator is out of scope is OK.
pub struct FrameTreeIterator {
priv stack: ~[@mut FrameTree],
}
@@ -165,7 +168,7 @@ impl Iterator<@mut FrameTree> for FrameTreeIterator {
fn next(&mut self) -> Option<@mut FrameTree> {
if !self.stack.is_empty() {
let next = self.stack.pop();
for &ChildFrameTree { frame_tree, _ } in next.children.iter() {
for &ChildFrameTree { frame_tree, _ } in next.children.rev_iter() {
self.stack.push(frame_tree);
}
Some(next)
@@ -179,6 +182,7 @@ impl Iterator<@mut FrameTree> for FrameTreeIterator {
struct FrameChange {
before: Option<PipelineId>,
after: @mut FrameTree,
navigation_type: NavigationType,
}

/// Stores the Id's of the pipelines previous and next in the browser's history
@@ -380,7 +384,7 @@ impl Constellation {
if url.path.ends_with(".js") {
pipeline.script_chan.send(ExecuteMsg(pipeline.id, url));
} else {
pipeline.load(url, Some(constellation_msg::Load));
pipeline.load(url);

self.pending_frames.push(FrameChange{
before: None,
@@ -389,6 +393,7 @@ impl Constellation {
parent: None,
children: ~[],
},
navigation_type: constellation_msg::Load,
});
}
self.pipelines.insert(pipeline.id, pipeline);
@@ -518,7 +523,7 @@ impl Constellation {
if url.path.ends_with(".js") {
pipeline.execute(url);
} else {
pipeline.load(url, None);
pipeline.load(url);
}
let rect = self.pending_sizes.pop(&(source_pipeline_id, subpage_id));
for frame_tree in frame_trees.iter() {
@@ -574,7 +579,7 @@ impl Constellation {
if url.path.ends_with(".js") {
pipeline.script_chan.send(ExecuteMsg(pipeline.id, url));
} else {
pipeline.load(url, Some(constellation_msg::Load));
pipeline.load(url);

self.pending_frames.push(FrameChange{
before: Some(source_id),
@@ -583,6 +588,7 @@ impl Constellation {
parent: parent,
children: ~[],
},
navigation_type: constellation_msg::Load,
});
}
self.pipelines.insert(pipeline.id, pipeline);
@@ -624,9 +630,9 @@ impl Constellation {

for frame in destination_frame.iter() {
let pipeline = &frame.pipeline;
pipeline.reload(Some(constellation_msg::Navigate));
pipeline.reload();
}
self.grant_paint_permission(destination_frame);
self.grant_paint_permission(destination_frame, constellation_msg::Navigate);

}

@@ -640,8 +646,6 @@ impl Constellation {
// TODO(tkuehn): In fact, this kind of message might be provably
// impossible to occur.
if current_frame.contains(pipeline_id) {
debug!("updating compositor frame tree with %?", current_frame);
self.set_ids(current_frame);
return;
}
}
@@ -701,7 +705,7 @@ impl Constellation {
}
}
}
self.grant_paint_permission(next_frame_tree);
self.grant_paint_permission(next_frame_tree, frame_change.navigation_type);
}
}

@@ -713,8 +717,9 @@ impl Constellation {
ResizeEvent(width, height)));
already_seen.insert(pipeline.id.clone());
}
for &@FrameTree { pipeline: ref pipeline, _ } in self.navigation_context.previous.iter()
for frame_tree in self.navigation_context.previous.iter()
.chain(self.navigation_context.next.iter()) {
let pipeline = &frame_tree.pipeline;
if !already_seen.contains(&pipeline.id) {
pipeline.script_chan.send(ResizeInactiveMsg(pipeline.id.clone(), new_size));
already_seen.insert(pipeline.id.clone());
@@ -723,14 +728,14 @@ 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: @mut FrameTree) {
fn grant_paint_permission(&mut self, frame_tree: @mut FrameTree, navigation_type: NavigationType) {
// Give permission to paint to the new frame and all child frames
self.set_ids(frame_tree);

// Don't call navigation_context.load() on a Navigate type (or None, as in the case of
// parsed iframes that finish loading)
match frame_tree.pipeline.navigation_type {
Some(constellation_msg::Load) => {
match navigation_type {
constellation_msg::Load => {
let evicted = self.navigation_context.load(frame_tree);
for frame_tree in evicted.iter() {
// exit any pipelines that don't exist outside the evicted frame trees
@@ -11,7 +11,7 @@ use gfx::opts::Opts;
use layout::layout_task::LayoutTask;
use script::layout_interface::LayoutChan;
use script::script_task::{ExecuteMsg, LoadMsg};
use servo_msg::constellation_msg::{ConstellationChan, NavigationType, PipelineId, SubpageId};
use servo_msg::constellation_msg::{ConstellationChan, PipelineId, SubpageId};
use script::script_task::{AttachLayoutMsg, NewLayoutInfo, ScriptTask, ScriptChan};
use script::script_task;
use servo_net::image_cache_task::ImageCacheTask;
@@ -31,7 +31,6 @@ pub struct Pipeline {
render_chan: RenderChan,
/// The most recently loaded url
url: Option<Url>,
navigation_type: Option<NavigationType>,
}

impl Pipeline {
@@ -140,13 +139,11 @@ impl Pipeline {
layout_chan: layout_chan,
render_chan: render_chan,
url: None,
navigation_type: None,
}
}

pub fn load(&mut self, url: Url, navigation_type: Option<NavigationType>) {
pub fn load(&mut self, url: Url) {
self.url = Some(url.clone());
self.navigation_type = navigation_type;
self.script_chan.send(LoadMsg(self.id, url));
}

@@ -163,11 +160,10 @@ impl Pipeline {
self.render_chan.send(PaintPermissionRevoked);
}

pub fn reload(&mut self, navigation_type: Option<NavigationType>) {
if self.url.is_some() {
let url = self.url.get_ref().clone();
self.load(url, navigation_type);
}
pub fn reload(&mut self) {
do self.url.clone().map_consume() |url| {
self.load(url);
};
}

pub fn exit(&self) {

0 comments on commit f2c00f7

Please sign in to comment.
You can’t perform that action at this time.