Bug 181651 - Use traits for animation timing functions
Summary: Use traits for animation timing functions
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Animations (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dean Jackson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-01-15 10:58 PST by Dean Jackson
Modified: 2018-01-16 10:45 PST (History)
5 users (show)

See Also:


Attachments
Patch (11.77 KB, patch)
2018-01-15 11:01 PST, Dean Jackson
no flags Details | Formatted Diff | Diff
Patch (10.42 KB, patch)
2018-01-16 03:21 PST, Antoine Quint
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dean Jackson 2018-01-15 10:58:04 PST
Use traits for animation timing functions
Comment 1 Radar WebKit Bug Importer 2018-01-15 10:59:31 PST
<rdar://problem/36525328>
Comment 2 Dean Jackson 2018-01-15 11:01:30 PST
Created attachment 331347 [details]
Patch
Comment 3 Dean Jackson 2018-01-15 11:16:24 PST
Committed r226952: <https://trac.webkit.org/changeset/226952>
Comment 4 Darin Adler 2018-01-15 14:43:19 PST
Comment on attachment 331347 [details]
Patch

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

Great idea!

> Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1545
> +        auto& function = downcast<const CubicBezierTimingFunction>(timingFunction);

The downcast function template does not require you to specify const: it makes const match automatically, so this should be:

    auto& function = downcast<CubicBezierTimingFunction>(timingFunction);

> Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1568
> +        auto& function = downcast<const StepsTimingFunction>(timingFunction);

Ditto.

> Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1572
> +        auto& function = downcast<const FramesTimingFunction>(timingFunction);

Ditto.

> Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1576
> +        auto& function = downcast<const SpringTimingFunction>(timingFunction);

Ditto.

> Source/WebCore/platform/animation/TimingFunction.cpp:69
> +        auto& function = *downcast<const CubicBezierTimingFunction>(this);

It’s better to put the * inside before calling downcast, also const not needed:

    auto& function = downcast<CubicBezierTimingFunction>(*this);

> Source/WebCore/platform/animation/TimingFunction.cpp:76
> +        auto& function = *downcast<const StepsTimingFunction>(this);

Ditto.

> Source/WebCore/platform/animation/TimingFunction.cpp:84
> +        auto& function = *downcast<const FramesTimingFunction>(this);

Ditto.

> Source/WebCore/platform/animation/TimingFunction.cpp:93
> +        auto& function = *downcast<const SpringTimingFunction>(this);

Ditto.

> Source/WebCore/platform/animation/TimingFunction.h:126
> +        auto& otherCubic = downcast<const CubicBezierTimingFunction>(other);

Ditto.

> Source/WebCore/platform/animation/TimingFunction.h:199
> +        auto& otherSteps = downcast<const StepsTimingFunction>(other);

Ditto.

> Source/WebCore/platform/animation/TimingFunction.h:281
> +        auto& otherSpring = downcast<const SpringTimingFunction>(other);

Ditto.

> Source/WebCore/platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm:134
> +        const CubicBezierTimingFunction* ctf = downcast<const CubicBezierTimingFunction>(timingFunction);

I suggest using auto to avoid repeating everything:

    auto* function = downcast<CubicBezierTimingFunction>(timingFunction);
Comment 5 Antoine Quint 2018-01-16 00:29:20 PST
(In reply to Darin Adler from comment #4)
> Comment on attachment 331347 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=331347&action=review
> 
> Great idea!
> 
> > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1545
> > +        auto& function = downcast<const CubicBezierTimingFunction>(timingFunction);
> 
> The downcast function template does not require you to specify const: it
> makes const match automatically, so this should be:
> 
>     auto& function = downcast<CubicBezierTimingFunction>(timingFunction);

I have a patch coming up that will address all of those.
Comment 6 Antoine Quint 2018-01-16 03:21:07 PST
Reopening to attach new patch.
Comment 7 Antoine Quint 2018-01-16 03:21:10 PST
Created attachment 331380 [details]
Patch
Comment 8 WebKit Commit Bot 2018-01-16 10:45:51 PST
Comment on attachment 331380 [details]
Patch

Clearing flags on attachment: 331380

Committed r226976: <https://trac.webkit.org/changeset/226976>
Comment 9 WebKit Commit Bot 2018-01-16 10:45:52 PST
All reviewed patches have been landed.  Closing bug.