Bug 1890793: Assert CallArgs::newTarget is not gray. r=spidermonkey-reviewers,sfink...
[gecko.git] / dom / svg / SVGMotionSMILType.h
blob8b62641035349ac32302fd460610500a49eb1f48
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* implementation of SMILType for use by <animateMotion> element */
9 #ifndef DOM_SVG_SVGMOTIONSMILTYPE_H_
10 #define DOM_SVG_SVGMOTIONSMILTYPE_H_
12 #include "mozilla/gfx/2D.h"
13 #include "mozilla/Attributes.h"
14 #include "mozilla/SMILType.h"
16 namespace mozilla {
18 class SMILValue;
20 /**
21 * MotionRotateType: Enum to indicate the type of our "rotate" attribute.
23 enum RotateType {
24 eRotateType_Explicit, // for e.g. rotate="45"/"45deg"/"0.785rad"
25 eRotateType_Auto, // for rotate="auto"
26 eRotateType_AutoReverse // for rotate="auto-reverse"
29 /**
30 * SVGMotionSMILType: Implements the SMILType interface for SMIL animations
31 * from <animateMotion>.
33 * NOTE: Even though there's technically no "motion" attribute, we behave in
34 * many ways as if there were, for simplicity.
36 class SVGMotionSMILType : public SMILType {
37 using Path = mozilla::gfx::Path;
39 public:
40 // Singleton for SMILValue objects to hold onto.
41 static SVGMotionSMILType sSingleton;
43 protected:
44 // SMILType Methods
45 // -------------------
46 void Init(SMILValue& aValue) const override;
47 void Destroy(SMILValue& aValue) const override;
48 nsresult Assign(SMILValue& aDest, const SMILValue& aSrc) const override;
49 bool IsEqual(const SMILValue& aLeft, const SMILValue& aRight) const override;
50 nsresult Add(SMILValue& aDest, const SMILValue& aValueToAdd,
51 uint32_t aCount) const override;
52 nsresult SandwichAdd(SMILValue& aDest,
53 const SMILValue& aValueToAdd) const override;
54 nsresult ComputeDistance(const SMILValue& aFrom, const SMILValue& aTo,
55 double& aDistance) const override;
56 nsresult Interpolate(const SMILValue& aStartVal, const SMILValue& aEndVal,
57 double aUnitDistance, SMILValue& aResult) const override;
59 public:
60 // Used to generate a transform matrix from an <animateMotion> SMILValue.
61 static gfx::Matrix CreateMatrix(const SMILValue& aSMILVal);
63 // Used to generate a SMILValue for the point at the given distance along
64 // the given path.
65 static SMILValue ConstructSMILValue(Path* aPath, float aDist,
66 RotateType aRotateType,
67 float aRotateAngle);
69 private:
70 // Private constructor: prevent instances beyond my singleton.
71 constexpr SVGMotionSMILType() = default;
74 } // namespace mozilla
76 #endif // DOM_SVG_SVGMOTIONSMILTYPE_H_