mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Rust upgrade to rustc hash b03a2755193cd756583bcf5831cf4545d75ecb8a
This commit is contained in:
parent
26045d7fcb
commit
d1b433a3b3
160 changed files with 1427 additions and 1162 deletions
|
@ -55,7 +55,7 @@ pub fn serialize(iterator: &mut NodeIterator) -> String {
|
|||
}
|
||||
DocumentFragmentNodeTypeId => {}
|
||||
DocumentNodeTypeId => {
|
||||
fail!("It shouldn't be possible to serialize a document node")
|
||||
panic!("It shouldn't be possible to serialize a document node")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ fn serialize_processing_instruction(processing_instruction: JSRef<ProcessingInst
|
|||
html: &mut String) {
|
||||
html.push_str("<?");
|
||||
html.push_str(processing_instruction.target().as_slice());
|
||||
html.push_char(' ');
|
||||
html.push(' ');
|
||||
html.push_str(processing_instruction.characterdata().data().as_slice());
|
||||
html.push_str("?>");
|
||||
}
|
||||
|
@ -102,17 +102,17 @@ fn serialize_processing_instruction(processing_instruction: JSRef<ProcessingInst
|
|||
fn serialize_doctype(doctype: JSRef<DocumentType>, html: &mut String) {
|
||||
html.push_str("<!DOCTYPE");
|
||||
html.push_str(doctype.name().as_slice());
|
||||
html.push_char('>');
|
||||
html.push('>');
|
||||
}
|
||||
|
||||
fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &mut String) {
|
||||
html.push_char('<');
|
||||
html.push('<');
|
||||
html.push_str(elem.local_name().as_slice());
|
||||
for attr in elem.attrs().iter() {
|
||||
let attr = attr.root();
|
||||
serialize_attr(*attr, html);
|
||||
};
|
||||
html.push_char('>');
|
||||
html.push('>');
|
||||
|
||||
match elem.local_name().as_slice() {
|
||||
"pre" | "listing" | "textarea" if *elem.namespace() == ns!(HTML) => {
|
||||
|
@ -121,7 +121,7 @@ fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &
|
|||
Some(ref child) if child.is_text() => {
|
||||
let text: JSRef<CharacterData> = CharacterDataCast::to_ref(**child).unwrap();
|
||||
if text.data().len() > 0 && text.data().as_slice().char_at(0) == '\n' {
|
||||
html.push_char('\x0A');
|
||||
html.push('\x0A');
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
|
@ -136,7 +136,7 @@ fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &
|
|||
}
|
||||
|
||||
fn serialize_attr(attr: JSRef<Attr>, html: &mut String) {
|
||||
html.push_char(' ');
|
||||
html.push(' ');
|
||||
if *attr.namespace() == ns!(XML) {
|
||||
html.push_str("xml:");
|
||||
html.push_str(attr.local_name().as_slice());
|
||||
|
@ -154,18 +154,18 @@ fn serialize_attr(attr: JSRef<Attr>, html: &mut String) {
|
|||
};
|
||||
html.push_str("=\"");
|
||||
escape(attr.value().as_slice(), true, html);
|
||||
html.push_char('"');
|
||||
html.push('"');
|
||||
}
|
||||
|
||||
fn escape(string: &str, attr_mode: bool, html: &mut String) {
|
||||
for c in string.chars() {
|
||||
match c {
|
||||
'&' => html.push_str("&"),
|
||||
'\xA0' => html.push_str(" "),
|
||||
'\u00A0' => html.push_str(" "),
|
||||
'"' if attr_mode => html.push_str("""),
|
||||
'<' if !attr_mode => html.push_str("<"),
|
||||
'>' if !attr_mode => html.push_str(">"),
|
||||
c => html.push_char(c),
|
||||
c => html.push(c),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue