Backed out 9 changesets (bug 1846848) for causing multiple build bustages. CLOSED...
[gecko.git] / dom / animation / ComputedTiming.h
blobfe98277bb38bef416a313abf65d179e5bebdf9dd
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/. */
7 #ifndef mozilla_ComputedTiming_h
8 #define mozilla_ComputedTiming_h
10 #include "mozilla/dom/Nullable.h"
11 #include "mozilla/StickyTimeDuration.h"
13 #include "mozilla/dom/AnimationEffectBinding.h" // FillMode
15 namespace mozilla {
17 /**
18 * Stores the results of calculating the timing properties of an animation
19 * at a given sample time.
21 struct ComputedTiming {
22 // The total duration of the animation including all iterations.
23 // Will equal StickyTimeDuration::Forever() if the animation repeats
24 // indefinitely.
25 StickyTimeDuration mActiveDuration;
26 // The time within the active interval.
27 StickyTimeDuration mActiveTime;
28 // The effect end time in local time (i.e. an offset from the effect's
29 // start time). Will equal StickyTimeDuration::Forever() if the animation
30 // plays indefinitely.
31 StickyTimeDuration mEndTime;
32 // Progress towards the end of the current iteration. If the effect is
33 // being sampled backwards, this will go from 1.0 to 0.0.
34 // Will be null if the animation is neither animating nor
35 // filling at the sampled time.
36 dom::Nullable<double> mProgress;
37 // Zero-based iteration index (meaningless if mProgress is null).
38 uint64_t mCurrentIteration = 0;
39 // Unlike TimingParams::mIterations, this value is
40 // guaranteed to be in the range [0, Infinity].
41 double mIterations = 1.0;
42 double mIterationStart = 0.0;
43 StickyTimeDuration mDuration;
45 // This is the computed fill mode so it is never auto
46 dom::FillMode mFill = dom::FillMode::None;
47 bool FillsForwards() const {
48 MOZ_ASSERT(mFill != dom::FillMode::Auto,
49 "mFill should not be Auto in ComputedTiming.");
50 return mFill == dom::FillMode::Both || mFill == dom::FillMode::Forwards;
52 bool FillsBackwards() const {
53 MOZ_ASSERT(mFill != dom::FillMode::Auto,
54 "mFill should not be Auto in ComputedTiming.");
55 return mFill == dom::FillMode::Both || mFill == dom::FillMode::Backwards;
58 enum class AnimationPhase {
59 Idle, // Not sampled (null sample time)
60 Before, // Sampled prior to the start of the active interval
61 Active, // Sampled within the active interval
62 After // Sampled after (or at) the end of the active interval
64 AnimationPhase mPhase = AnimationPhase::Idle;
66 bool mBeforeFlag = false;
69 } // namespace mozilla
71 #endif // mozilla_ComputedTiming_h