зеркало из https://github.com/mozilla/gecko-dev.git
servo: Add a content task to drive the layout task
Source-Repo: https://github.com/servo/servo Source-Revision: 7ec7daf5859c5c9c14faadb4013d8578fa56c58b
This commit is contained in:
Родитель
518bbceb78
Коммит
79d825b491
|
@ -0,0 +1,46 @@
|
|||
export msg;
|
||||
export content;
|
||||
|
||||
import gfx::geom::*;
|
||||
import dom::rcu::*;
|
||||
import dom::base::*;
|
||||
import layout::base::tree; // method implementations of tree for box and node
|
||||
|
||||
enum msg {
|
||||
exit
|
||||
}
|
||||
|
||||
fn content(layout: chan<layout::layout::msg>) -> chan<msg> {
|
||||
|
||||
task::spawn_listener::<msg> {|po|
|
||||
let s = scope();
|
||||
let n0 = s.new_node(nk_img(size(int_to_au(10),int_to_au(10))));
|
||||
let n1 = s.new_node(nk_img(size(int_to_au(10),int_to_au(15))));
|
||||
let n2 = s.new_node(nk_img(size(int_to_au(10),int_to_au(20))));
|
||||
let n3 = s.new_node(nk_div);
|
||||
|
||||
tree::add_child(n3, n0);
|
||||
tree::add_child(n3, n1);
|
||||
tree::add_child(n3, n2);
|
||||
|
||||
let b0 = layout::base::linked_box(n0);
|
||||
let b1 = layout::base::linked_box(n1);
|
||||
let b2 = layout::base::linked_box(n2);
|
||||
let b3 = layout::base::linked_box(n3);
|
||||
|
||||
tree::add_child(b3, b0);
|
||||
tree::add_child(b3, b1);
|
||||
tree::add_child(b3, b2);
|
||||
|
||||
// TODO: RCU this stuff over to layout
|
||||
loop {
|
||||
if po.peek() {
|
||||
break;
|
||||
} else {
|
||||
#debug("content: requesting layout");
|
||||
layout.send(layout::layout::build);
|
||||
std::timer::sleep(100u);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,3 +46,4 @@ mod util {
|
|||
mod tree;
|
||||
}
|
||||
|
||||
mod content;
|
||||
|
|
|
@ -33,24 +33,20 @@ fn main(args: [str]) {
|
|||
// The layout task
|
||||
let layout = layout::layout::layout(renderer);
|
||||
|
||||
// The content task
|
||||
let content = content::content(layout);
|
||||
|
||||
// The keyboard handler
|
||||
let key_po = port();
|
||||
send(osmain, platform::osmain::add_key_handler(chan(key_po)));
|
||||
|
||||
loop {
|
||||
send(layout, layout::layout::build);
|
||||
key_po.recv();
|
||||
comm::send(content, content::exit);
|
||||
comm::send(layout, layout::layout::exit);
|
||||
|
||||
std::timer::sleep(200u);
|
||||
let draw_exit_confirm_po = comm::port();
|
||||
comm::send(renderer, gfx::renderer::exit(comm::chan(draw_exit_confirm_po)));
|
||||
|
||||
if peek(key_po) {
|
||||
comm::send(layout, layout::layout::exit);
|
||||
|
||||
let draw_exit_confirm_po = comm::port();
|
||||
comm::send(renderer, gfx::renderer::exit(comm::chan(draw_exit_confirm_po)));
|
||||
|
||||
comm::recv(draw_exit_confirm_po);
|
||||
comm::send(osmain, platform::osmain::exit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
comm::recv(draw_exit_confirm_po);
|
||||
comm::send(osmain, platform::osmain::exit);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче