Upgrade to rustc 0.8-pre (0a677bc 2013-08-14 10:35:12 -0700)

This commit is contained in:
Simon Sapin 2013-08-16 14:48:52 +01:00
parent b5860f407f
commit 8fec26174b
9 changed files with 27 additions and 31 deletions

View file

@ -8,7 +8,7 @@ use cssparser::{SyntaxError, SourceLocation};
pub struct ErrorLoggerIterator<I>(I); pub struct ErrorLoggerIterator<I>(I);
impl<T, I: Iterator<Result<T, SyntaxError>>> Iterator<T> for ErrorLoggerIterator<I> { impl<T, I: Iterator<Result<T, SyntaxError>>> Iterator<T> for ErrorLoggerIterator<I> {
pub fn next(&mut self) -> Option<T> { fn next(&mut self) -> Option<T> {
for result in **self { for result in **self {
match result { match result {
Ok(v) => return Some(v), Ok(v) => return Some(v),

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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 cssparser::*;
use errors::{ErrorLoggerIterator, log_css_error}; use errors::{ErrorLoggerIterator, log_css_error};
use stylesheets::{CSSRule, CSSMediaRule, parse_style_rule, parse_nested_at_rule}; 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 { match rule {
QualifiedRule(rule) => parse_style_rule(rule, &mut rules, namespaces), QualifiedRule(rule) => parse_style_rule(rule, &mut rules, namespaces),
AtRule(rule) => parse_nested_at_rule( 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 { parent_rules.push(CSSMediaRule(MediaRule {
@ -80,8 +80,7 @@ pub fn parse_media_query_list(input: &[ComponentValue]) -> MediaQueryList {
loop { loop {
let mq = match next { let mq = match next {
Some(&Ident(ref value)) => { Some(&Ident(ref value)) => {
let media_type: &str = to_ascii_lower(value.as_slice()); match value.to_ascii_lower().as_slice() {
match media_type {
"screen" => Some(MediaQuery{ media_type: MediaType(Screen) }), "screen" => Some(MediaQuery{ media_type: MediaType(Screen) }),
"print" => Some(MediaQuery{ media_type: MediaType(Print) }), "print" => Some(MediaQuery{ media_type: MediaType(Print) }),
"all" => Some(MediaQuery{ media_type: All }), "all" => Some(MediaQuery{ media_type: All }),

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * 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 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> { pub fn get_ident_lower(component_value: &ComponentValue) -> Option<~str> {
match component_value { match component_value {
&Ident(ref value) => Some(to_ascii_lower(value.as_slice())), &Ident(ref value) => Some(value.to_ascii_lower()),
_ => None, _ => None,
} }
} }

View file

@ -11,7 +11,7 @@ pub type Integer = i64;
pub mod specified { pub mod specified {
use std::ascii::{to_ascii_lower, eq_ignore_ascii_case}; use std::ascii::StrAsciiExt;
use cssparser::*; use cssparser::*;
use super::{Integer, Float}; use super::{Integer, Float};
@ -50,7 +50,7 @@ pub mod specified {
Length::parse_internal(input, /* negative_ok = */ false) Length::parse_internal(input, /* negative_ok = */ false)
} }
pub fn parse_dimension(value: Float, unit: &str) -> Option<Length> { pub fn parse_dimension(value: Float, unit: &str) -> Option<Length> {
match to_ascii_lower(unit).as_slice() { match unit.to_ascii_lower().as_slice() {
"px" => Some(Length::from_px(value)), "px" => Some(Length::from_px(value)),
"in" => Some(Au((value * AU_PER_IN) as Integer)), "in" => Some(Au((value * AU_PER_IN) as Integer)),
"cm" => Some(Au((value * AU_PER_CM) 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_), => Length::parse_dimension(value.value, unit.as_slice()).map_move(Length_),
&ast::Percentage(ref value) if negative_ok || value.value >= 0. &ast::Percentage(ref value) if negative_ok || value.value >= 0.
=> Some(Percentage_(value.value)), => Some(Percentage_(value.value)),
&Number(ref value) if value.value == 0. => Some(Length_(Au(0))), &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), &Ident(ref value) if value.eq_ignore_ascii_case("auto") => Some(Auto),
_ => None _ => None
} }
} }

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * 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::iterator;
pub use std::option; pub use std::option;
pub use cssparser::*; pub use cssparser::*;
@ -84,7 +84,7 @@ single_type!(border_left_style, BorderStyle)
pub fn parse_border_width(component_value: &ComponentValue) -> Option<specified::Length> { pub fn parse_border_width(component_value: &ComponentValue) -> Option<specified::Length> {
match component_value { 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.)), "thin" => Some(specified::Length::from_px(1.)),
"medium" => Some(specified::Length::from_px(3.)), "medium" => Some(specified::Length::from_px(3.)),
"thick" => Some(specified::Length::from_px(5.)), "thick" => Some(specified::Length::from_px(5.)),
@ -154,7 +154,7 @@ pub mod line_height {
=> Some(Percentage(value.value)), => Some(Percentage(value.value)),
&Dimension(ref value, ref unit) if value.value >= 0. &Dimension(ref value, ref unit) if value.value >= 0.
=> specified::Length::parse_dimension(value.value, unit.as_slice()).map_move(Length), => 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), => Some(Normal),
_ => None, _ => None,
} }
@ -213,7 +213,7 @@ pub mod font_family {
Some(&String(ref value)) => add!(FamilyName(value.to_owned())), Some(&String(ref value)) => add!(FamilyName(value.to_owned())),
Some(&Ident(ref value)) => { Some(&Ident(ref value)) => {
let value = value.as_slice(); let value = value.as_slice();
match to_ascii_lower(value).as_slice() { match value.to_ascii_lower().as_slice() {
"serif" => add!(Serif), "serif" => add!(Serif),
"sans-serif" => add!(SansSerif), "sans-serif" => add!(SansSerif),
"cursive" => add!(Cursive), "cursive" => add!(Cursive),
@ -273,7 +273,7 @@ pub mod font_weight {
} }
pub fn from_component_value(input: &ComponentValue) -> Option<SpecifiedValue> { pub fn from_component_value(input: &ComponentValue) -> Option<SpecifiedValue> {
match input { 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), "bold" => Some(Weight700),
"normal" => Some(Weight400), "normal" => Some(Weight400),
"bolder" => Some(Bolder), "bolder" => Some(Bolder),

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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 cssparser::*;
use errors::{ErrorLoggerIterator, log_css_error}; 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)), rule.location, fmt!("Unsupported at-rule in declaration list: @%s", rule.name)),
Declaration(Declaration{ location: l, name: n, value: v, important: i}) => { Declaration(Declaration{ location: l, name: n, value: v, important: i}) => {
let list = if i { &mut important } else { &mut normal }; 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") log_css_error(l, "Invalid property declaration")
} }
} }

View file

@ -208,7 +208,7 @@ shorthand!(font [
// font-style, font-weight and font-variant. // font-style, font-weight and font-variant.
// Leaves the values to None, 'normal' is the initial value for each of them. // Leaves the values to None, 'normal' is the initial value for each of them.
if get_ident_lower(component_value).filtered( 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; nb_normals += 1;
loop; loop;
} }

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::{vec, iterator}; use std::{vec, iterator};
use std::ascii::to_ascii_lower; use std::ascii::StrAsciiExt;
use cssparser::*; use cssparser::*;
use namespaces::NamespaceMap; use namespaces::NamespaceMap;
@ -230,7 +230,7 @@ fn parse_type_selector(iter: &mut Iter, namespaces: &NamespaceMap)
} }
match local_name { match local_name {
Some(name) => simple_selectors.push(LocalNameSelector{ Some(name) => simple_selectors.push(LocalNameSelector{
lowercase_name: to_ascii_lower(name), lowercase_name: name.to_ascii_lower(),
cased_name: name, cased_name: name,
}), }),
None => (), 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((_, None))) => fail!("Implementation error, this should not happen."),
Some(Some((namespace, Some(local_name)))) => AttrSelector { Some(Some((namespace, Some(local_name)))) => AttrSelector {
namespace: namespace, namespace: namespace,
lowercase_name: to_ascii_lower(local_name), lowercase_name: local_name.to_ascii_lower(),
cased_name: local_name, cased_name: local_name,
}, },
}; };
@ -394,8 +394,7 @@ fn parse_attribute_selector(content: ~[ComponentValue], namespaces: &NamespaceMa
fn parse_simple_pseudo_class(name: ~str) -> Option<Either<SimpleSelector, PseudoElement>> { fn parse_simple_pseudo_class(name: ~str) -> Option<Either<SimpleSelector, PseudoElement>> {
let lower_name: &str = to_ascii_lower(name); match name.to_ascii_lower().as_slice() {
match lower_name {
"root" => Some(Left(Root)), "root" => Some(Left(Root)),
"empty" => Some(Left(Empty)), "empty" => Some(Left(Empty)),
@ -412,8 +411,7 @@ fn parse_simple_pseudo_class(name: ~str) -> Option<Either<SimpleSelector, Pseudo
fn parse_functional_pseudo_class(name: ~str, arguments: ~[ComponentValue], fn parse_functional_pseudo_class(name: ~str, arguments: ~[ComponentValue],
namespaces: &NamespaceMap, inside_negation: bool) namespaces: &NamespaceMap, inside_negation: bool)
-> Option<SimpleSelector> { -> Option<SimpleSelector> {
let lower_name: &str = to_ascii_lower(name); match name.to_ascii_lower().as_slice() {
match lower_name {
"lang" => parse_lang(arguments), "lang" => parse_lang(arguments),
"nth-child" => parse_nth(arguments).map(|&(a, b)| NthChild(a, b)), "nth-child" => parse_nth(arguments).map(|&(a, b)| NthChild(a, b)),
"not" => if inside_negation { None } else { parse_negation(arguments, namespaces) }, "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<PseudoElement> { fn parse_pseudo_element(name: ~str) -> Option<PseudoElement> {
let lower_name: &str = to_ascii_lower(name); match name.to_ascii_lower().as_slice() {
match lower_name {
// All supported pseudo-elements // All supported pseudo-elements
"before" => Some(Before), "before" => Some(Before),
"after" => Some(After), "after" => Some(After),

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::iterator::Iterator; use std::iterator::Iterator;
use std::ascii::to_ascii_lower; use std::ascii::StrAsciiExt;
use cssparser::*; use cssparser::*;
use selectors; use selectors;
use properties; use properties;
@ -49,8 +49,8 @@ fn parse_stylesheet(css: &str) -> Stylesheet {
parse_style_rule(rule, &mut rules, &namespaces) parse_style_rule(rule, &mut rules, &namespaces)
}, },
AtRule(rule) => { AtRule(rule) => {
let lower_name: &str = to_ascii_lower(rule.name); let lower_name = rule.name.to_ascii_lower();
match lower_name { match lower_name.as_slice() {
"charset" => { "charset" => {
if state > STATE_CHARSET { if state > STATE_CHARSET {
log_css_error(rule.location, "@charset must be the first rule") log_css_error(rule.location, "@charset must be the first rule")