summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGAnimationElement.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGAnimationElement.h')
-rw-r--r--Source/WebCore/svg/SVGAnimationElement.h105
1 files changed, 43 insertions, 62 deletions
diff --git a/Source/WebCore/svg/SVGAnimationElement.h b/Source/WebCore/svg/SVGAnimationElement.h
index bbe4872b8..b8e258524 100644
--- a/Source/WebCore/svg/SVGAnimationElement.h
+++ b/Source/WebCore/svg/SVGAnimationElement.h
@@ -22,10 +22,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef SVGAnimationElement_h
-#define SVGAnimationElement_h
+#pragma once
-#if ENABLE(SVG)
#include "SMILTime.h"
#include "SVGAnimatedBoolean.h"
#include "SVGExternalResourcesRequired.h"
@@ -35,6 +33,10 @@
namespace WebCore {
+class ConditionEventListener;
+class SVGAnimatedType;
+class TimeContainer;
+
enum AnimationMode {
NoAnimation,
FromToAnimation,
@@ -47,31 +49,15 @@ enum AnimationMode {
// If we have 'currentColor' or 'inherit' as animation value, we need to grab
// the value during the animation since the value can be animated itself.
-enum AnimatedPropertyValueType {
- RegularPropertyValue,
- CurrentColorValue,
- InheritValue
-};
+enum AnimatedPropertyValueType { RegularPropertyValue, CurrentColorValue, InheritValue };
-enum CalcMode {
- CalcModeDiscrete,
- CalcModeLinear,
- CalcModePaced,
- CalcModeSpline
-};
+enum class CalcMode { Discrete, Linear, Paced, Spline };
-class ConditionEventListener;
-class TimeContainer;
-class SVGAnimatedType;
-
-class SVGAnimationElement : public SVGSMILElement,
- public SVGTests,
- public SVGExternalResourcesRequired {
+class SVGAnimationElement : public SVGSMILElement, public SVGTests, public SVGExternalResourcesRequired {
public:
- // SVGAnimationElement
float getStartTime() const;
float getCurrentTime() const;
- float getSimpleDuration(ExceptionCode&) const;
+ float getSimpleDuration() const;
void beginElement();
void beginElementAt(float offset);
@@ -80,7 +66,7 @@ public:
static bool isTargetAttributeCSSProperty(SVGElement*, const QualifiedName&);
- virtual bool isAdditive() const override;
+ bool isAdditive() const override;
bool isAccumulated() const;
AnimationMode animationMode() const { return m_animationMode; }
CalcMode calcMode() const { return m_calcMode; }
@@ -88,7 +74,8 @@ public:
enum ShouldApplyAnimation {
DontApplyAnimation,
ApplyCSSAnimation,
- ApplyXMLAnimation
+ ApplyXMLAnimation,
+ ApplyXMLandCSSAnimation // For presentation attributes with SVG DOM properties.
};
ShouldApplyAnimation shouldApplyAnimation(SVGElement* targetElement, const QualifiedName& attributeName);
@@ -96,9 +83,7 @@ public:
AnimatedPropertyValueType fromPropertyValueType() const { return m_fromPropertyValueType; }
AnimatedPropertyValueType toPropertyValueType() const { return m_toPropertyValueType; }
- template<typename AnimatedType>
- void adjustForInheritance(AnimatedType (*parseTypeFromString)(SVGAnimationElement*, const String&),
- AnimatedPropertyValueType valueType, AnimatedType& animatedType, SVGElement* contextElement)
+ template<typename AnimatedType> void adjustForInheritance(AnimatedType (*parseTypeFromString)(SVGAnimationElement*, const String&), AnimatedPropertyValueType valueType, AnimatedType& animatedType, SVGElement* contextElement)
{
if (valueType != InheritValue)
return;
@@ -109,8 +94,7 @@ public:
animatedType = (*parseTypeFromString)(this, typeString);
}
- template<typename AnimatedType>
- bool adjustFromToListValues(const AnimatedType& fromList, const AnimatedType& toList, AnimatedType& animatedList, float percentage, bool resizeAnimatedListIfNeeded = true)
+ template<typename AnimatedType> bool adjustFromToListValues(const AnimatedType& fromList, const AnimatedType& toList, AnimatedType& animatedList, float percentage, bool resizeAnimatedListIfNeeded = true)
{
// If no 'to' value is given, nothing to animate.
unsigned toListSize = toList.size();
@@ -136,8 +120,7 @@ public:
return true;
}
- template<typename AnimatedType>
- void animateDiscreteType(float percentage, const AnimatedType& fromType, const AnimatedType& toType, AnimatedType& animatedType)
+ template<typename AnimatedType> void animateDiscreteType(float percentage, const AnimatedType& fromType, const AnimatedType& toType, AnimatedType& animatedType)
{
if ((animationMode() == FromToAnimation && percentage > 0.5) || animationMode() == ToAnimation || percentage == 1) {
animatedType = AnimatedType(toType);
@@ -149,7 +132,7 @@ public:
void animateAdditiveNumber(float percentage, unsigned repeatCount, float fromNumber, float toNumber, float toAtEndOfDurationNumber, float& animatedNumber)
{
float number;
- if (calcMode() == CalcModeDiscrete)
+ if (calcMode() == CalcMode::Discrete)
number = percentage < 0.5 ? fromNumber : toNumber;
else
number = (toNumber - fromNumber) * percentage + fromNumber;
@@ -163,21 +146,23 @@ public:
animatedNumber = number;
}
+ // SVGTests
+ Ref<SVGStringList> requiredFeatures();
+ Ref<SVGStringList> requiredExtensions();
+ Ref<SVGStringList> systemLanguage();
+
protected:
SVGAnimationElement(const QualifiedName&, Document&);
void computeCSSPropertyValue(SVGElement*, CSSPropertyID, String& value);
virtual void determinePropertyValueTypes(const String& from, const String& to);
+ virtual void resetAnimatedPropertyType();
- bool isSupportedAttribute(const QualifiedName&);
- virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
- virtual void svgAttributeChanged(const QualifiedName&) override;
+ static bool isSupportedAttribute(const QualifiedName&);
+ void parseAttribute(const QualifiedName&, const AtomicString&) override;
+ void svgAttributeChanged(const QualifiedName&) override;
- enum AttributeType {
- AttributeTypeCSS,
- AttributeTypeXML,
- AttributeTypeAuto
- };
+ enum class AttributeType { CSS, XML, Auto };
AttributeType attributeType() const { return m_attributeType; }
String toValue() const;
@@ -187,26 +172,25 @@ protected:
String targetAttributeBaseValue();
// from SVGSMILElement
- virtual void startedActiveInterval() override;
- virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) override;
+ void startedActiveInterval() override;
+ void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) override;
- AnimatedPropertyValueType m_fromPropertyValueType;
- AnimatedPropertyValueType m_toPropertyValueType;
+ AnimatedPropertyValueType m_fromPropertyValueType { RegularPropertyValue };
+ AnimatedPropertyValueType m_toPropertyValueType { RegularPropertyValue };
- virtual void setTargetElement(SVGElement*) override;
- virtual void setAttributeName(const QualifiedName&) override;
+ void setTargetElement(SVGElement*) override;
+ void setAttributeName(const QualifiedName&) override { }
bool hasInvalidCSSAttributeType() const { return m_hasInvalidCSSAttributeType; }
+ void checkInvalidCSSAttributeType(SVGElement*);
virtual void updateAnimationMode();
void setAnimationMode(AnimationMode animationMode) { m_animationMode = animationMode; }
void setCalcMode(CalcMode calcMode) { m_calcMode = calcMode; }
private:
- virtual void animationAttributeChanged() override;
+ void animationAttributeChanged() override;
void setAttributeType(const AtomicString&);
- void checkInvalidCSSAttributeType(SVGElement*);
-
virtual bool calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString) = 0;
virtual bool calculateFromAndToValues(const String& fromString, const String& toString) = 0;
virtual bool calculateFromAndByValues(const String& fromString, const String& byString) = 0;
@@ -225,31 +209,28 @@ private:
void adjustForInheritance(SVGElement* targetElement, const QualifiedName& attributeName, String&);
BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGAnimationElement)
- DECLARE_ANIMATED_BOOLEAN(ExternalResourcesRequired, externalResourcesRequired)
+ DECLARE_ANIMATED_BOOLEAN_OVERRIDE(ExternalResourcesRequired, externalResourcesRequired)
END_DECLARE_ANIMATED_PROPERTIES
// SVGTests
- virtual void synchronizeRequiredFeatures() override { SVGTests::synchronizeRequiredFeatures(this); }
- virtual void synchronizeRequiredExtensions() override { SVGTests::synchronizeRequiredExtensions(this); }
- virtual void synchronizeSystemLanguage() override { SVGTests::synchronizeSystemLanguage(this); }
+ void synchronizeRequiredFeatures() final { SVGTests::synchronizeRequiredFeatures(*this); }
+ void synchronizeRequiredExtensions() final { SVGTests::synchronizeRequiredExtensions(*this); }
+ void synchronizeSystemLanguage() final { SVGTests::synchronizeSystemLanguage(*this); }
void setCalcMode(const AtomicString&);
- bool m_animationValid;
+ bool m_animationValid { false };
- AttributeType m_attributeType;
+ AttributeType m_attributeType { AttributeType::Auto };
Vector<String> m_values;
Vector<float> m_keyTimes;
Vector<float> m_keyPoints;
Vector<UnitBezier> m_keySplines;
String m_lastValuesAnimationFrom;
String m_lastValuesAnimationTo;
- bool m_hasInvalidCSSAttributeType;
- CalcMode m_calcMode;
- AnimationMode m_animationMode;
+ bool m_hasInvalidCSSAttributeType { false };
+ CalcMode m_calcMode { CalcMode::Linear };
+ AnimationMode m_animationMode { NoAnimation };
};
} // namespace WebCore
-
-#endif // ENABLE(SVG)
-#endif // SVGAnimationElement_h