mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
trace window.location and window.navigator
This commit is contained in:
parent
ccc7fa7be0
commit
f9433e357c
2 changed files with 26 additions and 20 deletions
|
@ -29,7 +29,7 @@ use js::jsapi::{JS_ValueToString, JS_GetReservedSlot, JS_SetReservedSlot};
|
|||
use js::jsapi::{JSContext, JSObject, JSBool, jsid, JSClass, JSNative, JSTracer};
|
||||
use js::jsapi::{JSFunctionSpec, JSPropertySpec, JSVal, JSPropertyDescriptor};
|
||||
use js::jsapi::{JSPropertyOp, JSStrictPropertyOp, JS_NewGlobalObject, JS_InitStandardClasses};
|
||||
use js::jsapi::{JSString};
|
||||
use js::jsapi::{JSString, JS_CallTracer, JSTRACE_OBJECT};
|
||||
use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType;
|
||||
use js::{JSPROP_ENUMERATE, JSVAL_NULL, JSCLASS_IS_GLOBAL, JSCLASS_IS_DOMJSCLASS};
|
||||
use js::{JSPROP_PERMANENT, JSID_VOID, JSPROP_NATIVE_ACCESSORS, JSPROP_GETTER};
|
||||
|
@ -588,6 +588,24 @@ pub trait Traceable {
|
|||
fn trace(&self, trc: *mut JSTracer);
|
||||
}
|
||||
|
||||
#[fixed_stack_segment]
|
||||
pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) {
|
||||
unsafe {
|
||||
do description.to_c_str().with_ref |name| {
|
||||
(*tracer).debugPrinter = ptr::null();
|
||||
(*tracer).debugPrintIndex = -1;
|
||||
(*tracer).debugPrintArg = name as *libc::c_void;
|
||||
debug!("tracing {:s}", description);
|
||||
JS_CallTracer(tracer as *JSTracer, reflector.get_jsobject(),
|
||||
JSTRACE_OBJECT as u32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn trace_option<T: Reflectable>(tracer: *mut JSTracer, description: &str, option: Option<@mut T>) {
|
||||
option.map(|some| trace_reflector(tracer, description, some.reflector()));
|
||||
}
|
||||
|
||||
#[fixed_stack_segment]
|
||||
pub fn initialize_global(global: *JSObject) {
|
||||
let protoArray = @mut ([0 as *JSObject, ..PrototypeList::id::_ID_Count as uint]);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
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};
|
||||
|
@ -17,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;
|
||||
|
@ -251,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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue