From c387eff065caaea9729b2d7aa66c785e1f511f86 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 13 Nov 2016 22:39:38 -0800 Subject: [PATCH] Fix single_value_to_css --- .../style/properties/declaration_block.rs | 17 +++++++---------- tests/unit/style/properties/serialization.rs | 4 ++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index 5ba7f52db14..b65fc6698d6 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -214,16 +214,13 @@ impl PropertyDeclarationBlock { if !self.declarations.iter().all(|decl| decl.0.shorthands().contains(&shorthand)) { return Err(fmt::Error) } - let success = try!(shorthand.serialize_shorthand_to_buffer( - dest, - self.declarations.iter() - .map(get_declaration as fn(_) -> _), - &mut true) - ); - if success { - Ok(()) - } else { - Err(fmt::Error) + let iter = self.declarations.iter().map(get_declaration as fn(_) -> _); + match shorthand.get_shorthand_appendable_value(iter) { + Some(AppendableValue::Css(css)) => dest.write_str(css), + Some(AppendableValue::DeclarationsForShorthand(_, decls)) => { + shorthand.longhands_to_css(decls, dest) + } + _ => Ok(()) } } } diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs index 1128f060fd9..96b0004b843 100644 --- a/tests/unit/style/properties/serialization.rs +++ b/tests/unit/style/properties/serialization.rs @@ -1030,7 +1030,7 @@ mod shorthand_serialization { let x = block.single_value_to_css("scroll-snap-type", &mut s); assert_eq!(x.is_ok(), true); - assert_eq!(s, "scroll-snap-type: ;"); + assert_eq!(s, ""); } #[test] @@ -1052,7 +1052,7 @@ mod shorthand_serialization { let x = block.single_value_to_css("scroll-snap-type", &mut s); assert_eq!(x.is_ok(), true); - assert_eq!(s, "scroll-snap-type: mandatory;"); + assert_eq!(s, "mandatory"); } } }