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 ToTyped,
59)]
60#[repr(C, u8)]
61pub enum GenericVerticalAlign<LengthPercentage> {
62 Keyword(VerticalAlignKeyword),
64 Length(LengthPercentage),
66}
67
68pub use self::GenericVerticalAlign as VerticalAlign;
69
70impl<L> VerticalAlign<L> {
71 #[inline]
73 pub fn baseline() -> Self {
74 VerticalAlign::Keyword(VerticalAlignKeyword::Baseline)
75 }
76}
77
78impl<L> ToAnimatedZero for VerticalAlign<L> {
79 fn to_animated_zero(&self) -> Result<Self, ()> {
80 Err(())
81 }
82}
83
84#[derive(
86 Animate,
87 Clone,
88 ComputeSquaredDistance,
89 Debug,
90 MallocSizeOf,
91 PartialEq,
92 SpecifiedValueInfo,
93 ToComputedValue,
94 ToAnimatedValue,
95 ToAnimatedZero,
96 ToResolvedValue,
97 ToShmem,
98 ToTyped,
99)]
100#[value_info(other_values = "auto")]
101#[repr(C, u8)]
102pub enum GenericContainIntrinsicSize<L> {
103 None,
105 AutoNone,
107 Length(L),
109 AutoLength(L),
111}
112
113pub use self::GenericContainIntrinsicSize as ContainIntrinsicSize;
114
115impl<L: ToCss> ToCss for ContainIntrinsicSize<L> {
116 fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
117 where
118 W: Write,
119 {
120 match *self {
121 Self::None => dest.write_str("none"),
122 Self::AutoNone => dest.write_str("auto none"),
123 Self::Length(ref l) => l.to_css(dest),
124 Self::AutoLength(ref l) => {
125 dest.write_str("auto ")?;
126 l.to_css(dest)
127 },
128 }
129 }
130}
131
132#[derive(
138 Clone,
139 ComputeSquaredDistance,
140 Copy,
141 Debug,
142 MallocSizeOf,
143 PartialEq,
144 SpecifiedValueInfo,
145 ToComputedValue,
146 ToAnimatedValue,
147 ToAnimatedZero,
148 ToResolvedValue,
149 ToShmem,
150 ToTyped,
151)]
152#[repr(transparent)]
153#[value_info(other_values = "none")]
154pub struct GenericLineClamp<I>(pub I);
155
156pub use self::GenericLineClamp as LineClamp;
157
158impl<I: crate::Zero> LineClamp<I> {
159 pub fn none() -> Self {
161 Self(crate::Zero::zero())
162 }
163
164 pub fn is_none(&self) -> bool {
166 self.0.is_zero()
167 }
168}
169
170impl<I: crate::Zero + ToCss> ToCss for LineClamp<I> {
171 fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
172 where
173 W: Write,
174 {
175 if self.is_none() {
176 return dest.write_str("none");
177 }
178 self.0.to_css(dest)
179 }
180}
181
182#[derive(
184 Animate,
185 Clone,
186 ComputeSquaredDistance,
187 Copy,
188 Debug,
189 MallocSizeOf,
190 Parse,
191 PartialEq,
192 SpecifiedValueInfo,
193 ToAnimatedValue,
194 ToAnimatedZero,
195 ToComputedValue,
196 ToCss,
197 ToResolvedValue,
198 ToShmem,
199 ToTyped,
200)]
201#[repr(C, u8)]
202pub enum GenericPerspective<NonNegativeLength> {
203 Length(NonNegativeLength),
205 None,
207}
208
209pub use self::GenericPerspective as Perspective;
210
211impl<L> Perspective<L> {
212 #[inline]
214 pub fn none() -> Self {
215 Perspective::None
216 }
217}
218
219#[derive(
220 Clone,
221 Copy,
222 Debug,
223 MallocSizeOf,
224 Parse,
225 PartialEq,
226 SpecifiedValueInfo,
227 ToComputedValue,
228 ToCss,
229 ToResolvedValue,
230 ToShmem,
231 ToTyped,
232)]
233#[repr(u8)]
234#[allow(missing_docs)]
235pub enum PositionProperty {
236 Static = 0,
237 Relative,
238 Absolute,
239 Fixed,
240 Sticky,
241}
242
243impl PositionProperty {
244 pub fn is_absolutely_positioned(self) -> bool {
246 matches!(self, Self::Absolute | Self::Fixed)
247 }
248}