mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update rustc to revision 3dcd2157403163789aaf21a9ab3c4d30a7c6494d.
This commit is contained in:
parent
b8900782b0
commit
466faac2a5
223 changed files with 4414 additions and 4105 deletions
|
@ -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),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue