From b5a558e592fb1dec977a868ed1b7adaf3fa490d9 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 24 Apr 2017 12:54:34 +0200 Subject: [PATCH] Implement the unitless length quirk for border-*-width --- components/style/properties/helpers.mako.rs | 8 +++- .../style/properties/longhand/border.mako.rs | 4 +- components/style/values/specified/mod.rs | 12 ++++- .../quirks-mode/unitless-length.html.ini | 48 ------------------- 4 files changed, 20 insertions(+), 52 deletions(-) diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 2505d1f82d5..5cfe95eec4d 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -8,11 +8,13 @@ %> <%def name="predefined_type(name, type, initial_value, parse_method='parse', - needs_context=True, vector=False, computed_type=None, initial_specified_value=None, **kwargs)"> + needs_context=True, vector=False, computed_type=None, initial_specified_value=None, + allow_quirks=False, **kwargs)"> <%def name="predefined_type_inner(name, type, initial_value, parse_method)"> #[allow(unused_imports)] use app_units::Au; use cssparser::{Color as CSSParserColor, RGBA}; + use values::specified::AllowQuirks; pub use values::specified::${type} as SpecifiedValue; pub mod computed_value { % if computed_type: @@ -30,7 +32,9 @@ pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { - % if needs_context: + % if allow_quirks: + specified::${type}::${parse_method}_quirky(context, input, AllowQuirks::Yes) + % elif needs_context: specified::${type}::${parse_method}(context, input) % else: specified::${type}::${parse_method}(input) diff --git a/components/style/properties/longhand/border.mako.rs b/components/style/properties/longhand/border.mako.rs index df5cb06f1cc..a540b515a82 100644 --- a/components/style/properties/longhand/border.mako.rs +++ b/components/style/properties/longhand/border.mako.rs @@ -33,7 +33,9 @@ computed_type="::app_units::Au", alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-width"), spec=maybe_logical_spec(side, "width"), - animation_value_type="ComputedValue", logical=side[1])} + animation_value_type="ComputedValue", + logical=side[1], + allow_quirks=not side[1])} % endfor ${helpers.gecko_keyword_conversion(Keyword('border-style', diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 6519613bf6b..6c7a74627c0 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -491,7 +491,17 @@ pub enum BorderWidth { impl Parse for BorderWidth { fn parse(context: &ParserContext, input: &mut Parser) -> Result { - match input.try(|i| Length::parse_non_negative(context, i)) { + Self::parse_quirky(context, input, AllowQuirks::No) + } +} + +impl BorderWidth { + /// Parses a border width, allowing quirks. + pub fn parse_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) + -> Result { + match input.try(|i| Length::parse_non_negative_quirky(context, i, allow_quirks)) { Ok(length) => Ok(BorderWidth::Width(length)), Err(_) => match_ignore_ascii_case! { &try!(input.expect_ident()), "thin" => Ok(BorderWidth::Thin), diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 2be0a018e45..84929e65d87 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -1,17 +1,5 @@ [unitless-length.html] type: testharness - [border-top-width: 1 (quirks)] - expected: FAIL - - [border-right-width: 1 (quirks)] - expected: FAIL - - [border-bottom-width: 1 (quirks)] - expected: FAIL - - [border-left-width: 1 (quirks)] - expected: FAIL - [border-width: 1 (quirks)] expected: FAIL @@ -99,18 +87,6 @@ [word-spacing: 1 (quirks)] expected: FAIL - [border-top-width: +1 (quirks)] - expected: FAIL - - [border-right-width: +1 (quirks)] - expected: FAIL - - [border-bottom-width: +1 (quirks)] - expected: FAIL - - [border-left-width: +1 (quirks)] - expected: FAIL - [border-width: +1 (quirks)] expected: FAIL @@ -249,18 +225,6 @@ [word-spacing: -1 (quirks)] expected: FAIL - [border-top-width: 1.5 (quirks)] - expected: FAIL - - [border-right-width: 1.5 (quirks)] - expected: FAIL - - [border-bottom-width: 1.5 (quirks)] - expected: FAIL - - [border-left-width: 1.5 (quirks)] - expected: FAIL - [border-width: 1.5 (quirks)] expected: FAIL @@ -348,18 +312,6 @@ [word-spacing: 1.5 (quirks)] expected: FAIL - [border-top-width: +1.5 (quirks)] - expected: FAIL - - [border-right-width: +1.5 (quirks)] - expected: FAIL - - [border-bottom-width: +1.5 (quirks)] - expected: FAIL - - [border-left-width: +1.5 (quirks)] - expected: FAIL - [border-width: +1.5 (quirks)] expected: FAIL