Reject negative values of flex-basis.

Fixes #15902
This commit is contained in:
Carlos Martinez 2017-04-05 18:37:34 +02:00
parent bf7c044955
commit b85f1a0240
2 changed files with 19 additions and 0 deletions

View file

@ -142,6 +142,7 @@ ${helpers.predefined_type("flex-basis",
"LengthOrPercentageOrAutoOrContent", "LengthOrPercentageOrAutoOrContent",
"computed::LengthOrPercentageOrAuto::Auto" if product == "gecko" else "computed::LengthOrPercentageOrAuto::Auto" if product == "gecko" else
"computed::LengthOrPercentageOrAutoOrContent::Auto", "computed::LengthOrPercentageOrAutoOrContent::Auto",
"parse_non_negative_with_context",
spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property", spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property",
extra_prefixes="webkit", extra_prefixes="webkit",
animatable=True if product == "gecko" else False)} 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, ()> { pub fn parse_non_negative(input: &mut Parser) -> Result<LengthOrPercentageOrAuto, ()> {
LengthOrPercentageOrAuto::parse_internal(input, AllowedNumericType::NonNegative) 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 { impl Parse for LengthOrPercentageOrAuto {
@ -1273,6 +1281,16 @@ pub enum LengthOrPercentageOrAutoOrContent {
Content 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 { impl HasViewportPercentage for LengthOrPercentageOrAutoOrContent {
fn has_viewport_percentage(&self) -> bool { fn has_viewport_percentage(&self) -> bool {
match *self { match *self {