Bug 958643, part 4 - Inline CreateHolderIfNeeded. r=krizsa
The last argument is always null, so we don't need this function any more.
MozReview-Commit-ID: 5YWMO9ywZK3
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -709,32 +709,16 @@ XPCConvert::JSData2Native(void* d, Handl
}
default:
NS_ERROR("bad type");
return false;
}
return true;
}
-static inline bool
-CreateHolderIfNeeded(JSContext* cx, HandleObject obj, MutableHandleValue d,
- nsIXPConnectJSObjectHolder** dest)
-{
- if (dest) {
- if (!obj)
- return false;
- RefPtr<XPCJSObjectHolder> objHolder = new XPCJSObjectHolder(cx, obj);
- objHolder.forget(dest);
- }
-
- d.setObjectOrNull(obj);
-
- return true;
-}
-
/***************************************************************************/
// static
bool
XPCConvert::NativeInterface2JSObject(MutableHandleValue d,
xpcObjectHelper& aHelper,
const nsID* iid,
bool allowNativeWrapper,
nsresult* pErr)
@@ -774,29 +758,31 @@ XPCConvert::NativeInterface2JSObject(Mut
js::AssertSameCompartment(cx, global);
flat = cache->WrapObject(cx, nullptr);
if (!flat)
return false;
}
if (flat) {
if (allowNativeWrapper && !JS_WrapObject(cx, &flat))
return false;
- return CreateHolderIfNeeded(cx, flat, d, nullptr);
+ d.setObjectOrNull(flat);
+ return true;
}
if (iid->Equals(NS_GET_IID(nsISupports))) {
// Check for a Promise being returned via nsISupports. In that
// situation, we want to dig out its underlying JS object and return
// that.
RefPtr<Promise> promise = do_QueryObject(aHelper.Object());
if (promise) {
flat = promise->PromiseObj();
if (!JS_WrapObject(cx, &flat))
return false;
- return CreateHolderIfNeeded(cx, flat, d, nullptr);
+ d.setObjectOrNull(flat);
+ return true;
}
}
// Don't double wrap CPOWs. This is a temporary measure for compatibility
// with objects that don't provide necessary QIs (such as objects under
// the new DOM bindings). We expect the other side of the CPOW to have
// the appropriate wrappers in place.
RootedObject cpow(cx, UnwrapNativeCPOW(aHelper.Object()));