aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/browsercontext.rs
diff options
context:
space:
mode:
authorMichael Wu <mwu@mozilla.com>2015-09-23 16:53:03 -0400
committerMichael Wu <mwu@mozilla.com>2015-10-14 15:30:52 -0400
commite733a7c46a5d14a1be219e76136cdcb2d678d33a (patch)
tree7a50317a6cfa109eb3a7049add9ad87597dac55e /components/script/dom/browsercontext.rs
parent32daa17d5cbcad02db0713e21e52410cdc60480e (diff)
downloadservo-e733a7c46a5d14a1be219e76136cdcb2d678d33a.tar.gz
servo-e733a7c46a5d14a1be219e76136cdcb2d678d33a.zip
Support the updated spidermonkey bindings
Diffstat (limited to 'components/script/dom/browsercontext.rs')
-rw-r--r--components/script/dom/browsercontext.rs47
1 files changed, 23 insertions, 24 deletions
diff --git a/components/script/dom/browsercontext.rs b/components/script/dom/browsercontext.rs
index 3209231d196..3df44a5ba9b 100644
--- a/components/script/dom/browsercontext.rs
+++ b/components/script/dom/browsercontext.rs
@@ -13,14 +13,13 @@ use dom::element::Element;
use dom::window::Window;
use js::glue::{CreateWrapperProxyHandler, ProxyTraps, WrapperNew};
use js::glue::{GetProxyPrivate};
-use js::jsapi::{Handle, HandleValue, Heap, JS_ForwardSetPropertyTo, ObjectOpResult, RootedObject, RootedValue};
+use js::jsapi::{Handle, Heap, JS_ForwardSetPropertyTo, ObjectOpResult, RootedObject, RootedValue};
use js::jsapi::{HandleId, HandleObject, MutableHandle, MutableHandleValue};
use js::jsapi::{JSAutoCompartment, JSAutoRequest};
use js::jsapi::{JSContext, JSErrNum, JSObject, JSPropertyDescriptor};
use js::jsapi::{JS_AlreadyHasOwnPropertyById, JS_ForwardGetPropertyTo};
use js::jsapi::{JS_DefinePropertyById6, JS_GetPropertyDescriptorById};
use js::jsval::{ObjectValue, UndefinedValue};
-use js::{JSFalse, JSTrue};
use std::default::Default;
use std::ptr;
@@ -115,20 +114,20 @@ unsafe fn GetSubframeWindow(cx: *mut JSContext, proxy: HandleObject, id: HandleI
#[allow(unsafe_code)]
unsafe extern fn getOwnPropertyDescriptor(cx: *mut JSContext, proxy: HandleObject, id: HandleId,
- desc: MutableHandle<JSPropertyDescriptor>) -> u8 {
+ desc: MutableHandle<JSPropertyDescriptor>) -> bool {
let window = GetSubframeWindow(cx, proxy, id);
if let Some(window) = window {
let mut val = RootedValue::new(cx, UndefinedValue());
window.to_jsval(cx, val.handle_mut());
(*desc.ptr).value = val.ptr;
fill_property_descriptor(&mut *desc.ptr, *proxy.ptr, true);
- return JSTrue;
+ return true;
}
let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object());
// XXX This should be JS_GetOwnPropertyDescriptorById
- if JS_GetPropertyDescriptorById(cx, target.handle(), id, desc) == 0 {
- return JSFalse;
+ if !JS_GetPropertyDescriptorById(cx, target.handle(), id, desc) {
+ return false;
}
if (*desc.ptr).obj != target.ptr {
@@ -138,7 +137,7 @@ unsafe extern fn getOwnPropertyDescriptor(cx: *mut JSContext, proxy: HandleObjec
(*desc.ptr).obj = *proxy.ptr;
}
- JSTrue
+ true
}
#[allow(unsafe_code)]
@@ -146,14 +145,14 @@ unsafe extern fn defineProperty(cx: *mut JSContext,
proxy: HandleObject,
id: HandleId,
desc: Handle<JSPropertyDescriptor>,
- res: *mut ObjectOpResult) -> u8 {
+ res: *mut ObjectOpResult) -> bool {
if get_array_index_from_id(cx, id).is_some() {
// Spec says to Reject whether this is a supported index or not,
// since we have no indexed setter or indexed creator. That means
// throwing in strict mode (FIXME: Bug 828137), doing nothing in
// non-strict mode.
- (*res).code_ = JSErrNum::JSMSG_CANT_DEFINE_WINDOW_ELEMENT as u32;
- return JSTrue;
+ (*res).code_ = JSErrNum::JSMSG_CANT_DEFINE_WINDOW_ELEMENT as ::libc::uintptr_t;
+ return true;
}
let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object());
@@ -161,21 +160,21 @@ unsafe extern fn defineProperty(cx: *mut JSContext,
}
#[allow(unsafe_code)]
-unsafe extern fn hasOwn(cx: *mut JSContext, proxy: HandleObject, id: HandleId, bp: *mut u8) -> u8 {
+unsafe extern fn hasOwn(cx: *mut JSContext, proxy: HandleObject, id: HandleId, bp: *mut bool) -> bool {
let window = GetSubframeWindow(cx, proxy, id);
if window.is_some() {
- *bp = JSTrue;
- return JSTrue;
+ *bp = true;
+ return true;
}
let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object());
- let mut found = 0;
- if JS_AlreadyHasOwnPropertyById(cx, target.handle(), id, &mut found) == 0 {
- return JSFalse;
+ let mut found = false;
+ if !JS_AlreadyHasOwnPropertyById(cx, target.handle(), id, &mut found) {
+ return false;
}
- *bp = (found != 0) as u8;
- JSTrue
+ *bp = found;
+ true
}
#[allow(unsafe_code)]
@@ -183,11 +182,11 @@ unsafe extern fn get(cx: *mut JSContext,
proxy: HandleObject,
receiver: HandleObject,
id: HandleId,
- vp: MutableHandleValue) -> u8 {
+ vp: MutableHandleValue) -> bool {
let window = GetSubframeWindow(cx, proxy, id);
if let Some(window) = window {
window.to_jsval(cx, vp);
- return JSTrue;
+ return true;
}
let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object());
@@ -200,16 +199,16 @@ unsafe extern fn set(cx: *mut JSContext,
receiver: HandleObject,
id: HandleId,
vp: MutableHandleValue,
- res: *mut ObjectOpResult) -> u8 {
+ res: *mut ObjectOpResult) -> bool {
if get_array_index_from_id(cx, id).is_some() {
// Reject (which means throw if and only if strict) the set.
- (*res).code_ = JSErrNum::JSMSG_READ_ONLY as u32;
- return JSTrue;
+ (*res).code_ = JSErrNum::JSMSG_READ_ONLY as ::libc::uintptr_t;
+ return true;
}
let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object());
let receiver = RootedValue::new(cx, ObjectValue(&**receiver.ptr));
- JS_ForwardSetPropertyTo(cx, target.handle(), id, HandleValue { ptr: vp.ptr }, receiver.handle(), res)
+ JS_ForwardSetPropertyTo(cx, target.handle(), id, vp.to_handle(), receiver.handle(), res)
}
static PROXY_HANDLER: ProxyTraps = ProxyTraps {