aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/utils.rs
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2016-07-04 20:59:01 +0300
committerEduard Burtescu <edy.burt@gmail.com>2016-07-04 20:59:01 +0300
commit0db1faf87651c99223683faafc836353f016ffb3 (patch)
treedec7ee5366fdb60a47f495d32c11a9ed2b8a4eb2 /components/script/dom/bindings/utils.rs
parenta77cc9950fb13ccd674a10e46c2327bfa0735dab (diff)
downloadservo-0db1faf87651c99223683faafc836353f016ffb3.tar.gz
servo-0db1faf87651c99223683faafc836353f016ffb3.zip
Switch to using the new rooted!/RootedGuard API for rooting.
Diffstat (limited to 'components/script/dom/bindings/utils.rs')
-rw-r--r--components/script/dom/bindings/utils.rs37
1 files changed, 18 insertions, 19 deletions
diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs
index 0f0d5bcf00e..e7085bf424a 100644
--- a/components/script/dom/bindings/utils.rs
+++ b/components/script/dom/bindings/utils.rs
@@ -29,8 +29,8 @@ use js::jsapi::{JS_ForwardGetPropertyTo, JS_GetClass, JS_GetLatin1StringCharsAnd
use js::jsapi::{JS_GetProperty, JS_GetPrototype, JS_GetReservedSlot, JS_HasProperty};
use js::jsapi::{JS_HasPropertyById, JS_IsExceptionPending, JS_IsGlobalObject, JS_NewGlobalObject};
use js::jsapi::{JS_ResolveStandardClass, JS_SetProperty, ToWindowProxyIfWindow};
-use js::jsapi::{JS_SetReservedSlot, JS_StringHasLatin1Chars, MutableHandleValue, ObjectOpResult};
-use js::jsapi::{OnNewGlobalHookOption, RootedObject, RootedValue};
+use js::jsapi::{JS_SetReservedSlot, JS_StringHasLatin1Chars, MutableHandleValue};
+use js::jsapi::{ObjectOpResult, OnNewGlobalHookOption};
use js::jsval::{JSVal, ObjectValue, PrivateValue, UndefinedValue};
use js::rust::{GCMethods, ToString};
use libc;
@@ -135,8 +135,8 @@ pub fn get_property_on_prototype(cx: *mut JSContext,
-> bool {
unsafe {
// let proto = GetObjectProto(proxy);
- let mut proto = RootedObject::new(cx, ptr::null_mut());
- if !JS_GetPrototype(cx, proxy, proto.handle_mut()) || proto.ptr.is_null() {
+ rooted!(in(cx) let mut proto = ptr::null_mut());
+ if !JS_GetPrototype(cx, proxy, proto.handle_mut()) || proto.is_null() {
*found = false;
return true;
}
@@ -150,7 +150,7 @@ pub fn get_property_on_prototype(cx: *mut JSContext,
return true;
}
- let receiver = RootedValue::new(cx, ObjectValue(&**proxy.ptr));
+ rooted!(in(cx) let receiver = ObjectValue(&*proxy.get()));
JS_ForwardGetPropertyTo(cx, proto.handle(), id, receiver.handle(), vp)
}
}
@@ -305,29 +305,28 @@ pub fn create_dom_global(cx: *mut JSContext,
options.creationOptions_.traceGlobal_ = trace;
options.creationOptions_.sharedMemoryAndAtomics_ = true;
- let obj =
- RootedObject::new(cx,
- JS_NewGlobalObject(cx,
- class,
- ptr::null_mut(),
- OnNewGlobalHookOption::DontFireOnNewGlobalHook,
- &options));
- if obj.ptr.is_null() {
+ rooted!(in(cx) let obj =
+ JS_NewGlobalObject(cx,
+ class,
+ ptr::null_mut(),
+ OnNewGlobalHookOption::DontFireOnNewGlobalHook,
+ &options));
+ if obj.is_null() {
return ptr::null_mut();
}
// Initialize the reserved slots before doing amything that can GC, to
// avoid getting trace hooks called on a partially initialized object.
- JS_SetReservedSlot(obj.ptr, DOM_OBJECT_SLOT, PrivateValue(private));
+ JS_SetReservedSlot(obj.get(), DOM_OBJECT_SLOT, PrivateValue(private));
let proto_array: Box<ProtoOrIfaceArray> =
box [0 as *mut JSObject; PROTO_OR_IFACE_LENGTH];
- JS_SetReservedSlot(obj.ptr,
+ JS_SetReservedSlot(obj.get(),
DOM_PROTOTYPE_SLOT,
PrivateValue(Box::into_raw(proto_array) as *const libc::c_void));
- let _ac = JSAutoCompartment::new(cx, obj.ptr);
+ let _ac = JSAutoCompartment::new(cx, obj.get());
JS_FireOnNewGlobalObject(cx, obj.handle());
- obj.ptr
+ obj.get()
}
}
@@ -459,14 +458,14 @@ unsafe fn generic_call(cx: *mut JSContext,
} else {
GetGlobalForObjectCrossCompartment(JS_CALLEE(cx, vp).to_object_or_null())
};
- let obj = RootedObject::new(cx, obj);
+ rooted!(in(cx) let obj = obj);
let info = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp));
let proto_id = (*info).protoID;
let depth = (*info).depth;
let proto_check = |class: &'static DOMClass| {
class.interface_chain[depth as usize] as u16 == proto_id
};
- let this = match private_from_proto_check(obj.ptr, proto_check) {
+ let this = match private_from_proto_check(obj.get(), proto_check) {
Ok(val) => val,
Err(()) => {
if is_lenient {