mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Add lots of logging to content and layout messages
This commit is contained in:
parent
147cd4589b
commit
ad937a6167
3 changed files with 45 additions and 13 deletions
|
@ -8,6 +8,7 @@ export ControlMsg, ExecuteMsg, ParseMsg, ExitMsg, Timer;
|
|||
export PingMsg, PongMsg;
|
||||
export task_from_context;
|
||||
|
||||
use core::util::replace;
|
||||
use std::arc::{ARC, clone};
|
||||
use comm::{Port, Chan, listen, select2};
|
||||
use task::{spawn, spawn_listener};
|
||||
|
@ -74,6 +75,8 @@ fn ContentTask<S: Compositor Send Copy>(layout_task: LayoutTask,
|
|||
|
||||
struct Content {
|
||||
layout_task: LayoutTask,
|
||||
mut layout_join_port: Option<pipes::Port<()>>,
|
||||
|
||||
image_cache_task: ImageCacheTask,
|
||||
from_master: comm::Port<ControlMsg>,
|
||||
event_port: comm::Port<Event>,
|
||||
|
@ -111,6 +114,7 @@ fn Content(layout_task: LayoutTask,
|
|||
|
||||
let content = @Content {
|
||||
layout_task : layout_task,
|
||||
layout_join_port : None,
|
||||
image_cache_task : img_cache_task,
|
||||
from_master : from_master,
|
||||
event_port : event_port,
|
||||
|
@ -239,11 +243,23 @@ impl Content {
|
|||
pending layout request messages).
|
||||
*/
|
||||
fn join_layout() {
|
||||
assert self.scope.is_reader_forked() == self.layout_join_port.is_some();
|
||||
|
||||
if self.scope.is_reader_forked() {
|
||||
listen(|response_from_layout| {
|
||||
self.layout_task.send(layout_task::PingMsg(response_from_layout));
|
||||
response_from_layout.recv();
|
||||
});
|
||||
|
||||
let join_port = replace(&mut self.layout_join_port, None);
|
||||
|
||||
match join_port {
|
||||
Some(ref join_port) => {
|
||||
if !join_port.peek() {
|
||||
warn!("content: waiting on layout");
|
||||
}
|
||||
join_port.recv();
|
||||
debug!("content: layout joined");
|
||||
}
|
||||
None => fail ~"reader forked but no join port?"
|
||||
}
|
||||
|
||||
self.scope.reader_joined();
|
||||
}
|
||||
}
|
||||
|
@ -260,14 +276,20 @@ impl Content {
|
|||
// changes we have made.
|
||||
self.join_layout();
|
||||
|
||||
// Layout will let us know when it's done
|
||||
let (join_chan, join_port) = pipes::stream();
|
||||
self.layout_join_port = move Some(join_port);
|
||||
|
||||
// Send new document and relevant styles to layout
|
||||
// FIXME: Put CSS rules in an arc or something.
|
||||
self.layout_task.send(BuildMsg(document.root, clone(&document.css_rules), copy *doc_url,
|
||||
self.event_port.chan(), self.window_size));
|
||||
self.event_port.chan(), self.window_size, join_chan));
|
||||
|
||||
// Indicate that reader was forked so any further
|
||||
// changes will be isolated.
|
||||
self.scope.reader_forked();
|
||||
|
||||
debug!("content: layout forked");
|
||||
}
|
||||
|
||||
fn query_layout(query: layout_task::LayoutQuery) -> layout_task::LayoutQueryResponse {
|
||||
|
|
|
@ -66,7 +66,13 @@ pub fn RenderTask<C: Compositor Send>(compositor: C) -> RenderTask {
|
|||
loop {
|
||||
match po.recv() {
|
||||
RenderMsg(move render_layer) => {
|
||||
#debug("renderer: got render request");
|
||||
debug!("renderer: got render request");
|
||||
|
||||
if !layer_buffer_port.peek() {
|
||||
warn!("renderer: no layer buffer. skipping frame");
|
||||
loop;
|
||||
}
|
||||
|
||||
let layer_buffer_cell = Cell(layer_buffer_port.recv());
|
||||
|
||||
let (layer_buffer_channel, new_layer_buffer_port) = pipes::stream();
|
||||
|
|
|
@ -27,6 +27,7 @@ use resource::local_image_cache::LocalImageCache;
|
|||
use servo_text::font_cache::FontCache;
|
||||
use std::arc::ARC;
|
||||
use std::net::url::Url;
|
||||
use core::util::replace;
|
||||
|
||||
use layout::traverse::*;
|
||||
use comm::*;
|
||||
|
@ -45,8 +46,7 @@ enum LayoutQueryResponse_ {
|
|||
}
|
||||
|
||||
pub enum Msg {
|
||||
BuildMsg(Node, ARC<Stylesheet>, Url, comm::Chan<Event>, Size2D<uint>),
|
||||
PingMsg(comm::Chan<content_task::PingMsg>),
|
||||
BuildMsg(Node, ARC<Stylesheet>, Url, comm::Chan<Event>, Size2D<uint>, pipes::Chan<()>),
|
||||
QueryMsg(LayoutQuery, comm::Chan<LayoutQueryResponse>),
|
||||
ExitMsg
|
||||
}
|
||||
|
@ -118,20 +118,20 @@ impl Layout {
|
|||
}
|
||||
|
||||
fn start() {
|
||||
while self.handle_request(self.from_content) {
|
||||
while self.handle_request() {
|
||||
// loop indefinitely
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_request(request: comm::Port<Msg>) -> bool {
|
||||
match request.recv() {
|
||||
PingMsg(ping_channel) => ping_channel.send(content_task::PongMsg),
|
||||
fn handle_request() -> bool {
|
||||
|
||||
match self.from_content.recv() {
|
||||
QueryMsg(query, chan) => self.handle_query(query, chan),
|
||||
ExitMsg => {
|
||||
debug!("layout: ExitMsg received");
|
||||
return false
|
||||
},
|
||||
BuildMsg(node, styles, doc_url, to_content, window_size) => {
|
||||
BuildMsg(node, styles, doc_url, to_content, window_size, join_chan) => {
|
||||
debug!("layout: received layout request for: %s", doc_url.to_str());
|
||||
debug!("layout: parsed Node tree");
|
||||
debug!("%?", node.dump());
|
||||
|
@ -193,6 +193,10 @@ impl Layout {
|
|||
&render_layer.display_list);
|
||||
self.render_task.send(render_task::RenderMsg(move render_layer));
|
||||
} // time(layout: display list building)
|
||||
|
||||
// Tell content we're done
|
||||
join_chan.send(());
|
||||
|
||||
} // BuildMsg
|
||||
} // match
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue