зеркало из https://github.com/mozilla/gecko-dev.git
Bug 876762 - Remove support for mScopeForNewJSObjects. r=luke
This commit is contained in:
Родитель
e96260d704
Коммит
49a6fe857d
|
@ -30,7 +30,6 @@ XPCCallContext::XPCCallContext(XPCContext::LangType callerLanguage,
|
|||
mContextPopRequired(false),
|
||||
mDestroyJSContextInDestructor(false),
|
||||
mCallerLanguage(callerLanguage),
|
||||
mScopeForNewJSObjects(cx),
|
||||
mFlattenedJSObject(cx),
|
||||
mWrapper(nullptr),
|
||||
mTearOff(nullptr),
|
||||
|
@ -55,7 +54,6 @@ XPCCallContext::XPCCallContext(XPCContext::LangType callerLanguage,
|
|||
mContextPopRequired(false),
|
||||
mDestroyJSContextInDestructor(false),
|
||||
mCallerLanguage(callerLanguage),
|
||||
mScopeForNewJSObjects(cx),
|
||||
mFlattenedJSObject(cx, flattenedJSObject),
|
||||
mWrapper(wrapper),
|
||||
mTearOff(tearOff),
|
||||
|
@ -139,10 +137,6 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
|
|||
if (!obj)
|
||||
return;
|
||||
|
||||
mScopeForNewJSObjects = obj;
|
||||
|
||||
mState = HAVE_SCOPE;
|
||||
|
||||
mMethodIndex = 0xDEAD;
|
||||
|
||||
mState = HAVE_OBJECT;
|
||||
|
|
|
@ -90,13 +90,6 @@ XPCConvert::NativeData2JS(XPCLazyCallContext& lccx, jsval* d, const void* s,
|
|||
NS_PRECONDITION(d, "bad param");
|
||||
|
||||
JSContext* cx = lccx.GetJSContext();
|
||||
|
||||
// Allow wrong compartment or unset ScopeForNewObject when the caller knows
|
||||
// the value is primitive (viz., XPCNativeMember::GetConstantValue).
|
||||
NS_ABORT_IF_FALSE(type.IsArithmetic() ||
|
||||
js::IsObjectInContextCompartment(lccx.GetScopeForNewJSObjects(), cx),
|
||||
"bad scope for new JSObjects");
|
||||
|
||||
if (pErr)
|
||||
*pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
|
||||
|
||||
|
@ -171,7 +164,7 @@ XPCConvert::NativeData2JS(XPCLazyCallContext& lccx, jsval* d, const void* s,
|
|||
nsID* iid2 = *((nsID**)s);
|
||||
if (!iid2)
|
||||
break;
|
||||
RootedObject scope(cx, lccx.GetScopeForNewJSObjects());
|
||||
RootedObject scope(cx, JS_GetGlobalForScopeChain(cx));
|
||||
JSObject* obj;
|
||||
if (!(obj = xpc_NewIDObject(cx, scope, *iid2)))
|
||||
return false;
|
||||
|
@ -813,11 +806,7 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
|
|||
// optimal -- we could detect this and roll the functionality into a
|
||||
// single wrapper, but the current solution is good enough for now.
|
||||
JSContext* cx = lccx.GetJSContext();
|
||||
NS_ABORT_IF_FALSE(js::IsObjectInContextCompartment(lccx.GetScopeForNewJSObjects(), cx),
|
||||
"bad scope for new JSObjects");
|
||||
|
||||
JSObject *jsscope = lccx.GetScopeForNewJSObjects();
|
||||
XPCWrappedNativeScope* xpcscope = GetObjectScope(jsscope);
|
||||
XPCWrappedNativeScope* xpcscope = GetObjectScope(JS_GetGlobalForScopeChain(cx));
|
||||
if (!xpcscope)
|
||||
return false;
|
||||
|
||||
|
@ -1405,8 +1394,6 @@ XPCConvert::NativeArray2JS(XPCLazyCallContext& lccx,
|
|||
return false;
|
||||
|
||||
JSContext* cx = ccx.GetJSContext();
|
||||
NS_ABORT_IF_FALSE(js::IsObjectInContextCompartment(lccx.GetScopeForNewJSObjects(), cx),
|
||||
"bad scope for new JSObjects");
|
||||
|
||||
// XXX add support for putting chars in a string rather than an array
|
||||
|
||||
|
|
|
@ -96,22 +96,6 @@ XPCCallContext::GetPrevCallContext() const
|
|||
return mPrevCallContext;
|
||||
}
|
||||
|
||||
inline JSObject*
|
||||
XPCCallContext::GetScopeForNewJSObjects() const
|
||||
{
|
||||
CHECK_STATE(HAVE_SCOPE);
|
||||
return mScopeForNewJSObjects;
|
||||
}
|
||||
|
||||
inline void
|
||||
XPCCallContext::SetScopeForNewJSObjects(JSObject *scope)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mState == HAVE_CONTEXT, "wrong call context state");
|
||||
NS_ABORT_IF_FALSE(js::IsObjectInContextCompartment(scope, mJSContext), "wrong compartment");
|
||||
mScopeForNewJSObjects = scope;
|
||||
mState = HAVE_SCOPE;
|
||||
}
|
||||
|
||||
inline JSObject*
|
||||
XPCCallContext::GetFlattenedJSObject() const
|
||||
{
|
||||
|
|
|
@ -418,9 +418,6 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
|
|||
|
||||
nsID iid;
|
||||
|
||||
NS_ABORT_IF_FALSE(js::IsObjectInContextCompartment(lccx.GetScopeForNewJSObjects(), cx),
|
||||
"bad scope for new JSObjects");
|
||||
|
||||
switch (type) {
|
||||
case nsIDataType::VTYPE_INT8:
|
||||
case nsIDataType::VTYPE_INT16:
|
||||
|
|
|
@ -1161,7 +1161,6 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
|
|||
RootedObject thisObj(cx, obj);
|
||||
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
ccx.SetScopeForNewJSObjects(obj);
|
||||
|
||||
AutoValueVector args(cx);
|
||||
AutoScriptEvaluate scriptEval(cx);
|
||||
|
|
|
@ -1561,7 +1561,6 @@ XPC_WN_Shared_Proto_Enumerate(JSContext *cx, JSHandleObject obj)
|
|||
XPCCallContext ccx(JS_CALLER, cx);
|
||||
if (!ccx.IsValid())
|
||||
return false;
|
||||
ccx.SetScopeForNewJSObjects(obj);
|
||||
|
||||
uint16_t interface_count = set->GetInterfaceCount();
|
||||
XPCNativeInterface** interfaceArray = set->GetInterfaceArray();
|
||||
|
@ -1614,7 +1613,6 @@ XPC_WN_ModsAllowed_Proto_Resolve(JSContext *cx, JSHandleObject obj, JSHandleId i
|
|||
XPCCallContext ccx(JS_CALLER, cx);
|
||||
if (!ccx.IsValid())
|
||||
return false;
|
||||
ccx.SetScopeForNewJSObjects(obj);
|
||||
|
||||
XPCNativeScriptableInfo* si = self->GetScriptableInfo();
|
||||
unsigned enumFlag = (si && si->GetFlags().DontEnumStaticProps()) ?
|
||||
|
@ -1695,7 +1693,6 @@ XPC_WN_OnlyIWrite_Proto_AddPropertyStub(JSContext *cx, JSHandleObject obj, JSHan
|
|||
XPCCallContext ccx(JS_CALLER, cx);
|
||||
if (!ccx.IsValid())
|
||||
return false;
|
||||
ccx.SetScopeForNewJSObjects(obj);
|
||||
|
||||
// Allow XPConnect to add the property only
|
||||
if (ccx.GetResolveName() == id)
|
||||
|
@ -1726,7 +1723,6 @@ XPC_WN_NoMods_Proto_Resolve(JSContext *cx, JSHandleObject obj, JSHandleId id)
|
|||
XPCCallContext ccx(JS_CALLER, cx);
|
||||
if (!ccx.IsValid())
|
||||
return false;
|
||||
ccx.SetScopeForNewJSObjects(obj);
|
||||
|
||||
XPCNativeScriptableInfo* si = self->GetScriptableInfo();
|
||||
unsigned enumFlag = (si && si->GetFlags().DontEnumStaticProps()) ?
|
||||
|
|
|
@ -1133,7 +1133,6 @@ NativeInterface2JSObject(XPCLazyCallContext & lccx,
|
|||
nsIXPConnectJSObjectHolder **aHolder)
|
||||
{
|
||||
JSAutoCompartment ac(lccx.GetJSContext(), aScope);
|
||||
lccx.SetScopeForNewJSObjects(aScope);
|
||||
|
||||
nsresult rv;
|
||||
xpcObjectHelper helper(aCOMObj, aCache);
|
||||
|
@ -1852,7 +1851,7 @@ nsXPConnect::VariantToJS(JSContext* ctx, JSObject* scopeArg, nsIVariant* value,
|
|||
return NS_ERROR_FAILURE;
|
||||
XPCLazyCallContext lccx(ccx);
|
||||
|
||||
ccx.SetScopeForNewJSObjects(scope);
|
||||
MOZ_ASSERT(js::IsObjectInContextCompartment(scope, ctx));
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (!XPCVariant::VariantDataToJS(lccx, value, &rv, _retval)) {
|
||||
|
|
|
@ -1154,17 +1154,6 @@ public:
|
|||
inline XPCContext::LangType GetPrevCallerLanguage() const ;
|
||||
inline XPCCallContext* GetPrevCallContext() const ;
|
||||
|
||||
/*
|
||||
* The 'scope for new JSObjects' will be the scope for objects created when
|
||||
* carrying out a JS/C++ call. This member is only available if HAVE_SCOPE.
|
||||
* The object passed to the ccx constructor is used as the scope for new
|
||||
* JSObjects. However, this object is also queried for a wrapper, so
|
||||
* clients that don't want a wrapper (and thus pass NULL to the ccx
|
||||
* constructor) need to manually call SetScopeForNewJSObjects.
|
||||
*/
|
||||
inline JSObject* GetScopeForNewJSObjects() const ;
|
||||
inline void SetScopeForNewJSObjects(JSObject *obj) ;
|
||||
|
||||
inline JSObject* GetFlattenedJSObject() const ;
|
||||
inline nsISupports* GetIdentityObject() const ;
|
||||
inline XPCWrappedNative* GetWrapper() const ;
|
||||
|
@ -1250,7 +1239,6 @@ private:
|
|||
INIT_FAILED,
|
||||
SYSTEM_SHUTDOWN,
|
||||
HAVE_CONTEXT,
|
||||
HAVE_SCOPE,
|
||||
HAVE_OBJECT,
|
||||
HAVE_NAME,
|
||||
HAVE_ARGS,
|
||||
|
@ -1282,7 +1270,6 @@ private:
|
|||
|
||||
XPCCallContext* mPrevCallContext;
|
||||
|
||||
JS::RootedObject mScopeForNewJSObjects;
|
||||
JS::RootedObject mFlattenedJSObject;
|
||||
XPCWrappedNative* mWrapper;
|
||||
XPCWrappedNativeTearOff* mTearOff;
|
||||
|
@ -1365,22 +1352,6 @@ public:
|
|||
|
||||
return mCx;
|
||||
}
|
||||
JSObject *GetScopeForNewJSObjects() const
|
||||
{
|
||||
if (mCcx)
|
||||
return mCcx->GetScopeForNewJSObjects();
|
||||
|
||||
return xpc_UnmarkGrayObject(mObj);
|
||||
}
|
||||
void SetScopeForNewJSObjects(JSObject *obj)
|
||||
{
|
||||
if (mCcx) {
|
||||
mCcx->SetScopeForNewJSObjects(obj);
|
||||
return;
|
||||
}
|
||||
NS_ABORT_IF_FALSE(!mObj, "already set!");
|
||||
mObj = obj;
|
||||
}
|
||||
JSObject *GetFlattenedJSObject() const
|
||||
{
|
||||
if (mCcx)
|
||||
|
|
Загрузка…
Ссылка в новой задаче