mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
Rust upgrades
This commit is contained in:
parent
caf1ed9446
commit
bbac8aa5c3
130 changed files with 1236 additions and 985 deletions
|
@ -25,16 +25,16 @@ use js::jsval::JSVal;
|
|||
use js::jsval::{NullValue, ObjectValue};
|
||||
use js::JSPROP_ENUMERATE;
|
||||
|
||||
use collections::hashmap::HashSet;
|
||||
use std::cast;
|
||||
use std::comm::SharedChan;
|
||||
use std::cmp;
|
||||
use std::comm::Chan;
|
||||
use std::comm::Select;
|
||||
use std::hashmap::HashSet;
|
||||
use std::hash::{Hash, sip};
|
||||
use std::io::timer::Timer;
|
||||
use std::num;
|
||||
use std::rc::Rc;
|
||||
use std::to_bytes::Cb;
|
||||
|
||||
use extra::serialize::{Encoder, Encodable};
|
||||
use serialize::{Encoder, Encodable};
|
||||
use extra::url::{Url};
|
||||
|
||||
pub enum TimerControlMsg {
|
||||
|
@ -53,9 +53,9 @@ impl<S: Encoder> Encodable<S> for TimerHandle {
|
|||
}
|
||||
}
|
||||
|
||||
impl IterBytes for TimerHandle {
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
self.handle.iter_bytes(lsb0, f)
|
||||
impl Hash for TimerHandle {
|
||||
fn hash(&self, state: &mut sip::SipState) {
|
||||
self.handle.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ pub struct Window {
|
|||
struct Untraceable {
|
||||
page: Rc<Page>,
|
||||
compositor: ~ScriptListener,
|
||||
timer_chan: SharedChan<TimerControlMsg>,
|
||||
timer_chan: Chan<TimerControlMsg>,
|
||||
}
|
||||
|
||||
impl<S: Encoder> Encodable<S> for Untraceable {
|
||||
|
@ -134,7 +134,7 @@ pub struct TimerData {
|
|||
impl Window {
|
||||
pub fn Alert(&self, s: DOMString) {
|
||||
// Right now, just print to the console
|
||||
println(format!("ALERT: {:s}", s));
|
||||
println!("ALERT: {:s}", s);
|
||||
}
|
||||
|
||||
pub fn Close(&self) {
|
||||
|
@ -226,7 +226,7 @@ impl Reflectable for Window {
|
|||
|
||||
impl Window {
|
||||
pub fn SetTimeout(&mut self, _cx: *JSContext, callback: JSVal, timeout: i32) -> i32 {
|
||||
let timeout = num::max(0, timeout) as u64;
|
||||
let timeout = cmp::max(0, timeout) as u64;
|
||||
let handle = self.next_timer_handle;
|
||||
self.next_timer_handle += 1;
|
||||
|
||||
|
@ -241,10 +241,12 @@ impl Window {
|
|||
let mut cancel_port = cancel_port;
|
||||
|
||||
let select = Select::new();
|
||||
let timeout_handle = select.add(&mut timeout_port);
|
||||
let _cancel_handle = select.add(&mut cancel_port);
|
||||
let mut timeout_handle = select.handle(&timeout_port);
|
||||
unsafe { timeout_handle.add() };
|
||||
let mut _cancel_handle = select.handle(&cancel_port);
|
||||
unsafe { _cancel_handle.add() };
|
||||
let id = select.wait();
|
||||
if id == timeout_handle.id {
|
||||
if id == timeout_handle.id() {
|
||||
chan.send(TimerMessage_Fire(~TimerData {
|
||||
handle: handle,
|
||||
funval: callback,
|
||||
|
@ -290,9 +292,10 @@ impl Window {
|
|||
compositor: compositor,
|
||||
page: page.clone(),
|
||||
timer_chan: {
|
||||
let (timer_port, timer_chan): (Port<TimerControlMsg>, SharedChan<TimerControlMsg>) = SharedChan::new();
|
||||
let (timer_port, timer_chan): (Port<TimerControlMsg>, Chan<TimerControlMsg>) = Chan::new();
|
||||
let id = page.borrow().id.clone();
|
||||
spawn_named("timer controller", proc() {
|
||||
let ScriptChan(script_chan) = script_chan;
|
||||
loop {
|
||||
match timer_port.recv() {
|
||||
TimerMessage_Close => break,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue