diff --git a/errors.rs b/errors.rs index 7a64d0192dd..2a60f66dca8 100644 --- a/errors.rs +++ b/errors.rs @@ -8,7 +8,7 @@ use cssparser::{SyntaxError, SourceLocation}; pub struct ErrorLoggerIterator(I); impl>> Iterator for ErrorLoggerIterator { - pub fn next(&mut self) -> Option { + fn next(&mut self) -> Option { for result in **self { match result { Ok(v) => return Some(v), diff --git a/media_queries.rs b/media_queries.rs index c32642d18b1..3266130fcf1 100644 --- a/media_queries.rs +++ b/media_queries.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use std::ascii::to_ascii_lower; +use std::ascii::StrAsciiExt; use cssparser::*; use errors::{ErrorLoggerIterator, log_css_error}; use stylesheets::{CSSRule, CSSMediaRule, parse_style_rule, parse_nested_at_rule}; @@ -60,7 +60,7 @@ pub fn parse_media_rule(rule: AtRule, parent_rules: &mut ~[CSSRule], match rule { QualifiedRule(rule) => parse_style_rule(rule, &mut rules, namespaces), AtRule(rule) => parse_nested_at_rule( - to_ascii_lower(rule.name), rule, &mut rules, namespaces), + rule.name.to_ascii_lower(), rule, &mut rules, namespaces), } } parent_rules.push(CSSMediaRule(MediaRule { @@ -80,8 +80,7 @@ pub fn parse_media_query_list(input: &[ComponentValue]) -> MediaQueryList { loop { let mq = match next { Some(&Ident(ref value)) => { - let media_type: &str = to_ascii_lower(value.as_slice()); - match media_type { + match value.to_ascii_lower().as_slice() { "screen" => Some(MediaQuery{ media_type: MediaType(Screen) }), "print" => Some(MediaQuery{ media_type: MediaType(Print) }), "all" => Some(MediaQuery{ media_type: All }), diff --git a/parsing_utils.rs b/parsing_utils.rs index 9f3cfddcab0..062e4f5a6ae 100644 --- a/parsing_utils.rs +++ b/parsing_utils.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use std::ascii::to_ascii_lower; +use std::ascii::StrAsciiExt; use cssparser::*; @@ -15,7 +15,7 @@ pub fn one_component_value<'a>(input: &'a [ComponentValue]) -> Option<&'a Compon pub fn get_ident_lower(component_value: &ComponentValue) -> Option<~str> { match component_value { - &Ident(ref value) => Some(to_ascii_lower(value.as_slice())), + &Ident(ref value) => Some(value.to_ascii_lower()), _ => None, } } diff --git a/properties/common_types.rs b/properties/common_types.rs index 53b30dde27c..80304ff7fe0 100644 --- a/properties/common_types.rs +++ b/properties/common_types.rs @@ -11,7 +11,7 @@ pub type Integer = i64; pub mod specified { - use std::ascii::{to_ascii_lower, eq_ignore_ascii_case}; + use std::ascii::StrAsciiExt; use cssparser::*; use super::{Integer, Float}; @@ -50,7 +50,7 @@ pub mod specified { Length::parse_internal(input, /* negative_ok = */ false) } pub fn parse_dimension(value: Float, unit: &str) -> Option { - match to_ascii_lower(unit).as_slice() { + match unit.to_ascii_lower().as_slice() { "px" => Some(Length::from_px(value)), "in" => Some(Au((value * AU_PER_IN) as Integer)), "cm" => Some(Au((value * AU_PER_CM) as Integer)), @@ -106,8 +106,8 @@ pub mod specified { => Length::parse_dimension(value.value, unit.as_slice()).map_move(Length_), &ast::Percentage(ref value) if negative_ok || value.value >= 0. => Some(Percentage_(value.value)), - &Number(ref value) if value.value == 0. => Some(Length_(Au(0))), - &Ident(ref value) if eq_ignore_ascii_case(value.as_slice(), "auto") => Some(Auto), + &Number(ref value) if value.value == 0. => Some(Length_(Au(0))), + &Ident(ref value) if value.eq_ignore_ascii_case("auto") => Some(Auto), _ => None } } diff --git a/properties/longhands.rs b/properties/longhands.rs index 64c859869a0..e0bc102f8f2 100644 --- a/properties/longhands.rs +++ b/properties/longhands.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -pub use std::ascii::{to_ascii_lower, eq_ignore_ascii_case}; +use std::ascii::StrAsciiExt; pub use std::iterator; pub use std::option; pub use cssparser::*; @@ -84,7 +84,7 @@ single_type!(border_left_style, BorderStyle) pub fn parse_border_width(component_value: &ComponentValue) -> Option { match component_value { - &Ident(ref value) => match to_ascii_lower(value.as_slice()).as_slice() { + &Ident(ref value) => match value.to_ascii_lower().as_slice() { "thin" => Some(specified::Length::from_px(1.)), "medium" => Some(specified::Length::from_px(3.)), "thick" => Some(specified::Length::from_px(5.)), @@ -154,7 +154,7 @@ pub mod line_height { => Some(Percentage(value.value)), &Dimension(ref value, ref unit) if value.value >= 0. => specified::Length::parse_dimension(value.value, unit.as_slice()).map_move(Length), - &Ident(ref value) if eq_ignore_ascii_case(value.as_slice(), "auto") + &Ident(ref value) if value.eq_ignore_ascii_case("auto") => Some(Normal), _ => None, } @@ -213,7 +213,7 @@ pub mod font_family { Some(&String(ref value)) => add!(FamilyName(value.to_owned())), Some(&Ident(ref value)) => { let value = value.as_slice(); - match to_ascii_lower(value).as_slice() { + match value.to_ascii_lower().as_slice() { "serif" => add!(Serif), "sans-serif" => add!(SansSerif), "cursive" => add!(Cursive), @@ -273,7 +273,7 @@ pub mod font_weight { } pub fn from_component_value(input: &ComponentValue) -> Option { match input { - &Ident(ref value) => match to_ascii_lower(value.as_slice()).as_slice() { + &Ident(ref value) => match value.to_ascii_lower().as_slice() { "bold" => Some(Weight700), "normal" => Some(Weight400), "bolder" => Some(Bolder), diff --git a/properties/mod.rs b/properties/mod.rs index 73a8716a828..fc1bd46d7f2 100644 --- a/properties/mod.rs +++ b/properties/mod.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use std::ascii::to_ascii_lower; +use std::ascii::StrAsciiExt; use cssparser::*; use errors::{ErrorLoggerIterator, log_css_error}; @@ -28,7 +28,7 @@ pub fn parse_property_declaration_list(input: ~[Node]) -> PropertyDeclarationBlo rule.location, fmt!("Unsupported at-rule in declaration list: @%s", rule.name)), Declaration(Declaration{ location: l, name: n, value: v, important: i}) => { let list = if i { &mut important } else { &mut normal }; - if !parse_one_property_declaration(to_ascii_lower(n), v, list) { + if !parse_one_property_declaration(n.to_ascii_lower(), v, list) { log_css_error(l, "Invalid property declaration") } } diff --git a/properties/shorthands.rs b/properties/shorthands.rs index b4358883813..178d6bfbe8b 100644 --- a/properties/shorthands.rs +++ b/properties/shorthands.rs @@ -208,7 +208,7 @@ shorthand!(font [ // font-style, font-weight and font-variant. // Leaves the values to None, 'normal' is the initial value for each of them. if get_ident_lower(component_value).filtered( - |v| eq_ignore_ascii_case(v.as_slice(), "normal")).is_some() { + |v| v.eq_ignore_ascii_case("normal")).is_some() { nb_normals += 1; loop; } diff --git a/selectors.rs b/selectors.rs index 8fbe6a67024..2cacb177b54 100644 --- a/selectors.rs +++ b/selectors.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::{vec, iterator}; -use std::ascii::to_ascii_lower; +use std::ascii::StrAsciiExt; use cssparser::*; use namespaces::NamespaceMap; @@ -230,7 +230,7 @@ fn parse_type_selector(iter: &mut Iter, namespaces: &NamespaceMap) } match local_name { Some(name) => simple_selectors.push(LocalNameSelector{ - lowercase_name: to_ascii_lower(name), + lowercase_name: name.to_ascii_lower(), cased_name: name, }), None => (), @@ -366,7 +366,7 @@ fn parse_attribute_selector(content: ~[ComponentValue], namespaces: &NamespaceMa Some(Some((_, None))) => fail!("Implementation error, this should not happen."), Some(Some((namespace, Some(local_name)))) => AttrSelector { namespace: namespace, - lowercase_name: to_ascii_lower(local_name), + lowercase_name: local_name.to_ascii_lower(), cased_name: local_name, }, }; @@ -394,8 +394,7 @@ fn parse_attribute_selector(content: ~[ComponentValue], namespaces: &NamespaceMa fn parse_simple_pseudo_class(name: ~str) -> Option> { - let lower_name: &str = to_ascii_lower(name); - match lower_name { + match name.to_ascii_lower().as_slice() { "root" => Some(Left(Root)), "empty" => Some(Left(Empty)), @@ -412,8 +411,7 @@ fn parse_simple_pseudo_class(name: ~str) -> Option Option { - let lower_name: &str = to_ascii_lower(name); - match lower_name { + match name.to_ascii_lower().as_slice() { "lang" => parse_lang(arguments), "nth-child" => parse_nth(arguments).map(|&(a, b)| NthChild(a, b)), "not" => if inside_negation { None } else { parse_negation(arguments, namespaces) }, @@ -423,8 +421,7 @@ fn parse_functional_pseudo_class(name: ~str, arguments: ~[ComponentValue], fn parse_pseudo_element(name: ~str) -> Option { - let lower_name: &str = to_ascii_lower(name); - match lower_name { + match name.to_ascii_lower().as_slice() { // All supported pseudo-elements "before" => Some(Before), "after" => Some(After), diff --git a/stylesheets.rs b/stylesheets.rs index 46ae1a953f6..5d9d5a2a9fa 100644 --- a/stylesheets.rs +++ b/stylesheets.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::iterator::Iterator; -use std::ascii::to_ascii_lower; +use std::ascii::StrAsciiExt; use cssparser::*; use selectors; use properties; @@ -49,8 +49,8 @@ fn parse_stylesheet(css: &str) -> Stylesheet { parse_style_rule(rule, &mut rules, &namespaces) }, AtRule(rule) => { - let lower_name: &str = to_ascii_lower(rule.name); - match lower_name { + let lower_name = rule.name.to_ascii_lower(); + match lower_name.as_slice() { "charset" => { if state > STATE_CHARSET { log_css_error(rule.location, "@charset must be the first rule")