Declare onFinish event handler for AnimationPlayer.

Finish events occur when a sample occurs that causes a player to be newly limited or newly disassociated with a timeline. 
(From section 3.5.4 Player events 
http://dev.w3.org/fxtf/web-animations/#player-events
and section 5.19 The AnimationPlayerEvent interface
http://dev.w3.org/fxtf/web-animations/#the-animationplayerevent-interface )

Subsequent CL 216203003 dispatches the events declared here.

BUG=356120

Review URL: https://codereview.chromium.org/210363007

git-svn-id: svn://svn.chromium.org/blink/trunk@170518 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 297a88e9
......@@ -8,6 +8,7 @@ AnalyserNode
Animation
AnimationEvent
AnimationPlayer
AnimationPlayerEvent
ApplicationCache
ApplicationCacheErrorEvent
Array
......
......@@ -238,6 +238,20 @@ void AnimationPlayer::finish(ExceptionState& exceptionState)
ASSERT(finished());
}
const AtomicString& AnimationPlayer::interfaceName() const
{
return EventTargetNames::AnimationPlayer;
}
ExecutionContext* AnimationPlayer::executionContext() const
{
if (m_timeline) {
if (Document* document = m_timeline->document())
return document->contextDocument().get();
}
return 0;
}
void AnimationPlayer::setPlaybackRate(double playbackRate)
{
if (!std::isfinite(playbackRate))
......
......@@ -32,6 +32,7 @@
#define AnimationPlayer_h
#include "core/animation/TimedItem.h"
#include "core/events/EventTarget.h"
#include "wtf/RefPtr.h"
namespace WebCore {
......@@ -39,8 +40,8 @@ namespace WebCore {
class DocumentTimeline;
class ExceptionState;
class AnimationPlayer FINAL : public RefCounted<AnimationPlayer> {
class AnimationPlayer FINAL : public RefCounted<AnimationPlayer>, public EventTargetWithInlineData {
REFCOUNTED_EVENT_TARGET(AnimationPlayer);
public:
~AnimationPlayer();
static PassRefPtr<AnimationPlayer> create(DocumentTimeline&, TimedItem*);
......@@ -66,6 +67,11 @@ public:
void finish(ExceptionState&);
bool finished() { return limited(currentTime()); }
DEFINE_ATTRIBUTE_EVENT_LISTENER(finish);
virtual const AtomicString& interfaceName() const OVERRIDE;
virtual ExecutionContext* executionContext() const OVERRIDE;
double playbackRate() const { return m_playbackRate; }
void setPlaybackRate(double);
const DocumentTimeline* timeline() const { return m_timeline; }
......
......@@ -30,7 +30,7 @@
[
RuntimeEnabled=WebAnimationsAPI,
] interface AnimationPlayer {
] interface AnimationPlayer : EventTarget {
attribute TimedItem? source;
attribute double startTime;
attribute double currentTime;
......@@ -43,4 +43,6 @@
void play();
void pause();
void reverse();
attribute EventHandler onfinish;
};
......@@ -79,6 +79,8 @@ AnimationPlayer* DocumentTimeline::createAnimationPlayer(TimedItem* child)
AnimationPlayer* DocumentTimeline::play(TimedItem* child)
{
if (!m_document)
return 0;
AnimationPlayer* player = createAnimationPlayer(child);
player->setStartTime(effectiveTime());
return player;
......@@ -200,6 +202,7 @@ size_t DocumentTimeline::numberOfActiveAnimationsForTesting() const
}
void DocumentTimeline::detachFromDocument() {
// FIXME: DocumentTimeline should keep Document alive.
m_document = 0;
}
......
......@@ -89,6 +89,7 @@ public:
void setOutdatedAnimationPlayer(AnimationPlayer*);
bool hasOutdatedAnimationPlayer() const { return m_hasOutdatedAnimationPlayer; }
Document* document() { return m_document; }
void detachFromDocument();
protected:
......
......@@ -84,6 +84,7 @@
'dom/URL.idl',
'dom/XMLDocument.idl',
'dom/shadow/ShadowRoot.idl',
'events/AnimationPlayerEvent.idl',
'events/ApplicationCacheErrorEvent.idl',
'events/AutocompleteErrorEvent.idl',
'events/BeforeUnloadEvent.idl',
......@@ -2138,6 +2139,8 @@
'dom/VisitedLinkState.h',
'dom/WheelController.cpp',
'dom/WheelController.h',
'events/AnimationPlayerEvent.cpp',
'events/AnimationPlayerEvent.h',
'events/ApplicationCacheErrorEvent.cpp',
'events/ApplicationCacheErrorEvent.h',
'events/AutocompleteErrorEvent.h',
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "core/events/AnimationPlayerEvent.h"
namespace WebCore {
AnimationPlayerEventInit::AnimationPlayerEventInit()
: currentTime(0.0)
, timelineTime(0.0)
{
}
AnimationPlayerEvent::AnimationPlayerEvent()
: m_currentTime(0.0)
, m_timelineTime(0.0)
{
ScriptWrappable::init(this);
}
AnimationPlayerEvent::AnimationPlayerEvent(const AtomicString& type, double currentTime, double timelineTime)
: Event(type, false, false)
, m_currentTime(currentTime)
, m_timelineTime(timelineTime)
{
ScriptWrappable::init(this);
}
AnimationPlayerEvent::AnimationPlayerEvent(const AtomicString& type, const AnimationPlayerEventInit& initializer)
: Event(type, initializer)
, m_currentTime(initializer.currentTime)
, m_timelineTime(initializer.timelineTime)
{
ScriptWrappable::init(this);
}
AnimationPlayerEvent::~AnimationPlayerEvent()
{
}
double AnimationPlayerEvent::currentTime() const
{
return m_currentTime;
}
double AnimationPlayerEvent::timelineTime() const
{
return m_timelineTime;
}
const AtomicString& AnimationPlayerEvent::interfaceName() const
{
return EventNames::AnimationPlayerEvent;
}
void AnimationPlayerEvent::trace(Visitor* visitor)
{
Event::trace(visitor);
}
} // namespace WebCore
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef AnimationPlayerEvent_h
#define AnimationPlayerEvent_h
#include "core/events/Event.h"
namespace WebCore {
struct AnimationPlayerEventInit : public EventInit {
AnimationPlayerEventInit();
double currentTime;
double timelineTime;
};
class AnimationPlayerEvent FINAL : public Event {
public:
static PassRefPtrWillBeRawPtr<AnimationPlayerEvent> create()
{
return adoptRefWillBeRefCountedGarbageCollected(new AnimationPlayerEvent);
}
static PassRefPtrWillBeRawPtr<AnimationPlayerEvent> create(const AtomicString& type, double currentTime, double timelineTime)
{
return adoptRefWillBeRefCountedGarbageCollected(new AnimationPlayerEvent(type, currentTime, timelineTime));
}
static PassRefPtrWillBeRawPtr<AnimationPlayerEvent> create(const AtomicString& type, const AnimationPlayerEventInit& initializer)
{
return adoptRefWillBeRefCountedGarbageCollected(new AnimationPlayerEvent(type, initializer));
}
virtual ~AnimationPlayerEvent();
double currentTime() const;
double timelineTime() const;
virtual const AtomicString& interfaceName() const OVERRIDE;
virtual void trace(Visitor*) OVERRIDE;
private:
AnimationPlayerEvent();
AnimationPlayerEvent(const AtomicString& type, double currentTime, double timelineTime);
AnimationPlayerEvent(const AtomicString&, const AnimationPlayerEventInit&);
double m_currentTime;
double m_timelineTime;
};
} // namespace WebCore
#endif // AnimationPlayerEvent_h
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[
EventConstructor,
RuntimeEnabled=WebAnimationsAPI,
] interface AnimationPlayerEvent : Event {
[InitializedByEventConstructor] readonly attribute double currentTime;
[InitializedByEventConstructor] readonly attribute double timelineTime;
};
namespace="EventTarget"
core/animation/AnimationPlayer
core/css/FontFaceSet
core/dom/MessagePort
core/dom/Node
......
......@@ -78,6 +78,7 @@ enter
error
exit
fetch
finish
focus
focusin
focusout
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment