/work/obj-fuzz/dist/include/mozilla/dom/AnimationEffect.h
Line | Count | Source (jump to first uncovered line) |
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 file, |
5 | | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_AnimationEffect_h |
8 | | #define mozilla_dom_AnimationEffect_h |
9 | | |
10 | | #include "mozilla/ComputedTiming.h" |
11 | | #include "mozilla/dom/BindingDeclarations.h" |
12 | | #include "mozilla/dom/Nullable.h" |
13 | | #include "mozilla/Maybe.h" |
14 | | #include "mozilla/StickyTimeDuration.h" |
15 | | #include "mozilla/TimeStamp.h" |
16 | | #include "mozilla/TimingParams.h" |
17 | | #include "nsCycleCollectionParticipant.h" |
18 | | #include "nsWrapperCache.h" |
19 | | |
20 | | namespace mozilla { |
21 | | |
22 | | struct ElementPropertyTransition; |
23 | | |
24 | | namespace dom { |
25 | | |
26 | | class Animation; |
27 | | class KeyframeEffect; |
28 | | struct ComputedEffectTiming; |
29 | | |
30 | | class AnimationEffect : public nsISupports, |
31 | | public nsWrapperCache |
32 | | { |
33 | | public: |
34 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
35 | | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AnimationEffect) |
36 | | |
37 | | AnimationEffect(nsIDocument* aDocument, const TimingParams& aTiming); |
38 | | |
39 | 0 | virtual KeyframeEffect* AsKeyframeEffect() { return nullptr; } |
40 | | |
41 | 0 | virtual ElementPropertyTransition* AsTransition() { return nullptr; } |
42 | | virtual const ElementPropertyTransition* AsTransition() const |
43 | 0 | { |
44 | 0 | return nullptr; |
45 | 0 | } |
46 | | |
47 | 0 | nsISupports* GetParentObject() const { return mDocument; } |
48 | | |
49 | | bool IsCurrent() const; |
50 | | bool IsInEffect() const; |
51 | | bool HasFiniteActiveDuration() const |
52 | 0 | { |
53 | 0 | return SpecifiedTiming().ActiveDuration() != TimeDuration::Forever(); |
54 | 0 | } |
55 | | |
56 | | // AnimationEffect interface |
57 | | void GetTiming(EffectTiming& aRetVal) const; |
58 | | void GetComputedTimingAsDict(ComputedEffectTiming& aRetVal) const; |
59 | | void UpdateTiming(const OptionalEffectTiming& aTiming, ErrorResult& aRv); |
60 | | |
61 | 0 | const TimingParams& SpecifiedTiming() const { return mTiming; } |
62 | | void SetSpecifiedTiming(const TimingParams& aTiming); |
63 | | |
64 | | // This function takes as input the timing parameters of an animation and |
65 | | // returns the computed timing at the specified local time. |
66 | | // |
67 | | // The local time may be null in which case only static parameters such as the |
68 | | // active duration are calculated. All other members of the returned object |
69 | | // are given a null/initial value. |
70 | | // |
71 | | // This function returns a null mProgress member of the return value |
72 | | // if the animation should not be run |
73 | | // (because it is not currently active and is not filling at this time). |
74 | | static ComputedTiming |
75 | | GetComputedTimingAt(const Nullable<TimeDuration>& aLocalTime, |
76 | | const TimingParams& aTiming, |
77 | | double aPlaybackRate); |
78 | | // Shortcut that gets the computed timing using the current local time as |
79 | | // calculated from the timeline time. |
80 | | ComputedTiming GetComputedTiming(const TimingParams* aTiming = nullptr) const; |
81 | | |
82 | | virtual void SetAnimation(Animation* aAnimation) = 0; |
83 | 0 | Animation* GetAnimation() const { return mAnimation; }; |
84 | | |
85 | | /** |
86 | | * Returns true if this effect animates one of the properties we consider |
87 | | * geometric properties, e.g. properties such as 'width' or 'margin-left' |
88 | | * that we try to synchronize with transform animations, on a valid target |
89 | | * element. |
90 | | */ |
91 | | virtual bool AffectsGeometry() const = 0; |
92 | | |
93 | | protected: |
94 | | virtual ~AnimationEffect(); |
95 | | |
96 | | Nullable<TimeDuration> GetLocalTime() const; |
97 | | |
98 | | protected: |
99 | | RefPtr<nsIDocument> mDocument; |
100 | | RefPtr<Animation> mAnimation; |
101 | | TimingParams mTiming; |
102 | | }; |
103 | | |
104 | | } // namespace dom |
105 | | } // namespace mozilla |
106 | | |
107 | | #endif // mozilla_dom_AnimationEffect_h |