Bug 1941128 - Turn off network.dns.native_https_query on Mac again
[gecko.git] / dom / svg / SVGMotionSMILAnimationFunction.h
blobfd49092d020e474fd38c168cd138bf61f48a5318
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 #ifndef DOM_SVG_SVGMOTIONSMILANIMATIONFUNCTION_H_
8 #define DOM_SVG_SVGMOTIONSMILANIMATIONFUNCTION_H_
10 #include "mozilla/gfx/2D.h"
11 #include "mozilla/RefPtr.h"
12 #include "mozilla/SMILAnimationFunction.h"
13 #include "SVGMotionSMILType.h"
14 #include "nsTArray.h"
16 class nsAttrValue;
17 class nsAtom;
18 class nsIContent;
20 namespace mozilla {
22 class SMILAttr;
23 class SMILValue;
25 namespace dom {
26 class SVGMPathElement;
27 } // namespace dom
29 //----------------------------------------------------------------------
30 // SVGMotionSMILAnimationFunction
32 // Subclass of SMILAnimationFunction to support a few extra features offered
33 // by the <animateMotion> element.
35 class SVGMotionSMILAnimationFunction final : public SMILAnimationFunction {
36 using Path = mozilla::gfx::Path;
38 public:
39 SVGMotionSMILAnimationFunction();
40 bool SetAttr(nsAtom* aAttribute, const nsAString& aValue,
41 nsAttrValue& aResult, nsresult* aParseResult = nullptr) override;
42 bool UnsetAttr(nsAtom* aAttribute) override;
44 // Method to allow our owner-element to signal us when our <mpath>
45 // has changed or been added/removed. When that happens, we need to
46 // mark ourselves as changed so we'll get recomposed, and mark our path data
47 // as stale so it'll get regenerated (regardless of mPathSourceType, since
48 // <mpath> trumps all the other sources of path data)
49 void MpathChanged() { mIsPathStale = mHasChanged = true; }
51 protected:
52 enum PathSourceType {
53 // NOTE: Ordering matters here. Higher-priority path-descriptors should
54 // have higher enumerated values
55 ePathSourceType_None, // uninitialized or not applicable
56 ePathSourceType_ByAttr, // by or from-by animation
57 ePathSourceType_ToAttr, // to or from-to animation
58 ePathSourceType_ValuesAttr,
59 ePathSourceType_PathAttr,
60 ePathSourceType_Mpath
63 SMILCalcMode GetCalcMode() const override;
64 virtual nsresult GetValues(const SMILAttr& aSMILAttr,
65 SMILValueArray& aResult) override;
66 void CheckValueListDependentAttrs(uint32_t aNumValues) override;
68 bool IsToAnimation() const override;
70 void CheckKeyPoints();
71 nsresult SetKeyPoints(const nsAString& aKeyPoints, nsAttrValue& aResult);
72 void UnsetKeyPoints();
73 nsresult SetRotate(const nsAString& aRotate, nsAttrValue& aResult);
74 void UnsetRotate();
76 // Helpers for GetValues
77 void MarkStaleIfAttributeAffectsPath(nsAtom* aAttribute);
78 void RebuildPathAndVertices(const nsIContent* aTargetElement);
79 void RebuildPathAndVerticesFromMpathElem(dom::SVGMPathElement* aMpathElem);
80 void RebuildPathAndVerticesFromPathAttr();
81 void RebuildPathAndVerticesFromBasicAttrs(const nsIContent* aContextElem);
82 bool GenerateValuesForPathAndPoints(Path* aPath, bool aIsKeyPoints,
83 FallibleTArray<double>& aPointDistances,
84 SMILValueArray& aResult);
86 // Members
87 // -------
88 FallibleTArray<double> mKeyPoints; // parsed from "keyPoints" attribute.
90 RotateType mRotateType; // auto, auto-reverse, or explicit.
91 float mRotateAngle; // the angle value, if explicit.
93 PathSourceType mPathSourceType; // source of our Path.
94 RefPtr<Path> mPath; // representation of motion path.
95 FallibleTArray<double> mPathVertices; // distances of vertices along path.
97 bool mIsPathStale;
100 } // namespace mozilla
102 #endif // DOM_SVG_SVGMOTIONSMILANIMATIONFUNCTION_H_