diff --git a/components/style/properties/data.py b/components/style/properties/data.py index c935e00a79f..8db09e6fe81 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -140,7 +140,7 @@ class Longhand(object): need_clone=False, need_index=False, gecko_ffi_name=None, depend_on_viewport_size=False, allowed_in_keyframe_block=True, complex_color=False, cast_type='u8', has_uncacheable_values=False, logical=False, alias=None, extra_prefixes=None, boxed=False, - flags=None, allowed_in_page_rule=False): + flags=None, allowed_in_page_rule=False, allow_quirks=False): self.name = name if not spec: raise TypeError("Spec should be specified for %s" % name) @@ -166,6 +166,7 @@ class Longhand(object): self.boxed = arg_to_bool(boxed) self.flags = flags.split() if flags else [] self.allowed_in_page_rule = arg_to_bool(allowed_in_page_rule) + self.allow_quirks = allow_quirks # https://drafts.csswg.org/css-animations/#keyframes # > The inside of accepts any CSS property diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 5cfe95eec4d..6563b97df15 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -375,7 +375,11 @@ parse(context, input).map(|result| Box::new(result)) % else: -> Result { - parse(context, input) + % if property.allow_quirks: + parse_quirky(context, input, specified::AllowQuirks::Yes) + % else: + parse(context, input) + % endif % endif } pub fn parse_declared(context: &ParserContext, input: &mut Parser) diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 6bdc67037d3..02df590ee9d 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -550,14 +550,14 @@ ${helpers.single_keyword_system("font-variant-caps", <%helpers:longhand name="font-size" need_clone="True" animation_value_type="ComputedValue" - spec="https://drafts.csswg.org/css-fonts/#propdef-font-size"> + allow_quirks="True" spec="https://drafts.csswg.org/css-fonts/#propdef-font-size"> use app_units::Au; use properties::longhands::system_font::SystemFont; use properties::style_structs::Font; use std::fmt; use style_traits::ToCss; use values::{FONT_MEDIUM_PX, HasViewportPercentage}; - use values::specified::{FontRelativeLength, LengthOrPercentage, Length}; + use values::specified::{AllowQuirks, FontRelativeLength, LengthOrPercentage, Length}; use values::specified::{NoCalcLength, Percentage}; use values::specified::length::FontBaseSize; @@ -843,9 +843,19 @@ ${helpers.single_keyword_system("font-variant-caps", )) } } + /// | | | pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { - if let Ok(lop) = input.try(|i| specified::LengthOrPercentage::parse_non_negative(context, i)) { + parse_quirky(context, input, AllowQuirks::No) + } + + /// Parses a font-size, with quirks. + pub fn parse_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) + -> Result { + use self::specified::LengthOrPercentage; + if let Ok(lop) = input.try(|i| LengthOrPercentage::parse_non_negative_quirky(context, i, allow_quirks)) { return Ok(SpecifiedValue::Length(lop)) } diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 142b44e1861..6a66e658aef 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -1204,7 +1204,16 @@ impl LengthOrPercentage { /// Parse a non-negative length. #[inline] pub fn parse_non_negative(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::NonNegative, AllowQuirks::No) + Self::parse_non_negative_quirky(context, input, AllowQuirks::No) + } + + /// Parse a non-negative length, with quirks. + #[inline] + pub fn parse_non_negative_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) + -> Result { + Self::parse_internal(context, input, AllowedLengthType::NonNegative, allow_quirks) } /// Parse a length, treating dimensionless numbers as pixels diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 6b916d49a89..95010cb9d61 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -12,9 +12,6 @@ expected: if os == "mac": FAIL - [font-size: 1 (quirks)] - expected: FAIL - [height: 1 (quirks)] expected: FAIL @@ -96,9 +93,6 @@ expected: if os == "mac": FAIL - [font-size: +1 (quirks)] - expected: FAIL - [height: +1 (quirks)] expected: FAIL @@ -231,9 +225,6 @@ expected: if os == "mac": FAIL - [font-size: 1.5 (quirks)] - expected: FAIL - [height: 1.5 (quirks)] expected: FAIL @@ -315,9 +306,6 @@ expected: if os == "mac": FAIL - [font-size: +1.5 (quirks)] - expected: FAIL - [height: +1.5 (quirks)] expected: FAIL