SVGAnimatedProperty.h [plain text]
#pragma once
#include "SVGAttributeAnimator.h"
#include "SVGPropertyOwner.h"
#include <wtf/Optional.h>
#include <wtf/RefCounted.h>
#include <wtf/WeakHashSet.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class SVGElement;
class SVGAnimatedProperty : public RefCounted<SVGAnimatedProperty>, public SVGPropertyOwner {
public:
virtual ~SVGAnimatedProperty() = default;
bool isAttached() const { return m_contextElement; }
void detach() { m_contextElement = nullptr; }
SVGElement* contextElement() const { return m_contextElement; }
virtual String baseValAsString() const { return emptyString(); }
virtual String animValAsString() const { return emptyString(); }
virtual bool isDirty() const { return false; }
virtual void setDirty() { }
virtual Optional<String> synchronize() { return WTF::nullopt; }
bool isAnimating() const { return m_animators.computeSize(); }
virtual void startAnimation(SVGAttributeAnimator& animator) { m_animators.add(animator); }
virtual void stopAnimation(SVGAttributeAnimator& animator) { m_animators.remove(animator); }
virtual void instanceStartAnimation(SVGAttributeAnimator& animator, SVGAnimatedProperty&) { startAnimation(animator); }
virtual void instanceStopAnimation(SVGAttributeAnimator& animator) { stopAnimation(animator); }
protected:
SVGAnimatedProperty(SVGElement* contextElement)
: m_contextElement(contextElement)
{
}
SVGPropertyOwner* owner() const override;
void commitPropertyChange(SVGProperty*) override;
SVGElement* m_contextElement { nullptr };
WeakHashSet<SVGAttributeAnimator> m_animators;
};
}