1use crate::values::animated::ToAnimatedZero;
8use std::fmt::{self, Write};
9use style_traits::{CssWriter, ToCss};
10
11#[derive(
12 Animate,
13 Clone,
14 ComputeSquaredDistance,
15 Copy,
16 Debug,
17 FromPrimitive,
18 MallocSizeOf,
19 Parse,
20 PartialEq,
21 SpecifiedValueInfo,
22 ToAnimatedValue,
23 ToComputedValue,
24 ToCss,
25 ToResolvedValue,
26 ToShmem,
27)]
28#[repr(u8)]
29#[allow(missing_docs)]
30pub enum VerticalAlignKeyword {
31 Baseline,
32 Sub,
33 Super,
34 Top,
35 TextTop,
36 Middle,
37 Bottom,
38 TextBottom,
39 #[cfg(feature = "gecko")]
40 MozMiddleWithBaseline,
41}
42
43#[derive(
45 Animate,
46 Clone,
47 ComputeSquaredDistance,
48 Copy,
49 Debug,
50 MallocSizeOf,
51 PartialEq,
52 SpecifiedValueInfo,
53 ToAnimatedValue,
54 ToComputedValue,
55 ToCss,
56 ToResolvedValue,
57 ToShmem,
58)]
59#[repr(C, u8)]
60pub enum GenericVerticalAlign<LengthPercentage> {
61 Keyword(VerticalAlignKeyword),
63 Length(LengthPercentage),
65}
66
67pub use self::GenericVerticalAlign as VerticalAlign;
68
69impl<L> VerticalAlign<L> {
70 #[inline]
72 pub fn baseline() -> Self {
73 VerticalAlign::Keyword(VerticalAlignKeyword::Baseline)
74 }
75}
76
77impl<L> ToAnimatedZero for VerticalAlign<L> {
78 fn to_animated_zero(&self) -> Result<Self, ()> {
79 Err(())
80 }
81}
82
83#[derive(
85 Animate,
86 Clone,
87 ComputeSquaredDistance,
88 Debug,
89 MallocSizeOf,
90 PartialEq,
91 SpecifiedValueInfo,
92 ToComputedValue,
93 ToAnimatedValue,
94 ToAnimatedZero,
95 ToResolvedValue,
96 ToShmem,
97)]
98#[value_info(other_values = "auto")]
99#[repr(C, u8)]
100pub enum GenericContainIntrinsicSize<L> {
101 None,
103 AutoNone,
105 Length(L),
107 AutoLength(L),
109}
110
111pub use self::GenericContainIntrinsicSize as ContainIntrinsicSize;
112
113impl<L: ToCss> ToCss for ContainIntrinsicSize<L> {
114 fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
115 where
116 W: Write,
117 {
118 match *self {
119 Self::None => dest.write_str("none"),
120 Self::AutoNone => dest.write_str("auto none"),
121 Self::Length(ref l) => l.to_css(dest),
122 Self::AutoLength(ref l) => {
123 dest.write_str("auto ")?;
124 l.to_css(dest)
125 },
126 }
127 }
128}
129
130#[derive(
136 Clone,
137 ComputeSquaredDistance,
138 Copy,
139 Debug,
140 MallocSizeOf,
141 PartialEq,
142 SpecifiedValueInfo,
143 ToComputedValue,
144 ToAnimatedValue,
145 ToAnimatedZero,
146 ToResolvedValue,
147 ToShmem,
148)]
149#[repr(transparent)]
150#[value_info(other_values = "none")]
151pub struct GenericLineClamp<I>(pub I);
152
153pub use self::GenericLineClamp as LineClamp;
154
155impl<I: crate::Zero> LineClamp<I> {
156 pub fn none() -> Self {
158 Self(crate::Zero::zero())
159 }
160
161 pub fn is_none(&self) -> bool {
163 self.0.is_zero()
164 }
165}
166
167impl<I: crate::Zero + ToCss> ToCss for LineClamp<I> {
168 fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
169 where
170 W: Write,
171 {
172 if self.is_none() {
173 return dest.write_str("none");
174 }
175 self.0.to_css(dest)
176 }
177}
178
179#[derive(
181 Animate,
182 Clone,
183 ComputeSquaredDistance,
184 Copy,
185 Debug,
186 MallocSizeOf,
187 Parse,
188 PartialEq,
189 SpecifiedValueInfo,
190 ToAnimatedValue,
191 ToAnimatedZero,
192 ToComputedValue,
193 ToCss,
194 ToResolvedValue,
195 ToShmem,
196)]
197#[repr(C, u8)]
198pub enum GenericPerspective<NonNegativeLength> {
199 Length(NonNegativeLength),
201 None,
203}
204
205pub use self::GenericPerspective as Perspective;
206
207impl<L> Perspective<L> {
208 #[inline]
210 pub fn none() -> Self {
211 Perspective::None
212 }
213}
214
215#[derive(
216 Clone,
217 Copy,
218 Debug,
219 MallocSizeOf,
220 Parse,
221 PartialEq,
222 SpecifiedValueInfo,
223 ToComputedValue,
224 ToCss,
225 ToResolvedValue,
226 ToShmem,
227)]
228#[repr(u8)]
229#[allow(missing_docs)]
230pub enum PositionProperty {
231 Static = 0,
232 Relative,
233 Absolute,
234 Fixed,
235 Sticky,
236}
237
238impl PositionProperty {
239 pub fn is_absolutely_positioned(self) -> bool {
241 matches!(self, Self::Absolute | Self::Fixed)
242 }
243}