#ifndef ScriptedAnimationController_h
#define ScriptedAnimationController_h
#include "heap/Handle.h"
#include "wtf/ListHashSet.h"
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
#include "wtf/Vector.h"
#include "wtf/text/StringImpl.h"
namespace WebCore {
class Document;
class Event;
class EventTarget;
class RequestAnimationFrameCallback;
class ScriptedAnimationController : public RefCounted<ScriptedAnimationController> {
public:
static PassRefPtr<ScriptedAnimationController> create(Document* document)
{
return adoptRef(new ScriptedAnimationController(document));
}
~ScriptedAnimationController();
void clearDocumentPointer() { m_document = 0; }
typedef int CallbackId;
int registerCallback(PassOwnPtr<RequestAnimationFrameCallback>);
void cancelCallback(CallbackId);
void serviceScriptedAnimations(double monotonicTimeNow);
void enqueueEvent(PassRefPtrWillBeRawPtr<Event>);
void enqueuePerFrameEvent(PassRefPtrWillBeRawPtr<Event>);
void suspend();
void resume();
private:
explicit ScriptedAnimationController(Document*);
void scheduleAnimationIfNeeded();
void dispatchEvents();
void executeCallbacks(double monotonicTimeNow);
typedef Vector<OwnPtr<RequestAnimationFrameCallback> > CallbackList;
CallbackList m_callbacks;
CallbackList m_callbacksToInvoke;
Document* m_document;
CallbackId m_nextCallbackId;
int m_suspendCount;
WillBePersistentHeapVector<RefPtrWillBeMember<Event> > m_eventQueue;
ListHashSet<std::pair<const EventTarget*, const StringImpl*> > m_perFrameEvents;
};
}
#endif