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
35
36
37
38
39
use crate::css_rules::Location;
use crate::css_values::ident::CustomIdent;
use crate::{DeclarationBlock, PrintErr, Printer};
/// A [@counter-style](https://drafts.csswg.org/css-counter-styles/#the-counter-style-rule) rule.
pub struct CounterStyleRule {
/// The name of the counter style to declare.
pub name: CustomIdent,
/// Declarations in the `@counter-style` rule.
// PORT NOTE: `DeclarationBlock<'bump>` borrows the parser arena; lifetime
// erased to `'static` here per the rules/mod.rs `CssRule<R>` PORT NOTE.
pub declarations: DeclarationBlock<'static>,
/// The location of the rule in the source file.
pub loc: Location,
}
impl CounterStyleRule {
pub(crate) fn to_css(&self, dest: &mut Printer) -> Result<(), PrintErr> {
// #[cfg(feature = "sourcemap")]
// dest.add_mapping(self.loc);
dest.write_str("@counter-style")?;
super::custom_ident_to_css(&self.name, dest)?;
super::decl_block_to_css(&self.declarations, dest)
}
}
impl CounterStyleRule {
pub(crate) fn deep_clone(&self, bump: &bun_alloc::Arena) -> Self {
// PORT NOTE: `css.implementDeepClone` field-walk.
Self {
name: self.name.deep_clone(bump),
declarations: super::dc::decl_block_static(&self.declarations, bump),
loc: self.loc,
}
}
}
// ported from: src/css/rules/counter_style.zig