Changeset 224181 in webkit


Ignore:
Timestamp:
Oct 30, 2017 8:09:02 AM (6 years ago)
Author:
graouts@webkit.org
Message:

[Web Animations] Expose the playbackRate property on Animation
https://bugs.webkit.org/show_bug.cgi?id=178931

Reviewed by Sam Weinig.

Source/WebCore:

Account for the playback rate when computing and setting an animation's
current time, ensuring that we adjust the start time to preserve the
current time when setting a new playback rate.

Test: http/wpt/wk-web-animations/timing-model/animation-playback-rate.html

  • animation/WebAnimation.cpp:

(WebCore::WebAnimation::WebAnimation):
(WebCore::WebAnimation::currentTime const):
(WebCore::WebAnimation::setCurrentTime):
(WebCore::WebAnimation::setPlaybackRate):

  • animation/WebAnimation.h:
  • animation/WebAnimation.idl:

LayoutTests:

Add a new test, using WPT, to check that the playbackRate property is accounted
for when getting and setting the current time.

  • http/wpt/wk-web-animations/timing-model/animation-playback-rate-expected.txt: Added.
  • http/wpt/wk-web-animations/timing-model/animation-playback-rate.html: Added.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r224178 r224181  
     12017-10-30  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Expose the playbackRate property on Animation
     4        https://bugs.webkit.org/show_bug.cgi?id=178931
     5
     6        Reviewed by Sam Weinig.
     7
     8        Add a new test, using WPT, to check that the playbackRate property is accounted
     9        for when getting and setting the current time.
     10
     11        * http/wpt/wk-web-animations/timing-model/animation-playback-rate-expected.txt: Added.
     12        * http/wpt/wk-web-animations/timing-model/animation-playback-rate.html: Added.
     13
    1142017-10-30  Carlos Alberto Lopez Perez  <clopez@igalia.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r224179 r224181  
     12017-10-30  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Expose the playbackRate property on Animation
     4        https://bugs.webkit.org/show_bug.cgi?id=178931
     5
     6        Reviewed by Sam Weinig.
     7
     8        Account for the playback rate when computing and setting an animation's
     9        current time, ensuring that we adjust the start time to preserve the
     10        current time when setting a new playback rate.
     11
     12        Test: http/wpt/wk-web-animations/timing-model/animation-playback-rate.html
     13
     14        * animation/WebAnimation.cpp:
     15        (WebCore::WebAnimation::WebAnimation):
     16        (WebCore::WebAnimation::currentTime const):
     17        (WebCore::WebAnimation::setCurrentTime):
     18        (WebCore::WebAnimation::setPlaybackRate):
     19        * animation/WebAnimation.h:
     20        * animation/WebAnimation.idl:
     21
    1222017-10-30  Michael Catanzaro  <mcatanzaro@igalia.com>
    223
  • trunk/Source/WebCore/animation/WebAnimation.cpp

    r224164 r224181  
    114114        return std::nullopt;
    115115
    116     // FIXME: account for playback rate when we support it (webkit.org/b/178931).
    117     return timelineTime.value() - m_startTime.value();
     116    return (timelineTime.value() - m_startTime.value()) * m_playbackRate;
    118117}
    119118
    120119void WebAnimation::setCurrentTime(std::optional<Seconds> seekTime)
    121120{
    122     // FIXME: account for hold time when we support it (webkit.org/b/178932).
     121    // FIXME: account for hold time when we support it (webkit.org/b/178932),
     122    // including situations where playbackRate is 0.
    123123
    124124    if (!m_timeline) {
     
    133133    }
    134134
    135     // FIXME: account for playback rate when we support it (webkit.org/b/178931).
    136     setStartTime(timelineTime.value() - seekTime.value());
     135    setStartTime(timelineTime.value() - (seekTime.value() / m_playbackRate));
     136}
     137
     138void WebAnimation::setPlaybackRate(double newPlaybackRate)
     139{
     140    if (m_playbackRate == newPlaybackRate)
     141        return;
     142
     143    // 3.5.17.1. Updating the playback rate of an animation
     144    // Changes to the playback rate trigger a compensatory seek so that that the animation's current time
     145    // is unaffected by the change to the playback rate.
     146    auto previousTime = currentTime();
     147    m_playbackRate = newPlaybackRate;
     148    if (previousTime)
     149        setCurrentTime(previousTime);
    137150}
    138151
  • trunk/Source/WebCore/animation/WebAnimation.h

    r224163 r224181  
    5858    void setCurrentTime(std::optional<Seconds>);
    5959
     60    double playbackRate() const { return m_playbackRate; }
     61    void setPlaybackRate(double);
     62
    6063    String description();
    6164
     
    6669    RefPtr<AnimationTimeline> m_timeline;
    6770    std::optional<Seconds> m_startTime;
     71    double m_playbackRate { 1 };
    6872};
    6973
  • trunk/Source/WebCore/animation/WebAnimation.idl

    r224163 r224181  
    3434    [ImplementedAs=bindingsStartTime] attribute double? startTime;
    3535    [MayThrowException, ImplementedAs=bindingsCurrentTime] attribute double? currentTime;
     36    attribute double playbackRate;
    3637};
Note: See TracChangeset for help on using the changeset viewer.