AnimationTimeline.h [plain text]
#pragma once
#include "WebAnimation.h"
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/Optional.h>
#include <wtf/Ref.h>
#include <wtf/RefCounted.h>
#include <wtf/Seconds.h>
namespace WebCore {
class AnimationEffect;
class Element;
class WebAnimation;
class AnimationTimeline : public RefCounted<AnimationTimeline> {
public:
bool isDocumentTimeline() const { return m_classType == DocumentTimelineClass; }
void addAnimation(Ref<WebAnimation>&&);
void removeAnimation(Ref<WebAnimation>&&);
std::optional<double> bindingsCurrentTime();
virtual std::optional<Seconds> currentTime() { return m_currentTime; }
WEBCORE_EXPORT void setCurrentTime(Seconds);
WEBCORE_EXPORT String description();
WEBCORE_EXPORT virtual void pause() { };
virtual void animationTimingModelDidChange() { };
const HashSet<RefPtr<WebAnimation>>& animations() const { return m_animations; }
Vector<RefPtr<WebAnimation>> animationsForElement(Element&);
void animationWasAddedToElement(WebAnimation&, Element&);
void animationWasRemovedFromElement(WebAnimation&, Element&);
virtual ~AnimationTimeline();
protected:
enum ClassType {
DocumentTimelineClass
};
ClassType classType() const { return m_classType; }
explicit AnimationTimeline(ClassType);
const HashMap<RefPtr<Element>, Vector<RefPtr<WebAnimation>>>& elementToAnimationsMap() { return m_elementToAnimationsMap; }
private:
ClassType m_classType;
std::optional<Seconds> m_currentTime;
HashMap<RefPtr<Element>, Vector<RefPtr<WebAnimation>>> m_elementToAnimationsMap;
HashSet<RefPtr<WebAnimation>> m_animations;
};
}
#define SPECIALIZE_TYPE_TRAITS_ANIMATION_TIMELINE(ToValueTypeName, predicate) \
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
static bool isType(const WebCore::AnimationTimeline& value) { return value.predicate; } \
SPECIALIZE_TYPE_TRAITS_END()