aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/window.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/script/dom/window.rs')
-rw-r--r--src/components/script/dom/window.rs36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/components/script/dom/window.rs b/src/components/script/dom/window.rs
index 7303d5d81f0..4814550e42f 100644
--- a/src/components/script/dom/window.rs
+++ b/src/components/script/dom/window.rs
@@ -4,10 +4,12 @@
use dom::bindings::codegen::WindowBinding;
use dom::bindings::utils::{Reflectable, Reflector, Traceable};
+use dom::bindings::utils::{trace_option, trace_reflector};
use dom::bindings::utils::DOMString;
use dom::document::AbstractDocument;
use dom::eventtarget::{EventTarget, WindowTypeId};
use dom::node::{AbstractNode, ScriptView};
+use dom::location::Location;
use dom::navigator::Navigator;
use layout_interface::ReflowForDisplay;
@@ -16,8 +18,8 @@ use servo_msg::compositor_msg::ScriptListener;
use servo_net::image_cache_task::ImageCacheTask;
use js::glue::*;
-use js::jsapi::{JSObject, JSContext, JS_DefineProperty, JS_CallTracer};
-use js::jsapi::{JSPropertyOp, JSStrictPropertyOp, JSTracer, JSTRACE_OBJECT};
+use js::jsapi::{JSObject, JSContext, JS_DefineProperty};
+use js::jsapi::{JSPropertyOp, JSStrictPropertyOp, JSTracer};
use js::{JSVAL_NULL, JSPROP_ENUMERATE};
use std::cell::Cell;
@@ -43,6 +45,7 @@ pub struct Window {
script_chan: ScriptChan,
compositor: @ScriptListener,
timer_chan: SharedChan<TimerControlMsg>,
+ location: Option<@mut Location>,
navigator: Option<@mut Navigator>,
image_cache_task: ImageCacheTask,
active_timers: ~HashSet<i32>,
@@ -116,6 +119,13 @@ impl Window {
None
}
+ pub fn Location(&mut self) -> @mut Location {
+ if self.location.is_none() {
+ self.location = Some(Location::new(self, self.page));
+ }
+ self.location.unwrap()
+ }
+
pub fn Navigator(&mut self) -> @mut Navigator {
if self.navigator.is_none() {
self.navigator = Some(Navigator::new(self));
@@ -215,6 +225,7 @@ impl Window {
}
SharedChan::new(timer_chan)
},
+ location: None,
navigator: None,
image_cache_task: image_cache_task,
active_timers: ~HashSet::new(),
@@ -241,24 +252,11 @@ impl Window {
}
impl Traceable for Window {
- #[fixed_stack_segment]
fn trace(&self, tracer: *mut JSTracer) {
debug!("tracing window");
- unsafe {
- match self.page.frame {
- Some(frame) => {
- (*tracer).debugPrinter = ptr::null();
- (*tracer).debugPrintIndex = -1;
- do "document".to_c_str().with_ref |name| {
- (*tracer).debugPrintArg = name as *libc::c_void;
- debug!("tracing document");
- JS_CallTracer(tracer as *JSTracer,
- frame.document.reflector().get_jsobject(),
- JSTRACE_OBJECT as u32);
- }
- }
- None => ()
- }
- }
+
+ self.page.frame.map(|frame| trace_reflector(tracer, "document", frame.document.reflector()));
+ trace_option(tracer, "location", self.location);
+ trace_option(tracer, "navigator", self.navigator);
}
}