diff --git a/components/style/properties/longhand/inherited_table.mako.rs b/components/style/properties/longhand/inherited_table.mako.rs index 3069482976ed..e464d9433f61 100644 --- a/components/style/properties/longhand/inherited_table.mako.rs +++ b/components/style/properties/longhand/inherited_table.mako.rs @@ -26,6 +26,7 @@ ${helpers.single_keyword("caption-side", "top bottom", use std::fmt; use style_traits::ToCss; use values::HasViewportPercentage; + use values::specified::{AllowQuirks, Length}; pub mod computed_value { use app_units::Au; @@ -60,8 +61,8 @@ ${helpers.single_keyword("caption-side", "top bottom", #[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue { - pub horizontal: specified::Length, - pub vertical: Option, + pub horizontal: Length, + pub vertical: Option, } #[inline] @@ -117,11 +118,11 @@ ${helpers.single_keyword("caption-side", "top bottom", pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { let mut first = None; let mut second = None; - match specified::Length::parse_non_negative(context, input) { + match Length::parse_non_negative_quirky(context, input, AllowQuirks::Yes) { Err(()) => (), Ok(length) => { first = Some(length); - if let Ok(len) = input.try(|input| specified::Length::parse_non_negative(context, input)) { + if let Ok(len) = input.try(|i| Length::parse_non_negative_quirky(context, i, AllowQuirks::Yes)) { second = Some(len); } } diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index e161b5fc5891..424e65532798 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -563,13 +563,17 @@ impl Length { } #[inline] - fn parse_internal(context: &ParserContext, input: &mut Parser, num_context: AllowedLengthType) + fn parse_internal(context: &ParserContext, + input: &mut Parser, + num_context: AllowedLengthType, + allow_quirks: AllowQuirks) -> Result { match try!(input.next()) { Token::Dimension(ref value, ref unit) if num_context.is_ok(value.value) => Length::parse_dimension(context, value.value, unit), - Token::Number(ref value) => { - if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() { + Token::Number(ref value) if num_context.is_ok(value.value) => { + if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() && + !allow_quirks.allowed(context.quirks_mode) { return Err(()) } Ok(Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(value.value)))) @@ -585,7 +589,16 @@ impl Length { /// Parse a non-negative length #[inline] pub fn parse_non_negative(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::NonNegative) + Self::parse_non_negative_quirky(context, input, AllowQuirks::No) + } + + /// Parse a non-negative length, allowing 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) } /// Get an absolute length from a px value. @@ -605,7 +618,7 @@ impl Length { impl Parse for Length { fn parse(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::All) + Self::parse_internal(context, input, AllowedLengthType::All, AllowQuirks::No) } } @@ -616,7 +629,7 @@ impl Either { if let Ok(v) = input.try(|input| T::parse(context, input)) { return Ok(Either::Second(v)); } - Length::parse_internal(context, input, AllowedLengthType::NonNegative).map(Either::First) + Length::parse_internal(context, input, AllowedLengthType::NonNegative, AllowQuirks::No).map(Either::First) } } diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 9b8f785c3ce8..2be0a018e450 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -1,8 +1,5 @@ [unitless-length.html] type: testharness - [border-spacing: 1 (quirks)] - expected: FAIL - [border-top-width: 1 (quirks)] expected: FAIL @@ -102,9 +99,6 @@ [word-spacing: 1 (quirks)] expected: FAIL - [border-spacing: +1 (quirks)] - expected: FAIL - [border-top-width: +1 (quirks)] expected: FAIL @@ -255,9 +249,6 @@ [word-spacing: -1 (quirks)] expected: FAIL - [border-spacing: 1.5 (quirks)] - expected: FAIL - [border-top-width: 1.5 (quirks)] expected: FAIL @@ -357,9 +348,6 @@ [word-spacing: 1.5 (quirks)] expected: FAIL - [border-spacing: +1.5 (quirks)] - expected: FAIL - [border-top-width: +1.5 (quirks)] expected: FAIL @@ -1248,9 +1236,6 @@ [top: calc(2 * 2px) (standards)] expected: FAIL - [border-spacing: 1px 2 (quirks)] - expected: FAIL - [border-width: 1px 2 (quirks)] expected: FAIL @@ -1260,9 +1245,6 @@ [padding: 1px 2 (quirks)] expected: FAIL - [border-spacing: 1 2px (quirks)] - expected: FAIL - [border-width: 1 2px (quirks)] expected: FAIL @@ -1272,9 +1254,6 @@ [padding: 1 2px (quirks)] expected: FAIL - [border-spacing: 1 +2 (quirks)] - expected: FAIL - [border-width: 1 +2 (quirks)] expected: FAIL