forked from parcel-bundler/lightningcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcounter_style.rs
More file actions
34 lines (31 loc) · 1.08 KB
/
counter_style.rs
File metadata and controls
34 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//! The `@counter-style` rule.
use super::Location;
use crate::declaration::DeclarationBlock;
use crate::error::PrinterError;
use crate::printer::Printer;
use crate::traits::ToCss;
use crate::values::ident::CustomIdent;
/// A [@counter-style](https://drafts.csswg.org/css-counter-styles/#the-counter-style-rule) rule.
#[derive(Debug, PartialEq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CounterStyleRule<'i> {
/// The name of the counter style to declare.
#[cfg_attr(feature = "serde", serde(borrow))]
pub name: CustomIdent<'i>,
// TODO: eventually parse these properties
/// Declarations in the `@counter-style` rule.
pub declarations: DeclarationBlock<'i>,
/// The location of the rule in the source file.
pub loc: Location,
}
impl<'i> ToCss for CounterStyleRule<'i> {
fn to_css<W>(&self, dest: &mut Printer<W>) -> Result<(), PrinterError>
where
W: std::fmt::Write,
{
dest.add_mapping(self.loc);
dest.write_str("@counter-style ")?;
self.name.to_css(dest)?;
self.declarations.to_css_block(dest)
}
}