Changeset 224242 in webkit


Ignore:
Timestamp:
Oct 31, 2017 1:28:18 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[Web Animations] Support AnimationEffect parameter in Animation constructor and read-write timeline property
https://bugs.webkit.org/show_bug.cgi?id=179066

Patch by Antoine Quint <Antoine Quint> on 2017-10-31
Reviewed by Dean Jackson.

Source/WebCore:

We update the Animation constructor signature and behavior to allow for an AnimationEffect as its first,
null by default, parameter and implement the spec behavior where an omitted AnimationTimeline parameter
should default to the document timeline. We also make the timeline property read-write.

Existing tests are rebaselined and amended for this new behavior.

  • animation/WebAnimation.cpp:

(WebCore::WebAnimation::create):
(WebCore::WebAnimation::WebAnimation):
(WebCore::WebAnimation::setEffect):
(WebCore::WebAnimation::setTimeline):

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

LayoutTests:

Rebaseline and amend tests to show support for the AnimationEffect first parameter to the Animation
constructor and the default document timeline value for the AnimationTimeline second parameter.

  • http/wpt/web-animations/interfaces/Animation/constructor-expected.txt:
  • http/wpt/web-animations/interfaces/Animation/idlharness-expected.txt:
  • http/wpt/web-animations/interfaces/Animation/startTime-expected.txt:
  • http/wpt/web-animations/interfaces/KeyframeEffect/setTarget-expected.txt:
  • http/wpt/web-animations/timing-model/animations/current-time-expected.txt:
  • http/wpt/web-animations/timing-model/animations/reversing-an-animation-expected.txt:
  • http/wpt/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt:
  • http/wpt/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt:
  • http/wpt/wk-web-animations/timing-model/animation-creation-basic-expected.txt:
  • http/wpt/wk-web-animations/timing-model/animation-creation-basic.html:
  • http/wpt/wk-web-animations/timing-model/animation-current-time.html:
  • http/wpt/wk-web-animations/timing-model/animation-playback-rate.html:
  • webanimations/animation-creation-addition.html:
Location:
trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r224241 r224242  
     12017-10-31  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Support AnimationEffect parameter in Animation constructor and read-write timeline property
     4        https://bugs.webkit.org/show_bug.cgi?id=179066
     5
     6        Reviewed by Dean Jackson.
     7
     8        Rebaseline and amend tests to show support for the AnimationEffect first parameter to the Animation
     9        constructor and the default document timeline value for the AnimationTimeline second parameter.
     10
     11        * http/wpt/web-animations/interfaces/Animation/constructor-expected.txt:
     12        * http/wpt/web-animations/interfaces/Animation/idlharness-expected.txt:
     13        * http/wpt/web-animations/interfaces/Animation/startTime-expected.txt:
     14        * http/wpt/web-animations/interfaces/KeyframeEffect/setTarget-expected.txt:
     15        * http/wpt/web-animations/timing-model/animations/current-time-expected.txt:
     16        * http/wpt/web-animations/timing-model/animations/reversing-an-animation-expected.txt:
     17        * http/wpt/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt:
     18        * http/wpt/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt:
     19        * http/wpt/wk-web-animations/timing-model/animation-creation-basic-expected.txt:
     20        * http/wpt/wk-web-animations/timing-model/animation-creation-basic.html:
     21        * http/wpt/wk-web-animations/timing-model/animation-current-time.html:
     22        * http/wpt/wk-web-animations/timing-model/animation-playback-rate.html:
     23        * webanimations/animation-creation-addition.html:
     24
    1252017-10-31  Ali Juma  <ajuma@chromium.org>
    226
  • trunk/LayoutTests/http/wpt/web-animations/interfaces/Animation/constructor-expected.txt

    r224182 r224242  
    11
    2 FAIL Animation can be constructed with null effect and null timeline assert_equals: Animation.playState should be initially 'idle' expected (string) "idle" but got (undefined) undefined
    3 FAIL Animation can be constructed with null effect and non-null timeline assert_equals: Animation timeline should be document.timeline expected object "[object DocumentTimeline]" but got null
    4 FAIL Animation can be constructed with null effect and no timeline parameter assert_equals: Animation timeline should be document.timeline expected object "[object DocumentTimeline]" but got null
     2FAIL Animation can be constructed with null effect and null timeline assert_equals: Animation timeline should be null expected null but got object "[object DocumentTimeline]"
     3FAIL Animation can be constructed with null effect and non-null timeline assert_equals: Animation.playState should be initially 'idle' expected (string) "idle" but got (undefined) undefined
     4FAIL Animation can be constructed with null effect and no timeline parameter assert_equals: Animation.playState should be initially 'idle' expected (string) "idle" but got (undefined) undefined
    55FAIL Animation can be constructed with non-null effect and null timeline Can't find variable: KeyframeEffectReadOnly
    66FAIL Animation can be constructed with non-null effect and non-null timeline Can't find variable: KeyframeEffectReadOnly
  • trunk/LayoutTests/http/wpt/web-animations/interfaces/Animation/idlharness-expected.txt

    r224182 r224242  
    1212FAIL Animation interface: attribute id assert_true: The prototype object must have a property "id" expected true got false
    1313PASS Animation interface: attribute effect
    14 FAIL Animation interface: attribute timeline assert_equals: setter must be function for PutForwards, Replaceable, or non-readonly attributes expected "function" but got "undefined"
     14PASS Animation interface: attribute timeline
    1515PASS Animation interface: attribute startTime
    1616PASS Animation interface: attribute currentTime
  • trunk/LayoutTests/http/wpt/web-animations/interfaces/Animation/startTime-expected.txt

    r224182 r224242  
    11
    2 FAIL startTime of a newly created (idle) animation is unresolved Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    3 FAIL startTime of a play-pending animation is unresolved Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    4 FAIL startTime of a pause-pending animation is unresolved Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
     2PASS startTime of a newly created (idle) animation is unresolved
     3FAIL startTime of a play-pending animation is unresolved animation.play is not a function. (In 'animation.play()', 'animation.play' is undefined)
     4FAIL startTime of a pause-pending animation is unresolved animation.pause is not a function. (In 'animation.pause()', 'animation.pause' is undefined)
    55FAIL startTime of a play-pending animation created using Element.animate shortcut is unresolved createDiv(t).animate is not a function. (In 'createDiv(t).animate(null)', 'createDiv(t).animate' is undefined)
    66FAIL startTime is resolved when running createDiv(t).animate is not a function. (In 'createDiv(t).animate(null, 100 * MS_PER_SEC)', 'createDiv(t).animate' is undefined)
  • trunk/LayoutTests/http/wpt/web-animations/interfaces/KeyframeEffect/setTarget-expected.txt

    r224182 r224242  
    11
    22FAIL Test setting target before constructing the associated animation Attempted to assign to readonly property.
    3 FAIL Test setting target from null to a valid target Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
     3FAIL Test setting target from null to a valid target anim.play is not a function. (In 'anim.play()', 'anim.play' is undefined)
    44FAIL Test setting target from a valid target to null div.animate is not a function. (In 'div.animate(gKeyFrames, 100 * MS_PER_SEC)', 'div.animate' is undefined)
    55FAIL Test setting target from a valid target to another target a.animate is not a function. (In 'a.animate(gKeyFrames, 100 * MS_PER_SEC)', 'a.animate' is undefined)
  • trunk/LayoutTests/http/wpt/web-animations/timing-model/animations/current-time-expected.txt

    r224182 r224242  
    11
    2 FAIL The current time returns the hold time when set Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    3 FAIL The current time is unresolved when there is no associated timeline (and no hold time is set) Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    4 FAIL The current time is unresolved when the start time is unresolved (and no hold time is set) Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    5 FAIL The current time is calculated from the timeline time, start time and playback rate Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
     2FAIL The current time returns the hold time when set animation.play is not a function. (In 'animation.play()', 'animation.play' is undefined)
     3FAIL The current time is unresolved when there is no associated timeline (and no hold time is set) undefined is not an object (evaluating 'animation.ready.then')
     4PASS The current time is unresolved when the start time is unresolved (and no hold time is set)
     5FAIL The current time is calculated from the timeline time, start time and playback rate assert_approx_equals: Animation has a unresolved start time expected a number but got a "object"
    66FAIL The current time does not progress if playback rate is 0 createDiv(t).animate is not a function. (In 'createDiv(t).animate(null, 100 * MS_PER_SEC)', 'createDiv(t).animate' is undefined)
    77
  • trunk/LayoutTests/http/wpt/web-animations/timing-model/animations/reversing-an-animation-expected.txt

    r224182 r224242  
    2222                                   iterations: Infinity})', 'div.animate' is undefined)
    2323FAIL Reversing when when playbackRate == 0 should preserve the current time and playback rate div.animate is not a function. (In 'div.animate({}, 100 * MS_PER_SEC)', 'div.animate' is undefined)
    24 FAIL Reversing an animation without an active timeline throws an InvalidStateError Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
     24FAIL Reversing an animation without an active timeline throws an InvalidStateError assert_throws: function "function () { animation.reverse(); }" threw object "TypeError: animation.reverse is not a function. (In 'animation.reverse()', 'animation.reverse' is undefined)" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
    2525
  • trunk/LayoutTests/http/wpt/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt

    r224182 r224242  
    11
    2 FAIL Setting the start time of an animation without an active timeline Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    3 FAIL Setting an unresolved start time an animation without an active timeline does not clear the current time Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    4 FAIL Setting the start time clears the hold time Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    5 FAIL Setting an unresolved start time sets the hold time Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    6 FAIL Setting the start time resolves a pending ready promise Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    7 FAIL Setting the start time resolves a pending pause task Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    8 FAIL Setting the start time updates the finished state Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
     2FAIL Setting the start time of an animation without an active timeline assert_equals: Setting the current time succeeds expected (number) 1000 but got (object) null
     3FAIL Setting an unresolved start time an animation without an active timeline does not clear the current time assert_equals: Setting the current time succeeds expected (number) 1000 but got (object) null
     4FAIL Setting the start time clears the hold time assert_equals: The current time is calculated from the hold time expected (number) 1000 but got (object) null
     5FAIL Setting an unresolved start time sets the hold time assert_equals: expected (string) "running" but got (undefined) undefined
     6FAIL Setting the start time resolves a pending ready promise undefined is not an object (evaluating 'animation.ready.then')
     7FAIL Setting the start time resolves a pending pause task undefined is not an object (evaluating 'animation.ready.then')
     8FAIL Setting the start time updates the finished state assert_equals: Seeked to finished state using the startTime expected (string) "finished" but got (undefined) undefined
    99
  • trunk/LayoutTests/http/wpt/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt

    r224182 r224242  
    11
    2 FAIL After setting timeline on paused animation it is still paused Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    3 FAIL After setting timeline on animation paused outside active interval it is still paused Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    4 FAIL After setting timeline on an idle animation without a start time it is still idle Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    5 FAIL After setting timeline on an idle animation with a start time it is running Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    6 FAIL After setting timeline on an idle animation with a sufficiently ancient start time it is finished Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    7 FAIL After setting timeline on a play-pending animation it is still pending Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    8 FAIL After setting timeline on a play-pending animation it begins playing after pending Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    9 FAIL After setting timeline on a pause-pending animation it is still pending Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    10 FAIL After setting timeline on a pause-pending animation it becomes paused after pending Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    11 FAIL After clearing timeline on paused animation it is still paused Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    12 FAIL After clearing timeline on finished animation it is idle Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    13 FAIL After clearing timeline on running animation it is idle Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    14 FAIL After clearing timeline on idle animation it is still idle Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
     2FAIL After setting timeline on paused animation it is still paused assert_equals: expected (string) "paused" but got (undefined) undefined
     3FAIL After setting timeline on animation paused outside active interval it is still paused assert_equals: expected (string) "paused" but got (undefined) undefined
     4FAIL After setting timeline on an idle animation without a start time it is still idle assert_equals: expected (string) "idle" but got (undefined) undefined
     5FAIL After setting timeline on an idle animation with a start time it is running assert_equals: expected (string) "idle" but got (undefined) undefined
     6FAIL After setting timeline on an idle animation with a sufficiently ancient start time it is finished assert_equals: expected (string) "idle" but got (undefined) undefined
     7FAIL After setting timeline on a play-pending animation it is still pending animation.play is not a function. (In 'animation.play()', 'animation.play' is undefined)
     8FAIL After setting timeline on a play-pending animation it begins playing after pending animation.play is not a function. (In 'animation.play()', 'animation.play' is undefined)
     9FAIL After setting timeline on a pause-pending animation it is still pending animation.pause is not a function. (In 'animation.pause()', 'animation.pause' is undefined)
     10FAIL After setting timeline on a pause-pending animation it becomes paused after pending animation.pause is not a function. (In 'animation.pause()', 'animation.pause' is undefined)
     11FAIL After clearing timeline on paused animation it is still paused assert_equals: expected (string) "paused" but got (undefined) undefined
     12FAIL After clearing timeline on finished animation it is idle assert_equals: expected (string) "finished" but got (undefined) undefined
     13FAIL After clearing timeline on running animation it is idle assert_equals: expected (string) "running" but got (undefined) undefined
     14FAIL After clearing timeline on idle animation it is still idle assert_equals: expected (string) "idle" but got (undefined) undefined
    1515FAIL After clearing timeline on play-pending animation it is still pending createDiv(t).animate is not a function. (In 'createDiv(t).animate(null, 100 * MS_PER_SEC)', 'createDiv(t).animate' is undefined)
    1616FAIL After clearing and re-setting timeline on play-pending animation it begins to play createDiv(t).animate is not a function. (In 'createDiv(t).animate(null, 100 * MS_PER_SEC)', 'createDiv(t).animate' is undefined)
    17 FAIL After clearing timeline on a pause-pending animation it is still pending Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    18 FAIL After clearing and re-setting timeline on a pause-pending animation it becomes paused Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
    19 FAIL After clearing and re-setting timeline on an animation in the middle of an aborted pause, it continues playing using the same start time Argument 1 ('timeline') to the Animation constructor must be an instance of AnimationTimeline
     17FAIL After clearing timeline on a pause-pending animation it is still pending animation.pause is not a function. (In 'animation.pause()', 'animation.pause' is undefined)
     18FAIL After clearing and re-setting timeline on a pause-pending animation it becomes paused animation.pause is not a function. (In 'animation.pause()', 'animation.pause' is undefined)
     19FAIL After clearing and re-setting timeline on an animation in the middle of an aborted pause, it continues playing using the same start time animation.pause is not a function. (In 'animation.pause()', 'animation.pause' is undefined)
    2020
  • trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/animation-creation-basic-expected.txt

    r224188 r224242  
    11
    22PASS The Animation interface is defined.
    3 PASS Creating Animation without arguments should have a null timeline.
    4 PASS Creating Animation with an undefined argument should have a null timeline.
    5 PASS Creating Animation with a null argument should have a null timeline.
    6 PASS Creating Animation with a timeline has a timeline.
     3PASS Creating Animation without arguments should have a null effect and the document timeline.
     4PASS Creating Animation with an undefined argument should have a null effect and the document timeline.
     5PASS Creating Animation with a null argument should have a null effect and the document timeline.
     6PASS Creating Animation with an effect should only set the effect property and have the document timeline.
    77
  • trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/animation-creation-basic.html

    r224188 r224242  
    1515test(t => {
    1616    const animation = new Animation;
    17     assert_equals(animation.timeline, null);
    18 }, "Creating Animation without arguments should have a null timeline.");
     17    assert_equals(animation.effect, null);
     18    assert_equals(animation.timeline, document.timeline);
     19}, "Creating Animation without arguments should have a null effect and the document timeline.");
    1920
    2021test(t => {
    2122    const animation = new Animation(undefined);
    22     assert_equals(animation.timeline, null);
    23 }, "Creating Animation with an undefined argument should have a null timeline.");
     23    assert_equals(animation.effect, null);
     24    assert_equals(animation.timeline, document.timeline);
     25}, "Creating Animation with an undefined argument should have a null effect and the document timeline.");
    2426
    2527test(t => {
    2628    const animation = new Animation(null);
    27     assert_equals(animation.timeline, null);
    28 }, "Creating Animation with a null argument should have a null timeline.");
     29    assert_equals(animation.effect, null);
     30    assert_equals(animation.timeline, document.timeline);
     31}, "Creating Animation with a null argument should have a null effect and the document timeline.");
    2932
    3033test(t => {
    31     const animation = new Animation(document.timeline);
     34    const effect = new KeyframeEffect(document.body);
     35    const animation = new Animation(effect);
     36    assert_equals(animation.effect, effect);
    3237    assert_equals(animation.timeline, document.timeline);
    33 }, "Creating Animation with a timeline has a timeline.");
     38}, "Creating Animation with an effect should only set the effect property and have the document timeline.");
    3439
    3540</script>
  • trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/animation-current-time.html

    r224188 r224242  
    1010
    1111test(t => {
    12     const animation = new Animation(document.timeline);
     12    const animation = new Animation;
    1313    assert_equals(animation.currentTime, null);
    1414}, "An animation's currentTime is null when the timeline has no currentTime set.");
    1515
    1616test(t => {
    17     const animation = new Animation(document.timeline);
     17    const animation = new Animation;
    1818    animation.startTime = 2;
    1919    internals.setTimelineCurrentTime(document.timeline, 0);
     
    2626
    2727test(t => {
    28     const animation = new Animation(document.timeline);
     28    const animation = new Animation;
    2929    animation.startTime = 1;
    3030    internals.setTimelineCurrentTime(document.timeline, 3);
     
    3636
    3737test(t => {
    38     const animation = new Animation(document.timeline);
     38    const animation = new Animation;
    3939    assert_throws(new TypeError, () => animation.currentTime = null);
    4040}, "Setting the current time to null should throw a TypeError.");
  • trunk/LayoutTests/http/wpt/wk-web-animations/timing-model/animation-playback-rate.html

    r224181 r224242  
    1111
    1212test(t => {
    13   const animation = new Animation(document.timeline);
     13  const animation = new Animation;
    1414
    1515  assert_equals(animation.playbackRate, 1);
     
    1717
    1818test(t => {
    19   const animation = new Animation(document.timeline);
     19  const animation = new Animation;
    2020  animation.startTime = 1;
    2121  animation.playbackRate = 2;
     
    2828
    2929test(t => {
    30   const animation = new Animation(document.timeline);
     30  const animation = new Animation;
    3131  animation.startTime = 2;
    3232  animation.playbackRate = 2;
     
    4141
    4242test(t => {
    43   const animation = new Animation(document.timeline);
     43  const animation = new Animation;
    4444  animation.startTime = 2;
    4545  animation.playbackRate = 0.5;
     
    5454
    5555test(t => {
    56   const animation = new Animation(document.timeline);
     56  const animation = new Animation;
    5757  animation.currentTime = 1;
    5858  animation.playbackRate = -1;
     
    6565
    6666test(t => {
    67   const animation = new Animation(document.timeline);
     67  const animation = new Animation;
    6868  animation.playbackRate = 0;
    6969  animation.startTime = 0;
  • trunk/LayoutTests/webanimations/animation-creation-addition.html

    r223825 r224242  
    44description("Constructing an Animation with a timeline should add the animation to the timeline.");
    55
    6 new Animation(document.timeline);
    7 new Animation();
    8 new Animation(document.timeline);
     6new Animation(null, document.timeline);
     7new Animation(null, document.timeline);
    98debug(internals.timelineDescription(document.timeline));
    109
  • trunk/Source/WebCore/ChangeLog

    r224241 r224242  
     12017-10-31  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Support AnimationEffect parameter in Animation constructor and read-write timeline property
     4        https://bugs.webkit.org/show_bug.cgi?id=179066
     5
     6        Reviewed by Dean Jackson.
     7
     8        We update the Animation constructor signature and behavior to allow for an AnimationEffect as its first,
     9        null by default, parameter and implement the spec behavior where an omitted AnimationTimeline parameter
     10        should default to the document timeline. We also make the timeline property read-write.
     11
     12        Existing tests are rebaselined and amended for this new behavior.
     13
     14        * animation/WebAnimation.cpp:
     15        (WebCore::WebAnimation::create):
     16        (WebCore::WebAnimation::WebAnimation):
     17        (WebCore::WebAnimation::setEffect):
     18        (WebCore::WebAnimation::setTimeline):
     19        * animation/WebAnimation.h:
     20        * animation/WebAnimation.idl:
     21
    1222017-10-31  Ali Juma  <ajuma@chromium.org>
    223
  • trunk/Source/WebCore/animation/WebAnimation.cpp

    r224181 r224242  
    2929#include "AnimationEffect.h"
    3030#include "AnimationTimeline.h"
     31#include "Document.h"
    3132#include <wtf/text/WTFString.h>
    3233
    3334namespace WebCore {
    3435
    35 Ref<WebAnimation> WebAnimation::create(AnimationTimeline* timeline)
     36Ref<WebAnimation> WebAnimation::create(Document& document, AnimationEffect* effect, AnimationTimeline* timeline)
    3637{
    37     auto result = adoptRef(*new WebAnimation(timeline));
     38    auto result = adoptRef(*new WebAnimation());
    3839
    39     if (timeline)
    40         timeline->addAnimation(result.copyRef());
     40    result->setEffect(effect);
     41   
     42    // FIXME: the spec mandates distinguishing between an omitted timeline parameter
     43    // and an explicit null or undefined value (webkit.org/b/179065).
     44    result->setTimeline(timeline ? timeline : &document.timeline());
    4145   
    4246    return result;
    4347}
    4448
    45 WebAnimation::WebAnimation(AnimationTimeline* timeline)
    46     : m_timeline(timeline)
     49WebAnimation::WebAnimation()
    4750{
    4851}
     
    5659void WebAnimation::setEffect(RefPtr<AnimationEffect>&& effect)
    5760{
     61    if (effect == m_effect)
     62        return;
     63
    5864    m_effect = WTFMove(effect);
    5965}
    6066
     67void WebAnimation::setTimeline(RefPtr<AnimationTimeline>&& timeline)
     68{
     69    if (timeline == m_timeline)
     70        return;
     71
     72    // FIXME: If the animation start time of animation is resolved, make animation’s
     73    // hold time unresolved (webkit.org/b/178932).
     74
     75    if (m_timeline)
     76        m_timeline->removeAnimation(*this);
     77
     78    if (timeline)
     79        timeline->addAnimation(*this);
     80
     81    m_timeline = WTFMove(timeline);
     82}
     83   
    6184std::optional<double> WebAnimation::bindingsStartTime() const
    6285{
  • trunk/Source/WebCore/animation/WebAnimation.h

    r224181 r224242  
    3838class AnimationEffect;
    3939class AnimationTimeline;
     40class Document;
    4041
    4142class WebAnimation final : public RefCounted<WebAnimation> {
    4243public:
    43     static Ref<WebAnimation> create(AnimationTimeline*);
     44    static Ref<WebAnimation> create(Document&, AnimationEffect*, AnimationTimeline*);
    4445    ~WebAnimation();
    4546
     
    4748    void setEffect(RefPtr<AnimationEffect>&&);
    4849    AnimationTimeline* timeline() const { return m_timeline.get(); }
     50    void setTimeline(RefPtr<AnimationTimeline>&&);
    4951
    5052    std::optional<double> bindingsStartTime() const;
     
    6466
    6567private:
    66     WebAnimation(AnimationTimeline*);
     68    WebAnimation();
    6769
    6870    RefPtr<AnimationEffect> m_effect;
  • trunk/Source/WebCore/animation/WebAnimation.idl

    r224181 r224242  
    2828    InterfaceName=Animation,
    2929    ImplementationLacksVTable,
    30     Constructor(optional AnimationTimeline? timeline)
     30    ConstructorCallWith=Document,
     31    Constructor(optional AnimationEffect? effect = null, optional AnimationTimeline? timeline)
    3132] interface WebAnimation {
    3233    attribute AnimationEffect? effect;
    33     readonly attribute AnimationTimeline? timeline;
     34    attribute AnimationTimeline? timeline;
    3435    [ImplementedAs=bindingsStartTime] attribute double? startTime;
    3536    [MayThrowException, ImplementedAs=bindingsCurrentTime] attribute double? currentTime;
Note: See TracChangeset for help on using the changeset viewer.