/work/obj-fuzz/dist/include/nsSMILMilestone.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 |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef NS_SMILMILESTONE_H_ |
8 | | #define NS_SMILMILESTONE_H_ |
9 | | |
10 | | /* |
11 | | * A significant moment in an nsSMILTimedElement's lifetime where a sample is |
12 | | * required. |
13 | | * |
14 | | * Animations register the next milestone in their lifetime with the time |
15 | | * container that they belong to. When the animation controller goes to run |
16 | | * a sample it first visits all the animations that have a registered milestone |
17 | | * in order of their milestone times. This allows interdependencies between |
18 | | * animations to be correctly resolved and events to fire in the proper order. |
19 | | * |
20 | | * A distinction is made between a milestone representing the end of an interval |
21 | | * and any other milestone. This is because if animation A ends at time t, and |
22 | | * animation B begins at the same time t (or has some other significant moment |
23 | | * such as firing a repeat event), SMIL's endpoint-exclusive timing model |
24 | | * implies that the interval end occurs first. In fact, interval ends can be |
25 | | * thought of as ending an infinitesimally small time before t. Therefore, |
26 | | * A should be sampled before B. |
27 | | * |
28 | | * Furthermore, this distinction between sampling the end of an interval and |
29 | | * a regular sample is used within the timing model (specifically in |
30 | | * nsSMILTimedElement) to ensure that all intervals ending at time t are sampled |
31 | | * before any new intervals are entered so that we have a fully up-to-date set |
32 | | * of instance times available before committing to a new interval. Once an |
33 | | * interval is entered, the begin time is fixed. |
34 | | */ |
35 | | class nsSMILMilestone |
36 | | { |
37 | | public: |
38 | | nsSMILMilestone(nsSMILTime aTime, bool aIsEnd) |
39 | | : mTime(aTime), mIsEnd(aIsEnd) |
40 | | { } |
41 | | |
42 | | nsSMILMilestone() |
43 | | : mTime(0), mIsEnd(false) |
44 | | { } |
45 | | |
46 | | bool operator==(const nsSMILMilestone& aOther) const |
47 | | { |
48 | | return mTime == aOther.mTime && mIsEnd == aOther.mIsEnd; |
49 | | } |
50 | | |
51 | | bool operator!=(const nsSMILMilestone& aOther) const |
52 | 0 | { |
53 | 0 | return !(*this == aOther); |
54 | 0 | } |
55 | | |
56 | | bool operator<(const nsSMILMilestone& aOther) const |
57 | | { |
58 | | // Earlier times sort first, and for equal times end milestones sort first |
59 | | return mTime < aOther.mTime || |
60 | | (mTime == aOther.mTime && mIsEnd && !aOther.mIsEnd); |
61 | | } |
62 | | |
63 | | bool operator<=(const nsSMILMilestone& aOther) const |
64 | 0 | { |
65 | 0 | return *this == aOther || *this < aOther; |
66 | 0 | } |
67 | | |
68 | | bool operator>=(const nsSMILMilestone& aOther) const |
69 | | { |
70 | | return !(*this < aOther); |
71 | | } |
72 | | |
73 | | nsSMILTime mTime; // The milestone time. This may be in container time or |
74 | | // parent container time depending on where it is used. |
75 | | bool mIsEnd; // true if this milestone corresponds to an interval |
76 | | // end, false otherwise. |
77 | | }; |
78 | | |
79 | | #endif // NS_SMILMILESTONE_H_ |