1 | /* |
2 | * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> |
3 | * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
4 | * Copyright (C) 2008-2019 Apple Inc. All rights reserved. |
5 | * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
6 | * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved. |
7 | * |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Library General Public |
10 | * License as published by the Free Software Foundation; either |
11 | * version 2 of the License, or (at your option) any later version. |
12 | * |
13 | * This library is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Library General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU Library General Public License |
19 | * along with this library; see the file COPYING.LIB. If not, write to |
20 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 | * Boston, MA 02110-1301, USA. |
22 | */ |
23 | |
24 | #pragma once |
25 | |
26 | #include "SVGAnimationElement.h" |
27 | #include "SVGNames.h" |
28 | |
29 | namespace WebCore { |
30 | |
31 | class SVGAttributeAnimator; |
32 | |
33 | class SVGAnimateElementBase : public SVGAnimationElement { |
34 | WTF_MAKE_ISO_ALLOCATED(SVGAnimateElementBase); |
35 | public: |
36 | bool isDiscreteAnimator() const; |
37 | |
38 | protected: |
39 | SVGAnimateElementBase(const QualifiedName&, Document&); |
40 | |
41 | SVGAttributeAnimator* animator() const; |
42 | SVGAttributeAnimator* animatorIfExists() const { return m_animator.get(); } |
43 | |
44 | bool hasValidAttributeType() const override; |
45 | |
46 | void setTargetElement(SVGElement*) override; |
47 | void setAttributeName(const QualifiedName&) override; |
48 | void resetAnimation() override; |
49 | |
50 | bool calculateFromAndToValues(const String& fromString, const String& toString) override; |
51 | bool calculateFromAndByValues(const String& fromString, const String& byString) override; |
52 | bool calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString) override; |
53 | |
54 | void resetAnimatedType() override; |
55 | void calculateAnimatedValue(float progress, unsigned repeatCount, SVGSMILElement* resultElement) override; |
56 | void applyResultsToTarget() override; |
57 | void clearAnimatedType(SVGElement* targetElement) override; |
58 | Optional<float> calculateDistance(const String& fromString, const String& toString) override; |
59 | |
60 | virtual String animateRangeString(const String& string) const { return string; } |
61 | |
62 | private: |
63 | bool hasInvalidCSSAttributeType() const; |
64 | |
65 | mutable std::unique_ptr<SVGAttributeAnimator> m_animator; |
66 | mutable Optional<bool> m_hasInvalidCSSAttributeType; |
67 | }; |
68 | |
69 | } // namespace WebCore |
70 | |
71 | SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGAnimateElementBase) |
72 | static bool isType(const WebCore::SVGElement& element) |
73 | { |
74 | return element.hasTagName(WebCore::SVGNames::animateTag) || element.hasTagName(WebCore::SVGNames::animateColorTag) |
75 | || element.hasTagName(WebCore::SVGNames::animateTransformTag) || element.hasTagName(WebCore::SVGNames::setTag); |
76 | } |
77 | static bool isType(const WebCore::Node& node) { return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node)); } |
78 | SPECIALIZE_TYPE_TRAITS_END() |
79 | |