1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 //! Computed types for CSS values that are related to motion path.
6 
7 use crate::values::computed::Angle;
8 use crate::values::generics::motion::GenericOffsetPath;
9 use crate::Zero;
10 
11 /// The computed value of `offset-path`.
12 pub type OffsetPath = GenericOffsetPath<Angle>;
13 
14 #[inline]
is_auto_zero_angle(auto: &bool, angle: &Angle) -> bool15 fn is_auto_zero_angle(auto: &bool, angle: &Angle) -> bool {
16     *auto && angle.is_zero()
17 }
18 
19 /// A computed offset-rotate.
20 #[derive(
21     Animate,
22     Clone,
23     ComputeSquaredDistance,
24     Copy,
25     Debug,
26     Deserialize,
27     MallocSizeOf,
28     PartialEq,
29     Serialize,
30     ToAnimatedZero,
31     ToCss,
32     ToResolvedValue,
33 )]
34 #[repr(C)]
35 pub struct OffsetRotate {
36     /// If auto is false, this is a fixed angle which indicates a
37     /// constant clockwise rotation transformation applied to it by this
38     /// specified rotation angle. Otherwise, the angle will be added to
39     /// the angle of the direction in layout.
40     #[animation(constant)]
41     #[css(represents_keyword)]
42     pub auto: bool,
43     /// The angle value.
44     #[css(contextual_skip_if = "is_auto_zero_angle")]
45     pub angle: Angle,
46 }
47 
48 impl OffsetRotate {
49     /// Returns "auto 0deg".
50     #[inline]
auto() -> Self51     pub fn auto() -> Self {
52         OffsetRotate {
53             auto: true,
54             angle: Zero::zero(),
55         }
56     }
57 }
58