aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/attr.rs
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2015-11-03 14:16:55 +0100
committerMs2ger <Ms2ger@gmail.com>2015-11-04 12:09:11 +0100
commit6b75078503f25a61084a3e9cae1b7d57de21772f (patch)
treeddfc15e73be407657f687f55d9c8b7bce5b9596c /components/script/dom/attr.rs
parente6aa976462fad0aafb2d59d0a590b69a8c8b5ba9 (diff)
downloadservo-6b75078503f25a61084a3e9cae1b7d57de21772f.tar.gz
servo-6b75078503f25a61084a3e9cae1b7d57de21772f.zip
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.
Diffstat (limited to 'components/script/dom/attr.rs')
-rw-r--r--components/script/dom/attr.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs
index d3aea55d60f..024522acfe8 100644
--- a/components/script/dom/attr.rs
+++ b/components/script/dom/attr.rs
@@ -46,7 +46,7 @@ impl AttrValue {
}
pub fn from_atomic_tokens(atoms: Vec<Atom>) -> AttrValue {
- let tokens = str_join(&atoms, "\x20");
+ let tokens = DOMString(str_join(&atoms, "\x20"));
AttrValue::TokenList(tokens, atoms)
}
@@ -212,12 +212,12 @@ impl Attr {
impl AttrMethods for Attr {
// https://dom.spec.whatwg.org/#dom-attr-localname
fn LocalName(&self) -> DOMString {
- (**self.local_name()).to_owned()
+ DOMString((**self.local_name()).to_owned())
}
// https://dom.spec.whatwg.org/#dom-attr-value
fn Value(&self) -> DOMString {
- (**self.value()).to_owned()
+ DOMString((**self.value()).to_owned())
}
// https://dom.spec.whatwg.org/#dom-attr-value
@@ -253,7 +253,7 @@ impl AttrMethods for Attr {
// https://dom.spec.whatwg.org/#dom-attr-name
fn Name(&self) -> DOMString {
- (*self.name).to_owned()
+ DOMString((*self.name).to_owned())
}
// https://dom.spec.whatwg.org/#dom-attr-namespaceuri
@@ -261,13 +261,13 @@ impl AttrMethods for Attr {
let Namespace(ref atom) = self.namespace;
match &**atom {
"" => None,
- url => Some(url.to_owned()),
+ url => Some(DOMString(url.to_owned())),
}
}
// https://dom.spec.whatwg.org/#dom-attr-prefix
fn GetPrefix(&self) -> Option<DOMString> {
- self.prefix().as_ref().map(|p| (**p).to_owned())
+ self.prefix().as_ref().map(|p| DOMString((**p).to_owned()))
}
// https://dom.spec.whatwg.org/#dom-attr-ownerelement
@@ -326,8 +326,8 @@ impl Attr {
let Namespace(ref ns) = self.namespace;
AttrInfo {
namespace: (**ns).to_owned(),
- name: self.Name(),
- value: self.Value(),
+ name: self.Name().0,
+ value: self.Value().0,
}
}
}