diff options
author | Ms2ger <Ms2ger@gmail.com> | 2015-11-03 14:16:55 +0100 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2015-11-04 12:09:11 +0100 |
commit | 6b75078503f25a61084a3e9cae1b7d57de21772f (patch) | |
tree | ddfc15e73be407657f687f55d9c8b7bce5b9596c /components/script/parse/html.rs | |
parent | e6aa976462fad0aafb2d59d0a590b69a8c8b5ba9 (diff) | |
download | servo-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/parse/html.rs')
-rw-r--r-- | components/script/parse/html.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/components/script/parse/html.rs b/components/script/parse/html.rs index 36062208400..10115b9a235 100644 --- a/components/script/parse/html.rs +++ b/components/script/parse/html.rs @@ -71,14 +71,14 @@ impl<'a> TreeSink for servohtmlparser::Sink { ElementCreator::ParserCreated); for attr in attrs { - elem.set_attribute_from_parser(attr.name, attr.value.into(), None); + elem.set_attribute_from_parser(attr.name, DOMString(attr.value.into()), None); } JS::from_ref(elem.upcast()) } fn create_comment(&mut self, text: StrTendril) -> JS<Node> { - let comment = Comment::new(text.into(), &*self.document); + let comment = Comment::new(DOMString(text.into()), &*self.document); JS::from_ref(comment.upcast()) } @@ -115,7 +115,8 @@ impl<'a> TreeSink for servohtmlparser::Sink { system_id: StrTendril) { let doc = &*self.document; let doctype = DocumentType::new( - name.into(), Some(public_id.into()), Some(system_id.into()), doc); + DOMString(name.into()), Some(DOMString(public_id.into())), + Some(DOMString(system_id.into())), doc); doc.upcast::<Node>().AppendChild(doctype.upcast()).expect("Appending failed"); } @@ -123,7 +124,7 @@ impl<'a> TreeSink for servohtmlparser::Sink { let elem = target.downcast::<Element>() .expect("tried to set attrs on non-Element in HTML parsing"); for attr in attrs { - elem.set_attribute_from_parser(attr.name, attr.value.into(), None); + elem.set_attribute_from_parser(attr.name, DOMString(attr.value.into()), None); } } @@ -237,7 +238,7 @@ pub enum ParseContext<'a> { } pub fn parse_html(document: &Document, - input: String, + input: DOMString, url: Url, context: ParseContext) { let parser = match context { @@ -246,7 +247,7 @@ pub fn parse_html(document: &Document, ParseContext::Fragment(fc) => ServoHTMLParser::new_for_fragment(Some(url), document, fc), }; - parser.parse_chunk(input.into()); + parser.parse_chunk(input.0.into()); } // https://html.spec.whatwg.org/multipage/#parsing-html-fragments |