From 877c6ac821ae6f80735b0d7e45a82c209432495c Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Mon, 23 Sep 2019 02:07:16 +0000 Subject: [PATCH] style: Parse '0' as a number for border-image-width. As per CSS Values & Units: "However, if a 0 could be parsed as either a or a in a property (such as line-height), it must parse as a ." (https://drafts.csswg.org/css-values-4/#lengths) Differential Revision: https://phabricator.services.mozilla.com/D46723 --- components/style/values/generics/border.rs | 8 ++++++-- components/style/values/specified/border.rs | 18 ------------------ 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/components/style/values/generics/border.rs b/components/style/values/generics/border.rs index f36062ce39b..755a368a958 100644 --- a/components/style/values/generics/border.rs +++ b/components/style/values/generics/border.rs @@ -16,6 +16,7 @@ use style_traits::{CssWriter, ToCss}; Copy, Debug, MallocSizeOf, + Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, @@ -25,10 +26,13 @@ use style_traits::{CssWriter, ToCss}; )] #[repr(C, u8)] pub enum GenericBorderImageSideWidth { + /// `` + /// + /// NOTE: Numbers need to be before length-percentagess, in order to parse + /// them first, since `0` should be a number, not the `0px` length. + Number(N), /// `` LengthPercentage(LP), - /// `` - Number(N), /// `auto` Auto, } diff --git a/components/style/values/specified/border.rs b/components/style/values/specified/border.rs index 8c42b585d91..375700809d1 100644 --- a/components/style/values/specified/border.rs +++ b/components/style/values/specified/border.rs @@ -180,24 +180,6 @@ impl BorderImageSideWidth { } } -impl Parse for BorderImageSideWidth { - fn parse<'i, 't>( - context: &ParserContext, - input: &mut Parser<'i, 't>, - ) -> Result> { - if input.try(|i| i.expect_ident_matching("auto")).is_ok() { - return Ok(GenericBorderImageSideWidth::Auto); - } - - if let Ok(len) = input.try(|i| NonNegativeLengthPercentage::parse(context, i)) { - return Ok(GenericBorderImageSideWidth::LengthPercentage(len)); - } - - let num = NonNegativeNumber::parse(context, input)?; - Ok(GenericBorderImageSideWidth::Number(num)) - } -} - impl Parse for BorderImageSlice { fn parse<'i, 't>( context: &ParserContext,