mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 851465 - Remove slim wrappers - remove slim wrapper macros and rename WN macros. r=bholley.
This commit is contained in:
parent
7d1069ede0
commit
ef9e24aa33
@ -2090,7 +2090,7 @@ nsScriptSecurityManager::old_doGetObjectPrincipal(JS::Handle<JSObject*> aObj,
|
||||
// Note: jsClass is set before this loop, and also at the
|
||||
// *end* of this loop.
|
||||
|
||||
if (IS_WRAPPER_CLASS(jsClass)) {
|
||||
if (IS_WN_CLASS(jsClass)) {
|
||||
result = nsXPConnect::XPConnect()->GetPrincipal(obj,
|
||||
aAllowShortCircuit);
|
||||
if (result) {
|
||||
|
@ -4259,7 +4259,7 @@ LocationSetterGuts(JSContext *cx, JSObject *obj, jsval *vp)
|
||||
{
|
||||
// This function duplicates some of the logic in XPC_WN_HelperSetProperty
|
||||
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
|
||||
if (!IS_WN_WRAPPER(obj))
|
||||
if (!IS_WN_REFLECTOR(obj))
|
||||
return NS_ERROR_XPC_BAD_CONVERT_JS;
|
||||
XPCWrappedNative *wrapper = XPCWrappedNative::Get(obj);
|
||||
|
||||
|
@ -98,7 +98,7 @@ XPCCallContext::XPCCallContext(XPCContext::LangType callerLanguage,
|
||||
}
|
||||
} else {
|
||||
js::Class *clasp = js::GetObjectClass(unwrapped);
|
||||
if (IS_WRAPPER_CLASS(clasp)) {
|
||||
if (IS_WN_CLASS(clasp)) {
|
||||
mWrapper = XPCWrappedNative::Get(unwrapped);
|
||||
} else if (IS_TEAROFF_CLASS(clasp)) {
|
||||
mTearOff = (XPCWrappedNativeTearOff*)js::GetObjectPrivate(unwrapped);
|
||||
@ -421,8 +421,7 @@ XPCCallContext::UnwrapThisIfAllowed(HandleObject obj, HandleObject fun, unsigned
|
||||
MOZ_ASSERT(unwrapped == JS_ObjectToInnerObject(mJSContext, js::Wrapper::wrappedObject(obj)));
|
||||
|
||||
// Make sure we have an XPCWN, and grab it.
|
||||
MOZ_ASSERT(!IS_SLIM_WRAPPER(unwrapped), "security wrapping morphs slim wrappers");
|
||||
if (!IS_WRAPPER_CLASS(js::GetObjectClass(unwrapped)))
|
||||
if (!IS_WN_REFLECTOR(unwrapped))
|
||||
return nullptr;
|
||||
XPCWrappedNative *wn = (XPCWrappedNative*)js::GetObjectPrivate(unwrapped);
|
||||
|
||||
|
@ -3312,7 +3312,7 @@ xpc_CreateSandboxObject(JSContext *cx, jsval *vp, nsISupports *prinOrSop, Sandbo
|
||||
// Now check what sort of thing we've got in |proto|
|
||||
JSObject *unwrappedProto = js::UncheckedUnwrap(options.proto, false);
|
||||
js::Class *unwrappedClass = js::GetObjectClass(unwrappedProto);
|
||||
if (IS_WRAPPER_CLASS(unwrappedClass) ||
|
||||
if (IS_WN_CLASS(unwrappedClass) ||
|
||||
mozilla::dom::IsDOMClass(Jsvalify(unwrappedClass))) {
|
||||
// Wrap it up in a proxy that will do the right thing in terms
|
||||
// of this-binding for methods.
|
||||
|
@ -862,8 +862,7 @@ XPCConvert::NativeInterface2JSObject(jsval* d,
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(!flat || IS_WRAPPER_CLASS(js::GetObjectClass(flat)),
|
||||
"What kind of wrapper is this?");
|
||||
NS_ASSERTION(!flat || IS_WN_REFLECTOR(flat), "What kind of wrapper is this?");
|
||||
|
||||
nsresult rv;
|
||||
XPCWrappedNative* wrapper;
|
||||
@ -874,7 +873,7 @@ XPCConvert::NativeInterface2JSObject(jsval* d,
|
||||
|
||||
wrapper = strongWrapper;
|
||||
} else {
|
||||
MOZ_ASSERT(IS_WN_WRAPPER_OBJECT(flat));
|
||||
MOZ_ASSERT(IS_WN_REFLECTOR(flat));
|
||||
|
||||
wrapper = static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(flat));
|
||||
|
||||
@ -985,7 +984,7 @@ XPCConvert::JSObject2NativeInterface(void** dest, HandleObject src,
|
||||
|
||||
// Is this really a native xpcom object with a wrapper?
|
||||
XPCWrappedNative* wrappedNative = nullptr;
|
||||
if (IS_WN_WRAPPER(inner))
|
||||
if (IS_WN_REFLECTOR(inner))
|
||||
wrappedNative = XPCWrappedNative::Get(inner);
|
||||
if (wrappedNative) {
|
||||
iface = wrappedNative->GetIdentityObject();
|
||||
@ -1116,8 +1115,8 @@ XPCConvert::JSValToXPCException(jsval sArg,
|
||||
JSObject *unwrapped = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
|
||||
if (!unwrapped)
|
||||
return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
|
||||
XPCWrappedNative* wrapper = IS_WN_WRAPPER(unwrapped) ? XPCWrappedNative::Get(unwrapped)
|
||||
: nullptr;
|
||||
XPCWrappedNative* wrapper = IS_WN_REFLECTOR(unwrapped) ? XPCWrappedNative::Get(unwrapped)
|
||||
: nullptr;
|
||||
if (wrapper) {
|
||||
nsISupports* supports = wrapper->GetIdentityObject();
|
||||
nsCOMPtr<nsIException> iface = do_QueryInterface(supports);
|
||||
|
@ -476,7 +476,7 @@ static JSObject *
|
||||
FindObjectForHasInstance(JSContext *cx, HandleObject objArg)
|
||||
{
|
||||
RootedObject obj(cx, objArg), proto(cx);
|
||||
while (obj && !IS_WRAPPER_CLASS(js::GetObjectClass(obj)) && !IsDOMObject(obj)) {
|
||||
while (obj && !IS_WN_REFLECTOR(obj) && !IsDOMObject(obj)) {
|
||||
if (js::IsWrapper(obj)) {
|
||||
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
|
||||
continue;
|
||||
@ -524,7 +524,7 @@ nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(IS_WN_WRAPPER(obj));
|
||||
MOZ_ASSERT(IS_WN_REFLECTOR(obj));
|
||||
XPCWrappedNative* other_wrapper = XPCWrappedNative::Get(obj);
|
||||
if (!other_wrapper)
|
||||
return NS_OK;
|
||||
@ -841,7 +841,7 @@ nsJSCID::HasInstance(nsIXPConnectWrappedNative *wrapper,
|
||||
// is this really a native xpcom object with a wrapper?
|
||||
nsIClassInfo* ci = nullptr;
|
||||
obj = FindObjectForHasInstance(cx, obj);
|
||||
if (!obj || !IS_WRAPPER_CLASS(js::GetObjectClass(obj)))
|
||||
if (!obj || !IS_WN_REFLECTOR(obj))
|
||||
return rv;
|
||||
if (XPCWrappedNative* other_wrapper = XPCWrappedNative::Get(obj))
|
||||
ci = other_wrapper->GetClassInfo();
|
||||
@ -893,7 +893,7 @@ xpc_JSObjectToID(JSContext *cx, JSObject* obj)
|
||||
// NOTE: this call does NOT addref
|
||||
XPCWrappedNative* wrapper = nullptr;
|
||||
obj = js::CheckedUnwrap(obj);
|
||||
if (obj && IS_WN_WRAPPER(obj))
|
||||
if (obj && IS_WN_REFLECTOR(obj))
|
||||
wrapper = XPCWrappedNative::Get(obj);
|
||||
if (wrapper &&
|
||||
(wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSID)) ||
|
||||
@ -911,7 +911,7 @@ xpc_JSObjectIsID(JSContext *cx, JSObject* obj)
|
||||
// NOTE: this call does NOT addref
|
||||
XPCWrappedNative* wrapper = nullptr;
|
||||
obj = js::CheckedUnwrap(obj);
|
||||
if (obj && IS_WN_WRAPPER(obj))
|
||||
if (obj && IS_WN_REFLECTOR(obj))
|
||||
wrapper = XPCWrappedNative::Get(obj);
|
||||
return wrapper &&
|
||||
(wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSID)) ||
|
||||
|
@ -2537,7 +2537,7 @@ PreserveWrapper(JSContext *cx, JSObject *objArg)
|
||||
if (!ccx.IsValid())
|
||||
return false;
|
||||
|
||||
if (!IS_WRAPPER_CLASS(js::GetObjectClass(obj)))
|
||||
if (!IS_WN_REFLECTOR(obj))
|
||||
return mozilla::dom::TryPreserveWrapper(obj);
|
||||
|
||||
nsISupports *supports = XPCWrappedNative::Get(obj)->Native();
|
||||
|
@ -69,7 +69,7 @@ LookupInterfaceOrAncestor(uint32_t tableSize, const xpc_qsHashEntry *table,
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
HasBitInInterfacesBitmap(JSObject *obj, uint32_t interfaceBit)
|
||||
{
|
||||
NS_ASSERTION(IS_WRAPPER_CLASS(js::GetObjectClass(obj)), "Not a wrapper?");
|
||||
NS_ASSERTION(IS_WN_REFLECTOR(obj), "Not a wrapper?");
|
||||
|
||||
XPCWrappedNativeJSClass *clasp =
|
||||
(XPCWrappedNativeJSClass*)js::GetObjectClass(obj);
|
||||
@ -178,7 +178,7 @@ GetMemberInfo(JSObject *obj, jsid memberId, const char **ifaceName)
|
||||
// because it isn't worth the risk of something going wrong just to generate
|
||||
// an error message. Instead, only handle the simple case where we have the
|
||||
// reflector in hand.
|
||||
if (IS_WRAPPER_CLASS(js::GetObjectClass(obj))) {
|
||||
if (IS_WN_REFLECTOR(obj)) {
|
||||
XPCWrappedNative *wrapper =
|
||||
static_cast<XPCWrappedNative *>(js::GetObjectPrivate(obj));
|
||||
XPCWrappedNativeProto *proto = wrapper->GetProto();
|
||||
@ -561,7 +561,7 @@ getWrapper(JSContext *cx,
|
||||
|
||||
// If we've got a WN, store things the way callers expect. Otherwise, leave
|
||||
// things null and return.
|
||||
if (IS_WRAPPER_CLASS(clasp))
|
||||
if (IS_WN_CLASS(clasp))
|
||||
*wrapper = XPCWrappedNative::Get(obj);
|
||||
|
||||
return NS_OK;
|
||||
@ -614,7 +614,7 @@ castNativeFromWrapper(JSContext *cx,
|
||||
XPCWrappedNativeTearOff *tearoff;
|
||||
JSObject *cur;
|
||||
|
||||
if (IS_WRAPPER_CLASS(js::GetObjectClass(obj))) {
|
||||
if (IS_WN_REFLECTOR(obj)) {
|
||||
cur = obj;
|
||||
wrapper = (XPCWrappedNative*)xpc_GetJSPrivate(obj);
|
||||
tearoff = nullptr;
|
||||
|
@ -45,7 +45,7 @@ XPCVariant::XPCVariant(JSContext* cx, jsval aJSVal)
|
||||
mJSVal = OBJECT_TO_JSVAL(obj);
|
||||
|
||||
JSObject *unwrapped = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
|
||||
mReturnRawObject = !(unwrapped && IS_WN_WRAPPER(unwrapped));
|
||||
mReturnRawObject = !(unwrapped && IS_WN_REFLECTOR(unwrapped));
|
||||
} else
|
||||
mReturnRawObject = false;
|
||||
}
|
||||
|
@ -699,8 +699,7 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
||||
|
||||
bool isSystem;
|
||||
rv = secMan->IsSystemPrincipal(objPrin, &isSystem);
|
||||
if ((NS_FAILED(rv) || !isSystem) &&
|
||||
!IS_WRAPPER_CLASS(js::GetObjectClass(selfObj))) {
|
||||
if ((NS_FAILED(rv) || !isSystem) && !IS_WN_REFLECTOR(selfObj)) {
|
||||
// A content object.
|
||||
nsRefPtr<SameOriginCheckedComponent> checked =
|
||||
new SameOriginCheckedComponent(self);
|
||||
|
@ -36,7 +36,7 @@ bool
|
||||
xpc_OkToHandOutWrapper(nsWrapperCache *cache)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(cache->GetWrapper(), "Must have wrapper");
|
||||
NS_ABORT_IF_FALSE(IS_WN_WRAPPER(cache->GetWrapper()),
|
||||
NS_ABORT_IF_FALSE(IS_WN_REFLECTOR(cache->GetWrapper()),
|
||||
"Must have XPCWrappedNative wrapper");
|
||||
return
|
||||
!static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(cache->GetWrapper()))->
|
||||
@ -1358,10 +1358,8 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCWrappedNativeScope* aOldScope,
|
||||
js::GetObjectCompartment(aNewScope->GetGlobalJSObject()));
|
||||
NS_ASSERTION(aNewParent, "won't be able to find the new parent");
|
||||
|
||||
if (wrapper->HasProto())
|
||||
if (wrapper->HasProto()) {
|
||||
oldProto = wrapper->GetProto();
|
||||
|
||||
if (oldProto) {
|
||||
XPCNativeScriptableInfo *info = oldProto->GetScriptableInfo();
|
||||
XPCNativeScriptableCreateInfo ci(*info);
|
||||
newProto =
|
||||
@ -1509,10 +1507,8 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCWrappedNativeScope* aOldScope,
|
||||
if (!JS_SetParent(cx, flat, aNewParent))
|
||||
MOZ_CRASH();
|
||||
|
||||
JSObject *nw;
|
||||
if (wrapper &&
|
||||
(nw = wrapper->GetWrapper()) &&
|
||||
!JS_SetParent(cx, nw, JS_GetGlobalForObject(cx, aNewParent))) {
|
||||
JSObject *nw = wrapper->GetWrapper();
|
||||
if (nw && !JS_SetParent(cx, nw, JS_GetGlobalForObject(cx, aNewParent))) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
}
|
||||
@ -1560,7 +1556,7 @@ RescueOrphans(HandleObject obj)
|
||||
// PreCreate may touch dead compartments.
|
||||
js::AutoMaybeTouchDeadZones agc(parentObj);
|
||||
|
||||
bool isWN = IS_WRAPPER_CLASS(js::GetObjectClass(obj));
|
||||
bool isWN = IS_WN_REFLECTOR(obj);
|
||||
|
||||
// There's one little nasty twist here. For reasons described in bug 752764,
|
||||
// we nuke SOW-ed objects after transplanting them. This means that nodes
|
||||
|
@ -610,7 +610,7 @@ MarkWrappedNative(JSTracer *trc, JSObject *obj)
|
||||
if (clazz->flags & JSCLASS_DOM_GLOBAL) {
|
||||
mozilla::dom::TraceProtoAndIfaceCache(trc, obj);
|
||||
}
|
||||
MOZ_ASSERT(IS_WRAPPER_CLASS(clazz));
|
||||
MOZ_ASSERT(IS_WN_CLASS(clazz));
|
||||
|
||||
XPCWrappedNative *wrapper = XPCWrappedNative::Get(obj);
|
||||
if (wrapper && wrapper->IsValid())
|
||||
@ -795,7 +795,7 @@ XPC_WN_MaybeResolvingDeletePropertyStub(JSContext *cx, JSHandleObject obj, JSHan
|
||||
JS_ReportError(cx, "Permission denied to operate on object."); \
|
||||
return false; \
|
||||
} \
|
||||
if (!IS_WRAPPER_CLASS(js::GetObjectClass(unwrapped))) { \
|
||||
if (!IS_WN_REFLECTOR(unwrapped)) { \
|
||||
return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx); \
|
||||
} \
|
||||
XPCWrappedNative *wrapper = XPCWrappedNative::Get(unwrapped); \
|
||||
@ -1038,7 +1038,7 @@ XPC_WN_JSOp_Enumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
|
||||
JSMutableHandleValue statep, MutableHandleId idp)
|
||||
{
|
||||
js::Class *clazz = js::GetObjectClass(obj);
|
||||
if (!IS_WRAPPER_CLASS(clazz) || clazz == &XPC_WN_NoHelper_JSClass.base) {
|
||||
if (!IS_WN_CLASS(clazz) || clazz == &XPC_WN_NoHelper_JSClass.base) {
|
||||
// obj must be a prototype object or a wrapper w/o a
|
||||
// helper. Short circuit this call to the default
|
||||
// implementation.
|
||||
|
@ -1222,7 +1222,7 @@ nsXPConnect::GetWrappedNativeOfJSObject(JSContext * aJSContext,
|
||||
|
||||
RootedObject aJSObj(aJSContext, aJSObjArg);
|
||||
aJSObj = js::CheckedUnwrap(aJSObj, /* stopAtOuter = */ false);
|
||||
if (aJSObj && IS_WN_WRAPPER(aJSObj)) {
|
||||
if (aJSObj && IS_WN_REFLECTOR(aJSObj)) {
|
||||
NS_IF_ADDREF(*_retval = XPCWrappedNative::Get(aJSObj));
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1245,7 +1245,7 @@ nsXPConnect::GetNativeOfWrapper(JSContext * aJSContext,
|
||||
JS_ReportError(aJSContext, "Permission denied to get native of security wrapper");
|
||||
return nullptr;
|
||||
}
|
||||
if (IS_WRAPPER_CLASS(js::GetObjectClass(aJSObj))) {
|
||||
if (IS_WN_REFLECTOR(aJSObj)) {
|
||||
if (XPCWrappedNative *wn = XPCWrappedNative::Get(aJSObj))
|
||||
return wn->Native();
|
||||
return nullptr;
|
||||
@ -1918,28 +1918,25 @@ IsJSContextOnStack(JSContext *aCx)
|
||||
nsIPrincipal*
|
||||
nsXPConnect::GetPrincipal(JSObject* obj, bool allowShortCircuit) const
|
||||
{
|
||||
NS_ASSERTION(IS_WRAPPER_CLASS(js::GetObjectClass(obj)),
|
||||
"What kind of wrapper is this?");
|
||||
NS_ASSERTION(IS_WN_REFLECTOR(obj), "What kind of wrapper is this?");
|
||||
|
||||
if (IS_WN_WRAPPER_OBJECT(obj)) {
|
||||
XPCWrappedNative *xpcWrapper =
|
||||
(XPCWrappedNative *)xpc_GetJSPrivate(obj);
|
||||
if (xpcWrapper) {
|
||||
if (allowShortCircuit) {
|
||||
nsIPrincipal *result = xpcWrapper->GetObjectPrincipal();
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
XPCWrappedNative *xpcWrapper =
|
||||
(XPCWrappedNative *)xpc_GetJSPrivate(obj);
|
||||
if (xpcWrapper) {
|
||||
if (allowShortCircuit) {
|
||||
nsIPrincipal *result = xpcWrapper->GetObjectPrincipal();
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// If not, check if it points to an nsIScriptObjectPrincipal
|
||||
nsCOMPtr<nsIScriptObjectPrincipal> objPrin =
|
||||
do_QueryInterface(xpcWrapper->Native());
|
||||
if (objPrin) {
|
||||
nsIPrincipal *result = objPrin->GetPrincipal();
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
// If not, check if it points to an nsIScriptObjectPrincipal
|
||||
nsCOMPtr<nsIScriptObjectPrincipal> objPrin =
|
||||
do_QueryInterface(xpcWrapper->Native());
|
||||
if (objPrin) {
|
||||
nsIPrincipal *result = objPrin->GetPrincipal();
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,10 +42,6 @@
|
||||
* pointers are smooshed together in a tagged union.) Either way it can reach
|
||||
* its scope.
|
||||
*
|
||||
* In the case of slim wrappers (where there is no XPCWrappedNative), the
|
||||
* flattened JS object has a pointer to the XPCWrappedNativeProto stored in a
|
||||
* reserved slot.
|
||||
*
|
||||
* An XPCWrappedNativeProto keeps track of the set of interfaces implemented by
|
||||
* the C++ object in an XPCNativeSet. (The list of interfaces is obtained by
|
||||
* calling a method on the nsIClassInfo.) An XPCNativeSet is a collection of
|
||||
@ -287,13 +283,13 @@ extern const char XPC_XPCONNECT_CONTRACTID[];
|
||||
|
||||
inline void SetWNExpandoChain(JSObject *obj, JSObject *chain)
|
||||
{
|
||||
MOZ_ASSERT(IS_WN_WRAPPER(obj));
|
||||
MOZ_ASSERT(IS_WN_REFLECTOR(obj));
|
||||
JS_SetReservedSlot(obj, WRAPPER_MULTISLOT, JS::ObjectOrNullValue(chain));
|
||||
}
|
||||
|
||||
inline JSObject* GetWNExpandoChain(JSObject *obj)
|
||||
{
|
||||
MOZ_ASSERT(IS_WN_WRAPPER(obj));
|
||||
MOZ_ASSERT(IS_WN_REFLECTOR(obj));
|
||||
return JS_GetReservedSlot(obj, WRAPPER_MULTISLOT).toObjectOrNull();
|
||||
}
|
||||
|
||||
@ -1937,13 +1933,10 @@ public:
|
||||
{return mJSClass.interfacesBitmap;}
|
||||
JSClass* GetJSClass()
|
||||
{return Jsvalify(&mJSClass.base);}
|
||||
JSClass* GetSlimJSClass()
|
||||
{if (mCanBeSlim) return GetJSClass(); return nullptr;}
|
||||
|
||||
XPCNativeScriptableShared(uint32_t aFlags, char* aName,
|
||||
uint32_t interfacesBitmap)
|
||||
: mFlags(aFlags),
|
||||
mCanBeSlim(false)
|
||||
: mFlags(aFlags)
|
||||
{memset(&mJSClass, 0, sizeof(mJSClass));
|
||||
mJSClass.base.name = aName; // take ownership
|
||||
mJSClass.interfacesBitmap = interfacesBitmap;
|
||||
@ -1966,7 +1959,6 @@ public:
|
||||
private:
|
||||
XPCNativeScriptableFlags mFlags;
|
||||
XPCWrappedNativeJSClass mJSClass;
|
||||
JSBool mCanBeSlim;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
@ -1991,9 +1983,6 @@ public:
|
||||
JSClass*
|
||||
GetJSClass() {return mShared->GetJSClass();}
|
||||
|
||||
JSClass*
|
||||
GetSlimJSClass() {return mShared->GetSlimJSClass();}
|
||||
|
||||
XPCNativeScriptableShared*
|
||||
GetScriptableShared() {return mShared;}
|
||||
|
||||
@ -2398,7 +2387,7 @@ public:
|
||||
SetSet(XPCNativeSet* set) {XPCAutoLock al(GetLock()); mSet = set;}
|
||||
|
||||
static XPCWrappedNative* Get(JSObject *obj) {
|
||||
MOZ_ASSERT(IS_WN_WRAPPER(obj));
|
||||
MOZ_ASSERT(IS_WN_REFLECTOR(obj));
|
||||
return (XPCWrappedNative*)js::GetObjectPrivate(obj);
|
||||
}
|
||||
|
||||
|
@ -82,45 +82,23 @@ xpc_LocalizeRuntime(JSRuntime *rt);
|
||||
NS_EXPORT_(void)
|
||||
xpc_DelocalizeRuntime(JSRuntime *rt);
|
||||
|
||||
static inline bool IS_WRAPPER_CLASS(js::Class* clazz)
|
||||
// If IS_WN_CLASS for the JSClass of an object is true, the object is a
|
||||
// wrappednative wrapper, holding the XPCWrappedNative in its private slot.
|
||||
|
||||
static inline bool IS_WN_CLASS(js::Class* clazz)
|
||||
{
|
||||
return clazz->ext.isWrappedNative;
|
||||
}
|
||||
|
||||
// If IS_WRAPPER_CLASS for the JSClass of an object is true, the object can be
|
||||
// a slim wrapper, holding a native in its private slot, or a wrappednative
|
||||
// wrapper, holding the XPCWrappedNative in its private slot. A slim wrapper
|
||||
// also holds a pointer to its XPCWrappedNativeProto in a reserved slot, we can
|
||||
// check that slot for a private value (i.e. a double) to distinguish between
|
||||
// the two. This allows us to store a JSObject in that slot for non-slim wrappers
|
||||
// while still being able to distinguish the two cases.
|
||||
|
||||
// NB: This slot isn't actually reserved for us on globals, because SpiderMonkey
|
||||
// uses the first N slots on globals internally. The fact that we use it for
|
||||
// wrapped global objects is totally broken. But due to a happy coincidence, the
|
||||
// JS engine never uses that slot. This still needs fixing though. See bug 760095.
|
||||
#define WRAPPER_MULTISLOT 0
|
||||
|
||||
static inline bool IS_WN_WRAPPER_OBJECT(JSObject *obj)
|
||||
static inline bool IS_WN_REFLECTOR(JSObject *obj)
|
||||
{
|
||||
MOZ_ASSERT(IS_WRAPPER_CLASS(js::GetObjectClass(obj)));
|
||||
return !js::GetReservedSlot(obj, WRAPPER_MULTISLOT).isDouble();
|
||||
}
|
||||
static inline bool IS_SLIM_WRAPPER_OBJECT(JSObject *obj)
|
||||
{
|
||||
return !IS_WN_WRAPPER_OBJECT(obj);
|
||||
}
|
||||
|
||||
// Use these functions if IS_WRAPPER_CLASS(GetObjectClass(obj)) might be false.
|
||||
// Avoid calling them if IS_WRAPPER_CLASS(GetObjectClass(obj)) can only be
|
||||
// true, as we'd do a redundant call to IS_WRAPPER_CLASS.
|
||||
static inline bool IS_WN_WRAPPER(JSObject *obj)
|
||||
{
|
||||
return IS_WRAPPER_CLASS(js::GetObjectClass(obj)) && IS_WN_WRAPPER_OBJECT(obj);
|
||||
}
|
||||
static inline bool IS_SLIM_WRAPPER(JSObject *obj)
|
||||
{
|
||||
return IS_WRAPPER_CLASS(js::GetObjectClass(obj)) && IS_SLIM_WRAPPER_OBJECT(obj);
|
||||
return IS_WN_CLASS(js::GetObjectClass(obj));
|
||||
}
|
||||
|
||||
extern bool
|
||||
|
@ -179,8 +179,8 @@ IsFrameId(JSContext *cx, JSObject *objArg, jsid idArg)
|
||||
|
||||
obj = JS_ObjectToInnerObject(cx, obj);
|
||||
MOZ_ASSERT(!js::IsWrapper(obj));
|
||||
XPCWrappedNative *wn = IS_WN_WRAPPER(obj) ? XPCWrappedNative::Get(obj)
|
||||
: nullptr;
|
||||
XPCWrappedNative *wn = IS_WN_REFLECTOR(obj) ? XPCWrappedNative::Get(obj)
|
||||
: nullptr;
|
||||
if (!wn) {
|
||||
return false;
|
||||
}
|
||||
@ -272,7 +272,7 @@ AccessCheck::needsSystemOnlyWrapper(JSObject *obj)
|
||||
if (dom::GetSameCompartmentWrapperForDOMBinding(wrapper))
|
||||
return wrapper != obj;
|
||||
|
||||
if (!IS_WN_WRAPPER(obj))
|
||||
if (!IS_WN_REFLECTOR(obj))
|
||||
return false;
|
||||
|
||||
XPCWrappedNative *wn = static_cast<XPCWrappedNative *>(js::GetObjectPrivate(obj));
|
||||
|
@ -196,7 +196,7 @@ WrapperFactory::PrepareForWrapping(JSContext *cx, HandleObject scope,
|
||||
// those objects in a security wrapper, then we need to hand back the
|
||||
// wrapper for the new scope instead. Also, global objects don't move
|
||||
// between scopes so for those we also want to return the wrapper. So...
|
||||
if (!IS_WN_WRAPPER(obj) || !js::GetObjectParent(obj))
|
||||
if (!IS_WN_REFLECTOR(obj) || !js::GetObjectParent(obj))
|
||||
return DoubleWrap(cx, obj, flags);
|
||||
|
||||
XPCWrappedNative *wn = static_cast<XPCWrappedNative *>(xpc_GetJSPrivate(obj));
|
||||
@ -295,7 +295,7 @@ WrapperFactory::PrepareForWrapping(JSContext *cx, HandleObject scope,
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
obj = JSVAL_TO_OBJECT(v);
|
||||
NS_ASSERTION(IS_WN_WRAPPER(obj), "bad object");
|
||||
NS_ASSERTION(IS_WN_REFLECTOR(obj), "bad object");
|
||||
|
||||
// Because the underlying native didn't have a PreCreate hook, we had
|
||||
// to a new (or possibly pre-existing) XPCWN in our compartment.
|
||||
@ -517,7 +517,7 @@ WrapperFactory::WrapForSameCompartment(JSContext *cx, HandleObject objArg)
|
||||
|
||||
MOZ_ASSERT(!dom::IsDOMObject(obj));
|
||||
|
||||
if (!IS_WN_WRAPPER(obj))
|
||||
if (!IS_WN_REFLECTOR(obj))
|
||||
return obj;
|
||||
|
||||
// Extract the WN. It should exist.
|
||||
|
@ -61,7 +61,7 @@ GetXrayType(JSObject *obj)
|
||||
return XrayForDOMObject;
|
||||
|
||||
js::Class* clasp = js::GetObjectClass(obj);
|
||||
if (IS_WRAPPER_CLASS(clasp) || clasp->ext.innerObject)
|
||||
if (IS_WN_CLASS(clasp) || clasp->ext.innerObject)
|
||||
return XrayForWrappedNative;
|
||||
|
||||
return NotXray;
|
||||
@ -509,7 +509,7 @@ GetHolder(JSObject *obj)
|
||||
static XPCWrappedNative *
|
||||
GetWrappedNative(JSObject *obj)
|
||||
{
|
||||
MOZ_ASSERT(IS_WN_WRAPPER_OBJECT(obj));
|
||||
MOZ_ASSERT(IS_WN_REFLECTOR(obj));
|
||||
return static_cast<XPCWrappedNative *>(js::GetObjectPrivate(obj));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user