CompositeAnimation.h [plain text]
#pragma once
#include "CSSAnimationController.h"
#include "ImplicitAnimation.h"
#include "KeyframeAnimation.h"
#include <wtf/HashMap.h>
#include <wtf/text/AtomicString.h>
namespace WebCore {
class CSSAnimationControllerPrivate;
class CSSAnimationController;
class RenderElement;
class RenderStyle;
class CompositeAnimation : public RefCounted<CompositeAnimation> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<CompositeAnimation> create(CSSAnimationControllerPrivate& animationController)
{
return adoptRef(*new CompositeAnimation(animationController));
};
~CompositeAnimation();
void clearElement();
AnimationUpdate animate(Element&, const RenderStyle* currentStyle, const RenderStyle& targetStyle);
std::unique_ptr<RenderStyle> getAnimatedStyle() const;
bool computeExtentOfTransformAnimation(LayoutRect&) const;
std::optional<Seconds> timeToNextService() const;
CSSAnimationControllerPrivate& animationController() const { return m_animationController; }
void suspendAnimations();
void resumeAnimations();
bool isSuspended() const { return m_suspended; }
bool hasAnimations() const { return !m_transitions.isEmpty() || !m_keyframeAnimations.isEmpty(); }
bool isAnimatingProperty(CSSPropertyID, bool acceleratedOnly, AnimationBase::RunningState) const;
KeyframeAnimation* animationForProperty(CSSPropertyID) const;
void overrideImplicitAnimations(CSSPropertyID);
void resumeOverriddenImplicitAnimations(CSSPropertyID);
bool pauseAnimationAtTime(const AtomicString& name, double t);
bool pauseTransitionAtTime(CSSPropertyID, double);
unsigned numberOfActiveAnimations() const;
#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
bool hasScrollTriggeredAnimation() const { return m_hasScrollTriggeredAnimation; }
#endif
bool hasAnimationThatDependsOnLayout() const { return m_hasAnimationThatDependsOnLayout; }
private:
CompositeAnimation(CSSAnimationControllerPrivate&);
void updateTransitions(Element&, const RenderStyle* currentStyle, const RenderStyle& targetStyle);
void updateKeyframeAnimations(Element&, const RenderStyle* currentStyle, const RenderStyle& targetStyle);
typedef HashMap<int, RefPtr<ImplicitAnimation>> CSSPropertyTransitionsMap;
typedef HashMap<AtomicStringImpl*, RefPtr<KeyframeAnimation>> AnimationNameMap;
CSSAnimationControllerPrivate& m_animationController;
CSSPropertyTransitionsMap m_transitions;
AnimationNameMap m_keyframeAnimations;
Vector<AtomicStringImpl*> m_keyframeAnimationOrderMap;
bool m_suspended;
bool m_hasAnimationThatDependsOnLayout { false };
#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
bool m_hasScrollTriggeredAnimation { false };
#endif
};
}