Auto merge of #15662 - canaltinova:column, r=Manishearth

Fix parsing methods of column-{gap,width}

<!-- Please describe your changes on the following line: -->
They weren't accepting {normal, auto} keywords. Fixed parsing methods of these properties.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15088 (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15662)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-02-20 10:28:03 -08:00 committed by GitHub
commit f86e711506
5 changed files with 76 additions and 15 deletions

View file

@ -496,10 +496,24 @@ impl Parse for Length {
}
}
impl<T> Either<Length, T> {
impl Either<Length, Normal> {
#[inline]
#[allow(missing_docs)]
pub fn parse_non_negative_length(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
pub fn parse_non_negative_length(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
if input.try(|input| Normal::parse(context, input)).is_ok() {
return Ok(Either::Second(Normal));
}
Length::parse_internal(input, AllowedNumericType::NonNegative).map(Either::First)
}
}
impl Either<Length, Auto> {
#[inline]
#[allow(missing_docs)]
pub fn parse_non_negative_length(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
if input.try(|input| Auto::parse(context, input)).is_ok() {
return Ok(Either::Second(Auto));
}
Length::parse_internal(input, AllowedNumericType::NonNegative).map(Either::First)
}
}