use USVStrings instead of DOMString for urls in Node and Document

This commit is contained in:
Thiago Pontes 2016-05-28 14:53:09 -04:00
parent 0173cabbb6
commit 766ad5e092
4 changed files with 16 additions and 13 deletions

View file

@ -27,7 +27,7 @@ use dom::bindings::js::{JS, LayoutJS, MutNullableHeap, Root};
use dom::bindings::num::Finite; use dom::bindings::num::Finite;
use dom::bindings::refcounted::Trusted; use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflectable, reflect_dom_object}; 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::trace::RootedVec;
use dom::bindings::xmlname::XMLName::InvalidXMLName; use dom::bindings::xmlname::XMLName::InvalidXMLName;
use dom::bindings::xmlname::{validate_and_extract, namespace_from_domstring, xml_name_type}; 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 // https://dom.spec.whatwg.org/#dom-document-url
fn URL(&self) -> DOMString { fn URL(&self) -> USVString {
DOMString::from(self.url().as_str()) USVString(String::from(self.url().as_str()))
} }
// https://html.spec.whatwg.org/multipage/#dom-document-activeelement // 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 // https://dom.spec.whatwg.org/#dom-document-documenturi
fn DocumentURI(&self) -> DOMString { fn DocumentURI(&self) -> USVString {
self.URL() self.URL()
} }
@ -2192,8 +2192,10 @@ impl DocumentMethods for Document {
)), )),
"webglcontextevent" => "webglcontextevent" =>
Ok(Root::upcast(WebGLContextEvent::new_uninitialized(GlobalRef::Window(&self.window)))), Ok(Root::upcast(WebGLContextEvent::new_uninitialized(GlobalRef::Window(&self.window)))),
"storageevent" => "storageevent" => {
Ok(Root::upcast(StorageEvent::new_uninitialized(&self.window, self.URL()))), let USVString(url) = self.URL();
Ok(Root::upcast(StorageEvent::new_uninitialized(&self.window, DOMString::from(url))))
},
"progressevent" => "progressevent" =>
Ok(Root::upcast(ProgressEvent::new_uninitialized(&self.window))), Ok(Root::upcast(ProgressEvent::new_uninitialized(&self.window))),
"focusevent" => "focusevent" =>

View file

@ -28,7 +28,7 @@ use dom::bindings::js::Root;
use dom::bindings::js::RootedReference; use dom::bindings::js::RootedReference;
use dom::bindings::js::{JS, LayoutJS, MutNullableHeap}; use dom::bindings::js::{JS, LayoutJS, MutNullableHeap};
use dom::bindings::reflector::{Reflectable, reflect_dom_object}; 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::trace::RootedVec;
use dom::bindings::xmlname::namespace_from_domstring; use dom::bindings::xmlname::namespace_from_domstring;
use dom::characterdata::{CharacterData, LayoutCharacterDataHelpers}; use dom::characterdata::{CharacterData, LayoutCharacterDataHelpers};
@ -804,9 +804,10 @@ impl Node {
} }
pub fn summarize(&self) -> NodeInfo { pub fn summarize(&self) -> NodeInfo {
let USVString(baseURI) = self.BaseURI();
NodeInfo { NodeInfo {
uniqueId: self.unique_id(), uniqueId: self.unique_id(),
baseURI: String::from(self.BaseURI()), baseURI: baseURI,
parent: self.GetParentNode().map_or("".to_owned(), |node| node.unique_id()), parent: self.GetParentNode().map_or("".to_owned(), |node| node.unique_id()),
nodeType: self.NodeType(), nodeType: self.NodeType(),
namespaceURI: String::new(), //FIXME namespaceURI: String::new(), //FIXME
@ -1860,8 +1861,8 @@ impl NodeMethods for Node {
} }
// https://dom.spec.whatwg.org/#dom-node-baseuri // https://dom.spec.whatwg.org/#dom-node-baseuri
fn BaseURI(&self) -> DOMString { fn BaseURI(&self) -> USVString {
DOMString::from(self.owner_doc().base_url().as_str()) USVString(String::from(self.owner_doc().base_url().as_str()))
} }
// https://dom.spec.whatwg.org/#dom-node-ownerdocument // https://dom.spec.whatwg.org/#dom-node-ownerdocument

View file

@ -13,10 +13,10 @@ interface Document : Node {
[SameObject] [SameObject]
readonly attribute DOMImplementation implementation; readonly attribute DOMImplementation implementation;
[Constant] [Constant]
readonly attribute DOMString URL; readonly attribute USVString URL;
readonly attribute Element? activeElement; readonly attribute Element? activeElement;
[Constant] [Constant]
readonly attribute DOMString documentURI; readonly attribute USVString documentURI;
readonly attribute DOMString compatMode; readonly attribute DOMString compatMode;
readonly attribute DOMString characterSet; readonly attribute DOMString characterSet;
readonly attribute DOMString charset; // legacy alias of .characterSet readonly attribute DOMString charset; // legacy alias of .characterSet

View file

@ -26,7 +26,7 @@ interface Node : EventTarget {
readonly attribute DOMString nodeName; readonly attribute DOMString nodeName;
[Pure] [Pure]
readonly attribute DOMString baseURI; readonly attribute USVString baseURI;
[Pure] [Pure]
readonly attribute Document? ownerDocument; readonly attribute Document? ownerDocument;