зеркало из https://github.com/mozilla/gecko-dev.git
Bug 851465 - Remove slim wrappers - stop morphing slim wrappers. r=bholley.
This commit is contained in:
Родитель
583f9d98a8
Коммит
a6f9979ef0
|
@ -401,13 +401,6 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
|
|||
|
||||
AutoJSContext cx;
|
||||
nsresult rv;
|
||||
JS::RootedObject wrapper(cx);
|
||||
bool isDOMBinding;
|
||||
if (aReparentScope && (wrapper = aNode->GetWrapper()) &&
|
||||
!(isDOMBinding = IsDOMObject(wrapper))) {
|
||||
rv = xpc_MorphSlimWrapper(cx, aNode);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsNodeInfoManager *nodeInfoManager = aNewNodeInfoManager;
|
||||
|
||||
|
@ -523,19 +516,22 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
|
|||
elem->RecompileScriptEventListeners();
|
||||
}
|
||||
|
||||
if (aReparentScope && wrapper) {
|
||||
if (isDOMBinding) {
|
||||
rv = ReparentWrapper(cx, wrapper);
|
||||
} else {
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
if (xpc) {
|
||||
rv = xpc->ReparentWrappedNativeIfFound(cx, wrapper, aReparentScope, aNode);
|
||||
if (aReparentScope) {
|
||||
JS::Rooted<JSObject*> wrapper(cx);
|
||||
if ((wrapper = aNode->GetWrapper())) {
|
||||
if (IsDOMObject(wrapper)) {
|
||||
rv = ReparentWrapper(cx, wrapper);
|
||||
} else {
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
if (xpc) {
|
||||
rv = xpc->ReparentWrappedNativeIfFound(cx, wrapper, aReparentScope, aNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
aNode->mNodeInfo.swap(nodeInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
aNode->mNodeInfo.swap(nodeInfo);
|
||||
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2684,10 +2684,6 @@ nsXPCComponents_Utils::LookupMethod(const JS::Value& object,
|
|||
// Enter the target compartment.
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
|
||||
// Morph slim wrappers.
|
||||
if (IS_SLIM_WRAPPER(obj) && !MorphSlimWrapper(cx, obj))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Now, try to create an Xray wrapper around the object. This won't work
|
||||
// if the object isn't Xray-able. In that case, we throw.
|
||||
JSObject *xray = WrapperFactory::WrapForSameCompartmentXray(cx, obj);
|
||||
|
|
|
@ -887,17 +887,6 @@ XPCConvert::NativeInterface2JSObject(jsval* d,
|
|||
wrapper->FindTearOff(iface, false, &rv);
|
||||
else
|
||||
rv = NS_OK;
|
||||
} else {
|
||||
NS_ASSERTION(IS_SLIM_WRAPPER(flat),
|
||||
"What kind of wrapper is this?");
|
||||
|
||||
SLIM_LOG(("***** morphing from XPCConvert::NativeInterface2JSObject"
|
||||
"(%p)\n",
|
||||
static_cast<nsISupports*>(xpc_GetJSPrivate(flat))));
|
||||
|
||||
rv = XPCWrappedNative::Morph(flat, iface, cache,
|
||||
getter_AddRefs(strongWrapper));
|
||||
wrapper = strongWrapper;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) && pErr)
|
||||
|
|
|
@ -505,7 +505,6 @@ nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
|
|||
|
||||
NS_ASSERTION(obj, "when is an object not an object?");
|
||||
|
||||
nsISupports *identity = nullptr;
|
||||
// is this really a native xpcom object with a wrapper?
|
||||
const nsIID* iid;
|
||||
mInfo->GetIIDShared(&iid);
|
||||
|
@ -514,30 +513,16 @@ nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
|
|||
if (!obj)
|
||||
return NS_OK;
|
||||
|
||||
if (IS_SLIM_WRAPPER(obj)) {
|
||||
XPCWrappedNativeProto* proto = GetSlimWrapperProto(obj);
|
||||
if (proto->GetSet()->HasInterfaceWithAncestor(iid)) {
|
||||
*bp = true;
|
||||
if (IsDOMObject(obj)) {
|
||||
// Not all DOM objects implement nsISupports. But if they don't,
|
||||
// there's nothing to do in this HasInstance hook.
|
||||
nsISupports *identity = UnwrapDOMObjectToISupports(obj);
|
||||
if (!identity)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_slimwrappers
|
||||
char foo[NSID_LENGTH];
|
||||
iid->ToProvidedString(foo);
|
||||
SLIM_LOG_WILL_MORPH_FOR_PROP(cx, obj, foo);
|
||||
#endif
|
||||
if (!MorphSlimWrapper(cx, obj))
|
||||
return NS_ERROR_FAILURE;
|
||||
} else if (IsDOMObject(obj)) {
|
||||
// Not all DOM objects implement nsISupports. But if they don't,
|
||||
// there's nothing to do in this HasInstance hook.
|
||||
identity = UnwrapDOMObjectToISupports(obj);
|
||||
if (!identity)
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsISupports> supp;
|
||||
identity->QueryInterface(*iid, getter_AddRefs(supp));
|
||||
*bp = supp;
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsISupports> supp;
|
||||
identity->QueryInterface(*iid, getter_AddRefs(supp));
|
||||
*bp = supp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(IS_WN_WRAPPER(obj));
|
||||
|
|
|
@ -532,15 +532,8 @@ XPCWrappedNative::GetNewOrUsed(xpcObjectHelper& helper,
|
|||
|
||||
if (cache) {
|
||||
RootedObject cached(cx, cache->GetWrapper());
|
||||
if (cached) {
|
||||
if (IS_SLIM_WRAPPER_OBJECT(cached)) {
|
||||
if (NS_FAILED(XPCWrappedNative::Morph(cached,
|
||||
Interface, cache, getter_AddRefs(wrapper))))
|
||||
return NS_ERROR_FAILURE;
|
||||
} else {
|
||||
wrapper = static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(cached));
|
||||
}
|
||||
}
|
||||
if (cached)
|
||||
wrapper = static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(cached));
|
||||
} else {
|
||||
// scoped lock
|
||||
XPCAutoLock lock(mapLock);
|
||||
|
@ -711,67 +704,6 @@ FinishCreate(XPCWrappedNativeScope* Scope,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
XPCWrappedNative::Morph(HandleObject existingJSObject,
|
||||
XPCNativeInterface* Interface,
|
||||
nsWrapperCache *cache,
|
||||
XPCWrappedNative** resultWrapper)
|
||||
{
|
||||
AutoJSContext cx;
|
||||
NS_ASSERTION(IS_SLIM_WRAPPER(existingJSObject),
|
||||
"Trying to morph a JSObject that's not a slim wrapper?");
|
||||
|
||||
nsISupports *identity =
|
||||
static_cast<nsISupports*>(xpc_GetJSPrivate(existingJSObject));
|
||||
XPCWrappedNativeProto *proto = GetSlimWrapperProto(existingJSObject);
|
||||
|
||||
#if DEBUG
|
||||
// FIXME Can't assert this until
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=343141 is fixed.
|
||||
#if 0
|
||||
if (proto->GetScriptableInfo()->GetFlags().WantPreCreate()) {
|
||||
JSObject* parent = JS_GetParent(existingJSObject);
|
||||
JSObject* plannedParent = parent;
|
||||
nsresult rv =
|
||||
proto->GetScriptableInfo()->GetCallback()->PreCreate(identity, ccx,
|
||||
parent,
|
||||
&parent);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NS_ASSERTION(parent == plannedParent,
|
||||
"PreCreate returned a different parent");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
nsRefPtr<XPCWrappedNative> wrapper = new XPCWrappedNative(dont_AddRef(identity), proto);
|
||||
if (!wrapper)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_ASSERTION(!xpc::WrapperFactory::IsXrayWrapper(js::GetObjectParent(existingJSObject)),
|
||||
"Xray wrapper being used to parent XPCWrappedNative?");
|
||||
|
||||
// We use an AutoMarkingPtr here because it is possible for JS gc to happen
|
||||
// after we have Init'd the wrapper but *before* we add it to the hashtable.
|
||||
// This would cause the mSet to get collected and we'd later crash. I've
|
||||
// *seen* this happen.
|
||||
AutoMarkingWrappedNativePtr wrapperMarker(cx, wrapper);
|
||||
|
||||
JSAutoCompartment ac(cx, existingJSObject);
|
||||
if (!wrapper->Init(existingJSObject))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv;
|
||||
if (Interface && !wrapper->FindTearOff(Interface, false, &rv)) {
|
||||
NS_ASSERTION(NS_FAILED(rv), "returning NS_OK on failure");
|
||||
return rv;
|
||||
}
|
||||
|
||||
return FinishCreate(wrapper->GetScope(), Interface, cache, wrapper, resultWrapper);
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
XPCWrappedNative::GetUsedOnly(nsISupports* Object,
|
||||
|
@ -787,17 +719,11 @@ XPCWrappedNative::GetUsedOnly(nsISupports* Object,
|
|||
CallQueryInterface(Object, &cache);
|
||||
if (cache) {
|
||||
RootedObject flat(cx, cache->GetWrapper());
|
||||
if (flat && IS_SLIM_WRAPPER_OBJECT(flat) && !MorphSlimWrapper(cx, flat))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
wrapper = flat ?
|
||||
static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(flat)) :
|
||||
nullptr;
|
||||
|
||||
if (!wrapper) {
|
||||
if (!flat) {
|
||||
*resultWrapper = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
wrapper = static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(flat));
|
||||
NS_ADDREF(wrapper);
|
||||
} else {
|
||||
nsCOMPtr<nsISupports> identity = do_QueryInterface(Object);
|
||||
|
@ -1067,10 +993,6 @@ XPCWrappedNative::GatherScriptableCreateInfo(nsISupports* obj,
|
|||
return sciProto;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_slimwrappers
|
||||
static uint32_t sMorphedSlimWrappers;
|
||||
#endif
|
||||
|
||||
JSBool
|
||||
XPCWrappedNative::Init(HandleObject parent,
|
||||
const XPCNativeScriptableCreateInfo* sci)
|
||||
|
@ -1129,33 +1051,12 @@ XPCWrappedNative::Init(HandleObject parent,
|
|||
return FinishInit();
|
||||
}
|
||||
|
||||
JSBool
|
||||
XPCWrappedNative::Init(JSObject *existingJSObject)
|
||||
{
|
||||
// Set up the private to point to the WN.
|
||||
JS_SetPrivate(existingJSObject, this);
|
||||
|
||||
// Officially mark us as non-slim.
|
||||
MorphMultiSlot(existingJSObject);
|
||||
|
||||
mScriptableInfo = GetProto()->GetScriptableInfo();
|
||||
mFlatJSObject = existingJSObject;
|
||||
|
||||
SLIM_LOG(("----- %i morphed slim wrapper (mFlatJSObject: %p, %p)\n",
|
||||
++sMorphedSlimWrappers, mFlatJSObject,
|
||||
static_cast<nsISupports*>(xpc_GetJSPrivate(mFlatJSObject))));
|
||||
|
||||
return FinishInit();
|
||||
}
|
||||
|
||||
JSBool
|
||||
XPCWrappedNative::FinishInit()
|
||||
{
|
||||
AutoJSContext cx;
|
||||
|
||||
// For all WNs, we want to make sure that the multislot starts out as null.
|
||||
// This happens explicitly when morphing a slim wrapper, but we need to
|
||||
// make sure it happens in the other cases too.
|
||||
JS_SetReservedSlot(mFlatJSObject, WRAPPER_MULTISLOT, JSVAL_NULL);
|
||||
|
||||
// This reference will be released when mFlatJSObject is finalized.
|
||||
|
@ -1693,12 +1594,6 @@ RescueOrphans(HandleObject obj)
|
|||
}
|
||||
}
|
||||
|
||||
// Morph any slim wrappers, lest they confuse us.
|
||||
if (IS_SLIM_WRAPPER(parentObj)) {
|
||||
bool ok = MorphSlimWrapper(cx, parentObj);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
// Recursively fix up orphans on the parent chain.
|
||||
rv = RescueOrphans(parentObj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -3553,18 +3448,3 @@ XPCJSObjectHolder::newHolder(JSObject* obj)
|
|||
}
|
||||
return new XPCJSObjectHolder(obj);
|
||||
}
|
||||
|
||||
JSBool
|
||||
MorphSlimWrapper(JSContext *cx, HandleObject obj)
|
||||
{
|
||||
SLIM_LOG(("***** morphing from MorphSlimToWrapper (%p, %p)\n",
|
||||
obj, static_cast<nsISupports*>(xpc_GetJSPrivate(obj))));
|
||||
|
||||
nsISupports* object = static_cast<nsISupports*>(xpc_GetJSPrivate(obj));
|
||||
nsWrapperCache *cache = nullptr;
|
||||
CallQueryInterface(object, &cache);
|
||||
nsRefPtr<XPCWrappedNative> wn;
|
||||
nsresult rv = XPCWrappedNative::Morph(obj, nullptr, cache,
|
||||
getter_AddRefs(wn));
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
|
|
@ -30,13 +30,6 @@ static JSBool Throw(nsresult errNum, JSContext* cx)
|
|||
|
||||
// Handy macro used in many callback stub below.
|
||||
|
||||
#define MORPH_SLIM_WRAPPER(cx, obj) \
|
||||
PR_BEGIN_MACRO \
|
||||
SLIM_LOG_WILL_MORPH(cx, obj); \
|
||||
if (IS_SLIM_WRAPPER(obj) && !MorphSlimWrapper(cx, obj)) \
|
||||
return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx); \
|
||||
PR_END_MACRO
|
||||
|
||||
#define THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper) \
|
||||
PR_BEGIN_MACRO \
|
||||
if (!wrapper) \
|
||||
|
@ -173,7 +166,6 @@ XPC_WN_DoubleWrappedGetter(JSContext *cx, unsigned argc, jsval *vp)
|
|||
if (!obj)
|
||||
return false;
|
||||
|
||||
MORPH_SLIM_WRAPPER(cx, obj);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
|
@ -513,7 +505,6 @@ XPC_WN_Shared_Convert(JSContext *cx, JSHandleObject obj, JSType type, JSMutableH
|
|||
return true;
|
||||
}
|
||||
|
||||
MORPH_SLIM_WRAPPER(cx, obj);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
|
@ -566,7 +557,6 @@ XPC_WN_Shared_Convert(JSContext *cx, JSHandleObject obj, JSType type, JSMutableH
|
|||
static JSBool
|
||||
XPC_WN_Shared_Enumerate(JSContext *cx, JSHandleObject obj)
|
||||
{
|
||||
MORPH_SLIM_WRAPPER(cx, obj);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
|
@ -693,7 +683,6 @@ XPC_WN_NoHelper_Trace(JSTracer *trc, JSObject *obj)
|
|||
static JSBool
|
||||
XPC_WN_NoHelper_Resolve(JSContext *cx, JSHandleObject obj, JSHandleId id)
|
||||
{
|
||||
MORPH_SLIM_WRAPPER(cx, obj);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj, NullPtr(), id);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
|
@ -826,7 +815,6 @@ XPCWrappedNativeJSClass XPC_WN_NoHelper_JSClass = {
|
|||
static JSBool
|
||||
XPC_WN_MaybeResolvingPropertyStub(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp)
|
||||
{
|
||||
MORPH_SLIM_WRAPPER(cx, obj);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
|
@ -846,7 +834,6 @@ XPC_WN_MaybeResolvingStrictPropertyStub(JSContext *cx, JSHandleObject obj, JSHan
|
|||
static JSBool
|
||||
XPC_WN_MaybeResolvingDeletePropertyStub(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool *succeeded)
|
||||
{
|
||||
MORPH_SLIM_WRAPPER(cx, obj);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
|
@ -859,13 +846,6 @@ XPC_WN_MaybeResolvingDeletePropertyStub(JSContext *cx, JSHandleObject obj, JSHan
|
|||
}
|
||||
|
||||
// macro fun!
|
||||
#define PRE_HELPER_STUB_NO_SLIM \
|
||||
XPCWrappedNative* wrapper = \
|
||||
XPCWrappedNative::GetAndMorphWrappedNativeOfJSObject(cx, obj); \
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper); \
|
||||
bool retval = true; \
|
||||
nsresult rv = wrapper->GetScriptableCallback()->
|
||||
|
||||
#define PRE_HELPER_STUB \
|
||||
XPCWrappedNative* wrapper; \
|
||||
nsIXPCScriptable* si; \
|
||||
|
@ -934,8 +914,7 @@ XPC_WN_Helper_SetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBo
|
|||
static JSBool
|
||||
XPC_WN_Helper_Convert(JSContext *cx, JSHandleObject obj, JSType type, JSMutableHandleValue vp)
|
||||
{
|
||||
SLIM_LOG_WILL_MORPH(cx, obj);
|
||||
PRE_HELPER_STUB_NO_SLIM
|
||||
PRE_HELPER_STUB
|
||||
Convert(wrapper, cx, obj, type, vp.address(), &retval);
|
||||
POST_HELPER_STUB
|
||||
}
|
||||
|
@ -963,8 +942,7 @@ XPC_WN_Helper_Call(JSContext *cx, unsigned argc, jsval *vp)
|
|||
|
||||
MOZ_ASSERT(obj == ccx.GetFlattenedJSObject());
|
||||
|
||||
SLIM_LOG_WILL_MORPH(cx, obj);
|
||||
PRE_HELPER_STUB_NO_SLIM
|
||||
PRE_HELPER_STUB
|
||||
Call(wrapper, cx, obj, args, &retval);
|
||||
POST_HELPER_STUB
|
||||
}
|
||||
|
@ -984,8 +962,7 @@ XPC_WN_Helper_Construct(JSContext *cx, unsigned argc, jsval *vp)
|
|||
|
||||
MOZ_ASSERT(obj == ccx.GetFlattenedJSObject());
|
||||
|
||||
SLIM_LOG_WILL_MORPH(cx, obj);
|
||||
PRE_HELPER_STUB_NO_SLIM
|
||||
PRE_HELPER_STUB
|
||||
Construct(wrapper, cx, obj, args, &retval);
|
||||
POST_HELPER_STUB
|
||||
}
|
||||
|
@ -993,9 +970,8 @@ XPC_WN_Helper_Construct(JSContext *cx, unsigned argc, jsval *vp)
|
|||
static JSBool
|
||||
XPC_WN_Helper_HasInstance(JSContext *cx, JSHandleObject obj, JSMutableHandleValue valp, JSBool *bp)
|
||||
{
|
||||
SLIM_LOG_WILL_MORPH(cx, obj);
|
||||
bool retval2;
|
||||
PRE_HELPER_STUB_NO_SLIM
|
||||
PRE_HELPER_STUB
|
||||
HasInstance(wrapper, cx, obj, valp, &retval2, &retval);
|
||||
*bp = retval2;
|
||||
POST_HELPER_STUB
|
||||
|
@ -1158,8 +1134,6 @@ XPC_WN_JSOp_Enumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
|
|||
return JS_EnumerateState(cx, obj, enum_op, statep, idp);
|
||||
}
|
||||
|
||||
MORPH_SLIM_WRAPPER(cx, obj);
|
||||
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
|
@ -1453,18 +1427,6 @@ XPC_WN_CallMethod(JSContext *cx, unsigned argc, jsval *vp)
|
|||
if (!obj)
|
||||
return false;
|
||||
|
||||
#ifdef DEBUG_slimwrappers
|
||||
{
|
||||
JSFunction* fun = funobj->getFunctionPrivate();
|
||||
JSString *funid = JS_GetFunctionDisplayId(fun);
|
||||
JSAutoByteString bytes;
|
||||
const char *funname = !funid ? "" : bytes.encodeLatin1(cx, funid) ? bytes.ptr() : "<error>";
|
||||
SLIM_LOG_WILL_MORPH_FOR_PROP(cx, obj, funname);
|
||||
}
|
||||
#endif
|
||||
if (IS_SLIM_WRAPPER(obj) && !MorphSlimWrapper(cx, obj))
|
||||
return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
|
||||
|
||||
obj = FixUpThisIfBroken(obj, funobj);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj, funobj, JSID_VOIDHANDLE, argc,
|
||||
JS_ARGV(cx, vp), vp);
|
||||
|
@ -1490,21 +1452,6 @@ XPC_WN_GetterSetter(JSContext *cx, unsigned argc, jsval *vp)
|
|||
if (!obj)
|
||||
return false;
|
||||
|
||||
#ifdef DEBUG_slimwrappers
|
||||
{
|
||||
const char* funname = nullptr;
|
||||
JSAutoByteString bytes;
|
||||
if (JS_TypeOfValue(cx, JS_CALLEE(cx, vp)) == JSTYPE_FUNCTION) {
|
||||
JSString *funid = JS_GetFunctionDisplayId(funobj->getFunctionPrivate());
|
||||
funname = !funid ? "" : bytes.encodeLatin1(cx, funid) ? bytes.ptr() : "<error>";
|
||||
}
|
||||
SLIM_LOG_WILL_MORPH_FOR_PROP(cx, obj, funname);
|
||||
}
|
||||
#endif
|
||||
if (IS_SLIM_WRAPPER(obj) && !MorphSlimWrapper(cx, obj))
|
||||
return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
|
||||
|
||||
|
||||
obj = FixUpThisIfBroken(obj, funobj);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj, funobj, JSID_VOIDHANDLE, argc,
|
||||
JS_ARGV(cx, vp), vp);
|
||||
|
@ -1787,7 +1734,6 @@ js::Class XPC_WN_NoMods_NoCall_Proto_JSClass = {
|
|||
static JSBool
|
||||
XPC_WN_TearOff_Enumerate(JSContext *cx, JSHandleObject obj)
|
||||
{
|
||||
MORPH_SLIM_WRAPPER(cx, obj);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
|
@ -1810,7 +1756,6 @@ XPC_WN_TearOff_Enumerate(JSContext *cx, JSHandleObject obj)
|
|||
static JSBool
|
||||
XPC_WN_TearOff_Resolve(JSContext *cx, JSHandleObject obj, JSHandleId id)
|
||||
{
|
||||
MORPH_SLIM_WRAPPER(cx, obj);
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
|
|
|
@ -1080,21 +1080,6 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
xpc_MorphSlimWrapper(JSContext *cx, nsISupports *tomorph)
|
||||
{
|
||||
nsWrapperCache *cache;
|
||||
CallQueryInterface(tomorph, &cache);
|
||||
if (!cache)
|
||||
return NS_OK;
|
||||
|
||||
RootedObject obj(cx, cache->GetWrapper());
|
||||
if (!obj || !IS_SLIM_WRAPPER(obj))
|
||||
return NS_OK;
|
||||
NS_ENSURE_STATE(MorphSlimWrapper(cx, obj));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
NativeInterface2JSObject(HandleObject aScope,
|
||||
nsISupports *aCOMObj,
|
||||
|
@ -1236,12 +1221,9 @@ nsXPConnect::GetWrappedNativeOfJSObject(JSContext * aJSContext,
|
|||
NS_ASSERTION(_retval, "bad param");
|
||||
|
||||
RootedObject aJSObj(aJSContext, aJSObjArg);
|
||||
SLIM_LOG_WILL_MORPH(aJSContext, aJSObj);
|
||||
nsIXPConnectWrappedNative* wrapper =
|
||||
XPCWrappedNative::GetAndMorphWrappedNativeOfJSObject(aJSContext, aJSObj);
|
||||
if (wrapper) {
|
||||
NS_ADDREF(wrapper);
|
||||
*_retval = wrapper;
|
||||
aJSObj = js::CheckedUnwrap(aJSObj, /* stopAtOuter = */ false);
|
||||
if (aJSObj && IS_WN_WRAPPER(aJSObj)) {
|
||||
NS_IF_ADDREF(*_retval = XPCWrappedNative::Get(aJSObj));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -304,16 +304,6 @@ inline XPCWrappedNativeProto* GetSlimWrapperProto(JSObject *obj)
|
|||
return static_cast<XPCWrappedNativeProto*>(v.toPrivate());
|
||||
}
|
||||
|
||||
// A slim wrapper is identified by having a native pointer in its reserved slot.
|
||||
// This function, therefore, does the official transition from a slim wrapper to
|
||||
// a non-slim wrapper.
|
||||
inline void MorphMultiSlot(JSObject *obj)
|
||||
{
|
||||
MOZ_ASSERT(IS_SLIM_WRAPPER(obj));
|
||||
JS_SetReservedSlot(obj, WRAPPER_MULTISLOT, JSVAL_NULL);
|
||||
MOZ_ASSERT(!IS_SLIM_WRAPPER(obj));
|
||||
}
|
||||
|
||||
inline void SetWNExpandoChain(JSObject *obj, JSObject *chain)
|
||||
{
|
||||
MOZ_ASSERT(IS_WN_WRAPPER(obj));
|
||||
|
@ -2241,8 +2231,6 @@ private:
|
|||
XPCNativeScriptableInfo* mScriptableInfo;
|
||||
};
|
||||
|
||||
extern JSBool MorphSlimWrapper(JSContext *cx, JS::HandleObject obj);
|
||||
|
||||
/***********************************************/
|
||||
// XPCWrappedNativeTearOff represents the info needed to make calls to one
|
||||
// interface on the underlying native object of a XPCWrappedNative.
|
||||
|
@ -2489,22 +2477,6 @@ public:
|
|||
XPCNativeInterface* Interface,
|
||||
XPCWrappedNative** wrapper);
|
||||
|
||||
static XPCWrappedNative*
|
||||
GetAndMorphWrappedNativeOfJSObject(JSContext* cx, JSObject* obj_)
|
||||
{
|
||||
JS::RootedObject obj(cx, obj_);
|
||||
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
if (!IS_WRAPPER_CLASS(js::GetObjectClass(obj)))
|
||||
return nullptr;
|
||||
|
||||
if (IS_SLIM_WRAPPER_OBJECT(obj) && !MorphSlimWrapper(cx, obj))
|
||||
return nullptr;
|
||||
MOZ_ASSERT(IS_WN_WRAPPER(obj));
|
||||
return XPCWrappedNative::Get(obj);
|
||||
}
|
||||
|
||||
static nsresult
|
||||
ReparentWrapperIfFound(XPCWrappedNativeScope* aOldScope,
|
||||
XPCWrappedNativeScope* aNewScope,
|
||||
|
@ -2668,7 +2640,6 @@ private:
|
|||
private:
|
||||
|
||||
JSBool Init(JS::HandleObject parent, const XPCNativeScriptableCreateInfo* sci);
|
||||
JSBool Init(JSObject *existingJSObject);
|
||||
JSBool FinishInit();
|
||||
|
||||
JSBool ExtendSet(XPCNativeInterface* aInterface);
|
||||
|
|
|
@ -82,9 +82,6 @@ xpc_LocalizeRuntime(JSRuntime *rt);
|
|||
NS_EXPORT_(void)
|
||||
xpc_DelocalizeRuntime(JSRuntime *rt);
|
||||
|
||||
nsresult
|
||||
xpc_MorphSlimWrapper(JSContext *cx, nsISupports *tomorph);
|
||||
|
||||
static inline bool IS_WRAPPER_CLASS(js::Class* clazz)
|
||||
{
|
||||
return clazz->ext.isWrappedNative;
|
||||
|
|
|
@ -152,11 +152,6 @@ WrapperFactory::PrepareForWrapping(JSContext *cx, HandleObject scope,
|
|||
// We should never get a proxy here (the JS engine unwraps those for us).
|
||||
MOZ_ASSERT(!IsWrapper(obj));
|
||||
|
||||
// As soon as an object is wrapped in a security wrapper, it morphs to be
|
||||
// a fat wrapper. (see also: bug XXX).
|
||||
if (IS_SLIM_WRAPPER(obj) && !MorphSlimWrapper(cx, obj))
|
||||
return nullptr;
|
||||
|
||||
// If the object being wrapped is a prototype for a standard class and the
|
||||
// wrapper does not subsumes the wrappee, use the one from the content
|
||||
// compartment. This is generally safer all-around, and in the COW case this
|
||||
|
|
Загрузка…
Ссылка в новой задаче