mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Rustfmt recent changes.
This commit is contained in:
parent
122f8ed1bb
commit
2e6d34cad9
5 changed files with 58 additions and 52 deletions
|
@ -11,15 +11,19 @@
|
||||||
// Animate for the computed types, instead of the generic types.
|
// Animate for the computed types, instead of the generic types.
|
||||||
|
|
||||||
use super::{Animate, Procedure, ToAnimatedZero};
|
use super::{Animate, Procedure, ToAnimatedZero};
|
||||||
use crate::values::computed::{GridTemplateComponent, TrackList, TrackSize};
|
|
||||||
use crate::values::computed::Integer;
|
use crate::values::computed::Integer;
|
||||||
use crate::values::computed::LengthPercentage;
|
use crate::values::computed::LengthPercentage;
|
||||||
|
use crate::values::computed::{GridTemplateComponent, TrackList, TrackSize};
|
||||||
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
|
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
|
||||||
use crate::values::generics::grid as generics;
|
use crate::values::generics::grid as generics;
|
||||||
|
|
||||||
fn discrete<T: Clone>(from: &T, to: &T, procedure: Procedure) -> Result<T, ()> {
|
fn discrete<T: Clone>(from: &T, to: &T, procedure: Procedure) -> Result<T, ()> {
|
||||||
if let Procedure::Interpolate { progress } = procedure {
|
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 {
|
} else {
|
||||||
Err(())
|
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>(
|
fn animate_with_discrete_fallback<T: Animate + Clone>(
|
||||||
from: &T,
|
from: &T,
|
||||||
to: &T,
|
to: &T,
|
||||||
procedure: Procedure
|
procedure: Procedure,
|
||||||
) -> Result<T, ()> {
|
) -> 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 {
|
impl Animate for TrackSize {
|
||||||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(&generics::TrackSize::Breadth(ref from),
|
(&generics::TrackSize::Breadth(ref from), &generics::TrackSize::Breadth(ref to)) => {
|
||||||
&generics::TrackSize::Breadth(ref to)) => {
|
|
||||||
animate_with_discrete_fallback(from, to, procedure)
|
animate_with_discrete_fallback(from, to, procedure)
|
||||||
.map(generics::TrackSize::Breadth)
|
.map(generics::TrackSize::Breadth)
|
||||||
},
|
},
|
||||||
(&generics::TrackSize::Minmax(ref from_min, ref from_max),
|
(
|
||||||
&generics::TrackSize::Minmax(ref to_min, ref to_max)) => {
|
&generics::TrackSize::Minmax(ref from_min, ref from_max),
|
||||||
Ok(generics::TrackSize::Minmax(
|
&generics::TrackSize::Minmax(ref to_min, ref to_max),
|
||||||
animate_with_discrete_fallback(from_min, to_min, procedure)?,
|
) => Ok(generics::TrackSize::Minmax(
|
||||||
animate_with_discrete_fallback(from_max, to_max, procedure)?,
|
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)) => {
|
&generics::TrackSize::FitContent(ref from),
|
||||||
animate_with_discrete_fallback(from, to, procedure)
|
&generics::TrackSize::FitContent(ref to),
|
||||||
.map(generics::TrackSize::FitContent)
|
) => animate_with_discrete_fallback(from, to, procedure)
|
||||||
},
|
.map(generics::TrackSize::FitContent),
|
||||||
(_, _) => discrete(self, other, procedure),
|
(_, _) => discrete(self, other, procedure),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,8 +76,11 @@ where
|
||||||
// length of track_sizes is the same.
|
// length of track_sizes is the same.
|
||||||
// https://github.com/w3c/csswg-drafts/issues/3503
|
// https://github.com/w3c/csswg-drafts/issues/3503
|
||||||
match (&self.count, &other.count) {
|
match (&self.count, &other.count) {
|
||||||
(&generics::RepeatCount::Number(from),
|
(&generics::RepeatCount::Number(from), &generics::RepeatCount::Number(to))
|
||||||
&generics::RepeatCount::Number(to)) if from == to => (),
|
if from == to =>
|
||||||
|
{
|
||||||
|
()
|
||||||
|
},
|
||||||
(_, _) => return Err(()),
|
(_, _) => return Err(()),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +90,8 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
let count = self.count;
|
let count = self.count;
|
||||||
let track_sizes = self.track_sizes
|
let track_sizes = self
|
||||||
|
.track_sizes
|
||||||
.iter()
|
.iter()
|
||||||
.zip(other.track_sizes.iter())
|
.zip(other.track_sizes.iter())
|
||||||
.map(|(a, b)| a.animate(b, procedure))
|
.map(|(a, b)| a.animate(b, procedure))
|
||||||
|
@ -93,7 +101,11 @@ where
|
||||||
// of |track_sizes|. Besides, <line-names> is always discrete.
|
// of |track_sizes|. Besides, <line-names> is always discrete.
|
||||||
let line_names = discrete(&self.line_names, &other.line_names, procedure)?;
|
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 list_type = self.list_type;
|
||||||
let auto_repeat = self.auto_repeat.animate(&other.auto_repeat, procedure)?;
|
let auto_repeat = self.auto_repeat.animate(&other.auto_repeat, procedure)?;
|
||||||
let values = self.values
|
let values = self
|
||||||
|
.values
|
||||||
.iter()
|
.iter()
|
||||||
.zip(other.values.iter())
|
.zip(other.values.iter())
|
||||||
.map(|(a, b)| a.animate(b, procedure))
|
.map(|(a, b)| a.animate(b, procedure))
|
||||||
|
@ -131,7 +144,12 @@ impl Animate for TrackList {
|
||||||
// of |track_sizes|. Besides, <line-names> is always discrete.
|
// of |track_sizes|. Besides, <line-names> is always discrete.
|
||||||
let line_names = discrete(&self.line_names, &other.line_names, procedure)?;
|
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,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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_::{AnimationName, Appearance, BreakBetween, BreakWithin};
|
||||||
pub use crate::values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat};
|
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_::{OverscrollBehavior, ScrollSnapType};
|
||||||
pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange};
|
pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange};
|
||||||
|
|
||||||
|
|
|
@ -174,14 +174,7 @@ pub enum TrackKeyword {
|
||||||
///
|
///
|
||||||
/// <https://drafts.csswg.org/css-grid/#typedef-track-breadth>
|
/// <https://drafts.csswg.org/css-grid/#typedef-track-breadth>
|
||||||
#[derive(
|
#[derive(
|
||||||
Animate,
|
Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
|
||||||
Clone,
|
|
||||||
Debug,
|
|
||||||
MallocSizeOf,
|
|
||||||
PartialEq,
|
|
||||||
SpecifiedValueInfo,
|
|
||||||
ToComputedValue,
|
|
||||||
ToCss,
|
|
||||||
)]
|
)]
|
||||||
pub enum TrackBreadth<L> {
|
pub enum TrackBreadth<L> {
|
||||||
/// The generic type is almost always a non-negative `<length-percentage>`
|
/// 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>
|
/// Track list values. Can be <track-size> or <track-repeat>
|
||||||
#[derive(
|
#[derive(
|
||||||
Animate,
|
Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
|
||||||
Clone,
|
|
||||||
Debug,
|
|
||||||
MallocSizeOf,
|
|
||||||
PartialEq,
|
|
||||||
SpecifiedValueInfo,
|
|
||||||
ToComputedValue,
|
|
||||||
ToCss
|
|
||||||
)]
|
)]
|
||||||
pub enum TrackListValue<LengthPercentage, Integer> {
|
pub enum TrackListValue<LengthPercentage, Integer> {
|
||||||
/// A <track-size> value.
|
/// A <track-size> value.
|
||||||
|
@ -712,20 +698,17 @@ impl ToCss for LineNameList {
|
||||||
/// Subgrid deferred to Level 2 spec due to lack of implementation.
|
/// Subgrid deferred to Level 2 spec due to lack of implementation.
|
||||||
/// But it's implemented in gecko, so we have to as well.
|
/// But it's implemented in gecko, so we have to as well.
|
||||||
#[derive(
|
#[derive(
|
||||||
Animate,
|
Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
|
||||||
Clone,
|
|
||||||
Debug,
|
|
||||||
MallocSizeOf,
|
|
||||||
PartialEq,
|
|
||||||
SpecifiedValueInfo,
|
|
||||||
ToComputedValue,
|
|
||||||
ToCss
|
|
||||||
)]
|
)]
|
||||||
pub enum GridTemplateComponent<L, I> {
|
pub enum GridTemplateComponent<L, I> {
|
||||||
/// `none` value.
|
/// `none` value.
|
||||||
None,
|
None,
|
||||||
/// The grid `<track-list>`
|
/// 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>?`
|
/// A `subgrid <line-name-list>?`
|
||||||
/// TODO: Support animations for this after subgrid is addressed in [grid-2] spec.
|
/// TODO: Support animations for this after subgrid is addressed in [grid-2] spec.
|
||||||
#[animation(error)]
|
#[animation(error)]
|
||||||
|
|
|
@ -36,7 +36,8 @@ pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
|
||||||
pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
|
pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
|
||||||
pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing, BorderStyle};
|
pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing, BorderStyle};
|
||||||
pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display};
|
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_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
|
||||||
pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange};
|
pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange};
|
||||||
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
|
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
|
||||||
|
|
|
@ -88,7 +88,10 @@ fn derive_variant_arm(
|
||||||
let field_attrs = cg::parse_field_attrs::<AnimationFieldAttrs>(&result.ast());
|
let field_attrs = cg::parse_field_attrs::<AnimationFieldAttrs>(&result.ast());
|
||||||
if field_attrs.field_bound {
|
if field_attrs.field_bound {
|
||||||
let ty = &this.ast().ty;
|
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 {
|
if field_attrs.constant {
|
||||||
quote! {
|
quote! {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue