style/values/animated/
text.rs1use super::{Animate, Procedure, ToAnimatedZero};
8use crate::values::computed::LengthPercentage;
9use crate::values::{ComputeSquaredDistance, MallocSizeOf, SquaredDistance};
10
11#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
14pub struct TextDecorationInset {
15 pub start: LengthPercentage,
17 pub end: LengthPercentage,
19 pub is_auto: bool,
21}
22
23impl Animate for TextDecorationInset {
24 fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
25 Ok(if self.is_auto && other.is_auto {
26 self.clone()
27 } else {
28 Self {
29 start: self.start.animate(&other.start, procedure)?,
30 end: self.end.animate(&other.end, procedure)?,
31 is_auto: false,
32 }
33 })
34 }
35}
36
37impl ComputeSquaredDistance for TextDecorationInset {
38 #[inline]
39 fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
40 Ok(if self.is_auto && other.is_auto {
41 SquaredDistance::from_sqrt(0.)
42 } else {
43 self.start.compute_squared_distance(&other.start)?
44 + self.end.compute_squared_distance(&other.end)?
45 })
46 }
47}
48
49impl ToAnimatedZero for TextDecorationInset {
50 #[inline]
51 fn to_animated_zero(&self) -> Result<Self, ()> {
52 Ok(Self {
53 start: self.start.to_animated_zero()?,
54 end: self.end.to_animated_zero()?,
55 is_auto: false,
56 })
57 }
58}