mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
Bug 1374233 - Part 1: Add NonNegativeNumber and GreaterThanOrEqualToOneNumber.
NonNegativeNumber: for -moz-box-flex, flex-grow, and flex-shrink. GreaterThanOrEqualToOneNumber: for stroke-miterlimit. MozReview-Commit-ID: Kgbt99BPdVA
This commit is contained in:
parent
50c9797ddd
commit
4cc97746f2
12 changed files with 181 additions and 26 deletions
|
@ -46,12 +46,13 @@
|
|||
extra_prefixes="webkit"
|
||||
derive_serialize="True"
|
||||
spec="https://drafts.csswg.org/css-flexbox/#flex-property">
|
||||
use values::specified::Number;
|
||||
use parser::Parse;
|
||||
use values::specified::NonNegativeNumber;
|
||||
|
||||
fn parse_flexibility<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<(Number, Option<Number>),ParseError<'i>> {
|
||||
let grow = Number::parse_non_negative(context, input)?;
|
||||
let shrink = input.try(|i| Number::parse_non_negative(context, i)).ok();
|
||||
-> Result<(NonNegativeNumber, Option<NonNegativeNumber>),ParseError<'i>> {
|
||||
let grow = NonNegativeNumber::parse(context, input)?;
|
||||
let shrink = input.try(|i| NonNegativeNumber::parse(context, i)).ok();
|
||||
Ok((grow, shrink))
|
||||
}
|
||||
|
||||
|
@ -63,8 +64,8 @@
|
|||
|
||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(expanded! {
|
||||
flex_grow: Number::new(0.0),
|
||||
flex_shrink: Number::new(0.0),
|
||||
flex_grow: NonNegativeNumber::new(0.0),
|
||||
flex_shrink: NonNegativeNumber::new(0.0),
|
||||
flex_basis: longhands::flex_basis::SpecifiedValue::auto(),
|
||||
})
|
||||
}
|
||||
|
@ -89,8 +90,8 @@
|
|||
return Err(StyleParseError::UnspecifiedError.into())
|
||||
}
|
||||
Ok(expanded! {
|
||||
flex_grow: grow.unwrap_or(Number::new(1.0)),
|
||||
flex_shrink: shrink.unwrap_or(Number::new(1.0)),
|
||||
flex_grow: grow.unwrap_or(NonNegativeNumber::new(1.0)),
|
||||
flex_shrink: shrink.unwrap_or(NonNegativeNumber::new(1.0)),
|
||||
// Per spec, this should be SpecifiedValue::zero(), but all
|
||||
// browsers currently agree on using `0%`. This is a spec
|
||||
// change which hasn't been adopted by browsers:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue