diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index 741806e9ef5..03b5eb2e33b 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -335,11 +335,11 @@ ${helpers.single_keyword("text-align-last", } } - pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result { + pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { if input.try(|input| input.expect_ident_matching("normal")).is_ok() { Ok(SpecifiedValue::Normal) } else { - specified::Length::parse_non_negative(input).map(SpecifiedValue::Specified) + specified::Length::parse(context, input).map(SpecifiedValue::Specified) } } @@ -416,11 +416,11 @@ ${helpers.single_keyword("text-align-last", } } - pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result { + pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { if input.try(|input| input.expect_ident_matching("normal")).is_ok() { Ok(SpecifiedValue::Normal) } else { - specified::LengthOrPercentage::parse_non_negative(input) + specified::LengthOrPercentage::parse(context, input) .map(SpecifiedValue::Specified) } } diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 351c692cc9a..99c4a09abf1 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -463,6 +463,7 @@ impl Length { } /// Parse a non-negative length + #[inline] pub fn parse_non_negative(input: &mut Parser) -> Result { Length::parse_internal(input, AllowedNumericType::NonNegative) } diff --git a/tests/unit/style/parsing/inherited_text.rs b/tests/unit/style/parsing/inherited_text.rs index fc77e7318e5..c8cea6aac29 100644 --- a/tests/unit/style/parsing/inherited_text.rs +++ b/tests/unit/style/parsing/inherited_text.rs @@ -7,6 +7,29 @@ use media_queries::CSSErrorReporterTest; use style::parser::ParserContext; use style::stylesheets::Origin; +#[test] +fn negative_letter_spacing_should_parse_properly() { + use style::properties::longhands::letter_spacing; + use style::properties::longhands::letter_spacing::SpecifiedValue; + use style::values::specified::length::{Length, NoCalcLength, FontRelativeLength}; + + let negative_value = parse_longhand!(letter_spacing, "-0.5em"); + let expected = SpecifiedValue::Specified(Length::NoCalc(NoCalcLength::FontRelative(FontRelativeLength::Em(-0.5)))); + assert_eq!(negative_value, expected); +} + +#[test] +fn negative_word_spacing_should_parse_properly() { + use style::properties::longhands::word_spacing; + use style::properties::longhands::word_spacing::SpecifiedValue; + use style::values::specified::length::{NoCalcLength, LengthOrPercentage, FontRelativeLength}; + + let negative_value = parse_longhand!(word_spacing, "-0.5em"); + let expected = SpecifiedValue::Specified(LengthOrPercentage::Length(NoCalcLength::FontRelative( + FontRelativeLength::Em(-0.5)))); + assert_eq!(negative_value, expected); +} + #[test] fn text_emphasis_style_longhand_should_parse_properly() { use style::properties::longhands::text_emphasis_style; @@ -79,7 +102,6 @@ fn test_text_emphasis_position() { assert_eq!(left_under, SpecifiedValue(HorizontalWritingModeValue::Under, VerticalWritingModeValue::Left)); } - #[test] fn webkit_text_stroke_shorthand_should_parse_properly() { use media_queries::CSSErrorReporterTest; diff --git a/tests/wpt/metadata-css/css-text-3_dev/html/text-word-spacing-001.htm.ini b/tests/wpt/metadata-css/css-text-3_dev/html/text-word-spacing-001.htm.ini deleted file mode 100644 index 39a078b78a4..00000000000 --- a/tests/wpt/metadata-css/css-text-3_dev/html/text-word-spacing-001.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[text-word-spacing-001.htm] - type: reftest - expected: FAIL diff --git a/tests/wpt/metadata-css/css21_dev/html4/c542-letter-sp-001.htm.ini b/tests/wpt/metadata-css/css21_dev/html4/c542-letter-sp-001.htm.ini deleted file mode 100644 index d6d93651343..00000000000 --- a/tests/wpt/metadata-css/css21_dev/html4/c542-letter-sp-001.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[c542-letter-sp-001.htm] - type: reftest - expected: FAIL