mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-12 23:12:21 +00:00
Bug 944363 - Change functions that call SetURI in nsLocation to propagate return values. r=bholley
This commit is contained in:
parent
7c919057d8
commit
bcb32b4d36
@ -319,11 +319,11 @@ nsLocation::SetHash(const nsAString& aHash)
|
||||
hash.Insert(char16_t('#'), 0);
|
||||
}
|
||||
rv = uri->SetRef(hash);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
SetURI(uri);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
return SetURI(uri);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -360,15 +360,16 @@ nsLocation::SetHost(const nsAString& aHost)
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = GetWritableURI(getter_AddRefs(uri));
|
||||
|
||||
if (uri) {
|
||||
rv = uri->SetHostPort(NS_ConvertUTF16toUTF8(aHost));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
SetURI(uri);
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(rv) || !uri)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
rv = uri->SetHostPort(NS_ConvertUTF16toUTF8(aHost));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return SetURI(uri);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -405,15 +406,16 @@ nsLocation::SetHostname(const nsAString& aHostname)
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = GetWritableURI(getter_AddRefs(uri));
|
||||
|
||||
if (uri) {
|
||||
rv = uri->SetHost(NS_ConvertUTF16toUTF8(aHostname));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
SetURI(uri);
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(rv) || !uri)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
rv = uri->SetHost(NS_ConvertUTF16toUTF8(aHostname));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return SetURI(uri);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -588,15 +590,16 @@ nsLocation::SetPathname(const nsAString& aPathname)
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = GetWritableURI(getter_AddRefs(uri));
|
||||
|
||||
if (uri) {
|
||||
rv = uri->SetPath(NS_ConvertUTF16toUTF8(aPathname));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
SetURI(uri);
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(rv) || !uri)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
rv = uri->SetPath(NS_ConvertUTF16toUTF8(aPathname));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return SetURI(uri);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -637,29 +640,30 @@ nsLocation::SetPort(const nsAString& aPort)
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = GetWritableURI(getter_AddRefs(uri));
|
||||
if (NS_WARN_IF(NS_FAILED(rv) || !uri)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (uri) {
|
||||
// perhaps use nsReadingIterators at some point?
|
||||
NS_ConvertUTF16toUTF8 portStr(aPort);
|
||||
const char *buf = portStr.get();
|
||||
int32_t port = -1;
|
||||
// perhaps use nsReadingIterators at some point?
|
||||
NS_ConvertUTF16toUTF8 portStr(aPort);
|
||||
const char *buf = portStr.get();
|
||||
int32_t port = -1;
|
||||
|
||||
if (!portStr.IsEmpty() && buf) {
|
||||
if (*buf == ':') {
|
||||
port = atol(buf+1);
|
||||
}
|
||||
else {
|
||||
port = atol(buf);
|
||||
}
|
||||
if (!portStr.IsEmpty() && buf) {
|
||||
if (*buf == ':') {
|
||||
port = atol(buf+1);
|
||||
}
|
||||
|
||||
rv = uri->SetPort(port);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
SetURI(uri);
|
||||
else {
|
||||
port = atol(buf);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
rv = uri->SetPort(port);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return SetURI(uri);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -697,15 +701,16 @@ nsLocation::SetProtocol(const nsAString& aProtocol)
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = GetWritableURI(getter_AddRefs(uri));
|
||||
|
||||
if (uri) {
|
||||
rv = uri->SetScheme(NS_ConvertUTF16toUTF8(aProtocol));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
SetURI(uri);
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(rv) || !uri)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
rv = uri->SetScheme(NS_ConvertUTF16toUTF8(aProtocol));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return SetURI(uri);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -747,14 +752,16 @@ nsLocation::SetSearch(const nsAString& aSearch)
|
||||
nsresult rv = GetWritableURI(getter_AddRefs(uri));
|
||||
|
||||
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
|
||||
if (url) {
|
||||
rv = url->SetQuery(NS_ConvertUTF16toUTF8(aSearch));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
SetURI(uri);
|
||||
}
|
||||
if (NS_WARN_IF(NS_FAILED(rv) || !url)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
rv = url->SetQuery(NS_ConvertUTF16toUTF8(aSearch));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return SetURI(uri);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
Loading…
x
Reference in New Issue
Block a user