add pipeline.rs, modularized pipelines communicating with constellation

This commit is contained in:
Tim Kuehn 2013-06-26 22:42:01 -07:00
parent fdb0d820a4
commit fba7ec423c
19 changed files with 528 additions and 317 deletions

View file

@ -5,7 +5,6 @@
//! The layout task. Performs layout on the DOM, builds display lists and sends them to be
/// rendered.
use compositing::CompositorChan;
use css::matching::MatchMethods;
use css::select::new_css_select_ctx;
use layout::aux::{LayoutData, LayoutAuxMethods};
@ -34,7 +33,7 @@ use script::dom::node::{AbstractNode, LayoutView};
use script::layout_interface::{AddStylesheetMsg, ContentBoxQuery};
use script::layout_interface::{HitTestQuery, ContentBoxResponse, HitTestResponse};
use script::layout_interface::{ContentBoxesQuery, ContentBoxesResponse, ExitMsg, LayoutQuery};
use script::layout_interface::{LayoutResponse, MatchSelectorsDocumentDamage, Msg};
use script::layout_interface::{MatchSelectorsDocumentDamage, Msg};
use script::layout_interface::{QueryMsg, RouteScriptMsg, Reflow, ReflowDocumentDamage};
use script::layout_interface::{ReflowForDisplay, ReflowMsg};
use script::script_task::{ReflowCompleteMsg, ScriptChan, ScriptMsg, SendEventMsg};
@ -45,28 +44,10 @@ use servo_util::time::{ProfilerChan, profile, time};
use servo_util::time;
use extra::net::url::Url;
pub fn create_layout_task(port: Port<Msg>,
script_chan: ScriptChan,
render_chan: RenderChan<CompositorChan>,
img_cache_task: ImageCacheTask,
opts: Opts,
profiler_chan: ProfilerChan) {
let port = Cell::new(port);
do spawn {
let mut layout = Layout::new(port.take(),
script_chan.clone(),
render_chan.clone(),
img_cache_task.clone(),
&opts,
profiler_chan.clone());
layout.start();
};
}
struct Layout {
struct LayoutTask {
port: Port<Msg>,
script_chan: ScriptChan,
render_chan: RenderChan<CompositorChan>,
render_chan: RenderChan,
image_cache_task: ImageCacheTask,
local_image_cache: @mut LocalImageCache,
font_ctx: @mut FontContext,
@ -80,17 +61,35 @@ struct Layout {
profiler_chan: ProfilerChan,
}
impl Layout {
impl LayoutTask {
pub fn create(port: Port<Msg>,
script_chan: ScriptChan,
render_chan: RenderChan,
img_cache_task: ImageCacheTask,
opts: Opts,
profiler_chan: ProfilerChan) {
let port = Cell::new(port);
do spawn {
let mut layout = LayoutTask::new(port.take(),
script_chan.clone(),
render_chan.clone(),
img_cache_task.clone(),
&opts,
profiler_chan.clone());
layout.start();
};
}
fn new(port: Port<Msg>,
script_chan: ScriptChan,
render_chan: RenderChan<CompositorChan>,
render_chan: RenderChan,
image_cache_task: ImageCacheTask,
opts: &Opts,
profiler_chan: ProfilerChan)
-> Layout {
-> LayoutTask {
let fctx = @mut FontContext::new(opts.render_backend, true, profiler_chan.clone());
Layout {
LayoutTask {
port: port,
script_chan: script_chan,
render_chan: render_chan,
@ -135,10 +134,10 @@ impl Layout {
self.handle_reflow(data.take());
}
}
QueryMsg(query, chan) => {
let chan = Cell::new(chan);
QueryMsg(query) => {
let query = Cell::new(query);
do profile(time::LayoutQueryCategory, self.profiler_chan.clone()) {
self.handle_query(query, chan.take());
self.handle_query(query.take());
}
}
RouteScriptMsg(script_msg) => {
@ -268,9 +267,9 @@ impl Layout {
/// Handles a query from the script task. This is the main routine that DOM functions like
/// `getClientRects()` or `getBoundingClientRect()` ultimately invoke.
fn handle_query(&self, query: LayoutQuery, reply_chan: Chan<Result<LayoutResponse,()>>) {
fn handle_query(&self, query: LayoutQuery) {
match query {
ContentBoxQuery(node) => {
ContentBoxQuery(node, reply_chan) => {
// FIXME: Isolate this transmutation into a single "bridge" module.
let node: AbstractNode<LayoutView> = unsafe {
transmute(node)
@ -302,7 +301,7 @@ impl Layout {
reply_chan.send(response)
}
ContentBoxesQuery(node) => {
ContentBoxesQuery(node, reply_chan) => {
// FIXME: Isolate this transmutation into a single "bridge" module.
let node: AbstractNode<LayoutView> = unsafe {
transmute(node)
@ -322,7 +321,7 @@ impl Layout {
reply_chan.send(response)
}
HitTestQuery(node, point) => {
HitTestQuery(node, point, reply_chan) => {
// FIXME: Isolate this transmutation into a single "bridge" module.
let node: AbstractNode<LayoutView> = unsafe {
transmute(node)