Bug 180402

Summary: [Web Animations] Implement Element.animate()
Product: WebKit Reporter: Antoine Quint <graouts>
Component: AnimationsAssignee: Antoine Quint <graouts>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, ews-watchlist, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=181116
https://bugs.webkit.org/show_bug.cgi?id=181119
https://bugs.webkit.org/show_bug.cgi?id=181121
https://bugs.webkit.org/show_bug.cgi?id=181122
https://bugs.webkit.org/show_bug.cgi?id=181123
Attachments:
Description Flags
Patch
none
Patch
none
Archive of layout-test-results from ews101 for mac-elcapitan
none
Archive of layout-test-results from ews105 for mac-elcapitan-wk2
none
Archive of layout-test-results from ews113 for mac-elcapitan
none
Archive of layout-test-results from ews125 for ios-simulator-wk2
none
Patch dino: review+

Description Antoine Quint 2017-12-05 02:28:44 PST
We need to expose and implement the animate() method on Element via the Animatable interface.
Comment 1 Radar WebKit Bug Importer 2017-12-05 02:30:27 PST
<rdar://problem/35851353>
Comment 2 Antoine Quint 2017-12-22 03:05:55 PST
Created attachment 330115 [details]
Patch
Comment 3 Antoine Quint 2017-12-22 04:34:31 PST
Created attachment 330118 [details]
Patch
Comment 4 EWS Watchlist 2017-12-22 05:39:08 PST
Comment on attachment 330118 [details]
Patch

Attachment 330118 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/5801251

New failing tests:
imported/w3c/web-platform-tests/css-timing-1/step-timing-functions-output.html
imported/w3c/web-platform-tests/css-timing-1/frames-timing-functions-output.html
imported/w3c/web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html
imported/blink/virtual/threaded/animations/compositor-rotate-zero-degrees.html
Comment 5 EWS Watchlist 2017-12-22 05:39:09 PST
Created attachment 330119 [details]
Archive of layout-test-results from ews101 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 6 EWS Watchlist 2017-12-22 05:49:53 PST
Comment on attachment 330118 [details]
Patch

Attachment 330118 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/5801268

New failing tests:
imported/blink/virtual/threaded/animations/compositor-rotate-zero-degrees.html
imported/w3c/web-platform-tests/css-timing-1/step-timing-functions-output.html
imported/w3c/web-platform-tests/css-timing-1/frames-timing-functions-output.html
imported/w3c/web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html
Comment 7 EWS Watchlist 2017-12-22 05:49:54 PST
Created attachment 330120 [details]
Archive of layout-test-results from ews105 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 8 EWS Watchlist 2017-12-22 05:59:02 PST
Comment on attachment 330118 [details]
Patch

Attachment 330118 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/5801279

New failing tests:
imported/w3c/web-platform-tests/css-timing-1/step-timing-functions-output.html
imported/w3c/web-platform-tests/css-timing-1/frames-timing-functions-output.html
imported/w3c/web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html
imported/blink/virtual/threaded/animations/compositor-rotate-zero-degrees.html
Comment 9 EWS Watchlist 2017-12-22 05:59:03 PST
Created attachment 330121 [details]
Archive of layout-test-results from ews113 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews113  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 10 EWS Watchlist 2017-12-22 06:04:56 PST
Comment on attachment 330118 [details]
Patch

Attachment 330118 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/5801290

New failing tests:
imported/w3c/web-platform-tests/css-timing-1/step-timing-functions-output.html
imported/w3c/web-platform-tests/css-timing-1/frames-timing-functions-output.html
imported/w3c/web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html
imported/blink/virtual/threaded/animations/compositor-rotate-zero-degrees.html
Comment 11 EWS Watchlist 2017-12-22 06:04:57 PST
Created attachment 330122 [details]
Archive of layout-test-results from ews125 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews125  Port: ios-simulator-wk2  Platform: Mac OS X 10.12.6
Comment 12 Antoine Quint 2017-12-22 06:25:02 PST
Created attachment 330124 [details]
Patch
Comment 13 Dean Jackson 2017-12-23 13:09:12 PST
Comment on attachment 330124 [details]
Patch

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

> Source/WebCore/animation/AnimationEffectTiming.cpp:55
> +        double durationAsDouble = WTF::get<double>(duration);

auto

> Source/WebCore/animation/AnimationEffectTiming.cpp:59
> +        m_duration = Seconds::fromMilliseconds(durationAsDouble);
> +    } else if (WTF::holds_alternative<String>(duration)) {

Return here. The only other option is String.

> Source/WebCore/animation/AnimationEffectTiming.cpp:61
> +        String durationAsString = WTF::get<String>(duration);
> +        if (durationAsString != "auto")

No need for the local variable.

> Source/WebCore/animation/AnimationEffectTimingProperties.h:44
> +struct AnimationEffectTimingProperties {
> +    double delay;
> +    double endDelay;
> +    FillMode fill;
> +    double iterationStart;
> +    double iterations;
> +    Variant<double, String> duration;
> +    PlaybackDirection direction;
> +    String easing;
> +};

Explicitly set all the default values? Or does the bindings code do that?

> Source/WebCore/animation/KeyframeEffect.cpp:383
> +    if (options) {
> +        Variant<double, String> bindingsDuration;
> +        if (WTF::holds_alternative<double>(options.value()))
> +            bindingsDuration = WTF::get<double>(options.value());
> +        else
> +            bindingsDuration = WTF::get<KeyframeEffectOptions>(options.value()).duration;
> +        auto setBindingsDurationResult = keyframeEffect->timing()->setBindingsDuration(WTFMove(bindingsDuration));
> +        if (setBindingsDurationResult.hasException())
> +            return setBindingsDurationResult.releaseException();
> +    }

Get the .value() as a local variable to avoid calling it so many times.

Also, you could use switch_on here, rather than holds_alternative, etc.

> Source/WebCore/animation/KeyframeEffect.h:45
> +        ~KeyframeEffect() { }

Indentation.

> Source/WebCore/animation/KeyframeEffectOptions.h:38
> +struct KeyframeEffectOptions : AnimationEffectTimingProperties {
> +    IterationCompositeOperation iterationComposite;
> +    CompositeOperation composite;
> +};

Ditto on default values.

> Source/WebCore/dom/Element.cpp:3700
> +        if (WTF::holds_alternative<double>(options.value()))
> +            keyframeEffectOptionsVariant = WTF::get<double>(options.value());
> +        else
> +            keyframeEffectOptionsVariant = WTF::get<KeyframeAnimationOptions>(options.value());

Another case where you could use switch_on, and use a local variable for the value (you wouldn't even need it with switch_on)
Comment 14 Antoine Quint 2017-12-24 05:58:08 PST
Committed r226289: <https://trac.webkit.org/changeset/226289>