style: Use write_char in place of write_str when serializing single-character literals

Generated by running

  find servo/components/style -name "*.rs" -exec perl -p -i -e "s/write_str\(\"(.)\"\)/write_char('\1')/g" {} \;

(and then added `use std::fmt::Write;` in a couple of places to fix build errors that arose).

Differential Revision: https://phabricator.services.mozilla.com/D168217
This commit is contained in:
Jonathan Kew 2023-01-29 22:01:28 +00:00 committed by Martin Robinson
parent 05fb1b62b7
commit 8a2cfc0b24
52 changed files with 131 additions and 129 deletions

View file

@ -244,7 +244,7 @@ macro_rules! counter_style_descriptors {
dest.write_str("; ")?; dest.write_str("; ")?;
} }
)+ )+
dest.write_str("}") dest.write_char('}')
} }
} }
} }

View file

@ -306,7 +306,7 @@ macro_rules! impl_range {
{ {
self.0.to_css(dest)?; self.0.to_css(dest)?;
if self.0 != self.1 { if self.0 != self.1 {
dest.write_str(" ")?; dest.write_char(' ')?;
self.1.to_css(dest)?; self.1.to_css(dest)?;
} }
Ok(()) Ok(())
@ -714,7 +714,7 @@ impl ToCssWithGuard for FontFaceRuleData {
fn to_css(&self, _guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result { fn to_css(&self, _guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
dest.write_str("@font-face { ")?; dest.write_str("@font-face { ")?;
self.decl_to_css(dest)?; self.decl_to_css(dest)?;
dest.write_str("}") dest.write_char('}')
} }
} }

View file

@ -11,6 +11,7 @@ use servo_arc::Arc;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::{fmt, mem, ptr}; use std::{fmt, mem, ptr};
use std::fmt::Write;
/// Trait for all objects that have Addref() and Release /// Trait for all objects that have Addref() and Release
/// methods and can be placed inside RefPtr<T> /// methods and can be placed inside RefPtr<T>
@ -35,7 +36,7 @@ impl<T: RefCounted> fmt::Debug for RefPtr<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RefPtr { ")?; f.write_str("RefPtr { ")?;
self.ptr.fmt(f)?; self.ptr.fmt(f)?;
f.write_str("}") f.write_char('}')
} }
} }

View file

@ -14,6 +14,7 @@ use selectors::parser::{Combinator, Component};
use selectors::OpaqueElement; use selectors::OpaqueElement;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::fmt; use std::fmt;
use std::fmt::Write;
/// A trait to abstract the collection of invalidations for a given pass. /// A trait to abstract the collection of invalidations for a given pass.
pub trait InvalidationProcessor<'a, E> pub trait InvalidationProcessor<'a, E>
@ -257,7 +258,7 @@ impl<'a> fmt::Debug for Invalidation<'a> {
} }
component.to_css(f)?; component.to_css(f)?;
} }
f.write_str(")") f.write_char(')')
} }
} }

View file

@ -39,7 +39,7 @@ impl ToCss for PiecewiseLinearFunctionEntry {
W: fmt::Write, W: fmt::Write,
{ {
self.y.to_css(dest)?; self.y.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
Percentage(self.x).to_css(dest) Percentage(self.x).to_css(dest)
} }
} }

View file

@ -1183,7 +1183,7 @@ where
W: Write, W: Write,
{ {
if !*is_first_serialization { if !*is_first_serialization {
dest.write_str(" ") dest.write_char(' ')
} else { } else {
*is_first_serialization = false; *is_first_serialization = false;
Ok(()) Ok(())

View file

@ -865,7 +865,7 @@
first.to_css(dest)?; first.to_css(dest)?;
if first != second { if first != second {
dest.write_str(" ")?; dest.write_char(' ')?;
second.to_css(dest)?; second.to_css(dest)?;
} }
Ok(()) Ok(())

View file

@ -134,10 +134,10 @@ pub mod shorthands {
width.to_css(dest)?; width.to_css(dest)?;
// FIXME(emilio): Should we really serialize the border style if it's // FIXME(emilio): Should we really serialize the border style if it's
// `solid`? // `solid`?
dest.write_str(" ")?; dest.write_char(' ')?;
style.to_css(dest)?; style.to_css(dest)?;
if *color != Color::CurrentColor { if *color != Color::CurrentColor {
dest.write_str(" ")?; dest.write_char(' ')?;
color.to_css(dest)?; color.to_css(dest)?;
} }
Ok(()) Ok(())

View file

@ -167,7 +167,7 @@
if *image != background_image::single_value::get_initial_specified_value() { if *image != background_image::single_value::get_initial_specified_value() {
if wrote_value { if wrote_value {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
image.to_css(dest)?; image.to_css(dest)?;
wrote_value = true; wrote_value = true;
@ -180,7 +180,7 @@
*size != background_size::single_value::get_initial_specified_value() *size != background_size::single_value::get_initial_specified_value()
{ {
if wrote_value { if wrote_value {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
Position { Position {
@ -199,7 +199,7 @@
% for name in "repeat attachment".split(): % for name in "repeat attachment".split():
if *${name} != background_${name}::single_value::get_initial_specified_value() { if *${name} != background_${name}::single_value::get_initial_specified_value() {
if wrote_value { if wrote_value {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
${name}.to_css(dest)?; ${name}.to_css(dest)?;
wrote_value = true; wrote_value = true;
@ -208,11 +208,11 @@
if *origin != Origin::PaddingBox || *clip != Clip::BorderBox { if *origin != Origin::PaddingBox || *clip != Clip::BorderBox {
if wrote_value { if wrote_value {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
origin.to_css(dest)?; origin.to_css(dest)?;
if *clip != From::from(*origin) { if *clip != From::from(*origin) {
dest.write_str(" ")?; dest.write_char(' ')?;
clip.to_css(dest)?; clip.to_css(dest)?;
} }

View file

@ -373,13 +373,13 @@ pub fn parse_border<'i, 't>(
impl<'a> ToCss for LonghandsToSerialize<'a> { impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
self.border_image_source.to_css(dest)?; self.border_image_source.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
self.border_image_slice.to_css(dest)?; self.border_image_slice.to_css(dest)?;
dest.write_str(" / ")?; dest.write_str(" / ")?;
self.border_image_width.to_css(dest)?; self.border_image_width.to_css(dest)?;
dest.write_str(" / ")?; dest.write_str(" / ")?;
self.border_image_outset.to_css(dest)?; self.border_image_outset.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
self.border_image_repeat.to_css(dest) self.border_image_repeat.to_css(dest)
} }
} }
@ -420,7 +420,7 @@ pub fn parse_border<'i, 't>(
self.border_${axis}_start_${prop}.to_css(dest)?; self.border_${axis}_start_${prop}.to_css(dest)?;
if self.border_${axis}_end_${prop} != self.border_${axis}_start_${prop} { if self.border_${axis}_end_${prop} != self.border_${axis}_start_${prop} {
dest.write_str(" ")?; dest.write_char(' ')?;
self.border_${axis}_end_${prop}.to_css(dest)?; self.border_${axis}_end_${prop}.to_css(dest)?;
} }

View file

@ -203,12 +203,12 @@ ${helpers.two_properties_shorthand(
self.offset_path.to_css(dest)?; self.offset_path.to_css(dest)?;
if !self.offset_distance.is_zero() { if !self.offset_distance.is_zero() {
dest.write_str(" ")?; dest.write_char(' ')?;
self.offset_distance.to_css(dest)?; self.offset_distance.to_css(dest)?;
} }
if !self.offset_rotate.is_auto() { if !self.offset_rotate.is_auto() {
dest.write_str(" ")?; dest.write_char(' ')?;
self.offset_rotate.to_css(dest)?; self.offset_rotate.to_css(dest)?;
} }

View file

@ -227,13 +227,13 @@
% for name in "style variant_caps weight".split(): % for name in "style variant_caps weight".split():
if self.font_${name} != &font_${name}::get_initial_specified_value() { if self.font_${name} != &font_${name}::get_initial_specified_value() {
self.font_${name}.to_css(dest)?; self.font_${name}.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
} }
% endfor % endfor
if font_stretch != FontStretchKeyword::Normal { if font_stretch != FontStretchKeyword::Normal {
font_stretch.to_css(dest)?; font_stretch.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
} }
self.font_size.to_css(dest)?; self.font_size.to_css(dest)?;
@ -243,7 +243,7 @@
self.line_height.to_css(dest)?; self.line_height.to_css(dest)?;
} }
dest.write_str(" ")?; dest.write_char(' ')?;
self.font_family.to_css(dest)?; self.font_family.to_css(dest)?;
Ok(()) Ok(())
@ -443,7 +443,7 @@
% endif % endif
if value != &font_variant_${prop}::get_initial_specified_value() { if value != &font_variant_${prop}::get_initial_specified_value() {
if has_any { if has_any {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
has_any = true; has_any = true;
value.to_css(dest)?; value.to_css(dest)?;

View file

@ -120,7 +120,7 @@
} }
if self.list_style_image != &ListStyleImage::None { if self.list_style_image != &ListStyleImage::None {
if have_one_non_initial_value { if have_one_non_initial_value {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
self.list_style_image.to_css(dest)?; self.list_style_image.to_css(dest)?;
have_one_non_initial_value = true; have_one_non_initial_value = true;
@ -131,7 +131,7 @@
let type_is_initial = self.list_style_type == &ListStyleType::Disc; let type_is_initial = self.list_style_type == &ListStyleType::Disc;
if !type_is_initial { if !type_is_initial {
if have_one_non_initial_value { if have_one_non_initial_value {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
self.list_style_type.to_css(dest)?; self.list_style_type.to_css(dest)?;
have_one_non_initial_value = true; have_one_non_initial_value = true;

View file

@ -138,7 +138,7 @@
self.row_gap.to_css(dest) self.row_gap.to_css(dest)
} else { } else {
self.row_gap.to_css(dest)?; self.row_gap.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
self.column_gap.to_css(dest) self.column_gap.to_css(dest)
} }
} }
@ -497,7 +497,7 @@
.zip(&mut names_iter) .zip(&mut names_iter)
.zip(track_list.values.iter()) { .zip(track_list.values.iter()) {
if i > 0 { if i > 0 {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
if !names.is_empty() { if !names.is_empty() {
@ -508,7 +508,7 @@
// If the track size is the initial value then it's redundant here. // If the track size is the initial value then it's redundant here.
if !value.is_initial() { if !value.is_initial() {
dest.write_str(" ")?; dest.write_char(' ')?;
value.to_css(dest)?; value.to_css(dest)?;
} }
} }
@ -665,7 +665,7 @@
} }
if !self.grid_auto_columns.is_initial() { if !self.grid_auto_columns.is_initial() {
dest.write_str(" ")?; dest.write_char(' ')?;
self.grid_auto_columns.to_css(dest)?; self.grid_auto_columns.to_css(dest)?;
} }
@ -691,7 +691,7 @@
} }
if !self.grid_auto_rows.is_initial() { if !self.grid_auto_rows.is_initial() {
dest.write_str(" ")?; dest.write_char(' ')?;
self.grid_auto_rows.to_css(dest)?; self.grid_auto_rows.to_css(dest)?;
} }
@ -749,7 +749,7 @@
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
self.align_content.to_css(dest)?; self.align_content.to_css(dest)?;
if self.align_content.0 != self.justify_content.0 { if self.align_content.0 != self.justify_content.0 {
dest.write_str(" ")?; dest.write_char(' ')?;
self.justify_content.to_css(dest)?; self.justify_content.to_css(dest)?;
} }
Ok(()) Ok(())
@ -790,7 +790,7 @@
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
self.align_self.to_css(dest)?; self.align_self.to_css(dest)?;
if self.align_self.0 != self.justify_self.0 { if self.align_self.0 != self.justify_self.0 {
dest.write_str(" ")?; dest.write_char(' ')?;
self.justify_self.to_css(dest)?; self.justify_self.to_css(dest)?;
} }
Ok(()) Ok(())
@ -832,7 +832,7 @@
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
self.align_items.to_css(dest)?; self.align_items.to_css(dest)?;
if self.align_items.0 != self.justify_items.0 { if self.align_items.0 != self.justify_items.0 {
dest.write_str(" ")?; dest.write_char(' ')?;
self.justify_items.to_css(dest)?; self.justify_items.to_css(dest)?;
} }

View file

@ -150,7 +150,7 @@
image.to_css(dest)?; image.to_css(dest)?;
if *mode != mask_mode::single_value::get_initial_specified_value() { if *mode != mask_mode::single_value::get_initial_specified_value() {
dest.write_str(" ")?; dest.write_char(' ')?;
mode.to_css(dest)?; mode.to_css(dest)?;
} }
@ -158,7 +158,7 @@
*position_y != PositionComponent::zero() || *position_y != PositionComponent::zero() ||
*size != mask_size::single_value::get_initial_specified_value() *size != mask_size::single_value::get_initial_specified_value()
{ {
dest.write_str(" ")?; dest.write_char(' ')?;
Position { Position {
horizontal: position_x.clone(), horizontal: position_x.clone(),
vertical: position_y.clone() vertical: position_y.clone()
@ -171,21 +171,21 @@
} }
if *repeat != mask_repeat::single_value::get_initial_specified_value() { if *repeat != mask_repeat::single_value::get_initial_specified_value() {
dest.write_str(" ")?; dest.write_char(' ')?;
repeat.to_css(dest)?; repeat.to_css(dest)?;
} }
if *origin != Origin::BorderBox || *clip != Clip::BorderBox { if *origin != Origin::BorderBox || *clip != Clip::BorderBox {
dest.write_str(" ")?; dest.write_char(' ')?;
origin.to_css(dest)?; origin.to_css(dest)?;
if *clip != From::from(*origin) { if *clip != From::from(*origin) {
dest.write_str(" ")?; dest.write_char(' ')?;
clip.to_css(dest)?; clip.to_css(dest)?;
} }
} }
if *composite != mask_composite::single_value::get_initial_specified_value() { if *composite != mask_composite::single_value::get_initial_specified_value() {
dest.write_str(" ")?; dest.write_char(' ')?;
composite.to_css(dest)?; composite.to_css(dest)?;
} }
} }

View file

@ -91,7 +91,7 @@
% if engine == "gecko": % if engine == "gecko":
if !is_auto_thickness { if !is_auto_thickness {
if has_value { if has_value {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
self.text_decoration_thickness.to_css(dest)?; self.text_decoration_thickness.to_css(dest)?;
has_value = true; has_value = true;
@ -99,7 +99,7 @@
if !is_solid_style { if !is_solid_style {
if has_value { if has_value {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
self.text_decoration_style.to_css(dest)?; self.text_decoration_style.to_css(dest)?;
has_value = true; has_value = true;
@ -107,7 +107,7 @@
if !is_current_color { if !is_current_color {
if has_value { if has_value {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
self.text_decoration_color.to_css(dest)?; self.text_decoration_color.to_css(dest)?;
has_value = true; has_value = true;

View file

@ -154,7 +154,7 @@ macro_rules! try_parse_one {
self.transition_property.0[i].to_css(dest)?; self.transition_property.0[i].to_css(dest)?;
} }
% for name in "duration timing_function delay".split(): % for name in "duration timing_function delay".split():
dest.write_str(" ")?; dest.write_char(' ')?;
self.transition_${name}.0[i].to_css(dest)?; self.transition_${name}.0[i].to_css(dest)?;
% endfor % endfor
} }
@ -289,7 +289,7 @@ macro_rules! try_parse_one {
% for name in props[2:]: % for name in props[2:]:
self.animation_${name}.0[i].to_css(dest)?; self.animation_${name}.0[i].to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
% endfor % endfor
self.animation_name.0[i].to_css(dest)?; self.animation_name.0[i].to_css(dest)?;

View file

@ -263,7 +263,7 @@ impl ToCss for QueryFeatureExpression {
where where
W: fmt::Write, W: fmt::Write,
{ {
dest.write_str("(")?; dest.write_char('(')?;
match self.kind { match self.kind {
QueryFeatureExpressionKind::Empty => self.write_name(dest)?, QueryFeatureExpressionKind::Empty => self.write_name(dest)?,

View file

@ -129,7 +129,7 @@ where
T: Debug, T: Debug,
{ {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("[")?; f.write_char('[')?;
let mut first = true; let mut first = true;
for entry in self.entries.iter() { for entry in self.entries.iter() {
if !first { if !first {
@ -138,7 +138,7 @@ where
first = false; first = false;
entry.fmt(f)?; entry.fmt(f)?;
} }
f.write_str("]") f.write_char(']')
} }
} }

View file

@ -337,7 +337,7 @@ impl ToCss for NonTSPseudoClass {
if let Lang(ref lang) = *self { if let Lang(ref lang) = *self {
dest.write_str(":lang(")?; dest.write_str(":lang(")?;
serialize_identifier(lang, dest)?; serialize_identifier(lang, dest)?;
return dest.write_str(")"); return dest.write_char(')');
} }
dest.write_str(match *self { dest.write_str(match *self {

View file

@ -158,7 +158,7 @@ impl ToCss for CssUrl {
dest.write_str("url(")?; dest.write_str("url(")?;
string.to_css(dest)?; string.to_css(dest)?;
dest.write_str(")") dest.write_char(')')
} }
} }
@ -230,7 +230,7 @@ impl ToCss for ComputedUrl {
dest.write_str("url(")?; dest.write_str("url(")?;
string.to_css(dest)?; string.to_css(dest)?;
dest.write_str(")") dest.write_char(')')
} }
} }

View file

@ -47,7 +47,7 @@ impl ToCssWithGuard for DocumentRule {
self.condition.to_css(&mut CssWriter::new(dest))?; self.condition.to_css(&mut CssWriter::new(dest))?;
dest.write_str(" {")?; dest.write_str(" {")?;
for rule in self.rules.read_with(guard).0.iter() { for rule in self.rules.read_with(guard).0.iter() {
dest.write_str(" ")?; dest.write_char(' ')?;
rule.to_css(guard, dest)?; rule.to_css(guard, dest)?;
} }
dest.write_str(" }") dest.write_str(" }")

View file

@ -46,7 +46,7 @@ impl<T: ToCss> ToCss for FFVDeclaration<T> {
serialize_atom_identifier(&self.name, dest)?; serialize_atom_identifier(&self.name, dest)?;
dest.write_str(": ")?; dest.write_str(": ")?;
self.value.to_css(dest)?; self.value.to_css(dest)?;
dest.write_str(";") dest.write_char(';')
} }
} }
@ -335,7 +335,7 @@ macro_rules! font_feature_values_blocks {
self.family_names.to_css(&mut CssWriter::new(dest))?; self.family_names.to_css(&mut CssWriter::new(dest))?;
dest.write_str(" {\n")?; dest.write_str(" {\n")?;
self.value_to_css(&mut CssWriter::new(dest))?; self.value_to_css(&mut CssWriter::new(dest))?;
dest.write_str("}") dest.write_char('}')
} }
} }

View file

@ -61,7 +61,7 @@ impl ToCss for FontPaletteOverrideColor {
W: fmt::Write, W: fmt::Write,
{ {
self.index.to_css(dest)?; self.index.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
self.color.to_css(dest) self.color.to_css(dest)
} }
} }
@ -200,7 +200,7 @@ impl ToCssWithGuard for FontPaletteValuesRule {
self.name.to_css(&mut CssWriter::new(dest))?; self.name.to_css(&mut CssWriter::new(dest))?;
dest.write_str(" { ")?; dest.write_str(" { ")?;
self.value_to_css(&mut CssWriter::new(dest))?; self.value_to_css(&mut CssWriter::new(dest))?;
dest.write_str("}") dest.write_char('}')
} }
} }

View file

@ -71,9 +71,9 @@ impl ToCssWithGuard for StyleRule {
declaration_block.to_css(dest)?; declaration_block.to_css(dest)?;
// Step 4 // Step 4
if !declaration_block.declarations().is_empty() { if !declaration_block.declarations().is_empty() {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
// Step 5 // Step 5
dest.write_str("}") dest.write_char('}')
} }
} }

View file

@ -296,9 +296,9 @@ impl ToCss for SupportsCondition {
cond.to_css(dest) cond.to_css(dest)
}, },
SupportsCondition::Parenthesized(ref cond) => { SupportsCondition::Parenthesized(ref cond) => {
dest.write_str("(")?; dest.write_char('(')?;
cond.to_css(dest)?; cond.to_css(dest)?;
dest.write_str(")") dest.write_char(')')
}, },
SupportsCondition::And(ref vec) => { SupportsCondition::And(ref vec) => {
let mut first = true; let mut first = true;
@ -323,31 +323,31 @@ impl ToCss for SupportsCondition {
Ok(()) Ok(())
}, },
SupportsCondition::Declaration(ref decl) => { SupportsCondition::Declaration(ref decl) => {
dest.write_str("(")?; dest.write_char('(')?;
decl.to_css(dest)?; decl.to_css(dest)?;
dest.write_str(")") dest.write_char(')')
}, },
SupportsCondition::Selector(ref selector) => { SupportsCondition::Selector(ref selector) => {
dest.write_str("selector(")?; dest.write_str("selector(")?;
selector.to_css(dest)?; selector.to_css(dest)?;
dest.write_str(")") dest.write_char(')')
}, },
SupportsCondition::MozBoolPref(ref name) => { SupportsCondition::MozBoolPref(ref name) => {
dest.write_str("-moz-bool-pref(")?; dest.write_str("-moz-bool-pref(")?;
let name = let name =
str::from_utf8(name.as_bytes()).expect("Should be parsed from valid UTF-8"); str::from_utf8(name.as_bytes()).expect("Should be parsed from valid UTF-8");
name.to_css(dest)?; name.to_css(dest)?;
dest.write_str(")") dest.write_char(')')
}, },
SupportsCondition::FontFormat(ref kw) => { SupportsCondition::FontFormat(ref kw) => {
dest.write_str("font-format(")?; dest.write_str("font-format(")?;
kw.to_css(dest)?; kw.to_css(dest)?;
dest.write_str(")") dest.write_char(')')
}, },
SupportsCondition::FontTech(ref flag) => { SupportsCondition::FontTech(ref flag) => {
dest.write_str("font-tech(")?; dest.write_str("font-tech(")?;
flag.to_css(dest)?; flag.to_css(dest)?;
dest.write_str(")") dest.write_char(')')
}, },
SupportsCondition::FutureSyntax(ref s) => dest.write_str(&s), SupportsCondition::FutureSyntax(ref s) => dest.write_str(&s),
} }

View file

@ -108,7 +108,7 @@ macro_rules! declare_viewport_descriptor_inner {
}, },
)* )*
} }
dest.write_str(";") dest.write_char(';')
} }
} }
}; };
@ -504,7 +504,7 @@ impl ToCssWithGuard for ViewportRule {
let mut iter = self.declarations.iter(); let mut iter = self.declarations.iter();
iter.next().unwrap().to_css(&mut CssWriter::new(dest))?; iter.next().unwrap().to_css(&mut CssWriter::new(dest))?;
for declaration in iter { for declaration in iter {
dest.write_str(" ")?; dest.write_char(' ')?;
declaration.to_css(&mut CssWriter::new(dest))?; declaration.to_css(&mut CssWriter::new(dest))?;
} }
dest.write_str(" }") dest.write_str(" }")

View file

@ -177,7 +177,7 @@ impl generic::LineDirection for LineDirection {
dest.write_str("to ")?; dest.write_str("to ")?;
} }
x.to_css(dest)?; x.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
y.to_css(dest) y.to_css(dest)
}, },
} }

View file

@ -53,7 +53,7 @@ impl ToCss for Position {
W: Write, W: Write,
{ {
self.horizontal.to_css(dest)?; self.horizontal.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
self.vertical.to_css(dest) self.vertical.to_css(dest)
} }
} }

View file

@ -161,7 +161,7 @@ impl ToCss for TextOverflow {
self.second.to_css(dest)?; self.second.to_css(dest)?;
} else { } else {
self.first.to_css(dest)?; self.first.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
self.second.to_css(dest)?; self.second.to_css(dest)?;
} }
Ok(()) Ok(())

View file

@ -40,6 +40,6 @@ impl ToCss for Time {
W: Write, W: Write,
{ {
self.seconds().to_css(dest)?; self.seconds().to_css(dest)?;
dest.write_str("s") dest.write_char('s')
} }
} }

View file

@ -418,7 +418,7 @@ where
dest.write_str(" round ")?; dest.write_str(" round ")?;
self.round.to_css(dest)?; self.round.to_css(dest)?;
} }
dest.write_str(")") dest.write_char(')')
} }
} }
@ -434,11 +434,11 @@ where
dest.write_str("circle(")?; dest.write_str("circle(")?;
if self.radius != Default::default() { if self.radius != Default::default() {
self.radius.to_css(dest)?; self.radius.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
} }
dest.write_str("at ")?; dest.write_str("at ")?;
self.position.to_css(dest)?; self.position.to_css(dest)?;
dest.write_str(")") dest.write_char(')')
} }
} }
@ -454,13 +454,13 @@ where
dest.write_str("ellipse(")?; dest.write_str("ellipse(")?;
if self.semiaxis_x != Default::default() || self.semiaxis_y != Default::default() { if self.semiaxis_x != Default::default() || self.semiaxis_y != Default::default() {
self.semiaxis_x.to_css(dest)?; self.semiaxis_x.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
self.semiaxis_y.to_css(dest)?; self.semiaxis_y.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
} }
dest.write_str("at ")?; dest.write_str("at ")?;
self.position.to_css(dest)?; self.position.to_css(dest)?;
dest.write_str(")") dest.write_char(')')
} }
} }

View file

@ -1078,7 +1078,7 @@ impl<L: CalcNodeLeaf> CalcNode<L> {
} }
if write_closing_paren { if write_closing_paren {
dest.write_str(")")?; dest.write_char(')')?;
} }
Ok(()) Ok(())
} }

View file

@ -230,16 +230,16 @@ impl<Color: ToCss, Percentage: ToCss + ToPercentage> ToCss for ColorMix<Color, P
dest.write_str(", ")?; dest.write_str(", ")?;
self.left.to_css(dest)?; self.left.to_css(dest)?;
if !can_omit(&self.left_percentage, &self.right_percentage, true) { if !can_omit(&self.left_percentage, &self.right_percentage, true) {
dest.write_str(" ")?; dest.write_char(' ')?;
self.left_percentage.to_css(dest)?; self.left_percentage.to_css(dest)?;
} }
dest.write_str(", ")?; dest.write_str(", ")?;
self.right.to_css(dest)?; self.right.to_css(dest)?;
if !can_omit(&self.right_percentage, &self.left_percentage, false) { if !can_omit(&self.right_percentage, &self.left_percentage, false) {
dest.write_str(" ")?; dest.write_char(' ')?;
self.right_percentage.to_css(dest)?; self.right_percentage.to_css(dest)?;
} }
dest.write_str(")") dest.write_char(')')
} }
} }

View file

@ -50,12 +50,12 @@ where
} }
self.name.to_css(dest)?; self.name.to_css(dest)?;
if self.is_reversed { if self.is_reversed {
dest.write_str(")")?; dest.write_char(')')?;
if self.value == i32::min_value() { if self.value == i32::min_value() {
return Ok(()); return Ok(());
} }
} }
dest.write_str(" ")?; dest.write_char(' ')?;
self.value.to_css(dest) self.value.to_css(dest)
} }
} }

View file

@ -109,14 +109,14 @@ where
if !self.line_num.is_zero() { if !self.line_num.is_zero() {
if self.is_span { if self.is_span {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
self.line_num.to_css(dest)?; self.line_num.to_css(dest)?;
} }
if self.ident != atom!("") { if self.ident != atom!("") {
if self.is_span || !self.line_num.is_zero() { if self.is_span || !self.line_num.is_zero() {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
CustomIdent(self.ident.clone()).to_css(dest)?; CustomIdent(self.ident.clone()).to_css(dest)?;
} }
@ -341,12 +341,12 @@ impl<L: ToCss> ToCss for TrackSize<L> {
min.to_css(dest)?; min.to_css(dest)?;
dest.write_str(", ")?; dest.write_str(", ")?;
max.to_css(dest)?; max.to_css(dest)?;
dest.write_str(")") dest.write_char(')')
}, },
TrackSize::FitContent(ref lp) => { TrackSize::FitContent(ref lp) => {
dest.write_str("fit-content(")?; dest.write_str("fit-content(")?;
lp.to_css(dest)?; lp.to_css(dest)?;
dest.write_str(")") dest.write_char(')')
}, },
} }
} }
@ -493,7 +493,7 @@ impl<L: ToCss, I: ToCss> ToCss for TrackRepeat<L, I> {
.enumerate() .enumerate()
{ {
if i > 0 { if i > 0 {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
concat_serialize_idents("[", "] ", names, " ", dest)?; concat_serialize_idents("[", "] ", names, " ", dest)?;
@ -504,7 +504,7 @@ impl<L: ToCss, I: ToCss> ToCss for TrackRepeat<L, I> {
concat_serialize_idents(" [", "]", line_names_last, " ", dest)?; concat_serialize_idents(" [", "]", line_names_last, " ", dest)?;
} }
dest.write_str(")")?; dest.write_char(')')?;
Ok(()) Ok(())
} }
@ -615,7 +615,7 @@ impl<L: ToCss, I: ToCss> ToCss for TrackList<L, I> {
match values_iter.next() { match values_iter.next() {
Some(value) => { Some(value) => {
if !names.is_empty() { if !names.is_empty() {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
value.to_css(dest)?; value.to_css(dest)?;
@ -627,7 +627,7 @@ impl<L: ToCss, I: ToCss> ToCss for TrackList<L, I> {
line_names_iter.peek().map_or(false, |v| !v.is_empty()) || line_names_iter.peek().map_or(false, |v| !v.is_empty()) ||
(idx + 1 == self.auto_repeat_index) (idx + 1 == self.auto_repeat_index)
{ {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
} }
@ -753,14 +753,14 @@ impl ToCss for LineNameList {
if let Some((ref first, rest)) = names.split_first() { if let Some((ref first, rest)) = names.split_first() {
first.to_css(dest)?; first.to_css(dest)?;
for name in rest { for name in rest {
dest.write_str(" ")?; dest.write_char(' ')?;
name.to_css(dest)?; name.to_css(dest)?;
} }
} }
dest.write_str("]")?; dest.write_char(']')?;
if fill_len > 0 && i == fill_start + fill_len - 1 { if fill_len > 0 && i == fill_start + fill_len - 1 {
dest.write_str(")")?; dest.write_char(')')?;
} }
} }

View file

@ -142,14 +142,14 @@ impl<I: style_traits::ToCss, R: style_traits::ToCss> ToCss for GenericImageSetIt
W: fmt::Write, W: fmt::Write,
{ {
self.image.to_css(dest)?; self.image.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
self.resolution.to_css(dest)?; self.resolution.to_css(dest)?;
if self.has_mime_type { if self.has_mime_type {
dest.write_str(" ")?; dest.write_char(' ')?;
dest.write_str("type(")?; dest.write_str("type(")?;
self.mime_type.to_css(dest)?; self.mime_type.to_css(dest)?;
dest.write_str(")")?; dest.write_char(')')?;
} }
Ok(()) Ok(())
} }
@ -369,7 +369,7 @@ impl ToCss for PaintWorklet {
dest.write_str(", ")?; dest.write_str(", ")?;
argument.to_css(dest)?; argument.to_css(dest)?;
} }
dest.write_str(")") dest.write_char(')')
} }
} }
@ -433,7 +433,7 @@ where
Image::Element(ref selector) => { Image::Element(ref selector) => {
dest.write_str("-moz-element(#")?; dest.write_str("-moz-element(#")?;
serialize_atom_identifier(selector, dest)?; serialize_atom_identifier(selector, dest)?;
dest.write_str(")") dest.write_char(')')
}, },
Image::ImageSet(ref is) => is.to_css(dest), Image::ImageSet(ref is) => is.to_css(dest),
Image::CrossFade(ref cf) => cf.to_css(dest), Image::CrossFade(ref cf) => cf.to_css(dest),
@ -520,7 +520,7 @@ where
if !omit_shape { if !omit_shape {
shape.to_css(dest)?; shape.to_css(dest)?;
if !omit_position { if !omit_position {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
} }
if !omit_position { if !omit_position {
@ -560,7 +560,7 @@ where
dest.write_str("from ")?; dest.write_str("from ")?;
angle.to_css(dest)?; angle.to_css(dest)?;
if !omit_position { if !omit_position {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
} }
if !omit_position { if !omit_position {
@ -577,7 +577,7 @@ where
} }
}, },
} }
dest.write_str(")") dest.write_char(')')
} }
} }

View file

@ -110,17 +110,17 @@ where
if same_vertical && same_horizontal && self.0 == self.1 { if same_vertical && same_horizontal && self.0 == self.1 {
return Ok(()); return Ok(());
} }
dest.write_str(" ")?; dest.write_char(' ')?;
self.1.to_css(dest)?; self.1.to_css(dest)?;
if same_vertical && same_horizontal { if same_vertical && same_horizontal {
return Ok(()); return Ok(());
} }
dest.write_str(" ")?; dest.write_char(' ')?;
self.2.to_css(dest)?; self.2.to_css(dest)?;
if same_horizontal { if same_horizontal {
return Ok(()); return Ok(());
} }
dest.write_str(" ")?; dest.write_char(' ')?;
self.3.to_css(dest) self.3.to_css(dest)
} }
} }

View file

@ -80,7 +80,7 @@ where
self.width.to_css(dest)?; self.width.to_css(dest)?;
if self.height != self.width { if self.height != self.width {
dest.write_str(" ")?; dest.write_char(' ')?;
self.height.to_css(dest)?; self.height.to_css(dest)?;
} }

View file

@ -79,9 +79,9 @@ impl<Image: ToCss, Number: ToCss> ToCss for CursorImage<Image, Number> {
{ {
self.image.to_css(dest)?; self.image.to_css(dest)?;
if self.has_hotspot { if self.has_hotspot {
dest.write_str(" ")?; dest.write_char(' ')?;
self.hotspot_x.to_css(dest)?; self.hotspot_x.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
self.hotspot_y.to_css(dest)?; self.hotspot_y.to_css(dest)?;
} }
Ok(()) Ok(())

View file

@ -360,7 +360,7 @@ where
W: Write, W: Write,
{ {
(value * 100.).to_css(dest)?; (value * 100.).to_css(dest)?;
dest.write_str("%") dest.write_char('%')
} }
/// Convenience void type to disable some properties and values through types. /// Convenience void type to disable some properties and values through types.

View file

@ -97,7 +97,7 @@ impl ToCss for Angle {
} }
self.value.to_css(dest)?; self.value.to_css(dest)?;
if self.was_calc { if self.was_calc {
dest.write_str(")")?; dest.write_char(')')?;
} }
Ok(()) Ok(())
} }

View file

@ -102,7 +102,7 @@ impl ToCss for BackgroundRepeat {
(horizontal, vertical) => { (horizontal, vertical) => {
horizontal.to_css(dest)?; horizontal.to_css(dest)?;
if horizontal != vertical { if horizontal != vertical {
dest.write_str(" ")?; dest.write_char(' ')?;
vertical.to_css(dest)?; vertical.to_css(dest)?;
} }
Ok(()) Ok(())

View file

@ -278,7 +278,7 @@ impl ToCss for BorderImageRepeat {
{ {
self.0.to_css(dest)?; self.0.to_css(dest)?;
if self.0 != self.1 { if self.0 != self.1 {
dest.write_str(" ")?; dest.write_char(' ')?;
self.1.to_css(dest)?; self.1.to_css(dest)?;
} }
Ok(()) Ok(())

View file

@ -400,11 +400,11 @@ impl ToCss for Display {
if self.is_list_item() { if self.is_list_item() {
if outside != DisplayOutside::Block { if outside != DisplayOutside::Block {
outside.to_css(dest)?; outside.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
} }
if inside != DisplayInside::Flow { if inside != DisplayInside::Flow {
inside.to_css(dest)?; inside.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
} }
dest.write_str("list-item") dest.write_str("list-item")
} else { } else {
@ -969,7 +969,7 @@ impl ToCss for ScrollSnapType {
} }
self.axis.to_css(dest)?; self.axis.to_css(dest)?;
if self.strictness != ScrollSnapStrictness::Proximity { if self.strictness != ScrollSnapStrictness::Proximity {
dest.write_str(" ")?; dest.write_char(' ')?;
self.strictness.to_css(dest)?; self.strictness.to_css(dest)?;
} }
Ok(()) Ok(())
@ -1054,7 +1054,7 @@ impl ToCss for ScrollSnapAlign {
{ {
self.block.to_css(dest)?; self.block.to_css(dest)?;
if self.block != self.inline { if self.block != self.inline {
dest.write_str(" ")?; dest.write_char(' ')?;
self.inline.to_css(dest)?; self.inline.to_css(dest)?;
} }
Ok(()) Ok(())

View file

@ -947,7 +947,7 @@ impl generic::LineDirection for LineDirection {
dest.write_str("to ")?; dest.write_str("to ")?;
} }
x.to_css(dest)?; x.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
y.to_css(dest) y.to_css(dest)
}, },
} }

View file

@ -319,7 +319,7 @@ impl ToCss for Number {
} }
self.value.to_css(dest)?; self.value.to_css(dest)?;
if self.calc_clamping_mode.is_some() { if self.calc_clamping_mode.is_some() {
dest.write_str(")")?; dest.write_char(')')?;
} }
Ok(()) Ok(())
} }
@ -702,7 +702,7 @@ impl ToCss for Integer {
} }
self.value.to_css(dest)?; self.value.to_css(dest)?;
if self.was_calc { if self.was_calc {
dest.write_str(")")?; dest.write_char(')')?;
} }
Ok(()) Ok(())
} }
@ -950,9 +950,9 @@ impl ToCss for Attr {
dest.write_str("attr(")?; dest.write_str("attr(")?;
if !self.namespace_prefix.is_empty() { if !self.namespace_prefix.is_empty() {
serialize_atom_identifier(&self.namespace_prefix, dest)?; serialize_atom_identifier(&self.namespace_prefix, dest)?;
dest.write_str("|")?; dest.write_char('|')?;
} }
serialize_atom_identifier(&self.attribute, dest)?; serialize_atom_identifier(&self.attribute, dest)?;
dest.write_str(")") dest.write_char(')')
} }
} }

View file

@ -40,7 +40,7 @@ impl ToCss for Percentage {
serialize_percentage(self.value, dest)?; serialize_percentage(self.value, dest)?;
if self.calc_clamping_mode.is_some() { if self.calc_clamping_mode.is_some() {
dest.write_str(")")?; dest.write_char(')')?;
} }
Ok(()) Ok(())
} }

View file

@ -224,12 +224,12 @@ impl ToCss for Position {
) => { ) => {
dest.write_str("left ")?; dest.write_str("left ")?;
x_lp.to_css(dest)?; x_lp.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
y_pos.to_css(dest) y_pos.to_css(dest)
}, },
(x_pos, y_pos) => { (x_pos, y_pos) => {
x_pos.to_css(dest)?; x_pos.to_css(dest)?;
dest.write_str(" ")?; dest.write_char(' ')?;
y_pos.to_css(dest) y_pos.to_css(dest)
}, },
} }

View file

@ -239,7 +239,7 @@ impl ToCss for SVGPaintOrder {
for pos in 0..last_pos_to_serialize + 1 { for pos in 0..last_pos_to_serialize + 1 {
if pos != 0 { if pos != 0 {
dest.write_str(" ")? dest.write_char(' ')?
} }
self.order_at(pos).to_css(dest)?; self.order_at(pos).to_css(dest)?;
} }

View file

@ -373,7 +373,7 @@ impl ToCss for TextTransform {
if self.case_ != TextTransformCase::None { if self.case_ != TextTransformCase::None {
self.case_.to_css(dest)?; self.case_.to_css(dest)?;
if !self.other_.is_empty() { if !self.other_.is_empty() {
dest.write_str(" ")?; dest.write_char(' ')?;
} }
} }

View file

@ -159,7 +159,7 @@ impl ToCss for Time {
match self.unit { match self.unit {
TimeUnit::Second => { TimeUnit::Second => {
self.seconds.to_css(dest)?; self.seconds.to_css(dest)?;
dest.write_str("s")?; dest.write_char('s')?;
}, },
TimeUnit::Millisecond => { TimeUnit::Millisecond => {
(self.seconds * 1000.).to_css(dest)?; (self.seconds * 1000.).to_css(dest)?;
@ -167,7 +167,7 @@ impl ToCss for Time {
}, },
} }
if self.was_calc { if self.was_calc {
dest.write_str(")")?; dest.write_char(')')?;
} }
Ok(()) Ok(())
} }