Remove usage of the deprecated .as_slice() in libstyle.

This commit is contained in:
Simon Sapin 2015-02-13 08:30:22 +01:00
parent 1ceadf3813
commit 2ddb13db4b
6 changed files with 60 additions and 60 deletions

View file

@ -63,12 +63,12 @@ impl Stylesheet {
pub fn from_bytes_iter<I: Iterator<Item=Vec<u8>>>(
input: I, base_url: Url, protocol_encoding_label: Option<&str>,
environment_encoding: Option<EncodingRef>, origin: Origin) -> Stylesheet {
let mut bytes = vec!();
let mut bytes = vec![];
// TODO: incremental decoding and tokenization/parsing
for chunk in input {
bytes.push_all(chunk.as_slice())
bytes.push_all(&chunk)
}
Stylesheet::from_bytes(bytes.as_slice(), base_url, protocol_encoding_label,
Stylesheet::from_bytes(&bytes, base_url, protocol_encoding_label,
environment_encoding, origin)
}
@ -80,8 +80,8 @@ impl Stylesheet {
-> Stylesheet {
// TODO: bytes.as_slice could be bytes.container_as_bytes()
let (string, _) = decode_stylesheet_bytes(
bytes.as_slice(), protocol_encoding_label, environment_encoding);
Stylesheet::from_str(string.as_slice(), base_url, origin)
bytes, protocol_encoding_label, environment_encoding);
Stylesheet::from_str(&string, base_url, origin)
}
pub fn from_str<'i>(css: &'i str, base_url: Url, origin: Origin) -> Stylesheet {
@ -188,7 +188,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()).as_slice()));
let url = Namespace(Atom::from_slice(&*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"
@ -288,7 +288,7 @@ pub fn iter_style_rules<'a, F>(rules: &[CSSRule], device: &media_queries::Device
match *rule {
CSSRule::Style(ref rule) => callback(rule),
CSSRule::Media(ref rule) => if rule.media_queries.evaluate(device) {
iter_style_rules(rule.rules.as_slice(), device, callback)
iter_style_rules(&rule.rules, device, callback)
},
CSSRule::FontFace(..) |
CSSRule::Charset(..) |
@ -312,14 +312,14 @@ pub fn iter_stylesheet_media_rules<F>(stylesheet: &Stylesheet, mut callback: F)
#[inline]
pub fn iter_stylesheet_style_rules<F>(stylesheet: &Stylesheet, device: &media_queries::Device,
mut callback: F) where F: FnMut(&StyleRule) {
iter_style_rules(stylesheet.rules.as_slice(), device, &mut callback)
iter_style_rules(&stylesheet.rules, device, &mut callback)
}
#[inline]
pub fn iter_font_face_rules<F>(stylesheet: &Stylesheet, device: &Device,
callback: &F) where F: Fn(&str, &Source) {
iter_font_face_rules_inner(stylesheet.rules.as_slice(), device, callback)
iter_font_face_rules_inner(&stylesheet.rules, device, callback)
}