1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef NS_SMILMILESTONE_H_
7 #define NS_SMILMILESTONE_H_
10 * A significant moment in an nsSMILTimedElement's lifetime where a sample is
13 * Animations register the next milestone in their lifetime with the time
14 * container that they belong to. When the animation controller goes to run
15 * a sample it first visits all the animations that have a registered milestone
16 * in order of their milestone times. This allows interdependencies between
17 * animations to be correctly resolved and events to fire in the proper order.
19 * A distinction is made between a milestone representing the end of an interval
20 * and any other milestone. This is because if animation A ends at time t, and
21 * animation B begins at the same time t (or has some other significant moment
22 * such as firing a repeat event), SMIL's endpoint-exclusive timing model
23 * implies that the interval end occurs first. In fact, interval ends can be
24 * thought of as ending an infinitesimally small time before t. Therefore,
25 * A should be sampled before B.
27 * Furthermore, this distinction between sampling the end of an interval and
28 * a regular sample is used within the timing model (specifically in
29 * nsSMILTimedElement) to ensure that all intervals ending at time t are sampled
30 * before any new intervals are entered so that we have a fully up-to-date set
31 * of instance times available before committing to a new interval. Once an
32 * interval is entered, the begin time is fixed.
37 nsSMILMilestone(nsSMILTime aTime
, bool aIsEnd
)
38 : mTime(aTime
), mIsEnd(aIsEnd
)
42 : mTime(0), mIsEnd(false)
45 bool operator==(const nsSMILMilestone
& aOther
) const
47 return mTime
== aOther
.mTime
&& mIsEnd
== aOther
.mIsEnd
;
50 bool operator!=(const nsSMILMilestone
& aOther
) const
52 return !(*this == aOther
);
55 bool operator<(const nsSMILMilestone
& aOther
) const
57 // Earlier times sort first, and for equal times end milestones sort first
58 return mTime
< aOther
.mTime
||
59 (mTime
== aOther
.mTime
&& mIsEnd
&& !aOther
.mIsEnd
);
62 bool operator<=(const nsSMILMilestone
& aOther
) const
64 return *this == aOther
|| *this < aOther
;
67 bool operator>=(const nsSMILMilestone
& aOther
) const
69 return !(*this < aOther
);
72 nsSMILTime mTime
; // The milestone time. This may be in container time or
73 // parent container time depending on where it is used.
74 bool mIsEnd
; // true if this milestone corresponds to an interval
75 // end, false otherwise.
78 #endif // NS_SMILMILESTONE_H_