From fbdee15c5358dcda4c087c010747d730202a1a50 Mon Sep 17 00:00:00 2001 From: Kuba Pawlaczyk Date: Tue, 28 Mar 2017 21:38:42 +0200 Subject: [PATCH] Fixed #15200 - added missing comma in {background,mask}-position serialization --- .../style/properties/shorthand/background.mako.rs | 3 +++ components/style/properties/shorthand/mask.mako.rs | 4 ++++ tests/unit/style/properties/serialization.rs | 12 ++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/components/style/properties/shorthand/background.mako.rs b/components/style/properties/shorthand/background.mako.rs index a0747e9ea81..25954c768e6 100644 --- a/components/style/properties/shorthand/background.mako.rs +++ b/components/style/properties/shorthand/background.mako.rs @@ -234,6 +234,9 @@ self.background_position_x.0[i].to_css(dest)?; dest.write_str(" ")?; self.background_position_y.0[i].to_css(dest)?; + if i < len - 1 { + dest.write_str(", ")?; + } } Ok(()) } diff --git a/components/style/properties/shorthand/mask.mako.rs b/components/style/properties/shorthand/mask.mako.rs index 01caeddb9ca..e8229d59800 100644 --- a/components/style/properties/shorthand/mask.mako.rs +++ b/components/style/properties/shorthand/mask.mako.rs @@ -226,7 +226,11 @@ for i in 0..len { self.mask_position_x.0[i].to_css(dest)?; + dest.write_str(" ")?; self.mask_position_y.0[i].to_css(dest)?; + if i < len - 1 { + dest.write_str(", ")?; + } } Ok(()) diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs index 72296d9f98c..592f089651c 100644 --- a/tests/unit/style/properties/serialization.rs +++ b/tests/unit/style/properties/serialization.rs @@ -741,14 +741,14 @@ mod shorthand_serialization { // https://github.com/servo/servo/issues/15398 ) // With background, the color is one exception as it should only appear once for // multiple backgrounds. - // Below, background-position and background-origin only have one value. + // Below background-origin only has one value. let block_text = "\ background-color: rgb(0, 0, 255); \ background-image: url(\"http://servo/test.png\"), none; \ background-repeat: repeat-x, repeat-y; \ background-attachment: scroll, scroll; \ background-size: 70px 50px, 20px 30px; \ - background-position: 7px 4px; \ + background-position: 7px 4px, 5px 6px; \ background-origin: border-box; \ background-clip: padding-box, padding-box;"; let block = parse_declaration_block(block_text); @@ -905,6 +905,14 @@ mod shorthand_serialization { repeat-x padding-box subtract;" ); } + + #[test] + fn serialize_mask_position_with_multiple_values() { + let block_text = "mask-position: 1px 2px, 4px 3px;"; + let block = parse_declaration_block(block_text); + let serialization = block.to_css_string(); + assert_eq!(serialization, block_text); + } } mod scroll_snap_type {