mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Make DOMString a newtype around String, rather than a typedef.
This should make it somewhat easier to experiment with alternative representations in the future. To reduce churn, this commit leaves the String field public, though. Also, this will allow us to use the default String type to represent the IDL USVString type, which explicitly forbids unpaired surrogates, ans as such is a better match to the Rust String type.
This commit is contained in:
parent
e6aa976462
commit
6b75078503
83 changed files with 393 additions and 297 deletions
|
@ -1676,7 +1676,7 @@ impl Node {
|
|||
copy
|
||||
}
|
||||
|
||||
pub fn collect_text_contents<T: Iterator<Item=Root<Node>>>(iterator: T) -> String {
|
||||
pub fn collect_text_contents<T: Iterator<Item=Root<Node>>>(iterator: T) -> DOMString {
|
||||
let mut content = String::new();
|
||||
for node in iterator {
|
||||
match node.downcast::<Text>() {
|
||||
|
@ -1684,13 +1684,13 @@ impl Node {
|
|||
None => (),
|
||||
}
|
||||
}
|
||||
content
|
||||
DOMString(content)
|
||||
}
|
||||
|
||||
pub fn namespace_to_string(namespace: Namespace) -> Option<DOMString> {
|
||||
match namespace {
|
||||
ns!("") => None,
|
||||
Namespace(ref ns) => Some((**ns).to_owned())
|
||||
Namespace(ref ns) => Some(DOMString((**ns).to_owned()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1786,16 +1786,16 @@ impl NodeMethods for Node {
|
|||
NodeTypeId::Element(..) => {
|
||||
self.downcast::<Element>().unwrap().TagName()
|
||||
}
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => "#text".to_owned(),
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => DOMString("#text".to_owned()),
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => {
|
||||
self.downcast::<ProcessingInstruction>().unwrap().Target()
|
||||
}
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => "#comment".to_owned(),
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => DOMString("#comment".to_owned()),
|
||||
NodeTypeId::DocumentType => {
|
||||
self.downcast::<DocumentType>().unwrap().name().clone()
|
||||
},
|
||||
NodeTypeId::DocumentFragment => "#document-fragment".to_owned(),
|
||||
NodeTypeId::Document => "#document".to_owned()
|
||||
NodeTypeId::DocumentFragment => DOMString("#document-fragment".to_owned()),
|
||||
NodeTypeId::Document => DOMString("#document".to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue