AnimationController.h [plain text]
#pragma once
#include "AnimationBase.h"
#include "CSSPropertyNames.h"
#include <wtf/Forward.h>
namespace WebCore {
class AnimationControllerPrivate;
class Document;
class Element;
class Frame;
class LayoutRect;
class RenderElement;
class RenderStyle;
class AnimationController {
WTF_MAKE_FAST_ALLOCATED;
public:
explicit AnimationController(Frame&);
~AnimationController();
void cancelAnimations(RenderElement&);
bool updateAnimations(RenderElement&, const RenderStyle& newStyle, std::unique_ptr<RenderStyle>& animatedStyle);
std::unique_ptr<RenderStyle> getAnimatedStyleForRenderer(RenderElement&);
bool computeExtentOfAnimation(RenderElement&, LayoutRect&) const;
void notifyAnimationStarted(RenderElement&, double startTime);
WEBCORE_EXPORT bool pauseAnimationAtTime(RenderElement*, const AtomicString& name, double t); WEBCORE_EXPORT bool pauseTransitionAtTime(RenderElement*, const String& property, double t); WEBCORE_EXPORT unsigned numberOfActiveAnimations(Document*) const;
bool isRunningAnimationOnRenderer(RenderElement&, CSSPropertyID, AnimationBase::RunningState) const;
bool isRunningAcceleratedAnimationOnRenderer(RenderElement&, CSSPropertyID, AnimationBase::RunningState) const;
WEBCORE_EXPORT bool isSuspended() const;
WEBCORE_EXPORT void suspendAnimations();
WEBCORE_EXPORT void resumeAnimations();
#if ENABLE(REQUEST_ANIMATION_FRAME)
void serviceAnimations();
#endif
void suspendAnimationsForDocument(Document*);
void resumeAnimationsForDocument(Document*);
void startAnimationsIfNotSuspended(Document*);
void beginAnimationUpdate();
void endAnimationUpdate();
WEBCORE_EXPORT bool allowsNewAnimationsWhileSuspended() const;
WEBCORE_EXPORT void setAllowsNewAnimationsWhileSuspended(bool);
static bool supportsAcceleratedAnimationOfProperty(CSSPropertyID);
#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
bool wantsScrollUpdates() const;
void scrollWasUpdated();
#endif
bool hasAnimations() const;
private:
const std::unique_ptr<AnimationControllerPrivate> m_data;
};
class AnimationUpdateBlock {
public:
AnimationUpdateBlock(AnimationController* animationController)
: m_animationController(animationController)
{
if (m_animationController)
m_animationController->beginAnimationUpdate();
}
~AnimationUpdateBlock()
{
if (m_animationController)
m_animationController->endAnimationUpdate();
}
AnimationController* m_animationController;
};
}