auto merge of #5192 : glennw/servo/remove-frame-id, r=Ms2ger

This will be re-introduced in a follow up PR with a different usage, but I'm trying to create small, independent PRs that are easier to review than one large change.
This commit is contained in:
bors-servo 2015-03-11 03:45:47 -06:00
commit 6ba3014d9b
4 changed files with 9 additions and 38 deletions

View file

@ -5,7 +5,7 @@
//! Communication with the compositor task.
pub use windowing;
pub use constellation::{FrameId, SendableFrameTree};
pub use constellation::SendableFrameTree;
use compositor;
use headless;

View file

@ -76,9 +76,6 @@ pub struct Constellation<LTF, STF> {
/// The next free ID to assign to a pipeline.
next_pipeline_id: PipelineId,
/// The next free ID to assign to a frame.
next_frame_id: FrameId,
/// Navigation operations that are in progress.
pending_frames: Vec<FrameChange>,
@ -90,14 +87,8 @@ pub struct Constellation<LTF, STF> {
pub window_size: WindowSizeData,
}
/// A unique ID used to identify a frame.
#[derive(Copy)]
pub struct FrameId(u32);
/// One frame in the hierarchy.
struct FrameTree {
/// The ID of this frame.
pub id: FrameId,
/// The pipeline for this frame.
pub pipeline: RefCell<Rc<Pipeline>>,
/// The parent frame's pipeline.
@ -109,10 +100,9 @@ struct FrameTree {
}
impl FrameTree {
fn new(id: FrameId, pipeline: Rc<Pipeline>, parent_pipeline: Option<Rc<Pipeline>>)
fn new(pipeline: Rc<Pipeline>, parent_pipeline: Option<Rc<Pipeline>>)
-> FrameTree {
FrameTree {
id: id,
pipeline: RefCell::new(pipeline.clone()),
parent: RefCell::new(parent_pipeline),
children: RefCell::new(vec!()),
@ -364,7 +354,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
pipelines: HashMap::new(),
navigation_context: NavigationContext::new(),
next_pipeline_id: PipelineId(0),
next_frame_id: FrameId(0),
pending_frames: vec!(),
pending_sizes: HashMap::new(),
time_profiler_chan: time_profiler_chan,
@ -419,14 +408,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
id
}
/// Helper function for getting a unique frame ID.
fn get_next_frame_id(&mut self) -> FrameId {
let id = self.next_frame_id;
let FrameId(ref mut i) = self.next_frame_id;
*i += 1;
id
}
/// Convenience function for getting the currently active frame tree.
/// The currently active frame tree should always be the current painter
fn current_frame<'a>(&'a self) -> &'a Option<Rc<FrameTree>> {
@ -567,12 +548,11 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
debug!("creating replacement pipeline for about:failure");
let new_id = self.get_next_pipeline_id();
let new_frame_id = self.get_next_frame_id();
let pipeline = self.new_pipeline(new_id, parent, None,
LoadData::new(Url::parse("about:failure").unwrap()));
self.browse(Some(pipeline_id),
Rc::new(FrameTree::new(new_frame_id, pipeline.clone(), None)),
Rc::new(FrameTree::new(pipeline.clone(), None)),
NavigationType::Load);
self.pipelines.insert(new_id, pipeline);
@ -594,10 +574,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
fn handle_init_load(&mut self, url: Url) {
let next_pipeline_id = self.get_next_pipeline_id();
let next_frame_id = self.get_next_frame_id();
let pipeline = self.new_pipeline(next_pipeline_id, None, None, LoadData::new(url));
self.browse(None,
Rc::new(FrameTree::new(next_frame_id, pipeline.clone(), None)),
Rc::new(FrameTree::new(pipeline.clone(), None)),
NavigationType::Load);
self.pipelines.insert(pipeline.id, pipeline);
}
@ -729,8 +708,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
self.update_child_pipeline(frame_tree.clone(), new_pipeline, old_subpage_id),
None => {
let child_tree = Rc::new(
FrameTree::new(self.get_next_frame_id(),
new_pipeline,
FrameTree::new(new_pipeline,
Some(frame_tree.pipeline.borrow().clone())));
frame_tree.add_child(ChildFrameTree::new(child_tree, new_rect));
}
@ -826,11 +804,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let parent = source_frame.parent.clone();
let parent_id = source_frame.pipeline.borrow().parent;
let next_pipeline_id = self.get_next_pipeline_id();
let next_frame_id = self.get_next_frame_id();
let pipeline = self.new_pipeline(next_pipeline_id, parent_id, None, load_data);
self.browse(Some(source_id),
Rc::new(FrameTree::new(next_frame_id,
pipeline.clone(),
Rc::new(FrameTree::new(pipeline.clone(),
parent.borrow().clone())),
NavigationType::Load);
// Send message to ScriptTask that will suspend all timers

View file

@ -8,7 +8,7 @@ use dom::document::{Document, DocumentHelpers};
use dom::node::NodeHelpers;
use dom::window::Window;
use msg::constellation_msg::{PipelineId, SubpageId};
use msg::constellation_msg::PipelineId;
use util::smallvec::SmallVec;
use std::cell::Cell;
use std::rc::Rc;
@ -20,9 +20,6 @@ pub struct Page {
/// Pipeline id associated with this page.
id: PipelineId,
/// Subpage id associated with this page, if any.
subpage_id: Option<SubpageId>,
/// The outermost frame containing the document and window.
frame: DOMRefCell<Option<Frame>>,
@ -65,10 +62,9 @@ impl IterablePage for Rc<Page> {
}
impl Page {
pub fn new(id: PipelineId, subpage_id: Option<SubpageId>, url: Url) -> Page {
pub fn new(id: PipelineId, url: Url) -> Page {
Page {
id: id,
subpage_id: subpage_id,
frame: DOMRefCell::new(None),
url: url,
needs_reflow: Cell::new(true),

View file

@ -909,8 +909,7 @@ impl ScriptTask {
let cx = cx.as_ref().unwrap();
// Create a new frame tree entry.
let page = Rc::new(Page::new(incomplete.pipeline_id, incomplete.subpage_id.map(|p| p.1),
final_url.clone()));
let page = Rc::new(Page::new(incomplete.pipeline_id, final_url.clone()));
if !root_page_exists {
// We have a new root frame tree.
*self.page.borrow_mut() = Some(page.clone());