зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1190436 - Part 2: Use an early return in XPCConvert::JSObject2NativeInterface. r=gabor
This commit is contained in:
Родитель
074f97cf4c
Коммит
c3dc941170
|
@ -923,39 +923,33 @@ XPCConvert::JSObject2NativeInterface(void** dest, HandleObject src,
|
|||
|
||||
// Deal with slim wrappers here.
|
||||
if (GetISupportsFromJSObject(inner ? inner : src, &iface)) {
|
||||
if (iface)
|
||||
return NS_SUCCEEDED(iface->QueryInterface(*iid, dest));
|
||||
|
||||
return false;
|
||||
return iface && NS_SUCCEEDED(iface->QueryInterface(*iid, dest));
|
||||
}
|
||||
}
|
||||
|
||||
// else...
|
||||
|
||||
nsRefPtr<nsXPCWrappedJS> wrapper;
|
||||
nsresult rv = nsXPCWrappedJS::GetNewOrUsed(src, *iid, getter_AddRefs(wrapper));
|
||||
if (pErr)
|
||||
*pErr = rv;
|
||||
if (NS_SUCCEEDED(rv) && wrapper) {
|
||||
// If the caller wanted to aggregate this JS object to a native,
|
||||
// attach it to the wrapper. Note that we allow a maximum of one
|
||||
// aggregated native for a given XPCWrappedJS.
|
||||
if (aOuter)
|
||||
wrapper->SetAggregatedNativeObject(aOuter);
|
||||
|
||||
// We need to go through the QueryInterface logic to make this return
|
||||
// the right thing for the various 'special' interfaces; e.g.
|
||||
// nsIPropertyBag. We must use AggregatedQueryInterface in cases where
|
||||
// there is an outer to avoid nasty recursion.
|
||||
rv = aOuter ? wrapper->AggregatedQueryInterface(*iid, dest) :
|
||||
wrapper->QueryInterface(*iid, dest);
|
||||
if (pErr)
|
||||
*pErr = rv;
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
if (NS_FAILED(rv) || !wrapper)
|
||||
return false;
|
||||
|
||||
// else...
|
||||
return false;
|
||||
// If the caller wanted to aggregate this JS object to a native,
|
||||
// attach it to the wrapper. Note that we allow a maximum of one
|
||||
// aggregated native for a given XPCWrappedJS.
|
||||
if (aOuter)
|
||||
wrapper->SetAggregatedNativeObject(aOuter);
|
||||
|
||||
// We need to go through the QueryInterface logic to make this return
|
||||
// the right thing for the various 'special' interfaces; e.g.
|
||||
// nsIPropertyBag. We must use AggregatedQueryInterface in cases where
|
||||
// there is an outer to avoid nasty recursion.
|
||||
rv = aOuter ? wrapper->AggregatedQueryInterface(*iid, dest) :
|
||||
wrapper->QueryInterface(*iid, dest);
|
||||
if (pErr)
|
||||
*pErr = rv;
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
|
Загрузка…
Ссылка в новой задаче