mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Update SpiderMonkey
This commit is contained in:
parent
d32648172c
commit
eb94f1a918
21 changed files with 180 additions and 194 deletions
|
@ -14,10 +14,6 @@
|
|||
|
||||
DOMInterfaces = {
|
||||
|
||||
'Window': {
|
||||
'outerObjectHook': 'Some(bindings::utils::outerize_global)',
|
||||
},
|
||||
|
||||
'Range': {
|
||||
'weakReferenceable': True,
|
||||
},
|
||||
|
|
|
@ -1499,7 +1499,7 @@ class AttrDefiner(PropertyDefiner):
|
|||
|
||||
flags = "JSPROP_ENUMERATE | JSPROP_SHARED"
|
||||
if self.unforgeable:
|
||||
flags += " | JSPROP_READONLY | JSPROP_PERMANENT"
|
||||
flags += " | JSPROP_PERMANENT"
|
||||
|
||||
def getter(attr):
|
||||
if self.static:
|
||||
|
@ -1542,7 +1542,7 @@ class AttrDefiner(PropertyDefiner):
|
|||
array, name,
|
||||
' JSPropertySpec {\n'
|
||||
' name: %s as *const u8 as *const libc::c_char,\n'
|
||||
' flags: ((%s) & 0xFF) as u8,\n'
|
||||
' flags: (%s) as u8,\n'
|
||||
' getter: %s,\n'
|
||||
' setter: %s\n'
|
||||
' }',
|
||||
|
@ -1779,7 +1779,6 @@ class CGDOMJSClass(CGThing):
|
|||
"finalizeHook": FINALIZE_HOOK_NAME,
|
||||
"flags": "0",
|
||||
"name": str_to_const_array(self.descriptor.interface.identifier.name),
|
||||
"outerObjectHook": self.descriptor.outerObjectHook,
|
||||
"resolveHook": "None",
|
||||
"slots": "1",
|
||||
"traceHook": TRACE_HOOK_NAME,
|
||||
|
@ -1797,7 +1796,7 @@ class CGDOMJSClass(CGThing):
|
|||
static Class: DOMJSClass = DOMJSClass {
|
||||
base: js::jsapi::Class {
|
||||
name: %(name)s as *const u8 as *const libc::c_char,
|
||||
flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_IMPLEMENTS_BARRIERS | %(flags)s |
|
||||
flags: JSCLASS_IS_DOMJSCLASS | %(flags)s |
|
||||
(((%(slots)s) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
|
||||
/* JSCLASS_HAS_RESERVED_SLOTS(%(slots)s) */,
|
||||
addProperty: None,
|
||||
|
@ -1806,7 +1805,7 @@ static Class: DOMJSClass = DOMJSClass {
|
|||
setProperty: None,
|
||||
enumerate: %(enumerateHook)s,
|
||||
resolve: %(resolveHook)s,
|
||||
convert: None,
|
||||
mayResolve: None,
|
||||
finalize: Some(%(finalizeHook)s),
|
||||
call: None,
|
||||
hasInstance: None,
|
||||
|
@ -1814,19 +1813,17 @@ static Class: DOMJSClass = DOMJSClass {
|
|||
trace: Some(%(traceHook)s),
|
||||
|
||||
spec: js::jsapi::ClassSpec {
|
||||
createConstructor: None,
|
||||
createPrototype: None,
|
||||
constructorFunctions: 0 as *const js::jsapi::JSFunctionSpec,
|
||||
constructorProperties: 0 as *const js::jsapi::JSPropertySpec,
|
||||
prototypeFunctions: 0 as *const js::jsapi::JSFunctionSpec,
|
||||
prototypeProperties: 0 as *const js::jsapi::JSPropertySpec,
|
||||
finishInit: None,
|
||||
createConstructor_: None,
|
||||
createPrototype_: None,
|
||||
constructorFunctions_: 0 as *const js::jsapi::JSFunctionSpec,
|
||||
constructorProperties_: 0 as *const js::jsapi::JSPropertySpec,
|
||||
prototypeFunctions_: 0 as *const js::jsapi::JSFunctionSpec,
|
||||
prototypeProperties_: 0 as *const js::jsapi::JSPropertySpec,
|
||||
finishInit_: None,
|
||||
flags: 0,
|
||||
},
|
||||
|
||||
ext: js::jsapi::ClassExtension {
|
||||
outerObject: %(outerObjectHook)s,
|
||||
innerObject: None,
|
||||
isWrappedNative: false,
|
||||
weakmapKeyDelegateOp: None,
|
||||
objectMovedOp: None,
|
||||
|
@ -1844,7 +1841,6 @@ static Class: DOMJSClass = DOMJSClass {
|
|||
unwatch: None,
|
||||
getElements: None,
|
||||
enumerate: None,
|
||||
thisObject: %(outerObjectHook)s,
|
||||
funToString: None,
|
||||
},
|
||||
},
|
||||
|
@ -1878,13 +1874,13 @@ static PrototypeClass: JSClass = JSClass {
|
|||
setProperty: None,
|
||||
enumerate: None,
|
||||
resolve: None,
|
||||
convert: None,
|
||||
mayResolve: None,
|
||||
finalize: None,
|
||||
call: None,
|
||||
hasInstance: None,
|
||||
construct: None,
|
||||
trace: None,
|
||||
reserved: [0 as *mut libc::c_void; 26]
|
||||
reserved: [0 as *mut os::raw::c_void; 23]
|
||||
};
|
||||
""" % {'name': name, 'slotCount': slotCount}
|
||||
|
||||
|
@ -2402,10 +2398,11 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
|||
let mut interface = RootedObject::new(cx, ptr::null_mut());
|
||||
create_callback_interface_object(cx, global, sConstants, %(name)s, interface.handle_mut());
|
||||
assert!(!interface.ptr.is_null());
|
||||
assert!((*cache)[PrototypeList::Constructor::%(id)s as usize].is_null());
|
||||
(*cache)[PrototypeList::Constructor::%(id)s as usize] = interface.ptr;
|
||||
if <*mut JSObject>::needs_post_barrier(interface.ptr) {
|
||||
<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::Constructor::%(id)s as isize));
|
||||
}
|
||||
<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::Constructor::%(id)s as isize),
|
||||
ptr::null_mut(),
|
||||
interface.ptr);
|
||||
""" % {"id": name, "name": str_to_const_array(name)})
|
||||
|
||||
if len(self.descriptor.prototypeChain) == 1:
|
||||
|
@ -2445,10 +2442,12 @@ create_interface_prototype_object(cx,
|
|||
%(consts)s,
|
||||
prototype.handle_mut());
|
||||
assert!(!prototype.ptr.is_null());
|
||||
assert!((*cache)[PrototypeList::ID::%(id)s as usize].is_null());
|
||||
(*cache)[PrototypeList::ID::%(id)s as usize] = prototype.ptr;
|
||||
if <*mut JSObject>::needs_post_barrier(prototype.ptr) {
|
||||
<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::%(id)s as isize));
|
||||
}""" % properties))
|
||||
<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::%(id)s as isize),
|
||||
ptr::null_mut(),
|
||||
prototype.ptr);
|
||||
""" % properties))
|
||||
|
||||
if self.descriptor.interface.hasInterfaceObject():
|
||||
properties["name"] = str_to_const_array(name)
|
||||
|
@ -2482,10 +2481,12 @@ create_noncallback_interface_object(cx,
|
|||
assert!(!interface.ptr.is_null());""" % properties))
|
||||
if self.descriptor.hasDescendants():
|
||||
code.append(CGGeneric("""\
|
||||
assert!((*cache)[PrototypeList::Constructor::%(id)s as usize].is_null());
|
||||
(*cache)[PrototypeList::Constructor::%(id)s as usize] = interface.ptr;
|
||||
if <*mut JSObject>::needs_post_barrier(prototype.ptr) {
|
||||
<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::Constructor::%(id)s as isize));
|
||||
}""" % properties))
|
||||
<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::Constructor::%(id)s as isize),
|
||||
ptr::null_mut(),
|
||||
interface.ptr);
|
||||
""" % properties))
|
||||
|
||||
constructors = self.descriptor.interface.namedConstructors
|
||||
if constructors:
|
||||
|
@ -3167,7 +3168,7 @@ class CGMemberJITInfo(CGThing):
|
|||
aliasSet, alwaysInSlot, lazilyInSlot, slotIndex,
|
||||
returnTypes, args):
|
||||
"""
|
||||
aliasSet is a JSJitInfo::AliasSet value, without the "JSJitInfo::" bit.
|
||||
aliasSet is a JSJitInfo_AliasSet value, without the "JSJitInfo_AliasSet::" bit.
|
||||
|
||||
args is None if we don't want to output argTypes for some
|
||||
reason (e.g. we have overloads or we're not a method) and
|
||||
|
@ -3180,16 +3181,17 @@ class CGMemberJITInfo(CGThing):
|
|||
initializer = fill(
|
||||
"""
|
||||
JSJitInfo {
|
||||
call: ${opName} as *const ::libc::c_void,
|
||||
call: ${opName} as *const os::raw::c_void,
|
||||
protoID: PrototypeList::ID::${name} as u16,
|
||||
depth: ${depth},
|
||||
_bitfield_1:
|
||||
JSJitInfo::new_bitfield_1(
|
||||
OpType::${opType} as u8,
|
||||
AliasSet::${aliasSet} as u8,
|
||||
JSJitInfo_OpType::${opType} as u8,
|
||||
JSJitInfo_AliasSet::${aliasSet} as u8,
|
||||
JSValueType::${returnType} as u8,
|
||||
${isInfallible},
|
||||
${isMovable},
|
||||
${isEliminatable},
|
||||
${isAlwaysInSlot},
|
||||
${isLazilyCachedInSlot},
|
||||
${isTypedMethod},
|
||||
|
@ -3206,6 +3208,8 @@ class CGMemberJITInfo(CGThing):
|
|||
""),
|
||||
isInfallible=toStringBool(infallible),
|
||||
isMovable=toStringBool(movable),
|
||||
# FIXME(nox): https://github.com/servo/servo/issues/10991
|
||||
isEliminatable=toStringBool(False),
|
||||
isAlwaysInSlot=toStringBool(alwaysInSlot),
|
||||
isLazilyCachedInSlot=toStringBool(lazilyInSlot),
|
||||
isTypedMethod=toStringBool(isTypedMethod),
|
||||
|
@ -3215,7 +3219,7 @@ class CGMemberJITInfo(CGThing):
|
|||
if args is not None:
|
||||
argTypes = "%s_argTypes" % infoName
|
||||
args = [CGMemberJITInfo.getJSArgType(arg.type) for arg in args]
|
||||
args.append("ArgType::ArgTypeListEnd as i32")
|
||||
args.append("JSJitInfo_ArgType::ArgTypeListEnd as i32")
|
||||
argTypesDecl = (
|
||||
"const %s: [i32; %d] = [ %s ];\n" %
|
||||
(argTypes, len(args), ", ".join(args)))
|
||||
|
@ -3224,7 +3228,7 @@ class CGMemberJITInfo(CGThing):
|
|||
$*{argTypesDecl}
|
||||
const ${infoName}: JSTypedMethodJitInfo = JSTypedMethodJitInfo {
|
||||
base: ${jitInfo},
|
||||
argTypes: &${argTypes} as *const _ as *const ArgType,
|
||||
argTypes: &${argTypes} as *const _ as *const JSJitInfo_ArgType,
|
||||
};
|
||||
""",
|
||||
argTypesDecl=argTypesDecl,
|
||||
|
@ -3438,56 +3442,56 @@ class CGMemberJITInfo(CGThing):
|
|||
assert not t.isVoid()
|
||||
if t.nullable():
|
||||
# Sometimes it might return null, sometimes not
|
||||
return "ArgType::Null as i32 | %s" % CGMemberJITInfo.getJSArgType(t.inner)
|
||||
return "JSJitInfo_ArgType::Null as i32 | %s" % CGMemberJITInfo.getJSArgType(t.inner)
|
||||
if t.isArray():
|
||||
# No idea yet
|
||||
assert False
|
||||
if t.isSequence():
|
||||
return "ArgType::Object as i32"
|
||||
return "JSJitInfo_ArgType::Object as i32"
|
||||
if t.isGeckoInterface():
|
||||
return "ArgType::Object as i32"
|
||||
return "JSJitInfo_ArgType::Object as i32"
|
||||
if t.isString():
|
||||
return "ArgType::String as i32"
|
||||
return "JSJitInfo_ArgType::String as i32"
|
||||
if t.isEnum():
|
||||
return "ArgType::String as i32"
|
||||
return "JSJitInfo_ArgType::String as i32"
|
||||
if t.isCallback():
|
||||
return "ArgType::Object as i32"
|
||||
return "JSJitInfo_ArgType::Object as i32"
|
||||
if t.isAny():
|
||||
# The whole point is to return various stuff
|
||||
return "ArgType::Any as i32"
|
||||
return "JSJitInfo_ArgType::Any as i32"
|
||||
if t.isObject():
|
||||
return "ArgType::Object as i32"
|
||||
return "JSJitInfo_ArgType::Object as i32"
|
||||
if t.isSpiderMonkeyInterface():
|
||||
return "ArgType::Object as i32"
|
||||
return "JSJitInfo_ArgType::Object as i32"
|
||||
if t.isUnion():
|
||||
u = t.unroll()
|
||||
type = "JSJitInfo::Null as i32" if u.hasNullableType else ""
|
||||
return reduce(CGMemberJITInfo.getSingleArgType,
|
||||
u.flatMemberTypes, type)
|
||||
if t.isDictionary():
|
||||
return "ArgType::Object as i32"
|
||||
return "JSJitInfo_ArgType::Object as i32"
|
||||
if t.isDate():
|
||||
return "ArgType::Object as i32"
|
||||
return "JSJitInfo_ArgType::Object as i32"
|
||||
if not t.isPrimitive():
|
||||
raise TypeError("No idea what type " + str(t) + " is.")
|
||||
tag = t.tag()
|
||||
if tag == IDLType.Tags.bool:
|
||||
return "ArgType::Boolean as i32"
|
||||
return "JSJitInfo_ArgType::Boolean as i32"
|
||||
if tag in [IDLType.Tags.int8, IDLType.Tags.uint8,
|
||||
IDLType.Tags.int16, IDLType.Tags.uint16,
|
||||
IDLType.Tags.int32]:
|
||||
return "ArgType::Integer as i32"
|
||||
return "JSJitInfo_ArgType::Integer as i32"
|
||||
if tag in [IDLType.Tags.int64, IDLType.Tags.uint64,
|
||||
IDLType.Tags.unrestricted_float, IDLType.Tags.float,
|
||||
IDLType.Tags.unrestricted_double, IDLType.Tags.double]:
|
||||
# These all use JS_NumberValue, which can return int or double.
|
||||
# But TI treats "double" as meaning "int or double", so we're
|
||||
# good to return JSVAL_TYPE_DOUBLE here.
|
||||
return "ArgType::Double as i32"
|
||||
return "JSJitInfo_ArgType::Double as i32"
|
||||
if tag != IDLType.Tags.uint32:
|
||||
raise TypeError("No idea what type " + str(t) + " is.")
|
||||
# uint32 is sometimes int and sometimes double.
|
||||
return "ArgType::Double as i32"
|
||||
return "JSJitInfo_ArgType::Double as i32"
|
||||
|
||||
@staticmethod
|
||||
def getSingleArgType(existingType, t):
|
||||
|
@ -4319,7 +4323,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', 'proxy'),
|
||||
Argument('HandleId', 'id'),
|
||||
Argument('MutableHandle<JSPropertyDescriptor>', 'desc')]
|
||||
Argument('MutableHandle<PropertyDescriptor>', 'desc')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, "getOwnPropertyDescriptor",
|
||||
"bool", args)
|
||||
self.descriptor = descriptor
|
||||
|
@ -4405,7 +4409,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
|||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', 'proxy'),
|
||||
Argument('HandleId', 'id'),
|
||||
Argument('Handle<JSPropertyDescriptor>', 'desc'),
|
||||
Argument('Handle<PropertyDescriptor>', 'desc'),
|
||||
Argument('*mut ObjectOpResult', 'opresult')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, "defineProperty", "bool", args)
|
||||
self.descriptor = descriptor
|
||||
|
@ -4511,7 +4515,7 @@ class CGDOMJSProxyHandler_ownPropertyKeys(CGAbstractExternMethod):
|
|||
"""
|
||||
for name in (*unwrapped_proxy).SupportedPropertyNames() {
|
||||
let cstring = CString::new(name).unwrap();
|
||||
let jsstring = JS_InternString(cx, cstring.as_ptr());
|
||||
let jsstring = JS_AtomizeAndPinString(cx, cstring.as_ptr());
|
||||
let rooted = RootedString::new(cx, jsstring);
|
||||
let jsid = INTERNED_STRING_TO_JSID(cx, rooted.handle().get());
|
||||
let rooted_jsid = RootedId::new(cx, jsid);
|
||||
|
@ -4632,7 +4636,7 @@ return true;"""
|
|||
class CGDOMJSProxyHandler_get(CGAbstractExternMethod):
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', 'proxy'),
|
||||
Argument('HandleObject', 'receiver'), Argument('HandleId', 'id'),
|
||||
Argument('HandleValue', 'receiver'), Argument('HandleId', 'id'),
|
||||
Argument('MutableHandleValue', 'vp')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, "get", "bool", args)
|
||||
self.descriptor = descriptor
|
||||
|
@ -5366,13 +5370,12 @@ class CGBindingRoot(CGThing):
|
|||
# Add imports
|
||||
curr = CGImports(curr, descriptors + callbackDescriptors, mainCallbacks, [
|
||||
'js',
|
||||
'js::{JSCLASS_GLOBAL_SLOT_COUNT, JSCLASS_IMPLEMENTS_BARRIERS}',
|
||||
'js::{JS_CALLEE, JSCLASS_GLOBAL_SLOT_COUNT}',
|
||||
'js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL, JSCLASS_RESERVED_SLOTS_MASK}',
|
||||
'js::{JSCLASS_RESERVED_SLOTS_SHIFT, JSITER_HIDDEN, JSITER_OWNONLY}',
|
||||
'js::{JSITER_SYMBOLS, JSPROP_ENUMERATE, JSPROP_PERMANENT, JSPROP_READONLY}',
|
||||
'js::{JSPROP_SHARED, JS_CALLEE}',
|
||||
'js::error::throw_type_error',
|
||||
'js::jsapi::{AliasSet, ArgType, AutoIdVector, CallArgs, FreeOp}',
|
||||
'js::jsapi::{JSJitInfo_AliasSet, JSJitInfo_ArgType, AutoIdVector, CallArgs, FreeOp}',
|
||||
'js::jsapi::{JSITER_SYMBOLS, JSPROP_ENUMERATE, JSPROP_PERMANENT, JSPROP_READONLY, JSPROP_SHARED}',
|
||||
'js::jsapi::{JSCLASS_RESERVED_SLOTS_SHIFT, JSITER_HIDDEN, JSITER_OWNONLY}',
|
||||
'js::jsapi::{GetGlobalForObjectCrossCompartment , GetPropertyKeys, Handle}',
|
||||
'js::jsapi::{HandleId, HandleObject, HandleValue, HandleValueArray}',
|
||||
'js::jsapi::{INTERNED_STRING_TO_JSID, IsCallable, JS_CallFunctionValue}',
|
||||
|
@ -5381,16 +5384,16 @@ class CGBindingRoot(CGThing):
|
|||
'js::jsapi::{JS_GetGlobalForObject, JS_GetObjectPrototype, JS_GetProperty}',
|
||||
'js::jsapi::{JS_GetPropertyById, JS_GetPropertyDescriptorById, JS_GetReservedSlot}',
|
||||
'js::jsapi::{JS_HasProperty, JS_HasPropertyById, JS_InitializePropertiesFromCompatibleNativeObject}',
|
||||
'js::jsapi::{JS_InternString, JS_IsExceptionPending, JS_NewObject, JS_NewObjectWithGivenProto}',
|
||||
'js::jsapi::{JS_AtomizeAndPinString, JS_IsExceptionPending, JS_NewObject, JS_NewObjectWithGivenProto}',
|
||||
'js::jsapi::{JS_NewObjectWithoutMetadata, JS_NewStringCopyZ, JS_SetProperty}',
|
||||
'js::jsapi::{JS_SetPrototype, JS_SetReservedSlot, JS_WrapValue, JSAutoCompartment}',
|
||||
'js::jsapi::{JSAutoRequest, JSContext, JSClass, JSFreeOp, JSFunctionSpec}',
|
||||
'js::jsapi::{JSJitGetterCallArgs, JSJitInfo, JSJitMethodCallArgs, JSJitSetterCallArgs}',
|
||||
'js::jsapi::{JSNative, JSObject, JSNativeWrapper, JSPropertyDescriptor, JSPropertySpec}',
|
||||
'js::jsapi::{JSNative, JSObject, JSNativeWrapper, JSPropertySpec}',
|
||||
'js::jsapi::{JSString, JSTracer, JSType, JSTypedMethodJitInfo, JSValueType}',
|
||||
'js::jsapi::{ObjectOpResult, OpType, MutableHandle, MutableHandleObject}',
|
||||
'js::jsapi::{MutableHandleValue, RootedId, RootedObject, RootedString}',
|
||||
'js::jsapi::{RootedValue, SymbolCode, jsid}',
|
||||
'js::jsapi::{ObjectOpResult, JSJitInfo_OpType, MutableHandle, MutableHandleObject}',
|
||||
'js::jsapi::{MutableHandleValue, PropertyDescriptor, RootedId, RootedObject}',
|
||||
'js::jsapi::{RootedString, RootedValue, SymbolCode, jsid}',
|
||||
'js::jsval::JSVal',
|
||||
'js::jsval::{ObjectValue, ObjectOrNullValue, PrivateValue}',
|
||||
'js::jsval::{NullValue, UndefinedValue}',
|
||||
|
@ -5449,6 +5452,7 @@ class CGBindingRoot(CGThing):
|
|||
'std::cmp',
|
||||
'std::mem',
|
||||
'std::num',
|
||||
'std::os',
|
||||
'std::ptr',
|
||||
'std::str',
|
||||
'std::rc',
|
||||
|
|
|
@ -281,7 +281,7 @@ pub unsafe fn private_from_proto_check<F>(mut obj: *mut JSObject,
|
|||
let dom_class = try!(get_dom_class(obj).or_else(|_| {
|
||||
if IsWrapper(obj) {
|
||||
debug!("found wrapper");
|
||||
obj = UnwrapObject(obj, /* stopAtOuter = */ 0);
|
||||
obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0);
|
||||
if obj.is_null() {
|
||||
debug!("unwrapping security wrapper failed");
|
||||
Err(())
|
||||
|
@ -424,7 +424,9 @@ unsafe impl ArrayBufferViewContents for f64 {
|
|||
pub unsafe fn array_buffer_view_data<'a, T: ArrayBufferViewContents>(abv: *mut JSObject) -> Option<&'a mut [T]> {
|
||||
let mut byte_length = 0;
|
||||
let mut ptr = ptr::null_mut();
|
||||
let ret = JS_GetObjectAsArrayBufferView(abv, &mut byte_length, &mut ptr);
|
||||
let mut is_shared = false;
|
||||
let ret = JS_GetObjectAsArrayBufferView(abv, &mut byte_length, &mut is_shared, &mut ptr);
|
||||
assert!(!is_shared);
|
||||
if ret.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
@ -463,5 +465,7 @@ pub fn array_buffer_view_to_vec_checked<T: ArrayBufferViewContents>(abv: *mut JS
|
|||
/// Note: Currently only Arrays are supported.
|
||||
/// TODO: Expand this to support sequences and other array-like objects
|
||||
pub unsafe fn is_array_like(cx: *mut JSContext, value: HandleValue) -> bool {
|
||||
JS_IsArrayObject(cx, value)
|
||||
let mut result = false;
|
||||
assert!(JS_IsArrayObject(cx, value, &mut result));
|
||||
result
|
||||
}
|
||||
|
|
|
@ -11,15 +11,15 @@ use js::error::throw_type_error;
|
|||
use js::glue::UncheckedUnwrapObject;
|
||||
use js::jsapi::{Class, ClassExtension, ClassSpec, GetGlobalForObjectCrossCompartment};
|
||||
use js::jsapi::{HandleObject, HandleValue, JSClass, JSContext, JSFunctionSpec};
|
||||
use js::jsapi::{JSNative, JSPropertySpec, JSString, JS_DefineProperty1, JS_DefineProperty2};
|
||||
use js::jsapi::{JS_DefineProperty4, JS_GetClass, JS_GetFunctionObject, JS_GetPrototype};
|
||||
use js::jsapi::{JS_InternString, JS_LinkConstructorAndPrototype, JS_NewFunction, JS_NewObject};
|
||||
use js::jsapi::{JSNative, JSFUN_CONSTRUCTOR, JSPROP_ENUMERATE, JSPROP_PERMANENT, JSPROP_READONLY};
|
||||
use js::jsapi::{JSPROP_RESOLVING, JSPropertySpec, JSString, JS_DefineProperty1, JS_DefineProperty2};
|
||||
use js::jsapi::{JS_AtomizeAndPinString, JS_DefineProperty4, JS_GetClass, JS_GetFunctionObject};
|
||||
use js::jsapi::{JS_GetPrototype, JS_LinkConstructorAndPrototype, JS_NewFunction, JS_NewObject};
|
||||
use js::jsapi::{JS_NewObjectWithUniqueType, JS_NewStringCopyZ, JS_DefineProperty};
|
||||
use js::jsapi::{MutableHandleObject, MutableHandleValue, ObjectOps, RootedObject, RootedString};
|
||||
use js::jsapi::{RootedValue, Value};
|
||||
use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, NullValue, UInt32Value};
|
||||
use js::rust::{define_methods, define_properties};
|
||||
use js::{JSPROP_ENUMERATE, JSFUN_CONSTRUCTOR, JSPROP_PERMANENT, JSPROP_READONLY};
|
||||
use libc;
|
||||
use std::ptr;
|
||||
|
||||
|
@ -127,25 +127,23 @@ impl NonCallbackInterfaceObjectClass {
|
|||
setProperty: None,
|
||||
enumerate: None,
|
||||
resolve: None,
|
||||
convert: None,
|
||||
mayResolve: None,
|
||||
finalize: None,
|
||||
call: constructor_behavior.call,
|
||||
construct: constructor_behavior.construct,
|
||||
hasInstance: Some(has_instance_hook),
|
||||
trace: None,
|
||||
spec: ClassSpec {
|
||||
createConstructor: None,
|
||||
createPrototype: None,
|
||||
constructorFunctions: ptr::null(),
|
||||
constructorProperties: ptr::null(),
|
||||
prototypeFunctions: ptr::null(),
|
||||
prototypeProperties: ptr::null(),
|
||||
finishInit: None,
|
||||
createConstructor_: None,
|
||||
createPrototype_: None,
|
||||
constructorFunctions_: ptr::null(),
|
||||
constructorProperties_: ptr::null(),
|
||||
prototypeFunctions_: ptr::null(),
|
||||
prototypeProperties_: ptr::null(),
|
||||
finishInit_: None,
|
||||
flags: 0,
|
||||
},
|
||||
ext: ClassExtension {
|
||||
outerObject: None,
|
||||
innerObject: None,
|
||||
isWrappedNative: false,
|
||||
weakmapKeyDelegateOp: None,
|
||||
objectMovedOp: None,
|
||||
|
@ -162,7 +160,6 @@ impl NonCallbackInterfaceObjectClass {
|
|||
unwatch: None,
|
||||
getElements: None,
|
||||
enumerate: None,
|
||||
thisObject: None,
|
||||
funToString: Some(fun_to_string_hook),
|
||||
}
|
||||
},
|
||||
|
@ -323,7 +320,7 @@ unsafe fn has_instance(
|
|||
let js_class = JS_GetClass(interface_object.get());
|
||||
let object_class = &*(js_class as *const NonCallbackInterfaceObjectClass);
|
||||
|
||||
if let Ok(dom_class) = get_dom_class(UncheckedUnwrapObject(value.ptr, /* stopAtOuter = */ 0)) {
|
||||
if let Ok(dom_class) = get_dom_class(UncheckedUnwrapObject(value.ptr, /* stopAtWindowProxy = */ 0)) {
|
||||
if dom_class.interface_chain[object_class.proto_depth as usize] == object_class.proto_id {
|
||||
// Step 4.
|
||||
return Ok(true);
|
||||
|
@ -372,8 +369,8 @@ unsafe fn create_object(
|
|||
|
||||
unsafe fn define_name(cx: *mut JSContext, obj: HandleObject, name: &'static [u8]) {
|
||||
assert!(*name.last().unwrap() == b'\0');
|
||||
let name =
|
||||
RootedString::new(cx, JS_InternString(cx, name.as_ptr() as *const libc::c_char));
|
||||
let name = RootedString::new(
|
||||
cx, JS_AtomizeAndPinString(cx, name.as_ptr() as *const libc::c_char));
|
||||
assert!(!name.ptr.is_null());
|
||||
assert!(JS_DefineProperty2(cx,
|
||||
obj,
|
||||
|
@ -402,7 +399,7 @@ unsafe fn define_on_global_object(
|
|||
receiver,
|
||||
name.as_ptr() as *const libc::c_char,
|
||||
obj,
|
||||
0,
|
||||
JSPROP_RESOLVING,
|
||||
None, None));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,16 +8,15 @@
|
|||
|
||||
use dom::bindings::conversions::is_dom_proxy;
|
||||
use dom::bindings::utils::delete_property_by_id;
|
||||
use js::JSPROP_GETTER;
|
||||
use js::glue::GetProxyExtra;
|
||||
use js::glue::InvokeGetOwnPropertyDescriptor;
|
||||
use js::glue::{GetProxyHandler, SetProxyExtra};
|
||||
use js::jsapi::GetObjectProto;
|
||||
use js::jsapi::JS_GetPropertyDescriptorById;
|
||||
use js::jsapi::{Handle, HandleId, HandleObject, MutableHandle, ObjectOpResult, RootedObject};
|
||||
use js::jsapi::{JSContext, JSObject, JSPropertyDescriptor};
|
||||
use js::jsapi::{JSContext, JSObject, JSPROP_GETTER, PropertyDescriptor};
|
||||
use js::jsapi::{JSErrNum, JS_StrictPropertyStub};
|
||||
use js::jsapi::{JS_DefinePropertyById6, JS_NewObjectWithGivenProto};
|
||||
use js::jsapi::{JS_DefinePropertyById, JS_NewObjectWithGivenProto};
|
||||
use js::jsval::ObjectValue;
|
||||
use libc;
|
||||
use std::{mem, ptr};
|
||||
|
@ -31,7 +30,7 @@ static JSPROXYSLOT_EXPANDO: u32 = 0;
|
|||
pub unsafe extern "C" fn get_property_descriptor(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId,
|
||||
desc: MutableHandle<JSPropertyDescriptor>)
|
||||
desc: MutableHandle<PropertyDescriptor>)
|
||||
-> bool {
|
||||
let handler = GetProxyHandler(proxy.get());
|
||||
if !InvokeGetOwnPropertyDescriptor(handler, cx, proxy, id, desc) {
|
||||
|
@ -54,7 +53,7 @@ pub unsafe extern "C" fn get_property_descriptor(cx: *mut JSContext,
|
|||
pub unsafe extern "C" fn define_property(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId,
|
||||
desc: Handle<JSPropertyDescriptor>,
|
||||
desc: Handle<PropertyDescriptor>,
|
||||
result: *mut ObjectOpResult)
|
||||
-> bool {
|
||||
// FIXME: Workaround for https://github.com/rust-lang/rfcs/issues/718
|
||||
|
@ -67,7 +66,7 @@ pub unsafe extern "C" fn define_property(cx: *mut JSContext,
|
|||
}
|
||||
|
||||
let expando = RootedObject::new(cx, ensure_expando_object(cx, proxy));
|
||||
JS_DefinePropertyById6(cx, expando.handle(), id, desc, result)
|
||||
JS_DefinePropertyById(cx, expando.handle(), id, desc, result)
|
||||
}
|
||||
|
||||
/// Deletes an expando off the given `proxy`.
|
||||
|
@ -126,7 +125,7 @@ pub fn ensure_expando_object(cx: *mut JSContext, obj: HandleObject) -> *mut JSOb
|
|||
expando = JS_NewObjectWithGivenProto(cx, ptr::null_mut(), HandleObject::null());
|
||||
assert!(!expando.is_null());
|
||||
|
||||
SetProxyExtra(obj.get(), JSPROXYSLOT_EXPANDO, ObjectValue(&*expando));
|
||||
SetProxyExtra(obj.get(), JSPROXYSLOT_EXPANDO, &ObjectValue(&*expando));
|
||||
}
|
||||
expando
|
||||
}
|
||||
|
@ -134,7 +133,7 @@ pub fn ensure_expando_object(cx: *mut JSContext, obj: HandleObject) -> *mut JSOb
|
|||
|
||||
/// Set the property descriptor's object to `obj` and set it to enumerable,
|
||||
/// and writable if `readonly` is true.
|
||||
pub fn fill_property_descriptor(desc: &mut JSPropertyDescriptor,
|
||||
pub fn fill_property_descriptor(desc: &mut PropertyDescriptor,
|
||||
obj: *mut JSObject,
|
||||
attrs: u32) {
|
||||
desc.obj = obj;
|
||||
|
|
|
@ -33,6 +33,7 @@ use std::cell::RefCell;
|
|||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use std::collections::hash_map::HashMap;
|
||||
use std::marker::PhantomData;
|
||||
use std::os;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
|
||||
|
@ -199,7 +200,7 @@ impl LiveDOMReferences {
|
|||
|
||||
/// A JSTraceDataOp for tracing reflectors held in LIVE_REFERENCES
|
||||
pub unsafe extern "C" fn trace_refcounted_objects(tracer: *mut JSTracer,
|
||||
_data: *mut libc::c_void) {
|
||||
_data: *mut os::raw::c_void) {
|
||||
LIVE_REFERENCES.with(|ref r| {
|
||||
let r = r.borrow();
|
||||
let live_references = r.as_ref().unwrap();
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
|
||||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use js::glue::JS_STRUCTURED_CLONE_VERSION;
|
||||
use js::jsapi::{HandleValue, MutableHandleValue};
|
||||
use js::jsapi::{JSContext, JS_ReadStructuredClone};
|
||||
use js::jsapi::{JSContext, JS_ReadStructuredClone, JS_STRUCTURED_CLONE_VERSION};
|
||||
use js::jsapi::{JS_ClearPendingException, JS_WriteStructuredClone};
|
||||
use libc::size_t;
|
||||
use std::ptr;
|
||||
|
|
|
@ -49,8 +49,8 @@ use hyper::header::Headers;
|
|||
use hyper::method::Method;
|
||||
use hyper::mime::Mime;
|
||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||
use js::jsapi::JS_CallUnbarrieredObjectTracer;
|
||||
use js::jsapi::{GCTraceKindToAscii, Heap, JSGCTraceKind, JSObject, JSTracer, JS_CallObjectTracer, JS_CallValueTracer};
|
||||
use js::glue::{CallObjectTracer, CallUnbarrieredObjectTracer, CallValueTracer};
|
||||
use js::jsapi::{GCTraceKindToAscii, Heap, TraceKind, JSObject, JSTracer};
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::Runtime;
|
||||
use layout_interface::{LayoutChan, LayoutRPC};
|
||||
|
@ -72,7 +72,6 @@ use smallvec::SmallVec;
|
|||
use std::boxed::FnBox;
|
||||
use std::cell::{Cell, UnsafeCell};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::ffi::CString;
|
||||
use std::hash::{BuildHasher, Hash};
|
||||
use std::intrinsics::return_address;
|
||||
use std::iter::{FromIterator, IntoIterator};
|
||||
|
@ -114,12 +113,8 @@ pub fn trace_jsval(tracer: *mut JSTracer, description: &str, val: &Heap<JSVal>)
|
|||
return;
|
||||
}
|
||||
|
||||
let name = CString::new(description).unwrap();
|
||||
(*tracer).debugPrinter_ = None;
|
||||
(*tracer).debugPrintIndex_ = !0;
|
||||
(*tracer).debugPrintArg_ = name.as_ptr() as *const libc::c_void;
|
||||
debug!("tracing value {}", description);
|
||||
JS_CallValueTracer(tracer,
|
||||
CallValueTracer(tracer,
|
||||
val.ptr.get() as *mut _,
|
||||
GCTraceKindToAscii(val.get().trace_kind()));
|
||||
}
|
||||
|
@ -129,28 +124,20 @@ pub fn trace_jsval(tracer: *mut JSTracer, description: &str, val: &Heap<JSVal>)
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) {
|
||||
unsafe {
|
||||
let name = CString::new(description).unwrap();
|
||||
(*tracer).debugPrinter_ = None;
|
||||
(*tracer).debugPrintIndex_ = !0;
|
||||
(*tracer).debugPrintArg_ = name.as_ptr() as *const libc::c_void;
|
||||
debug!("tracing reflector {}", description);
|
||||
JS_CallUnbarrieredObjectTracer(tracer,
|
||||
CallUnbarrieredObjectTracer(tracer,
|
||||
reflector.rootable(),
|
||||
GCTraceKindToAscii(JSGCTraceKind::JSTRACE_OBJECT));
|
||||
GCTraceKindToAscii(TraceKind::Object));
|
||||
}
|
||||
}
|
||||
|
||||
/// Trace a `JSObject`.
|
||||
pub fn trace_object(tracer: *mut JSTracer, description: &str, obj: &Heap<*mut JSObject>) {
|
||||
unsafe {
|
||||
let name = CString::new(description).unwrap();
|
||||
(*tracer).debugPrinter_ = None;
|
||||
(*tracer).debugPrintIndex_ = !0;
|
||||
(*tracer).debugPrintArg_ = name.as_ptr() as *const libc::c_void;
|
||||
debug!("tracing {}", description);
|
||||
JS_CallObjectTracer(tracer,
|
||||
CallObjectTracer(tracer,
|
||||
obj.ptr.get() as *mut _,
|
||||
GCTraceKindToAscii(JSGCTraceKind::JSTRACE_OBJECT));
|
||||
GCTraceKindToAscii(TraceKind::Object));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,13 +7,11 @@
|
|||
use dom::bindings::codegen::InterfaceObjectMap;
|
||||
use dom::bindings::codegen::PrototypeList;
|
||||
use dom::bindings::codegen::PrototypeList::{MAX_PROTO_CHAIN_LENGTH, PROTO_OR_IFACE_LENGTH};
|
||||
use dom::bindings::conversions::{DOM_OBJECT_SLOT, is_dom_class};
|
||||
use dom::bindings::conversions::{private_from_proto_check, root_from_handleobject};
|
||||
use dom::bindings::conversions::{DOM_OBJECT_SLOT, is_dom_class, private_from_proto_check};
|
||||
use dom::bindings::error::throw_invalid_this;
|
||||
use dom::bindings::inheritance::TopTypeId;
|
||||
use dom::bindings::trace::trace_object;
|
||||
use dom::browsingcontext;
|
||||
use dom::window;
|
||||
use heapsize::HeapSizeOf;
|
||||
use js;
|
||||
use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper};
|
||||
|
@ -23,15 +21,14 @@ use js::glue::{RUST_JSID_TO_INT, RUST_JSID_TO_STRING, UnwrapObject};
|
|||
use js::jsapi::{CallArgs, CompartmentOptions, DOMCallbacks, GetGlobalForObjectCrossCompartment};
|
||||
use js::jsapi::{HandleId, HandleObject, HandleValue, Heap, JSAutoCompartment, JSClass, JSContext};
|
||||
use js::jsapi::{JSJitInfo, JSObject, JSTraceOp, JSTracer, JSVersion, JSWrapObjectCallbacks};
|
||||
use js::jsapi::{JS_DeletePropertyById1, JS_EnumerateStandardClasses, JS_FireOnNewGlobalObject};
|
||||
use js::jsapi::{JS_DeletePropertyById, JS_EnumerateStandardClasses, JS_FireOnNewGlobalObject};
|
||||
use js::jsapi::{JS_ForwardGetPropertyTo, JS_GetClass, JS_GetLatin1StringCharsAndLength};
|
||||
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_ObjectToOuterObject, JS_ResolveStandardClass, JS_SetProperty};
|
||||
use js::jsapi::{JS_ResolveStandardClass, JS_SetProperty, ToWindowProxyIfWindow};
|
||||
use js::jsapi::{JS_SetReservedSlot, JS_StringHasLatin1Chars, MutableHandleValue, ObjectOpResult};
|
||||
use js::jsapi::{OnNewGlobalHookOption, RootedObject};
|
||||
use js::jsval::{JSVal};
|
||||
use js::jsval::{PrivateValue, UndefinedValue};
|
||||
use js::jsapi::{OnNewGlobalHookOption, RootedObject, RootedValue};
|
||||
use js::jsval::{JSVal, ObjectValue, PrivateValue, UndefinedValue};
|
||||
use js::rust::{GCMethods, ToString};
|
||||
use js::{JS_CALLEE};
|
||||
use libc;
|
||||
|
@ -152,7 +149,8 @@ pub fn get_property_on_prototype(cx: *mut JSContext,
|
|||
return true;
|
||||
}
|
||||
|
||||
JS_ForwardGetPropertyTo(cx, proto.handle(), id, proxy, vp)
|
||||
let receiver = RootedValue::new(cx, ObjectValue(&**proxy.ptr));
|
||||
JS_ForwardGetPropertyTo(cx, proto.handle(), id, receiver.handle(), vp)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,7 +206,7 @@ pub fn is_platform_object(obj: *mut JSObject) -> bool {
|
|||
}
|
||||
// Now for simplicity check for security wrappers before anything else
|
||||
if IsWrapper(obj) {
|
||||
let unwrapped_obj = UnwrapObject(obj, /* stopAtOuter = */ 0);
|
||||
let unwrapped_obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0);
|
||||
if unwrapped_obj.is_null() {
|
||||
return false;
|
||||
}
|
||||
|
@ -302,8 +300,9 @@ pub fn create_dom_global(cx: *mut JSContext,
|
|||
-> *mut JSObject {
|
||||
unsafe {
|
||||
let mut options = CompartmentOptions::default();
|
||||
options.version_ = JSVersion::JSVERSION_ECMA_5;
|
||||
options.traceGlobal_ = trace;
|
||||
options.behaviors_.version_ = JSVersion::JSVERSION_ECMA_5;
|
||||
options.creationOptions_.traceGlobal_ = trace;
|
||||
options.creationOptions_.sharedMemoryAndAtomics_ = true;
|
||||
|
||||
let obj =
|
||||
RootedObject::new(cx,
|
||||
|
@ -338,9 +337,7 @@ pub unsafe fn finalize_global(obj: *mut JSObject) {
|
|||
for idx in 0..PROTO_OR_IFACE_LENGTH as isize {
|
||||
let entry = list.offset(idx);
|
||||
let value = *entry;
|
||||
if <*mut JSObject>::needs_post_barrier(value) {
|
||||
<*mut JSObject>::relocate(entry);
|
||||
}
|
||||
<*mut JSObject>::post_barrier(entry, value, ptr::null_mut());
|
||||
}
|
||||
let _: Box<ProtoOrIfaceArray> = Box::from_raw(protolist);
|
||||
}
|
||||
|
@ -422,7 +419,9 @@ unsafe extern "C" fn pre_wrap(cx: *mut JSContext,
|
|||
_object_passed_to_wrap: HandleObject)
|
||||
-> *mut JSObject {
|
||||
let _ac = JSAutoCompartment::new(cx, obj.get());
|
||||
JS_ObjectToOuterObject(cx, obj)
|
||||
let obj = ToWindowProxyIfWindow(obj.get());
|
||||
assert!(!obj.is_null());
|
||||
obj
|
||||
}
|
||||
|
||||
/// Callback table for use with JS_SetWrapObjectCallbacks
|
||||
|
@ -431,21 +430,13 @@ pub static WRAP_CALLBACKS: JSWrapObjectCallbacks = JSWrapObjectCallbacks {
|
|||
preWrap: Some(pre_wrap),
|
||||
};
|
||||
|
||||
/// Callback to outerize windows.
|
||||
pub unsafe extern "C" fn outerize_global(_cx: *mut JSContext, obj: HandleObject) -> *mut JSObject {
|
||||
debug!("outerizing");
|
||||
let win = root_from_handleobject::<window::Window>(obj).unwrap();
|
||||
let context = win.browsing_context();
|
||||
context.window_proxy()
|
||||
}
|
||||
|
||||
/// Deletes the property `id` from `object`.
|
||||
pub unsafe fn delete_property_by_id(cx: *mut JSContext,
|
||||
object: HandleObject,
|
||||
id: HandleId,
|
||||
bp: *mut ObjectOpResult)
|
||||
-> bool {
|
||||
JS_DeletePropertyById1(cx, object, id, bp)
|
||||
JS_DeletePropertyById(cx, object, id, bp)
|
||||
}
|
||||
|
||||
unsafe fn generic_call(cx: *mut JSContext,
|
||||
|
|
|
@ -12,15 +12,15 @@ use dom::bindings::utils::get_array_index_from_id;
|
|||
use dom::document::Document;
|
||||
use dom::element::Element;
|
||||
use dom::window::Window;
|
||||
use js::JSCLASS_IS_GLOBAL;
|
||||
use js::glue::{CreateWrapperProxyHandler, ProxyTraps, NewWindowProxy};
|
||||
use js::glue::{GetProxyPrivate, SetProxyExtra};
|
||||
use js::jsapi::{Handle, HandleId, HandleObject, JSAutoCompartment, JSAutoRequest, JSContext};
|
||||
use js::jsapi::{JSErrNum, JSObject, JSPropertyDescriptor, JS_DefinePropertyById6};
|
||||
use js::jsapi::{Handle, HandleId, HandleObject, HandleValue, JSAutoCompartment, JSAutoRequest};
|
||||
use js::jsapi::{JSContext, JSPROP_READONLY, JSErrNum, JSObject, PropertyDescriptor, JS_DefinePropertyById};
|
||||
use js::jsapi::{JS_ForwardGetPropertyTo, JS_ForwardSetPropertyTo, JS_GetClass};
|
||||
use js::jsapi::{JS_GetOwnPropertyDescriptorById, JS_HasPropertyById, MutableHandle};
|
||||
use js::jsapi::{MutableHandleValue, ObjectOpResult, RootedObject, RootedValue};
|
||||
use js::jsval::{ObjectValue, UndefinedValue, PrivateValue};
|
||||
use js::{JSCLASS_IS_GLOBAL, JSPROP_READONLY};
|
||||
use js::jsval::{UndefinedValue, PrivateValue};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct BrowsingContext {
|
||||
|
@ -59,7 +59,7 @@ impl BrowsingContext {
|
|||
let object = box BrowsingContext::new_inherited(frame_element);
|
||||
|
||||
let raw = Box::into_raw(object);
|
||||
SetProxyExtra(window_proxy.ptr, 0, PrivateValue(raw as *const _));
|
||||
SetProxyExtra(window_proxy.ptr, 0, &PrivateValue(raw as *const _));
|
||||
|
||||
(*raw).init_reflector(window_proxy.ptr);
|
||||
|
||||
|
@ -131,7 +131,7 @@ unsafe fn GetSubframeWindow(cx: *mut JSContext,
|
|||
unsafe extern "C" fn getOwnPropertyDescriptor(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId,
|
||||
desc: MutableHandle<JSPropertyDescriptor>)
|
||||
desc: MutableHandle<PropertyDescriptor>)
|
||||
-> bool {
|
||||
let window = GetSubframeWindow(cx, proxy, id);
|
||||
if let Some(window) = window {
|
||||
|
@ -159,7 +159,7 @@ unsafe extern "C" fn getOwnPropertyDescriptor(cx: *mut JSContext,
|
|||
unsafe extern "C" fn defineProperty(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
id: HandleId,
|
||||
desc: Handle<JSPropertyDescriptor>,
|
||||
desc: Handle<PropertyDescriptor>,
|
||||
res: *mut ObjectOpResult)
|
||||
-> bool {
|
||||
if get_array_index_from_id(cx, id).is_some() {
|
||||
|
@ -172,7 +172,7 @@ unsafe extern "C" fn defineProperty(cx: *mut JSContext,
|
|||
}
|
||||
|
||||
let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object());
|
||||
JS_DefinePropertyById6(cx, target.handle(), id, desc, res)
|
||||
JS_DefinePropertyById(cx, target.handle(), id, desc, res)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
@ -200,7 +200,7 @@ unsafe extern "C" fn has(cx: *mut JSContext,
|
|||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn get(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
receiver: HandleObject,
|
||||
receiver: HandleValue,
|
||||
id: HandleId,
|
||||
vp: MutableHandleValue)
|
||||
-> bool {
|
||||
|
@ -217,9 +217,9 @@ unsafe extern "C" fn get(cx: *mut JSContext,
|
|||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn set(cx: *mut JSContext,
|
||||
proxy: HandleObject,
|
||||
receiver: HandleObject,
|
||||
id: HandleId,
|
||||
vp: MutableHandleValue,
|
||||
v: HandleValue,
|
||||
receiver: HandleValue,
|
||||
res: *mut ObjectOpResult)
|
||||
-> bool {
|
||||
if get_array_index_from_id(cx, id).is_some() {
|
||||
|
@ -229,12 +229,11 @@ unsafe extern "C" fn set(cx: *mut JSContext,
|
|||
}
|
||||
|
||||
let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object());
|
||||
let receiver = RootedValue::new(cx, ObjectValue(&**receiver.ptr));
|
||||
JS_ForwardSetPropertyTo(cx,
|
||||
target.handle(),
|
||||
id,
|
||||
vp.to_handle(),
|
||||
receiver.handle(),
|
||||
v,
|
||||
receiver,
|
||||
res)
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,9 @@ impl ImageData {
|
|||
let js_object: *mut JSObject = JS_NewUint8ClampedArray(cx, width * height * 4);
|
||||
|
||||
if let Some(vec) = data {
|
||||
let js_object_data: *mut uint8_t = JS_GetUint8ClampedArrayData(js_object, ptr::null());
|
||||
let mut is_shared = false;
|
||||
let js_object_data: *mut uint8_t = JS_GetUint8ClampedArrayData(js_object, &mut is_shared, ptr::null());
|
||||
assert!(!is_shared);
|
||||
ptr::copy_nonoverlapping(vec.as_ptr(), js_object_data, vec.len())
|
||||
}
|
||||
(*imagedata).data.set(js_object);
|
||||
|
@ -53,7 +55,10 @@ impl ImageData {
|
|||
pub fn get_data_array(&self, global: &GlobalRef) -> Vec<u8> {
|
||||
unsafe {
|
||||
let cx = global.get_cx();
|
||||
let data: *const uint8_t = JS_GetUint8ClampedArrayData(self.Data(cx), ptr::null()) as *const uint8_t;
|
||||
let mut is_shared = false;
|
||||
let data: *const uint8_t =
|
||||
JS_GetUint8ClampedArrayData(self.Data(cx), &mut is_shared, ptr::null()) as *const uint8_t;
|
||||
assert!(!is_shared);
|
||||
let len = self.Width() * self.Height() * 4;
|
||||
slice::from_raw_parts(data, len as usize).to_vec()
|
||||
}
|
||||
|
|
|
@ -76,8 +76,9 @@ impl TextEncoderMethods for TextEncoder {
|
|||
let encoded = self.encoder.encode(&input.0, EncoderTrap::Strict).unwrap();
|
||||
let length = encoded.len() as u32;
|
||||
let js_object: *mut JSObject = JS_NewUint8Array(cx, length);
|
||||
|
||||
let js_object_data: *mut uint8_t = JS_GetUint8ArrayData(js_object, ptr::null());
|
||||
let mut is_shared = false;
|
||||
let js_object_data: *mut uint8_t = JS_GetUint8ArrayData(js_object, &mut is_shared, ptr::null());
|
||||
assert!(!is_shared);
|
||||
ptr::copy_nonoverlapping(encoded.as_ptr(), js_object_data, length as usize);
|
||||
js_object
|
||||
}
|
||||
|
|
|
@ -604,7 +604,9 @@ impl Runnable for MessageReceivedTask {
|
|||
BinaryType::Arraybuffer => {
|
||||
let len = data.len() as uint32_t;
|
||||
let buf = JS_NewArrayBuffer(cx, len);
|
||||
let buf_data: *mut uint8_t = JS_GetArrayBufferData(buf, ptr::null());
|
||||
let mut is_shared = false;
|
||||
let buf_data: *mut uint8_t = JS_GetArrayBufferData(buf, &mut is_shared, ptr::null());
|
||||
assert!(!is_shared);
|
||||
ptr::copy_nonoverlapping(data.as_ptr(), buf_data, len as usize);
|
||||
buf.to_jsval(cx, message.handle_mut());
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ use gfx_traits::LayerId;
|
|||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use js::jsapi::{Evaluate2, MutableHandleValue};
|
||||
use js::jsapi::{HandleValue, JSContext};
|
||||
use js::jsapi::{JSAutoCompartment, JSAutoRequest, JS_GC, JS_GetRuntime};
|
||||
use js::jsapi::{JSAutoCompartment, JSAutoRequest, JS_GC, JS_GetRuntime, SetWindowProxy};
|
||||
use js::rust::CompileOptionsWrapper;
|
||||
use js::rust::Runtime;
|
||||
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
|
||||
|
@ -1192,9 +1192,15 @@ impl Window {
|
|||
self.layout_rpc.margin_style()
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn init_browsing_context(&self, browsing_context: &BrowsingContext) {
|
||||
assert!(self.browsing_context.get().is_none());
|
||||
self.browsing_context.set(Some(&browsing_context));
|
||||
let window = self.reflector().get_jsobject();
|
||||
let cx = self.get_cx();
|
||||
let _ar = JSAutoRequest::new(cx);
|
||||
let _ac = JSAutoCompartment::new(cx, window.get());
|
||||
unsafe { SetWindowProxy(cx, window, browsing_context.reflector().get_jsobject()); }
|
||||
}
|
||||
|
||||
/// Commence a new URL load which will either replace this window or scroll to a fragment.
|
||||
|
|
|
@ -18,7 +18,8 @@ use dom::window::{base64_atob, base64_btoa};
|
|||
use dom::workerlocation::WorkerLocation;
|
||||
use dom::workernavigator::WorkerNavigator;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use js::jsapi::{HandleValue, JSAutoRequest, JSContext, JSRuntime};
|
||||
use js::jsapi::{HandleValue, JSAutoRequest, JSContext, JSRuntime, RootedValue};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::Runtime;
|
||||
use msg::constellation_msg::{ConstellationChan, PipelineId};
|
||||
use net_traits::{LoadContext, ResourceThread, load_whole_resource};
|
||||
|
@ -216,6 +217,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
|
|||
};
|
||||
}
|
||||
|
||||
let mut rval = RootedValue::new(self.runtime.cx(), UndefinedValue());
|
||||
for url in urls {
|
||||
let (url, source) = match load_whole_resource(LoadContext::Script, &self.resource_thread, url, None) {
|
||||
Err(_) => return Err(Error::Network),
|
||||
|
@ -225,7 +227,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
|
|||
};
|
||||
|
||||
match self.runtime.evaluate_script(
|
||||
self.reflector().get_jsobject(), source, url.to_string(), 1) {
|
||||
self.reflector().get_jsobject(), &source, url.as_str(), 1, rval.handle_mut()) {
|
||||
Ok(_) => (),
|
||||
Err(_) => {
|
||||
println!("evaluate_script failed");
|
||||
|
@ -316,8 +318,9 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
|
|||
|
||||
impl WorkerGlobalScope {
|
||||
pub fn execute_script(&self, source: DOMString) {
|
||||
let mut rval = RootedValue::new(self.runtime.cx(), UndefinedValue());
|
||||
match self.runtime.evaluate_script(
|
||||
self.reflector().get_jsobject(), String::from(source), self.worker_url.to_string(), 1) {
|
||||
self.reflector().get_jsobject(), &source, self.worker_url.as_str(), 1, rval.handle_mut()) {
|
||||
Ok(_) => (),
|
||||
Err(_) => {
|
||||
if self.is_closing() {
|
||||
|
|
|
@ -17,12 +17,12 @@ use js::jsapi::{JSGCMode, JSGCParamKey, JS_SetGCParameter, JS_SetGlobalJitCompil
|
|||
use js::jsapi::{JSJitCompilerOption, JS_SetOffthreadIonCompilationEnabled, JS_SetParallelParsingEnabled};
|
||||
use js::jsapi::{JSObject, RuntimeOptionsRef, SetPreserveWrapperCallback};
|
||||
use js::rust::Runtime;
|
||||
use libc;
|
||||
use profile_traits::mem::{Report, ReportKind, ReportsChan};
|
||||
use script_thread::{Runnable, STACK_ROOTS, trace_thread};
|
||||
use std::cell::Cell;
|
||||
use std::io::{Write, stdout};
|
||||
use std::marker::PhantomData;
|
||||
use std::os;
|
||||
use std::ptr;
|
||||
use time::{Tm, now};
|
||||
use util::opts;
|
||||
|
@ -362,7 +362,7 @@ unsafe extern "C" fn gc_slice_callback(_rt: *mut JSRuntime, progress: GCProgress
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn debug_gc_callback(_rt: *mut JSRuntime, status: JSGCStatus, _data: *mut libc::c_void) {
|
||||
unsafe extern "C" fn debug_gc_callback(_rt: *mut JSRuntime, status: JSGCStatus, _data: *mut os::raw::c_void) {
|
||||
match status {
|
||||
JSGCStatus::JSGC_BEGIN => thread_state::enter(thread_state::IN_GC),
|
||||
JSGCStatus::JSGC_END => thread_state::exit(thread_state::IN_GC),
|
||||
|
@ -370,7 +370,7 @@ unsafe extern "C" fn debug_gc_callback(_rt: *mut JSRuntime, status: JSGCStatus,
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern fn trace_rust_roots(tr: *mut JSTracer, _data: *mut libc::c_void) {
|
||||
unsafe extern fn trace_rust_roots(tr: *mut JSTracer, _data: *mut os::raw::c_void) {
|
||||
trace_thread(tr);
|
||||
trace_traceables(tr);
|
||||
trace_roots(tr);
|
||||
|
|
|
@ -51,9 +51,9 @@ use hyper::method::Method;
|
|||
use hyper::mime::{Mime, SubLevel, TopLevel};
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::glue::GetWindowProxyClass;
|
||||
use js::jsapi::{DOMProxyShadowsResult, HandleId, HandleObject, RootedValue};
|
||||
use js::jsapi::{JSAutoRequest, JS_SetWrapObjectCallbacks};
|
||||
use js::jsapi::{JSContext, JSTracer};
|
||||
use js::jsapi::{JSAutoRequest, JSContext, JS_SetWrapObjectCallbacks, JSTracer, SetWindowProxyClass};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::Runtime;
|
||||
use layout_interface::{ReflowQueryType};
|
||||
|
@ -515,6 +515,7 @@ impl ScriptThread {
|
|||
unsafe {
|
||||
JS_SetWrapObjectCallbacks(runtime.rt(),
|
||||
&WRAP_CALLBACKS);
|
||||
SetWindowProxyClass(runtime.rt(), GetWindowProxyClass());
|
||||
}
|
||||
|
||||
// Ask the router to proxy IPC messages from the devtools to us.
|
||||
|
|
6
components/servo/Cargo.lock
generated
6
components/servo/Cargo.lock
generated
|
@ -1019,13 +1019,13 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "js"
|
||||
version = "0.1.2"
|
||||
source = "git+https://github.com/servo/rust-mozjs#efe805affa75d776316e9ea6113f85cdad1e82ed"
|
||||
source = "git+https://github.com/servo/rust-mozjs#8ad6c1148fd77e5b9dc2ce0f0ab40d4f455f6f4e"
|
||||
dependencies = [
|
||||
"heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)",
|
||||
"num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1270,7 +1270,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "mozjs_sys"
|
||||
version = "0.0.0"
|
||||
source = "git+https://github.com/servo/mozjs#3122a1e1a80b78377ae1ce8e7edd4ad3bcbb3d65"
|
||||
source = "git+https://github.com/servo/mozjs#2af5849a97a9f18acd482940ba3fa0c6797ed7eb"
|
||||
dependencies = [
|
||||
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libz-sys 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
6
ports/cef/Cargo.lock
generated
6
ports/cef/Cargo.lock
generated
|
@ -940,13 +940,13 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "js"
|
||||
version = "0.1.2"
|
||||
source = "git+https://github.com/servo/rust-mozjs#efe805affa75d776316e9ea6113f85cdad1e82ed"
|
||||
source = "git+https://github.com/servo/rust-mozjs#8ad6c1148fd77e5b9dc2ce0f0ab40d4f455f6f4e"
|
||||
dependencies = [
|
||||
"heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)",
|
||||
"num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1184,7 +1184,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "mozjs_sys"
|
||||
version = "0.0.0"
|
||||
source = "git+https://github.com/servo/mozjs#3122a1e1a80b78377ae1ce8e7edd4ad3bcbb3d65"
|
||||
source = "git+https://github.com/servo/mozjs#2af5849a97a9f18acd482940ba3fa0c6797ed7eb"
|
||||
dependencies = [
|
||||
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libz-sys 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
6
ports/gonk/Cargo.lock
generated
6
ports/gonk/Cargo.lock
generated
|
@ -923,13 +923,13 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "js"
|
||||
version = "0.1.2"
|
||||
source = "git+https://github.com/servo/rust-mozjs#efe805affa75d776316e9ea6113f85cdad1e82ed"
|
||||
source = "git+https://github.com/servo/rust-mozjs#8ad6c1148fd77e5b9dc2ce0f0ab40d4f455f6f4e"
|
||||
dependencies = [
|
||||
"heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mozjs_sys 0.0.0 (git+https://github.com/servo/mozjs)",
|
||||
"num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1167,7 +1167,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "mozjs_sys"
|
||||
version = "0.0.0"
|
||||
source = "git+https://github.com/servo/mozjs#3122a1e1a80b78377ae1ce8e7edd4ad3bcbb3d65"
|
||||
source = "git+https://github.com/servo/mozjs#2af5849a97a9f18acd482940ba3fa0c6797ed7eb"
|
||||
dependencies = [
|
||||
"libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libz-sys 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -30,7 +30,6 @@ var ecmaGlobals = [
|
|||
"Int32Array",
|
||||
"Int8Array",
|
||||
"InternalError",
|
||||
"Intl",
|
||||
"Iterator",
|
||||
"JSON",
|
||||
"Map",
|
||||
|
@ -41,19 +40,11 @@ var ecmaGlobals = [
|
|||
"Proxy",
|
||||
"RangeError",
|
||||
"ReferenceError",
|
||||
"Reflect",
|
||||
"RegExp",
|
||||
"SIMD",
|
||||
"Set",
|
||||
"SharedArrayBuffer",
|
||||
"SharedFloat32Array",
|
||||
"SharedFloat64Array",
|
||||
"SharedInt16Array",
|
||||
"SharedInt32Array",
|
||||
"SharedInt8Array",
|
||||
"SharedUint16Array",
|
||||
"SharedUint32Array",
|
||||
"SharedUint8Array",
|
||||
"SharedUint8ClampedArray",
|
||||
"StopIteration",
|
||||
"String",
|
||||
"Symbol",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue