mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Bug 887364 - Update URLUtils interface. r=ehsan
This commit is contained in:
parent
4d4fd26659
commit
517dec0b94
@ -146,6 +146,32 @@ Link::SetProtocol(const nsAString &aProtocol)
|
||||
SetHrefAttribute(uri);
|
||||
}
|
||||
|
||||
void
|
||||
Link::SetPassword(const nsAString &aPassword)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri(GetURIToMutate());
|
||||
if (!uri) {
|
||||
// Ignore failures to be compatible with NS4.
|
||||
return;
|
||||
}
|
||||
|
||||
uri->SetPassword(NS_ConvertUTF16toUTF8(aPassword));
|
||||
SetHrefAttribute(uri);
|
||||
}
|
||||
|
||||
void
|
||||
Link::SetUsername(const nsAString &aUsername)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri(GetURIToMutate());
|
||||
if (!uri) {
|
||||
// Ignore failures to be compatible with NS4.
|
||||
return;
|
||||
}
|
||||
|
||||
uri->SetUsername(NS_ConvertUTF16toUTF8(aUsername));
|
||||
SetHrefAttribute(uri);
|
||||
}
|
||||
|
||||
void
|
||||
Link::SetHost(const nsAString &aHost)
|
||||
{
|
||||
@ -259,6 +285,27 @@ Link::SetHash(const nsAString &aHash)
|
||||
SetHrefAttribute(uri);
|
||||
}
|
||||
|
||||
void
|
||||
Link::GetOrigin(nsAString &aOrigin)
|
||||
{
|
||||
aOrigin.Truncate();
|
||||
|
||||
nsCOMPtr<nsIURI> uri(GetURI());
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsString origin;
|
||||
nsresult rv = nsContentUtils::GetUTFOrigin(uri, origin);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aOrigin.EqualsLiteral("null")) {
|
||||
aOrigin.Assign(origin);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Link::GetProtocol(nsAString &_protocol)
|
||||
{
|
||||
@ -275,6 +322,36 @@ Link::GetProtocol(nsAString &_protocol)
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
Link::GetUsername(nsAString& aUsername)
|
||||
{
|
||||
aUsername.Truncate();
|
||||
|
||||
nsCOMPtr<nsIURI> uri(GetURI());
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString username;
|
||||
uri->GetUsername(username);
|
||||
CopyASCIItoUTF16(username, aUsername);
|
||||
}
|
||||
|
||||
void
|
||||
Link::GetPassword(nsAString &aPassword)
|
||||
{
|
||||
aPassword.Truncate();
|
||||
|
||||
nsCOMPtr<nsIURI> uri(GetURI());
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString password;
|
||||
uri->GetPassword(password);
|
||||
CopyASCIItoUTF16(password, aPassword);
|
||||
}
|
||||
|
||||
void
|
||||
Link::GetHost(nsAString &_host)
|
||||
{
|
||||
|
@ -54,13 +54,18 @@ public:
|
||||
* Helper methods for modifying and obtaining parts of the URI of the Link.
|
||||
*/
|
||||
void SetProtocol(const nsAString &aProtocol);
|
||||
void SetUsername(const nsAString &aUsername);
|
||||
void SetPassword(const nsAString &aPassword);
|
||||
void SetHost(const nsAString &aHost);
|
||||
void SetHostname(const nsAString &aHostname);
|
||||
void SetPathname(const nsAString &aPathname);
|
||||
void SetSearch(const nsAString &aSearch);
|
||||
void SetPort(const nsAString &aPort);
|
||||
void SetHash(const nsAString &aHash);
|
||||
void GetOrigin(nsAString &aOrigin);
|
||||
void GetProtocol(nsAString &_protocol);
|
||||
void GetUsername(nsAString &aUsername);
|
||||
void GetPassword(nsAString &aPassword);
|
||||
void GetHost(nsAString &_host);
|
||||
void GetHostname(nsAString &_hostname);
|
||||
void GetPathname(nsAString &_pathname);
|
||||
|
@ -134,6 +134,31 @@ public:
|
||||
{
|
||||
rv = SetText(aValue);
|
||||
}
|
||||
|
||||
void GetOrigin(nsAString& aOrigin)
|
||||
{
|
||||
Link::GetOrigin(aOrigin);
|
||||
}
|
||||
|
||||
void GetUsername(nsAString& aUsername)
|
||||
{
|
||||
Link::GetUsername(aUsername);
|
||||
}
|
||||
|
||||
void SetUsername(const nsAString& aUsername)
|
||||
{
|
||||
Link::SetUsername(aUsername);
|
||||
}
|
||||
|
||||
void GetPassword(nsAString& aPassword)
|
||||
{
|
||||
Link::GetPassword(aPassword);
|
||||
}
|
||||
|
||||
void SetPassword(const nsAString& aPassword)
|
||||
{
|
||||
Link::SetPassword(aPassword);
|
||||
}
|
||||
// The XPCOM URI decomposition attributes are fine for us
|
||||
void GetCoords(nsString& aValue)
|
||||
{
|
||||
|
@ -108,9 +108,34 @@ public:
|
||||
SetHTMLAttr(nsGkAtoms::ping, aPing, aError);
|
||||
}
|
||||
|
||||
void GetOrigin(nsAString &aOrigin)
|
||||
{
|
||||
Link::GetOrigin(aOrigin);
|
||||
}
|
||||
|
||||
// The XPCOM GetProtocol is OK for us
|
||||
// The XPCOM SetProtocol is OK for us
|
||||
|
||||
void GetUsername(nsAString& aUsername)
|
||||
{
|
||||
Link::GetUsername(aUsername);
|
||||
}
|
||||
|
||||
void SetUsername(const nsAString& aUsername)
|
||||
{
|
||||
Link::SetUsername(aUsername);
|
||||
}
|
||||
|
||||
void GetPassword(nsAString& aPassword)
|
||||
{
|
||||
Link::GetPassword(aPassword);
|
||||
}
|
||||
|
||||
void SetPassword(const nsAString& aPassword)
|
||||
{
|
||||
Link::SetPassword(aPassword);
|
||||
}
|
||||
|
||||
// The XPCOM GetHost is OK for us
|
||||
// The XPCOM SetHost is OK for us
|
||||
|
||||
|
@ -13,12 +13,7 @@
|
||||
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#the-a-element
|
||||
interface HTMLAnchorElement : HTMLElement {
|
||||
// No support for stringifier attributes yet
|
||||
//[SetterThrows]
|
||||
//stringifier attribute DOMString href;
|
||||
stringifier;
|
||||
[SetterThrows]
|
||||
attribute DOMString href;
|
||||
[SetterThrows]
|
||||
attribute DOMString target;
|
||||
[SetterThrows]
|
||||
|
@ -14,18 +14,13 @@
|
||||
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#the-area-element
|
||||
interface HTMLAreaElement : HTMLElement {
|
||||
stringifier;
|
||||
[SetterThrows]
|
||||
attribute DOMString alt;
|
||||
[SetterThrows]
|
||||
attribute DOMString coords;
|
||||
[SetterThrows]
|
||||
attribute DOMString shape;
|
||||
// No support for stringifier attributes yet
|
||||
//[SetterThrows]
|
||||
//stringifier attribute DOMString href;
|
||||
stringifier;
|
||||
[SetterThrows]
|
||||
attribute DOMString href;
|
||||
[SetterThrows]
|
||||
attribute DOMString target;
|
||||
[SetterThrows]
|
||||
|
@ -14,7 +14,6 @@
|
||||
// No support for [Unforgeable] on interfaces yet
|
||||
//[Unforgeable]
|
||||
interface Location {
|
||||
stringifier attribute DOMString href;
|
||||
void assign(DOMString url);
|
||||
void replace(DOMString url);
|
||||
void reload();
|
||||
|
@ -15,13 +15,13 @@
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface URLUtils {
|
||||
// [SetterThrows]
|
||||
// stringifier attribute DOMString href;
|
||||
// readonly attribute DOMString origin;
|
||||
[SetterThrows]
|
||||
stringifier attribute DOMString href;
|
||||
readonly attribute DOMString origin;
|
||||
|
||||
attribute DOMString protocol;
|
||||
// attribute DOMString username;
|
||||
// attribute DOMString password;
|
||||
attribute DOMString username;
|
||||
attribute DOMString password;
|
||||
attribute DOMString host;
|
||||
attribute DOMString hostname;
|
||||
attribute DOMString port;
|
||||
|
Loading…
x
Reference in New Issue
Block a user