diff options
Diffstat (limited to 'components/util/str.rs')
-rw-r--r-- | components/util/str.rs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/components/util/str.rs b/components/util/str.rs index 7b2cfdf5107..4ada243391c 100644 --- a/components/util/str.rs +++ b/components/util/str.rs @@ -4,11 +4,11 @@ use geometry::Au; -use cssparser::{mod, RGBA, RGBAColor}; +use cssparser::{mod, RGBA, Color}; use std::ascii::AsciiExt; -use std::from_str::FromStr; use std::iter::Filter; -use std::str::{CharEq, CharSplits}; +use std::num::Int; +use std::str::{CharEq, CharSplits, FromStr}; use unicode::char::to_lowercase; pub type DOMString = String; @@ -105,13 +105,13 @@ fn do_parse_integer<T: Iterator<char>>(input: T) -> Option<i64> { d as i64 - '0' as i64 }).fold(Some(0i64), |accumulator, d| { accumulator.and_then(|accumulator| { - accumulator.checked_mul(&10) + accumulator.checked_mul(10) }).and_then(|accumulator| { - accumulator.checked_add(&d) + accumulator.checked_add(d) }) }); - return value.and_then(|value| value.checked_mul(&sign)); + return value.and_then(|value| value.checked_mul(sign)); } /// Parse an integer according to @@ -131,23 +131,23 @@ pub fn parse_unsigned_integer<T: Iterator<char>>(input: T) -> Option<u32> { } pub enum LengthOrPercentageOrAuto { - AutoLpa, - PercentageLpa(f64), - LengthLpa(Au), + Auto, + Percentage(f64), + Length(Au), } -/// Parses a length per HTML5 § 2.4.4.4. If unparseable, `AutoLpa` is returned. +/// Parses a length per HTML5 § 2.4.4.4. If unparseable, `Auto` is returned. pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto { value = value.trim_left_chars(Whitespace); if value.len() == 0 { - return AutoLpa + return LengthOrPercentageOrAuto::Auto } if value.starts_with("+") { value = value.slice_from(1) } value = value.trim_left_chars('0'); if value.len() == 0 { - return AutoLpa + return LengthOrPercentageOrAuto::Auto } let mut end_index = value.len(); @@ -175,14 +175,14 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto { if found_percent { let result: Option<f64> = FromStr::from_str(value); match result { - Some(number) => return PercentageLpa((number as f64) / 100.0), - None => return AutoLpa, + Some(number) => return LengthOrPercentageOrAuto::Percentage((number as f64) / 100.0), + None => return LengthOrPercentageOrAuto::Auto, } } match FromStr::from_str(value) { - Some(number) => LengthLpa(Au::from_px(number)), - None => AutoLpa, + Some(number) => LengthOrPercentageOrAuto::Length(Au::from_px(number)), + None => LengthOrPercentageOrAuto::Auto, } } @@ -203,7 +203,7 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA,()> { // Step 5. match cssparser::parse_color_keyword(input) { - Ok(RGBAColor(rgba)) => return Ok(rgba), + Ok(Color::RGBA(rgba)) => return Ok(rgba), _ => {} } |