style: Implement Animate for track lists on grid-template-{columns|rows}.

Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1348519#c6 and
https://github.com/w3c/csswg-drafts/issues/3201:

Currently grid-template-rows/columns interpolate “per computed value”, which
means that if the number of tracks differs, or any track changes to/from a
particular keyword value to any other value, or if a line name is added/removed
at any position, the entire track listing is interpolated as “discrete”.
But we "agree" with two more granular options:

1. Check interpolation type per track, rather than for the entire list, before
   falling back to discrete. I.e. a length-percentage track can animate between
   two values while an adjacent auto track flips discretely to min-content.
2. Allow discrete interpolation of line name changes independently of track
   sizes.

Besides, for the repeat() function, it's complicated to support interpolation
between different repeat types (i.e. auto-fill, auto-fit) and different repeat
counts, so we always fall-back to discrete if the first parameter of repeat()
is different.

Differential Revision: https://phabricator.services.mozilla.com/D16129
This commit is contained in:
Boris Chiou 2019-01-12 02:22:39 +00:00 committed by Emilio Cobos Álvarez
parent a8943d2ec5
commit 2b77a29697
4 changed files with 191 additions and 7 deletions

View file

@ -151,6 +151,7 @@ impl Parse for GridLine<specified::Integer> {
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(
Animate,
Clone,
Copy,
Debug,
@ -172,7 +173,16 @@ pub enum TrackKeyword {
/// avoid re-implementing it for the computed type.
///
/// <https://drafts.csswg.org/css-grid/#typedef-track-breadth>
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
#[derive(
Animate,
Clone,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
)]
pub enum TrackBreadth<L> {
/// The generic type is almost always a non-negative `<length-percentage>`
Breadth(L),
@ -481,12 +491,21 @@ impl<L: Clone> TrackRepeat<L, specified::Integer> {
}
/// Track list values. Can be <track-size> or <track-repeat>
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
#[derive(
Animate,
Clone,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss
)]
pub enum TrackListValue<LengthPercentage, Integer> {
/// A <track-size> value.
TrackSize(TrackSize<LengthPercentage>),
TrackSize(#[animation(field_bound)] TrackSize<LengthPercentage>),
/// A <track-repeat> value.
TrackRepeat(TrackRepeat<LengthPercentage, Integer>),
TrackRepeat(#[animation(field_bound)] TrackRepeat<LengthPercentage, Integer>),
}
/// The type of a `<track-list>` as determined during parsing.
@ -692,13 +711,24 @@ impl ToCss for LineNameList {
/// Variants for `<grid-template-rows> | <grid-template-columns>`
/// Subgrid deferred to Level 2 spec due to lack of implementation.
/// But it's implemented in gecko, so we have to as well.
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
#[derive(
Animate,
Clone,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss
)]
pub enum GridTemplateComponent<L, I> {
/// `none` value.
None,
/// The grid `<track-list>`
TrackList(#[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)]
Subgrid(LineNameList),
}