font.rs (1395B)
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 //! Animation implementation for various font-related types. 6 7 use super::{Animate, Procedure, ToAnimatedZero}; 8 use crate::values::computed::font::FontVariationSettings; 9 use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; 10 11 /// <https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def> 12 /// 13 /// Note that the ComputedValue implementation will already have sorted and de-dup'd 14 /// the lists of settings, so we can just iterate over the two lists together and 15 /// animate their individual values. 16 impl Animate for FontVariationSettings { 17 #[inline] 18 fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> { 19 let result: Box<[_]> = 20 super::lists::by_computed_value::animate(&self.0, &other.0, procedure)?; 21 Ok(Self(result)) 22 } 23 } 24 25 impl ComputeSquaredDistance for FontVariationSettings { 26 #[inline] 27 fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> { 28 super::lists::by_computed_value::squared_distance(&self.0, &other.0) 29 } 30 } 31 32 impl ToAnimatedZero for FontVariationSettings { 33 #[inline] 34 fn to_animated_zero(&self) -> Result<Self, ()> { 35 Err(()) 36 } 37 }