lightningcss/rules/
viewport.rs1use super::Location;
4use crate::declaration::DeclarationBlock;
5use crate::error::PrinterError;
6use crate::printer::Printer;
7use crate::traits::ToCss;
8use crate::vendor_prefix::VendorPrefix;
9#[cfg(feature = "visitor")]
10use crate::visitor::Visit;
11
12#[derive(Debug, PartialEq, Clone)]
14#[cfg_attr(feature = "visitor", derive(Visit))]
15#[cfg_attr(feature = "into_owned", derive(static_self::IntoOwned))]
16#[cfg_attr(
17 feature = "serde",
18 derive(serde::Serialize, serde::Deserialize),
19 serde(rename_all = "camelCase")
20)]
21#[cfg_attr(feature = "jsonschema", derive(schemars::JsonSchema))]
22pub struct ViewportRule<'i> {
23 #[cfg_attr(feature = "visitor", skip_visit)]
25 pub vendor_prefix: VendorPrefix,
26 #[cfg_attr(feature = "serde", serde(borrow))]
28 pub declarations: DeclarationBlock<'i>,
29 #[cfg_attr(feature = "visitor", skip_visit)]
31 pub loc: Location,
32}
33
34impl<'i> ToCss for ViewportRule<'i> {
35 fn to_css<W>(&self, dest: &mut Printer<W>) -> Result<(), PrinterError>
36 where
37 W: std::fmt::Write,
38 {
39 #[cfg(feature = "sourcemap")]
40 dest.add_mapping(self.loc);
41 dest.write_char('@')?;
42 self.vendor_prefix.to_css(dest)?;
43 dest.write_str("viewport")?;
44 self.declarations.to_css_block(dest)
45 }
46}