mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Add some factory methods for frame tree types
This commit is contained in:
parent
a10e261ffd
commit
750bedab81
1 changed files with 31 additions and 28 deletions
|
@ -85,6 +85,19 @@ struct FrameTree {
|
||||||
pub children: RefCell<Vec<ChildFrameTree>>,
|
pub children: RefCell<Vec<ChildFrameTree>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FrameTree {
|
||||||
|
fn new(pipeline: Rc<Pipeline>, parent_pipeline: Option<Rc<Pipeline>>) -> FrameTree {
|
||||||
|
FrameTree {
|
||||||
|
pipeline: pipeline.clone(),
|
||||||
|
parent: match parent_pipeline {
|
||||||
|
Some(ref pipeline) => RefCell::new(Some(pipeline.clone())),
|
||||||
|
None => RefCell::new(None),
|
||||||
|
},
|
||||||
|
children: RefCell::new(vec!()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[deriving(Clone)]
|
#[deriving(Clone)]
|
||||||
struct ChildFrameTree {
|
struct ChildFrameTree {
|
||||||
frame_tree: Rc<FrameTree>,
|
frame_tree: Rc<FrameTree>,
|
||||||
|
@ -93,6 +106,15 @@ struct ChildFrameTree {
|
||||||
pub rect: Option<TypedRect<PagePx, f32>>,
|
pub rect: Option<TypedRect<PagePx, f32>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ChildFrameTree {
|
||||||
|
fn new(frame_tree: Rc<FrameTree>, rect: Option<TypedRect<PagePx, f32>>) -> ChildFrameTree {
|
||||||
|
ChildFrameTree {
|
||||||
|
frame_tree: frame_tree,
|
||||||
|
rect: rect,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct SendableFrameTree {
|
pub struct SendableFrameTree {
|
||||||
pub pipeline: CompositionPipeline,
|
pub pipeline: CompositionPipeline,
|
||||||
pub children: Vec<SendableChildFrameTree>,
|
pub children: Vec<SendableChildFrameTree>,
|
||||||
|
@ -481,11 +503,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
|
|
||||||
self.pending_frames.push(FrameChange{
|
self.pending_frames.push(FrameChange{
|
||||||
before: Some(pipeline_id),
|
before: Some(pipeline_id),
|
||||||
after: Rc::new(FrameTree {
|
after: Rc::new(FrameTree::new(pipeline.clone(), None)),
|
||||||
pipeline: pipeline.clone(),
|
|
||||||
parent: RefCell::new(None),
|
|
||||||
children: RefCell::new(vec!()),
|
|
||||||
}),
|
|
||||||
navigation_type: constellation_msg::Load,
|
navigation_type: constellation_msg::Load,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -498,11 +516,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
|
|
||||||
self.pending_frames.push(FrameChange {
|
self.pending_frames.push(FrameChange {
|
||||||
before: None,
|
before: None,
|
||||||
after: Rc::new(FrameTree {
|
after: Rc::new(FrameTree::new(pipeline.clone(), None)),
|
||||||
pipeline: pipeline.clone(),
|
|
||||||
parent: RefCell::new(None),
|
|
||||||
children: RefCell::new(vec!()),
|
|
||||||
}),
|
|
||||||
navigation_type: constellation_msg::Load,
|
navigation_type: constellation_msg::Load,
|
||||||
});
|
});
|
||||||
self.pipelines.insert(pipeline.id, pipeline);
|
self.pipelines.insert(pipeline.id, pipeline);
|
||||||
|
@ -645,14 +659,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
|
|
||||||
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() {
|
||||||
frame_tree.children.borrow_mut().push(ChildFrameTree {
|
frame_tree.children.borrow_mut().push(ChildFrameTree::new(
|
||||||
frame_tree: Rc::new(FrameTree {
|
Rc::new(FrameTree::new(pipeline.clone(), Some(source_pipeline.clone()))),
|
||||||
pipeline: pipeline.clone(),
|
rect));
|
||||||
parent: RefCell::new(Some(source_pipeline.clone())),
|
|
||||||
children: RefCell::new(vec!()),
|
|
||||||
}),
|
|
||||||
rect: rect,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
self.pipelines.insert(pipeline.id, pipeline);
|
self.pipelines.insert(pipeline.id, pipeline);
|
||||||
}
|
}
|
||||||
|
@ -686,13 +695,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
|
|
||||||
let pipeline = self.new_pipeline(next_pipeline_id, subpage_id, None, load_data);
|
let pipeline = self.new_pipeline(next_pipeline_id, subpage_id, None, load_data);
|
||||||
|
|
||||||
self.pending_frames.push(FrameChange{
|
self.pending_frames.push(FrameChange {
|
||||||
before: Some(source_id),
|
before: Some(source_id),
|
||||||
after: Rc::new(FrameTree {
|
after: Rc::new(FrameTree::new(pipeline.clone(), parent.borrow().clone())),
|
||||||
pipeline: pipeline.clone(),
|
|
||||||
parent: parent,
|
|
||||||
children: RefCell::new(vec!()),
|
|
||||||
}),
|
|
||||||
navigation_type: constellation_msg::Load,
|
navigation_type: constellation_msg::Load,
|
||||||
});
|
});
|
||||||
self.pipelines.insert(pipeline.id, pipeline);
|
self.pipelines.insert(pipeline.id, pipeline);
|
||||||
|
@ -816,10 +821,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
let parent = next_frame_tree.find(parent.id).expect(
|
let parent = next_frame_tree.find(parent.id).expect(
|
||||||
"Constellation: pending frame has a parent frame that is not
|
"Constellation: pending frame has a parent frame that is not
|
||||||
active. This is a bug.");
|
active. This is a bug.");
|
||||||
parent.children.borrow_mut().push(ChildFrameTree {
|
parent.children.borrow_mut().push(ChildFrameTree::new(to_add.clone(),
|
||||||
frame_tree: to_add.clone(),
|
rect));
|
||||||
rect: rect,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue