dom/smil/nsSMILMilestone.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial