Update string_cache to 0.2.

Updated string_cache, html5ever, xml5ever and selectors in Cargo.toml files and Cargo.lock.
Removed references to string_cache_plugin.
Import atom! and ns! from string_cache.
Replaced ns!("") by ns!().
Replaced ns!(XML) and co by ns!(xml) and co.
Replaced atom!(foo) by atom!("foo").
Replaced Atom::from_slice by Atom::from.
Replaced atom.as_slice() by &*atom.
This commit is contained in:
Alan Jeffrey 2015-11-24 13:44:59 -06:00
parent e7b1924948
commit 3dec6edd10
68 changed files with 328 additions and 434 deletions

View file

@ -35,8 +35,7 @@ num = "0.1.24"
lazy_static = "0.1.10"
selectors = { version = "0.2", features = ["unstable"] }
smallvec = "0.1"
string_cache = "0.1"
string_cache_plugin = "0.1"
string_cache = "0.2"
euclid = {version = "0.3", features = ["plugins"]}
serde = "0.6"
serde_macros = "0.6"

View file

@ -27,7 +27,7 @@ impl AttrValue {
pub fn from_serialized_tokenlist(tokens: DOMString) -> AttrValue {
let atoms =
split_html_space_chars(&tokens)
.map(Atom::from_slice)
.map(Atom::from)
.fold(vec![], |mut acc, atom| {
if !acc.contains(&atom) { acc.push(atom) }
acc
@ -64,7 +64,8 @@ impl AttrValue {
}
pub fn from_atomic(string: DOMString) -> AttrValue {
let value = Atom::from_slice(&string);
// FIXME(ajeffrey): convert directly from DOMString to Atom
let value = Atom::from(&*string);
AttrValue::Atom(value)
}

View file

@ -286,7 +286,7 @@ fn parse_var_function<'i, 't>(input: &mut Parser<'i, 't>,
}));
}
if let Some(ref mut refs) = *references {
refs.insert(Atom::from_slice(name));
refs.insert(Atom::from(name));
}
Ok(())
}
@ -510,7 +510,7 @@ fn substitute_block<F>(input: &mut Parser,
try!(input.parse_nested_block(|input| {
// parse_var_function() ensures neither .unwrap() will fail.
let name = input.expect_ident().unwrap();
let name = Atom::from_slice(parse_name(&name).unwrap());
let name = Atom::from(parse_name(&name).unwrap());
if let Ok(last) = substitute_one(&name, partial_computed_value) {
last_token_type = last;

View file

@ -12,7 +12,6 @@
#![feature(vec_push_all)]
#![plugin(serde_macros)]
#![plugin(string_cache_plugin)]
#![plugin(serde_macros)]
#![plugin(plugins)]
@ -37,7 +36,7 @@ extern crate rustc_serialize;
#[macro_use(state_pseudo_classes)] extern crate selectors;
extern crate serde;
extern crate smallvec;
extern crate string_cache;
#[macro_use(atom, ns)] extern crate string_cache;
extern crate url;
extern crate util;

View file

@ -1721,14 +1721,14 @@ pub mod longhands {
#[inline]
pub fn name(&self) -> &str {
match *self {
FontFamily::FamilyName(ref name) => name.as_slice(),
FontFamily::FamilyName(ref name) => &*name,
}
}
}
impl ToCss for FontFamily {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self {
FontFamily::FamilyName(ref name) => dest.write_str(name.as_slice()),
FontFamily::FamilyName(ref name) => dest.write_str(&*name),
}
}
}
@ -1759,7 +1759,7 @@ pub mod longhands {
}
pub fn parse_one_family(input: &mut Parser) -> Result<FontFamily, ()> {
if let Ok(value) = input.try(|input| input.expect_string()) {
return Ok(FontFamily::FamilyName(Atom::from_slice(&value)))
return Ok(FontFamily::FamilyName(Atom::from(&*value)))
}
let first_ident = try!(input.expect_ident());
// match_ignore_ascii_case! { first_ident,
@ -1775,7 +1775,7 @@ pub mod longhands {
value.push_str(" ");
value.push_str(&ident);
}
Ok(FontFamily::FamilyName(Atom::from_slice(&value)))
Ok(FontFamily::FamilyName(Atom::from(&*value)))
}
</%self:longhand>
@ -6006,7 +6006,7 @@ impl PropertyDeclaration {
Err(()) => return PropertyDeclarationParseResult::InvalidValue,
}
};
result_list.push(PropertyDeclaration::Custom(Atom::from_slice(name), value));
result_list.push(PropertyDeclaration::Custom(Atom::from(name), value));
return PropertyDeclarationParseResult::ValidOrIgnoredDeclaration;
}
match_ignore_ascii_case! { name,
@ -6317,7 +6317,7 @@ impl ComputedValues {
_ => {
let name = try!(::custom_properties::parse_name(name));
let map = try!(self.custom_properties.as_ref().ok_or(()));
let value = try!(map.get(&Atom::from_slice(name)).ok_or(()));
let value = try!(map.get(&Atom::from(name)).ok_or(()));
Ok(value.to_css_string())
}
}

View file

@ -137,13 +137,13 @@ impl<'a, E> Element for ElementWrapper<'a, E> where E: Element {
}
fn get_id(&self) -> Option<Atom> {
match self.snapshot.attrs {
Some(_) => self.snapshot.get_attr(&ns!(""), &atom!("id")).map(|value| value.as_atom().clone()),
Some(_) => self.snapshot.get_attr(&ns!(), &atom!("id")).map(|value| value.as_atom().clone()),
None => self.element.get_id(),
}
}
fn has_class(&self, name: &Atom) -> bool {
match self.snapshot.attrs {
Some(_) => self.snapshot.get_attr(&ns!(""), &atom!("class"))
Some(_) => self.snapshot.get_attr(&ns!(), &atom!("class"))
.map_or(false, |v| { v.as_tokens().iter().any(|atom| atom == name) }),
None => self.element.has_class(name),
}
@ -180,7 +180,7 @@ impl<'a, E> Element for ElementWrapper<'a, E> where E: Element {
fn each_class<F>(&self, mut callback: F) where F: FnMut(&Atom) {
match self.snapshot.attrs {
Some(_) => {
if let Some(v) = self.snapshot.get_attr(&ns!(""), &atom!("class")) {
if let Some(v) = self.snapshot.get_attr(&ns!(), &atom!("class")) {
for c in v.as_tokens() { callback(c) }
}
}

View file

@ -385,7 +385,7 @@ impl<'a> AtRuleParser for TopLevelRuleParser<'a> {
self.state.set(State::Namespaces);
let prefix = input.try(|input| input.expect_ident()).ok().map(|p| p.into_owned());
let url = Namespace(Atom::from_slice(&*try!(input.expect_url_or_string())));
let url = Namespace(Atom::from(&*try!(input.expect_url_or_string())));
return Ok(AtRuleType::WithoutBlock(CSSRule::Namespace(prefix, url)))
} else {
return Err(()) // "@namespace must be before any rule but @charset and @import"