move navigation_type from Pipeline to FrameChange

This commit is contained in:
Tim Kuehn 2013-08-08 23:06:10 -07:00
parent 8993434c39
commit f2c00f7e28
4 changed files with 30 additions and 26 deletions

View file

@ -339,7 +339,8 @@ impl CompositorLayer {
// Add new tiles. // Add new tiles.
let quadtree = match self.quadtree { 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, Tree(ref mut quadtree) => quadtree,
}; };
@ -384,7 +385,8 @@ impl CompositorLayer {
if self.pipeline.id == pipeline_id { if self.pipeline.id == pipeline_id {
{ // block here to prevent double mutable borrow of self { // block here to prevent double mutable borrow of self
let quadtree = match self.quadtree { 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, Tree(ref mut quadtree) => quadtree,
}; };

View file

@ -299,6 +299,7 @@ impl CompositorTask {
} }
SetLayerPageSize(id, new_size) => { SetLayerPageSize(id, new_size) => {
println(fmt!("Compositor: id %? sent new layer of size %?", id, new_size));
match compositor_layer { match compositor_layer {
Some(ref mut layer) => { Some(ref mut layer) => {
let page_window = Size2D(window_size.width as f32 / world_zoom, let page_window = Size2D(window_size.width as f32 / world_zoom,

View file

@ -15,7 +15,7 @@ use gfx::opts::Opts;
use pipeline::Pipeline; use pipeline::Pipeline;
use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, FrameRectMsg}; use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, FrameRectMsg};
use servo_msg::constellation_msg::{InitLoadUrlMsg, LoadIframeUrlMsg, LoadUrlMsg}; 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::{PipelineId, RendererReadyMsg, ResizedWindowMsg, SubpageId};
use servo_msg::constellation_msg; use servo_msg::constellation_msg;
use script::script_task::{SendEventMsg, ResizeInactiveMsg, ExecuteMsg}; 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 { pub struct FrameTreeIterator {
priv stack: ~[@mut FrameTree], priv stack: ~[@mut FrameTree],
} }
@ -165,7 +168,7 @@ impl Iterator<@mut FrameTree> for FrameTreeIterator {
fn next(&mut self) -> Option<@mut FrameTree> { fn next(&mut self) -> Option<@mut FrameTree> {
if !self.stack.is_empty() { if !self.stack.is_empty() {
let next = self.stack.pop(); 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); self.stack.push(frame_tree);
} }
Some(next) Some(next)
@ -179,6 +182,7 @@ impl Iterator<@mut FrameTree> for FrameTreeIterator {
struct FrameChange { struct FrameChange {
before: Option<PipelineId>, before: Option<PipelineId>,
after: @mut FrameTree, after: @mut FrameTree,
navigation_type: NavigationType,
} }
/// Stores the Id's of the pipelines previous and next in the browser's history /// 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") { if url.path.ends_with(".js") {
pipeline.script_chan.send(ExecuteMsg(pipeline.id, url)); pipeline.script_chan.send(ExecuteMsg(pipeline.id, url));
} else { } else {
pipeline.load(url, Some(constellation_msg::Load)); pipeline.load(url);
self.pending_frames.push(FrameChange{ self.pending_frames.push(FrameChange{
before: None, before: None,
@ -389,6 +393,7 @@ impl Constellation {
parent: None, parent: None,
children: ~[], children: ~[],
}, },
navigation_type: constellation_msg::Load,
}); });
} }
self.pipelines.insert(pipeline.id, pipeline); self.pipelines.insert(pipeline.id, pipeline);
@ -518,7 +523,7 @@ impl Constellation {
if url.path.ends_with(".js") { if url.path.ends_with(".js") {
pipeline.execute(url); pipeline.execute(url);
} else { } else {
pipeline.load(url, None); pipeline.load(url);
} }
let rect = self.pending_sizes.pop(&(source_pipeline_id, subpage_id)); let rect = self.pending_sizes.pop(&(source_pipeline_id, subpage_id));
for frame_tree in frame_trees.iter() { for frame_tree in frame_trees.iter() {
@ -574,7 +579,7 @@ impl Constellation {
if url.path.ends_with(".js") { if url.path.ends_with(".js") {
pipeline.script_chan.send(ExecuteMsg(pipeline.id, url)); pipeline.script_chan.send(ExecuteMsg(pipeline.id, url));
} else { } else {
pipeline.load(url, Some(constellation_msg::Load)); pipeline.load(url);
self.pending_frames.push(FrameChange{ self.pending_frames.push(FrameChange{
before: Some(source_id), before: Some(source_id),
@ -583,6 +588,7 @@ impl Constellation {
parent: parent, parent: parent,
children: ~[], children: ~[],
}, },
navigation_type: constellation_msg::Load,
}); });
} }
self.pipelines.insert(pipeline.id, pipeline); self.pipelines.insert(pipeline.id, pipeline);
@ -624,9 +630,9 @@ impl Constellation {
for frame in destination_frame.iter() { for frame in destination_frame.iter() {
let pipeline = &frame.pipeline; 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 // TODO(tkuehn): In fact, this kind of message might be provably
// impossible to occur. // impossible to occur.
if current_frame.contains(pipeline_id) { if current_frame.contains(pipeline_id) {
debug!("updating compositor frame tree with %?", current_frame);
self.set_ids(current_frame);
return; 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))); ResizeEvent(width, height)));
already_seen.insert(pipeline.id.clone()); 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()) { .chain(self.navigation_context.next.iter()) {
let pipeline = &frame_tree.pipeline;
if !already_seen.contains(&pipeline.id) { if !already_seen.contains(&pipeline.id) {
pipeline.script_chan.send(ResizeInactiveMsg(pipeline.id.clone(), new_size)); pipeline.script_chan.send(ResizeInactiveMsg(pipeline.id.clone(), new_size));
already_seen.insert(pipeline.id.clone()); 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 // 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 // Give permission to paint to the new frame and all child frames
self.set_ids(frame_tree); self.set_ids(frame_tree);
// Don't call navigation_context.load() on a Navigate type (or None, as in the case of // 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 frame_tree.pipeline.navigation_type { match navigation_type {
Some(constellation_msg::Load) => { constellation_msg::Load => {
let evicted = self.navigation_context.load(frame_tree); let evicted = self.navigation_context.load(frame_tree);
for frame_tree in evicted.iter() { for frame_tree in evicted.iter() {
// exit any pipelines that don't exist outside the evicted frame trees // exit any pipelines that don't exist outside the evicted frame trees

View file

@ -11,7 +11,7 @@ use gfx::opts::Opts;
use layout::layout_task::LayoutTask; use layout::layout_task::LayoutTask;
use script::layout_interface::LayoutChan; use script::layout_interface::LayoutChan;
use script::script_task::{ExecuteMsg, LoadMsg}; 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::{AttachLayoutMsg, NewLayoutInfo, ScriptTask, ScriptChan};
use script::script_task; use script::script_task;
use servo_net::image_cache_task::ImageCacheTask; use servo_net::image_cache_task::ImageCacheTask;
@ -31,7 +31,6 @@ pub struct Pipeline {
render_chan: RenderChan, render_chan: RenderChan,
/// The most recently loaded url /// The most recently loaded url
url: Option<Url>, url: Option<Url>,
navigation_type: Option<NavigationType>,
} }
impl Pipeline { impl Pipeline {
@ -140,13 +139,11 @@ impl Pipeline {
layout_chan: layout_chan, layout_chan: layout_chan,
render_chan: render_chan, render_chan: render_chan,
url: None, 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.url = Some(url.clone());
self.navigation_type = navigation_type;
self.script_chan.send(LoadMsg(self.id, url)); self.script_chan.send(LoadMsg(self.id, url));
} }
@ -163,11 +160,10 @@ impl Pipeline {
self.render_chan.send(PaintPermissionRevoked); self.render_chan.send(PaintPermissionRevoked);
} }
pub fn reload(&mut self, navigation_type: Option<NavigationType>) { pub fn reload(&mut self) {
if self.url.is_some() { do self.url.clone().map_consume() |url| {
let url = self.url.get_ref().clone(); self.load(url);
self.load(url, navigation_type); };
}
} }
pub fn exit(&self) { pub fn exit(&self) {