1/*
2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
3 * Copyright (C) 2008 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB.  If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifndef SVGAnimateMotionElement_h
22#define SVGAnimateMotionElement_h
23#include "Path.h"
24#include "SVGAnimationElement.h"
25
26namespace WebCore {
27
28class AffineTransform;
29
30class SVGAnimateMotionElement final : public SVGAnimationElement {
31public:
32    static PassRefPtr<SVGAnimateMotionElement> create(const QualifiedName&, Document&);
33    void updateAnimationPath();
34
35private:
36    SVGAnimateMotionElement(const QualifiedName&, Document&);
37
38    virtual bool hasValidAttributeType() override;
39    virtual bool hasValidAttributeName() override;
40
41    bool isSupportedAttribute(const QualifiedName&);
42    virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
43
44    virtual void resetAnimatedType() override;
45    virtual void clearAnimatedType(SVGElement* targetElement) override;
46    virtual bool calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString) override;
47    virtual bool calculateFromAndToValues(const String& fromString, const String& toString) override;
48    virtual bool calculateFromAndByValues(const String& fromString, const String& byString) override;
49    virtual void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement* resultElement) override;
50    virtual void applyResultsToTarget() override;
51    virtual float calculateDistance(const String& fromString, const String& toString) override;
52
53    enum RotateMode {
54        RotateAngle,
55        RotateAuto,
56        RotateAutoReverse
57    };
58    RotateMode rotateMode() const;
59    void buildTransformForProgress(AffineTransform*, float percentage);
60
61    bool m_hasToPointAtEndOfDuration;
62
63    virtual void updateAnimationMode() override;
64
65    // Note: we do not support percentage values for to/from coords as the spec implies we should (opera doesn't either)
66    FloatPoint m_fromPoint;
67    FloatPoint m_toPoint;
68    FloatPoint m_toPointAtEndOfDuration;
69
70    Path m_path;
71    Path m_animationPath;
72};
73
74NODE_TYPE_CASTS(SVGAnimateMotionElement)
75
76} // namespace WebCore
77
78#endif // SVGAnimateMotionElement_h
79