SVGAnimationElement.h [plain text]
#ifndef SVGAnimationElement_h
#define SVGAnimationElement_h
#if ENABLE(SVG)
#include "SVGExternalResourcesRequired.h"
#include "SVGStringList.h"
#include "SVGTests.h"
namespace WebCore {
enum EFillMode {
FILL_REMOVE = 0,
FILL_FREEZE
};
enum EAdditiveMode {
ADDITIVE_REPLACE = 0,
ADDITIVE_SUM
};
enum EAccumulateMode {
ACCUMULATE_NONE = 0,
ACCUMULATE_SUM
};
enum ECalcMode {
CALCMODE_DISCRETE = 0,
CALCMODE_LINEAR,
CALCMODE_PACED,
CALCMODE_SPLINE
};
enum ERestart {
RESTART_ALWAYS = 0,
RESTART_WHENNOTACTIVE,
RESTART_NEVER
};
enum EAttributeType {
ATTRIBUTETYPE_CSS = 0,
ATTRIBUTETYPE_XML,
ATTRIBUTETYPE_AUTO
};
enum EAnimationMode {
NO_ANIMATION = 0,
TO_ANIMATION,
BY_ANIMATION,
VALUES_ANIMATION,
FROM_TO_ANIMATION,
FROM_BY_ANIMATION
};
class SVGAnimationElement : public SVGElement,
public SVGTests,
public SVGExternalResourcesRequired
{
public:
SVGAnimationElement(const QualifiedName&, Document*);
virtual ~SVGAnimationElement();
SVGElement* targetElement() const;
virtual bool hasValidTarget() const;
bool isValidAnimation() const;
virtual bool isValid() const { return SVGTests::isValid(); }
float getEndTime() const;
float getStartTime() const;
float getCurrentTime() const;
float getSimpleDuration(ExceptionCode&) const;
virtual void parseMappedAttribute(MappedAttribute* attr);
virtual void finishParsingChildren();
virtual bool updateAnimationBaseValueFromElement();
bool updateAnimatedValueForElapsedSeconds(double elapsedSeconds);
virtual void applyAnimatedValueToElement();
String attributeName() const;
bool connectedToTimer() const;
bool isFrozen() const;
bool isAdditive() const;
bool isAccumulated() const;
double repeations() const;
static bool isIndefinite(double value);
protected:
mutable SVGElement* m_targetElement;
EAnimationMode detectAnimationMode() const;
static double parseClockValue(const String&);
static void setTargetAttribute(SVGElement* target, const String& name, const String& value, EAttributeType = ATTRIBUTETYPE_AUTO);
String targetAttributeAnimatedValue() const;
void setTargetAttributeAnimatedValue(const String&);
void connectTimer();
void disconnectTimer();
virtual float calculateTotalDistance();
virtual void valueIndexAndPercentagePastForDistance(float distancePercentage, unsigned& valueIndex, float& percentagePast);
void calculateValueIndexAndPercentagePast(float timePercentage, unsigned& valueIndex, float& percentagePast);
void handleTimerEvent(double elapsedSeconds, double timePercentage);
virtual bool updateAnimatedValue(EAnimationMode, float timePercentage, unsigned valueIndex, float percentagePast) = 0;
virtual bool calculateFromAndToValues(EAnimationMode, unsigned valueIndex) = 0;
static void parseKeyNumbers(Vector<float>& keyNumbers, const String& value);
static void parseBeginOrEndValue(double& number, const String& value);
ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired)
bool m_connectedToTimer : 1;
double m_currentTime;
double m_simpleDuration;
unsigned m_fill : 1; unsigned m_restart : 2; unsigned m_calcMode : 2; unsigned m_additive : 1; unsigned m_accumulate : 1; unsigned m_attributeType : 2;
String m_to;
String m_by;
String m_from;
String m_href;
String m_repeatDur;
String m_attributeName;
String m_baseValue;
String m_animatedValue;
double m_max;
double m_min;
double m_end;
double m_begin;
double m_repetitions;
double m_repeatCount;
Vector<String> m_values;
Vector<float> m_keyTimes;
struct KeySpline {
FloatPoint control1;
FloatPoint control2;
};
Vector<KeySpline> m_keySplines;
};
}
#endif // ENABLE(SVG)
#endif // SVGAnimationElement_h