mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Make reflect_dom_object take a &GlobalScope
This commit is contained in:
parent
093b189b48
commit
fcb59d3057
132 changed files with 488 additions and 407 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue