зеркало из https://github.com/mozilla/gecko-dev.git
servo: Structure layout task a little more
Source-Repo: https://github.com/servo/servo Source-Revision: 35e24aafcafb3a1231f75209adb153bc314766e3
This commit is contained in:
Родитель
3caed99a10
Коммит
03c8a2bcd7
|
@ -6,10 +6,11 @@ Builds display lists on request and passes them to the renderer
|
|||
|
||||
import task::*;
|
||||
import comm::*;
|
||||
import display_list::*;
|
||||
import gfx::geom;
|
||||
import gfx::geom::*;
|
||||
import gfx::renderer;
|
||||
import dom::base::*;
|
||||
import display_list::*;
|
||||
|
||||
enum msg {
|
||||
build,
|
||||
|
@ -19,47 +20,17 @@ enum msg {
|
|||
fn layout(renderer: chan<renderer::msg>) -> chan<msg> {
|
||||
|
||||
spawn_listener::<msg> {|po|
|
||||
let mut x1 = 100;
|
||||
let mut y1 = 100;
|
||||
let mut w1 = 200;
|
||||
let mut h1 = 200;
|
||||
let mut x2 = 200;
|
||||
let mut y2 = 200;
|
||||
let mut w2 = 300;
|
||||
let mut h2 = 300;
|
||||
|
||||
let dom = new_node(nk_div);
|
||||
|
||||
loop {
|
||||
alt recv(po) {
|
||||
build {
|
||||
let dlist = [
|
||||
display_item({
|
||||
item_type: solid_color,
|
||||
bounds: geom::box(
|
||||
int_to_au(x1),
|
||||
int_to_au(y1),
|
||||
int_to_au(w1),
|
||||
int_to_au(h1))
|
||||
}),
|
||||
display_item({
|
||||
item_type: solid_color,
|
||||
bounds: geom::box(
|
||||
int_to_au(x2),
|
||||
int_to_au(y2),
|
||||
int_to_au(w2),
|
||||
int_to_au(h2))
|
||||
})
|
||||
];
|
||||
|
||||
let box = layout_dom(dom);
|
||||
let dlist = build_display_list(box);
|
||||
|
||||
send(renderer, gfx::renderer::draw(dlist));
|
||||
|
||||
x1 += 1;
|
||||
y1 += 1;
|
||||
x2 -= 1;
|
||||
y2 -= 1;
|
||||
if x1 > 800 { x1 = 0 }
|
||||
if y1 > 600 { y1 = 0 }
|
||||
if x2 < 0 { x2 = 800 }
|
||||
if y2 < 0 { y2 = 600 }
|
||||
}
|
||||
exit {
|
||||
break;
|
||||
|
@ -69,3 +40,28 @@ fn layout(renderer: chan<renderer::msg>) -> chan<msg> {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
fn layout_dom(dom: node) -> base::box {
|
||||
base::new_box(dom)
|
||||
}
|
||||
|
||||
fn build_display_list(_box: base::box) -> display_list::display_list {
|
||||
[
|
||||
display_item({
|
||||
item_type: solid_color,
|
||||
bounds: geom::box(
|
||||
int_to_au(0),
|
||||
int_to_au(0),
|
||||
int_to_au(100),
|
||||
int_to_au(100))
|
||||
}),
|
||||
display_item({
|
||||
item_type: solid_color,
|
||||
bounds: geom::box(
|
||||
int_to_au(100),
|
||||
int_to_au(100),
|
||||
int_to_au(100),
|
||||
int_to_au(100))
|
||||
})
|
||||
]
|
||||
}
|
Загрузка…
Ссылка в новой задаче