Skip to content

Commit

Permalink
No bug - Revendor rust dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Servo VCS Sync committed Oct 10, 2017
1 parent 4f4b90d commit 88c4d2a
Show file tree
Hide file tree
Showing 12 changed files with 294 additions and 214 deletions.
2 changes: 1 addition & 1 deletion third_party/rust/cssparser/.cargo-checksum.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"f1fb4b65964c81bc1240544267ea334f554ca38ae7a74d57066f4d47d2b5d568","Cargo.toml":"7d35a8de9f311d00bd9dfa96e533e3db0584f914b1798d4937ddf1ff6baff74e","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"c5781e673335f37ed3d7acb119f8ed33efdf6eb75a7094b7da2abe0c3230adb8","build.rs":"950bcc47a196f07f99f59637c28cc65e02a885130011f90a2b2608248b4724a2","build/match_byte.rs":"2c84b8ca5884347d2007f49aecbd85b4c7582085526e2704399817249996e19b","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"422a2e934b06a2cca7beef7afeab42bdca81a73eb27afcbdb3d2a98db892590b","src/cow_rc_str.rs":"541216f8ef74ee3cc5cbbc1347e5f32ed66588c401851c9a7d68b867aede1de0","src/from_bytes.rs":"331fe63af2123ae3675b61928a69461b5ac77799fff3ce9978c55cf2c558f4ff","src/lib.rs":"37aec41c81021cd4cc8f34491ee75de2e8340feada2d0096b107597fc4ac485d","src/macros.rs":"adb9773c157890381556ea83d7942dcc676f99eea71abbb6afeffee1e3f28960","src/nth.rs":"17f014269795809cbbee0462eb1a0ecfb73a6e9f3e60d19971430cfc9662911a","src/parser.rs":"69ef59a1c28e49b89cfc67effc7408e59af63c416128889b5e8d48022e17c06d","src/rules_and_declarations.rs":"962f59aab8030b0d1202859ff841ed6254ce4bd4159eee5e915ccdf4b802f4d5","src/serializer.rs":"3dc1d9441c9602f26d34c0b209f6d3954814815b780c068f9dc3514d808de3d9","src/size_of_tests.rs":"4b5e4f6fa209bfe4ff8e44fdf10535a5eba5b7b644afac7ee32b60923c23460c","src/tests.rs":"3572f340d9e38b3482f5f8e6bdbabc99c8ff9caeb8f92cdb7d266a1e5110abb1","src/tokenizer.rs":"c46d540cf589de8a2a2a0d918575a257de4d6a55af78e87b0d9c1345032b80ef","src/unicode_range.rs":"fbbd0f4b393944699730a6b0f945b2b2376fcea61fce2ea37190fb287793021a"},"package":"89af8ca7a36c8c591a9ff56ffb88ea2597095d8c1b834af9ca5be5032dcfe06e"}
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"f1fb4b65964c81bc1240544267ea334f554ca38ae7a74d57066f4d47d2b5d568","Cargo.toml":"fac23b751b4a88d7102e488a4417d695099287c6c88541e64f11dd8bb52d710f","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"c5781e673335f37ed3d7acb119f8ed33efdf6eb75a7094b7da2abe0c3230adb8","build.rs":"950bcc47a196f07f99f59637c28cc65e02a885130011f90a2b2608248b4724a2","build/match_byte.rs":"2c84b8ca5884347d2007f49aecbd85b4c7582085526e2704399817249996e19b","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"c92cdb9dcabcc63de005478ca770858b330f02ee712f9fd21b31eeb7472df72d","src/cow_rc_str.rs":"541216f8ef74ee3cc5cbbc1347e5f32ed66588c401851c9a7d68b867aede1de0","src/from_bytes.rs":"331fe63af2123ae3675b61928a69461b5ac77799fff3ce9978c55cf2c558f4ff","src/lib.rs":"a0433a3cf2147e09a8b2471f50ca136d3494d7fc764417b43dc146e2dd5a09ff","src/macros.rs":"adb9773c157890381556ea83d7942dcc676f99eea71abbb6afeffee1e3f28960","src/nth.rs":"0450aa21ecc4639cbe350a143598d570ed9d2b03ac21b9cb795577e0f92f3be6","src/parser.rs":"3533ece7309e694eccf4858435ad090fc6bf98123d443691572931c4323f44d4","src/rules_and_declarations.rs":"eda11baa27c80df932e43460ec6864ff8c3367aaf7673c15410443097efe2506","src/serializer.rs":"3dc1d9441c9602f26d34c0b209f6d3954814815b780c068f9dc3514d808de3d9","src/size_of_tests.rs":"ccbbd8601646798f87b57877135346bc270736560d2c85b5e5ae8cd6492efd65","src/tests.rs":"e8c2593ee6e93e10fd2bb6a9b8b872d280577ba132c04a533f76c58c7233bf70","src/tokenizer.rs":"c46d540cf589de8a2a2a0d918575a257de4d6a55af78e87b0d9c1345032b80ef","src/unicode_range.rs":"c1c4ed2493e09d248c526ce1ef8575a5f8258da3962b64ffc814ef3bdf9780d0"},"package":"44313341610282488e1156ad1fedebca51c54766c87a041d0287b10499c04ba1"}
32 changes: 16 additions & 16 deletions third_party/rust/cssparser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

[package]
name = "cssparser"
version = "0.21.3"
version = "0.22.0"
authors = ["Simon Sapin <[email protected]>"]
build = "build.rs"
exclude = ["src/css-parsing-tests/**", "src/big-data-url.css"]
Expand All @@ -22,21 +22,18 @@ readme = "README.md"
keywords = ["css", "syntax", "parser"]
license = "MPL-2.0"
repository = "https://github.com/servo/rust-cssparser"
[dependencies.matches]
version = "0.1"

[dependencies.phf]
version = "0.7"

[dependencies.cssparser-macros]
[dependencies.itoa]
version = "0.3"

[dependencies.serde]
version = "1.0"
optional = true

[dependencies.dtoa-short]
version = "0.3"
[dependencies.procedural-masquerade]
version = "0.1"

[dependencies.matches]
version = "0.1"

[dependencies.heapsize]
version = ">= 0.3, < 0.5"
Expand All @@ -45,19 +42,22 @@ optional = true
[dependencies.smallvec]
version = "0.4.3"

[dependencies.procedural-masquerade]
version = "0.1"
[dependencies.phf]
version = "0.7"

[dependencies.itoa]
[dependencies.cssparser-macros]
version = "0.3"

[dependencies.dtoa-short]
version = "0.3"
[dev-dependencies.rustc-serialize]
version = "0.3"

[dev-dependencies.encoding_rs]
version = "0.7"

[dev-dependencies.difference]
version = "1.0"

[dev-dependencies.encoding_rs]
version = "0.7"
[build-dependencies.syn]
version = "0.11"

Expand Down
27 changes: 16 additions & 11 deletions third_party/rust/cssparser/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ impl Color {
/// FIXME(#2) Deprecated CSS2 System Colors are not supported yet.
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Color, BasicParseError<'i>> {
// FIXME: remove clone() when lifetimes are non-lexical
let location = input.current_source_location();
let token = input.next()?.clone();
match token {
Token::Hash(ref value) | Token::IDHash(ref value) => {
Expand All @@ -158,12 +159,11 @@ impl Color {
Token::Ident(ref value) => parse_color_keyword(&*value),
Token::Function(ref name) => {
return input.parse_nested_block(|arguments| {
parse_color_function(&*name, arguments)
.map_err(|e| ParseError::Basic(e))
parse_color_function(&*name, arguments).map_err(|e| e.into())
}).map_err(ParseError::<()>::basic);
}
_ => Err(())
}.map_err(|()| BasicParseError::UnexpectedToken(token))
}.map_err(|()| location.new_basic_unexpected_token_error(token))
}

/// Parse a color hash, without the leading '#' character.
Expand Down Expand Up @@ -424,7 +424,7 @@ fn parse_color_function<'i, 't>(name: &str, arguments: &mut Parser<'i, 't>) -> R
let (red, green, blue, uses_commas) = match_ignore_ascii_case! { name,
"rgb" | "rgba" => parse_rgb_components_rgb(arguments)?,
"hsl" | "hsla" => parse_rgb_components_hsl(arguments)?,
_ => return Err(BasicParseError::UnexpectedToken(Token::Ident(name.to_owned().into()))),
_ => return Err(arguments.new_basic_unexpected_token_error(Token::Ident(name.to_owned().into()))),
};

let alpha = if !arguments.is_exhausted() {
Expand All @@ -433,6 +433,7 @@ fn parse_color_function<'i, 't>(name: &str, arguments: &mut Parser<'i, 't>) -> R
} else {
arguments.expect_delim('/')?;
};
let location = arguments.current_source_location();
match *arguments.next()? {
Token::Number { value: v, .. } => {
clamp_unit_f32(v)
Expand All @@ -441,7 +442,7 @@ fn parse_color_function<'i, 't>(name: &str, arguments: &mut Parser<'i, 't>) -> R
clamp_unit_f32(v)
}
ref t => {
return Err(BasicParseError::UnexpectedToken(t.clone()))
return Err(location.new_basic_unexpected_token_error(t.clone()))
}
}
} else {
Expand All @@ -462,6 +463,8 @@ fn parse_rgb_components_rgb<'i, 't>(arguments: &mut Parser<'i, 't>) -> Result<(u

// Either integers or percentages, but all the same type.
// https://drafts.csswg.org/css-color/#rgb-functions
// FIXME: remove .clone() when lifetimes are non-lexical.
let location = arguments.current_source_location();
match arguments.next()?.clone() {
Token::Number { value: v, .. } => {
red = clamp_floor_256_f32(v);
Expand All @@ -471,7 +474,7 @@ fn parse_rgb_components_rgb<'i, 't>(arguments: &mut Parser<'i, 't>) -> Result<(u
uses_commas = true;
arguments.expect_number()?
}
t => return Err(BasicParseError::UnexpectedToken(t))
t => return Err(location.new_basic_unexpected_token_error(t))
});
if uses_commas {
arguments.expect_comma()?;
Expand All @@ -486,14 +489,14 @@ fn parse_rgb_components_rgb<'i, 't>(arguments: &mut Parser<'i, 't>) -> Result<(u
uses_commas = true;
arguments.expect_percentage()?
}
t => return Err(BasicParseError::UnexpectedToken(t))
t => return Err(location.new_basic_unexpected_token_error(t))
});
if uses_commas {
arguments.expect_comma()?;
}
blue = clamp_unit_f32(arguments.expect_percentage()?);
}
t => return Err(BasicParseError::UnexpectedToken(t))
t => return Err(location.new_basic_unexpected_token_error(t))
};
return Ok((red, green, blue, uses_commas));
}
Expand All @@ -503,6 +506,7 @@ fn parse_rgb_components_hsl<'i, 't>(arguments: &mut Parser<'i, 't>) -> Result<(u
let mut uses_commas = false;
// Hue given as an angle
// https://drafts.csswg.org/css-values/#angles
let location = arguments.current_source_location();
let hue_degrees = match *arguments.next()? {
Token::Number { value: v, .. } => v,
Token::Dimension { value: v, ref unit, .. } => {
Expand All @@ -511,24 +515,25 @@ fn parse_rgb_components_hsl<'i, 't>(arguments: &mut Parser<'i, 't>) -> Result<(u
"grad" => v * 360. / 400.,
"rad" => v * 360. / (2. * PI),
"turn" => v * 360.,
_ => return Err(BasicParseError::UnexpectedToken(Token::Ident(unit.clone()))),
_ => return Err(location.new_basic_unexpected_token_error(Token::Ident(unit.clone()))),
}
}
ref t => return Err(BasicParseError::UnexpectedToken(t.clone()))
ref t => return Err(location.new_basic_unexpected_token_error(t.clone()))
};
// Subtract an integer before rounding, to avoid some rounding errors:
let hue_normalized_degrees = hue_degrees - 360. * (hue_degrees / 360.).floor();
let hue = hue_normalized_degrees / 360.;

// Saturation and lightness are clamped to 0% ... 100%
// https://drafts.csswg.org/css-color/#the-hsl-notation
let location = arguments.current_source_location();
let saturation = match arguments.next()?.clone() {
Token::Percentage { unit_value, .. } => unit_value,
Token::Comma => {
uses_commas = true;
arguments.expect_percentage()?
}
t => return Err(BasicParseError::UnexpectedToken(t))
t => return Err(location.new_basic_unexpected_token_error(t))
};
let saturation = saturation.max(0.).min(1.);

Expand Down
5 changes: 3 additions & 2 deletions third_party/rust/cssparser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,14 @@ pub use cssparser_macros::*;
pub use tokenizer::{Token, SourcePosition, SourceLocation};
pub use rules_and_declarations::{parse_important};
pub use rules_and_declarations::{DeclarationParser, DeclarationListParser, parse_one_declaration};
pub use rules_and_declarations::{RuleListParser, parse_one_rule, PreciseParseError};
pub use rules_and_declarations::{RuleListParser, parse_one_rule};
pub use rules_and_declarations::{AtRuleType, QualifiedRuleParser, AtRuleParser};
pub use from_bytes::{stylesheet_encoding, EncodingSupport};
pub use color::{RGBA, Color, parse_color_keyword};
pub use nth::parse_nth;
pub use serializer::{ToCss, CssStringWriter, serialize_identifier, serialize_string, TokenSerializationType};
pub use parser::{Parser, Delimiter, Delimiters, ParserState, ParseError, BasicParseError, ParserInput};
pub use parser::{Parser, Delimiter, Delimiters, ParserState, ParserInput};
pub use parser::{ParseError, ParseErrorKind, BasicParseError, BasicParseErrorKind};
pub use unicode_range::UnicodeRange;
pub use cow_rc_str::CowRcStr;

Expand Down
15 changes: 8 additions & 7 deletions third_party/rust/cssparser/src/nth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn parse_nth<'i, 't>(input: &mut Parser<'i, 't>) -> Result<(i32, i32), Basic
"n-" => Ok(try!(parse_signless_b(input, a, -1))),
_ => match parse_n_dash_digits(&*unit) {
Ok(b) => Ok((a, b)),
Err(()) => Err(BasicParseError::UnexpectedToken(Token::Ident(unit.clone())))
Err(()) => Err(input.new_basic_unexpected_token_error(Token::Ident(unit.clone())))
}
}
}
Expand All @@ -44,7 +44,7 @@ pub fn parse_nth<'i, 't>(input: &mut Parser<'i, 't>) -> Result<(i32, i32), Basic
};
match parse_n_dash_digits(slice) {
Ok(b) => Ok((a, b)),
Err(()) => Err(BasicParseError::UnexpectedToken(Token::Ident(value.clone())))
Err(()) => Err(input.new_basic_unexpected_token_error(Token::Ident(value.clone())))
}
}
}
Expand All @@ -57,13 +57,13 @@ pub fn parse_nth<'i, 't>(input: &mut Parser<'i, 't>) -> Result<(i32, i32), Basic
"n-" => parse_signless_b(input, 1, -1),
_ => match parse_n_dash_digits(&*value) {
Ok(b) => Ok((1, b)),
Err(()) => Err(BasicParseError::UnexpectedToken(Token::Ident(value.clone())))
Err(()) => Err(input.new_basic_unexpected_token_error(Token::Ident(value.clone())))
}
}
}
token => Err(BasicParseError::UnexpectedToken(token)),
token => Err(input.new_basic_unexpected_token_error(token)),
},
token => Err(BasicParseError::UnexpectedToken(token)),
token => Err(input.new_basic_unexpected_token_error(token)),
}
}

Expand All @@ -82,9 +82,10 @@ fn parse_b<'i, 't>(input: &mut Parser<'i, 't>, a: i32) -> Result<(i32, i32), Bas
}

fn parse_signless_b<'i, 't>(input: &mut Parser<'i, 't>, a: i32, b_sign: i32) -> Result<(i32, i32), BasicParseError<'i>> {
match *input.next()? {
// FIXME: remove .clone() when lifetimes are non-lexical.
match input.next()?.clone() {
Token::Number { has_sign: false, int_value: Some(b), .. } => Ok((a, b_sign * b)),
ref token => Err(BasicParseError::UnexpectedToken(token.clone()))
token => Err(input.new_basic_unexpected_token_error(token))
}
}

Expand Down
Loading

0 comments on commit 88c4d2a

Please sign in to comment.