From 65c0eb035829f10ecf7edc884a58bf6954eab786 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Fri, 8 Feb 2013 10:39:01 +0000 Subject: [PATCH] Bug 812669 - Remove XPConnect equality hooks. r=mrbkap --- dom/base/nsDOMClassInfo.cpp | 11 ----- js/xpconnect/idl/nsIXPCScriptable.idl | 8 +--- js/xpconnect/public/xpc_map_end.h | 12 ----- js/xpconnect/src/XPCWrappedNativeJSOps.cpp | 54 +--------------------- js/xpconnect/src/xpcprivate.h | 8 ---- 5 files changed, 4 insertions(+), 89 deletions(-) diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 79b92a25589f..4d6e47192815 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -508,13 +508,11 @@ static const char kDOMStringBundleURL[] = nsIXPCScriptable::WANT_FINALIZE | \ nsIXPCScriptable::WANT_ENUMERATE | \ nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE | \ - nsIXPCScriptable::USE_STUB_EQUALITY_HOOK | \ nsIXPCScriptable::IS_GLOBAL_OBJECT | \ nsIXPCScriptable::WANT_OUTER_OBJECT) #define NODE_SCRIPTABLE_FLAGS \ ((DOM_DEFAULT_SCRIPTABLE_FLAGS | \ - nsIXPCScriptable::USE_STUB_EQUALITY_HOOK | \ nsIXPCScriptable::WANT_ADDPROPERTY) & \ ~nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY) @@ -4177,15 +4175,6 @@ nsDOMClassInfo::HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx, return NS_ERROR_UNEXPECTED; } -NS_IMETHODIMP -nsDOMClassInfo::Equality(nsIXPConnectWrappedNative *wrapper, JSContext * cx, - JSObject * obj, const jsval &val, bool *bp) -{ - NS_WARNING("nsDOMClassInfo::Equality Don't call me!"); - - return NS_ERROR_UNEXPECTED; -} - NS_IMETHODIMP nsDOMClassInfo::OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, JSObject * *_retval) diff --git a/js/xpconnect/idl/nsIXPCScriptable.idl b/js/xpconnect/idl/nsIXPCScriptable.idl index 4fb892b9de1a..569f3ff42082 100644 --- a/js/xpconnect/idl/nsIXPCScriptable.idl +++ b/js/xpconnect/idl/nsIXPCScriptable.idl @@ -19,7 +19,7 @@ * boolean to PR_TRUE before making the call. Implementations may skip writing * to *_retval unless they want to return PR_FALSE. */ -[uuid(c4788e02-3239-490a-8aeb-60fad08303fd)] +[uuid(1236e34a-21e0-423c-a8c8-9b3f1e6d7060)] interface nsIXPCScriptable : nsISupports { /* bitflags used for 'flags' (only 32 bits available!) */ @@ -52,9 +52,8 @@ interface nsIXPCScriptable : nsISupports const uint32_t ALLOW_PROP_MODS_TO_PROTOTYPE = 1 << 25; const uint32_t IS_GLOBAL_OBJECT = 1 << 26; const uint32_t DONT_REFLECT_INTERFACE_NAMES = 1 << 27; - const uint32_t WANT_EQUALITY = 1 << 28; + // Unused bit here! const uint32_t WANT_OUTER_OBJECT = 1 << 29; - const uint32_t USE_STUB_EQUALITY_HOOK = 1 << 30; // The high order bit is RESERVED for consumers of these flags. // No implementor of this interface should ever return flags @@ -134,9 +133,6 @@ interface nsIXPCScriptable : nsISupports in JSContextPtr cx, in JSObjectPtr obj, in jsval val, out boolean bp); - boolean equality(in nsIXPConnectWrappedNative wrapper, - in JSContextPtr cx, in JSObjectPtr obj, in jsval val); - JSObjectPtr outerObject(in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj); diff --git a/js/xpconnect/public/xpc_map_end.h b/js/xpconnect/public/xpc_map_end.h index 634d010e5891..70c40454cb16 100644 --- a/js/xpconnect/public/xpc_map_end.h +++ b/js/xpconnect/public/xpc_map_end.h @@ -77,9 +77,6 @@ XPC_MAP_CLASSNAME::GetScriptableFlags() #ifdef XPC_MAP_WANT_HASINSTANCE nsIXPCScriptable::WANT_HASINSTANCE | #endif -#ifdef XPC_MAP_WANT_EQUALITY - nsIXPCScriptable::WANT_EQUALITY | -#endif #ifdef XPC_MAP_WANT_OUTER_OBJECT nsIXPCScriptable::WANT_OUTER_OBJECT | #endif @@ -175,11 +172,6 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::HasInstance(nsIXPConnectWrappedNative *wrapper, {NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;} #endif -#ifndef XPC_MAP_WANT_EQUALITY -NS_IMETHODIMP XPC_MAP_CLASSNAME::Equality(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, const jsval &val, bool *bp) - {NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;} -#endif - #ifndef XPC_MAP_WANT_OUTER_OBJECT NS_IMETHODIMP XPC_MAP_CLASSNAME::OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, JSObject * *_retval) {NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;} @@ -259,10 +251,6 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::PostCreatePrototype(JSContext *cx, JSObject *pr #undef XPC_MAP_WANT_HASINSTANCE #endif -#ifdef XPC_MAP_WANT_EQUALITY -#undef XPC_MAP_WANT_EQUALITY -#endif - #ifdef XPC_MAP_WANT_OUTER_OBJECT #undef XPC_MAP_WANT_OUTER_OBJECT #endif diff --git a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp index de19564172c3..bc0c1912450e 100644 --- a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp +++ b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp @@ -709,49 +709,6 @@ XPC_WN_NoHelper_Resolve(JSContext *cx, JSHandleObject obj, JSHandleId id) JSPROP_PERMANENT, nullptr); } -nsISupports * -XPC_GetIdentityObject(JSContext *cx, JSObject *obj) -{ - XPCWrappedNative *wrapper = - XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj); - - return wrapper ? wrapper->GetIdentityObject() : nullptr; -} - -JSBool -XPC_WN_Equality(JSContext *cx, JSHandleObject obj, JSHandleValue v, JSBool *bp) -{ - *bp = false; - - JSObject *obj2; - XPCWrappedNative *wrapper = - XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj, nullptr, &obj2); - if (obj2) { - *bp = !JSVAL_IS_PRIMITIVE(v) && (JSVAL_TO_OBJECT(v) == obj2); - - return true; - } - - THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper); - - XPCNativeScriptableInfo* si = wrapper->GetScriptableInfo(); - if (si && si->GetFlags().WantEquality()) { - bool res; - nsresult rv = si->GetCallback()->Equality(wrapper, cx, obj, v, &res); - if (NS_FAILED(rv)) - return Throw(rv, cx); - *bp = res; - } else if (!JSVAL_IS_PRIMITIVE(v)) { - JSObject *other = JSVAL_TO_OBJECT(v); - - *bp = (obj == other || - XPC_GetIdentityObject(cx, obj) == - XPC_GetIdentityObject(cx, other)); - } - - return true; -} - static JSObject * XPC_WN_OuterObject(JSContext *cx, JSHandleObject obj_) { @@ -815,7 +772,7 @@ XPCWrappedNativeJSClass XPC_WN_NoHelper_JSClass = { // ClassExtension { - XPC_WN_Equality, + nullptr, // equality nullptr, // outerObject nullptr, // innerObject nullptr, // iteratorObject @@ -1427,14 +1384,7 @@ XPCNativeScriptableShared::PopulateJSClass() ops->typeOf = XPC_WN_JSOp_TypeOf_Object; } - if (mFlags.UseStubEqualityHook()) { - NS_ASSERTION(!mFlags.WantEquality(), - "If you want an Equality callback, you can't use a stub " - "equality hook"); - mJSClass.base.ext.equality = nullptr; - } else { - mJSClass.base.ext.equality = XPC_WN_Equality; - } + mJSClass.base.ext.equality = nullptr; if (mFlags.WantHasInstance()) mJSClass.base.hasInstance = XPC_WN_Helper_HasInstance; diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index ab30377f1aaa..286e561c5d86 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -1466,9 +1466,6 @@ extern js::Class XPC_WN_ModsAllowed_NoCall_Proto_JSClass; extern js::Class XPC_WN_Tearoff_JSClass; extern js::Class XPC_WN_NoHelper_Proto_JSClass; -extern JSBool -XPC_WN_Equality(JSContext *cx, JSHandleObject obj, const jsval *v, JSBool *bp); - extern JSBool XPC_WN_CallMethod(JSContext *cx, unsigned argc, jsval *vp); @@ -2144,7 +2141,6 @@ public: JSBool WantCall() GET_IT(WANT_CALL) JSBool WantConstruct() GET_IT(WANT_CONSTRUCT) JSBool WantHasInstance() GET_IT(WANT_HASINSTANCE) - JSBool WantEquality() GET_IT(WANT_EQUALITY) JSBool WantOuterObject() GET_IT(WANT_OUTER_OBJECT) JSBool UseJSStubForAddProperty() GET_IT(USE_JSSTUB_FOR_ADDPROPERTY) JSBool UseJSStubForDelProperty() GET_IT(USE_JSSTUB_FOR_DELPROPERTY) @@ -2157,7 +2153,6 @@ public: JSBool AllowPropModsToPrototype() GET_IT(ALLOW_PROP_MODS_TO_PROTOTYPE) JSBool IsGlobalObject() GET_IT(IS_GLOBAL_OBJECT) JSBool DontReflectInterfaceNames() GET_IT(DONT_REFLECT_INTERFACE_NAMES) - JSBool UseStubEqualityHook() GET_IT(USE_STUB_EQUALITY_HOOK) #undef GET_IT }; @@ -4260,9 +4255,6 @@ xpc_ForcePropertyResolve(JSContext* cx, JSObject* obj, jsid id); inline jsid GetRTIdByIndex(JSContext *cx, unsigned index); -nsISupports * -XPC_GetIdentityObject(JSContext *cx, JSObject *obj); - namespace xpc { class CompartmentPrivate