diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index c9ea798b1d9..b723f16dca0 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -336,7 +336,7 @@ class CGMethodCall(CGThing): # Check for vanilla JS objects # XXXbz Do we need to worry about security wrappers? - pickFirstSignature("%s.is_object() && !IsPlatformObject(%s.to_object())" % + pickFirstSignature("%s.is_object() && !is_platform_object(%s.to_object())" % (distinguishingArg, distinguishingArg), lambda s: (s[1][distinguishingIndex].type.isCallback() or s[1][distinguishingIndex].type.isCallbackInterface() or @@ -719,7 +719,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None, handleInvalidEnumValueCode = "return 1;" template = ( - "match FindEnumStringIndex(cx, ${val}, %(values)s) {\n" + "match find_enum_string_index(cx, ${val}, %(values)s) {\n" " Err(_) => { %(exceptionCode)s },\n" " Ok(None) => { %(handleInvalidEnumValueCode)s },\n" " Ok(Some(index)) => {\n" @@ -1811,7 +1811,7 @@ assert!(!obj.is_null());\ """ % (descriptor.name, parent) else: if descriptor.isGlobal(): - create += "let obj = CreateDOMGlobal(aCx, &Class.base as *const js::Class as *const JSClass);\n" + create += "let obj = create_dom_global(aCx, &Class.base as *const js::Class as *const JSClass);\n" else: create += ("let obj = with_compartment(aCx, proto, || {\n" " JS_NewObject(aCx, &Class.base as *const js::Class as *const JSClass, &*proto, &*%s)\n" @@ -1905,10 +1905,10 @@ class CGAbstractExternMethod(CGAbstractMethod): class PropertyArrays(): def __init__(self, descriptor): - self.staticMethods = MethodDefiner(descriptor, "StaticMethods", - static=True) - self.staticAttrs = AttrDefiner(descriptor, "StaticAttributes", - static=True) + self.static_methods = MethodDefiner(descriptor, "StaticMethods", + static=True) + self.static_attrs = AttrDefiner(descriptor, "StaticAttributes", + static=True) self.methods = MethodDefiner(descriptor, "Methods", static=False) self.attrs = AttrDefiner(descriptor, "Attributes", static=False) self.consts = ConstDefiner(descriptor, "Constants") @@ -1916,7 +1916,7 @@ class PropertyArrays(): @staticmethod def arrayNames(): - return [ "staticMethods", "staticAttrs", "methods", "attrs", "consts" ] + return ["static_methods", "static_attrs", "methods", "attrs", "consts"] def variableNames(self): names = {} @@ -1991,7 +1991,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): constructHook = CONSTRUCT_HOOK_NAME constructArgs = methodLength(self.descriptor.interface.ctor()) else: - constructHook = "ThrowingConstructor" + constructHook = "throwing_constructor" constructArgs = 0 constructor = 'Some((%s as NonNullJSNative, "%s", %d))' % ( @@ -2001,10 +2001,10 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): constructor = 'None' call = """\ -return CreateInterfaceObjects2(aCx, aGlobal, aReceiver, parentProto, - &PrototypeClass, %s, - %s, - &sNativeProperties);""" % (constructor, domClass) +return do_create_interface_objects(aCx, aGlobal, aReceiver, parentProto, + &PrototypeClass, %s, + %s, + &sNativeProperties);""" % (constructor, domClass) return CGList([ CGGeneric(getParentProto), @@ -2034,7 +2034,7 @@ class CGGetPerInterfaceObject(CGAbstractMethod): assert!(((*JS_GetClass(aGlobal)).flags & JSCLASS_DOM_GLOBAL) != 0); /* Check to see whether the interface objects are already installed */ -let protoOrIfaceArray = GetProtoOrIfaceArray(aGlobal); +let protoOrIfaceArray = get_proto_or_iface_array(aGlobal); let cachedObject: *mut JSObject = *protoOrIfaceArray.offset(%s as int); if cachedObject.is_null() { let tmp: *mut JSObject = CreateInterfaceObjects(aCx, aGlobal, aReceiver); @@ -3627,7 +3627,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): setOrIndexedGet = "" if indexedGetter or indexedSetter: - setOrIndexedGet += "let index = GetArrayIndexFromId(cx, id);\n" + setOrIndexedGet += "let index = get_array_index_from_id(cx, id);\n" if indexedGetter: readonly = toStringBool(self.descriptor.operations['IndexedSetter'] is None) @@ -3680,7 +3680,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): # ResolveOwnProperty or EnumerateOwnProperties filter out named # properties that shadow prototype properties. namedGet = ("\n" + - "if !set && RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" + + "if !set && RUST_JSID_IS_STRING(id) != 0 && !has_property_on_prototype(cx, proxy, id) {\n" + " let name = jsid_to_str(cx, id);\n" + " let this = UnwrapProxy(proxy);\n" + " let this = JS::from_raw(this);\n" + @@ -3725,7 +3725,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod): if indexedSetter: if not (self.descriptor.operations['IndexedCreator'] is indexedSetter): raise TypeError("Can't handle creator that's different from the setter") - set += ("let index = GetArrayIndexFromId(cx, id);\n" + + set += ("let index = get_array_index_from_id(cx, id);\n" + "if index.is_some() {\n" + " let index = index.unwrap();\n" + " let this = UnwrapProxy(proxy);\n" + @@ -3735,7 +3735,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod): " return true;\n" + "}\n") elif self.descriptor.operations['IndexedGetter']: - set += ("if GetArrayIndexFromId(cx, id).is_some() {\n" + + set += ("if get_array_index_from_id(cx, id).is_some() {\n" + " return false;\n" + " //return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" + "}\n") % self.descriptor.name @@ -3800,7 +3800,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod): def getBody(self): indexedGetter = self.descriptor.operations['IndexedGetter'] if indexedGetter: - indexed = ("let index = GetArrayIndexFromId(cx, id);\n" + + indexed = ("let index = get_array_index_from_id(cx, id);\n" + "if index.is_some() {\n" + " let index = index.unwrap();\n" + " let this = UnwrapProxy(proxy);\n" + @@ -3815,7 +3815,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod): namedGetter = self.descriptor.operations['NamedGetter'] if namedGetter: - named = ("if RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" + + named = ("if RUST_JSID_IS_STRING(id) != 0 && !has_property_on_prototype(cx, proxy, id) {\n" + " let name = jsid_to_str(cx, id);\n" + " let this = UnwrapProxy(proxy);\n" + " let this = JS::from_raw(this);\n" + @@ -3873,7 +3873,7 @@ if !expando.is_null() { indexedGetter = self.descriptor.operations['IndexedGetter'] if indexedGetter: - getIndexedOrExpando = ("let index = GetArrayIndexFromId(cx, id);\n" + + getIndexedOrExpando = ("let index = get_array_index_from_id(cx, id);\n" + "if index.is_some() {\n" + " let index = index.unwrap();\n" + " let this = UnwrapProxy(proxy);\n" + @@ -3908,7 +3908,7 @@ if !expando.is_null() { %s let mut found = false; -if !GetPropertyOnPrototype(cx, proxy, id, &mut found, vp) { +if !get_property_on_prototype(cx, proxy, id, &mut found, vp) { return false; } @@ -4548,17 +4548,17 @@ class CGBindingRoot(CGThing): 'dom::bindings::js::{JS, JSRef, Root, RootedReference, Temporary}', 'dom::bindings::js::{OptionalRootable, OptionalRootedRootable, ResultRootable}', 'dom::bindings::js::{OptionalRootedReference, OptionalOptionalRootedRootable}', - 'dom::bindings::utils::{CreateDOMGlobal, CreateInterfaceObjects2}', + 'dom::bindings::utils::{create_dom_global, do_create_interface_objects}', 'dom::bindings::utils::ConstantSpec', 'dom::bindings::utils::{DOMClass}', 'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}', - 'dom::bindings::utils::{FindEnumStringIndex, GetArrayIndexFromId}', - 'dom::bindings::utils::{GetPropertyOnPrototype, GetProtoOrIfaceArray}', - 'dom::bindings::utils::HasPropertyOnPrototype', - 'dom::bindings::utils::IsPlatformObject', + 'dom::bindings::utils::{find_enum_string_index, get_array_index_from_id}', + 'dom::bindings::utils::{get_property_on_prototype, get_proto_or_iface_array}', + 'dom::bindings::utils::has_property_on_prototype', + 'dom::bindings::utils::is_platform_object', 'dom::bindings::utils::{Reflectable}', 'dom::bindings::utils::{squirrel_away_unique}', - 'dom::bindings::utils::{ThrowingConstructor}', + 'dom::bindings::utils::throwing_constructor', 'dom::bindings::utils::get_dictionary_property', 'dom::bindings::utils::{NativeProperties, NativePropertyHooks}', 'dom::bindings::utils::ConstantVal::{IntVal, UintVal}', diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 2819018cf27..5c68dfce33d 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -24,7 +24,7 @@ use js::glue::{IsWrapper, RUST_JSID_IS_INT, RUST_JSID_TO_INT}; use js::jsapi::{JS_AlreadyHasOwnProperty, JS_NewFunction}; use js::jsapi::{JS_DefineProperties, JS_ForwardGetPropertyTo}; use js::jsapi::{JS_GetClass, JS_LinkConstructorAndPrototype, JS_GetStringCharsAndLength}; -use js::jsapi::{JS_ObjectIsRegExp, JS_ObjectIsDate, JSHandleObject}; +use js::jsapi::JSHandleObject; use js::jsapi::JS_GetFunctionObject; use js::jsapi::{JS_HasPropertyById, JS_GetPrototype}; use js::jsapi::{JS_GetProperty, JS_HasProperty}; @@ -55,10 +55,12 @@ pub struct GlobalStaticData { pub windowproxy_handler: WindowProxyHandler, } -/// Creates a new GlobalStaticData. -pub fn GlobalStaticData() -> GlobalStaticData { - GlobalStaticData { - windowproxy_handler: browsercontext::new_window_proxy_handler(), +impl GlobalStaticData { + /// Creates a new GlobalStaticData. + pub fn new() -> GlobalStaticData { + GlobalStaticData { + windowproxy_handler: browsercontext::new_window_proxy_handler(), + } } } @@ -152,7 +154,7 @@ unsafe impl Sync for DOMJSClass {} /// Returns the ProtoOrIfaceArray for the given global object. /// Fails if `global` is not a DOM global object. -pub fn GetProtoOrIfaceArray(global: *mut JSObject) -> *mut *mut JSObject { +pub fn get_proto_or_iface_array(global: *mut JSObject) -> *mut *mut JSObject { unsafe { assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0); JS_GetReservedSlot(global, DOM_PROTOTYPE_SLOT).to_private() as *mut *mut JSObject @@ -169,9 +171,9 @@ pub struct NativeProperties { /// Constants for the interface. pub consts: Option<&'static [ConstantSpec]>, /// Static methods for the interface. - pub staticMethods: Option<&'static [JSFunctionSpec]>, + pub static_methods: Option<&'static [JSFunctionSpec]>, /// Static attributes for the interface. - pub staticAttrs: Option<&'static [JSPropertySpec]>, + pub static_attrs: Option<&'static [JSPropertySpec]>, } unsafe impl Sync for NativeProperties {} @@ -182,26 +184,28 @@ pub type NonNullJSNative = /// Creates the *interface prototype object* and the *interface object* (if /// needed). /// Fails on JSAPI failure. -pub fn CreateInterfaceObjects2(cx: *mut JSContext, global: *mut JSObject, receiver: *mut JSObject, - protoProto: *mut JSObject, - protoClass: &'static JSClass, - constructor: Option<(NonNullJSNative, &'static str, u32)>, - domClass: *const DOMClass, - members: &'static NativeProperties) -> *mut JSObject { - let proto = CreateInterfacePrototypeObject(cx, global, protoProto, - protoClass, members); +pub fn do_create_interface_objects(cx: *mut JSContext, global: *mut JSObject, + receiver: *mut JSObject, + proto_proto: *mut JSObject, + proto_class: &'static JSClass, + constructor: Option<(NonNullJSNative, &'static str, u32)>, + dom_class: *const DOMClass, + members: &'static NativeProperties) + -> *mut JSObject { + let proto = create_interface_prototype_object(cx, global, proto_proto, + proto_class, members); unsafe { JS_SetReservedSlot(proto, DOM_PROTO_INSTANCE_CLASS_SLOT, - PrivateValue(domClass as *const libc::c_void)); + PrivateValue(dom_class as *const libc::c_void)); } match constructor { Some((native, name, nargs)) => { let s = CString::from_slice(name.as_bytes()); - CreateInterfaceObject(cx, global, receiver, - native, nargs, proto, - members, s.as_ptr()) + create_interface_object(cx, global, receiver, + native, nargs, proto, + members, s.as_ptr()) }, None => (), } @@ -211,31 +215,36 @@ pub fn CreateInterfaceObjects2(cx: *mut JSContext, global: *mut JSObject, receiv /// Creates the *interface object*. /// Fails on JSAPI failure. -fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *mut JSObject, - constructorNative: NonNullJSNative, - ctorNargs: u32, proto: *mut JSObject, - members: &'static NativeProperties, - name: *const libc::c_char) { +fn create_interface_object(cx: *mut JSContext, global: *mut JSObject, + receiver: *mut JSObject, + constructor_native: NonNullJSNative, + ctor_nargs: u32, proto: *mut JSObject, + members: &'static NativeProperties, + name: *const libc::c_char) { unsafe { - let fun = JS_NewFunction(cx, Some(constructorNative), ctorNargs, + let fun = JS_NewFunction(cx, Some(constructor_native), ctor_nargs, JSFUN_CONSTRUCTOR, global, name); assert!(!fun.is_null()); let constructor = JS_GetFunctionObject(fun); assert!(!constructor.is_null()); - match members.staticMethods { - Some(staticMethods) => DefineMethods(cx, constructor, staticMethods), + match members.static_methods { + Some(static_methods) => { + define_methods(cx, constructor, static_methods) + }, _ => (), } - match members.staticAttrs { - Some(staticProperties) => DefineProperties(cx, constructor, staticProperties), + match members.static_attrs { + Some(static_properties) => { + define_properties(cx, constructor, static_properties) + }, _ => (), } match members.consts { - Some(constants) => DefineConstants(cx, constructor, constants), + Some(constants) => define_constants(cx, constructor, constants), _ => (), } @@ -243,10 +252,10 @@ fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *m assert!(JS_LinkConstructorAndPrototype(cx, constructor, proto) != 0); } - let mut alreadyDefined = 0; - assert!(JS_AlreadyHasOwnProperty(cx, receiver, name, &mut alreadyDefined) != 0); + let mut already_defined = 0; + assert!(JS_AlreadyHasOwnProperty(cx, receiver, name, &mut already_defined) != 0); - if alreadyDefined == 0 { + if already_defined == 0 { assert!(JS_DefineProperty(cx, receiver, name, ObjectValue(&*constructor), None, None, 0) != 0); @@ -256,7 +265,8 @@ fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *m /// Defines constants on `obj`. /// Fails on JSAPI failure. -fn DefineConstants(cx: *mut JSContext, obj: *mut JSObject, constants: &'static [ConstantSpec]) { +fn define_constants(cx: *mut JSContext, obj: *mut JSObject, + constants: &'static [ConstantSpec]) { for spec in constants.iter() { unsafe { assert!(JS_DefineProperty(cx, obj, spec.name.as_ptr() as *const libc::c_char, @@ -270,7 +280,8 @@ fn DefineConstants(cx: *mut JSContext, obj: *mut JSObject, constants: &'static [ /// Defines methods on `obj`. The last entry of `methods` must contain zeroed /// memory. /// Fails on JSAPI failure. -fn DefineMethods(cx: *mut JSContext, obj: *mut JSObject, methods: &'static [JSFunctionSpec]) { +fn define_methods(cx: *mut JSContext, obj: *mut JSObject, + methods: &'static [JSFunctionSpec]) { unsafe { assert!(JS_DefineFunctions(cx, obj, methods.as_ptr()) != 0); } @@ -279,7 +290,8 @@ fn DefineMethods(cx: *mut JSContext, obj: *mut JSObject, methods: &'static [JSFu /// Defines attributes on `obj`. The last entry of `properties` must contain /// zeroed memory. /// Fails on JSAPI failure. -fn DefineProperties(cx: *mut JSContext, obj: *mut JSObject, properties: &'static [JSPropertySpec]) { +fn define_properties(cx: *mut JSContext, obj: *mut JSObject, + properties: &'static [JSPropertySpec]) { unsafe { assert!(JS_DefineProperties(cx, obj, properties.as_ptr()) != 0); } @@ -287,36 +299,39 @@ fn DefineProperties(cx: *mut JSContext, obj: *mut JSObject, properties: &'static /// Creates the *interface prototype object*. /// Fails on JSAPI failure. -fn CreateInterfacePrototypeObject(cx: *mut JSContext, global: *mut JSObject, - parentProto: *mut JSObject, - protoClass: &'static JSClass, - members: &'static NativeProperties) -> *mut JSObject { +fn create_interface_prototype_object(cx: *mut JSContext, global: *mut JSObject, + parent_proto: *mut JSObject, + proto_class: &'static JSClass, + members: &'static NativeProperties) + -> *mut JSObject { unsafe { - let ourProto = JS_NewObjectWithUniqueType(cx, protoClass, &*parentProto, &*global); - assert!(!ourProto.is_null()); + let our_proto = JS_NewObjectWithUniqueType(cx, proto_class, + &*parent_proto, &*global); + assert!(!our_proto.is_null()); match members.methods { - Some(methods) => DefineMethods(cx, ourProto, methods), + Some(methods) => define_methods(cx, our_proto, methods), _ => (), } match members.attrs { - Some(properties) => DefineProperties(cx, ourProto, properties), + Some(properties) => define_properties(cx, our_proto, properties), _ => (), } match members.consts { - Some(constants) => DefineConstants(cx, ourProto, constants), + Some(constants) => define_constants(cx, our_proto, constants), _ => (), } - return ourProto; + return our_proto; } } /// A throwing constructor, for those interfaces that have neither /// `NoInterfaceObject` nor `Constructor`. -pub unsafe extern fn ThrowingConstructor(cx: *mut JSContext, _argc: c_uint, _vp: *mut JSVal) -> JSBool { +pub unsafe extern fn throwing_constructor(cx: *mut JSContext, _argc: c_uint, + _vp: *mut JSVal) -> JSBool { throw_type_error(cx, "Illegal constructor."); return 0; } @@ -324,10 +339,11 @@ pub unsafe extern fn ThrowingConstructor(cx: *mut JSContext, _argc: c_uint, _vp: /// Construct and cache the ProtoOrIfaceArray for the given global. /// Fails if the argument is not a DOM global. pub fn initialize_global(global: *mut JSObject) { - let protoArray = box () ([0 as *mut JSObject; PrototypeList::ID::Count as uint]); + let proto_array = box () + ([0 as *mut JSObject; PrototypeList::ID::Count as uint]); unsafe { assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0); - let box_ = squirrel_away_unique(protoArray); + let box_ = squirrel_away_unique(proto_array); JS_SetReservedSlot(global, DOM_PROTOTYPE_SLOT, PrivateValue(box_ as *const libc::c_void)); @@ -394,8 +410,9 @@ impl Reflector { /// set to true and `*vp` to the value, otherwise `*found` is set to false. /// /// Returns false on JSAPI failure. -pub fn GetPropertyOnPrototype(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, found: *mut bool, - vp: *mut JSVal) -> bool { +pub fn get_property_on_prototype(cx: *mut JSContext, proxy: *mut JSObject, + id: jsid, found: *mut bool, vp: *mut JSVal) + -> bool { unsafe { //let proto = GetObjectProto(proxy); let proto = JS_GetPrototype(proxy); @@ -403,13 +420,13 @@ pub fn GetPropertyOnPrototype(cx: *mut JSContext, proxy: *mut JSObject, id: jsid *found = false; return true; } - let mut hasProp = 0; - if JS_HasPropertyById(cx, proto, id, &mut hasProp) == 0 { + let mut has_property = 0; + if JS_HasPropertyById(cx, proto, id, &mut has_property) == 0 { return false; } - *found = hasProp != 0; + *found = has_property != 0; let no_output = vp.is_null(); - if hasProp == 0 || no_output { + if has_property == 0 || no_output { return true; } @@ -419,7 +436,7 @@ pub fn GetPropertyOnPrototype(cx: *mut JSContext, proxy: *mut JSObject, id: jsid /// Get an array index from the given `jsid`. Returns `None` if the given /// `jsid` is not an integer. -pub fn GetArrayIndexFromId(_cx: *mut JSContext, id: jsid) -> Option { +pub fn get_array_index_from_id(_cx: *mut JSContext, id: jsid) -> Option { unsafe { if RUST_JSID_IS_INT(id) != 0 { return Some(RUST_JSID_TO_INT(id) as u32); @@ -445,9 +462,10 @@ pub fn GetArrayIndexFromId(_cx: *mut JSContext, id: jsid) -> Option { /// Find the index of a string given by `v` in `values`. /// Returns `Err(())` on JSAPI failure (there is a pending exception), and /// `Ok(None)` if there was no matching string. -pub fn FindEnumStringIndex(cx: *mut JSContext, - v: JSVal, - values: &[&'static str]) -> Result, ()> { +pub fn find_enum_string_index(cx: *mut JSContext, + v: JSVal, + values: &[&'static str]) + -> Result, ()> { unsafe { let jsstr = JS_ValueToString(cx, v); if jsstr.is_null() { @@ -471,7 +489,7 @@ pub fn FindEnumStringIndex(cx: *mut JSContext, /// Returns wether `obj` is a platform object /// http://heycam.github.io/webidl/#dfn-platform-object -pub fn IsPlatformObject(obj: *mut JSObject) -> bool { +pub fn is_platform_object(obj: *mut JSObject) -> bool { unsafe { // Fast-path the common case let mut clasp = JS_GetClass(obj); @@ -534,21 +552,16 @@ pub fn get_dictionary_property(cx: *mut JSContext, } /// Returns whether `proxy` has a property `id` on its prototype. -pub fn HasPropertyOnPrototype(cx: *mut JSContext, proxy: *mut JSObject, id: jsid) -> bool { +pub fn has_property_on_prototype(cx: *mut JSContext, proxy: *mut JSObject, + id: jsid) -> bool { // MOZ_ASSERT(js::IsProxy(proxy) && js::GetProxyHandler(proxy) == handler); let mut found = false; - return !GetPropertyOnPrototype(cx, proxy, id, &mut found, ptr::null_mut()) || found; -} - -/// Returns whether `obj` can be converted to a callback interface per IDL. -pub fn IsConvertibleToCallbackInterface(cx: *mut JSContext, obj: *mut JSObject) -> bool { - unsafe { - JS_ObjectIsDate(cx, obj) == 0 && JS_ObjectIsRegExp(cx, obj) == 0 - } + return !get_property_on_prototype(cx, proxy, id, &mut found, ptr::null_mut()) || found; } /// Create a DOM global object with the given class. -pub fn CreateDOMGlobal(cx: *mut JSContext, class: *const JSClass) -> *mut JSObject { +pub fn create_dom_global(cx: *mut JSContext, class: *const JSClass) + -> *mut JSObject { unsafe { let obj = JS_NewGlobalObject(cx, class, ptr::null_mut()); if obj.is_null() { diff --git a/components/script/dom/browsercontext.rs b/components/script/dom/browsercontext.rs index f3e52d0f46d..3d486a3fe11 100644 --- a/components/script/dom/browsercontext.rs +++ b/components/script/dom/browsercontext.rs @@ -9,7 +9,7 @@ use dom::bindings::js::{OptionalRootable, OptionalRootedRootable, ResultRootable use dom::bindings::js::{OptionalRootedReference, OptionalOptionalRootedRootable}; use dom::bindings::proxyhandler::{get_property_descriptor, fill_property_descriptor}; use dom::bindings::utils::{Reflectable, WindowProxyHandler}; -use dom::bindings::utils::{GetArrayIndexFromId}; +use dom::bindings::utils::get_array_index_from_id; use dom::document::{Document, DocumentHelpers}; use dom::window::Window; use dom::window::WindowHelpers; @@ -100,7 +100,7 @@ impl SessionHistoryEntry { } unsafe fn GetSubframeWindow(cx: *mut JSContext, proxy: *mut JSObject, id: jsid) -> Option> { - let index = GetArrayIndexFromId(cx, id); + let index = get_array_index_from_id(cx, id); if let Some(index) = index { let target = GetProxyPrivate(proxy).to_object(); let win: Root = unwrap_jsmanaged(target).unwrap().root(); @@ -139,7 +139,7 @@ unsafe extern fn getOwnPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObje unsafe extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, desc: *mut JSPropertyDescriptor) -> bool { - if GetArrayIndexFromId(cx, id).is_some() { + 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 @@ -182,7 +182,7 @@ unsafe extern fn get(cx: *mut JSContext, proxy: *mut JSObject, receiver: *mut JS } unsafe extern fn set(cx: *mut JSContext, proxy: *mut JSObject, _receiver: *mut JSObject, id: jsid, _strict: bool, vp: *mut JSVal) -> bool { - if GetArrayIndexFromId(cx, id).is_some() { + if get_array_index_from_id(cx, id).is_some() { // Reject (which means throw if and only if strict) the set. // FIXME: Throw return true; diff --git a/components/script/page.rs b/components/script/page.rs index 2433f03f2c5..b9dce92fac5 100644 --- a/components/script/page.rs +++ b/components/script/page.rs @@ -133,7 +133,7 @@ impl Page { constellation_chan: ConstellationChan, js_context: Rc) -> Page { let js_info = JSPageInfo { - dom_static: GlobalStaticData(), + dom_static: GlobalStaticData::new(), js_context: js_context, }; let layout_rpc: Box = {