mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Use USVString for URLUtils and URLUtilsReadOnly.
This commit is contained in:
parent
bbbdb98897
commit
0593d77b93
5 changed files with 43 additions and 44 deletions
|
@ -6,6 +6,7 @@ use dom::bindings::codegen::Bindings::LocationBinding;
|
|||
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, JSRef, Temporary};
|
||||
use dom::bindings::str::USVString;
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::urlhelper::UrlHelper;
|
||||
use dom::window::Window;
|
||||
|
@ -41,19 +42,19 @@ impl<'a> LocationMethods for JSRef<'a, Location> {
|
|||
self.window.root().r().load_url(url);
|
||||
}
|
||||
|
||||
fn Href(self) -> DOMString {
|
||||
fn Href(self) -> USVString {
|
||||
UrlHelper::Href(&self.get_url())
|
||||
}
|
||||
|
||||
fn Stringify(self) -> DOMString {
|
||||
self.Href()
|
||||
self.Href().0
|
||||
}
|
||||
|
||||
fn Search(self) -> DOMString {
|
||||
fn Search(self) -> USVString {
|
||||
UrlHelper::Search(&self.get_url())
|
||||
}
|
||||
|
||||
fn Hash(self) -> DOMString {
|
||||
fn Hash(self) -> USVString {
|
||||
UrlHelper::Hash(&self.get_url())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
* 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/. */
|
||||
|
||||
use util::str::DOMString;
|
||||
use dom::bindings::str::USVString;
|
||||
|
||||
use url::Url;
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
|
@ -10,24 +11,24 @@ use std::borrow::ToOwned;
|
|||
pub struct UrlHelper;
|
||||
|
||||
impl UrlHelper {
|
||||
pub fn Href(url: &Url) -> DOMString {
|
||||
url.serialize()
|
||||
pub fn Href(url: &Url) -> USVString {
|
||||
USVString(url.serialize())
|
||||
}
|
||||
|
||||
pub fn Search(url: &Url) -> DOMString {
|
||||
match url.query {
|
||||
pub fn Search(url: &Url) -> USVString {
|
||||
USVString(match url.query {
|
||||
None => "".to_owned(),
|
||||
Some(ref query) if query.as_slice() == "" => "".to_owned(),
|
||||
Some(ref query) => format!("?{}", query)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn Hash(url: &Url) -> DOMString {
|
||||
match url.fragment {
|
||||
pub fn Hash(url: &Url) -> USVString {
|
||||
USVString(match url.fragment {
|
||||
None => "".to_owned(),
|
||||
Some(ref hash) if hash.as_slice() == "" => "".to_owned(),
|
||||
Some(ref hash) => format!("#{}", hash)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/browsers.html#same-origin
|
||||
|
|
|
@ -6,21 +6,21 @@
|
|||
// http://url.spec.whatwg.org/#urlutils
|
||||
[NoInterfaceObject]
|
||||
interface URLUtils {
|
||||
//stringifier attribute ScalarValueString href;
|
||||
readonly attribute DOMString href;
|
||||
//readonly attribute ScalarValueString origin;
|
||||
// attribute ScalarValueString protocol;
|
||||
// attribute ScalarValueString username;
|
||||
// attribute ScalarValueString password;
|
||||
// attribute ScalarValueString host;
|
||||
// attribute ScalarValueString hostname;
|
||||
// attribute ScalarValueString port;
|
||||
// attribute ScalarValueString pathname;
|
||||
// attribute ScalarValueString search;
|
||||
readonly attribute DOMString search;
|
||||
//stringifier attribute USVString href;
|
||||
readonly attribute USVString href;
|
||||
//readonly attribute USVString origin;
|
||||
// attribute USVString protocol;
|
||||
// attribute USVString username;
|
||||
// attribute USVString password;
|
||||
// attribute USVString host;
|
||||
// attribute USVString hostname;
|
||||
// attribute USVString port;
|
||||
// attribute USVString pathname;
|
||||
// attribute USVString search;
|
||||
readonly attribute USVString search;
|
||||
// attribute URLSearchParams searchParams;
|
||||
// attribute ScalarValueString hash;
|
||||
readonly attribute DOMString hash;
|
||||
// attribute USVString hash;
|
||||
readonly attribute USVString hash;
|
||||
|
||||
// This is only doing as well as gecko right now, bug 824857 is on file for
|
||||
// adding attribute stringifier support.
|
||||
|
|
|
@ -7,17 +7,15 @@
|
|||
[NoInterfaceObject/*,
|
||||
Exposed=(Window,Worker)*/]
|
||||
interface URLUtilsReadOnly {
|
||||
//stringifier readonly attribute ScalarValueString href;
|
||||
readonly attribute DOMString href;
|
||||
//readonly attribute ScalarValueString origin;
|
||||
//stringifier readonly attribute USVString href;
|
||||
readonly attribute USVString href;
|
||||
//readonly attribute USVString origin;
|
||||
|
||||
//readonly attribute ScalarValueString protocol;
|
||||
//readonly attribute ScalarValueString host;
|
||||
//readonly attribute ScalarValueString hostname;
|
||||
//readonly attribute ScalarValueString port;
|
||||
//readonly attribute ScalarValueString pathname;
|
||||
//readonly attribute ScalarValueString search;
|
||||
readonly attribute DOMString search;
|
||||
//readonly attribute ScalarValueString hash;
|
||||
readonly attribute DOMString hash;
|
||||
//readonly attribute USVString protocol;
|
||||
//readonly attribute USVString host;
|
||||
//readonly attribute USVString hostname;
|
||||
//readonly attribute USVString port;
|
||||
//readonly attribute USVString pathname;
|
||||
readonly attribute USVString search;
|
||||
readonly attribute USVString hash;
|
||||
};
|
||||
|
|
|
@ -6,12 +6,11 @@ use dom::bindings::codegen::Bindings::WorkerLocationBinding;
|
|||
use dom::bindings::codegen::Bindings::WorkerLocationBinding::WorkerLocationMethods;
|
||||
use dom::bindings::js::{JSRef, Temporary};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::str::USVString;
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::urlhelper::UrlHelper;
|
||||
use dom::workerglobalscope::WorkerGlobalScope;
|
||||
|
||||
use util::str::DOMString;
|
||||
|
||||
use url::Url;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -36,15 +35,15 @@ impl WorkerLocation {
|
|||
}
|
||||
|
||||
impl<'a> WorkerLocationMethods for JSRef<'a, WorkerLocation> {
|
||||
fn Href(self) -> DOMString {
|
||||
fn Href(self) -> USVString {
|
||||
UrlHelper::Href(&self.url)
|
||||
}
|
||||
|
||||
fn Search(self) -> DOMString {
|
||||
fn Search(self) -> USVString {
|
||||
UrlHelper::Search(&self.url)
|
||||
}
|
||||
|
||||
fn Hash(self) -> DOMString {
|
||||
fn Hash(self) -> USVString {
|
||||
UrlHelper::Hash(&self.url)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue