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