mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Reverse Number and LengthOrPercentage in LengthOrPercentageOrNumber
"0" must be parsed as the number 0, not the unitless 0px length.
This commit is contained in:
parent
f1287814db
commit
193e1d5569
6 changed files with 18 additions and 11 deletions
|
@ -1191,7 +1191,7 @@ impl ToComputedValue for SVGPaintKind {
|
|||
}
|
||||
|
||||
/// <length> | <percentage> | <number>
|
||||
pub type LengthOrPercentageOrNumber = Either<LengthOrPercentage, Number>;
|
||||
pub type LengthOrPercentageOrNumber = Either<Number, LengthOrPercentage>;
|
||||
|
||||
impl LengthOrPercentageOrNumber {
|
||||
/// parse a <length-percentage> | <number> enforcing that the contents aren't negative
|
||||
|
@ -1199,10 +1199,10 @@ impl LengthOrPercentageOrNumber {
|
|||
// NB: Parse numbers before Lengths so we are consistent about how to
|
||||
// recognize and serialize "0".
|
||||
if let Ok(num) = input.try(|i| Number::parse_non_negative(context, i)) {
|
||||
return Ok(Either::Second(num))
|
||||
return Ok(Either::First(num))
|
||||
}
|
||||
|
||||
LengthOrPercentage::parse_non_negative(context, input).map(Either::First)
|
||||
LengthOrPercentage::parse_non_negative(context, input).map(Either::Second)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue