From d6fa6e453a606d10ed94453c640e6878f715658e Mon Sep 17 00:00:00 2001 From: rwakulszowa Date: Tue, 25 Oct 2016 20:06:37 +0200 Subject: [PATCH] Use off/- instead of 0/1 when serializing --- components/style/properties/longhand/font.mako.rs | 6 +++++- tests/unit/style/parsing/font.rs | 9 ++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 3a1fa19b87e..ff837bbaee4 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -411,7 +411,11 @@ ${helpers.single_keyword("font-variant-position", impl ToCss for FeatureTagValue { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - let s = format!("\"{}\" {}", self.tag, self.value); + let s = match self.value { + 1 => format!("\"{}\"", self.tag), + 0 => format!("\"{}\" off", self.tag), + x => format!("\"{}\" {}", self.tag, x) + }; dest.write_str(&s) } } diff --git a/tests/unit/style/parsing/font.rs b/tests/unit/style/parsing/font.rs index bbf248ebe00..962e081ee20 100644 --- a/tests/unit/style/parsing/font.rs +++ b/tests/unit/style/parsing/font.rs @@ -70,10 +70,9 @@ fn font_feature_settings_should_throw_on_bad_input() { #[test] fn font_feature_settings_to_css() { assert_roundtrip_with_context!(font_feature_settings::parse, "normal"); - assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\"", "\"abcd\" 1"); - assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\" on", "\"abcd\" 1"); - assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\" off", "\"abcd\" 0"); + assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\""); + assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\" on", "\"abcd\""); + assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\" off"); assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\" 4"); - assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\", \"efgh\"", - "\"abcd\" 1, \"efgh\" 1"); + assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\", \"efgh\""); }