Use atom! in place of Atom::from_slice where necessary

This commit is contained in:
Manish Goregaokar 2014-11-22 16:07:55 +05:30
parent e6e73b8da7
commit 534919327d
4 changed files with 6 additions and 8 deletions

View file

@ -824,7 +824,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
let name = Atom::from_slice(name.as_slice()); let name = Atom::from_slice(name.as_slice());
let local_name = Atom::from_slice(local_name); let local_name = Atom::from_slice(local_name);
let xmlns = Atom::from_slice("xmlns"); // TODO: Make this a static atom type let xmlns = atom!("xmlns");
// Step 7a. // Step 7a.
if xmlns == name && namespace != ns!(XMLNS) { if xmlns == name && namespace != ns!(XMLNS) {

View file

@ -18,8 +18,6 @@ use dom::node::{TextNodeTypeId, NodeHelpers};
use dom::processinginstruction::ProcessingInstruction; use dom::processinginstruction::ProcessingInstruction;
use dom::text::Text; use dom::text::Text;
use string_cache::Atom;
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
pub fn serialize(iterator: &mut NodeIterator) -> String { pub fn serialize(iterator: &mut NodeIterator) -> String {
let mut html = String::new(); let mut html = String::new();
@ -141,7 +139,7 @@ fn serialize_attr(attr: JSRef<Attr>, html: &mut String) {
html.push_str("xml:"); html.push_str("xml:");
html.push_str(attr.local_name().as_slice()); html.push_str(attr.local_name().as_slice());
} else if *attr.namespace() == ns!(XMLNS) && } else if *attr.namespace() == ns!(XMLNS) &&
*attr.local_name() == Atom::from_slice("xmlns") { *attr.local_name() == atom!("xmlns") {
html.push_str("xmlns"); html.push_str("xmlns");
} else if *attr.namespace() == ns!(XMLNS) { } else if *attr.namespace() == ns!(XMLNS) {
html.push_str("xmlns:"); html.push_str("xmlns:");

View file

@ -1230,7 +1230,7 @@ mod tests {
fn test_get_id_name(){ fn test_get_id_name(){
let rules_list = get_mock_rules([".intro", "#top"]); let rules_list = get_mock_rules([".intro", "#top"]);
assert_eq!(SelectorMap::get_id_name(&rules_list[0][0]), None); assert_eq!(SelectorMap::get_id_name(&rules_list[0][0]), None);
assert_eq!(SelectorMap::get_id_name(&rules_list[1][0]), Some(Atom::from_slice("top"))); assert_eq!(SelectorMap::get_id_name(&rules_list[1][0]), Some(atom!("top")));
} }
#[test] #[test]
@ -1260,7 +1260,7 @@ mod tests {
let rules_list = get_mock_rules([".intro.foo", "#top"]); let rules_list = get_mock_rules([".intro.foo", "#top"]);
let mut selector_map = SelectorMap::new(); let mut selector_map = SelectorMap::new();
selector_map.insert(rules_list[1][0].clone()); selector_map.insert(rules_list[1][0].clone());
assert_eq!(1, selector_map.id_hash.find(&Atom::from_slice("top")).unwrap()[0].declarations.source_order); assert_eq!(1, selector_map.id_hash.find(&atom!("top")).unwrap()[0].declarations.source_order);
selector_map.insert(rules_list[0][0].clone()); selector_map.insert(rules_list[0][0].clone());
assert_eq!(0, selector_map.class_hash.find(&Atom::from_slice("intro")).unwrap()[0].declarations.source_order); assert_eq!(0, selector_map.class_hash.find(&Atom::from_slice("intro")).unwrap()[0].declarations.source_order);
assert!(selector_map.class_hash.find(&Atom::from_slice("foo")).is_none()); assert!(selector_map.class_hash.find(&Atom::from_slice("foo")).is_none());

View file

@ -719,8 +719,8 @@ mod tests {
simple_selectors: vec!(), simple_selectors: vec!(),
next: Some((box CompoundSelector { next: Some((box CompoundSelector {
simple_selectors: vec!(LocalNameSelector(LocalName { simple_selectors: vec!(LocalNameSelector(LocalName {
name: Atom::from_slice("div"), name: atom!("div"),
lower_name: Atom::from_slice("div") })), lower_name: atom!("div") })),
next: None, next: None,
}, Descendant)), }, Descendant)),
}), }),