style/values/resolved/
animation.rs

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//! Resolved animation values.
6
7use super::{Context, ToResolvedValue};
8
9use crate::values::computed::time::Time;
10use crate::values::computed::AnimationDuration;
11
12impl ToResolvedValue for AnimationDuration {
13    type ResolvedValue = Self;
14
15    fn to_resolved_value(self, context: &Context) -> Self::ResolvedValue {
16        match self {
17            // For backwards-compatibility with Level 1, when the computed value of
18            // animation-timeline is auto (i.e. only one list value, and that value being auto),
19            // the resolved value of auto for animation-duration is 0s whenever its used value
20            // would also be 0s.
21            // https://drafts.csswg.org/css-animations-2/#animation-duration
22            Self::Auto if context.style.get_ui().has_initial_animation_timeline() => {
23                Self::Time(Time::from_seconds(0.0f32))
24            },
25            _ => self,
26        }
27    }
28
29    #[inline]
30    fn from_resolved_value(value: Self::ResolvedValue) -> Self {
31        value
32    }
33}