Bug 1323683 - Fold nsIURIWithQuery into nsIURI

native in moebius
This commit is contained in:
janekptacijarabaci
2018-04-22 21:20:53 +02:00
committed by Roy Tam
parent 75dcd43896
commit 8dccc387f9
14 changed files with 110 additions and 107 deletions
+26
View File
@@ -167,6 +167,32 @@ nsNullPrincipalURI::SetPath(const nsACString &aPath)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNullPrincipalURI::GetFilePath(nsACString &aFilePath)
{
aFilePath.Truncate();
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNullPrincipalURI::SetFilePath(const nsACString &aFilePath)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNullPrincipalURI::GetQuery(nsACString &aQuery)
{
aQuery.Truncate();
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNullPrincipalURI::SetQuery(const nsACString &aQuery)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNullPrincipalURI::GetRef(nsACString &_ref)
{
+5 -9
View File
@@ -582,15 +582,12 @@ Location::GetPathname(nsAString& aPathname)
return result;
}
nsCOMPtr<nsIURIWithQuery> url(do_QueryInterface(uri));
if (url) {
nsAutoCString file;
nsAutoCString file;
result = url->GetFilePath(file);
result = uri->GetFilePath(file);
if (NS_SUCCEEDED(result)) {
AppendUTF8toUTF16(file, aPathname);
}
if (NS_SUCCEEDED(result)) {
AppendUTF8toUTF16(file, aPathname);
}
return result;
@@ -605,8 +602,7 @@ Location::SetPathname(const nsAString& aPathname)
return rv;
}
nsCOMPtr<nsIURIWithQuery> url(do_QueryInterface(uri));
if (url && NS_SUCCEEDED(url->SetFilePath(NS_ConvertUTF16toUTF8(aPathname)))) {
if (NS_SUCCEEDED(uri->SetFilePath(NS_ConvertUTF16toUTF8(aPathname)))) {
return SetURI(uri);
}
+8 -32
View File
@@ -17,7 +17,6 @@
#include "nsEscape.h"
#include "nsHostObjectProtocolHandler.h"
#include "nsIIOService.h"
#include "nsIURIWithQuery.h"
#include "nsIURL.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
@@ -525,21 +524,10 @@ URLMainThread::GetPathname(nsAString& aPathname, ErrorResult& aRv) const
// Do not throw! Not having a valid URI or URL should result in an empty
// string.
nsCOMPtr<nsIURIWithQuery> url(do_QueryInterface(mURI));
if (url) {
nsAutoCString file;
nsresult rv = url->GetFilePath(file);
if (NS_SUCCEEDED(rv)) {
CopyUTF8toUTF16(file, aPathname);
}
return;
}
nsAutoCString path;
nsresult rv = mURI->GetPath(path);
nsAutoCString file;
nsresult rv = mURI->GetFilePath(file);
if (NS_SUCCEEDED(rv)) {
CopyUTF8toUTF16(path, aPathname);
CopyUTF8toUTF16(file, aPathname);
}
}
@@ -548,11 +536,7 @@ URLMainThread::SetPathname(const nsAString& aPathname, ErrorResult& aRv)
{
// Do not throw!
nsCOMPtr<nsIURIWithQuery> url(do_QueryInterface(mURI));
if (url) {
url->SetFilePath(NS_ConvertUTF16toUTF8(aPathname));
return;
}
mURI->SetFilePath(NS_ConvertUTF16toUTF8(aPathname));
}
void
@@ -566,13 +550,9 @@ URLMainThread::GetSearch(nsAString& aSearch, ErrorResult& aRv) const
nsAutoCString search;
nsresult rv;
nsCOMPtr<nsIURIWithQuery> url(do_QueryInterface(mURI));
if (url) {
rv = url->GetQuery(search);
if (NS_SUCCEEDED(rv) && !search.IsEmpty()) {
CopyUTF8toUTF16(NS_LITERAL_CSTRING("?") + search, aSearch);
}
return;
rv = mURI->GetQuery(search);
if (NS_SUCCEEDED(rv) && !search.IsEmpty()) {
CopyUTF8toUTF16(NS_LITERAL_CSTRING("?") + search, aSearch);
}
}
@@ -603,11 +583,7 @@ URLMainThread::SetSearchInternal(const nsAString& aSearch, ErrorResult& aRv)
{
// Ignore failures to be compatible with NS4.
nsCOMPtr<nsIURIWithQuery> uriWithQuery(do_QueryInterface(mURI));
if (uriWithQuery) {
uriWithQuery->SetQuery(NS_ConvertUTF16toUTF8(aSearch));
return;
}
mURI->SetQuery(NS_ConvertUTF16toUTF8(aSearch));
}
} // anonymous namespace
+26
View File
@@ -371,6 +371,32 @@ nsMozIconURI::SetPath(const nsACString& aPath)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsMozIconURI::GetFilePath(nsACString& aFilePath)
{
aFilePath.Truncate();
return NS_OK;
}
NS_IMETHODIMP
nsMozIconURI::SetFilePath(const nsACString& aFilePath)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsMozIconURI::GetQuery(nsACString& aQuery)
{
aQuery.Truncate();
return NS_OK;
}
NS_IMETHODIMP
nsMozIconURI::SetQuery(const nsACString& aQuery)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsMozIconURI::GetRef(nsACString& aRef)
{
-1
View File
@@ -41,7 +41,6 @@ NS_IMPL_RELEASE(nsJARURI)
NS_INTERFACE_MAP_BEGIN(nsJARURI)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIJARURI)
NS_INTERFACE_MAP_ENTRY(nsIURI)
NS_INTERFACE_MAP_ENTRY(nsIURIWithQuery)
NS_INTERFACE_MAP_ENTRY(nsIURL)
NS_INTERFACE_MAP_ENTRY(nsIJARURI)
NS_INTERFACE_MAP_ENTRY(nsISerializable)
-1
View File
@@ -41,7 +41,6 @@ class nsJARURI final : public nsIJARURI,
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIURI
NS_DECL_NSIURIWITHQUERY
NS_DECL_NSIURL
NS_DECL_NSIJARURI
NS_DECL_NSISERIALIZABLE
-1
View File
@@ -132,7 +132,6 @@ XPIDL_SOURCES += [
'nsIURIClassifier.idl',
'nsIURIWithBlobImpl.idl',
'nsIURIWithPrincipal.idl',
'nsIURIWithQuery.idl',
'nsIURL.idl',
'nsIURLParser.idl',
'nsPILoadGroupInternal.idl',
+40 -20
View File
@@ -10,18 +10,18 @@
* provides accessors to set and query the most basic components of an URI.
* Subclasses, including nsIURL, impose greater structure on the URI.
*
* This interface follows Tim Berners-Lee's URI spec (RFC2396) [1], where the
* This interface follows Tim Berners-Lee's URI spec (RFC3986) [1], where the
* basic URI components are defined as such:
* <pre>
* ftp://username:password@hostname:portnumber/pathname#ref
* \ / \ / \ / \ /\ \ /
* - --------------- ------ -------- | -
* | | | | | |
* | | | | | Ref
* | | | Port \ /
* | | Host / --------
* | UserPass / |
* Scheme / Path
* ftp://username:password@hostname:portnumber/pathname?query#ref
* \ / \ / \ / \ /\ / \ / \ /
* - --------------- ------ -------- ------- --- -
* | | | | | | |
* | | | | FilePath Query Ref
* | | | Port \ /
* | | Host / ------------
* | UserPass / |
* Scheme / Path
* \ /
* --------------------------------
* |
@@ -30,13 +30,9 @@
* The definition of the URI components has been extended to allow for
* internationalized domain names [2] and the more generic IRI structure [3].
*
* Note also that the RFC defines #-separated fragment identifiers as being
* "not part of the URI". Despite this, we bundle them as part of the URI, for
* convenience.
*
* [1] http://www.ietf.org/rfc/rfc2396.txt
* [2] http://www.ietf.org/internet-drafts/draft-ietf-idn-idna-06.txt
* [3] http://www.ietf.org/internet-drafts/draft-masinter-url-i18n-08.txt
* [1] https://tools.ietf.org/html/rfc3986
* [2] https://tools.ietf.org/html/rfc5890
* [3] https://tools.ietf.org/html/rfc3987
*/
%{C++
@@ -116,7 +112,7 @@ interface nsIURI : nsISupports
/**
* The Scheme is the protocol to which this URI refers. The scheme is
* restricted to the US-ASCII charset per RFC2396. Setting this is
* restricted to the US-ASCII charset per RFC3986. Setting this is
* highly discouraged outside of a protocol handler implementation, since
* that will generally lead to incorrect results.
*/
@@ -174,6 +170,9 @@ interface nsIURI : nsISupports
* empty, depending on the protocol).
*
* Some characters may be escaped.
*
* This attribute contains query and ref parts for historical reasons.
* Use the 'filePath' attribute if you do not want those parts included.
*/
attribute AUTF8String path;
@@ -281,10 +280,31 @@ interface nsIURI : nsISupports
/**
* returns a string for the current URI with the ref element cleared.
*/
readonly attribute AUTF8String specIgnoringRef;
readonly attribute AUTF8String specIgnoringRef;
/**
* Returns if there is a reference portion (the part after the "#") of the URI.
*/
readonly attribute boolean hasRef;
readonly attribute boolean hasRef;
/************************************************************************
* Additional attributes added for .query support:
*/
/**
* Returns a path including the directory and file portions of a
* URL. For example, the filePath of "http://host/foo/bar.html#baz"
* is "/foo/bar.html".
*
* Some characters may be escaped.
*/
attribute AUTF8String filePath;
/**
* Returns the query portion (the part after the "?") of the URL.
* If there isn't one, an empty string is returned.
*
* Some characters may be escaped.
*/
attribute AUTF8String query;
};
-30
View File
@@ -1,30 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIURI.idl"
/**
* nsIURIWithQuery is implemented by URIs which have a query parameter.
* This is useful for the URL API.
*/
[scriptable, uuid(367510ee-8556-435a-8f99-b5fd357e08cc)]
interface nsIURIWithQuery : nsIURI
{
/**
* Returns a path including the directory and file portions of a
* URL. For example, the filePath of "http://host/foo/bar.html#baz"
* is "/foo/bar.html".
*
* Some characters may be escaped.
*/
attribute AUTF8String filePath;
/**
* Returns the query portion (the part after the "?") of the URL.
* If there isn't one, an empty string is returned.
*
* Some characters may be escaped.
*/
attribute AUTF8String query;
};
+3 -3
View File
@@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIURIWithQuery.idl"
#include "nsIURI.idl"
/**
* The nsIURL interface provides convenience methods that further
@@ -20,7 +20,7 @@
* filePath
*/
[scriptable, uuid(86adcd89-0b70-47a2-b0fe-5bb2c5f37e31)]
interface nsIURL : nsIURIWithQuery
interface nsIURL : nsIURI
{
/*************************************************************************
* The URL path is broken down into the following principal components:
@@ -28,7 +28,7 @@ interface nsIURL : nsIURIWithQuery
* attribute AUTF8String filePath;
* attribute AUTF8String query;
*
* These are inherited from nsIURIWithQuery.
* These are inherited from nsIURI.
*/
/*************************************************************************
+1 -5
View File
@@ -48,7 +48,7 @@ nsSimpleURI::~nsSimpleURI()
NS_IMPL_ADDREF(nsSimpleURI)
NS_IMPL_RELEASE(nsSimpleURI)
NS_INTERFACE_TABLE_HEAD(nsSimpleURI)
NS_INTERFACE_TABLE(nsSimpleURI, nsIURI, nsIURIWithQuery, nsISerializable,
NS_INTERFACE_TABLE(nsSimpleURI, nsIURI, nsISerializable,
nsIClassInfo, nsIMutable, nsIIPCSerializableURI)
NS_INTERFACE_TABLE_TO_MAP_SEGUE
if (aIID.Equals(kThisSimpleURIImplementationCID))
@@ -784,10 +784,6 @@ nsSimpleURI::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
//----------------------------------------------------------------------------
// nsSimpleURI::nsIURIWithQuery
//----------------------------------------------------------------------------
NS_IMETHODIMP
nsSimpleURI::GetFilePath(nsACString& aFilePath)
{
+1 -3
View File
@@ -8,7 +8,6 @@
#include "mozilla/MemoryReporting.h"
#include "nsIURI.h"
#include "nsIURIWithQuery.h"
#include "nsISerializable.h"
#include "nsString.h"
#include "nsIClassInfo.h"
@@ -28,7 +27,7 @@ namespace net {
}
class nsSimpleURI
: public nsIURIWithQuery
: public nsIURI
, public nsISerializable
, public nsIClassInfo
, public nsIMutable
@@ -41,7 +40,6 @@ protected:
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIURI
NS_DECL_NSIURIWITHQUERY
NS_DECL_NSISERIALIZABLE
NS_DECL_NSICLASSINFO
NS_DECL_NSIMUTABLE
-1
View File
@@ -1182,7 +1182,6 @@ NS_IMPL_RELEASE(nsStandardURL)
NS_INTERFACE_MAP_BEGIN(nsStandardURL)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStandardURL)
NS_INTERFACE_MAP_ENTRY(nsIURI)
NS_INTERFACE_MAP_ENTRY(nsIURIWithQuery)
NS_INTERFACE_MAP_ENTRY(nsIURL)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIFileURL, mSupportsFileURL)
NS_INTERFACE_MAP_ENTRY(nsIStandardURL)
-1
View File
@@ -54,7 +54,6 @@ protected:
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIURI
NS_DECL_NSIURIWITHQUERY
NS_DECL_NSIURL
NS_DECL_NSIFILEURL
NS_DECL_NSISTANDARDURL