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

@ -20,11 +20,11 @@ pub fn iter_font_face_rules_inner<F>(rules: &[CSSRule], device: &Device,
CSSRule::Charset(..) | CSSRule::Charset(..) |
CSSRule::Namespace(..) => {}, CSSRule::Namespace(..) => {},
CSSRule::Media(ref rule) => if rule.media_queries.evaluate(device) { CSSRule::Media(ref rule) => if rule.media_queries.evaluate(device) {
iter_font_face_rules_inner(rule.rules.as_slice(), device, callback) iter_font_face_rules_inner(&rule.rules, device, callback)
}, },
CSSRule::FontFace(ref rule) => { CSSRule::FontFace(ref rule) => {
for source in rule.sources.iter() { for source in rule.sources.iter() {
callback(rule.family.as_slice(), source) callback(&rule.family, source)
} }
}, },
} }
@ -130,7 +130,7 @@ fn parse_one_src(context: &ParserContext, input: &mut Parser) -> Result<Source,
let url = match input.next() { let url = match input.next() {
// Parsing url() // Parsing url()
Ok(Token::Url(url)) => { Ok(Token::Url(url)) => {
UrlParser::new().base_url(context.base_url).parse(url.as_slice()).unwrap_or_else( UrlParser::new().base_url(context.base_url).parse(&url).unwrap_or_else(
|_error| Url::parse("about:invalid").unwrap()) |_error| Url::parse("about:invalid").unwrap())
}, },
// Parsing local() with early return // Parsing local() with early return

View file

@ -487,10 +487,10 @@ pub mod longhands {
Ok(SpecifiedValue::Percentage(value.unit_value)) Ok(SpecifiedValue::Percentage(value.unit_value))
} }
Token::Dimension(ref value, ref unit) if value.value >= 0. => { Token::Dimension(ref value, ref unit) if value.value >= 0. => {
specified::Length::parse_dimension(value.value, unit.as_slice()) specified::Length::parse_dimension(value.value, unit)
.map(SpecifiedValue::Length) .map(SpecifiedValue::Length)
} }
Token::Ident(ref value) if value.as_slice().eq_ignore_ascii_case("normal") => { Token::Ident(ref value) if value.eq_ignore_ascii_case("normal") => {
Ok(SpecifiedValue::Normal) Ok(SpecifiedValue::Normal)
} }
_ => Err(()), _ => Err(()),
@ -781,7 +781,7 @@ pub mod longhands {
if input.try(|input| input.expect_ident_matching("none")).is_ok() { if input.try(|input| input.expect_ident_matching("none")).is_ok() {
Ok(SpecifiedValue::None) Ok(SpecifiedValue::None)
} else { } else {
Ok(SpecifiedValue::Url(context.parse_url(try!(input.expect_url()).as_slice()))) Ok(SpecifiedValue::Url(context.parse_url(&*try!(input.expect_url()))))
} }
} }
#[inline] #[inline]
@ -988,7 +988,7 @@ pub mod longhands {
impl FontFamily { impl FontFamily {
pub fn name(&self) -> &str { pub fn name(&self) -> &str {
match *self { match *self {
FontFamily::FamilyName(ref name) => name.as_slice(), FontFamily::FamilyName(ref name) => name,
} }
} }
} }
@ -1040,7 +1040,7 @@ pub mod longhands {
let mut value = first_ident.into_owned(); let mut value = first_ident.into_owned();
while let Ok(ident) = input.try(|input| input.expect_ident()) { while let Ok(ident) = input.try(|input| input.expect_ident()) {
value.push_str(" "); value.push_str(" ");
value.push_str(ident.as_slice()); value.push_str(&ident);
} }
Ok(FontFamily::FamilyName(value)) Ok(FontFamily::FamilyName(value))
} }
@ -1555,7 +1555,7 @@ pub mod longhands {
if ident.eq_ignore_ascii_case("auto") { if ident.eq_ignore_ascii_case("auto") {
Ok(SpecifiedValue::AutoCursor) Ok(SpecifiedValue::AutoCursor)
} else { } else {
util_cursor::Cursor::from_css_keyword(ident.as_slice()) util_cursor::Cursor::from_css_keyword(&ident)
.map(SpecifiedValue::SpecifiedCursor) .map(SpecifiedValue::SpecifiedCursor)
} }
} }
@ -2600,9 +2600,9 @@ pub fn parse_property_declaration_list(context: &ParserContext, input: &mut Pars
match declaration { match declaration {
Ok((results, important)) => { Ok((results, important)) => {
if important { if important {
important_declarations.push_all(results.as_slice()); important_declarations.push_all(&results);
} else { } else {
normal_declarations.push_all(results.as_slice()); normal_declarations.push_all(&results);
} }
} }
Err(range) => { Err(range) => {
@ -2727,11 +2727,12 @@ impl PropertyDeclaration {
} }
pub fn matches(&self, name: &str) -> bool { pub fn matches(&self, name: &str) -> bool {
let name_lower = name.as_slice().to_ascii_lowercase(); match *self {
match (self, name_lower.as_slice()) {
% for property in LONGHANDS: % for property in LONGHANDS:
% if property.derived_from is None: % if property.derived_from is None:
(&PropertyDeclaration::${property.camel_case}(..), "${property.name}") => true, PropertyDeclaration::${property.camel_case}(..) => {
name.eq_ignore_ascii_case("${property.name}")
}
% endif % endif
% endfor % endfor
_ => false, _ => false,

View file

@ -126,7 +126,7 @@ impl SelectorMap {
SelectorMap::get_matching_rules(node, SelectorMap::get_matching_rules(node,
parent_bf, parent_bf,
self.universal_rules.as_slice(), &self.universal_rules,
matching_rules_list, matching_rules_list,
shareable); shareable);
@ -151,7 +151,7 @@ impl SelectorMap {
Some(rules) => { Some(rules) => {
SelectorMap::get_matching_rules(node, SelectorMap::get_matching_rules(node,
parent_bf, parent_bf,
rules.as_slice(), rules,
matching_rules, matching_rules,
shareable) shareable)
} }
@ -292,8 +292,8 @@ impl Stylist {
// (Does it make a difference?) // (Does it make a difference?)
for &filename in ["user-agent.css", "servo.css", "presentational-hints.css"].iter() { for &filename in ["user-agent.css", "servo.css", "presentational-hints.css"].iter() {
let ua_stylesheet = Stylesheet::from_bytes( let ua_stylesheet = Stylesheet::from_bytes(
read_resource_file(&[filename]).unwrap().as_slice(), &read_resource_file(&[filename]).unwrap(),
Url::parse(format!("chrome:///{:?}", filename).as_slice()).unwrap(), Url::parse(&format!("chrome:///{:?}", filename)).unwrap(),
None, None,
None, None,
Origin::UserAgent); Origin::UserAgent);
@ -384,7 +384,7 @@ impl Stylist {
pub fn add_quirks_mode_stylesheet(&mut self) { pub fn add_quirks_mode_stylesheet(&mut self) {
self.add_stylesheet(Stylesheet::from_bytes( self.add_stylesheet(Stylesheet::from_bytes(
read_resource_file(&["quirks-mode.css"]).unwrap().as_slice(), &read_resource_file(&["quirks-mode.css"]).unwrap(),
Url::parse("chrome:///quirks-mode.css").unwrap(), Url::parse("chrome:///quirks-mode.css").unwrap(),
None, None,
None, None,
@ -862,10 +862,10 @@ pub fn matches_simple_selector<'a,E,N>(selector: &SimpleSelector,
element.match_attr(attr, |_| true) element.match_attr(attr, |_| true)
} }
SimpleSelector::AttrEqual(ref attr, ref value, case_sensitivity) => { SimpleSelector::AttrEqual(ref attr, ref value, case_sensitivity) => {
if value.as_slice() != "DIR" && if *value != "DIR" &&
common_style_affecting_attributes().iter().all(|common_attr_info| { common_style_affecting_attributes().iter().all(|common_attr_info| {
!(common_attr_info.atom == attr.name && match common_attr_info.mode { !(common_attr_info.atom == attr.name && match common_attr_info.mode {
CommonStyleAffectingAttributeMode::IsEqual(target_value, _) => target_value == value.as_slice(), CommonStyleAffectingAttributeMode::IsEqual(target_value, _) => *value == target_value,
CommonStyleAffectingAttributeMode::IsPresent(_) => false, CommonStyleAffectingAttributeMode::IsPresent(_) => false,
}) })
}) { }) {
@ -875,40 +875,40 @@ pub fn matches_simple_selector<'a,E,N>(selector: &SimpleSelector,
} }
element.match_attr(attr, |attr_value| { element.match_attr(attr, |attr_value| {
match case_sensitivity { match case_sensitivity {
CaseSensitivity::CaseSensitive => attr_value == value.as_slice(), CaseSensitivity::CaseSensitive => attr_value == *value,
CaseSensitivity::CaseInsensitive => attr_value.eq_ignore_ascii_case(value.as_slice()), CaseSensitivity::CaseInsensitive => attr_value.eq_ignore_ascii_case(value),
} }
}) })
} }
SimpleSelector::AttrIncludes(ref attr, ref value) => { SimpleSelector::AttrIncludes(ref attr, ref value) => {
*shareable = false; *shareable = false;
element.match_attr(attr, |attr_value| { element.match_attr(attr, |attr_value| {
attr_value.split(SELECTOR_WHITESPACE).any(|v| v == value.as_slice()) attr_value.split(SELECTOR_WHITESPACE).any(|v| v == *value)
}) })
} }
SimpleSelector::AttrDashMatch(ref attr, ref value, ref dashing_value) => { SimpleSelector::AttrDashMatch(ref attr, ref value, ref dashing_value) => {
*shareable = false; *shareable = false;
element.match_attr(attr, |attr_value| { element.match_attr(attr, |attr_value| {
attr_value == value.as_slice() || attr_value == *value ||
attr_value.starts_with(dashing_value.as_slice()) attr_value.starts_with(dashing_value)
}) })
} }
SimpleSelector::AttrPrefixMatch(ref attr, ref value) => { SimpleSelector::AttrPrefixMatch(ref attr, ref value) => {
*shareable = false; *shareable = false;
element.match_attr(attr, |attr_value| { element.match_attr(attr, |attr_value| {
attr_value.starts_with(value.as_slice()) attr_value.starts_with(value)
}) })
} }
SimpleSelector::AttrSubstringMatch(ref attr, ref value) => { SimpleSelector::AttrSubstringMatch(ref attr, ref value) => {
*shareable = false; *shareable = false;
element.match_attr(attr, |attr_value| { element.match_attr(attr, |attr_value| {
attr_value.contains(value.as_slice()) attr_value.contains(value)
}) })
} }
SimpleSelector::AttrSuffixMatch(ref attr, ref value) => { SimpleSelector::AttrSuffixMatch(ref attr, ref value) => {
*shareable = false; *shareable = false;
element.match_attr(attr, |attr_value| { element.match_attr(attr, |attr_value| {
attr_value.ends_with(value.as_slice()) attr_value.ends_with(value)
}) })
} }

View file

@ -125,13 +125,13 @@ fn compute_specificity(mut selector: &CompoundSelector,
}; };
if pseudo_element.is_some() { specificity.element_selectors += 1 } if pseudo_element.is_some() { specificity.element_selectors += 1 }
simple_selectors_specificity(selector.simple_selectors.as_slice(), &mut specificity); simple_selectors_specificity(&selector.simple_selectors, &mut specificity);
loop { loop {
match selector.next { match selector.next {
None => break, None => break,
Some((ref next_selector, _)) => { Some((ref next_selector, _)) => {
selector = &**next_selector; selector = &**next_selector;
simple_selectors_specificity(selector.simple_selectors.as_slice(), &mut specificity) simple_selectors_specificity(&selector.simple_selectors, &mut specificity)
} }
} }
} }
@ -169,7 +169,7 @@ fn compute_specificity(mut selector: &CompoundSelector,
specificity.class_like_selectors += 1, specificity.class_like_selectors += 1,
&SimpleSelector::Namespace(..) => (), &SimpleSelector::Namespace(..) => (),
&SimpleSelector::Negation(ref negated) => &SimpleSelector::Negation(ref negated) =>
simple_selectors_specificity(negated.as_slice(), specificity), simple_selectors_specificity(negated, specificity),
} }
} }
} }
@ -270,8 +270,8 @@ fn parse_type_selector(context: &ParserContext, input: &mut Parser)
match local_name { match local_name {
Some(name) => { Some(name) => {
simple_selectors.push(SimpleSelector::LocalName(LocalName { simple_selectors.push(SimpleSelector::LocalName(LocalName {
name: Atom::from_slice(name.as_slice()), name: Atom::from_slice(&name),
lower_name: Atom::from_slice(name.into_owned().into_ascii_lowercase().as_slice()) lower_name: Atom::from_slice(&name.into_owned().into_ascii_lowercase())
})) }))
} }
None => (), None => (),
@ -322,7 +322,7 @@ fn parse_qualified_name<'i, 't>
let position = input.position(); let position = input.position();
match input.next_including_whitespace() { match input.next_including_whitespace() {
Ok(Token::Delim('|')) => { Ok(Token::Delim('|')) => {
let result = context.namespaces.prefix_map.get(value.as_slice()); let result = context.namespaces.prefix_map.get(&*value);
let namespace = try!(result.ok_or(())); let namespace = try!(result.ok_or(()));
explicit_namespace(input, NamespaceConstraint::Specific(namespace.clone())) explicit_namespace(input, NamespaceConstraint::Specific(namespace.clone()))
}, },
@ -366,8 +366,8 @@ fn parse_attribute_selector(context: &ParserContext, input: &mut Parser)
Some((_, None)) => unreachable!(), Some((_, None)) => unreachable!(),
Some((namespace, Some(local_name))) => AttrSelector { Some((namespace, Some(local_name))) => AttrSelector {
namespace: namespace, namespace: namespace,
lower_name: Atom::from_slice(local_name.as_slice().to_ascii_lowercase().as_slice()), lower_name: Atom::from_slice(&local_name.to_ascii_lowercase()),
name: Atom::from_slice(local_name.as_slice()), name: Atom::from_slice(&local_name),
}, },
}; };
@ -526,13 +526,13 @@ fn parse_one_simple_selector(context: &ParserContext,
let start_position = input.position(); let start_position = input.position();
match input.next_including_whitespace() { match input.next_including_whitespace() {
Ok(Token::IDHash(id)) => { Ok(Token::IDHash(id)) => {
let id = SimpleSelector::ID(Atom::from_slice(id.as_slice())); let id = SimpleSelector::ID(Atom::from_slice(&id));
Ok(Some(SimpleSelectorParseResult::SimpleSelector(id))) Ok(Some(SimpleSelectorParseResult::SimpleSelector(id)))
} }
Ok(Token::Delim('.')) => { Ok(Token::Delim('.')) => {
match input.next_including_whitespace() { match input.next_including_whitespace() {
Ok(Token::Ident(class)) => { Ok(Token::Ident(class)) => {
let class = SimpleSelector::Class(Atom::from_slice(class.as_slice())); let class = SimpleSelector::Class(Atom::from_slice(&class));
Ok(Some(SimpleSelectorParseResult::SimpleSelector(class))) Ok(Some(SimpleSelectorParseResult::SimpleSelector(class)))
} }
_ => Err(()), _ => Err(()),
@ -547,7 +547,7 @@ fn parse_one_simple_selector(context: &ParserContext,
Ok(Token::Colon) => { Ok(Token::Colon) => {
match input.next_including_whitespace() { match input.next_including_whitespace() {
Ok(Token::Ident(name)) => { Ok(Token::Ident(name)) => {
match parse_simple_pseudo_class(context, name.as_slice()) { match parse_simple_pseudo_class(context, &name) {
Err(()) => { Err(()) => {
let pseudo_element = match_ignore_ascii_case! { name, let pseudo_element = match_ignore_ascii_case! { name,
// Supported CSS 2.1 pseudo-elements only. // Supported CSS 2.1 pseudo-elements only.
@ -564,16 +564,15 @@ fn parse_one_simple_selector(context: &ParserContext,
} }
} }
Ok(Token::Function(name)) => { Ok(Token::Function(name)) => {
let name = name.as_slice();
let pseudo = try!(input.parse_nested_block(|input| { let pseudo = try!(input.parse_nested_block(|input| {
parse_functional_pseudo_class(context, input, name, inside_negation) parse_functional_pseudo_class(context, input, &name, inside_negation)
})); }));
Ok(Some(SimpleSelectorParseResult::SimpleSelector(pseudo))) Ok(Some(SimpleSelectorParseResult::SimpleSelector(pseudo)))
} }
Ok(Token::Colon) => { Ok(Token::Colon) => {
match input.next() { match input.next() {
Ok(Token::Ident(name)) => { Ok(Token::Ident(name)) => {
let pseudo = try!(parse_pseudo_element(name.as_slice())); let pseudo = try!(parse_pseudo_element(&name));
Ok(Some(SimpleSelectorParseResult::PseudoElement(pseudo))) Ok(Some(SimpleSelectorParseResult::PseudoElement(pseudo)))
} }
_ => Err(()) _ => Err(())

View file

@ -63,12 +63,12 @@ impl Stylesheet {
pub fn from_bytes_iter<I: Iterator<Item=Vec<u8>>>( pub fn from_bytes_iter<I: Iterator<Item=Vec<u8>>>(
input: I, base_url: Url, protocol_encoding_label: Option<&str>, input: I, base_url: Url, protocol_encoding_label: Option<&str>,
environment_encoding: Option<EncodingRef>, origin: Origin) -> Stylesheet { environment_encoding: Option<EncodingRef>, origin: Origin) -> Stylesheet {
let mut bytes = vec!(); let mut bytes = vec![];
// TODO: incremental decoding and tokenization/parsing // TODO: incremental decoding and tokenization/parsing
for chunk in input { 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) environment_encoding, origin)
} }
@ -80,8 +80,8 @@ impl Stylesheet {
-> Stylesheet { -> Stylesheet {
// TODO: bytes.as_slice could be bytes.container_as_bytes() // TODO: bytes.as_slice could be bytes.container_as_bytes()
let (string, _) = decode_stylesheet_bytes( let (string, _) = decode_stylesheet_bytes(
bytes.as_slice(), protocol_encoding_label, environment_encoding); bytes, protocol_encoding_label, environment_encoding);
Stylesheet::from_str(string.as_slice(), base_url, origin) Stylesheet::from_str(&string, base_url, origin)
} }
pub fn from_str<'i>(css: &'i str, base_url: Url, origin: Origin) -> Stylesheet { 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); self.state.set(State::Namespaces);
let prefix = input.try(|input| input.expect_ident()).ok().map(|p| p.into_owned()); 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))) return Ok(AtRuleType::WithoutBlock(CSSRule::Namespace(prefix, url)))
} else { } else {
return Err(()) // "@namespace must be before any rule but @charset and @import" 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 { match *rule {
CSSRule::Style(ref rule) => callback(rule), CSSRule::Style(ref rule) => callback(rule),
CSSRule::Media(ref rule) => if rule.media_queries.evaluate(device) { 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::FontFace(..) |
CSSRule::Charset(..) | CSSRule::Charset(..) |
@ -312,14 +312,14 @@ pub fn iter_stylesheet_media_rules<F>(stylesheet: &Stylesheet, mut callback: F)
#[inline] #[inline]
pub fn iter_stylesheet_style_rules<F>(stylesheet: &Stylesheet, device: &media_queries::Device, pub fn iter_stylesheet_style_rules<F>(stylesheet: &Stylesheet, device: &media_queries::Device,
mut callback: F) where F: FnMut(&StyleRule) { 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] #[inline]
pub fn iter_font_face_rules<F>(stylesheet: &Stylesheet, device: &Device, pub fn iter_font_face_rules<F>(stylesheet: &Stylesheet, device: &Device,
callback: &F) where F: Fn(&str, &Source) { 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)
} }

View file

@ -89,7 +89,7 @@ pub mod specified {
impl ToCss for CSSColor { impl ToCss for CSSColor {
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter { fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
match self.authored { match self.authored {
Some(ref s) => dest.write_str(s.as_slice()), Some(ref s) => dest.write_str(s),
None => self.parsed.to_css(dest), None => self.parsed.to_css(dest),
} }
} }
@ -107,7 +107,7 @@ pub mod specified {
impl ToCss for CSSRGBA { impl ToCss for CSSRGBA {
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter { fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
match self.authored { match self.authored {
Some(ref s) => dest.write_str(s.as_slice()), Some(ref s) => dest.write_str(s),
None => self.parsed.to_css(dest), None => self.parsed.to_css(dest),
} }
} }
@ -171,7 +171,7 @@ pub mod specified {
fn parse_internal(input: &mut Parser, negative_ok: bool) -> Result<Length, ()> { fn parse_internal(input: &mut Parser, negative_ok: bool) -> Result<Length, ()> {
match try!(input.next()) { match try!(input.next()) {
Token::Dimension(ref value, ref unit) if negative_ok || value.value >= 0. => { Token::Dimension(ref value, ref unit) if negative_ok || value.value >= 0. => {
Length::parse_dimension(value.value, unit.as_slice()) Length::parse_dimension(value.value, unit)
} }
Token::Number(ref value) if value.value == 0. => Ok(Length::Au(Au(0))), Token::Number(ref value) if value.value == 0. => Ok(Length::Au(Au(0))),
_ => Err(()) _ => Err(())
@ -229,7 +229,7 @@ pub mod specified {
-> Result<LengthOrPercentage, ()> { -> Result<LengthOrPercentage, ()> {
match try!(input.next()) { match try!(input.next()) {
Token::Dimension(ref value, ref unit) if negative_ok || value.value >= 0. => { Token::Dimension(ref value, ref unit) if negative_ok || value.value >= 0. => {
Length::parse_dimension(value.value, unit.as_slice()) Length::parse_dimension(value.value, unit)
.map(LengthOrPercentage::Length) .map(LengthOrPercentage::Length)
} }
Token::Percentage(ref value) if negative_ok || value.unit_value >= 0. => { Token::Percentage(ref value) if negative_ok || value.unit_value >= 0. => {
@ -278,7 +278,7 @@ pub mod specified {
-> Result<LengthOrPercentageOrAuto, ()> { -> Result<LengthOrPercentageOrAuto, ()> {
match try!(input.next()) { match try!(input.next()) {
Token::Dimension(ref value, ref unit) if negative_ok || value.value >= 0. => { Token::Dimension(ref value, ref unit) if negative_ok || value.value >= 0. => {
Length::parse_dimension(value.value, unit.as_slice()) Length::parse_dimension(value.value, unit)
.map(LengthOrPercentageOrAuto::Length) .map(LengthOrPercentageOrAuto::Length)
} }
Token::Percentage(ref value) if negative_ok || value.unit_value >= 0. => { Token::Percentage(ref value) if negative_ok || value.unit_value >= 0. => {
@ -329,7 +329,7 @@ pub mod specified {
-> Result<LengthOrPercentageOrNone, ()> { -> Result<LengthOrPercentageOrNone, ()> {
match try!(input.next()) { match try!(input.next()) {
Token::Dimension(ref value, ref unit) if negative_ok || value.value >= 0. => { Token::Dimension(ref value, ref unit) if negative_ok || value.value >= 0. => {
Length::parse_dimension(value.value, unit.as_slice()) Length::parse_dimension(value.value, unit)
.map(LengthOrPercentageOrNone::Length) .map(LengthOrPercentageOrNone::Length)
} }
Token::Percentage(ref value) if negative_ok || value.unit_value >= 0. => { Token::Percentage(ref value) if negative_ok || value.unit_value >= 0. => {
@ -370,7 +370,7 @@ pub mod specified {
pub fn parse(input: &mut Parser) -> Result<PositionComponent, ()> { pub fn parse(input: &mut Parser) -> Result<PositionComponent, ()> {
match try!(input.next()) { match try!(input.next()) {
Token::Dimension(ref value, ref unit) => { Token::Dimension(ref value, ref unit) => {
Length::parse_dimension(value.value, unit.as_slice()) Length::parse_dimension(value.value, unit)
.map(PositionComponent::Length) .map(PositionComponent::Length)
} }
Token::Percentage(ref value) => { Token::Percentage(ref value) => {
@ -479,7 +479,7 @@ pub mod specified {
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<Image, ()> { pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<Image, ()> {
match try!(input.next()) { match try!(input.next()) {
Token::Url(url) => { Token::Url(url) => {
Ok(Image::Url(context.parse_url(url.as_slice()))) Ok(Image::Url(context.parse_url(&url)))
} }
Token::Function(name) => { Token::Function(name) => {
match_ignore_ascii_case! { name, match_ignore_ascii_case! { name,