mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 801579 - Don't mix nsresult with HRESULT (widget/windows part) r=jmathies
This commit is contained in:
parent
20620b38aa
commit
2e4dc8b044
@ -309,10 +309,12 @@ HRESULT nsDataObj::CreateStream(IStream **outStream)
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsAutoString wideFileName;
|
||||
nsCOMPtr<nsIURI> sourceURI;
|
||||
HRESULT res;
|
||||
|
||||
rv = GetDownloadDetails(getter_AddRefs(sourceURI),
|
||||
wideFileName);
|
||||
NS_ENSURE_SUCCESS(rv, E_FAIL);
|
||||
res = GetDownloadDetails(getter_AddRefs(sourceURI),
|
||||
wideFileName);
|
||||
if(FAILED(res))
|
||||
return res;
|
||||
|
||||
nsDataObj::CStream *pStream = new nsDataObj::CStream();
|
||||
NS_ENSURE_TRUE(pStream, E_OUTOFMEMORY);
|
||||
@ -1116,9 +1118,9 @@ nsDataObj :: GetFileContentsInternetShortcut ( FORMATETC& aFE, STGMEDIUM& aSTG )
|
||||
rv = icoFile->GetNativePath(path);
|
||||
NS_ENSURE_SUCCESS(rv, E_FAIL);
|
||||
|
||||
static char* shortcutFormatStr = "[InternetShortcut]\r\nURL=%s\r\n"
|
||||
"IDList=\r\nHotKey=0\r\nIconFile=%s\r\n"
|
||||
"IconIndex=0\r\n";
|
||||
static const char* shortcutFormatStr = "[InternetShortcut]\r\nURL=%s\r\n"
|
||||
"IDList=\r\nHotKey=0\r\nIconFile=%s\r\n"
|
||||
"IconIndex=0\r\n";
|
||||
static const int formatLen = strlen(shortcutFormatStr) - 2*2; // don't include %s (2 times) in the len
|
||||
const int totalLen = formatLen + asciiUrl.Length()
|
||||
+ path.Length(); // we don't want a null character on the end
|
||||
@ -1538,10 +1540,11 @@ HRESULT nsDataObj::DropTempFile(FORMATETC& aFE, STGMEDIUM& aSTG)
|
||||
nsCString filename;
|
||||
nsAutoString wideFileName;
|
||||
nsCOMPtr<nsIURI> sourceURI;
|
||||
rv = GetDownloadDetails(getter_AddRefs(sourceURI),
|
||||
HRESULT res;
|
||||
res = GetDownloadDetails(getter_AddRefs(sourceURI),
|
||||
wideFileName);
|
||||
if (NS_FAILED(rv))
|
||||
return E_FAIL;
|
||||
if (FAILED(res))
|
||||
return res;
|
||||
NS_UTF16ToCString(wideFileName, NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, filename);
|
||||
|
||||
dropFile->AppendNative(filename);
|
||||
@ -1960,24 +1963,24 @@ nsDataObj::ExtractUniformResourceLocatorW(FORMATETC& aFE, STGMEDIUM& aSTG )
|
||||
|
||||
|
||||
// Gets the filename from the kFilePromiseURLMime flavour
|
||||
nsresult nsDataObj::GetDownloadDetails(nsIURI **aSourceURI,
|
||||
nsAString &aFilename)
|
||||
HRESULT nsDataObj::GetDownloadDetails(nsIURI **aSourceURI,
|
||||
nsAString &aFilename)
|
||||
{
|
||||
*aSourceURI = nullptr;
|
||||
|
||||
NS_ENSURE_TRUE(mTransferable, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(mTransferable, E_FAIL);
|
||||
|
||||
// get the URI from the kFilePromiseURLMime flavor
|
||||
nsCOMPtr<nsISupports> urlPrimitive;
|
||||
uint32_t dataSize = 0;
|
||||
mTransferable->GetTransferData(kFilePromiseURLMime, getter_AddRefs(urlPrimitive), &dataSize);
|
||||
nsCOMPtr<nsISupportsString> srcUrlPrimitive = do_QueryInterface(urlPrimitive);
|
||||
NS_ENSURE_TRUE(srcUrlPrimitive, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(srcUrlPrimitive, E_FAIL);
|
||||
|
||||
nsAutoString srcUri;
|
||||
srcUrlPrimitive->GetData(srcUri);
|
||||
if (srcUri.IsEmpty())
|
||||
return NS_ERROR_FAILURE;
|
||||
return E_FAIL;
|
||||
nsCOMPtr<nsIURI> sourceURI;
|
||||
NS_NewURI(getter_AddRefs(sourceURI), srcUri);
|
||||
|
||||
@ -1990,7 +1993,7 @@ nsresult nsDataObj::GetDownloadDetails(nsIURI **aSourceURI,
|
||||
} else {
|
||||
nsCOMPtr<nsIURL> sourceURL = do_QueryInterface(sourceURI);
|
||||
if (!sourceURL)
|
||||
return NS_ERROR_FAILURE;
|
||||
return E_FAIL;
|
||||
|
||||
nsAutoCString urlFileName;
|
||||
sourceURL->GetFileName(urlFileName);
|
||||
@ -1998,14 +2001,14 @@ nsresult nsDataObj::GetDownloadDetails(nsIURI **aSourceURI,
|
||||
CopyUTF8toUTF16(urlFileName, srcFileName);
|
||||
}
|
||||
if (srcFileName.IsEmpty())
|
||||
return NS_ERROR_FAILURE;
|
||||
return E_FAIL;
|
||||
|
||||
// make the name safe for the filesystem
|
||||
MangleTextToValidFilename(srcFileName);
|
||||
|
||||
sourceURI.swap(*aSourceURI);
|
||||
aFilename = srcFileName;
|
||||
return NS_OK;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT nsDataObj::GetFileDescriptor_IStreamA(FORMATETC& aFE, STGMEDIUM& aSTG)
|
||||
@ -2020,14 +2023,13 @@ HRESULT nsDataObj::GetFileDescriptor_IStreamA(FORMATETC& aFE, STGMEDIUM& aSTG)
|
||||
}
|
||||
|
||||
nsAutoString wideFileName;
|
||||
nsresult rv;
|
||||
HRESULT res;
|
||||
nsCOMPtr<nsIURI> sourceURI;
|
||||
rv = GetDownloadDetails(getter_AddRefs(sourceURI),
|
||||
wideFileName);
|
||||
if (NS_FAILED(rv))
|
||||
res = GetDownloadDetails(getter_AddRefs(sourceURI), wideFileName);
|
||||
if (FAILED(res))
|
||||
{
|
||||
::GlobalFree(fileGroupDescHandle);
|
||||
return E_FAIL;
|
||||
return res;
|
||||
}
|
||||
|
||||
nsAutoCString nativeFileName;
|
||||
@ -2059,14 +2061,14 @@ HRESULT nsDataObj::GetFileDescriptor_IStreamW(FORMATETC& aFE, STGMEDIUM& aSTG)
|
||||
}
|
||||
|
||||
nsAutoString wideFileName;
|
||||
nsresult rv;
|
||||
HRESULT res;
|
||||
nsCOMPtr<nsIURI> sourceURI;
|
||||
rv = GetDownloadDetails(getter_AddRefs(sourceURI),
|
||||
wideFileName);
|
||||
if (NS_FAILED(rv))
|
||||
res = GetDownloadDetails(getter_AddRefs(sourceURI),
|
||||
wideFileName);
|
||||
if (FAILED(res))
|
||||
{
|
||||
::GlobalFree(fileGroupDescHandle);
|
||||
return E_FAIL;
|
||||
return res;
|
||||
}
|
||||
|
||||
wcsncpy(fileGroupDescW->fgd[0].cFileName, wideFileName.get(), NS_MAX_FILEDESCRIPTOR - 1);
|
||||
|
@ -164,8 +164,8 @@ protected:
|
||||
public: // other methods
|
||||
|
||||
// Gets the filename from the kFilePromiseURLMime flavour
|
||||
nsresult GetDownloadDetails(nsIURI **aSourceURI,
|
||||
nsAString &aFilename);
|
||||
HRESULT GetDownloadDetails(nsIURI **aSourceURI,
|
||||
nsAString &aFilename);
|
||||
|
||||
protected:
|
||||
// help determine the kind of drag
|
||||
|
Loading…
Reference in New Issue
Block a user