From 660ca5d5cf626a7318f70066db9f29cf5626cfb8 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 21 Nov 2012 13:20:05 -0800 Subject: [PATCH] Bug 808608 - Remove unnecessary outparam. r=mrbkap --- content/base/src/nsNodeUtils.cpp | 5 +---- content/html/document/src/nsHTMLDocument.cpp | 4 +--- js/xpconnect/idl/nsIXPConnect.idl | 4 ++-- js/xpconnect/src/XPCWrappedNative.cpp | 13 +++---------- js/xpconnect/src/nsXPConnect.cpp | 12 +++++++----- js/xpconnect/src/xpcprivate.h | 3 +-- 6 files changed, 15 insertions(+), 26 deletions(-) diff --git a/content/base/src/nsNodeUtils.cpp b/content/base/src/nsNodeUtils.cpp index 176a112e1e81..01d8bc5303ff 100644 --- a/content/base/src/nsNodeUtils.cpp +++ b/content/base/src/nsNodeUtils.cpp @@ -527,10 +527,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep, if (aCx && wrapper) { nsIXPConnect *xpc = nsContentUtils::XPConnect(); if (xpc) { - nsCOMPtr oldWrapper; - rv = xpc->ReparentWrappedNativeIfFound(aCx, wrapper, aNewScope, aNode, - getter_AddRefs(oldWrapper)); - + rv = xpc->ReparentWrappedNativeIfFound(aCx, wrapper, aNewScope, aNode); if (NS_FAILED(rv)) { aNode->mNodeInfo.swap(nodeInfo); diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index bd18f85888bb..9f706fba98fe 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -1515,11 +1515,9 @@ nsHTMLDocument::Open(const nsAString& aContentTypeOrUrl, nsCOMPtr newScope(do_QueryReferent(mScopeObject)); if (oldScope && newScope != oldScope) { nsIXPConnect *xpc = nsContentUtils::XPConnect(); - nsCOMPtr ignored; rv = xpc->ReparentWrappedNativeIfFound(cx, oldScope->GetGlobalJSObject(), newScope->GetGlobalJSObject(), - static_cast(this), - getter_AddRefs(ignored)); + static_cast(this)); NS_ENSURE_SUCCESS(rv, rv); rv = xpc->RescueOrphansInScope(cx, oldScope->GetGlobalJSObject()); NS_ENSURE_SUCCESS(rv, rv); diff --git a/js/xpconnect/idl/nsIXPConnect.idl b/js/xpconnect/idl/nsIXPConnect.idl index 91eec4920881..84769b6e23a6 100644 --- a/js/xpconnect/idl/nsIXPConnect.idl +++ b/js/xpconnect/idl/nsIXPConnect.idl @@ -289,7 +289,7 @@ interface nsIXPCFunctionThisTranslator : nsISupports { 0xbd, 0xd6, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } } %} -[uuid(e28a33ce-dfe9-4816-ae20-0f1dc8077230)] +[uuid(b551afea-f38c-46d4-bc93-f1e05aebfec2)] interface nsIXPConnect : nsISupports { %{ C++ @@ -519,7 +519,7 @@ interface nsIXPConnect : nsISupports setFunctionThisTranslator(in nsIIDRef aIID, in nsIXPCFunctionThisTranslator aTranslator); - nsIXPConnectJSObjectHolder + void reparentWrappedNativeIfFound(in JSContextPtr aJSContext, in JSObjectPtr aScope, in JSObjectPtr aNewParent, diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp index cb9474fbc649..ce349fc955fb 100644 --- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -1423,8 +1423,7 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCCallContext& ccx, XPCWrappedNativeScope* aOldScope, XPCWrappedNativeScope* aNewScope, JSObject* aNewParent, - nsISupports* aCOMObj, - XPCWrappedNative** aWrapper) + nsISupports* aCOMObj) { XPCNativeInterface* iface = XPCNativeInterface::GetISupports(ccx); @@ -1455,10 +1454,8 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCCallContext& ccx, flat = wrapper->GetFlatJSObject(); } - if (!flat) { - *aWrapper = nullptr; + if (!flat) return NS_OK; - } // ReparentWrapperIfFound is really only meant to be called from DOM code // which must happen only on the main thread. Bail if we're on some other @@ -1657,9 +1654,6 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCCallContext& ccx, } } - *aWrapper = nullptr; - wrapper.swap(*aWrapper); - return NS_OK; } @@ -1755,10 +1749,9 @@ XPCWrappedNative::RescueOrphans(XPCCallContext& ccx) // We've been orphaned. Find where our parent went, and follow it. JSObject *parentGhost = js::GetObjectParent(mFlatJSObject); JSObject *realParent = js::UnwrapObject(parentGhost); - nsRefPtr ignored; return ReparentWrapperIfFound(ccx, GetObjectScope(parentGhost), GetObjectScope(realParent), - realParent, mIdentity, getter_AddRefs(ignored)); + realParent, mIdentity); } #define IS_TEAROFF_CLASS(clazz) \ diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index 912dca77f87f..43609cf2f60d 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -1462,13 +1462,15 @@ nsXPConnect::GetWrappedNativeOfNativeObject(JSContext * aJSContext, return NS_OK; } -/* nsIXPConnectJSObjectHolder reparentWrappedNativeIfFound (in JSContextPtr aJSContext, in JSObjectPtr aScope, in JSObjectPtr aNewParent, in nsISupports aCOMObj); */ +/* void reparentWrappedNativeIfFound (in JSContextPtr aJSContext, + * in JSObjectPtr aScope, + * in JSObjectPtr aNewParent, + * in nsISupports aCOMObj); */ NS_IMETHODIMP nsXPConnect::ReparentWrappedNativeIfFound(JSContext * aJSContext, JSObject * aScope, JSObject * aNewParent, - nsISupports *aCOMObj, - nsIXPConnectJSObjectHolder **_retval) + nsISupports *aCOMObj) { XPCCallContext ccx(NATIVE_CALLER, aJSContext); if (!ccx.IsValid()) @@ -1480,8 +1482,8 @@ nsXPConnect::ReparentWrappedNativeIfFound(JSContext * aJSContext, return UnexpectedFailure(NS_ERROR_FAILURE); return XPCWrappedNative:: - ReparentWrapperIfFound(ccx, scope, scope2, aNewParent, aCOMObj, - (XPCWrappedNative**) _retval); + ReparentWrapperIfFound(ccx, scope, scope2, aNewParent, + aCOMObj); } static JSDHashOperator diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index bab3abc5d615..5f0462b69888 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -2780,8 +2780,7 @@ public: XPCWrappedNativeScope* aOldScope, XPCWrappedNativeScope* aNewScope, JSObject* aNewParent, - nsISupports* aCOMObj, - XPCWrappedNative** aWrapper); + nsISupports* aCOMObj); bool IsOrphan(); nsresult RescueOrphans(XPCCallContext& ccx);