mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Modify *::get_cx methods to return a safe JSContext instead of a raw one
This commit is contained in:
parent
2c5d0a6ebc
commit
88cacfb009
43 changed files with 306 additions and 321 deletions
|
@ -7,7 +7,7 @@
|
|||
use crate::dom::bindings::conversions::DerivedFrom;
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::script_runtime::JSContext as SafeJSContext;
|
||||
use crate::script_runtime::JSContext;
|
||||
use js::jsapi::{Heap, JSObject};
|
||||
use js::rust::HandleObject;
|
||||
use std::default::Default;
|
||||
|
@ -17,20 +17,14 @@ use std::default::Default;
|
|||
pub fn reflect_dom_object<T, U>(
|
||||
obj: Box<T>,
|
||||
global: &U,
|
||||
wrap_fn: unsafe fn(SafeJSContext, &GlobalScope, Box<T>) -> DomRoot<T>,
|
||||
wrap_fn: unsafe fn(JSContext, &GlobalScope, Box<T>) -> DomRoot<T>,
|
||||
) -> DomRoot<T>
|
||||
where
|
||||
T: DomObject,
|
||||
U: DerivedFrom<GlobalScope>,
|
||||
{
|
||||
let global_scope = global.upcast();
|
||||
unsafe {
|
||||
wrap_fn(
|
||||
SafeJSContext::from_ptr(global_scope.get_cx()),
|
||||
global_scope,
|
||||
obj,
|
||||
)
|
||||
}
|
||||
unsafe { wrap_fn(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