Bug 797821 - Replace usage of XPCWrappedNativeScope::FindInJSObjectScope(ccx, obj) with GetObjectScope(obj). r=mrbkap

This commit is contained in:
Bobby Holley 2012-10-25 17:01:08 +02:00
Родитель 7ec5eb0580
Коммит 0cdf333aaa
8 изменённых файлов: 23 добавлений и 40 удалений

Просмотреть файл

@ -1424,8 +1424,7 @@ def CheckPref(descriptor, globalName, varName, retval, wrapperCache = None):
" return %s;") % (varName, retval)
return """
{
XPCWrappedNativeScope* scope =
XPCWrappedNativeScope::FindInJSObjectScope(aCx, %s);
XPCWrappedNativeScope* scope = xpc::ObjectScope(%s);
if (!scope) {
%s
}

Просмотреть файл

@ -2471,8 +2471,7 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
nsXPConnect* xpc = ccx.GetXPConnect();
XPCContext* xpcc = ccx.GetXPCContext();
XPCWrappedNativeScope* scope =
XPCWrappedNativeScope::FindInJSObjectScope(ccx, obj);
XPCWrappedNativeScope* scope = ObjectScope(obj);
nsXPCComponents* comp;
if (!xpc || !xpcc || !scope || !(comp = scope->GetComponents()))
@ -3310,7 +3309,7 @@ xpc_CreateSandboxObject(JSContext *cx, jsval *vp, nsISupports *prinOrSop, Sandbo
{
JSAutoCompartment ac(ccx, sandbox);
if (options.wantComponents &&
!nsXPCComponents::AttachComponentsObject(ccx, XPCWrappedNativeScope::FindInJSObjectScope(ccx, sandbox)))
!nsXPCComponents::AttachComponentsObject(ccx, ObjectScope(sandbox)))
return NS_ERROR_XPC_UNEXPECTED;
if (!XPCNativeWrapper::AttachNewConstructorObject(ccx, sandbox))
@ -4303,10 +4302,7 @@ nsXPCComponents_Utils::GetComponentsForScope(const jsval &vscope, JSContext *cx,
if (!vscope.isObject())
return NS_ERROR_INVALID_ARG;
JSObject *scopeObj = js::UnwrapObject(&vscope.toObject());
XPCWrappedNativeScope *scope =
XPCWrappedNativeScope::FindInJSObjectScope(cx, scopeObj);
if (!scope)
return NS_ERROR_FAILURE;
XPCWrappedNativeScope *scope = ObjectScope(scopeObj);
XPCCallContext ccx(NATIVE_CALLER, cx);
JSObject *components = scope->GetComponentsJSObject(ccx);
if (!components)

Просмотреть файл

@ -812,8 +812,7 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
"bad scope for new JSObjects");
JSObject *jsscope = lccx.GetScopeForNewJSObjects();
XPCWrappedNativeScope* xpcscope =
XPCWrappedNativeScope::FindInJSObjectScope(cx, jsscope);
XPCWrappedNativeScope* xpcscope = ObjectScope(jsscope);
if (!xpcscope)
return false;

Просмотреть файл

@ -17,6 +17,7 @@
#include "jsapi.h"
using namespace xpc;
NS_IMPL_THREADSAFE_ISUPPORTS1(nsXPCWrappedJSClass, nsIXPCWrappedJSClass)
// the value of this variable is never used - we use its address as a sentinel
@ -506,8 +507,7 @@ GetContextFromObject(JSObject *obj)
return nullptr;
JSAutoCompartment ac(ccx, obj);
XPCWrappedNativeScope* scope =
XPCWrappedNativeScope::FindInJSObjectScope(ccx, obj);
XPCWrappedNativeScope* scope = ObjectScope(obj);
XPCContext *xpcc = scope->GetContext();
if (xpcc) {

Просмотреть файл

@ -525,8 +525,7 @@ XPCWrappedNative::GetNewOrUsed(XPCCallContext& ccx,
ac.construct(ccx, parent);
if (parent != plannedParent) {
XPCWrappedNativeScope* betterScope =
XPCWrappedNativeScope::FindInJSObjectScope(ccx, parent);
XPCWrappedNativeScope* betterScope = ObjectScope(parent);
if (betterScope != Scope)
return GetNewOrUsed(ccx, helper, betterScope, Interface, resultWrapper);
@ -1788,11 +1787,7 @@ XPCWrappedNative::RescueOrphans(XPCCallContext& ccx)
JSObject *parentGhost = js::GetObjectParent(mFlatJSObject);
JSObject *realParent = js::UnwrapObject(parentGhost);
nsRefPtr<XPCWrappedNative> ignored;
return ReparentWrapperIfFound(ccx,
XPCWrappedNativeScope::
FindInJSObjectScope(ccx, parentGhost),
XPCWrappedNativeScope::
FindInJSObjectScope(ccx, realParent),
return ReparentWrapperIfFound(ccx, ObjectScope(parentGhost), ObjectScope(realParent),
realParent, mIdentity, getter_AddRefs(ignored));
}
@ -3816,8 +3811,7 @@ ConstructSlimWrapper(XPCCallContext &ccx,
JSAutoCompartment ac(ccx, parent);
if (parent != plannedParent) {
XPCWrappedNativeScope *newXpcScope =
XPCWrappedNativeScope::FindInJSObjectScope(ccx, parent);
XPCWrappedNativeScope *newXpcScope = ObjectScope(parent);
if (newXpcScope != xpcScope) {
SLIM_LOG_NOT_CREATED(ccx, identityObj, "crossing origins");

Просмотреть файл

@ -84,12 +84,10 @@ XPCWrappedNativeScope* XPCWrappedNativeScope::gDyingScopes = nullptr;
XPCWrappedNativeScope*
XPCWrappedNativeScope::GetNewOrUsed(JSContext *cx, JSObject* aGlobal)
{
XPCWrappedNativeScope* scope = FindInJSObjectScope(cx, aGlobal, true);
XPCWrappedNativeScope* scope = ObjectScope(aGlobal);
if (!scope) {
scope = new XPCWrappedNativeScope(cx, aGlobal);
}
else {
} else {
// We need to call SetGlobal in order to clear mPrototypeNoHelper (so we
// get a new new one if requested in the new scope) in the case where
// the global object is being reused (JS_SetAllNonReservedSlotsToUndefined

Просмотреть файл

@ -1451,8 +1451,7 @@ nsXPConnect::GetWrappedNativeOfNativeObject(JSContext * aJSContext,
if (!ccx.IsValid())
return UnexpectedFailure(NS_ERROR_FAILURE);
XPCWrappedNativeScope* scope =
XPCWrappedNativeScope::FindInJSObjectScope(ccx, aScope);
XPCWrappedNativeScope* scope = ObjectScope(aScope);
if (!scope)
return UnexpectedFailure(NS_ERROR_FAILURE);
@ -1483,14 +1482,9 @@ nsXPConnect::ReparentWrappedNativeIfFound(JSContext * aJSContext,
if (!ccx.IsValid())
return UnexpectedFailure(NS_ERROR_FAILURE);
XPCWrappedNativeScope* scope =
XPCWrappedNativeScope::FindInJSObjectScope(ccx, aScope);
if (!scope)
return UnexpectedFailure(NS_ERROR_FAILURE);
XPCWrappedNativeScope* scope2 =
XPCWrappedNativeScope::FindInJSObjectScope(ccx, aNewParent);
if (!scope2)
XPCWrappedNativeScope* scope = ObjectScope(aScope);
XPCWrappedNativeScope* scope2 = ObjectScope(aNewParent);
if (!scope || !scope2)
return UnexpectedFailure(NS_ERROR_FAILURE);
return XPCWrappedNative::
@ -1521,8 +1515,7 @@ nsXPConnect::RescueOrphansInScope(JSContext *aJSContext, JSObject *aScope)
if (!ccx.IsValid())
return UnexpectedFailure(NS_ERROR_FAILURE);
XPCWrappedNativeScope *scope =
XPCWrappedNativeScope::FindInJSObjectScope(ccx, aScope);
XPCWrappedNativeScope *scope = ObjectScope(aScope);
if (!scope)
return UnexpectedFailure(NS_ERROR_FAILURE);
@ -1774,8 +1767,7 @@ nsXPConnect::GetWrappedNativePrototype(JSContext * aJSContext,
JSAutoCompartment ac(aJSContext, aScope);
XPCWrappedNativeScope* scope =
XPCWrappedNativeScope::FindInJSObjectScope(ccx, aScope);
XPCWrappedNativeScope* scope = ObjectScope(aScope);
if (!scope)
return UnexpectedFailure(NS_ERROR_FAILURE);

Просмотреть файл

@ -4418,6 +4418,11 @@ inline bool EnableUniversalXPConnect(JSContext *cx)
js::AllCompartments());
}
inline XPCWrappedNativeScope*
ObjectScope(JSObject *obj)
{
return EnsureCompartmentPrivate(obj)->scope;
}
}
/***************************************************************************/