CSSAnimationController.h [plain text]
#pragma once
#include "AnimationBase.h"
#include "CSSPropertyNames.h"
#include <wtf/Forward.h>
namespace WebCore {
class CSSAnimationControllerPrivate;
class Document;
class Element;
class Frame;
class LayoutRect;
class RenderElement;
class RenderStyle;
class CSSAnimationController {
WTF_MAKE_FAST_ALLOCATED;
public:
explicit CSSAnimationController(Frame&);
~CSSAnimationController();
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();
void serviceAnimations();
void updateThrottlingState();
WEBCORE_EXPORT Seconds animationInterval() const;
WEBCORE_EXPORT void suspendAnimationsForDocument(Document*);
WEBCORE_EXPORT void resumeAnimationsForDocument(Document*);
WEBCORE_EXPORT bool animationsAreSuspendedForDocument(Document*);
void detachFromDocument(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<CSSAnimationControllerPrivate> m_data;
};
class AnimationUpdateBlock {
public:
AnimationUpdateBlock(CSSAnimationController* animationController)
: m_animationController(animationController)
{
if (m_animationController)
m_animationController->beginAnimationUpdate();
}
~AnimationUpdateBlock()
{
if (m_animationController)
m_animationController->endAnimationUpdate();
}
CSSAnimationController* m_animationController;
};
}