mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Move DOM window to own file
This commit is contained in:
parent
76a43555ac
commit
789398ddc2
5 changed files with 39 additions and 35 deletions
|
@ -12,8 +12,9 @@ use comm::{Port, Chan, listen, select2};
|
|||
use task::{spawn, spawn_listener};
|
||||
use io::{read_whole_file, println};
|
||||
|
||||
use dom::base::{Document, Node, NodeScope, Window, define_bindings};
|
||||
use dom::base::{Document, Node, NodeScope, define_bindings};
|
||||
use dom::event::{Event, ResizeEvent, ReflowEvent};
|
||||
use dom::window::Window;
|
||||
use gfx::compositor::Compositor;
|
||||
use html::lexer::spawn_html_lexer_task;
|
||||
use layout::layout_task;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/* The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements. */
|
||||
use comm::{Port, Chan};
|
||||
use content::content_task::{ControlMsg, Timer};
|
||||
use css::styles::SpecifiedStyle;
|
||||
use css::values::Stylesheet;
|
||||
use dom::element::{Attr, ElementData};
|
||||
use dom::window::Window;
|
||||
use dom::bindings;
|
||||
use geom::size::Size2D;
|
||||
use gfx::geometry::au;
|
||||
|
@ -18,36 +17,6 @@ use ptr::null;
|
|||
use std::arc::ARC;
|
||||
use util::tree;
|
||||
|
||||
enum TimerControlMsg {
|
||||
Fire(~dom::bindings::window::TimerData),
|
||||
Close
|
||||
}
|
||||
|
||||
struct Window {
|
||||
timer_chan: Chan<TimerControlMsg>,
|
||||
|
||||
drop {
|
||||
self.timer_chan.send(Close);
|
||||
}
|
||||
}
|
||||
|
||||
fn Window(content_port: Port<ControlMsg>) -> Window {
|
||||
let content_chan = Chan(content_port);
|
||||
|
||||
Window {
|
||||
timer_chan: do task::spawn_listener |timer_port: Port<TimerControlMsg>| {
|
||||
loop {
|
||||
match timer_port.recv() {
|
||||
Close => break,
|
||||
Fire(td) => {
|
||||
content_chan.send(Timer(copy td));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Document {
|
||||
root: Node,
|
||||
scope: NodeScope,
|
||||
|
|
|
@ -13,7 +13,8 @@ use ptr::null;
|
|||
use libc::c_uint;
|
||||
use utils::{rust_box, squirrel_away, jsval_to_str};
|
||||
use bindings::node::create;
|
||||
use dom::base::{Node, Window};
|
||||
use dom::window::{Window, TimerMessage_Fire};
|
||||
use dom::base::Node;
|
||||
use dvec::DVec;
|
||||
|
||||
extern fn alert(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool {
|
||||
|
@ -64,7 +65,7 @@ extern fn setTimeout(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool unsafe
|
|||
std::timer::delayed_send(std::uv_global_loop::get(),
|
||||
RUST_JSVAL_TO_INT(*ptr::offset(argv, 1)) as uint,
|
||||
(*unwrap(JS_THIS_OBJECT(cx, vp))).payload.timer_chan,
|
||||
base::Fire(~TimerData(argc, argv)));
|
||||
TimerMessage_Fire(~TimerData(argc, argv)));
|
||||
|
||||
JS_SET_RVAL(cx, vp, JSVAL_NULL);
|
||||
return 1;
|
||||
|
|
32
src/servo/dom/window.rs
Normal file
32
src/servo/dom/window.rs
Normal file
|
@ -0,0 +1,32 @@
|
|||
use comm::{Port, Chan};
|
||||
use content::content_task::{ControlMsg, Timer};
|
||||
|
||||
enum TimerControlMsg {
|
||||
TimerMessage_Fire(~dom::bindings::window::TimerData),
|
||||
TimerMessage_Close
|
||||
}
|
||||
|
||||
struct Window {
|
||||
timer_chan: Chan<TimerControlMsg>,
|
||||
|
||||
drop {
|
||||
self.timer_chan.send(TimerMessage_Close);
|
||||
}
|
||||
}
|
||||
|
||||
fn Window(content_port: Port<ControlMsg>) -> Window {
|
||||
let content_chan = Chan(content_port);
|
||||
|
||||
Window {
|
||||
timer_chan: do task::spawn_listener |timer_port: Port<TimerControlMsg>| {
|
||||
loop {
|
||||
match timer_port.recv() {
|
||||
TimerMessage_Close => break,
|
||||
TimerMessage_Fire(td) => {
|
||||
content_chan.send(Timer(copy td));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,6 +34,7 @@ mod dom {
|
|||
mod element;
|
||||
mod event;
|
||||
mod rcu;
|
||||
mod window;
|
||||
}
|
||||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue