1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/smil/nsSMILMilestone.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef NS_SMILMILESTONE_H_ 1.10 +#define NS_SMILMILESTONE_H_ 1.11 + 1.12 +/* 1.13 + * A significant moment in an nsSMILTimedElement's lifetime where a sample is 1.14 + * required. 1.15 + * 1.16 + * Animations register the next milestone in their lifetime with the time 1.17 + * container that they belong to. When the animation controller goes to run 1.18 + * a sample it first visits all the animations that have a registered milestone 1.19 + * in order of their milestone times. This allows interdependencies between 1.20 + * animations to be correctly resolved and events to fire in the proper order. 1.21 + * 1.22 + * A distinction is made between a milestone representing the end of an interval 1.23 + * and any other milestone. This is because if animation A ends at time t, and 1.24 + * animation B begins at the same time t (or has some other significant moment 1.25 + * such as firing a repeat event), SMIL's endpoint-exclusive timing model 1.26 + * implies that the interval end occurs first. In fact, interval ends can be 1.27 + * thought of as ending an infinitesimally small time before t. Therefore, 1.28 + * A should be sampled before B. 1.29 + * 1.30 + * Furthermore, this distinction between sampling the end of an interval and 1.31 + * a regular sample is used within the timing model (specifically in 1.32 + * nsSMILTimedElement) to ensure that all intervals ending at time t are sampled 1.33 + * before any new intervals are entered so that we have a fully up-to-date set 1.34 + * of instance times available before committing to a new interval. Once an 1.35 + * interval is entered, the begin time is fixed. 1.36 + */ 1.37 +class nsSMILMilestone 1.38 +{ 1.39 +public: 1.40 + nsSMILMilestone(nsSMILTime aTime, bool aIsEnd) 1.41 + : mTime(aTime), mIsEnd(aIsEnd) 1.42 + { } 1.43 + 1.44 + nsSMILMilestone() 1.45 + : mTime(0), mIsEnd(false) 1.46 + { } 1.47 + 1.48 + bool operator==(const nsSMILMilestone& aOther) const 1.49 + { 1.50 + return mTime == aOther.mTime && mIsEnd == aOther.mIsEnd; 1.51 + } 1.52 + 1.53 + bool operator!=(const nsSMILMilestone& aOther) const 1.54 + { 1.55 + return !(*this == aOther); 1.56 + } 1.57 + 1.58 + bool operator<(const nsSMILMilestone& aOther) const 1.59 + { 1.60 + // Earlier times sort first, and for equal times end milestones sort first 1.61 + return mTime < aOther.mTime || 1.62 + (mTime == aOther.mTime && mIsEnd && !aOther.mIsEnd); 1.63 + } 1.64 + 1.65 + bool operator<=(const nsSMILMilestone& aOther) const 1.66 + { 1.67 + return *this == aOther || *this < aOther; 1.68 + } 1.69 + 1.70 + bool operator>=(const nsSMILMilestone& aOther) const 1.71 + { 1.72 + return !(*this < aOther); 1.73 + } 1.74 + 1.75 + nsSMILTime mTime; // The milestone time. This may be in container time or 1.76 + // parent container time depending on where it is used. 1.77 + bool mIsEnd; // true if this milestone corresponds to an interval 1.78 + // end, false otherwise. 1.79 +}; 1.80 + 1.81 +#endif // NS_SMILMILESTONE_H_