diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 590b7cb8980..757c270bb49 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -179,7 +179,7 @@ ${helpers.predefined_type("flex-basis", use std::fmt; use style_traits::ToCss; use values::HasViewportPercentage; - use values::specified::${MinMax}Length; + use values::specified::{AllowQuirks, ${MinMax}Length}; impl HasViewportPercentage for SpecifiedValue { fn has_viewport_percentage(&self) -> bool { @@ -201,7 +201,11 @@ ${helpers.predefined_type("flex-basis", ${MinMax}Length::${initial} } fn parse(context: &ParserContext, input: &mut Parser) -> Result { + % if logical: let ret = ${MinMax}Length::parse(context, input); + % else: + let ret = ${MinMax}Length::parse_quirky(context, input, AllowQuirks::Yes); + % endif // Keyword values don't make sense in the block direction; don't parse them % if "block" in size: if let Ok(${MinMax}Length::ExtremumLength(..)) = ret { @@ -256,13 +260,17 @@ ${helpers.predefined_type("flex-basis", "computed::LengthOrPercentage::Length(Au(0))", "parse_non_negative", spec=spec % ("min-%s" % size), - animation_value_type="ComputedValue", logical = logical)} + animation_value_type="ComputedValue", + logical=logical, + allow_quirks=not logical)} ${helpers.predefined_type("max-%s" % size, "LengthOrPercentageOrNone", "computed::LengthOrPercentageOrNone::None", "parse_non_negative", spec=spec % ("min-%s" % size), - animation_value_type="ComputedValue", logical = logical)} + animation_value_type="ComputedValue", + logical=logical, + allow_quirks=not logical)} % endif % endfor diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 2581db7290d..d3ebba44726 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -1434,7 +1434,10 @@ impl ToCss for LengthOrPercentageOrNone { } } impl LengthOrPercentageOrNone { - 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()) { @@ -1442,8 +1445,9 @@ impl LengthOrPercentageOrNone { NoCalcLength::parse_dimension(context, value.value, unit).map(LengthOrPercentageOrNone::Length), Token::Percentage(ref value) if num_context.is_ok(value.unit_value) => Ok(LengthOrPercentageOrNone::Percentage(Percentage(value.unit_value))), - Token::Number(ref value) if value.value == 0. => { - if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() { + Token::Number(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(LengthOrPercentageOrNone::Length( @@ -1461,17 +1465,27 @@ impl LengthOrPercentageOrNone { _ => Err(()) } } + /// Parse a non-negative LengthOrPercentageOrNone. #[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 LengthOrPercentageOrNone, 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) } } impl Parse for LengthOrPercentageOrNone { #[inline] fn parse(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::All) + Self::parse_internal(context, input, AllowedLengthType::All, AllowQuirks::No) } } @@ -1615,8 +1629,17 @@ impl ToCss for MinLength { impl Parse for MinLength { fn parse(context: &ParserContext, input: &mut Parser) -> Result { + MinLength::parse_quirky(context, input, AllowQuirks::No) + } +} + +impl MinLength { + /// Parses, with quirks. + pub fn parse_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) -> Result { input.try(ExtremumLength::parse).map(MinLength::ExtremumLength) - .or_else(|()| input.try(|i| LengthOrPercentage::parse_non_negative(context, i)) + .or_else(|()| input.try(|i| LengthOrPercentage::parse_non_negative_quirky(context, i, allow_quirks)) .map(MinLength::LengthOrPercentage)) .or_else(|()| input.expect_ident_matching("auto").map(|()| MinLength::Auto)) } @@ -1656,8 +1679,17 @@ impl ToCss for MaxLength { impl Parse for MaxLength { fn parse(context: &ParserContext, input: &mut Parser) -> Result { + MaxLength::parse_quirky(context, input, AllowQuirks::No) + } +} + +impl MaxLength { + /// Parses, with quirks. + pub fn parse_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) -> Result { input.try(ExtremumLength::parse).map(MaxLength::ExtremumLength) - .or_else(|()| input.try(|i| LengthOrPercentage::parse_non_negative(context, i)) + .or_else(|()| input.try(|i| LengthOrPercentage::parse_non_negative_quirky(context, i, allow_quirks)) .map(MaxLength::LengthOrPercentage)) .or_else(|()| { match_ignore_ascii_case! { &try!(input.expect_ident()), diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index f9dadbfb7f1..d8a855aeba8 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -511,7 +511,7 @@ pub extern "C" fn Servo_StyleSheet_Empty(mode: SheetParsingMode) -> RawServoStyl Arc::new(Stylesheet::from_str( "", unsafe { dummy_url_data() }.clone(), origin, Arc::new(shared_lock.wrap(MediaList::empty())), - shared_lock, None, &RustLogReporter, QuirksMode::NoQuirks, Wh0u64) + shared_lock, None, &RustLogReporter, QuirksMode::NoQuirks, 0u64) ).into_strong() } diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 57b312ab152..3584ede282b 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -12,18 +12,6 @@ expected: if os == "mac": FAIL - [max-height: 1 (quirks)] - expected: FAIL - - [max-width: 1 (quirks)] - expected: FAIL - - [min-height: 1 (quirks)] - expected: FAIL - - [min-width: 1 (quirks)] - expected: FAIL - [padding-top: 1 (quirks)] expected: FAIL @@ -72,18 +60,6 @@ expected: if os == "mac": FAIL - [max-height: +1 (quirks)] - expected: FAIL - - [max-width: +1 (quirks)] - expected: FAIL - - [min-height: +1 (quirks)] - expected: FAIL - - [min-width: +1 (quirks)] - expected: FAIL - [padding-top: +1 (quirks)] expected: FAIL @@ -168,18 +144,6 @@ expected: if os == "mac": FAIL - [max-height: 1.5 (quirks)] - expected: FAIL - - [max-width: 1.5 (quirks)] - expected: FAIL - - [min-height: 1.5 (quirks)] - expected: FAIL - - [min-width: 1.5 (quirks)] - expected: FAIL - [padding-top: 1.5 (quirks)] expected: FAIL @@ -228,18 +192,6 @@ expected: if os == "mac": FAIL - [max-height: +1.5 (quirks)] - expected: FAIL - - [max-width: +1.5 (quirks)] - expected: FAIL - - [min-height: +1.5 (quirks)] - expected: FAIL - - [min-width: +1.5 (quirks)] - expected: FAIL - [padding-top: +1.5 (quirks)] expected: FAIL