mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 21:28:55 +00:00
Bug 1432320 - (Part 1) Add nsIURLMutator r=mayhemer
MozReview-Commit-ID: 8GYru46kFQE --HG-- extra : rebase_source : 064fae8d2e31db071da524b1946f135dda01cc1a
This commit is contained in:
parent
f83a4332e9
commit
d4c640e9f7
@ -257,7 +257,46 @@ nsJARURI::SetSpecInternal(const nsACString& aSpec)
|
||||
return SetSpecWithBase(aSpec, nullptr);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsJARURI::Mutator, nsIURISetters, nsIURIMutator)
|
||||
NS_IMPL_ISUPPORTS(nsJARURI::Mutator, nsIURISetters, nsIURIMutator, nsIURLMutator)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::Mutator::SetFileName(const nsACString& aFileName, nsIURIMutator** aMutator)
|
||||
{
|
||||
if (!mURI) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aMutator) {
|
||||
nsCOMPtr<nsIURIMutator> mutator = this;
|
||||
mutator.forget(aMutator);
|
||||
}
|
||||
return mURI->SetFileName(aFileName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::Mutator::SetFileBaseName(const nsACString& aFileBaseName, nsIURIMutator** aMutator)
|
||||
{
|
||||
if (!mURI) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aMutator) {
|
||||
nsCOMPtr<nsIURIMutator> mutator = this;
|
||||
mutator.forget(aMutator);
|
||||
}
|
||||
return mURI->SetFileBaseName(aFileBaseName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::Mutator::SetFileExtension(const nsACString& aFileExtension, nsIURIMutator** aMutator)
|
||||
{
|
||||
if (!mURI) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aMutator) {
|
||||
nsCOMPtr<nsIURIMutator> mutator = this;
|
||||
mutator.forget(aMutator);
|
||||
}
|
||||
return mURI->SetFileExtension(aFileExtension);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::Mutate(nsIURIMutator** aMutator)
|
||||
@ -670,7 +709,8 @@ nsJARURI::GetDirectory(nsACString& directory)
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetDirectory(const nsACString& directory)
|
||||
{
|
||||
return mJAREntry->SetDirectory(directory);
|
||||
MOZ_ASSERT_UNREACHABLE("SetDirectory");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -682,7 +722,11 @@ nsJARURI::GetFileName(nsACString& fileName)
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetFileName(const nsACString& fileName)
|
||||
{
|
||||
return mJAREntry->SetFileName(fileName);
|
||||
return NS_MutateURI(mJAREntry)
|
||||
.Apply<nsIURLMutator>(&nsIURLMutator::SetFileName,
|
||||
nsCString(fileName),
|
||||
nullptr)
|
||||
.Finalize(mJAREntry);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -694,7 +738,11 @@ nsJARURI::GetFileBaseName(nsACString& fileBaseName)
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetFileBaseName(const nsACString& fileBaseName)
|
||||
{
|
||||
return mJAREntry->SetFileBaseName(fileBaseName);
|
||||
return NS_MutateURI(mJAREntry)
|
||||
.Apply<nsIURLMutator>(&nsIURLMutator::SetFileBaseName,
|
||||
nsCString(fileBaseName),
|
||||
nullptr)
|
||||
.Finalize(mJAREntry);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -706,7 +754,11 @@ nsJARURI::GetFileExtension(nsACString& fileExtension)
|
||||
NS_IMETHODIMP
|
||||
nsJARURI::SetFileExtension(const nsACString& fileExtension)
|
||||
{
|
||||
return mJAREntry->SetFileExtension(fileExtension);
|
||||
return NS_MutateURI(mJAREntry)
|
||||
.Apply<nsIURLMutator>(&nsIURLMutator::SetFileExtension,
|
||||
nsCString(fileExtension),
|
||||
nullptr)
|
||||
.Finalize(mJAREntry);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -102,10 +102,12 @@ public:
|
||||
class Mutator
|
||||
: public nsIURIMutator
|
||||
, public BaseURIMutator<nsJARURI>
|
||||
, public nsIURLMutator
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI)
|
||||
NS_DEFINE_NSIMUTATOR_COMMON
|
||||
NS_DECL_NSIURLMUTATOR
|
||||
|
||||
explicit Mutator() { }
|
||||
private:
|
||||
|
@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsIURI.idl"
|
||||
interface nsIURIMutator;
|
||||
|
||||
/**
|
||||
* The nsIURL interface provides convenience methods that further
|
||||
@ -120,3 +121,11 @@ interface nsIURL : nsIURI
|
||||
AUTF8String getRelativeSpec(in nsIURI aURIToCompare);
|
||||
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(25072eb8-f1e6-482f-9ca9-eddd3d65169a)]
|
||||
interface nsIURLMutator : nsISupports
|
||||
{
|
||||
[must_use] nsIURIMutator setFileName(in AUTF8String aFileName);
|
||||
[must_use] nsIURIMutator setFileBaseName(in AUTF8String aFileBaseName);
|
||||
[must_use] nsIURIMutator setFileExtension(in AUTF8String aFileExtension);
|
||||
};
|
||||
|
@ -2226,7 +2226,8 @@ nsStandardURL::SetPathQueryRef(const nsACString &input)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsStandardURL::Mutator, nsIURISetters, nsIURIMutator, nsIStandardURLMutator)
|
||||
// When updating this also update SubstitutingURL::Mutator
|
||||
NS_IMPL_ISUPPORTS(nsStandardURL::Mutator, nsIURISetters, nsIURIMutator, nsIStandardURLMutator, nsIURLMutator)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStandardURL::Mutate(nsIURIMutator** aMutator)
|
||||
|
@ -321,6 +321,7 @@ public:
|
||||
: public nsIURIMutator
|
||||
, public BaseURIMutator<T>
|
||||
, public nsIStandardURLMutator
|
||||
, public nsIURLMutator
|
||||
{
|
||||
NS_FORWARD_SAFE_NSIURISETTERS_RET(BaseURIMutator<T>::mURI)
|
||||
|
||||
@ -390,6 +391,46 @@ public:
|
||||
return BaseURIMutator<T>::mURI->SetDefaultPort(aNewDefaultPort);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE NS_IMETHOD
|
||||
SetFileName(const nsACString& aFileName, nsIURIMutator** aMutator) override
|
||||
{
|
||||
if (!BaseURIMutator<T>::mURI) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aMutator) {
|
||||
nsCOMPtr<nsIURIMutator> mutator = this;
|
||||
mutator.forget(aMutator);
|
||||
}
|
||||
return BaseURIMutator<T>::mURI->SetFileName(aFileName);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE NS_IMETHOD
|
||||
SetFileBaseName(const nsACString& aFileBaseName, nsIURIMutator** aMutator) override
|
||||
{
|
||||
if (!BaseURIMutator<T>::mURI) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aMutator) {
|
||||
nsCOMPtr<nsIURIMutator> mutator = this;
|
||||
mutator.forget(aMutator);
|
||||
}
|
||||
return BaseURIMutator<T>::mURI->SetFileBaseName(aFileBaseName);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE NS_IMETHOD
|
||||
SetFileExtension(const nsACString& aFileExtension, nsIURIMutator** aMutator) override
|
||||
{
|
||||
if (!BaseURIMutator<T>::mURI) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aMutator) {
|
||||
nsCOMPtr<nsIURIMutator> mutator = this;
|
||||
mutator.forget(aMutator);
|
||||
}
|
||||
return BaseURIMutator<T>::mURI->SetFileExtension(aFileExtension);
|
||||
}
|
||||
|
||||
|
||||
explicit TemplatedMutator() { }
|
||||
private:
|
||||
virtual ~TemplatedMutator() { }
|
||||
|
@ -32,7 +32,7 @@ static NS_DEFINE_CID(kSubstitutingURLCID, NS_SUBSTITUTINGURL_CID);
|
||||
// SubstitutingURL : overrides nsStandardURL::GetFile to provide nsIFile resolution
|
||||
//---------------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_ISUPPORTS(SubstitutingURL::Mutator, nsIURISetters, nsIURIMutator, nsIStandardURLMutator)
|
||||
NS_IMPL_ISUPPORTS(SubstitutingURL::Mutator, nsIURISetters, nsIURIMutator, nsIStandardURLMutator, nsIURLMutator)
|
||||
|
||||
nsresult
|
||||
SubstitutingURL::EnsureFile()
|
||||
|
Loading…
x
Reference in New Issue
Block a user