michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef NS_SMILMILESTONE_H_ michael@0: #define NS_SMILMILESTONE_H_ michael@0: michael@0: /* michael@0: * A significant moment in an nsSMILTimedElement's lifetime where a sample is michael@0: * required. michael@0: * michael@0: * Animations register the next milestone in their lifetime with the time michael@0: * container that they belong to. When the animation controller goes to run michael@0: * a sample it first visits all the animations that have a registered milestone michael@0: * in order of their milestone times. This allows interdependencies between michael@0: * animations to be correctly resolved and events to fire in the proper order. michael@0: * michael@0: * A distinction is made between a milestone representing the end of an interval michael@0: * and any other milestone. This is because if animation A ends at time t, and michael@0: * animation B begins at the same time t (or has some other significant moment michael@0: * such as firing a repeat event), SMIL's endpoint-exclusive timing model michael@0: * implies that the interval end occurs first. In fact, interval ends can be michael@0: * thought of as ending an infinitesimally small time before t. Therefore, michael@0: * A should be sampled before B. michael@0: * michael@0: * Furthermore, this distinction between sampling the end of an interval and michael@0: * a regular sample is used within the timing model (specifically in michael@0: * nsSMILTimedElement) to ensure that all intervals ending at time t are sampled michael@0: * before any new intervals are entered so that we have a fully up-to-date set michael@0: * of instance times available before committing to a new interval. Once an michael@0: * interval is entered, the begin time is fixed. michael@0: */ michael@0: class nsSMILMilestone michael@0: { michael@0: public: michael@0: nsSMILMilestone(nsSMILTime aTime, bool aIsEnd) michael@0: : mTime(aTime), mIsEnd(aIsEnd) michael@0: { } michael@0: michael@0: nsSMILMilestone() michael@0: : mTime(0), mIsEnd(false) michael@0: { } michael@0: michael@0: bool operator==(const nsSMILMilestone& aOther) const michael@0: { michael@0: return mTime == aOther.mTime && mIsEnd == aOther.mIsEnd; michael@0: } michael@0: michael@0: bool operator!=(const nsSMILMilestone& aOther) const michael@0: { michael@0: return !(*this == aOther); michael@0: } michael@0: michael@0: bool operator<(const nsSMILMilestone& aOther) const michael@0: { michael@0: // Earlier times sort first, and for equal times end milestones sort first michael@0: return mTime < aOther.mTime || michael@0: (mTime == aOther.mTime && mIsEnd && !aOther.mIsEnd); michael@0: } michael@0: michael@0: bool operator<=(const nsSMILMilestone& aOther) const michael@0: { michael@0: return *this == aOther || *this < aOther; michael@0: } michael@0: michael@0: bool operator>=(const nsSMILMilestone& aOther) const michael@0: { michael@0: return !(*this < aOther); michael@0: } michael@0: michael@0: nsSMILTime mTime; // The milestone time. This may be in container time or michael@0: // parent container time depending on where it is used. michael@0: bool mIsEnd; // true if this milestone corresponds to an interval michael@0: // end, false otherwise. michael@0: }; michael@0: michael@0: #endif // NS_SMILMILESTONE_H_