Bug 178988

Summary: [Web Animations] Expose the currentTime property on Animation
Product: WebKit Reporter: Antoine Quint <graouts>
Component: AnimationsAssignee: Antoine Quint <graouts>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, cdumez, dino, esprehn+autocc, kondapallykalyan, 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=122912
Attachments:
Description Flags
Patch dino: review+

Description Antoine Quint 2017-10-29 11:36:07 PDT
[Web Animations] Expose the currentTime property on Animation
Comment 1 Antoine Quint 2017-10-29 11:40:38 PDT
Created attachment 325287 [details]
Patch
Comment 2 Dean Jackson 2017-10-29 12:20:18 PDT
Comment on attachment 325287 [details]
Patch

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

> Source/WebCore/animation/WebAnimation.cpp:94
> +    if (time == std::nullopt)
> +        return std::nullopt;
> +    return time->value();

If you want to test for the optional having a value you can just do

if (!time)
  return std::nullopt;

But in this case there is a helper to make it even easier for you:

return time.value_or(std::nullopt);

> Source/WebCore/animation/WebAnimation.cpp:100
> +    if (currentTime == std::nullopt)
> +        return Exception { TypeError };

if (!currentTime)

> Source/WebCore/animation/WebAnimation.cpp:110
> +    if (!m_timeline || m_startTime == std::nullopt)
> +        return std::nullopt;

if (!m_timeline || !m_startTime)

> Source/WebCore/animation/WebAnimation.cpp:113
> +    if (timelineTime == std::nullopt)

if (!timelineTime)

> Source/WebCore/animation/WebAnimation.cpp:129
> +    std::optional<Seconds> timelineTime = m_timeline->currentTime();

auto timelineTime = m_timeline->currentTime();

> Source/WebCore/animation/WebAnimation.cpp:130
> +    if (timelineTime == std::nullopt) {

if (!timelineTime)

> LayoutTests/ChangeLog:11
> +        Add a new test that checks that the currentTime property is set
> +        correctly based on the startTime value and the document timeline
> +        currentTime, and that setting the property may raise an exception
> +        and otherwise update the animation startTime.

If this is tested by the existing WPT tests, then you'd be better off importing them with expected results that show a lot of failures. Then, as you implement, you'll slowly change those failures into passes.

Then again, since you need to go through Internals, maybe there is no way to test this using WPT.
Comment 3 Antoine Quint 2017-10-29 13:22:43 PDT
Committed r224163: <https://trac.webkit.org/changeset/224163>
Comment 4 Antoine Quint 2017-10-29 14:08:57 PDT
Committed r224164: <https://trac.webkit.org/changeset/224164>
Comment 5 Radar WebKit Bug Importer 2017-10-31 06:41:13 PDT
<rdar://problem/35271084>