mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1143651 - don't use CallQueryInterface when the compiler can do the cast for us; r=ehsan
This commit is contained in:
parent
6a1aeb9960
commit
4c7234747e
@ -1801,13 +1801,10 @@ nsSHistory::SetRootDocShell(nsIDocShell * aDocShell)
|
||||
NS_IMETHODIMP
|
||||
nsSHistory::GetSHistoryEnumerator(nsISimpleEnumerator** aEnumerator)
|
||||
{
|
||||
nsresult status = NS_OK;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aEnumerator);
|
||||
nsSHEnumerator * iterator = new nsSHEnumerator(this);
|
||||
if (iterator && NS_FAILED(status = CallQueryInterface(iterator, aEnumerator)))
|
||||
delete iterator;
|
||||
return status;
|
||||
nsRefPtr<nsSHEnumerator> iterator = new nsSHEnumerator(this);
|
||||
iterator.forget(aEnumerator);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,7 +46,8 @@ MultipartFileImpl::GetInternalStream(nsIInputStream** aStream)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return CallQueryInterface(stream, aStream);
|
||||
stream.forget(aStream);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<FileImpl>
|
||||
|
@ -2499,7 +2499,9 @@ nsFrameLoader::GetMessageManager(nsIMessageSender** aManager)
|
||||
{
|
||||
EnsureMessageManager();
|
||||
if (mMessageManager) {
|
||||
CallQueryInterface(mMessageManager, aManager);
|
||||
nsRefPtr<nsFrameMessageManager> mm(mMessageManager);
|
||||
mm.forget(aManager);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1490,11 +1490,12 @@ NS_NewGlobalMessageManager(nsIMessageBroadcaster** aResult)
|
||||
{
|
||||
NS_ENSURE_TRUE(XRE_GetProcessType() == GeckoProcessType_Default,
|
||||
NS_ERROR_NOT_AVAILABLE);
|
||||
nsFrameMessageManager* mm = new nsFrameMessageManager(nullptr,
|
||||
nullptr,
|
||||
MM_CHROME | MM_GLOBAL | MM_BROADCASTER);
|
||||
nsRefPtr<nsFrameMessageManager> mm = new nsFrameMessageManager(nullptr,
|
||||
nullptr,
|
||||
MM_CHROME | MM_GLOBAL | MM_BROADCASTER);
|
||||
RegisterStrongMemoryReporter(new MessageManagerReporter());
|
||||
return CallQueryInterface(mm, aResult);
|
||||
mm.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDataHashtable<nsStringHashKey, nsMessageManagerScriptHolder*>*
|
||||
@ -2008,7 +2009,8 @@ NS_NewParentProcessMessageManager(nsIMessageBroadcaster** aResult)
|
||||
MM_CHROME | MM_PROCESSMANAGER | MM_BROADCASTER);
|
||||
nsFrameMessageManager::sParentProcessManager = mm;
|
||||
nsFrameMessageManager::NewProcessMessageManager(false); // Create same process message manager.
|
||||
return CallQueryInterface(mm, aResult);
|
||||
mm.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -2055,9 +2057,10 @@ NS_NewChildProcessMessageManager(nsISyncMessageSender** aResult)
|
||||
nullptr,
|
||||
MM_PROCESSMANAGER | MM_OWNSCALLBACK);
|
||||
nsFrameMessageManager::SetChildProcessManager(mm);
|
||||
ProcessGlobal* global = new ProcessGlobal(mm);
|
||||
nsRefPtr<ProcessGlobal> global = new ProcessGlobal(mm);
|
||||
NS_ENSURE_TRUE(global->Init(), NS_ERROR_UNEXPECTED);
|
||||
return CallQueryInterface(global, aResult);
|
||||
global.forget(aResult);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
|
@ -40,14 +40,12 @@
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
nsresult NS_NewHTMLContentSerializer(nsIContentSerializer** aSerializer)
|
||||
nsresult
|
||||
NS_NewHTMLContentSerializer(nsIContentSerializer** aSerializer)
|
||||
{
|
||||
nsHTMLContentSerializer* it = new nsHTMLContentSerializer();
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return CallQueryInterface(it, aSerializer);
|
||||
nsRefPtr<nsHTMLContentSerializer> it = new nsHTMLContentSerializer();
|
||||
it.forget(aSerializer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsHTMLContentSerializer::nsHTMLContentSerializer()
|
||||
|
@ -54,14 +54,12 @@ static int32_t GetUnicharStringWidth(const char16_t* pwcs, int32_t n);
|
||||
static const uint32_t TagStackSize = 500;
|
||||
static const uint32_t OLStackSize = 100;
|
||||
|
||||
nsresult NS_NewPlainTextSerializer(nsIContentSerializer** aSerializer)
|
||||
nsresult
|
||||
NS_NewPlainTextSerializer(nsIContentSerializer** aSerializer)
|
||||
{
|
||||
nsPlainTextSerializer* it = new nsPlainTextSerializer();
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return CallQueryInterface(it, aSerializer);
|
||||
nsRefPtr<nsPlainTextSerializer> it = new nsPlainTextSerializer();
|
||||
it.forget(aSerializer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsPlainTextSerializer::nsPlainTextSerializer()
|
||||
|
@ -40,14 +40,12 @@ static const int32_t kLongLineLen = 128;
|
||||
|
||||
#define kXMLNS "xmlns"
|
||||
|
||||
nsresult NS_NewXHTMLContentSerializer(nsIContentSerializer** aSerializer)
|
||||
nsresult
|
||||
NS_NewXHTMLContentSerializer(nsIContentSerializer** aSerializer)
|
||||
{
|
||||
nsXHTMLContentSerializer* it = new nsXHTMLContentSerializer();
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return CallQueryInterface(it, aSerializer);
|
||||
nsRefPtr<nsXHTMLContentSerializer> it = new nsXHTMLContentSerializer();
|
||||
it.forget(aSerializer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsXHTMLContentSerializer::nsXHTMLContentSerializer()
|
||||
|
@ -43,14 +43,12 @@ using namespace mozilla::dom;
|
||||
#define INDENT_STRING " "
|
||||
#define INDENT_STRING_LENGTH 2
|
||||
|
||||
nsresult NS_NewXMLContentSerializer(nsIContentSerializer** aSerializer)
|
||||
nsresult
|
||||
NS_NewXMLContentSerializer(nsIContentSerializer** aSerializer)
|
||||
{
|
||||
nsXMLContentSerializer* it = new nsXMLContentSerializer();
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return CallQueryInterface(it, aSerializer);
|
||||
nsRefPtr<nsXMLContentSerializer> it = new nsXMLContentSerializer();
|
||||
it.forget(aSerializer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsXMLContentSerializer::nsXMLContentSerializer()
|
||||
|
@ -1910,7 +1910,7 @@ HTMLInputElement::GetList(nsIDOMHTMLElement** aValue)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
CallQueryInterface(element, aValue);
|
||||
element.forget(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -38,13 +38,12 @@ NS_NewXBLContentSink(nsIXMLContentSink** aResult,
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
nsXBLContentSink* it = new nsXBLContentSink();
|
||||
|
||||
nsCOMPtr<nsIXMLContentSink> kungFuDeathGrip = it;
|
||||
nsRefPtr<nsXBLContentSink> it = new nsXBLContentSink();
|
||||
nsresult rv = it->Init(aDoc, aURI, aContainer);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(it, aResult);
|
||||
it.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsXBLContentSink::nsXBLContentSink()
|
||||
|
@ -86,13 +86,13 @@ NS_NewXMLContentSink(nsIXMLContentSink** aResult,
|
||||
if (nullptr == aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsXMLContentSink* it = new nsXMLContentSink();
|
||||
nsRefPtr<nsXMLContentSink> it = new nsXMLContentSink();
|
||||
|
||||
nsCOMPtr<nsIXMLContentSink> kungFuDeathGrip = it;
|
||||
nsresult rv = it->Init(aDoc, aURI, aContainer, aChannel);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(it, aResult);
|
||||
|
||||
it.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsXMLContentSink::nsXMLContentSink()
|
||||
|
@ -172,7 +172,7 @@ nsXULCommandDispatcher::GetFocusedWindow(nsIDOMWindow** aWindow)
|
||||
if (domdoc && !nsContentUtils::CanCallerAccess(domdoc))
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
|
||||
CallQueryInterface(window, aWindow);
|
||||
window.forget(aWindow);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1314,14 +1314,14 @@ nsXULTemplateQueryProcessorRDF::ParseLiteral(const nsString& aParseType,
|
||||
rv = gRDFService->GetIntLiteral(intValue, getter_AddRefs(intLiteral));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = CallQueryInterface(intLiteral, aResult);
|
||||
intLiteral.forget(aResult);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIRDFLiteral> literal;
|
||||
rv = gRDFService->GetLiteral(aValue.get(), getter_AddRefs(literal));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = CallQueryInterface(literal, aResult);
|
||||
literal.forget(aResult);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -141,7 +141,8 @@ static nsresult EncodeImageData(DataSourceSurface* aDataSurface,
|
||||
aDataSurface->Unmap();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(encoder, aStream);
|
||||
encoder.forget(aStream);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgTools::EncodeImage(imgIContainer *aContainer,
|
||||
|
@ -504,7 +504,8 @@ nsJARURI::Clone(nsIURI **result)
|
||||
rv = CloneWithJARFileInternal(mJARFile, eHonorRef, getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return CallQueryInterface(uri, result);
|
||||
uri.forget(result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -516,7 +517,8 @@ nsJARURI::CloneIgnoringRef(nsIURI **result)
|
||||
rv = CloneWithJARFileInternal(mJARFile, eIgnoreRef, getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return CallQueryInterface(uri, result);
|
||||
uri.forget(result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -749,11 +749,9 @@ Preferences::GetBranch(const char *aPrefRoot, nsIPrefBranch **_retval)
|
||||
|
||||
if ((nullptr != aPrefRoot) && (*aPrefRoot != '\0')) {
|
||||
// TODO: - cache this stuff and allow consumers to share branches (hold weak references I think)
|
||||
nsPrefBranch* prefBranch = new nsPrefBranch(aPrefRoot, false);
|
||||
if (!prefBranch)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = CallQueryInterface(prefBranch, _retval);
|
||||
nsRefPtr<nsPrefBranch> prefBranch = new nsPrefBranch(aPrefRoot, false);
|
||||
prefBranch.forget(_retval);
|
||||
rv = NS_OK;
|
||||
} else {
|
||||
// special case caching the default root
|
||||
nsCOMPtr<nsIPrefBranch> root(sRootBranch);
|
||||
|
@ -289,7 +289,8 @@ nsresult AndroidCaptureProvider::Init(nsACString& aContentType,
|
||||
} else {
|
||||
NS_NOTREACHED("Should not have asked Android for this type!");
|
||||
}
|
||||
return CallQueryInterface(stream, aStream);
|
||||
stream.forget(aStream);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<AndroidCaptureProvider> GetAndroidCaptureProvider() {
|
||||
|
@ -50,7 +50,8 @@ nsDeviceProtocolHandler::NewURI(const nsACString &spec,
|
||||
nsresult rv = uri->SetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(uri, result);
|
||||
uri.forget(result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -66,7 +67,8 @@ nsDeviceProtocolHandler::NewChannel2(nsIURI* aURI,
|
||||
rv = channel->SetLoadInfo(aLoadInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(channel, aResult);
|
||||
channel.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -237,10 +237,9 @@ nsResProtocolHandler::NewURI(const nsACString &aSpec,
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsResURL *resURL = new nsResURL();
|
||||
nsRefPtr<nsResURL> resURL = new nsResURL();
|
||||
if (!resURL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(resURL);
|
||||
|
||||
// unescape any %2f and %2e to make sure nsStandardURL coalesces them.
|
||||
// Later net_GetFileFromURLSpec() will do a full unescape and we want to
|
||||
@ -272,9 +271,9 @@ nsResProtocolHandler::NewURI(const nsACString &aSpec,
|
||||
spec.Append(last, src-last);
|
||||
|
||||
rv = resURL->Init(nsIStandardURL::URLTYPE_STANDARD, -1, spec, aCharset, aBaseURI);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = CallQueryInterface(resURL, result);
|
||||
NS_RELEASE(resURL);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
resURL.forget(result);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "pk11func.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsRefPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "PSMRunnable.h"
|
||||
#include "nsString.h"
|
||||
@ -84,13 +84,14 @@ NS_IMETHODIMP nsProtectedAuthThread::GetTokenName(nsAString &_retval)
|
||||
|
||||
NS_IMETHODIMP nsProtectedAuthThread::GetSlot(nsIPKCS11Slot **_retval)
|
||||
{
|
||||
RefPtr<nsPKCS11Slot> slot;
|
||||
nsRefPtr<nsPKCS11Slot> slot;
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
slot = new nsPKCS11Slot(mSlot);
|
||||
}
|
||||
|
||||
return CallQueryInterface (slot.get(), _retval);
|
||||
slot.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsProtectedAuthThread::SetParams(PK11SlotInfo* aSlot)
|
||||
|
@ -221,15 +221,14 @@ nsWindowMediator::GetZOrderDOMWindowEnumerator(
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
NS_ENSURE_STATE(mReady);
|
||||
|
||||
nsAppShellWindowEnumerator *enumerator;
|
||||
nsRefPtr<nsAppShellWindowEnumerator> enumerator;
|
||||
if (aFrontToBack)
|
||||
enumerator = new nsASDOMWindowFrontToBackEnumerator(aWindowType, *this);
|
||||
else
|
||||
enumerator = new nsASDOMWindowBackToFrontEnumerator(aWindowType, *this);
|
||||
if (enumerator)
|
||||
return CallQueryInterface(enumerator, _retval);
|
||||
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
enumerator.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -241,15 +240,14 @@ nsWindowMediator::GetZOrderXULWindowEnumerator(
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
NS_ENSURE_STATE(mReady);
|
||||
|
||||
nsAppShellWindowEnumerator *enumerator;
|
||||
nsRefPtr<nsAppShellWindowEnumerator> enumerator;
|
||||
if (aFrontToBack)
|
||||
enumerator = new nsASXULWindowFrontToBackEnumerator(aWindowType, *this);
|
||||
else
|
||||
enumerator = new nsASXULWindowBackToFrontEnumerator(aWindowType, *this);
|
||||
if (enumerator)
|
||||
return CallQueryInterface(enumerator, _retval);
|
||||
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
enumerator.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int32_t
|
||||
|
@ -365,7 +365,8 @@ NS_IMETHODIMP nsWindowDataSource::GetTarget(nsIRDFResource *aSource, nsIRDFResou
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
if (!indexInt) return(NS_ERROR_FAILURE);
|
||||
|
||||
return CallQueryInterface(indexInt, _retval);
|
||||
indexInt.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return mInner->GetTarget(aSource, aProperty, aTruthValue, _retval);
|
||||
|
Loading…
Reference in New Issue
Block a user