Make reflect_dom_object take a &GlobalScope

This commit is contained in:
Anthony Ramine 2016-09-27 13:16:41 +02:00
parent 093b189b48
commit fcb59d3057
132 changed files with 488 additions and 407 deletions

View file

@ -2,7 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::reflector::Reflectable;
use dom::eventtarget::EventTarget;
use js::jsapi::{JS_GetContext, JS_GetObjectRuntime, JSContext};
#[dom_struct]
pub struct GlobalScope {
@ -15,4 +17,16 @@ impl GlobalScope {
eventtarget: EventTarget::new_inherited(),
}
}
#[allow(unsafe_code)]
pub fn get_cx(&self) -> *mut JSContext {
unsafe {
let runtime = JS_GetObjectRuntime(
self.reflector().get_jsobject().get());
assert!(!runtime.is_null());
let context = JS_GetContext(runtime);
assert!(!context.is_null());
context
}
}
}