Simplify the implementation of cx_for_dom_reflector.

This commit is contained in:
Ms2ger 2014-07-15 12:20:31 +02:00
parent f963ed99ac
commit 954ab7a2e3

View file

@ -591,12 +591,8 @@ pub fn global_object_for_js_object(obj: *mut JSObject) -> JS<window::Window> {
} }
fn cx_for_dom_reflector(obj: *mut JSObject) -> *mut JSContext { fn cx_for_dom_reflector(obj: *mut JSObject) -> *mut JSContext {
let win = global_object_for_js_object(obj).root(); let global = global_object_for_js_object(obj).root();
let js_info = win.deref().page().js_info(); global.get_cx()
match *js_info {
Some(ref info) => info.js_context.deref().deref().ptr,
None => fail!("no JS context for DOM global")
}
} }
pub fn cx_for_dom_object<T: Reflectable>(obj: &T) -> *mut JSContext { pub fn cx_for_dom_object<T: Reflectable>(obj: &T) -> *mut JSContext {