Auto merge of #16274 - CarlosMcs:negative-flex-basis, r=emilio

Reject negative values of flex-basis.

Fixes #15902

<!-- Please describe your changes on the following line: -->

---
<!-- 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 #15902 (github issue number if applicable).

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

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/16274)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-04-05 12:09:20 -05:00 committed by GitHub
commit be35f564bd
2 changed files with 19 additions and 0 deletions

View file

@ -142,6 +142,7 @@ ${helpers.predefined_type("flex-basis",
"LengthOrPercentageOrAutoOrContent",
"computed::LengthOrPercentageOrAuto::Auto" if product == "gecko" else
"computed::LengthOrPercentageOrAutoOrContent::Auto",
"parse_non_negative_with_context",
spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property",
extra_prefixes="webkit",
animatable=True if product == "gecko" else False)}

View file

@ -1170,6 +1170,14 @@ impl LengthOrPercentageOrAuto {
pub fn parse_non_negative(input: &mut Parser) -> Result<LengthOrPercentageOrAuto, ()> {
LengthOrPercentageOrAuto::parse_internal(input, AllowedNumericType::NonNegative)
}
/// Parse a non-negative length, percentage, or auto.
#[inline]
pub fn parse_non_negative_with_context(_context: &ParserContext,
input: &mut Parser)
-> Result<LengthOrPercentageOrAuto, ()> {
LengthOrPercentageOrAuto::parse_non_negative(input)
}
}
impl Parse for LengthOrPercentageOrAuto {
@ -1273,6 +1281,16 @@ pub enum LengthOrPercentageOrAutoOrContent {
Content
}
impl LengthOrPercentageOrAutoOrContent {
/// Alias to `parse` so that Gecko and Servo can use the same method name for
/// both `LengthOrPercentageOrAuto` and `LengthOrPercentageOrAutoOrContent`.
///
/// NOTE: `parse` already only accepts non-negative values.
pub fn parse_non_negative_with_context(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
Self::parse(context, input)
}
}
impl HasViewportPercentage for LengthOrPercentageOrAutoOrContent {
fn has_viewport_percentage(&self) -> bool {
match *self {