aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/style/values/animated/grid.rs66
-rw-r--r--components/style/values/computed/box.rs3
-rw-r--r--components/style/values/generics/grid.rs33
-rw-r--r--components/style/values/specified/mod.rs3
-rw-r--r--components/style_derive/animate.rs5
5 files changed, 58 insertions, 52 deletions
diff --git a/components/style/values/animated/grid.rs b/components/style/values/animated/grid.rs
index 0943e97cef3..2b59f32e437 100644
--- a/components/style/values/animated/grid.rs
+++ b/components/style/values/animated/grid.rs
@@ -11,15 +11,19 @@
// Animate for the computed types, instead of the generic types.
use super::{Animate, Procedure, ToAnimatedZero};
-use crate::values::computed::{GridTemplateComponent, TrackList, TrackSize};
use crate::values::computed::Integer;
use crate::values::computed::LengthPercentage;
+use crate::values::computed::{GridTemplateComponent, TrackList, TrackSize};
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
use crate::values::generics::grid as generics;
fn discrete<T: Clone>(from: &T, to: &T, procedure: Procedure) -> Result<T, ()> {
if let Procedure::Interpolate { progress } = procedure {
- Ok(if progress < 0.5 { from.clone() } else { to.clone() })
+ Ok(if progress < 0.5 {
+ from.clone()
+ } else {
+ to.clone()
+ })
} else {
Err(())
}
@@ -28,31 +32,31 @@ fn discrete<T: Clone>(from: &T, to: &T, procedure: Procedure) -> Result<T, ()> {
fn animate_with_discrete_fallback<T: Animate + Clone>(
from: &T,
to: &T,
- procedure: Procedure
+ procedure: Procedure,
) -> Result<T, ()> {
- from.animate(to, procedure).or_else(|_| discrete(from, to, procedure))
+ from.animate(to, procedure)
+ .or_else(|_| discrete(from, to, procedure))
}
impl Animate for TrackSize {
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
match (self, other) {
- (&generics::TrackSize::Breadth(ref from),
- &generics::TrackSize::Breadth(ref to)) => {
+ (&generics::TrackSize::Breadth(ref from), &generics::TrackSize::Breadth(ref to)) => {
animate_with_discrete_fallback(from, to, procedure)
.map(generics::TrackSize::Breadth)
},
- (&generics::TrackSize::Minmax(ref from_min, ref from_max),
- &generics::TrackSize::Minmax(ref to_min, ref to_max)) => {
- Ok(generics::TrackSize::Minmax(
- animate_with_discrete_fallback(from_min, to_min, procedure)?,
- animate_with_discrete_fallback(from_max, to_max, procedure)?,
- ))
- },
- (&generics::TrackSize::FitContent(ref from),
- &generics::TrackSize::FitContent(ref to)) => {
- animate_with_discrete_fallback(from, to, procedure)
- .map(generics::TrackSize::FitContent)
- },
+ (
+ &generics::TrackSize::Minmax(ref from_min, ref from_max),
+ &generics::TrackSize::Minmax(ref to_min, ref to_max),
+ ) => Ok(generics::TrackSize::Minmax(
+ animate_with_discrete_fallback(from_min, to_min, procedure)?,
+ animate_with_discrete_fallback(from_max, to_max, procedure)?,
+ )),
+ (
+ &generics::TrackSize::FitContent(ref from),
+ &generics::TrackSize::FitContent(ref to),
+ ) => animate_with_discrete_fallback(from, to, procedure)
+ .map(generics::TrackSize::FitContent),
(_, _) => discrete(self, other, procedure),
}
}
@@ -72,8 +76,11 @@ where
// length of track_sizes is the same.
// https://github.com/w3c/csswg-drafts/issues/3503
match (&self.count, &other.count) {
- (&generics::RepeatCount::Number(from),
- &generics::RepeatCount::Number(to)) if from == to => (),
+ (&generics::RepeatCount::Number(from), &generics::RepeatCount::Number(to))
+ if from == to =>
+ {
+ ()
+ },
(_, _) => return Err(()),
}
@@ -83,7 +90,8 @@ where
}
let count = self.count;
- let track_sizes = self.track_sizes
+ let track_sizes = self
+ .track_sizes
.iter()
.zip(other.track_sizes.iter())
.map(|(a, b)| a.animate(b, procedure))
@@ -93,7 +101,11 @@ where
// of |track_sizes|. Besides, <line-names> is always discrete.
let line_names = discrete(&self.line_names, &other.line_names, procedure)?;
- Ok(generics::TrackRepeat { count, line_names, track_sizes })
+ Ok(generics::TrackRepeat {
+ count,
+ line_names,
+ track_sizes,
+ })
}
}
@@ -122,7 +134,8 @@ impl Animate for TrackList {
let list_type = self.list_type;
let auto_repeat = self.auto_repeat.animate(&other.auto_repeat, procedure)?;
- let values = self.values
+ let values = self
+ .values
.iter()
.zip(other.values.iter())
.map(|(a, b)| a.animate(b, procedure))
@@ -131,7 +144,12 @@ impl Animate for TrackList {
// of |track_sizes|. Besides, <line-names> is always discrete.
let line_names = discrete(&self.line_names, &other.line_names, procedure)?;
- Ok(TrackList { list_type, values, line_names, auto_repeat })
+ Ok(TrackList {
+ list_type,
+ values,
+ line_names,
+ auto_repeat,
+ })
}
}
diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs
index 89935e2b4d4..38d021d9829 100644
--- a/components/style/values/computed/box.rs
+++ b/components/style/values/computed/box.rs
@@ -13,7 +13,8 @@ use crate::values::specified::box_ as specified;
pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween, BreakWithin};
pub use crate::values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat};
-pub use crate::values::specified::box_::{Contain, Display, Overflow, OverflowAnchor, OverflowClipBox};
+pub use crate::values::specified::box_::{Contain, Display, Overflow};
+pub use crate::values::specified::box_::{OverflowAnchor, OverflowClipBox};
pub use crate::values::specified::box_::{OverscrollBehavior, ScrollSnapType};
pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange};
diff --git a/components/style/values/generics/grid.rs b/components/style/values/generics/grid.rs
index 38516c7a6c4..7dbee9b8dbe 100644
--- a/components/style/values/generics/grid.rs
+++ b/components/style/values/generics/grid.rs
@@ -174,14 +174,7 @@ pub enum TrackKeyword {
///
/// <https://drafts.csswg.org/css-grid/#typedef-track-breadth>
#[derive(
- Animate,
- Clone,
- Debug,
- MallocSizeOf,
- PartialEq,
- SpecifiedValueInfo,
- ToComputedValue,
- ToCss,
+ Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
)]
pub enum TrackBreadth<L> {
/// The generic type is almost always a non-negative `<length-percentage>`
@@ -492,14 +485,7 @@ impl<L: Clone> TrackRepeat<L, specified::Integer> {
/// Track list values. Can be <track-size> or <track-repeat>
#[derive(
- Animate,
- Clone,
- Debug,
- MallocSizeOf,
- PartialEq,
- SpecifiedValueInfo,
- ToComputedValue,
- ToCss
+ Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
)]
pub enum TrackListValue<LengthPercentage, Integer> {
/// A <track-size> value.
@@ -712,20 +698,17 @@ impl ToCss for LineNameList {
/// Subgrid deferred to Level 2 spec due to lack of implementation.
/// But it's implemented in gecko, so we have to as well.
#[derive(
- Animate,
- Clone,
- Debug,
- MallocSizeOf,
- PartialEq,
- SpecifiedValueInfo,
- ToComputedValue,
- ToCss
+ Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
)]
pub enum GridTemplateComponent<L, I> {
/// `none` value.
None,
/// The grid `<track-list>`
- TrackList(#[animation(field_bound)] #[compute(field_bound)] TrackList<L, I>),
+ TrackList(
+ #[animation(field_bound)]
+ #[compute(field_bound)]
+ TrackList<L, I>,
+ ),
/// A `subgrid <line-name-list>?`
/// TODO: Support animations for this after subgrid is addressed in [grid-2] spec.
#[animation(error)]
diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs
index d2015f714b5..2cb267045ac 100644
--- a/components/style/values/specified/mod.rs
+++ b/components/style/values/specified/mod.rs
@@ -36,7 +36,8 @@ pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing, BorderStyle};
pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display};
-pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float, Overflow, OverflowAnchor};
+pub use self::box_::{Appearance, BreakBetween, BreakWithin};
+pub use self::box_::{Clear, Float, Overflow, OverflowAnchor};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange};
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
diff --git a/components/style_derive/animate.rs b/components/style_derive/animate.rs
index 6686d2f4453..d9674e444c3 100644
--- a/components/style_derive/animate.rs
+++ b/components/style_derive/animate.rs
@@ -88,7 +88,10 @@ fn derive_variant_arm(
let field_attrs = cg::parse_field_attrs::<AnimationFieldAttrs>(&result.ast());
if field_attrs.field_bound {
let ty = &this.ast().ty;
- cg::add_predicate(where_clause, parse_quote!(#ty: crate::values::animated::Animate));
+ cg::add_predicate(
+ where_clause,
+ parse_quote!(#ty: crate::values::animated::Animate),
+ );
}
if field_attrs.constant {
quote! {