diff options
author | Thiago Pontes <github@thiago.me> | 2016-05-28 14:53:09 -0400 |
---|---|---|
committer | Thiago Pontes <github@thiago.me> | 2016-05-28 14:53:31 -0400 |
commit | 766ad5e0923b2b5c34053db9c115debb7b64f23e (patch) | |
tree | ccfeeaeb38eecf5953b908a39096d784bd4ee4be /components/script | |
parent | 0173cabbb6aedd5695e4035437b233927d4f27d0 (diff) | |
download | servo-766ad5e0923b2b5c34053db9c115debb7b64f23e.tar.gz servo-766ad5e0923b2b5c34053db9c115debb7b64f23e.zip |
use USVStrings instead of DOMString for urls in Node and Document
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/document.rs | 14 | ||||
-rw-r--r-- | components/script/dom/node.rs | 9 | ||||
-rw-r--r-- | components/script/dom/webidls/Document.webidl | 4 | ||||
-rw-r--r-- | components/script/dom/webidls/Node.webidl | 2 |
4 files changed, 16 insertions, 13 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 34bb2423007..a12f122e2c6 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -27,7 +27,7 @@ use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root}; use dom::bindings::num::Finite; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{Reflectable, reflect_dom_object}; -use dom::bindings::str::DOMString; +use dom::bindings::str::{DOMString, USVString}; use dom::bindings::trace::RootedVec; use dom::bindings::xmlname::XMLName::InvalidXMLName; use dom::bindings::xmlname::{validate_and_extract, namespace_from_domstring, xml_name_type}; @@ -1865,8 +1865,8 @@ impl DocumentMethods for Document { } // https://dom.spec.whatwg.org/#dom-document-url - fn URL(&self) -> DOMString { - DOMString::from(self.url().as_str()) + fn URL(&self) -> USVString { + USVString(String::from(self.url().as_str())) } // https://html.spec.whatwg.org/multipage/#dom-document-activeelement @@ -1916,7 +1916,7 @@ impl DocumentMethods for Document { } // https://dom.spec.whatwg.org/#dom-document-documenturi - fn DocumentURI(&self) -> DOMString { + fn DocumentURI(&self) -> USVString { self.URL() } @@ -2192,8 +2192,10 @@ impl DocumentMethods for Document { )), "webglcontextevent" => Ok(Root::upcast(WebGLContextEvent::new_uninitialized(GlobalRef::Window(&self.window)))), - "storageevent" => - Ok(Root::upcast(StorageEvent::new_uninitialized(&self.window, self.URL()))), + "storageevent" => { + let USVString(url) = self.URL(); + Ok(Root::upcast(StorageEvent::new_uninitialized(&self.window, DOMString::from(url)))) + }, "progressevent" => Ok(Root::upcast(ProgressEvent::new_uninitialized(&self.window))), "focusevent" => diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 11b02641f2d..35236dbcb4c 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -28,7 +28,7 @@ use dom::bindings::js::Root; use dom::bindings::js::RootedReference; use dom::bindings::js::{JS, LayoutJS, MutNullableHeap}; use dom::bindings::reflector::{Reflectable, reflect_dom_object}; -use dom::bindings::str::DOMString; +use dom::bindings::str::{DOMString, USVString}; use dom::bindings::trace::RootedVec; use dom::bindings::xmlname::namespace_from_domstring; use dom::characterdata::{CharacterData, LayoutCharacterDataHelpers}; @@ -804,9 +804,10 @@ impl Node { } pub fn summarize(&self) -> NodeInfo { + let USVString(baseURI) = self.BaseURI(); NodeInfo { uniqueId: self.unique_id(), - baseURI: String::from(self.BaseURI()), + baseURI: baseURI, parent: self.GetParentNode().map_or("".to_owned(), |node| node.unique_id()), nodeType: self.NodeType(), namespaceURI: String::new(), //FIXME @@ -1860,8 +1861,8 @@ impl NodeMethods for Node { } // https://dom.spec.whatwg.org/#dom-node-baseuri - fn BaseURI(&self) -> DOMString { - DOMString::from(self.owner_doc().base_url().as_str()) + fn BaseURI(&self) -> USVString { + USVString(String::from(self.owner_doc().base_url().as_str())) } // https://dom.spec.whatwg.org/#dom-node-ownerdocument diff --git a/components/script/dom/webidls/Document.webidl b/components/script/dom/webidls/Document.webidl index b73d563bac7..dd6ff9c924e 100644 --- a/components/script/dom/webidls/Document.webidl +++ b/components/script/dom/webidls/Document.webidl @@ -13,10 +13,10 @@ interface Document : Node { [SameObject] readonly attribute DOMImplementation implementation; [Constant] - readonly attribute DOMString URL; + readonly attribute USVString URL; readonly attribute Element? activeElement; [Constant] - readonly attribute DOMString documentURI; + readonly attribute USVString documentURI; readonly attribute DOMString compatMode; readonly attribute DOMString characterSet; readonly attribute DOMString charset; // legacy alias of .characterSet diff --git a/components/script/dom/webidls/Node.webidl b/components/script/dom/webidls/Node.webidl index f727fa98660..6335dfc565e 100644 --- a/components/script/dom/webidls/Node.webidl +++ b/components/script/dom/webidls/Node.webidl @@ -26,7 +26,7 @@ interface Node : EventTarget { readonly attribute DOMString nodeName; [Pure] - readonly attribute DOMString baseURI; + readonly attribute USVString baseURI; [Pure] readonly attribute Document? ownerDocument; |