style/values/generics/
easing.rs1use crate::derives::*;
9
10#[derive(
12 Clone,
13 Debug,
14 MallocSizeOf,
15 PartialEq,
16 SpecifiedValueInfo,
17 ToCss,
18 ToShmem,
19 Serialize,
20 Deserialize,
21)]
22#[value_info(ty = "TIMING_FUNCTION")]
23#[repr(u8, C)]
24pub enum TimingFunction<Integer, Number, LinearStops> {
25 Keyword(TimingKeyword),
27 #[allow(missing_docs)]
29 #[css(comma, function)]
30 CubicBezier {
31 x1: Number,
32 y1: Number,
33 x2: Number,
34 y2: Number,
35 },
36 #[css(comma, function)]
39 #[value_info(other_values = "step-start,step-end")]
40 Steps(Integer, #[css(skip_if = "is_end")] StepPosition),
41 #[css(function = "linear")]
45 LinearFunction(LinearStops),
46}
47
48#[allow(missing_docs)]
49#[derive(
50 Clone,
51 Copy,
52 Debug,
53 Eq,
54 MallocSizeOf,
55 Parse,
56 PartialEq,
57 SpecifiedValueInfo,
58 ToComputedValue,
59 ToCss,
60 ToResolvedValue,
61 ToShmem,
62 Serialize,
63 Deserialize,
64)]
65#[repr(u8)]
66pub enum TimingKeyword {
67 Linear,
68 Ease,
69 EaseIn,
70 EaseOut,
71 EaseInOut,
72}
73
74#[allow(missing_docs)]
77#[derive(PartialEq)]
78#[repr(u8)]
79pub enum BeforeFlag {
80 Unset,
81 Set,
82}
83
84#[allow(missing_docs)]
85#[derive(
86 Clone,
87 Copy,
88 Debug,
89 Eq,
90 MallocSizeOf,
91 Parse,
92 PartialEq,
93 ToComputedValue,
94 ToCss,
95 ToResolvedValue,
96 ToShmem,
97 Serialize,
98 Deserialize,
99)]
100#[repr(u8)]
101pub enum StepPosition {
102 JumpStart,
103 JumpEnd,
104 JumpNone,
105 JumpBoth,
106 Start,
107 End,
108}
109
110#[inline]
111fn is_end(position: &StepPosition) -> bool {
112 *position == StepPosition::JumpEnd || *position == StepPosition::End
113}
114
115impl<Integer, Number, LinearStops> TimingFunction<Integer, Number, LinearStops> {
116 #[inline]
118 pub fn ease() -> Self {
119 TimingFunction::Keyword(TimingKeyword::Ease)
120 }
121
122 #[inline]
124 pub fn is_ease(&self) -> bool {
125 matches!(*self, TimingFunction::Keyword(TimingKeyword::Ease))
126 }
127}