mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 12:35:58 +00:00
Bug 783523 - Fix platform-specific nsresult misuse; r=ehsan,tbsaunde,smaug
This commit is contained in:
parent
baacf2d48f
commit
291bfa222b
@ -137,9 +137,9 @@ __try {
|
||||
if (IsDefunct())
|
||||
return E_FAIL;
|
||||
|
||||
if (NS_FAILED(GetCharacterExtents(aStartIndex, aEndIndex,
|
||||
aX, aY, aWidth, aHeight))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
if (FAILED(GetCharacterExtents(aStartIndex, aEndIndex,
|
||||
aX, aY, aWidth, aHeight))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
|
||||
|
||||
@ -191,7 +191,7 @@ TextLeafAccessibleWrap::GetPointFromOffset(nsIFrame* aContainingFrame,
|
||||
/*
|
||||
* Given an offset, the x, y, width, and height values are filled appropriately.
|
||||
*/
|
||||
nsresult
|
||||
HRESULT
|
||||
TextLeafAccessibleWrap::GetCharacterExtents(int32_t aStartOffset,
|
||||
int32_t aEndOffset,
|
||||
int32_t* aX,
|
||||
@ -207,7 +207,7 @@ TextLeafAccessibleWrap::GetCharacterExtents(int32_t aStartOffset,
|
||||
nsPresContext* presContext = mDoc->PresContext();
|
||||
|
||||
nsIFrame *frame = GetFrame();
|
||||
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(frame, E_FAIL);
|
||||
|
||||
nsPoint startPoint, endPoint;
|
||||
nsIFrame *startFrame = GetPointFromOffset(frame, aStartOffset, true, startPoint);
|
||||
@ -234,7 +234,7 @@ TextLeafAccessibleWrap::GetCharacterExtents(int32_t aStartOffset,
|
||||
*aWidth = sum.width;
|
||||
*aHeight = sum.height;
|
||||
|
||||
return NS_OK;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
|
@ -55,9 +55,9 @@ public:
|
||||
/* [retval][out] */ BSTR __RPC_FAR *fontFamily);
|
||||
|
||||
protected:
|
||||
nsresult GetCharacterExtents(int32_t aStartOffset, int32_t aEndOffset,
|
||||
int32_t* aX, int32_t* aY,
|
||||
int32_t* aWidth, int32_t* aHeight);
|
||||
HRESULT GetCharacterExtents(int32_t aStartOffset, int32_t aEndOffset,
|
||||
int32_t* aX, int32_t* aY,
|
||||
int32_t* aWidth, int32_t* aHeight);
|
||||
|
||||
// Return child frame containing offset on success
|
||||
nsIFrame* GetPointFromOffset(nsIFrame *aContainingFrame,
|
||||
|
@ -56,7 +56,8 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsAccessNodeWrap, nsAccessNode, nsIWinAccessNode);
|
||||
NS_IMETHODIMP
|
||||
nsAccessNodeWrap::QueryNativeInterface(REFIID aIID, void** aInstancePtr)
|
||||
{
|
||||
return QueryInterface(aIID, aInstancePtr);
|
||||
// XXX Wrong for E_NOINTERFACE
|
||||
return static_cast<nsresult>(QueryInterface(aIID, aInstancePtr));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
@ -613,7 +613,7 @@ nsWindowsShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
bool isDefaultBrowser = false;
|
||||
rv = NS_SUCCEEDED(IsDefaultBrowser(&isDefaultBrowser)) &&
|
||||
isDefaultBrowser ? S_OK : NS_ERROR_FAILURE;
|
||||
isDefaultBrowser ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ nsPrintProgress::nsPrintProgress()
|
||||
m_closeProgress = false;
|
||||
m_processCanceled = false;
|
||||
m_pendingStateFlags = -1;
|
||||
m_pendingStateValue = 0;
|
||||
m_pendingStateValue = NS_OK;
|
||||
}
|
||||
|
||||
nsPrintProgress::~nsPrintProgress()
|
||||
@ -88,7 +88,9 @@ NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent,
|
||||
NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose)
|
||||
{
|
||||
m_closeProgress = true;
|
||||
return OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, forceClose);
|
||||
// XXX Casting bool to nsresult
|
||||
return OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP,
|
||||
static_cast<nsresult>(forceClose));
|
||||
}
|
||||
|
||||
/* nsIPrompt GetPrompter (); */
|
||||
@ -113,7 +115,7 @@ NS_IMETHODIMP nsPrintProgress::GetProcessCanceledByUser(bool *aProcessCanceledBy
|
||||
NS_IMETHODIMP nsPrintProgress::SetProcessCanceledByUser(bool aProcessCanceledByUser)
|
||||
{
|
||||
m_processCanceled = aProcessCanceledByUser;
|
||||
OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, false);
|
||||
OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, NS_OK);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -132,10 +134,11 @@ NS_IMETHODIMP nsPrintProgress::RegisterListener(nsIWebProgressListener * listene
|
||||
{
|
||||
m_listenerList->AppendElement(listener);
|
||||
if (m_closeProgress || m_processCanceled)
|
||||
listener->OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, 0);
|
||||
listener->OnStateChange(nullptr, nullptr,
|
||||
nsIWebProgressListener::STATE_STOP, NS_OK);
|
||||
else
|
||||
{
|
||||
listener->OnStatusChange(nullptr, nullptr, 0, m_pendingStatus.get());
|
||||
listener->OnStatusChange(nullptr, nullptr, NS_OK, m_pendingStatus.get());
|
||||
if (m_pendingStateFlags != -1)
|
||||
listener->OnStateChange(nullptr, nullptr, m_pendingStateFlags, m_pendingStateValue);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ private:
|
||||
bool m_processCanceled;
|
||||
nsString m_pendingStatus;
|
||||
int32_t m_pendingStateFlags;
|
||||
int32_t m_pendingStateValue;
|
||||
nsresult m_pendingStateValue;
|
||||
nsCOMPtr<nsIDOMWindow> m_dialog;
|
||||
nsCOMPtr<nsISupportsArray> m_listenerList;
|
||||
nsCOMPtr<nsIObserver> m_observer;
|
||||
|
@ -57,7 +57,7 @@ nsPrintProgress::nsPrintProgress()
|
||||
m_closeProgress = false;
|
||||
m_processCanceled = false;
|
||||
m_pendingStateFlags = -1;
|
||||
m_pendingStateValue = 0;
|
||||
m_pendingStateValue = NS_OK;
|
||||
}
|
||||
|
||||
nsPrintProgress::~nsPrintProgress()
|
||||
@ -116,7 +116,9 @@ NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent,
|
||||
NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose)
|
||||
{
|
||||
m_closeProgress = true;
|
||||
return OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, forceClose);
|
||||
// XXX Casting from bool to nsresult
|
||||
return OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP,
|
||||
static_cast<nsresult>(forceClose));
|
||||
}
|
||||
|
||||
/* nsIPrompt GetPrompter (); */
|
||||
@ -141,7 +143,7 @@ NS_IMETHODIMP nsPrintProgress::GetProcessCanceledByUser(bool *aProcessCanceledBy
|
||||
NS_IMETHODIMP nsPrintProgress::SetProcessCanceledByUser(bool aProcessCanceledByUser)
|
||||
{
|
||||
m_processCanceled = aProcessCanceledByUser;
|
||||
OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, false);
|
||||
OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, NS_OK);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -160,10 +162,11 @@ NS_IMETHODIMP nsPrintProgress::RegisterListener(nsIWebProgressListener * listene
|
||||
{
|
||||
m_listenerList->AppendElement(listener);
|
||||
if (m_closeProgress || m_processCanceled)
|
||||
listener->OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, 0);
|
||||
listener->OnStateChange(nullptr, nullptr,
|
||||
nsIWebProgressListener::STATE_STOP, NS_OK);
|
||||
else
|
||||
{
|
||||
listener->OnStatusChange(nullptr, nullptr, 0, m_pendingStatus.get());
|
||||
listener->OnStatusChange(nullptr, nullptr, NS_OK, m_pendingStatus.get());
|
||||
if (m_pendingStateFlags != -1)
|
||||
listener->OnStateChange(nullptr, nullptr, m_pendingStateFlags, m_pendingStateValue);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ private:
|
||||
bool m_processCanceled;
|
||||
nsString m_pendingStatus;
|
||||
int32_t m_pendingStateFlags;
|
||||
int32_t m_pendingStateValue;
|
||||
nsresult m_pendingStateValue;
|
||||
nsCOMPtr<nsIDOMWindow> m_dialog;
|
||||
nsCOMPtr<nsISupportsArray> m_listenerList;
|
||||
nsCOMPtr<nsIObserver> m_observer;
|
||||
|
@ -1214,7 +1214,7 @@ gfxDWriteFontList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
}
|
||||
|
||||
static nsresult GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName)
|
||||
static HRESULT GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName)
|
||||
{
|
||||
HRESULT hr;
|
||||
nsRefPtr<IDWriteFontFamily> family;
|
||||
@ -1256,7 +1256,7 @@ static nsresult GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName)
|
||||
}
|
||||
|
||||
if (!name.SetLength(length + 1)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
return E_FAIL;
|
||||
}
|
||||
hr = familyNames->GetString(index, name.Elements(), length + 1);
|
||||
if (FAILED(hr)) {
|
||||
@ -1264,7 +1264,7 @@ static nsresult GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName)
|
||||
}
|
||||
|
||||
aFamilyName.Assign(name.Elements());
|
||||
return NS_OK;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// bug 705594 - the method below doesn't actually do any "drawing", it's only
|
||||
|
@ -1282,7 +1282,10 @@ XPCConvert::JSValToXPCException(XPCCallContext& ccx,
|
||||
if (number > 0.0 &&
|
||||
number < (double)0xffffffff &&
|
||||
0.0 == fmod(number,1)) {
|
||||
rv = (nsresult) number;
|
||||
// Visual Studio 9 doesn't allow casting directly from a
|
||||
// double to an enumeration type, contrary to 5.2.9(10) of
|
||||
// C++11, so add an intermediate cast.
|
||||
rv = (nsresult)(uint32_t) number;
|
||||
if (NS_FAILED(rv))
|
||||
isResult = true;
|
||||
}
|
||||
|
@ -294,7 +294,10 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(XPCCallContext& ccx,
|
||||
} else if (JSVAL_IS_NUMBER(jsexception)) {
|
||||
// JS often throws an nsresult.
|
||||
if (JSVAL_IS_DOUBLE(jsexception))
|
||||
rv = (nsresult)(JSVAL_TO_DOUBLE(jsexception));
|
||||
// Visual Studio 9 doesn't allow casting directly from
|
||||
// a double to an enumeration type, contrary to
|
||||
// 5.2.9(10) of C++11, so add an intermediate cast.
|
||||
rv = (nsresult)(uint32_t)(JSVAL_TO_DOUBLE(jsexception));
|
||||
else
|
||||
rv = (nsresult)(JSVAL_TO_INT(jsexception));
|
||||
|
||||
|
@ -245,7 +245,7 @@ NS_IMETHODIMP AndroidCameraInputStream::AsyncWait(nsIInputStreamCallback *aCallb
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP AndroidCameraInputStream::CloseWithStatus(uint32_t status)
|
||||
NS_IMETHODIMP AndroidCameraInputStream::CloseWithStatus(nsresult status)
|
||||
{
|
||||
AndroidCameraInputStream::doClose();
|
||||
return NS_OK;
|
||||
|
@ -537,7 +537,7 @@ NS_IMETHODIMP GonkCameraInputStream::AsyncWait(nsIInputStreamCallback *aCallback
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP GonkCameraInputStream::CloseWithStatus(uint32_t status)
|
||||
NS_IMETHODIMP GonkCameraInputStream::CloseWithStatus(nsresult status)
|
||||
{
|
||||
GonkCameraInputStream::doClose();
|
||||
return NS_OK;
|
||||
|
@ -95,7 +95,7 @@ NS_IMETHODIMP nsNativeAppSupportCocoa::Start(bool *_retval)
|
||||
#endif
|
||||
if ((err != noErr) || response < minimumOS) {
|
||||
NSLog(@"Minimum OS version requirement not met!");
|
||||
return false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*_retval = true;
|
||||
|
@ -329,9 +329,12 @@ CopyUpdaterIntoUpdateDir(nsIFile *greDir, nsIFile *appDir, nsIFile *updateDir,
|
||||
return false;
|
||||
#if defined(XP_MACOSX)
|
||||
rv = updater->AppendNative(NS_LITERAL_CSTRING(kUpdaterApp));
|
||||
rv |= updater->AppendNative(NS_LITERAL_CSTRING("Contents"));
|
||||
rv |= updater->AppendNative(NS_LITERAL_CSTRING("MacOS"));
|
||||
if (NS_FAILED(rv))
|
||||
nsresult tmp = updater->AppendNative(NS_LITERAL_CSTRING("Contents"));
|
||||
if (NS_FAILED(tmp)) {
|
||||
rv = tmp;
|
||||
}
|
||||
tmp = updater->AppendNative(NS_LITERAL_CSTRING("MacOS"));
|
||||
if (NS_FAILED(tmp) || NS_FAILED(rv))
|
||||
return false;
|
||||
#endif
|
||||
rv = updater->AppendNative(NS_LITERAL_CSTRING(kUpdaterBin));
|
||||
|
@ -1565,8 +1565,8 @@ HRESULT nsDataObj::DropTempFile(FORMATETC& aFE, STGMEDIUM& aSTG)
|
||||
ULONG readCount = 0;
|
||||
uint32_t writeCount = 0;
|
||||
while (1) {
|
||||
rv = pStream->Read(buffer, sizeof(buffer), &readCount);
|
||||
if (NS_FAILED(rv))
|
||||
HRESULT hres = pStream->Read(buffer, sizeof(buffer), &readCount);
|
||||
if (FAILED(hres))
|
||||
return E_FAIL;
|
||||
if (readCount == 0)
|
||||
break;
|
||||
|
@ -2197,7 +2197,7 @@ nsWindow::SetNonClientMargins(nsIntMargin &margins)
|
||||
mCustomNonClient = true;
|
||||
if (!UpdateNonClientMargins()) {
|
||||
NS_WARNING("UpdateNonClientMargins failed!");
|
||||
return false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -456,7 +456,7 @@ NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
struct WalkStackData data;
|
||||
|
||||
if (!EnsureImageHlpInitialized())
|
||||
return false;
|
||||
return NS_OK;
|
||||
|
||||
HANDLE targetThread = ::GetCurrentThread();
|
||||
data.walkCallingThread = true;
|
||||
|
@ -100,7 +100,7 @@ nsUUIDGenerator::GenerateUUIDInPlace(nsID* id)
|
||||
|
||||
#if defined(XP_WIN)
|
||||
HRESULT hr = CoCreateGuid((GUID*)id);
|
||||
if (NS_FAILED(hr))
|
||||
if (FAILED(hr))
|
||||
return NS_ERROR_FAILURE;
|
||||
#elif defined(XP_MACOSX)
|
||||
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
|
||||
|
@ -108,7 +108,7 @@ invoke_copy_to_stack(uint32_t* stk, uint32_t *end,
|
||||
}
|
||||
}
|
||||
|
||||
typedef uint32_t (*vtable_func)(nsISupports *, uint32_t, uint32_t, uint32_t);
|
||||
typedef nsresult (*vtable_func)(nsISupports *, uint32_t, uint32_t, uint32_t);
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
|
||||
|
@ -156,10 +156,10 @@ NS_InvokeByIndex_P(nsISupports * that, uint32_t methodIndex,
|
||||
methodAddress += 8 * methodIndex;
|
||||
methodAddress = *((uint64_t *)methodAddress);
|
||||
|
||||
typedef uint32_t (*Method)(uint64_t, uint64_t, uint64_t, uint64_t,
|
||||
typedef nsresult (*Method)(uint64_t, uint64_t, uint64_t, uint64_t,
|
||||
uint64_t, uint64_t, double, double, double,
|
||||
double, double, double, double, double);
|
||||
uint32_t result = ((Method)methodAddress)(a0, a1, a2, a3, a4, a5,
|
||||
nsresult result = ((Method)methodAddress)(a0, a1, a2, a3, a4, a5,
|
||||
d0, d1, d2, d3, d4, d5,
|
||||
d6, d7);
|
||||
return result;
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
printf("nsTestComFactory: ");
|
||||
printf("%s", (aLock ? "Locking server" : "Unlocking server"));
|
||||
printf("\n");
|
||||
return S_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
@ -127,11 +127,8 @@ int main(int argc, char *argv[])
|
||||
IUnknown *iUnknown;
|
||||
nsITestCom *iTestCom;
|
||||
|
||||
nsresult res;
|
||||
iFactory->LockServer(TRUE);
|
||||
res = iFactory->CreateInstance(NULL,
|
||||
IID_IUnknown,
|
||||
(void **) &iUnknown);
|
||||
iFactory->CreateInstance(NULL, IID_IUnknown, (void **) &iUnknown);
|
||||
iFactory->LockServer(FALSE);
|
||||
|
||||
GUID testGUID = NS_ITEST_COM_IID;
|
||||
|
Loading…
x
Reference in New Issue
Block a user