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 | #pragma once |
22 | |
23 | #include "Path.h" |
24 | #include "SVGAnimationElement.h" |
25 | |
26 | namespace WebCore { |
27 | |
28 | class AffineTransform; |
29 | |
30 | class SVGAnimateMotionElement final : public SVGAnimationElement { |
31 | WTF_MAKE_ISO_ALLOCATED(SVGAnimateMotionElement); |
32 | public: |
33 | static Ref<SVGAnimateMotionElement> create(const QualifiedName&, Document&); |
34 | void updateAnimationPath(); |
35 | |
36 | private: |
37 | SVGAnimateMotionElement(const QualifiedName&, Document&); |
38 | |
39 | bool hasValidAttributeType() const override; |
40 | bool hasValidAttributeName() const override; |
41 | |
42 | void parseAttribute(const QualifiedName&, const AtomicString&) override; |
43 | |
44 | void resetAnimatedType() override; |
45 | void clearAnimatedType(SVGElement* targetElement) override; |
46 | bool calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString) override; |
47 | bool calculateFromAndToValues(const String& fromString, const String& toString) override; |
48 | bool calculateFromAndByValues(const String& fromString, const String& byString) override; |
49 | void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement* resultElement) override; |
50 | void applyResultsToTarget() override; |
51 | Optional<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 | 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 | |
74 | } // namespace WebCore |
75 | |