added CompositorLayer::from_frame_tree

This commit is contained in:
Tim Kuehn 2013-08-06 15:18:52 -07:00
parent 2e166fb7ca
commit e4d44fb8d2
2 changed files with 24 additions and 22 deletions

View file

@ -15,6 +15,7 @@ use windowing::{MouseWindowEvent, MouseWindowClickEvent, MouseWindowMouseDownEve
use compositing::quadtree::{Quadtree, Invalid};
use layers::layers::{ContainerLayerKind, ContainerLayer, TextureLayerKind, TextureLayer, TextureManager};
use pipeline::Pipeline;
use constellation::{SendableChildFrameTree, SendableFrameTree};
/// The CompositorLayer represents an element on a page that has a unique scroll
/// or animation behavior. This can include absolute positioned elements, iframes, etc.
@ -81,6 +82,27 @@ impl CompositorLayer {
}
}
pub fn from_frame_tree(frame_tree: SendableFrameTree, tile_size: uint, max_mem: Option<uint>) -> CompositorLayer {
let SendableFrameTree { pipeline, children } = frame_tree;
CompositorLayer {
pipeline: pipeline,
page_size: None,
scroll_offset: Point2D(0f32, 0f32),
children: (do children.consume_iter().transform |child| {
let SendableChildFrameTree { frame_tree, rect } = child;
let container = @mut ContainerLayer();
container.scissor = rect;
CompositorLayerChild {
child: ~CompositorLayer::from_frame_tree(frame_tree, tile_size, max_mem),
container: container,
}
}).collect(),
quadtree: NoTree(tile_size, max_mem),
root_layer: @mut ContainerLayer(),
hidden: true,
}
}
// Move the layer by as relative specified amount in page coordinates. Does not change
// the position of the layer relative to its parent. This also takes in a cursor position
// to see if the mouse is over child layers first. If a layer successfully scrolled, returns

View file

@ -22,7 +22,7 @@ use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
use servo_net::resource_task::ResourceTask;
use servo_net::resource_task;
use servo_util::time::ProfilerChan;
use std::hashmap::{HashMap, HashSet};
use std::hashmap::HashMap;
use std::util::replace;
use extra::future::from_value;
@ -361,26 +361,6 @@ impl Constellation {
self.pipelines.insert(pipeline.id, pipeline);
}
/*
FrameRectMsg(pipeline_id, subpage_id, rect) => {
let frame_trees: ~[@mut FrameTree] = {
let matching_navi_frames = self.navigation_context.find_all(pipeline_id);
let matching_pending_frames = do self.pending_frames.iter().filter_map |frame_change| {
frame_change.after.find_mut(pipeline_id)
};
matching_navi_frames.consume_iter().chain_(matching_pending_frames).collect()
};
let mut subframes = HashSet::new();
for self.current_frame().find(pipeline_id).iter().advance |subframe| {
self.compositor_chan.send(ResizeLayerMsg(
}
if self.current_frame().contains(pipeline_id) {
self.compositor_chan.send(ResizeLayerMsg(pipeline_
}
let frame_trees = self.navigation_context.find_all(pipeline_id);
}
*/
LoadIframeUrlMsg(url, source_pipeline_id, subpage_id, size_future) => {
// A message from the script associated with pipeline_id that it has
// parsed an iframe during html parsing. This iframe will result in a
@ -446,7 +426,7 @@ impl Constellation {
} else {
pipeline.load(url, None);
}
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() {
frame_tree.children.push(ChildFrameTree {
frame_tree: @mut FrameTree {