1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
/*
* Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
* Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
* Copyright (C) 2008 Apple Inc. All rights reserved.
* Copyright (C) Research In Motion Limited 2011. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef SVGAnimateElement_h
#define SVGAnimateElement_h
#include "core/CSSPropertyNames.h"
#include "core/CoreExport.h"
#include "core/SVGNames.h"
#include "core/svg/SVGAnimationElement.h"
#include "platform/heap/Handle.h"
#include <base/gtest_prod_util.h>
namespace blink {
// If we have 'inherit' as animation value, we need to grab the value
// during the animation since the value can be animated itself.
enum AnimatedPropertyValueType { RegularPropertyValue, InheritValue };
class CORE_EXPORT SVGAnimateElement : public SVGAnimationElement {
DEFINE_WRAPPERTYPEINFO();
public:
static SVGAnimateElement* create(Document&);
~SVGAnimateElement() override;
DECLARE_VIRTUAL_TRACE();
bool isSVGAnimationAttributeSettingJavaScriptURL(
const Attribute&) const override;
AnimatedPropertyType animatedPropertyType();
bool animatedPropertyTypeSupportsAddition();
protected:
SVGAnimateElement(const QualifiedName&, Document&);
bool hasValidTarget() override;
void resetAnimatedType() final;
void clearAnimatedType() final;
bool calculateToAtEndOfDurationValue(
const String& toAtEndOfDurationString) final;
bool calculateFromAndToValues(const String& fromString,
const String& toString) final;
bool calculateFromAndByValues(const String& fromString,
const String& byString) final;
void calculateAnimatedValue(float percentage,
unsigned repeatCount,
SVGSMILElement* resultElement) final;
void applyResultsToTarget() final;
float calculateDistance(const String& fromString,
const String& toString) final;
bool isAdditive() final;
void parseAttribute(const AttributeModificationParams&) override;
void svgAttributeChanged(const QualifiedName&) override;
void setTargetElement(SVGElement*) final;
void setAttributeName(const QualifiedName&);
enum AttributeType { AttributeTypeCSS, AttributeTypeXML, AttributeTypeAuto };
AttributeType getAttributeType() const { return m_attributeType; }
FRIEND_TEST_ALL_PREFIXES(UnsafeSVGAttributeSanitizationTest,
stringsShouldNotSupportAddition);
private:
void resetAnimatedPropertyType();
bool shouldApplyAnimation(const SVGElement& targetElement,
const QualifiedName& attributeName);
void setAttributeType(const AtomicString&);
InsertionNotificationRequest insertedInto(ContainerNode*) final;
void removedFrom(ContainerNode*) final;
void checkInvalidCSSAttributeType();
bool hasValidAttributeName() const;
virtual void resolveTargetProperty();
void clearTargetProperty();
virtual SVGPropertyBase* createPropertyForAnimation(const String&) const;
SVGPropertyBase* createPropertyForAttributeAnimation(const String&) const;
SVGPropertyBase* createPropertyForCSSAnimation(const String&) const;
SVGPropertyBase* adjustForInheritance(SVGPropertyBase*,
AnimatedPropertyValueType) const;
Member<SVGPropertyBase> m_fromProperty;
Member<SVGPropertyBase> m_toProperty;
Member<SVGPropertyBase> m_toAtEndOfDurationProperty;
Member<SVGPropertyBase> m_animatedValue;
protected:
Member<SVGAnimatedPropertyBase> m_targetProperty;
AnimatedPropertyType m_type;
CSSPropertyID m_cssPropertyId;
bool isAnimatingSVGDom() const { return m_targetProperty; }
bool isAnimatingCSSProperty() const {
return m_cssPropertyId != CSSPropertyInvalid;
}
private:
AnimatedPropertyValueType m_fromPropertyValueType;
AnimatedPropertyValueType m_toPropertyValueType;
AttributeType m_attributeType;
bool m_hasInvalidCSSAttributeType;
};
inline bool isSVGAnimateElement(const SVGElement& element) {
return element.hasTagName(SVGNames::animateTag) ||
element.hasTagName(SVGNames::animateTransformTag) ||
element.hasTagName(SVGNames::setTag);
}
DEFINE_SVGELEMENT_TYPE_CASTS_WITH_FUNCTION(SVGAnimateElement);
} // namespace blink
#endif // SVGAnimateElement_h
|