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.

     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_
     9 /*
    10  * A significant moment in an nsSMILTimedElement's lifetime where a sample is
    11  * required.
    12  *
    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.
    18  *
    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.
    26  *
    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.
    33  */
    34 class nsSMILMilestone
    35 {
    36 public:
    37   nsSMILMilestone(nsSMILTime aTime, bool aIsEnd)
    38     : mTime(aTime), mIsEnd(aIsEnd)
    39   { }
    41   nsSMILMilestone()
    42     : mTime(0), mIsEnd(false)
    43   { }
    45   bool operator==(const nsSMILMilestone& aOther) const
    46   {
    47     return mTime == aOther.mTime && mIsEnd == aOther.mIsEnd;
    48   }
    50   bool operator!=(const nsSMILMilestone& aOther) const
    51   {
    52     return !(*this == aOther);
    53   }
    55   bool operator<(const nsSMILMilestone& aOther) const
    56   {
    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);
    60   }
    62   bool operator<=(const nsSMILMilestone& aOther) const
    63   {
    64     return *this == aOther || *this < aOther;
    65   }
    67   bool operator>=(const nsSMILMilestone& aOther) const
    68   {
    69     return !(*this < aOther);
    70   }
    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.
    76 };
    78 #endif // NS_SMILMILESTONE_H_

mercurial