lewp_css/domain/at_rules/page/
page_at_rule.rs1use {
5 super::PageSelectorPseudoClass,
6 crate::domain::{
7 properties::{Importance, PropertyDeclaration, PropertyDeclarations},
8 HasPropertyDeclarations,
9 },
10 cssparser::ToCss,
11 std::fmt,
12};
13
14#[derive(Default, Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
18pub struct PageAtRule {
19 pub page_selector_pseudo_class: Option<PageSelectorPseudoClass>,
20
21 pub property_declarations: PropertyDeclarations<Importance>,
23}
24
25impl ToCss for PageAtRule {
26 fn to_css<W: fmt::Write>(&self, dest: &mut W) -> fmt::Result {
27 dest.write_str("@page")?;
28 if let Some(ref page_selector_pseudo_class) =
29 self.page_selector_pseudo_class
30 {
31 dest.write_char(' ')?;
32 page_selector_pseudo_class.to_css(dest)?;
33 }
34 dest.write_char('{')?;
35 self.property_declarations.to_css(dest)?;
36 dest.write_char('}')
37 }
38}
39
40impl HasPropertyDeclarations<Importance> for PageAtRule {
41 #[inline(always)]
42 fn property_declarations(&self) -> &PropertyDeclarations<Importance> {
43 &self.property_declarations
44 }
45
46 #[inline(always)]
47 fn property_declarations_mut(
48 &mut self,
49 ) -> &mut PropertyDeclarations<Importance> {
50 &mut self.property_declarations
51 }
52
53 #[inline(always)]
54 fn property_declarations_slice(
55 &self,
56 ) -> &[PropertyDeclaration<Importance>] {
57 &self.property_declarations.0[..]
58 }
59
60 #[inline(always)]
61 fn property_declarations_vec(
62 &self,
63 ) -> &Vec<PropertyDeclaration<Importance>> {
64 &self.property_declarations.0
65 }
66
67 #[inline(always)]
68 fn property_declarations_vec_mut(
69 &mut self,
70 ) -> &mut Vec<PropertyDeclaration<Importance>> {
71 &mut self.property_declarations.0
72 }
73}