Bug 1431204 - Make nsIURI.spec readonly r=mayhemer

MozReview-Commit-ID: 1l1CBUotIPh

--HG--
extra : rebase_source : 92af70ad412719d93222551b658f313cefd85e75
This commit is contained in:
Valentin Gosu 2018-01-19 15:26:07 +01:00
Родитель 89445898bd
Коммит ea4e6b68ff
7 изменённых файлов: 25 добавлений и 17 удалений

Просмотреть файл

@ -257,8 +257,8 @@ NullPrincipalURI::GetHasRef(bool* _result)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsresult
NullPrincipalURI::SetSpec(const nsACString& aSpec) NullPrincipalURI::SetSpecInternal(const nsACString& aSpec)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }

Просмотреть файл

@ -204,8 +204,8 @@ extractAttributeValue(const char* aSearchString,
} // if we got non-null search string and attribute name values } // if we got non-null search string and attribute name values
} }
NS_IMETHODIMP nsresult
nsMozIconURI::SetSpec(const nsACString& aSpec) nsMozIconURI::SetSpecInternal(const nsACString& aSpec)
{ {
// Reset everything to default values. // Reset everything to default values.
mIconURL = nullptr; mIconURL = nullptr;

Просмотреть файл

@ -258,8 +258,8 @@ nsJARURI::GetHasRef(bool *result)
return mJAREntry->GetHasRef(result); return mJAREntry->GetHasRef(result);
} }
NS_IMETHODIMP nsresult
nsJARURI::SetSpec(const nsACString& aSpec) nsJARURI::SetSpecInternal(const nsACString& aSpec)
{ {
return SetSpecWithBase(aSpec, nullptr); return SetSpecWithBase(aSpec, nullptr);
} }

Просмотреть файл

@ -80,7 +80,16 @@ interface nsIURI : nsISupports
*/ */
/** /**
* Returns a string representation of the URI. Setting the spec causes * Returns a string representation of the URI.
*
* Some characters may be escaped.
*/
readonly attribute AUTF8String spec;
/*
* This method should only be called by nsIURIMutator or C++ unit tests.
*
* Setting the spec causes
* the new spec to be parsed per the rules for the scheme the URI * the new spec to be parsed per the rules for the scheme the URI
* currently has. In particular, setting the spec to a URI string with a * currently has. In particular, setting the spec to a URI string with a
* different scheme will generally produce incorrect results; no one * different scheme will generally produce incorrect results; no one
@ -88,10 +97,9 @@ interface nsIURI : nsISupports
* the URI stores information from the nsIIOService.newURI call used to * the URI stores information from the nsIIOService.newURI call used to
* create it other than just the parsed string, then behavior of this * create it other than just the parsed string, then behavior of this
* information on setting the spec attribute is undefined. * information on setting the spec attribute is undefined.
*
* Some characters may be escaped.
*/ */
attribute AUTF8String spec; [noscript,notxpcom,nostdcall]
nsresult setSpecInternal(in ACString aSpec);
%{ C++ %{ C++
// An infallible wrapper for GetSpec() that returns a failure indication // An infallible wrapper for GetSpec() that returns a failure indication

Просмотреть файл

@ -75,7 +75,7 @@ protected:
uri = new T(); uri = new T();
} }
rv = uri->SetSpec(aSpec); rv = uri->SetSpecInternal(aSpec);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }

Просмотреть файл

@ -287,8 +287,8 @@ nsSimpleURI::GetHasRef(bool *result)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsresult
nsSimpleURI::SetSpec(const nsACString &aSpec) nsSimpleURI::SetSpecInternal(const nsACString &aSpec)
{ {
NS_ENSURE_STATE(mMutable); NS_ENSURE_STATE(mMutable);

Просмотреть файл

@ -1554,8 +1554,8 @@ IsSpecialProtocol(const nsACString &input)
protocol.LowerCaseEqualsLiteral("gopher"); protocol.LowerCaseEqualsLiteral("gopher");
} }
NS_IMETHODIMP nsresult
nsStandardURL::SetSpec(const nsACString &input) nsStandardURL::SetSpecInternal(const nsACString &input)
{ {
return SetSpecWithEncoding(input, nullptr); return SetSpecWithEncoding(input, nullptr);
} }
@ -2209,7 +2209,7 @@ nsStandardURL::SetPathQueryRef(const nsACString &input)
spec.Append('/'); spec.Append('/');
spec.Append(path); spec.Append(path);
return SetSpec(spec); return SetSpecInternal(spec);
} }
else if (mPath.mLen >= 1) { else if (mPath.mLen >= 1) {
mSpec.Cut(mPath.mPos + 1, mPath.mLen - 1); mSpec.Cut(mPath.mPos + 1, mPath.mLen - 1);
@ -2893,7 +2893,7 @@ nsStandardURL::SetFilePath(const nsACString &input)
spec.Append(mSpec.get() + end, mSpec.Length() - end); spec.Append(mSpec.get() + end, mSpec.Length() - end);
} }
return SetSpec(spec); return SetSpecInternal(spec);
} }
else if (mPath.mLen > 1) { else if (mPath.mLen > 1) {
mSpec.Cut(mPath.mPos + 1, mFilepath.mLen - 1); mSpec.Cut(mPath.mPos + 1, mFilepath.mLen - 1);