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:
Ms2ger 2015-11-03 14:16:55 +01:00
parent e6aa976462
commit 6b75078503
83 changed files with 393 additions and 297 deletions

View file

@ -76,23 +76,24 @@ use dom::htmlunknownelement::HTMLUnknownElement;
use dom::htmlvideoelement::HTMLVideoElement;
use std::borrow::ToOwned;
use string_cache::{Atom, QualName};
use util::str::DOMString;
pub fn create_element(name: QualName, prefix: Option<Atom>,
document: &Document, creator: ElementCreator)
-> Root<Element> {
let prefix = prefix.map(|p| (*p).to_owned());
let prefix = prefix.map(|p| DOMString((*p).to_owned()));
if name.ns != ns!(HTML) {
return Element::new((*name.local).to_owned(), name.ns, prefix, document);
return Element::new(DOMString((*name.local).to_owned()), name.ns, prefix, document);
}
macro_rules! make(
($ctor:ident) => ({
let obj = $ctor::new((*name.local).to_owned(), prefix, document);
let obj = $ctor::new(DOMString((*name.local).to_owned()), prefix, document);
Root::upcast(obj)
});
($ctor:ident, $($arg:expr),+) => ({
let obj = $ctor::new((*name.local).to_owned(), prefix, document, $($arg),+);
let obj = $ctor::new(DOMString((*name.local).to_owned()), prefix, document, $($arg),+);
Root::upcast(obj)
})
);