Pass ParserContext down to lengths

To make it possible to check the rule type when parsing lengths, we need to pass
the `ParserContext` down through many layers to the place where length units are
parsed.

This change leaves it unused, so it's only to prepare for the next change.

MozReview-Commit-ID: 70YwtcCxnWw
This commit is contained in:
J. Ryan Stinnett 2017-04-11 16:00:37 +08:00
parent 1ae1d370f2
commit 1a31b87c22
31 changed files with 304 additions and 251 deletions

View file

@ -525,16 +525,16 @@ ${helpers.single_keyword("-moz-float-edge", "content-box margin-box",
}
impl Parse for SingleSpecifiedValue {
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
if input.try(|input| input.expect_ident_matching("auto")).is_ok() {
return Ok(SingleSpecifiedValue::Auto);
}
if let Ok(len) = input.try(|input| LengthOrPercentage::parse_non_negative(input)) {
if let Ok(len) = input.try(|input| LengthOrPercentage::parse_non_negative(context, input)) {
return Ok(SingleSpecifiedValue::LengthOrPercentage(len));
}
let num = try!(Number::parse_non_negative(input));
let num = try!(Number::parse_non_negative(context, input));
Ok(SingleSpecifiedValue::Number(num))
}
}