Bug 1433958 - Change code that uses nsIURI.setHostAndPort() to use nsIURIMutator r=mayhemer
* Removes setHostAndPort from nsIURIMutator as it only has one use * Instead, the consumer sets the port to -1 before calling setHostPort() MozReview-Commit-ID: Jx9UMW440hq
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include "nsDOMString.h"
|
#include "nsDOMString.h"
|
||||||
#include "nsIStreamListener.h"
|
#include "nsIStreamListener.h"
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
|
#include "nsIURIMutator.h"
|
||||||
#include "nsIIOService.h"
|
#include "nsIIOService.h"
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
#include "nsIPrivateBrowsingChannel.h"
|
#include "nsIPrivateBrowsingChannel.h"
|
||||||
@@ -926,24 +927,17 @@ nsHTMLDocument::CreateInheritingURIForHost(const nsACString& aHostString)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> newURI;
|
nsresult rv;
|
||||||
nsresult rv = uri->Clone(getter_AddRefs(newURI));
|
rv = NS_MutateURI(uri)
|
||||||
|
.SetUserPass(EmptyCString())
|
||||||
|
.SetPort(-1) // we want to reset the port number if needed.
|
||||||
|
.SetHostPort(aHostString)
|
||||||
|
.Finalize(uri);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = newURI->SetUserPass(EmptyCString());
|
return uri.forget();
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We use SetHostAndPort because we want to reset the port number if needed.
|
|
||||||
rv = newURI->SetHostAndPort(aHostString);
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return newURI.forget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIURI>
|
already_AddRefed<nsIURI>
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ interface nsIURISetters : nsIURISetSpec
|
|||||||
[must_use] nsIURIMutator setUsername(in AUTF8String aUsername);
|
[must_use] nsIURIMutator setUsername(in AUTF8String aUsername);
|
||||||
[must_use] nsIURIMutator setPassword(in AUTF8String aPassword);
|
[must_use] nsIURIMutator setPassword(in AUTF8String aPassword);
|
||||||
[must_use] nsIURIMutator setHostPort(in AUTF8String aHostPort);
|
[must_use] nsIURIMutator setHostPort(in AUTF8String aHostPort);
|
||||||
[must_use] nsIURIMutator setHostAndPort(in AUTF8String aHostAndPort);
|
|
||||||
[must_use] nsIURIMutator setHost(in AUTF8String aHost);
|
[must_use] nsIURIMutator setHost(in AUTF8String aHost);
|
||||||
[must_use] nsIURIMutator setPort(in long aPort);
|
[must_use] nsIURIMutator setPort(in long aPort);
|
||||||
[must_use] nsIURIMutator setPathQueryRef(in AUTF8String aPathQueryRef);
|
[must_use] nsIURIMutator setPathQueryRef(in AUTF8String aPathQueryRef);
|
||||||
@@ -195,12 +194,6 @@ interface nsIURISetters : nsIURISetSpec
|
|||||||
return !_to ? NS_ERROR_NULL_POINTER : _to->SetHostPort(aHostPort); \
|
return !_to ? NS_ERROR_NULL_POINTER : _to->SetHostPort(aHostPort); \
|
||||||
} \
|
} \
|
||||||
MOZ_MUST_USE NS_IMETHOD \
|
MOZ_MUST_USE NS_IMETHOD \
|
||||||
SetHostAndPort(const nsACString& aHostAndPort, nsIURIMutator** aMutator) override \
|
|
||||||
{ \
|
|
||||||
if (aMutator) NS_ADDREF(*aMutator = this); \
|
|
||||||
return !_to ? NS_ERROR_NULL_POINTER : _to->SetHostAndPort(aHostAndPort); \
|
|
||||||
} \
|
|
||||||
MOZ_MUST_USE NS_IMETHOD \
|
|
||||||
SetHost(const nsACString& aHost, nsIURIMutator** aMutator) override \
|
SetHost(const nsACString& aHost, nsIURIMutator** aMutator) override \
|
||||||
{ \
|
{ \
|
||||||
if (aMutator) NS_ADDREF(*aMutator = this); \
|
if (aMutator) NS_ADDREF(*aMutator = this); \
|
||||||
@@ -360,12 +353,6 @@ public:
|
|||||||
mStatus = mMutator->SetHostPort(aHostPort, nullptr);
|
mStatus = mMutator->SetHostPort(aHostPort, nullptr);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
NS_MutateURI& SetHostAndPort(const nsACString& aHostAndPort)
|
|
||||||
{
|
|
||||||
NS_ENSURE_SUCCESS(mStatus, *this);
|
|
||||||
mStatus = mMutator->SetHostAndPort(aHostAndPort, nullptr);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
NS_MutateURI& SetHost(const nsACString& aHost)
|
NS_MutateURI& SetHost(const nsACString& aHost)
|
||||||
{
|
{
|
||||||
NS_ENSURE_SUCCESS(mStatus, *this);
|
NS_ENSURE_SUCCESS(mStatus, *this);
|
||||||
|
|||||||
Reference in New Issue
Block a user