use super::Printer;
use crate::ast;
use crate::whitespace::Edge;
impl<'a> Printer<'a> {
pub(super) fn print_css_rule(&mut self, rule: &ast::CssRule<'_>) {
self.print_selector_list(&rule.selector);
let kept = self.spell_gap_items(
rule.selector.span.end,
rule.block_span.start,
self.name_run_edge(rule.selector.span.end),
Edge::Flush,
);
let mut start_index = 0;
while let Some(ast::CssBlockChild::Comment(comment)) = rule.declarations.get(start_index) {
if comment.span.start >= rule.block_span.start {
break;
}
if kept.is_empty() {
self.write(" ");
self.print_css_comment(comment);
}
start_index += 1; }
if !kept.is_empty() {
self.write(&kept);
}
self.write_block_open();
self.indent_level += 1;
self.print_css_block_children(rule.declarations, start_index);
self.indent_level -= 1;
self.write_indent();
self.write_block_tail_boundary_ws(&rule.declarations[start_index..], rule.block_span);
self.write("}");
}
}