lewp_css/domain/at_rules/keyframes/
keyframe.rs

1// This file is part of css. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/css/master/COPYRIGHT. No part of predicator, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
2// Copyright © 2017 The developers of css. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/css/master/COPYRIGHT.
3
4use {
5    super::KeyframeSelector,
6    crate::domain::{
7        properties::{
8            DoesNotHaveImportance,
9            PropertyDeclaration,
10            PropertyDeclarations,
11        },
12        HasPropertyDeclarations,
13    },
14    cssparser::ToCss,
15    std::fmt,
16};
17
18/// A keyframe.
19#[derive(Debug, Clone)]
20pub struct Keyframe {
21    /// The selector this keyframe was specified from.
22    pub selector: KeyframeSelector,
23
24    /// The declaration block that was declared inside this keyframe.
25    pub property_declarations: PropertyDeclarations<DoesNotHaveImportance>,
26}
27
28impl ToCss for Keyframe {
29    fn to_css<W: fmt::Write>(&self, dest: &mut W) -> fmt::Result {
30        self.selector.to_css(dest)?;
31        dest.write_char('{')?;
32        self.property_declarations.to_css(dest)?;
33        dest.write_char('}')?;
34        Ok(())
35    }
36}
37
38impl HasPropertyDeclarations<DoesNotHaveImportance> for Keyframe {
39    #[inline(always)]
40    fn property_declarations(
41        &self,
42    ) -> &PropertyDeclarations<DoesNotHaveImportance> {
43        &self.property_declarations
44    }
45
46    #[inline(always)]
47    fn property_declarations_mut(
48        &mut self,
49    ) -> &mut PropertyDeclarations<DoesNotHaveImportance> {
50        &mut self.property_declarations
51    }
52
53    #[inline(always)]
54    fn property_declarations_slice(
55        &self,
56    ) -> &[PropertyDeclaration<DoesNotHaveImportance>] {
57        &self.property_declarations.0[..]
58    }
59
60    #[inline(always)]
61    fn property_declarations_vec(
62        &self,
63    ) -> &Vec<PropertyDeclaration<DoesNotHaveImportance>> {
64        &self.property_declarations.0
65    }
66
67    #[inline(always)]
68    fn property_declarations_vec_mut(
69        &mut self,
70    ) -> &mut Vec<PropertyDeclaration<DoesNotHaveImportance>> {
71        &mut self.property_declarations.0
72    }
73}