From cba88f213db683a01cc0d8fe85d747717ecd1d20 Mon Sep 17 00:00:00 2001 From: Dexter Haslem Date: Wed, 25 Jan 2017 09:22:21 -0700 Subject: [PATCH] fix transform: none serialization --- .../style/properties/longhand/box.mako.rs | 5 ++++ tests/unit/style/properties/serialization.rs | 23 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 5bac0d7dab7..754afaf164d 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -1251,6 +1251,11 @@ ${helpers.single_keyword("animation-fill-mode", impl ToCss for SpecifiedValue { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + + if self.0.is_empty() { + return dest.write_str("none") + } + let mut first = true; for operation in &self.0 { if !first { diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs index 2c47766eaa9..ec608fa6ccb 100644 --- a/tests/unit/style/properties/serialization.rs +++ b/tests/unit/style/properties/serialization.rs @@ -1067,4 +1067,27 @@ mod shorthand_serialization { assert_eq!(s, "mandatory"); } } + + mod transform { + pub use super::*; + + #[test] + fn should_serialize_none_correctly() { + use cssparser::Parser; + use media_queries::CSSErrorReporterTest; + use style::parser::ParserContext; + use style::properties::longhands::transform; + use style::stylesheets::Origin; + + let mut s = String::new(); + let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); + let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest)); + + let parsed = transform::parse(&context, &mut Parser::new("none")).unwrap(); + let try_serialize = parsed.to_css(&mut s); + + assert_eq!(try_serialize.is_ok(), true); + assert_eq!(s, "none"); + } + } }