Skip to content

Commit

Permalink
Bug 1323683 - Fold nsIURIWithQuery into nsIURI
Browse files Browse the repository at this point in the history
native in moebius
  • Loading branch information
janekptacijarabaci committed Apr 22, 2018
1 parent 8af1b0c commit dbfad99
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 107 deletions.
26 changes: 26 additions & 0 deletions caps/nsNullPrincipalURI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
14 changes: 5 additions & 9 deletions dom/base/Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down
40 changes: 8 additions & 32 deletions dom/url/URL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions image/decoders/icon/nsIconURI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 0 additions & 1 deletion modules/libjar/nsJARURI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion modules/libjar/nsJARURI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion netwerk/base/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ XPIDL_SOURCES += [
'nsIURIClassifier.idl',
'nsIURIWithBlobImpl.idl',
'nsIURIWithPrincipal.idl',
'nsIURIWithQuery.idl',
'nsIURL.idl',
'nsIURLParser.idl',
'nsPILoadGroupInternal.idl',
Expand Down
60 changes: 40 additions & 20 deletions netwerk/base/nsIURI.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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
* \ /
* --------------------------------
* |
Expand All @@ -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++
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 changes: 0 additions & 30 deletions netwerk/base/nsIURIWithQuery.idl

This file was deleted.

6 changes: 3 additions & 3 deletions netwerk/base/nsIURL.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,15 +20,15 @@
* 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:
*
* attribute AUTF8String filePath;
* attribute AUTF8String query;
*
* These are inherited from nsIURIWithQuery.
* These are inherited from nsIURI.
*/

/*************************************************************************
Expand Down
6 changes: 1 addition & 5 deletions netwerk/base/nsSimpleURI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -784,10 +784,6 @@ nsSimpleURI::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}

//----------------------------------------------------------------------------
// nsSimpleURI::nsIURIWithQuery
//----------------------------------------------------------------------------

NS_IMETHODIMP
nsSimpleURI::GetFilePath(nsACString& aFilePath)
{
Expand Down
4 changes: 1 addition & 3 deletions netwerk/base/nsSimpleURI.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "mozilla/MemoryReporting.h"
#include "nsIURI.h"
#include "nsIURIWithQuery.h"
#include "nsISerializable.h"
#include "nsString.h"
#include "nsIClassInfo.h"
Expand All @@ -28,7 +27,7 @@ namespace net {
}

class nsSimpleURI
: public nsIURIWithQuery
: public nsIURI
, public nsISerializable
, public nsIClassInfo
, public nsIMutable
Expand All @@ -41,7 +40,6 @@ class nsSimpleURI
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIURI
NS_DECL_NSIURIWITHQUERY
NS_DECL_NSISERIALIZABLE
NS_DECL_NSICLASSINFO
NS_DECL_NSIMUTABLE
Expand Down
Loading

0 comments on commit dbfad99

Please sign in to comment.