forked from mirrors/gecko-dev
No bug - Revendor rust dependencies
This commit is contained in:
parent
5dcd306c80
commit
13a5120a48
12 changed files with 197 additions and 156 deletions
|
|
@ -1 +1 @@
|
||||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"f1fb4b65964c81bc1240544267ea334f554ca38ae7a74d57066f4d47d2b5d568","Cargo.toml":"50b7d2c3be314d0890f52f5e3b93dc53c58801934ec05e2c7baeab4df3378d52","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"9afe084d70a5d9396674a2624012d6ac749df35f81e322d2d75b042bf208f523","build.rs":"950bcc47a196f07f99f59637c28cc65e02a885130011f90a2b2608248b4724a2","build/match_byte.rs":"89e8b941af74df2c204abf808672d3ff278bdec75abc918c41a843260b924677","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/big-data-url.css":"04a8f6197ea1181123bca48bd1ebd016268e1da40f01b8f21055814e44bf62b8","src/color.rs":"89f69097660fddf48141e221e59ab4cc5c3f53f5407c0f043b032b4796bb2668","src/compact_cow_str.rs":"7f5abdae953febe5a833604e6868d6f60518f1b4ece8de6a8aa8d521f21b8daa","src/css-parsing-tests/An+B.json":"d24559c1dad55d3da9d1fca29383edefdfc6046988435d6388a9bc0f28850257","src/css-parsing-tests/LICENSE":"5f9019a92f4aa8917aadc8e035aa673c2c1bf08d5ca2e535a0564106599f44eb","src/css-parsing-tests/README.rst":"775c5f957dd1d46d3ce954aaad219c821d2b64b4a9fb93c42e9737a11131ca44","src/css-parsing-tests/color3.json":"814179b0a6a9d3a935e635f485f1eaec9880129c5a0d09c0cda4efcea69649fb","src/css-parsing-tests/color3_hsl.json":"61c3b7d8d5ae02f94769d64458e0dd29e4c22c5068e5ea44040d14b88f9616b0","src/css-parsing-tests/color3_keywords.json":"95609bf9fe762c316878a30f371fa375a2e51c21a6fda24fa188a95cd9118f5c","src/css-parsing-tests/component_value_list.json":"516f9495fe089fa669321660bc431d7884839da8fb73e45edcbcd98625cb09dc","src/css-parsing-tests/declaration_list.json":"0b85cc3f19e945f838432acbfb9edb003abea13debc4ea27bcdcef25d117eac5","src/css-parsing-tests/make_color3_hsl.py":"3df7dd908ee719f78fd097ab24622f75edd10fcb67514230c172cbfc842c8ab7","src/css-parsing-tests/make_color3_keywords.py":"66bccab3f1dea18698fcfd854be79b1fd1cd724dd487e25b1f057b522163aad2","src/css-parsing-tests/one_component_value.json":"8798017709002e14cf11e203c9d716f82d308ce6ba0f6e64ee4eea331b8485c6","src/css-parsing-tests/one_declaration.json":"a34c9da56edfff9e2e21615f059e141b0e878e90f794dc8fa58d65b47cd193ed","src/css-parsing-tests/one_rule.json":"88f7b1b6049be88e1e2827673b75fc9261986b216e8ee6bf09621fecbe274e3c","src/css-parsing-tests/rule_list.json":"97c45e80fb83abef149a4016c5625a74f053e7ad70a2ce5a95c02fce1c195686","src/css-parsing-tests/stylesheet.json":"05f1e10fc486bfbda2c059c313a74ff78c0063c0768b99737cab41969c0c87ce","src/css-parsing-tests/stylesheet_bytes.json":"890fd856a596e61f82cf7ed77920ffe95df89209fdb5ee0afe0b26bdfdb80a42","src/css-parsing-tests/urange.json":"62720b143ddf52508baad42921473dd69519aad6c1cd49f37f3f264dc29e1c13","src/from_bytes.rs":"331fe63af2123ae3675b61928a69461b5ac77799fff3ce9978c55cf2c558f4ff","src/lib.rs":"a612f377e1b8a4bf1830c4a1da5b4d52296e965fc59ef2d8f915a49fd8db3a37","src/macros.rs":"adb9773c157890381556ea83d7942dcc676f99eea71abbb6afeffee1e3f28960","src/nth.rs":"7da645b4fcb492dda7e771897482ddb373a114e0ba4b66e1b23d655098e4653a","src/parser.rs":"51d2a55eca22cc8e7324b413016fd5ebe3e79b5e26f0ada2f8efaf981213a132","src/rules_and_declarations.rs":"81e1af778ccc580e42162d2e374dc9cac6a40d1164c55e8996c688caec59700f","src/serializer.rs":"99651bf65670ba478b918240a94362ef2f6e656a24e5e120802ec477321888fb","src/size_of_tests.rs":"fdcc0a12e274cc86b057e607e099b9b3f6af842d0edf9b65e40c0fcdd76fbf17","src/tests.rs":"621bcb4b14afccc6fcda11d91e90dd68d4b5016a532593a6cedc8c8fe39be4fd","src/tokenizer.rs":"f63aa6b443ca710122e54c223925dfd21573ad560fa30dcf531b4619933b3af7","src/unicode_range.rs":"efd937ab97ab6a38e2cfe2e89a44e259c33d111ee73ba4a6c4388b8517607d2d"},"package":"3c711c0c610b1e5fc2bf96e325b2d9f85839a8e71f6279a77c194af5dcafa502"}
|
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"f1fb4b65964c81bc1240544267ea334f554ca38ae7a74d57066f4d47d2b5d568","Cargo.toml":"48c6ae2b34febe2e7287b10e46fd77e6a9c7bb0a7e7f55de551e8113c1abba70","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"9afe084d70a5d9396674a2624012d6ac749df35f81e322d2d75b042bf208f523","build.rs":"950bcc47a196f07f99f59637c28cc65e02a885130011f90a2b2608248b4724a2","build/match_byte.rs":"89e8b941af74df2c204abf808672d3ff278bdec75abc918c41a843260b924677","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/big-data-url.css":"04a8f6197ea1181123bca48bd1ebd016268e1da40f01b8f21055814e44bf62b8","src/color.rs":"4b7ab1cb0271340aee65bfd535dfa19ba9c56222fbf7165807aae7c67e321665","src/compact_cow_str.rs":"7f5abdae953febe5a833604e6868d6f60518f1b4ece8de6a8aa8d521f21b8daa","src/css-parsing-tests/An+B.json":"d24559c1dad55d3da9d1fca29383edefdfc6046988435d6388a9bc0f28850257","src/css-parsing-tests/LICENSE":"5f9019a92f4aa8917aadc8e035aa673c2c1bf08d5ca2e535a0564106599f44eb","src/css-parsing-tests/README.rst":"233ce4fdc3e7306db23787fed0b67b0eb81a4600281ec0f7ff22270f2679ca8e","src/css-parsing-tests/color3.json":"9db91fd04a0424dcbde2b1bf530d4dbaa7502c887978aaaca75a613fbee028e9","src/css-parsing-tests/color3_hsl.json":"61c3b7d8d5ae02f94769d64458e0dd29e4c22c5068e5ea44040d14b88f9616b0","src/css-parsing-tests/color3_keywords.json":"95609bf9fe762c316878a30f371fa375a2e51c21a6fda24fa188a95cd9118f5c","src/css-parsing-tests/component_value_list.json":"516f9495fe089fa669321660bc431d7884839da8fb73e45edcbcd98625cb09dc","src/css-parsing-tests/declaration_list.json":"0b85cc3f19e945f838432acbfb9edb003abea13debc4ea27bcdcef25d117eac5","src/css-parsing-tests/make_color3_hsl.py":"3df7dd908ee719f78fd097ab24622f75edd10fcb67514230c172cbfc842c8ab7","src/css-parsing-tests/make_color3_keywords.py":"66bccab3f1dea18698fcfd854be79b1fd1cd724dd487e25b1f057b522163aad2","src/css-parsing-tests/one_component_value.json":"8798017709002e14cf11e203c9d716f82d308ce6ba0f6e64ee4eea331b8485c6","src/css-parsing-tests/one_declaration.json":"a34c9da56edfff9e2e21615f059e141b0e878e90f794dc8fa58d65b47cd193ed","src/css-parsing-tests/one_rule.json":"88f7b1b6049be88e1e2827673b75fc9261986b216e8ee6bf09621fecbe274e3c","src/css-parsing-tests/rule_list.json":"97c45e80fb83abef149a4016c5625a74f053e7ad70a2ce5a95c02fce1c195686","src/css-parsing-tests/stylesheet.json":"05f1e10fc486bfbda2c059c313a74ff78c0063c0768b99737cab41969c0c87ce","src/css-parsing-tests/stylesheet_bytes.json":"890fd856a596e61f82cf7ed77920ffe95df89209fdb5ee0afe0b26bdfdb80a42","src/css-parsing-tests/urange.json":"62720b143ddf52508baad42921473dd69519aad6c1cd49f37f3f264dc29e1c13","src/from_bytes.rs":"331fe63af2123ae3675b61928a69461b5ac77799fff3ce9978c55cf2c558f4ff","src/lib.rs":"a612f377e1b8a4bf1830c4a1da5b4d52296e965fc59ef2d8f915a49fd8db3a37","src/macros.rs":"adb9773c157890381556ea83d7942dcc676f99eea71abbb6afeffee1e3f28960","src/nth.rs":"5304dc5056164c4c6fe4f9682114b0126a28a912fc7af5b63ee86ef4eb728225","src/parser.rs":"ec2d8a9e47ef0a33ea9f42fc575094ef00255424bfed7d12de9a7807c2eb5628","src/rules_and_declarations.rs":"2bf4e1dcbdedf99e08ca8ee1d83abda4471fd41dfac35a42c18b78408c70fdf8","src/serializer.rs":"c212770541ac73e0e7269576abec580e6a7dd73e01e1663870514ddfca3a15b2","src/size_of_tests.rs":"fdcc0a12e274cc86b057e607e099b9b3f6af842d0edf9b65e40c0fcdd76fbf17","src/tests.rs":"6435cbb95b0865b9bfc3ec36e107dc653fd65b779103fc99a60e2acf691f9c25","src/tokenizer.rs":"f63aa6b443ca710122e54c223925dfd21573ad560fa30dcf531b4619933b3af7","src/unicode_range.rs":"efd937ab97ab6a38e2cfe2e89a44e259c33d111ee73ba4a6c4388b8517607d2d"},"package":"2842253baded8e712e9d8d80ebfe5ea8e95c5b27071e6a6db6080ca1e81c07d1"}
|
||||||
2
third_party/rust/cssparser/Cargo.toml
vendored
2
third_party/rust/cssparser/Cargo.toml
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
|
|
||||||
name = "cssparser"
|
name = "cssparser"
|
||||||
version = "0.16.0"
|
version = "0.16.1"
|
||||||
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]
|
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]
|
||||||
|
|
||||||
description = "Rust implementation of CSS Syntax Level 3"
|
description = "Rust implementation of CSS Syntax Level 3"
|
||||||
|
|
|
||||||
74
third_party/rust/cssparser/src/color.rs
vendored
74
third_party/rust/cssparser/src/color.rs
vendored
|
|
@ -88,7 +88,7 @@ impl<'de> Deserialize<'de> for RGBA {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where D: Deserializer<'de>
|
where D: Deserializer<'de>
|
||||||
{
|
{
|
||||||
let (r, g, b, a) = try!(Deserialize::deserialize(deserializer));
|
let (r, g, b, a) = Deserialize::deserialize(deserializer)?;
|
||||||
Ok(RGBA::new(r, g, b, a))
|
Ok(RGBA::new(r, g, b, a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -118,7 +118,7 @@ impl ToCss for RGBA {
|
||||||
/// A <color> value.
|
/// A <color> value.
|
||||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
/// The 'currentColor' keyword
|
/// The 'currentcolor' keyword
|
||||||
CurrentColor,
|
CurrentColor,
|
||||||
/// Everything else gets converted to RGBA during parsing
|
/// Everything else gets converted to RGBA during parsing
|
||||||
RGBA(RGBA),
|
RGBA(RGBA),
|
||||||
|
|
@ -130,7 +130,7 @@ known_heap_size!(0, Color);
|
||||||
impl ToCss for Color {
|
impl ToCss for Color {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
match *self {
|
match *self {
|
||||||
Color::CurrentColor => dest.write_str("currentColor"),
|
Color::CurrentColor => dest.write_str("currentcolor"),
|
||||||
Color::RGBA(ref rgba) => rgba.to_css(dest),
|
Color::RGBA(ref rgba) => rgba.to_css(dest),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -141,7 +141,7 @@ impl Color {
|
||||||
///
|
///
|
||||||
/// FIXME(#2) Deprecated CSS2 System Colors are not supported yet.
|
/// FIXME(#2) Deprecated CSS2 System Colors are not supported yet.
|
||||||
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Color, BasicParseError<'i>> {
|
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Color, BasicParseError<'i>> {
|
||||||
let token = try!(input.next());
|
let token = input.next()?;
|
||||||
match token {
|
match token {
|
||||||
Token::Hash(ref value) | Token::IDHash(ref value) => {
|
Token::Hash(ref value) | Token::IDHash(ref value) => {
|
||||||
Color::parse_hash(value.as_bytes())
|
Color::parse_hash(value.as_bytes())
|
||||||
|
|
@ -162,26 +162,26 @@ impl Color {
|
||||||
pub fn parse_hash(value: &[u8]) -> Result<Self, ()> {
|
pub fn parse_hash(value: &[u8]) -> Result<Self, ()> {
|
||||||
match value.len() {
|
match value.len() {
|
||||||
8 => Ok(rgba(
|
8 => Ok(rgba(
|
||||||
try!(from_hex(value[0])) * 16 + try!(from_hex(value[1])),
|
from_hex(value[0])? * 16 + from_hex(value[1])?,
|
||||||
try!(from_hex(value[2])) * 16 + try!(from_hex(value[3])),
|
from_hex(value[2])? * 16 + from_hex(value[3])?,
|
||||||
try!(from_hex(value[4])) * 16 + try!(from_hex(value[5])),
|
from_hex(value[4])? * 16 + from_hex(value[5])?,
|
||||||
try!(from_hex(value[6])) * 16 + try!(from_hex(value[7]))),
|
from_hex(value[6])? * 16 + from_hex(value[7])?),
|
||||||
),
|
),
|
||||||
6 => Ok(rgb(
|
6 => Ok(rgb(
|
||||||
try!(from_hex(value[0])) * 16 + try!(from_hex(value[1])),
|
from_hex(value[0])? * 16 + from_hex(value[1])?,
|
||||||
try!(from_hex(value[2])) * 16 + try!(from_hex(value[3])),
|
from_hex(value[2])? * 16 + from_hex(value[3])?,
|
||||||
try!(from_hex(value[4])) * 16 + try!(from_hex(value[5]))),
|
from_hex(value[4])? * 16 + from_hex(value[5])?),
|
||||||
),
|
),
|
||||||
4 => Ok(rgba(
|
4 => Ok(rgba(
|
||||||
try!(from_hex(value[0])) * 17,
|
from_hex(value[0])? * 17,
|
||||||
try!(from_hex(value[1])) * 17,
|
from_hex(value[1])? * 17,
|
||||||
try!(from_hex(value[2])) * 17,
|
from_hex(value[2])? * 17,
|
||||||
try!(from_hex(value[3])) * 17),
|
from_hex(value[3])? * 17),
|
||||||
),
|
),
|
||||||
3 => Ok(rgb(
|
3 => Ok(rgb(
|
||||||
try!(from_hex(value[0])) * 17,
|
from_hex(value[0])? * 17,
|
||||||
try!(from_hex(value[1])) * 17,
|
from_hex(value[1])? * 17,
|
||||||
try!(from_hex(value[2])) * 17),
|
from_hex(value[2])? * 17),
|
||||||
),
|
),
|
||||||
_ => Err(())
|
_ => Err(())
|
||||||
}
|
}
|
||||||
|
|
@ -420,14 +420,14 @@ fn parse_color_function<'i, 't>(name: &str, arguments: &mut Parser<'i, 't>) -> R
|
||||||
|
|
||||||
let alpha = if !arguments.is_exhausted() {
|
let alpha = if !arguments.is_exhausted() {
|
||||||
if uses_commas {
|
if uses_commas {
|
||||||
try!(arguments.expect_comma());
|
arguments.expect_comma()?;
|
||||||
} else {
|
} else {
|
||||||
match try!(arguments.next()) {
|
match arguments.next()? {
|
||||||
Token::Delim('/') => {},
|
Token::Delim('/') => {},
|
||||||
t => return Err(BasicParseError::UnexpectedToken(t)),
|
t => return Err(BasicParseError::UnexpectedToken(t)),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
let token = try!(arguments.next());
|
let token = arguments.next()?;
|
||||||
match token {
|
match token {
|
||||||
Token::Number { value: v, .. } => {
|
Token::Number { value: v, .. } => {
|
||||||
clamp_unit_f32(v)
|
clamp_unit_f32(v)
|
||||||
|
|
@ -443,7 +443,7 @@ fn parse_color_function<'i, 't>(name: &str, arguments: &mut Parser<'i, 't>) -> R
|
||||||
255
|
255
|
||||||
};
|
};
|
||||||
|
|
||||||
try!(arguments.expect_exhausted());
|
arguments.expect_exhausted()?;
|
||||||
Ok(rgba(red, green, blue, alpha))
|
Ok(rgba(red, green, blue, alpha))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -457,36 +457,36 @@ fn parse_rgb_components_rgb<'i, 't>(arguments: &mut Parser<'i, 't>) -> Result<(u
|
||||||
|
|
||||||
// Either integers or percentages, but all the same type.
|
// Either integers or percentages, but all the same type.
|
||||||
// https://drafts.csswg.org/css-color/#rgb-functions
|
// https://drafts.csswg.org/css-color/#rgb-functions
|
||||||
match try!(arguments.next()) {
|
match arguments.next()? {
|
||||||
Token::Number { value: v, .. } => {
|
Token::Number { value: v, .. } => {
|
||||||
red = clamp_floor_256_f32(v);
|
red = clamp_floor_256_f32(v);
|
||||||
green = clamp_floor_256_f32(match try!(arguments.next()) {
|
green = clamp_floor_256_f32(match arguments.next()? {
|
||||||
Token::Number { value: v, .. } => v,
|
Token::Number { value: v, .. } => v,
|
||||||
Token::Comma => {
|
Token::Comma => {
|
||||||
uses_commas = true;
|
uses_commas = true;
|
||||||
try!(arguments.expect_number())
|
arguments.expect_number()?
|
||||||
}
|
}
|
||||||
t => return Err(BasicParseError::UnexpectedToken(t))
|
t => return Err(BasicParseError::UnexpectedToken(t))
|
||||||
});
|
});
|
||||||
if uses_commas {
|
if uses_commas {
|
||||||
try!(arguments.expect_comma());
|
arguments.expect_comma()?;
|
||||||
}
|
}
|
||||||
blue = clamp_floor_256_f32(try!(arguments.expect_number()));
|
blue = clamp_floor_256_f32(arguments.expect_number()?);
|
||||||
}
|
}
|
||||||
Token::Percentage { unit_value, .. } => {
|
Token::Percentage { unit_value, .. } => {
|
||||||
red = clamp_unit_f32(unit_value);
|
red = clamp_unit_f32(unit_value);
|
||||||
green = clamp_unit_f32(match try!(arguments.next()) {
|
green = clamp_unit_f32(match arguments.next()? {
|
||||||
Token::Percentage { unit_value, .. } => unit_value,
|
Token::Percentage { unit_value, .. } => unit_value,
|
||||||
Token::Comma => {
|
Token::Comma => {
|
||||||
uses_commas = true;
|
uses_commas = true;
|
||||||
try!(arguments.expect_percentage())
|
arguments.expect_percentage()?
|
||||||
}
|
}
|
||||||
t => return Err(BasicParseError::UnexpectedToken(t))
|
t => return Err(BasicParseError::UnexpectedToken(t))
|
||||||
});
|
});
|
||||||
if uses_commas {
|
if uses_commas {
|
||||||
try!(arguments.expect_comma());
|
arguments.expect_comma()?;
|
||||||
}
|
}
|
||||||
blue = clamp_unit_f32(try!(arguments.expect_percentage()));
|
blue = clamp_unit_f32(arguments.expect_percentage()?);
|
||||||
}
|
}
|
||||||
t => return Err(BasicParseError::UnexpectedToken(t))
|
t => return Err(BasicParseError::UnexpectedToken(t))
|
||||||
};
|
};
|
||||||
|
|
@ -498,7 +498,7 @@ fn parse_rgb_components_hsl<'i, 't>(arguments: &mut Parser<'i, 't>) -> Result<(u
|
||||||
let mut uses_commas = false;
|
let mut uses_commas = false;
|
||||||
// Hue given as an angle
|
// Hue given as an angle
|
||||||
// https://drafts.csswg.org/css-values/#angles
|
// https://drafts.csswg.org/css-values/#angles
|
||||||
let token = try!(arguments.next());
|
let token = arguments.next()?;
|
||||||
let hue_degrees = match token {
|
let hue_degrees = match token {
|
||||||
Token::Number { value: v, .. } => Ok(v),
|
Token::Number { value: v, .. } => Ok(v),
|
||||||
Token::Dimension { value: v, ref unit, .. } => {
|
Token::Dimension { value: v, ref unit, .. } => {
|
||||||
|
|
@ -512,28 +512,28 @@ fn parse_rgb_components_hsl<'i, 't>(arguments: &mut Parser<'i, 't>) -> Result<(u
|
||||||
}
|
}
|
||||||
t => return Err(BasicParseError::UnexpectedToken(t))
|
t => return Err(BasicParseError::UnexpectedToken(t))
|
||||||
};
|
};
|
||||||
let hue_degrees = try!(hue_degrees.map_err(|()| BasicParseError::UnexpectedToken(token)));
|
let hue_degrees = hue_degrees.map_err(|()| BasicParseError::UnexpectedToken(token))?;
|
||||||
// Subtract an integer before rounding, to avoid some rounding errors:
|
// Subtract an integer before rounding, to avoid some rounding errors:
|
||||||
let hue_normalized_degrees = hue_degrees - 360. * (hue_degrees / 360.).floor();
|
let hue_normalized_degrees = hue_degrees - 360. * (hue_degrees / 360.).floor();
|
||||||
let hue = hue_normalized_degrees / 360.;
|
let hue = hue_normalized_degrees / 360.;
|
||||||
|
|
||||||
// Saturation and lightness are clamped to 0% ... 100%
|
// Saturation and lightness are clamped to 0% ... 100%
|
||||||
// https://drafts.csswg.org/css-color/#the-hsl-notation
|
// https://drafts.csswg.org/css-color/#the-hsl-notation
|
||||||
let saturation = match try!(arguments.next()) {
|
let saturation = match arguments.next()? {
|
||||||
Token::Percentage { unit_value, .. } => unit_value,
|
Token::Percentage { unit_value, .. } => unit_value,
|
||||||
Token::Comma => {
|
Token::Comma => {
|
||||||
uses_commas = true;
|
uses_commas = true;
|
||||||
try!(arguments.expect_percentage())
|
arguments.expect_percentage()?
|
||||||
}
|
}
|
||||||
t => return Err(BasicParseError::UnexpectedToken(t))
|
t => return Err(BasicParseError::UnexpectedToken(t))
|
||||||
};
|
};
|
||||||
let saturation = saturation.max(0.).min(1.);
|
let saturation = saturation.max(0.).min(1.);
|
||||||
|
|
||||||
if uses_commas {
|
if uses_commas {
|
||||||
try!(arguments.expect_comma());
|
arguments.expect_comma()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let lightness = try!(arguments.expect_percentage());
|
let lightness = arguments.expect_percentage()?;
|
||||||
let lightness = lightness.max(0.).min(1.);
|
let lightness = lightness.max(0.).min(1.);
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-color/#hsl-color
|
// https://drafts.csswg.org/css-color/#hsl-color
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ associated with the expected result.
|
||||||
the output as one of:
|
the output as one of:
|
||||||
|
|
||||||
* null if the input is not a valid color in CSS syntax
|
* null if the input is not a valid color in CSS syntax
|
||||||
* The string "currentColor" for the currentColor keyword
|
* The string "currentcolor" for the currentcolor keyword
|
||||||
* An array of length 4 for every other values:
|
* An array of length 4 for every other values:
|
||||||
four (floating point) numbers for the Red, Green, Blue and Alpha channel.
|
four (floating point) numbers for the Red, Green, Blue and Alpha channel.
|
||||||
Each value is between 0 and 1.
|
Each value is between 0 and 1.
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,9 @@
|
||||||
"transparent", [0, 0, 0, 0],
|
"transparent", [0, 0, 0, 0],
|
||||||
" transparent\n", [0, 0, 0, 0],
|
" transparent\n", [0, 0, 0, 0],
|
||||||
"TransParent", [0, 0, 0, 0],
|
"TransParent", [0, 0, 0, 0],
|
||||||
"currentColor", "currentColor",
|
"currentcolor", "currentcolor",
|
||||||
"CURRENTcolor", "currentColor",
|
"currentColor", "currentcolor",
|
||||||
|
"CURRENTcolor", "currentcolor",
|
||||||
"current-Color", null,
|
"current-Color", null,
|
||||||
|
|
||||||
"black", [0, 0, 0, 255],
|
"black", [0, 0, 0, 255],
|
||||||
|
|
|
||||||
10
third_party/rust/cssparser/src/nth.rs
vendored
10
third_party/rust/cssparser/src/nth.rs
vendored
|
|
@ -12,7 +12,7 @@ use super::{Token, Parser, BasicParseError};
|
||||||
/// in which case the caller needs to check if the arguments’ parser is exhausted.
|
/// in which case the caller needs to check if the arguments’ parser is exhausted.
|
||||||
/// Return `Ok((A, B))`, or `Err(())` for a syntax error.
|
/// Return `Ok((A, B))`, or `Err(())` for a syntax error.
|
||||||
pub fn parse_nth<'i, 't>(input: &mut Parser<'i, 't>) -> Result<(i32, i32), BasicParseError<'i>> {
|
pub fn parse_nth<'i, 't>(input: &mut Parser<'i, 't>) -> Result<(i32, i32), BasicParseError<'i>> {
|
||||||
let token = try!(input.next());
|
let token = input.next()?;
|
||||||
match token {
|
match token {
|
||||||
Token::Number { int_value: Some(b), .. } => {
|
Token::Number { int_value: Some(b), .. } => {
|
||||||
Ok((0, b))
|
Ok((0, b))
|
||||||
|
|
@ -42,7 +42,7 @@ pub fn parse_nth<'i, 't>(input: &mut Parser<'i, 't>) -> Result<(i32, i32), Basic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Token::Delim('+') => match try!(input.next_including_whitespace()) {
|
Token::Delim('+') => match input.next_including_whitespace()? {
|
||||||
Token::Ident(value) => {
|
Token::Ident(value) => {
|
||||||
match_ignore_ascii_case! { &value,
|
match_ignore_ascii_case! { &value,
|
||||||
"n" => Ok(try!(parse_b(input, 1))),
|
"n" => Ok(try!(parse_b(input, 1))),
|
||||||
|
|
@ -61,8 +61,8 @@ fn parse_b<'i, 't>(input: &mut Parser<'i, 't>, a: i32) -> Result<(i32, i32), Bas
|
||||||
let start_position = input.position();
|
let start_position = input.position();
|
||||||
let token = input.next();
|
let token = input.next();
|
||||||
match token {
|
match token {
|
||||||
Ok(Token::Delim('+')) => Ok(try!(parse_signless_b(input, a, 1))),
|
Ok(Token::Delim('+')) => Ok(parse_signless_b(input, a, 1)?),
|
||||||
Ok(Token::Delim('-')) => Ok(try!(parse_signless_b(input, a, -1))),
|
Ok(Token::Delim('-')) => Ok(parse_signless_b(input, a, -1)?),
|
||||||
Ok(Token::Number { has_sign: true, int_value: Some(b), .. }) => Ok((a, b)),
|
Ok(Token::Number { has_sign: true, int_value: Some(b), .. }) => Ok((a, b)),
|
||||||
_ => {
|
_ => {
|
||||||
input.reset(start_position);
|
input.reset(start_position);
|
||||||
|
|
@ -72,7 +72,7 @@ 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>> {
|
fn parse_signless_b<'i, 't>(input: &mut Parser<'i, 't>, a: i32, b_sign: i32) -> Result<(i32, i32), BasicParseError<'i>> {
|
||||||
let token = try!(input.next());
|
let token = input.next()?;
|
||||||
match token {
|
match token {
|
||||||
Token::Number { has_sign: false, int_value: Some(b), .. } => Ok((a, b_sign * b)),
|
Token::Number { has_sign: false, int_value: Some(b), .. } => Ok((a, b_sign * b)),
|
||||||
_ => Err(())
|
_ => Err(())
|
||||||
|
|
|
||||||
51
third_party/rust/cssparser/src/parser.rs
vendored
51
third_party/rust/cssparser/src/parser.rs
vendored
|
|
@ -343,7 +343,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
if self.stop_before.contains(Delimiters::from_byte(byte)) {
|
if self.stop_before.contains(Delimiters::from_byte(byte)) {
|
||||||
return Err(BasicParseError::EndOfInput)
|
return Err(BasicParseError::EndOfInput)
|
||||||
}
|
}
|
||||||
let token = try!((self.tokenizer.0).next().map_err(|()| BasicParseError::EndOfInput));
|
let token = (self.tokenizer.0).next().map_err(|()| BasicParseError::EndOfInput)?;
|
||||||
if let Some(block_type) = BlockType::opening(&token) {
|
if let Some(block_type) = BlockType::opening(&token) {
|
||||||
self.at_start_of = Some(block_type);
|
self.at_start_of = Some(block_type);
|
||||||
}
|
}
|
||||||
|
|
@ -358,7 +358,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
pub fn parse_entirely<F, T, E>(&mut self, parse: F) -> Result<T, ParseError<'i, E>>
|
pub fn parse_entirely<F, T, E>(&mut self, parse: F) -> Result<T, ParseError<'i, E>>
|
||||||
where F: FnOnce(&mut Parser<'i, 't>) -> Result<T, ParseError<'i, E>> {
|
where F: FnOnce(&mut Parser<'i, 't>) -> Result<T, ParseError<'i, E>> {
|
||||||
let result = parse(self);
|
let result = parse(self);
|
||||||
try!(self.expect_exhausted());
|
self.expect_exhausted()?;
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -377,7 +377,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
where F: for<'tt> FnMut(&mut Parser<'i, 'tt>) -> Result<T, ParseError<'i, E>> {
|
where F: for<'tt> FnMut(&mut Parser<'i, 'tt>) -> Result<T, ParseError<'i, E>> {
|
||||||
let mut values = vec![];
|
let mut values = vec![];
|
||||||
loop {
|
loop {
|
||||||
values.push(try!(self.parse_until_before(Delimiter::Comma, &mut parse_one)));
|
values.push(self.parse_until_before(Delimiter::Comma, &mut parse_one)?);
|
||||||
match self.next() {
|
match self.next() {
|
||||||
Err(_) => return Ok(values),
|
Err(_) => return Ok(values),
|
||||||
Ok(Token::Comma) => continue,
|
Ok(Token::Comma) => continue,
|
||||||
|
|
@ -403,11 +403,12 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
parse_nested_block(self, parse)
|
parse_nested_block(self, parse)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Limit parsing to until a given delimiter. (E.g. a semicolon for a property value.)
|
/// Limit parsing to until a given delimiter or the end of the input. (E.g.
|
||||||
|
/// a semicolon for a property value.)
|
||||||
///
|
///
|
||||||
/// The given closure is called with a "delimited" parser
|
/// The given closure is called with a "delimited" parser
|
||||||
/// that stops before the first character at this block/function nesting level
|
/// that stops before the first character at this block/function nesting level
|
||||||
/// that matches the given set of delimiters.
|
/// that matches the given set of delimiters, or at the end of the input.
|
||||||
///
|
///
|
||||||
/// The result is overridden to `Err(())` if the closure leaves some input before that point.
|
/// The result is overridden to `Err(())` if the closure leaves some input before that point.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
@ -432,7 +433,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// Parse a <whitespace-token> and return its value.
|
/// Parse a <whitespace-token> and return its value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_whitespace(&mut self) -> Result<&'i str, BasicParseError<'i>> {
|
pub fn expect_whitespace(&mut self) -> Result<&'i str, BasicParseError<'i>> {
|
||||||
match try!(self.next_including_whitespace()) {
|
match self.next_including_whitespace()? {
|
||||||
Token::WhiteSpace(value) => Ok(value),
|
Token::WhiteSpace(value) => Ok(value),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -441,7 +442,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// Parse a <ident-token> and return the unescaped value.
|
/// Parse a <ident-token> and return the unescaped value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_ident(&mut self) -> Result<CompactCowStr<'i>, BasicParseError<'i>> {
|
pub fn expect_ident(&mut self) -> Result<CompactCowStr<'i>, BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::Ident(value) => Ok(value),
|
Token::Ident(value) => Ok(value),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -450,7 +451,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// Parse a <ident-token> whose unescaped value is an ASCII-insensitive match for the given value.
|
/// Parse a <ident-token> whose unescaped value is an ASCII-insensitive match for the given value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_ident_matching(&mut self, expected_value: &str) -> Result<(), BasicParseError<'i>> {
|
pub fn expect_ident_matching(&mut self, expected_value: &str) -> Result<(), BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::Ident(ref value) if value.eq_ignore_ascii_case(expected_value) => Ok(()),
|
Token::Ident(ref value) if value.eq_ignore_ascii_case(expected_value) => Ok(()),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -459,7 +460,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// Parse a <string-token> and return the unescaped value.
|
/// Parse a <string-token> and return the unescaped value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_string(&mut self) -> Result<CompactCowStr<'i>, BasicParseError<'i>> {
|
pub fn expect_string(&mut self) -> Result<CompactCowStr<'i>, BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::QuotedString(value) => Ok(value),
|
Token::QuotedString(value) => Ok(value),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -468,7 +469,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// Parse either a <ident-token> or a <string-token>, and return the unescaped value.
|
/// Parse either a <ident-token> or a <string-token>, and return the unescaped value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_ident_or_string(&mut self) -> Result<CompactCowStr<'i>, BasicParseError<'i>> {
|
pub fn expect_ident_or_string(&mut self) -> Result<CompactCowStr<'i>, BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::Ident(value) => Ok(value),
|
Token::Ident(value) => Ok(value),
|
||||||
Token::QuotedString(value) => Ok(value),
|
Token::QuotedString(value) => Ok(value),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
|
|
@ -478,7 +479,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// Parse a <url-token> and return the unescaped value.
|
/// Parse a <url-token> and return the unescaped value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_url(&mut self) -> Result<CompactCowStr<'i>, BasicParseError<'i>> {
|
pub fn expect_url(&mut self) -> Result<CompactCowStr<'i>, BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::UnquotedUrl(value) => Ok(value),
|
Token::UnquotedUrl(value) => Ok(value),
|
||||||
Token::Function(ref name) if name.eq_ignore_ascii_case("url") => {
|
Token::Function(ref name) if name.eq_ignore_ascii_case("url") => {
|
||||||
self.parse_nested_block(|input| input.expect_string()
|
self.parse_nested_block(|input| input.expect_string()
|
||||||
|
|
@ -492,7 +493,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// Parse either a <url-token> or a <string-token>, and return the unescaped value.
|
/// Parse either a <url-token> or a <string-token>, and return the unescaped value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_url_or_string(&mut self) -> Result<CompactCowStr<'i>, BasicParseError<'i>> {
|
pub fn expect_url_or_string(&mut self) -> Result<CompactCowStr<'i>, BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::UnquotedUrl(value) => Ok(value),
|
Token::UnquotedUrl(value) => Ok(value),
|
||||||
Token::QuotedString(value) => Ok(value),
|
Token::QuotedString(value) => Ok(value),
|
||||||
Token::Function(ref name) if name.eq_ignore_ascii_case("url") => {
|
Token::Function(ref name) if name.eq_ignore_ascii_case("url") => {
|
||||||
|
|
@ -506,7 +507,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// Parse a <number-token> and return the integer value.
|
/// Parse a <number-token> and return the integer value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_number(&mut self) -> Result<f32, BasicParseError<'i>> {
|
pub fn expect_number(&mut self) -> Result<f32, BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::Number { value, .. } => Ok(value),
|
Token::Number { value, .. } => Ok(value),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -515,7 +516,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// Parse a <number-token> that does not have a fractional part, and return the integer value.
|
/// Parse a <number-token> that does not have a fractional part, and return the integer value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_integer(&mut self) -> Result<i32, BasicParseError<'i>> {
|
pub fn expect_integer(&mut self) -> Result<i32, BasicParseError<'i>> {
|
||||||
let token = try!(self.next());
|
let token = self.next()?;
|
||||||
match token {
|
match token {
|
||||||
Token::Number { int_value: Some(int_value), .. } => {
|
Token::Number { int_value: Some(int_value), .. } => {
|
||||||
Ok(int_value)
|
Ok(int_value)
|
||||||
|
|
@ -528,7 +529,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// `0%` and `100%` map to `0.0` and `1.0` (not `100.0`), respectively.
|
/// `0%` and `100%` map to `0.0` and `1.0` (not `100.0`), respectively.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_percentage(&mut self) -> Result<f32, BasicParseError<'i>> {
|
pub fn expect_percentage(&mut self) -> Result<f32, BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::Percentage { unit_value, .. } => Ok(unit_value),
|
Token::Percentage { unit_value, .. } => Ok(unit_value),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -537,7 +538,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// Parse a `:` <colon-token>.
|
/// Parse a `:` <colon-token>.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_colon(&mut self) -> Result<(), BasicParseError<'i>> {
|
pub fn expect_colon(&mut self) -> Result<(), BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::Colon => Ok(()),
|
Token::Colon => Ok(()),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -546,7 +547,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// Parse a `;` <semicolon-token>.
|
/// Parse a `;` <semicolon-token>.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_semicolon(&mut self) -> Result<(), BasicParseError<'i>> {
|
pub fn expect_semicolon(&mut self) -> Result<(), BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::Semicolon => Ok(()),
|
Token::Semicolon => Ok(()),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -555,7 +556,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// Parse a `,` <comma-token>.
|
/// Parse a `,` <comma-token>.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_comma(&mut self) -> Result<(), BasicParseError<'i>> {
|
pub fn expect_comma(&mut self) -> Result<(), BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::Comma => Ok(()),
|
Token::Comma => Ok(()),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -564,7 +565,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// Parse a <delim-token> with the given value.
|
/// Parse a <delim-token> with the given value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_delim(&mut self, expected_value: char) -> Result<(), BasicParseError<'i>> {
|
pub fn expect_delim(&mut self, expected_value: char) -> Result<(), BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::Delim(value) if value == expected_value => Ok(()),
|
Token::Delim(value) if value == expected_value => Ok(()),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -575,7 +576,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// If the result is `Ok`, you can then call the `Parser::parse_nested_block` method.
|
/// If the result is `Ok`, you can then call the `Parser::parse_nested_block` method.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_curly_bracket_block(&mut self) -> Result<(), BasicParseError<'i>> {
|
pub fn expect_curly_bracket_block(&mut self) -> Result<(), BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::CurlyBracketBlock => Ok(()),
|
Token::CurlyBracketBlock => Ok(()),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -586,7 +587,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// If the result is `Ok`, you can then call the `Parser::parse_nested_block` method.
|
/// If the result is `Ok`, you can then call the `Parser::parse_nested_block` method.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_square_bracket_block(&mut self) -> Result<(), BasicParseError<'i>> {
|
pub fn expect_square_bracket_block(&mut self) -> Result<(), BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::SquareBracketBlock => Ok(()),
|
Token::SquareBracketBlock => Ok(()),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -597,7 +598,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// If the result is `Ok`, you can then call the `Parser::parse_nested_block` method.
|
/// If the result is `Ok`, you can then call the `Parser::parse_nested_block` method.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_parenthesis_block(&mut self) -> Result<(), BasicParseError<'i>> {
|
pub fn expect_parenthesis_block(&mut self) -> Result<(), BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::ParenthesisBlock => Ok(()),
|
Token::ParenthesisBlock => Ok(()),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -608,7 +609,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// If the result is `Ok`, you can then call the `Parser::parse_nested_block` method.
|
/// If the result is `Ok`, you can then call the `Parser::parse_nested_block` method.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_function(&mut self) -> Result<CompactCowStr<'i>, BasicParseError<'i>> {
|
pub fn expect_function(&mut self) -> Result<CompactCowStr<'i>, BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::Function(name) => Ok(name),
|
Token::Function(name) => Ok(name),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -619,7 +620,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
/// If the result is `Ok`, you can then call the `Parser::parse_nested_block` method.
|
/// If the result is `Ok`, you can then call the `Parser::parse_nested_block` method.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expect_function_matching(&mut self, expected_name: &str) -> Result<(), BasicParseError<'i>> {
|
pub fn expect_function_matching(&mut self, expected_name: &str) -> Result<(), BasicParseError<'i>> {
|
||||||
match try!(self.next()) {
|
match self.next()? {
|
||||||
Token::Function(ref name) if name.eq_ignore_ascii_case(expected_name) => Ok(()),
|
Token::Function(ref name) if name.eq_ignore_ascii_case(expected_name) => Ok(()),
|
||||||
t => Err(BasicParseError::UnexpectedToken(t))
|
t => Err(BasicParseError::UnexpectedToken(t))
|
||||||
}
|
}
|
||||||
|
|
@ -636,7 +637,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
|
||||||
Ok(Token::SquareBracketBlock) | Ok(Token::CurlyBracketBlock) => {
|
Ok(Token::SquareBracketBlock) | Ok(Token::CurlyBracketBlock) => {
|
||||||
let result = self.parse_nested_block(|input| input.expect_no_error_token()
|
let result = self.parse_nested_block(|input| input.expect_no_error_token()
|
||||||
.map_err(|e| ParseError::Basic(e)));
|
.map_err(|e| ParseError::Basic(e)));
|
||||||
try!(result.map_err(ParseError::<()>::basic))
|
result.map_err(ParseError::<()>::basic)?
|
||||||
}
|
}
|
||||||
Ok(token) => {
|
Ok(token) => {
|
||||||
if token.is_parse_error() {
|
if token.is_parse_error() {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use super::{Token, Parser, Delimiter, SourcePosition, ParseError, BasicParseErro
|
||||||
/// Typical usage is `input.try(parse_important).is_ok()`
|
/// Typical usage is `input.try(parse_important).is_ok()`
|
||||||
/// at the end of a `DeclarationParser::parse_value` implementation.
|
/// at the end of a `DeclarationParser::parse_value` implementation.
|
||||||
pub fn parse_important<'i, 't>(input: &mut Parser<'i, 't>) -> Result<(), BasicParseError<'i>> {
|
pub fn parse_important<'i, 't>(input: &mut Parser<'i, 't>) -> Result<(), BasicParseError<'i>> {
|
||||||
try!(input.expect_delim('!'));
|
input.expect_delim('!')?;
|
||||||
input.expect_ident_matching("important")
|
input.expect_ident_matching("important")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,7 +246,7 @@ where P: DeclarationParser<'i, Declaration = I, Error = E> +
|
||||||
let parser = &mut self.parser;
|
let parser = &mut self.parser;
|
||||||
// FIXME: https://github.com/rust-lang/rust/issues/42508
|
// FIXME: https://github.com/rust-lang/rust/issues/42508
|
||||||
parse_until_after::<'i, 't, _, _, _>(self.input, Delimiter::Semicolon, |input| {
|
parse_until_after::<'i, 't, _, _, _>(self.input, Delimiter::Semicolon, |input| {
|
||||||
try!(input.expect_colon());
|
input.expect_colon()?;
|
||||||
parser.parse_value(name, input)
|
parser.parse_value(name, input)
|
||||||
})
|
})
|
||||||
}.map_err(|e| PreciseParseError {
|
}.map_err(|e| PreciseParseError {
|
||||||
|
|
@ -370,8 +370,8 @@ pub fn parse_one_declaration<'i, 't, P, E>(input: &mut Parser<'i, 't>, parser: &
|
||||||
where P: DeclarationParser<'i, Error = E> {
|
where P: DeclarationParser<'i, Error = E> {
|
||||||
let start_position = input.position();
|
let start_position = input.position();
|
||||||
input.parse_entirely(|input| {
|
input.parse_entirely(|input| {
|
||||||
let name = try!(input.expect_ident());
|
let name = input.expect_ident()?;
|
||||||
try!(input.expect_colon());
|
input.expect_colon()?;
|
||||||
parser.parse_value(name, input)
|
parser.parse_value(name, input)
|
||||||
}).map_err(|e| PreciseParseError {
|
}).map_err(|e| PreciseParseError {
|
||||||
error: e,
|
error: e,
|
||||||
|
|
@ -388,7 +388,7 @@ where P: QualifiedRuleParser<'i, QualifiedRule = R, Error = E> +
|
||||||
input.parse_entirely(|input| {
|
input.parse_entirely(|input| {
|
||||||
loop {
|
loop {
|
||||||
let start_position = input.position();
|
let start_position = input.position();
|
||||||
match try!(input.next_including_whitespace_and_comments()) {
|
match input.next_including_whitespace_and_comments()? {
|
||||||
Token::WhiteSpace(_) | Token::Comment(_) => {}
|
Token::WhiteSpace(_) | Token::Comment(_) => {}
|
||||||
Token::AtKeyword(name) => {
|
Token::AtKeyword(name) => {
|
||||||
return parse_at_rule(start_position, name, input, parser).map_err(|e| e.error)
|
return parse_at_rule(start_position, name, input, parser).map_err(|e| e.error)
|
||||||
|
|
@ -486,10 +486,10 @@ fn parse_qualified_rule<'i, 't, P, E>(input: &mut Parser<'i, 't>, parser: &mut P
|
||||||
let prelude = parse_until_before::<'i, 't, _, _, _>(input, Delimiter::CurlyBracketBlock, |input| {
|
let prelude = parse_until_before::<'i, 't, _, _, _>(input, Delimiter::CurlyBracketBlock, |input| {
|
||||||
parser.parse_prelude(input)
|
parser.parse_prelude(input)
|
||||||
});
|
});
|
||||||
match try!(input.next()) {
|
match input.next()? {
|
||||||
Token::CurlyBracketBlock => {
|
Token::CurlyBracketBlock => {
|
||||||
// Do this here so that we consume the `{` even if the prelude is `Err`.
|
// Do this here so that we consume the `{` even if the prelude is `Err`.
|
||||||
let prelude = try!(prelude);
|
let prelude = prelude?;
|
||||||
// FIXME: https://github.com/rust-lang/rust/issues/42508
|
// FIXME: https://github.com/rust-lang/rust/issues/42508
|
||||||
parse_nested_block::<'i, 't, _, _, _>(input, move |input| parser.parse_block(prelude, input))
|
parse_nested_block::<'i, 't, _, _, _>(input, move |input| parser.parse_block(prelude, input))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
124
third_party/rust/cssparser/src/serializer.rs
vendored
124
third_party/rust/cssparser/src/serializer.rs
vendored
|
|
@ -47,18 +47,18 @@ fn write_numeric<W>(value: f32, int_value: Option<i32>, has_sign: bool, dest: &m
|
||||||
-> fmt::Result where W: fmt::Write {
|
-> fmt::Result where W: fmt::Write {
|
||||||
// `value.value >= 0` is true for negative 0.
|
// `value.value >= 0` is true for negative 0.
|
||||||
if has_sign && value.is_sign_positive() {
|
if has_sign && value.is_sign_positive() {
|
||||||
try!(dest.write_str("+"));
|
dest.write_str("+")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if value == 0.0 && value.is_sign_negative() {
|
if value == 0.0 && value.is_sign_negative() {
|
||||||
// Negative zero. Work around #20596.
|
// Negative zero. Work around #20596.
|
||||||
try!(dest.write_str("-0"))
|
dest.write_str("-0")?
|
||||||
} else {
|
} else {
|
||||||
try!(write!(dest, "{}", value))
|
write!(dest, "{}", value)?
|
||||||
}
|
}
|
||||||
|
|
||||||
if int_value.is_none() && value.fract() == 0. {
|
if int_value.is_none() && value.fract() == 0. {
|
||||||
try!(dest.write_str(".0"));
|
dest.write_str(".0")?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -67,73 +67,73 @@ fn write_numeric<W>(value: f32, int_value: Option<i32>, has_sign: bool, dest: &m
|
||||||
impl<'a> ToCss for Token<'a> {
|
impl<'a> ToCss for Token<'a> {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
match *self {
|
match *self {
|
||||||
Token::Ident(ref value) => try!(serialize_identifier(&**value, dest)),
|
Token::Ident(ref value) => serialize_identifier(&**value, dest)?,
|
||||||
Token::AtKeyword(ref value) => {
|
Token::AtKeyword(ref value) => {
|
||||||
try!(dest.write_str("@"));
|
dest.write_str("@")?;
|
||||||
try!(serialize_identifier(&**value, dest));
|
serialize_identifier(&**value, dest)?;
|
||||||
},
|
},
|
||||||
Token::Hash(ref value) => {
|
Token::Hash(ref value) => {
|
||||||
try!(dest.write_str("#"));
|
dest.write_str("#")?;
|
||||||
try!(serialize_name(value, dest));
|
serialize_name(value, dest)?;
|
||||||
},
|
},
|
||||||
Token::IDHash(ref value) => {
|
Token::IDHash(ref value) => {
|
||||||
try!(dest.write_str("#"));
|
dest.write_str("#")?;
|
||||||
try!(serialize_identifier(&**value, dest));
|
serialize_identifier(&**value, dest)?;
|
||||||
}
|
}
|
||||||
Token::QuotedString(ref value) => try!(serialize_string(&**value, dest)),
|
Token::QuotedString(ref value) => serialize_string(&**value, dest)?,
|
||||||
Token::UnquotedUrl(ref value) => {
|
Token::UnquotedUrl(ref value) => {
|
||||||
try!(dest.write_str("url("));
|
dest.write_str("url(")?;
|
||||||
try!(serialize_unquoted_url(&**value, dest));
|
serialize_unquoted_url(&**value, dest)?;
|
||||||
try!(dest.write_str(")"));
|
dest.write_str(")")?;
|
||||||
},
|
},
|
||||||
Token::Delim(value) => try!(write!(dest, "{}", value)),
|
Token::Delim(value) => write!(dest, "{}", value)?,
|
||||||
|
|
||||||
Token::Number { value, int_value, has_sign } => {
|
Token::Number { value, int_value, has_sign } => {
|
||||||
try!(write_numeric(value, int_value, has_sign, dest))
|
write_numeric(value, int_value, has_sign, dest)?
|
||||||
}
|
}
|
||||||
Token::Percentage { unit_value, int_value, has_sign } => {
|
Token::Percentage { unit_value, int_value, has_sign } => {
|
||||||
try!(write_numeric(unit_value * 100., int_value, has_sign, dest));
|
write_numeric(unit_value * 100., int_value, has_sign, dest)?;
|
||||||
try!(dest.write_str("%"));
|
dest.write_str("%")?;
|
||||||
},
|
},
|
||||||
Token::Dimension { value, int_value, has_sign, ref unit } => {
|
Token::Dimension { value, int_value, has_sign, ref unit } => {
|
||||||
try!(write_numeric(value, int_value, has_sign, dest));
|
write_numeric(value, int_value, has_sign, dest)?;
|
||||||
// Disambiguate with scientific notation.
|
// Disambiguate with scientific notation.
|
||||||
let unit = &**unit;
|
let unit = &**unit;
|
||||||
if unit == "e" || unit == "E" || unit.starts_with("e-") || unit.starts_with("E-") {
|
if unit == "e" || unit == "E" || unit.starts_with("e-") || unit.starts_with("E-") {
|
||||||
try!(dest.write_str("\\65 "));
|
dest.write_str("\\65 ")?;
|
||||||
try!(serialize_name(&unit[1..], dest));
|
serialize_name(&unit[1..], dest)?;
|
||||||
} else {
|
} else {
|
||||||
try!(serialize_identifier(unit, dest));
|
serialize_identifier(unit, dest)?;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
Token::WhiteSpace(content) => try!(dest.write_str(content)),
|
Token::WhiteSpace(content) => dest.write_str(content)?,
|
||||||
Token::Comment(content) => try!(write!(dest, "/*{}*/", content)),
|
Token::Comment(content) => write!(dest, "/*{}*/", content)?,
|
||||||
Token::Colon => try!(dest.write_str(":")),
|
Token::Colon => dest.write_str(":")?,
|
||||||
Token::Semicolon => try!(dest.write_str(";")),
|
Token::Semicolon => dest.write_str(";")?,
|
||||||
Token::Comma => try!(dest.write_str(",")),
|
Token::Comma => dest.write_str(",")?,
|
||||||
Token::IncludeMatch => try!(dest.write_str("~=")),
|
Token::IncludeMatch => dest.write_str("~=")?,
|
||||||
Token::DashMatch => try!(dest.write_str("|=")),
|
Token::DashMatch => dest.write_str("|=")?,
|
||||||
Token::PrefixMatch => try!(dest.write_str("^=")),
|
Token::PrefixMatch => dest.write_str("^=")?,
|
||||||
Token::SuffixMatch => try!(dest.write_str("$=")),
|
Token::SuffixMatch => dest.write_str("$=")?,
|
||||||
Token::SubstringMatch => try!(dest.write_str("*=")),
|
Token::SubstringMatch => dest.write_str("*=")?,
|
||||||
Token::Column => try!(dest.write_str("||")),
|
Token::Column => dest.write_str("||")?,
|
||||||
Token::CDO => try!(dest.write_str("<!--")),
|
Token::CDO => dest.write_str("<!--")?,
|
||||||
Token::CDC => try!(dest.write_str("-->")),
|
Token::CDC => dest.write_str("-->")?,
|
||||||
|
|
||||||
Token::Function(ref name) => {
|
Token::Function(ref name) => {
|
||||||
try!(serialize_identifier(&**name, dest));
|
serialize_identifier(&**name, dest)?;
|
||||||
try!(dest.write_str("("));
|
dest.write_str("(")?;
|
||||||
},
|
},
|
||||||
Token::ParenthesisBlock => try!(dest.write_str("(")),
|
Token::ParenthesisBlock => dest.write_str("(")?,
|
||||||
Token::SquareBracketBlock => try!(dest.write_str("[")),
|
Token::SquareBracketBlock => dest.write_str("[")?,
|
||||||
Token::CurlyBracketBlock => try!(dest.write_str("{")),
|
Token::CurlyBracketBlock => dest.write_str("{")?,
|
||||||
|
|
||||||
Token::BadUrl => try!(dest.write_str("url(<bad url>)")),
|
Token::BadUrl => dest.write_str("url(<bad url>)")?,
|
||||||
Token::BadString => try!(dest.write_str("\"<bad string>\n")),
|
Token::BadString => dest.write_str("\"<bad string>\n")?,
|
||||||
Token::CloseParenthesis => try!(dest.write_str(")")),
|
Token::CloseParenthesis => dest.write_str(")")?,
|
||||||
Token::CloseSquareBracket => try!(dest.write_str("]")),
|
Token::CloseSquareBracket => dest.write_str("]")?,
|
||||||
Token::CloseCurlyBracket => try!(dest.write_str("}")),
|
Token::CloseCurlyBracket => dest.write_str("}")?,
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -147,17 +147,17 @@ pub fn serialize_identifier<W>(mut value: &str, dest: &mut W) -> fmt::Result whe
|
||||||
}
|
}
|
||||||
|
|
||||||
if value.starts_with("--") {
|
if value.starts_with("--") {
|
||||||
try!(dest.write_str("--"));
|
dest.write_str("--")?;
|
||||||
serialize_name(&value[2..], dest)
|
serialize_name(&value[2..], dest)
|
||||||
} else if value == "-" {
|
} else if value == "-" {
|
||||||
dest.write_str("\\-")
|
dest.write_str("\\-")
|
||||||
} else {
|
} else {
|
||||||
if value.as_bytes()[0] == b'-' {
|
if value.as_bytes()[0] == b'-' {
|
||||||
try!(dest.write_str("-"));
|
dest.write_str("-")?;
|
||||||
value = &value[1..];
|
value = &value[1..];
|
||||||
}
|
}
|
||||||
if let digit @ b'0'...b'9' = value.as_bytes()[0] {
|
if let digit @ b'0'...b'9' = value.as_bytes()[0] {
|
||||||
try!(write!(dest, "\\3{} ", digit as char));
|
write!(dest, "\\3{} ", digit as char)?;
|
||||||
value = &value[1..];
|
value = &value[1..];
|
||||||
}
|
}
|
||||||
serialize_name(value, dest)
|
serialize_name(value, dest)
|
||||||
|
|
@ -174,13 +174,13 @@ fn serialize_name<W>(value: &str, dest: &mut W) -> fmt::Result where W:fmt::Writ
|
||||||
b'\0' => Some("\u{FFFD}"),
|
b'\0' => Some("\u{FFFD}"),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
try!(dest.write_str(&value[chunk_start..i]));
|
dest.write_str(&value[chunk_start..i])?;
|
||||||
if let Some(escaped) = escaped {
|
if let Some(escaped) = escaped {
|
||||||
try!(dest.write_str(escaped));
|
dest.write_str(escaped)?;
|
||||||
} else if (b >= b'\x01' && b <= b'\x1F') || b == b'\x7F' {
|
} else if (b >= b'\x01' && b <= b'\x1F') || b == b'\x7F' {
|
||||||
try!(write!(dest, "\\{:x} ", b));
|
write!(dest, "\\{:x} ", b)?;
|
||||||
} else {
|
} else {
|
||||||
try!(write!(dest, "\\{}", b as char));
|
write!(dest, "\\{}", b as char)?;
|
||||||
}
|
}
|
||||||
chunk_start = i + 1;
|
chunk_start = i + 1;
|
||||||
}
|
}
|
||||||
|
|
@ -196,11 +196,11 @@ fn serialize_unquoted_url<W>(value: &str, dest: &mut W) -> fmt::Result where W:f
|
||||||
b'(' | b')' | b'"' | b'\'' | b'\\' => false,
|
b'(' | b')' | b'"' | b'\'' | b'\\' => false,
|
||||||
_ => continue
|
_ => continue
|
||||||
};
|
};
|
||||||
try!(dest.write_str(&value[chunk_start..i]));
|
dest.write_str(&value[chunk_start..i])?;
|
||||||
if hex {
|
if hex {
|
||||||
try!(write!(dest, "\\{:X} ", b));
|
write!(dest, "\\{:X} ", b)?;
|
||||||
} else {
|
} else {
|
||||||
try!(write!(dest, "\\{}", b as char));
|
write!(dest, "\\{}", b as char)?;
|
||||||
}
|
}
|
||||||
chunk_start = i + 1;
|
chunk_start = i + 1;
|
||||||
}
|
}
|
||||||
|
|
@ -210,9 +210,9 @@ fn serialize_unquoted_url<W>(value: &str, dest: &mut W) -> fmt::Result where W:f
|
||||||
|
|
||||||
/// Write a double-quoted CSS string token, escaping content as necessary.
|
/// Write a double-quoted CSS string token, escaping content as necessary.
|
||||||
pub fn serialize_string<W>(value: &str, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
pub fn serialize_string<W>(value: &str, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
try!(dest.write_str("\""));
|
dest.write_str("\"")?;
|
||||||
try!(CssStringWriter::new(dest).write_str(value));
|
CssStringWriter::new(dest).write_str(value)?;
|
||||||
try!(dest.write_str("\""));
|
dest.write_str("\"")?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -255,10 +255,10 @@ impl<'a, W> fmt::Write for CssStringWriter<'a, W> where W: fmt::Write {
|
||||||
b'\x01'...b'\x1F' | b'\x7F' => None,
|
b'\x01'...b'\x1F' | b'\x7F' => None,
|
||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
try!(self.inner.write_str(&s[chunk_start..i]));
|
self.inner.write_str(&s[chunk_start..i])?;
|
||||||
match escaped {
|
match escaped {
|
||||||
Some(x) => try!(self.inner.write_str(x)),
|
Some(x) => self.inner.write_str(x)?,
|
||||||
None => try!(write!(self.inner, "\\{:x} ", b)),
|
None => write!(self.inner, "\\{:x} ", b)?,
|
||||||
};
|
};
|
||||||
chunk_start = i + 1;
|
chunk_start = i + 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
45
third_party/rust/cssparser/src/tests.rs
vendored
45
third_party/rust/cssparser/src/tests.rs
vendored
|
|
@ -118,7 +118,7 @@ fn component_value_list() {
|
||||||
fn one_component_value() {
|
fn one_component_value() {
|
||||||
run_json_tests(include_str!("css-parsing-tests/one_component_value.json"), |input| {
|
run_json_tests(include_str!("css-parsing-tests/one_component_value.json"), |input| {
|
||||||
let result: Result<Json, ParseError<()>> = input.parse_entirely(|input| {
|
let result: Result<Json, ParseError<()>> = input.parse_entirely(|input| {
|
||||||
Ok(one_component_value_to_json(try!(input.next()), input))
|
Ok(one_component_value_to_json(input.next()?, input))
|
||||||
});
|
});
|
||||||
result.unwrap_or(JArray!["error", "invalid"])
|
result.unwrap_or(JArray!["error", "invalid"])
|
||||||
});
|
});
|
||||||
|
|
@ -426,7 +426,7 @@ fn serializer(preserve_comments: bool) {
|
||||||
#[test]
|
#[test]
|
||||||
fn serialize_current_color() {
|
fn serialize_current_color() {
|
||||||
let c = Color::CurrentColor;
|
let c = Color::CurrentColor;
|
||||||
assert!(c.to_css_string() == "currentColor");
|
assert!(c.to_css_string() == "currentcolor");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -622,7 +622,7 @@ impl ToJson for Color {
|
||||||
Color::RGBA(ref rgba) => {
|
Color::RGBA(ref rgba) => {
|
||||||
[rgba.red, rgba.green, rgba.blue, rgba.alpha].to_json()
|
[rgba.red, rgba.green, rgba.blue, rgba.alpha].to_json()
|
||||||
},
|
},
|
||||||
Color::CurrentColor => "currentColor".to_json(),
|
Color::CurrentColor => "currentcolor".to_json(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -881,3 +881,42 @@ fn procedural_masquerade_whitespace() {
|
||||||
_ => panic!("4"),
|
_ => panic!("4"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_until_before_stops_at_delimiter_or_end_of_input() {
|
||||||
|
// For all j and k, inputs[i].1[j] should parse the same as inputs[i].1[k]
|
||||||
|
// when we use delimiters inputs[i].0.
|
||||||
|
let inputs = vec![
|
||||||
|
(Delimiter::Bang | Delimiter::Semicolon,
|
||||||
|
// Note that the ';extra' is fine, because the ';' acts the same as
|
||||||
|
// the end of input.
|
||||||
|
vec!["token stream;extra", "token stream!", "token stream"]),
|
||||||
|
(Delimiter::Bang | Delimiter::Semicolon,
|
||||||
|
vec![";", "!", ""]),
|
||||||
|
];
|
||||||
|
for equivalent in inputs {
|
||||||
|
for (j, x) in equivalent.1.iter().enumerate() {
|
||||||
|
for y in equivalent.1[j + 1..].iter() {
|
||||||
|
let mut ix = ParserInput::new(x);
|
||||||
|
let mut ix = Parser::new(&mut ix);
|
||||||
|
|
||||||
|
let mut iy = ParserInput::new(y);
|
||||||
|
let mut iy = Parser::new(&mut iy);
|
||||||
|
|
||||||
|
let _ = ix.parse_until_before::<_, _, ()>(equivalent.0, |ix| {
|
||||||
|
iy.parse_until_before::<_, _, ()>(equivalent.0, |iy| {
|
||||||
|
loop {
|
||||||
|
let ox = ix.next();
|
||||||
|
let oy = iy.next();
|
||||||
|
assert_eq!(ox, oy);
|
||||||
|
if let Err(_) = ox {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
12
toolkit/library/gtest/rust/Cargo.lock
generated
12
toolkit/library/gtest/rust/Cargo.lock
generated
|
|
@ -227,7 +227,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cssparser"
|
name = "cssparser"
|
||||||
version = "0.16.0"
|
version = "0.16.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
@ -371,7 +371,7 @@ name = "geckoservo"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
@ -818,7 +818,7 @@ name = "selectors"
|
||||||
version = "0.19.0"
|
version = "0.19.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
@ -914,7 +914,7 @@ dependencies = [
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
@ -959,7 +959,7 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"selectors 0.19.0",
|
"selectors 0.19.0",
|
||||||
]
|
]
|
||||||
|
|
@ -1263,7 +1263,7 @@ dependencies = [
|
||||||
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
|
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
|
||||||
"checksum core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f841e9637adec70838c537cae52cb4c751cc6514ad05669b51d107c2021c79"
|
"checksum core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f841e9637adec70838c537cae52cb4c751cc6514ad05669b51d107c2021c79"
|
||||||
"checksum core-text 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7c42ae17408d6b881992268f638257e67303fc7c6c88723dbc0fe5889b22c0bc"
|
"checksum core-text 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7c42ae17408d6b881992268f638257e67303fc7c6c88723dbc0fe5889b22c0bc"
|
||||||
"checksum cssparser 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c711c0c610b1e5fc2bf96e325b2d9f85839a8e71f6279a77c194af5dcafa502"
|
"checksum cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2842253baded8e712e9d8d80ebfe5ea8e95c5b27071e6a6db6080ca1e81c07d1"
|
||||||
"checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df"
|
"checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df"
|
||||||
"checksum dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36e3b27cd0b8a68e00f07e8d8e1e4f4d8a6b8b873290a734f63bd56d792d23e1"
|
"checksum dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36e3b27cd0b8a68e00f07e8d8e1e4f4d8a6b8b873290a734f63bd56d792d23e1"
|
||||||
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
|
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
|
||||||
|
|
|
||||||
12
toolkit/library/rust/Cargo.lock
generated
12
toolkit/library/rust/Cargo.lock
generated
|
|
@ -225,7 +225,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cssparser"
|
name = "cssparser"
|
||||||
version = "0.16.0"
|
version = "0.16.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
@ -369,7 +369,7 @@ name = "geckoservo"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
@ -805,7 +805,7 @@ name = "selectors"
|
||||||
version = "0.19.0"
|
version = "0.19.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
@ -901,7 +901,7 @@ dependencies = [
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
@ -946,7 +946,7 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cssparser 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"selectors 0.19.0",
|
"selectors 0.19.0",
|
||||||
]
|
]
|
||||||
|
|
@ -1250,7 +1250,7 @@ dependencies = [
|
||||||
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
|
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
|
||||||
"checksum core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f841e9637adec70838c537cae52cb4c751cc6514ad05669b51d107c2021c79"
|
"checksum core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f841e9637adec70838c537cae52cb4c751cc6514ad05669b51d107c2021c79"
|
||||||
"checksum core-text 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7c42ae17408d6b881992268f638257e67303fc7c6c88723dbc0fe5889b22c0bc"
|
"checksum core-text 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7c42ae17408d6b881992268f638257e67303fc7c6c88723dbc0fe5889b22c0bc"
|
||||||
"checksum cssparser 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c711c0c610b1e5fc2bf96e325b2d9f85839a8e71f6279a77c194af5dcafa502"
|
"checksum cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2842253baded8e712e9d8d80ebfe5ea8e95c5b27071e6a6db6080ca1e81c07d1"
|
||||||
"checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df"
|
"checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df"
|
||||||
"checksum dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36e3b27cd0b8a68e00f07e8d8e1e4f4d8a6b8b873290a734f63bd56d792d23e1"
|
"checksum dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36e3b27cd0b8a68e00f07e8d8e1e4f4d8a6b8b873290a734f63bd56d792d23e1"
|
||||||
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
|
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue