Bug 226174 - [css-grid] Add discrete animation support for grid-template-columns|rows
Summary: [css-grid] Add discrete animation support for grid-template-columns|rows
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 204580
  Show dependency treegraph
 
Reported: 2021-05-24 05:24 PDT by zsun
Modified: 2021-05-27 12:52 PDT (History)
11 users (show)

See Also:


Attachments
Patch (242.49 KB, patch)
2021-05-24 05:45 PDT, zsun
no flags Details | Formatted Diff | Diff
Patch (233.00 KB, patch)
2021-05-25 05:50 PDT, zsun
no flags Details | Formatted Diff | Diff
Patch (236.11 KB, patch)
2021-05-25 06:09 PDT, zsun
no flags Details | Formatted Diff | Diff
Patch (233.99 KB, patch)
2021-05-26 05:03 PDT, zsun
no flags Details | Formatted Diff | Diff
Patch (231.97 KB, patch)
2021-05-27 03:07 PDT, zsun
no flags Details | Formatted Diff | Diff
Patch (231.94 KB, patch)
2021-05-27 07:17 PDT, zsun
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zsun 2021-05-24 05:24:01 PDT
We need to add discrete animation support for grid-template-columns|rows. This is the first step for Bug 204580.
Comment 1 zsun 2021-05-24 05:45:25 PDT
Created attachment 429527 [details]
Patch
Comment 2 Oriol Brufau 2021-05-24 09:09:24 PDT
Comment on attachment 429527 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429527&action=review

> Source/WebCore/animation/CSSPropertyAnimation.cpp:700
> +class GridTemplateColumnsWrapper final : public AnimationPropertyWrapperBase {

These 2 classes are almost identical. Maybe you could merge them into e.g. GridTemplateTracksWrapper? And then use something like

  new GridTemplateTracksWrapper(CSSPropertyGridTemplateColumns, &RenderStyle::gridColumns, &RenderStyle::setGridColumns, &RenderStyle::gridAutoRepeatColumns, &RenderStyle::setGridAutoRepeatColumns),
  new GridTemplateTracksWrapper(CSSPropertyGridTemplateRows, &RenderStyle::gridRows, &RenderStyle::setGridRows, &RenderStyle::gridAutoRepeatRows, &RenderStyle::setGridAutoRepeatRows),

> Source/WebCore/animation/CSSPropertyAnimation.cpp:707
> +    {        

Nit: remove trailing spaces

> Source/WebCore/animation/CSSPropertyAnimation.cpp:743
> +    {        

Nit: remove trailing spaces
Comment 3 zsun 2021-05-25 05:50:20 PDT
Created attachment 429648 [details]
Patch
Comment 4 zsun 2021-05-25 06:09:26 PDT
Created attachment 429650 [details]
Patch
Comment 5 Oriol Brufau 2021-05-25 10:52:47 PDT
Comment on attachment 429650 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429650&action=review

> Source/WebCore/animation/CSSPropertyAnimation.cpp:709
> +        , m_orderedNamedGridColumnLinesWrapper(DiscretePropertyWrapper<const OrderedNamedGridLinesMap&>(CSSPropertyGridTemplateColumns, &RenderStyle::orderedNamedGridColumnLines, &RenderStyle::setOrderedNamedGridColumnLines))

This may also need the named grid lines inside an auto-repeat: autoRepeatOrderedNamedGridColumnLines(), setAutoRepeatOrderedNamedGridColumnLines()

> Source/cmake/OptionsGTK.cmake:73
> +#WEBKIT_OPTION_DEFINE(USE_AVIF "Whether to enable support for AVIF images." PUBLIC ${ENABLE_EXPERIMENTAL_FEATURES})

The changes in this file seem unrelated
Comment 6 zsun 2021-05-26 05:03:53 PDT
Created attachment 429749 [details]
Patch
Comment 7 Antoine Quint 2021-05-26 05:28:23 PDT
Oriol commented earlier that the two classes should be refactored into a single class and I second that comment.
Comment 8 zsun 2021-05-26 07:07:26 PDT
(In reply to Antoine Quint from comment #7)
> Oriol commented earlier that the two classes should be refactored into a
> single class and I second that comment.

Thanks for the comments! Oriol and I had a private discussion on this. If we unify them into a single class, We will have to pass a lot arguments over to the the unified class, for the moment, around 13. We thought maybe just leave them separated?
Comment 9 Oriol Brufau 2021-05-26 07:49:14 PDT
(In reply to zsun from comment #8)
> Thanks for the comments! Oriol and I had a private discussion on this. If we
> unify them into a single class, We will have to pass a lot arguments over to
> the the unified class, for the moment, around 13. We thought maybe just
> leave them separated?

Thinking more about this, rather than passing all the functions as arguments to the constructor, I guess you could define a template class, and then specialize with different constructors. Something like

template <GridTrackSizingDirection>
class GridTemplateTracksWrapper : public AnimationPropertyWrapperBase {
    WTF_MAKE_FAST_ALLOCATED;
public:
    GridTemplateTracksWrapper();

private:
    // ... common logic
};

template <>
GridTemplateTracksWrapper<ForColumns>::GridTemplateTracksWrapper()
    : AnimationPropertyWrapperBase(CSSPropertyGridTemplateColumns)
    , m_gridTracksWrapper(DiscretePropertyWrapper<const Vector<GridTrackSize>&>(CSSPropertyGridTemplateColumns, &RenderStyle::gridColumns, &RenderStyle::setGridColumns))
    , m_autoRepeatTracksWrapper(DiscretePropertyWrapper<const Vector<GridTrackSize>&>(CSSPropertyGridTemplateColumns, &RenderStyle::gridAutoRepeatColumns, &RenderStyle::setGridAutoRepeatColumns))
    // ...
    {
    }

template <>
GridTemplateTracksWrapper<ForRows>::GridTemplateTracksWrapper()
    : AnimationPropertyWrapperBase(CSSPropertyGridTemplateRows)
    , m_gridTracksWrapper(DiscretePropertyWrapper<const Vector<GridTrackSize>&>(CSSPropertyGridTemplateRows, &RenderStyle::gridRows, &RenderStyle::setGridRows))
    , m_autoRepeatTracksWrapper(DiscretePropertyWrapper<const Vector<GridTrackSize>&>(CSSPropertyGridTemplateRows, &RenderStyle::gridAutoRepeatRows, &RenderStyle::setGridAutoRepeatRows))
    // ...
    {
    }

GridTrackSizingDirection is defined in GridPositionsResolver.h, you could also create another enum here I guess.
Comment 10 zsun 2021-05-27 03:07:44 PDT
Created attachment 429861 [details]
Patch
Comment 11 zsun 2021-05-27 03:23:17 PDT
(In reply to Oriol Brufau from comment #9)
> (In reply to zsun from comment #8)
> > Thanks for the comments! Oriol and I had a private discussion on this. If we
> > unify them into a single class, We will have to pass a lot arguments over to
> > the the unified class, for the moment, around 13. We thought maybe just
> > leave them separated?
> 
> Thinking more about this, rather than passing all the functions as arguments
> to the constructor, I guess you could define a template class, and then
> specialize with different constructors. Something like
> 
> template <GridTrackSizingDirection>
> class GridTemplateTracksWrapper : public AnimationPropertyWrapperBase {
>     WTF_MAKE_FAST_ALLOCATED;
> public:
>     GridTemplateTracksWrapper();
> 
> private:
>     // ... common logic
> };
> 
> template <>
> GridTemplateTracksWrapper<ForColumns>::GridTemplateTracksWrapper()
>     : AnimationPropertyWrapperBase(CSSPropertyGridTemplateColumns)
>     , m_gridTracksWrapper(DiscretePropertyWrapper<const
> Vector<GridTrackSize>&>(CSSPropertyGridTemplateColumns,
> &RenderStyle::gridColumns, &RenderStyle::setGridColumns))
>     , m_autoRepeatTracksWrapper(DiscretePropertyWrapper<const
> Vector<GridTrackSize>&>(CSSPropertyGridTemplateColumns,
> &RenderStyle::gridAutoRepeatColumns, &RenderStyle::setGridAutoRepeatColumns))
>     // ...
>     {
>     }
> 
> template <>
> GridTemplateTracksWrapper<ForRows>::GridTemplateTracksWrapper()
>     : AnimationPropertyWrapperBase(CSSPropertyGridTemplateRows)
>     , m_gridTracksWrapper(DiscretePropertyWrapper<const
> Vector<GridTrackSize>&>(CSSPropertyGridTemplateRows, &RenderStyle::gridRows,
> &RenderStyle::setGridRows))
>     , m_autoRepeatTracksWrapper(DiscretePropertyWrapper<const
> Vector<GridTrackSize>&>(CSSPropertyGridTemplateRows,
> &RenderStyle::gridAutoRepeatRows, &RenderStyle::setGridAutoRepeatRows))
>     // ...
>     {
>     }
> 
> GridTrackSizingDirection is defined in GridPositionsResolver.h, you could
> also create another enum here I guess.

Thanks very much for the suggestions! Code has been updated.
Comment 12 Oriol Brufau 2021-05-27 06:44:11 PDT
Comment on attachment 429861 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429861&action=review

Looks good, thanks! Just some nits

> Source/WebCore/ChangeLog:10
> +        Reviewed by  Antoine Quint.

Nit: double space in "by  Antoine"

> Source/WebCore/animation/CSSPropertyAnimation.cpp:754
> +    {

Nit: remove the indentation. I think the curly brackets should be aligned with GridTemplateTracksWrapper, not with the commas.

> Source/WebCore/animation/CSSPropertyAnimation.cpp:766
> +    // ...

Nit: remove this comment

> Source/WebCore/animation/CSSPropertyAnimation.cpp:767
> +    {

Nit: ditto (indentation)

> LayoutTests/imported/w3c/ChangeLog:6
> +        Reviewed by  Antoine Quint.

Nit: ditto (spaces)
Comment 13 zsun 2021-05-27 07:17:08 PDT
Created attachment 429876 [details]
Patch
Comment 14 EWS 2021-05-27 12:51:19 PDT
Committed r278173 (238216@main): <https://commits.webkit.org/238216@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 429876 [details].
Comment 15 Radar WebKit Bug Importer 2021-05-27 12:52:22 PDT
<rdar://problem/78582540>