mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Introduce values::animated::Animate
This replaces the Animatable trait and merges its three former methods into a single one.
This commit is contained in:
parent
0cceeb9d5c
commit
aea0cd7ec7
23 changed files with 876 additions and 937 deletions
|
@ -4,9 +4,9 @@
|
|||
|
||||
//! Computed types for CSS values related to backgrounds.
|
||||
|
||||
use properties::animated_properties::{Animatable, RepeatableListAnimatable};
|
||||
use properties::animated_properties::RepeatableListAnimatable;
|
||||
use properties::longhands::background_size::computed_value::T as BackgroundSizeList;
|
||||
use values::animated::{ToAnimatedValue, ToAnimatedZero};
|
||||
use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
|
||||
use values::computed::length::LengthOrPercentageOrAuto;
|
||||
use values::generics::background::BackgroundSize as GenericBackgroundSize;
|
||||
|
||||
|
@ -15,16 +15,16 @@ pub type BackgroundSize = GenericBackgroundSize<LengthOrPercentageOrAuto>;
|
|||
|
||||
impl RepeatableListAnimatable for BackgroundSize {}
|
||||
|
||||
impl Animatable for BackgroundSize {
|
||||
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64) -> Result<Self, ()> {
|
||||
impl Animate for BackgroundSize {
|
||||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||
match (self, other) {
|
||||
(
|
||||
&GenericBackgroundSize::Explicit { width: self_width, height: self_height },
|
||||
&GenericBackgroundSize::Explicit { width: other_width, height: other_height },
|
||||
) => {
|
||||
Ok(GenericBackgroundSize::Explicit {
|
||||
width: self_width.add_weighted(&other_width, self_portion, other_portion)?,
|
||||
height: self_height.add_weighted(&other_height, self_portion, other_portion)?,
|
||||
width: self_width.animate(&other_width, procedure)?,
|
||||
height: self_height.animate(&other_height, procedure)?,
|
||||
})
|
||||
}
|
||||
_ => Err(()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue