mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Remove Traceable/Untraceable from window.rs
This commit is contained in:
parent
a8f96ddfb2
commit
22567762a0
4 changed files with 30 additions and 23 deletions
|
@ -49,6 +49,7 @@ use http::headers::response::HeaderCollection as ResponseHeaderCollection;
|
||||||
use http::headers::request::HeaderCollection as RequestHeaderCollection;
|
use http::headers::request::HeaderCollection as RequestHeaderCollection;
|
||||||
use http::method::Method;
|
use http::method::Method;
|
||||||
use std::io::timer::Timer;
|
use std::io::timer::Timer;
|
||||||
|
use servo_msg::compositor_msg::ScriptListener;
|
||||||
|
|
||||||
impl<T: Reflectable> JSTraceable for JS<T> {
|
impl<T: Reflectable> JSTraceable for JS<T> {
|
||||||
fn trace(&self, trc: *mut JSTracer) {
|
fn trace(&self, trc: *mut JSTracer) {
|
||||||
|
@ -256,3 +257,10 @@ impl<A,B> JSTraceable for fn(A) -> B {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl JSTraceable for Box<ScriptListener+'static> {
|
||||||
|
#[inline]
|
||||||
|
fn trace(&self, _: *mut JSTracer) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -659,7 +659,7 @@ pub extern fn outerize_global(_cx: *mut JSContext, obj: JSHandleObject) -> *mut
|
||||||
IDLInterface::get_prototype_depth(None::<window::Window>))
|
IDLInterface::get_prototype_depth(None::<window::Window>))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.root();
|
.root();
|
||||||
win.deref().browser_context.deref().borrow().as_ref().unwrap().window_proxy()
|
win.deref().browser_context.borrow().as_ref().unwrap().window_proxy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ use dom::bindings::codegen::InheritTypes::EventTargetCast;
|
||||||
use dom::bindings::error::{Fallible, InvalidCharacter};
|
use dom::bindings::error::{Fallible, InvalidCharacter};
|
||||||
use dom::bindings::global;
|
use dom::bindings::global;
|
||||||
use dom::bindings::js::{MutNullableJS, JSRef, Temporary, OptionalSettable};
|
use dom::bindings::js::{MutNullableJS, JSRef, Temporary, OptionalSettable};
|
||||||
use dom::bindings::trace::{Traceable, Untraceable};
|
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
use dom::browsercontext::BrowserContext;
|
use dom::browsercontext::BrowserContext;
|
||||||
use dom::console::Console;
|
use dom::console::Console;
|
||||||
|
@ -60,7 +59,7 @@ pub struct TimerId(i32);
|
||||||
pub struct TimerHandle {
|
pub struct TimerHandle {
|
||||||
handle: TimerId,
|
handle: TimerId,
|
||||||
pub data: TimerData,
|
pub data: TimerData,
|
||||||
cancel_chan: Untraceable<Option<Sender<()>>>,
|
cancel_chan: Option<Sender<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Hash for TimerId {
|
impl Hash for TimerId {
|
||||||
|
@ -86,10 +85,10 @@ pub struct Window {
|
||||||
location: MutNullableJS<Location>,
|
location: MutNullableJS<Location>,
|
||||||
navigator: MutNullableJS<Navigator>,
|
navigator: MutNullableJS<Navigator>,
|
||||||
pub image_cache_task: ImageCacheTask,
|
pub image_cache_task: ImageCacheTask,
|
||||||
pub active_timers: Traceable<RefCell<HashMap<TimerId, TimerHandle>>>,
|
pub active_timers: RefCell<HashMap<TimerId, TimerHandle>>,
|
||||||
next_timer_handle: Traceable<Cell<i32>>,
|
next_timer_handle: Cell<i32>,
|
||||||
pub compositor: Untraceable<Box<ScriptListener+'static>>,
|
pub compositor: Box<ScriptListener+'static>,
|
||||||
pub browser_context: Traceable<RefCell<Option<BrowserContext>>>,
|
pub browser_context: RefCell<Option<BrowserContext>>,
|
||||||
pub page: Rc<Page>,
|
pub page: Rc<Page>,
|
||||||
performance: MutNullableJS<Performance>,
|
performance: MutNullableJS<Performance>,
|
||||||
pub navigationStart: u64,
|
pub navigationStart: u64,
|
||||||
|
@ -126,7 +125,7 @@ impl Drop for Window {
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
pub struct TimerData {
|
pub struct TimerData {
|
||||||
pub is_interval: bool,
|
pub is_interval: bool,
|
||||||
pub funval: Traceable<JSVal>,
|
pub funval: JSVal,
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://www.whatwg.org/html/#atob
|
// http://www.whatwg.org/html/#atob
|
||||||
|
@ -250,7 +249,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ClearTimeout(self, handle: i32) {
|
fn ClearTimeout(self, handle: i32) {
|
||||||
let mut timers = self.active_timers.deref().borrow_mut();
|
let mut timers = self.active_timers.borrow_mut();
|
||||||
let mut timer_handle = timers.pop(&TimerId(handle));
|
let mut timer_handle = timers.pop(&TimerId(handle));
|
||||||
match timer_handle {
|
match timer_handle {
|
||||||
Some(ref mut handle) => handle.cancel(),
|
Some(ref mut handle) => handle.cancel(),
|
||||||
|
@ -416,7 +415,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_browser_context(self, doc: JSRef<Document>) {
|
fn init_browser_context(self, doc: JSRef<Document>) {
|
||||||
*self.browser_context.deref().borrow_mut() = Some(BrowserContext::new(doc));
|
*self.browser_context.borrow_mut() = Some(BrowserContext::new(doc));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Commence a new URL load which will either replace this window or scroll to a fragment.
|
/// Commence a new URL load which will either replace this window or scroll to a fragment.
|
||||||
|
@ -437,7 +436,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
||||||
fn handle_fire_timer(self, timer_id: TimerId, cx: *mut JSContext) {
|
fn handle_fire_timer(self, timer_id: TimerId, cx: *mut JSContext) {
|
||||||
let this_value = self.reflector().get_jsobject();
|
let this_value = self.reflector().get_jsobject();
|
||||||
|
|
||||||
let data = match self.active_timers.deref().borrow().find(&timer_id) {
|
let data = match self.active_timers.borrow().find(&timer_id) {
|
||||||
None => return,
|
None => return,
|
||||||
Some(timer_handle) => timer_handle.data,
|
Some(timer_handle) => timer_handle.data,
|
||||||
};
|
};
|
||||||
|
@ -446,13 +445,13 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
||||||
with_compartment(cx, this_value, || {
|
with_compartment(cx, this_value, || {
|
||||||
let mut rval = NullValue();
|
let mut rval = NullValue();
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_CallFunctionValue(cx, this_value, *data.funval,
|
JS_CallFunctionValue(cx, this_value, data.funval,
|
||||||
0, ptr::null_mut(), &mut rval);
|
0, ptr::null_mut(), &mut rval);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if !data.is_interval {
|
if !data.is_interval {
|
||||||
self.active_timers.deref().borrow_mut().remove(&timer_id);
|
self.active_timers.borrow_mut().remove(&timer_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -460,8 +459,8 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
||||||
impl<'a> PrivateWindowHelpers for JSRef<'a, Window> {
|
impl<'a> PrivateWindowHelpers for JSRef<'a, Window> {
|
||||||
fn set_timeout_or_interval(self, callback: JSVal, timeout: i32, is_interval: bool) -> i32 {
|
fn set_timeout_or_interval(self, callback: JSVal, timeout: i32, is_interval: bool) -> i32 {
|
||||||
let timeout = cmp::max(0, timeout) as u64;
|
let timeout = cmp::max(0, timeout) as u64;
|
||||||
let handle = self.next_timer_handle.deref().get();
|
let handle = self.next_timer_handle.get();
|
||||||
self.next_timer_handle.deref().set(handle + 1);
|
self.next_timer_handle.set(handle + 1);
|
||||||
|
|
||||||
// Post a delayed message to the per-window timer task; it will dispatch it
|
// Post a delayed message to the per-window timer task; it will dispatch it
|
||||||
// to the relevant script handler that will deal with it.
|
// to the relevant script handler that will deal with it.
|
||||||
|
@ -507,13 +506,13 @@ impl<'a> PrivateWindowHelpers for JSRef<'a, Window> {
|
||||||
let timer_id = TimerId(handle);
|
let timer_id = TimerId(handle);
|
||||||
let timer = TimerHandle {
|
let timer = TimerHandle {
|
||||||
handle: timer_id,
|
handle: timer_id,
|
||||||
cancel_chan: Untraceable::new(Some(cancel_chan)),
|
cancel_chan: Some(cancel_chan),
|
||||||
data: TimerData {
|
data: TimerData {
|
||||||
is_interval: is_interval,
|
is_interval: is_interval,
|
||||||
funval: Traceable::new(callback),
|
funval: callback,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.active_timers.deref().borrow_mut().insert(timer_id, timer);
|
self.active_timers.borrow_mut().insert(timer_id, timer);
|
||||||
handle
|
handle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -531,14 +530,14 @@ impl Window {
|
||||||
script_chan: script_chan,
|
script_chan: script_chan,
|
||||||
control_chan: control_chan,
|
control_chan: control_chan,
|
||||||
console: Default::default(),
|
console: Default::default(),
|
||||||
compositor: Untraceable::new(compositor),
|
compositor: compositor,
|
||||||
page: page,
|
page: page,
|
||||||
location: Default::default(),
|
location: Default::default(),
|
||||||
navigator: Default::default(),
|
navigator: Default::default(),
|
||||||
image_cache_task: image_cache_task,
|
image_cache_task: image_cache_task,
|
||||||
active_timers: Traceable::new(RefCell::new(HashMap::new())),
|
active_timers: RefCell::new(HashMap::new()),
|
||||||
next_timer_handle: Traceable::new(Cell::new(0)),
|
next_timer_handle: Cell::new(0),
|
||||||
browser_context: Traceable::new(RefCell::new(None)),
|
browser_context: RefCell::new(None),
|
||||||
performance: Default::default(),
|
performance: Default::default(),
|
||||||
navigationStart: time::get_time().sec as u64,
|
navigationStart: time::get_time().sec as u64,
|
||||||
navigationStartPrecise: time::precise_time_s(),
|
navigationStartPrecise: time::precise_time_s(),
|
||||||
|
|
|
@ -165,7 +165,7 @@ impl Page {
|
||||||
if damaged {
|
if damaged {
|
||||||
let frame = self.frame();
|
let frame = self.frame();
|
||||||
let window = frame.as_ref().unwrap().window.root();
|
let window = frame.as_ref().unwrap().window.root();
|
||||||
self.reflow(goal, window.control_chan.clone(), &**window.compositor);
|
self.reflow(goal, window.control_chan.clone(), &*window.compositor);
|
||||||
} else {
|
} else {
|
||||||
self.avoided_reflows.set(self.avoided_reflows.get() + 1);
|
self.avoided_reflows.set(self.avoided_reflows.get() + 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue