mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
use USVStrings instead of DOMString for urls in Node and Document
This commit is contained in:
parent
0173cabbb6
commit
766ad5e092
4 changed files with 16 additions and 13 deletions
|
@ -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" =>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue