tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

motion.rs (2126B)


      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::derives::*;
      8 use crate::values::computed::basic_shape::BasicShape;
      9 use crate::values::computed::url::ComputedUrl;
     10 use crate::values::computed::{Angle, LengthPercentage, Position};
     11 use crate::values::generics::motion::{
     12    GenericOffsetPath, GenericOffsetPathFunction, GenericOffsetPosition, GenericRayFunction,
     13 };
     14 use crate::Zero;
     15 
     16 /// The computed value of ray() function.
     17 pub type RayFunction = GenericRayFunction<Angle, Position>;
     18 
     19 /// The computed value of <offset-path>.
     20 pub type OffsetPathFunction = GenericOffsetPathFunction<BasicShape, RayFunction, ComputedUrl>;
     21 
     22 /// The computed value of `offset-path`.
     23 pub type OffsetPath = GenericOffsetPath<OffsetPathFunction>;
     24 
     25 /// The computed value of `offset-position`.
     26 pub type OffsetPosition = GenericOffsetPosition<LengthPercentage, LengthPercentage>;
     27 
     28 #[inline]
     29 fn is_auto_zero_angle(auto: &bool, angle: &Angle) -> bool {
     30    *auto && angle.is_zero()
     31 }
     32 
     33 /// A computed offset-rotate.
     34 #[derive(
     35    Animate,
     36    Clone,
     37    ComputeSquaredDistance,
     38    Copy,
     39    Debug,
     40    Deserialize,
     41    MallocSizeOf,
     42    PartialEq,
     43    Serialize,
     44    ToAnimatedValue,
     45    ToAnimatedZero,
     46    ToCss,
     47    ToResolvedValue,
     48    ToTyped,
     49 )]
     50 #[repr(C)]
     51 pub struct OffsetRotate {
     52    /// If auto is false, this is a fixed angle which indicates a
     53    /// constant clockwise rotation transformation applied to it by this
     54    /// specified rotation angle. Otherwise, the angle will be added to
     55    /// the angle of the direction in layout.
     56    #[animation(constant)]
     57    #[css(represents_keyword)]
     58    pub auto: bool,
     59    /// The angle value.
     60    #[css(contextual_skip_if = "is_auto_zero_angle")]
     61    pub angle: Angle,
     62 }
     63 
     64 impl OffsetRotate {
     65    /// Returns "auto 0deg".
     66    #[inline]
     67    pub fn auto() -> Self {
     68        OffsetRotate {
     69            auto: true,
     70            angle: Zero::zero(),
     71        }
     72    }
     73 }