Remove Traceable/Untraceable from page.rs

This commit is contained in:
Manish Goregaokar 2014-09-29 06:47:45 +05:30
parent 22567762a0
commit 707a2870fa
9 changed files with 95 additions and 76 deletions

View file

@ -67,7 +67,7 @@ impl<'a> GlobalRef<'a> {
pub fn resource_task(&self) -> ResourceTask {
match *self {
Window(ref window) => window.page().resource_task.deref().clone(),
Window(ref window) => window.page().resource_task.clone(),
Worker(ref worker) => worker.resource_task().clone(),
}
}

View file

@ -50,6 +50,8 @@ use http::headers::request::HeaderCollection as RequestHeaderCollection;
use http::method::Method;
use std::io::timer::Timer;
use servo_msg::compositor_msg::ScriptListener;
use servo_msg::constellation_msg::ConstellationChan;
use layout_interface::{LayoutRPC, LayoutChan};
impl<T: Reflectable> JSTraceable for JS<T> {
fn trace(&self, trc: *mut JSTracer) {
@ -165,7 +167,7 @@ impl<T: JSTraceable> JSTraceable for RefCell<T> {
impl<T: JSTraceable> JSTraceable for Rc<T> {
fn trace(&self, trc: *mut JSTracer) {
self.deref().trace(trc)
(**self).trace(trc)
}
}
@ -228,6 +230,16 @@ impl<K: Eq+Hash+JSTraceable, V: JSTraceable> JSTraceable for HashMap<K, V> {
}
}
impl<A: JSTraceable, B: JSTraceable> JSTraceable for (A, B) {
#[inline]
fn trace(&self, trc: *mut JSTracer) {
let (ref a, ref b) = *self;
a.trace(trc);
b.trace(trc);
}
}
untraceable!(bool, f32, f64, String, Url)
untraceable!(uint, u8, u16, u32, u64)
untraceable!(int, i8, i16, i32, i64)
@ -243,6 +255,8 @@ untraceable!(SubpageId, WindowSizeData, PipelineId)
untraceable!(QuirksMode)
untraceable!(Cx)
untraceable!(ResponseHeaderCollection, RequestHeaderCollection, Method)
untraceable!(ConstellationChan)
untraceable!(LayoutChan)
impl<'a> JSTraceable for &'a str {
#[inline]
@ -264,3 +278,10 @@ impl JSTraceable for Box<ScriptListener+'static> {
// Do nothing
}
}
impl JSTraceable for Box<LayoutRPC+'static> {
#[inline]
fn trace(&self, _: *mut JSTracer) {
// Do nothing
}
}

View file

@ -56,7 +56,7 @@ impl BrowserContext {
assert!(handler.deref().is_not_null());
let parent = win.deref().reflector().get_jsobject();
let cx = js_info.as_ref().unwrap().js_context.deref().deref().ptr;
let cx = js_info.as_ref().unwrap().js_context.deref().ptr;
let wrapper = with_compartment(cx, parent, || unsafe {
WrapperNew(cx, parent, *handler.deref())
});

View file

@ -107,7 +107,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
subpage_id: subpage_id,
}));
let ConstellationChan(ref chan) = *page.constellation_chan.deref();
let ConstellationChan(ref chan) = page.constellation_chan;
chan.send(LoadIframeUrlMsg(url, page.id, subpage_id, sandboxed));
}
}
@ -152,12 +152,12 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
fn GetContentWindow(self) -> Option<Temporary<Window>> {
self.size.get().and_then(|size| {
let window = window_from_node(self).root();
let children = window.deref().page.children.deref().borrow();
let children = window.deref().page.children.borrow();
let child = children.iter().find(|child| {
child.subpage_id.unwrap() == size.subpage_id
});
child.and_then(|page| {
page.frame.deref().borrow().as_ref().map(|frame| {
page.frame.borrow().as_ref().map(|frame| {
Temporary::new(frame.window.clone())
})
})

View file

@ -118,7 +118,7 @@ impl<'a> PrivateHTMLLinkElementHelpers for JSRef<'a, HTMLLinkElement> {
let window = window_from_node(self).root();
match UrlParser::new().base_url(&window.deref().page().get_url()).parse(href) {
Ok(url) => {
let LayoutChan(ref layout_chan) = *window.deref().page().layout_chan;
let LayoutChan(ref layout_chan) = window.deref().page().layout_chan;
layout_chan.send(LoadStylesheetMsg(url));
}
Err(e) => debug!("Parsing url {:s} failed: {:?}", href, e)

View file

@ -57,7 +57,7 @@ impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> {
let data = node.GetTextContent().expect("Element.textContent must be a string");
let sheet = Stylesheet::from_str(data.as_slice(), url);
let LayoutChan(ref layout_chan) = *win.deref().page().layout_chan;
let LayoutChan(ref layout_chan) = win.deref().page().layout_chan;
layout_chan.send(AddStylesheetMsg(sheet));
}
}

View file

@ -99,7 +99,7 @@ pub struct Window {
impl Window {
pub fn get_cx(&self) -> *mut JSContext {
let js_info = self.page().js_info();
(**js_info.as_ref().unwrap().js_context).ptr
(*js_info.as_ref().unwrap().js_context).ptr
}
pub fn page<'a>(&'a self) -> &'a Page {