From cd7619dbf64493bccbab28c1ea3cb50b74c81cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 5 Sep 2020 00:42:43 +0000 Subject: [PATCH] style: Make @font-face and @counter-style serialization closer other browsers and style rules. Style rules serialize on one line and so should @font-face blocks. Part of https://github.com/w3c/csswg-drafts/issues/4828. Differential Revision: https://phabricator.services.mozilla.com/D89302 --- components/style/counter_style/mod.rs | 6 +++--- components/style/font_face.rs | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/components/style/counter_style/mod.rs b/components/style/counter_style/mod.rs index ecdc8828ec1..c7854b1ef1e 100644 --- a/components/style/counter_style/mod.rs +++ b/components/style/counter_style/mod.rs @@ -232,12 +232,12 @@ macro_rules! counter_style_descriptors { fn to_css(&self, _guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result { dest.write_str("@counter-style ")?; self.name.to_css(&mut CssWriter::new(dest))?; - dest.write_str(" {\n")?; + dest.write_str(" { ")?; $( if let Some(ref value) = self.$ident { - dest.write_str(concat!(" ", $name, ": "))?; + dest.write_str(concat!($name, ": "))?; ToCss::to_css(value, &mut CssWriter::new(dest))?; - dest.write_str(";\n")?; + dest.write_str("; ")?; } )+ dest.write_str("}") diff --git a/components/style/font_face.rs b/components/style/font_face.rs index 3ddd6b69a85..24204efc131 100644 --- a/components/style/font_face.rs +++ b/components/style/font_face.rs @@ -456,9 +456,9 @@ macro_rules! font_face_descriptors_common { pub fn decl_to_css(&self, dest: &mut CssStringWriter) -> fmt::Result { $( if let Some(ref value) = self.$ident { - dest.write_str(concat!(" ", $name, ": "))?; + dest.write_str(concat!($name, ": "))?; ToCss::to_css(value, &mut CssWriter::new(dest))?; - dest.write_str(";\n")?; + dest.write_str("; ")?; } )* Ok(()) @@ -469,8 +469,11 @@ macro_rules! font_face_descriptors_common { type Declaration = (); type Error = StyleParseErrorKind<'i>; - fn parse_value<'t>(&mut self, name: CowRcStr<'i>, input: &mut Parser<'i, 't>) - -> Result<(), ParseError<'i>> { + fn parse_value<'t>( + &mut self, + name: CowRcStr<'i>, + input: &mut Parser<'i, 't>, + ) -> Result<(), ParseError<'i>> { match_ignore_ascii_case! { &*name, $( $name if is_descriptor_enabled!($name) => { @@ -493,7 +496,7 @@ macro_rules! font_face_descriptors_common { impl ToCssWithGuard for FontFaceRuleData { // Serialization of FontFaceRule is not specced. fn to_css(&self, _guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result { - dest.write_str("@font-face {\n")?; + dest.write_str("@font-face { ")?; self.decl_to_css(dest)?; dest.write_str("}") }