aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-02-06 19:29:31 -0800
committerGitHub <noreply@github.com>2017-02-06 19:29:31 -0800
commit449147b8df3b81621c54af615eb1adb8589eb83b (patch)
tree493d9c691b332624ebffc712faf4c658d8ffe69d
parenta1d19ca5f831536ee60bb4fa85a9d3ea53c2170e (diff)
parent3682434828d33eb5df1f068e046e2fe14c8c5001 (diff)
downloadservo-449147b8df3b81621c54af615eb1adb8589eb83b.tar.gz
servo-449147b8df3b81621c54af615eb1adb8589eb83b.zip
Auto merge of #15237 - samuknet:negative-letter-spacing-word-spacing, r=emilio
Allow negative values for letter-spacing and word-spacing. Inline Le… <!-- Please describe your changes on the following line: --> Allow negative values when parsing `letter-spacing` and `word-spacing`. Inline `parse_non_negative` in `Length`. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #15204 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15237) <!-- Reviewable:end -->
-rw-r--r--components/style/properties/longhand/inherited_text.mako.rs8
-rw-r--r--components/style/values/specified/length.rs1
-rw-r--r--tests/unit/style/parsing/inherited_text.rs24
-rw-r--r--tests/wpt/metadata-css/css-text-3_dev/html/text-word-spacing-001.htm.ini3
-rw-r--r--tests/wpt/metadata-css/css21_dev/html4/c542-letter-sp-001.htm.ini3
5 files changed, 28 insertions, 11 deletions
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<SpecifiedValue, ()> {
+ pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
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)
}
}
</%helpers:longhand>
@@ -416,11 +416,11 @@ ${helpers.single_keyword("text-align-last",
}
}
- pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
+ pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
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, ()> {
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
@@ -8,6 +8,29 @@ 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;
use style::properties::longhands::text_emphasis_style::{ShapeKeyword, SpecifiedValue, KeywordValue};
@@ -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