SVGAttributeAnimator.h [plain text]
#pragma once
#include "CSSPropertyNames.h"
#include "QualifiedName.h"
#include <wtf/RefCounted.h>
#include <wtf/StdLibExtras.h>
#include <wtf/WeakPtr.h>
namespace WebCore {
class SVGElement;
enum class AnimationMode : uint8_t {
None,
FromTo,
FromBy,
To,
By,
Values,
Path
};
enum class CalcMode : uint8_t {
Discrete,
Linear,
Paced,
Spline
};
class SVGAttributeAnimator : public RefCounted<SVGAttributeAnimator>, public CanMakeWeakPtr<SVGAttributeAnimator> {
WTF_MAKE_FAST_ALLOCATED;
public:
SVGAttributeAnimator(const QualifiedName& attributeName)
: m_attributeName(attributeName)
{
}
virtual ~SVGAttributeAnimator() = default;
virtual bool isDiscrete() const { return false; }
virtual void setFromAndToValues(SVGElement*, const String&, const String&) { }
virtual void setFromAndByValues(SVGElement*, const String&, const String&) { }
virtual void setToAtEndOfDurationValue(const String&) { }
virtual void start(SVGElement*) = 0;
virtual void animate(SVGElement*, float progress, unsigned repeatCount) = 0;
virtual void apply(SVGElement*) = 0;
virtual void stop(SVGElement* targetElement) = 0;
virtual Optional<float> calculateDistance(SVGElement*, const String&, const String&) const { return { }; }
protected:
bool isAnimatedStylePropertyAniamtor(const SVGElement*) const;
static void invalidateStyle(SVGElement*);
static void applyAnimatedStylePropertyChange(SVGElement*, CSSPropertyID, const String& value);
static void removeAnimatedStyleProperty(SVGElement*, CSSPropertyID);
static void applyAnimatedPropertyChange(SVGElement*, const QualifiedName&);
void applyAnimatedStylePropertyChange(SVGElement*, const String& value);
void removeAnimatedStyleProperty(SVGElement*);
void applyAnimatedPropertyChange(SVGElement*);
const QualifiedName& m_attributeName;
};
}