mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Wrap(Global)Method now takes a SafeJSContext instead of a JSContext
as first argument.
This commit is contained in:
parent
cd0eb88a3e
commit
35dc5320ab
10 changed files with 55 additions and 37 deletions
|
@ -7,7 +7,8 @@
|
|||
use crate::dom::bindings::conversions::DerivedFrom;
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{Heap, JSContext, JSObject};
|
||||
use crate::script_runtime::JSContext as SafeJSContext;
|
||||
use js::jsapi::{Heap, JSObject};
|
||||
use js::rust::HandleObject;
|
||||
use std::default::Default;
|
||||
|
||||
|
@ -16,14 +17,20 @@ use std::default::Default;
|
|||
pub fn reflect_dom_object<T, U>(
|
||||
obj: Box<T>,
|
||||
global: &U,
|
||||
wrap_fn: unsafe fn(*mut JSContext, &GlobalScope, Box<T>) -> DomRoot<T>,
|
||||
wrap_fn: unsafe fn(SafeJSContext, &GlobalScope, Box<T>) -> DomRoot<T>,
|
||||
) -> DomRoot<T>
|
||||
where
|
||||
T: DomObject,
|
||||
U: DerivedFrom<GlobalScope>,
|
||||
{
|
||||
let global_scope = global.upcast();
|
||||
unsafe { wrap_fn(global_scope.get_cx(), global_scope, obj) }
|
||||
unsafe {
|
||||
wrap_fn(
|
||||
SafeJSContext::from_ptr(global_scope.get_cx()),
|
||||
global_scope,
|
||||
obj,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// A struct to store a reference to the reflector of a DOM object.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue