LCOV - code coverage report
Current view: directory - content/smil - nsSMILMilestone.h (source / functions) Found Hit Coverage
Test: app.info Lines: 12 3 25.0 %
Date: 2012-06-02 Functions: 5 1 20.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is the Mozilla SMIL module.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is Brian Birtles.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2009
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *   Brian Birtles <birtles@gmail.com>
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #ifndef NS_SMILMILESTONE_H_
      39                 : #define NS_SMILMILESTONE_H_
      40                 : 
      41                 : /*
      42                 :  * A significant moment in an nsSMILTimedElement's lifetime where a sample is
      43                 :  * required.
      44                 :  *
      45                 :  * Animations register the next milestone in their lifetime with the time
      46                 :  * container that they belong to. When the animation controller goes to run
      47                 :  * a sample it first visits all the animations that have a registered milestone
      48                 :  * in order of their milestone times. This allows interdependencies between
      49                 :  * animations to be correctly resolved and events to fire in the proper order.
      50                 :  *
      51                 :  * A distinction is made between a milestone representing the end of an interval
      52                 :  * and any other milestone. This is because if animation A ends at time t, and
      53                 :  * animation B begins at the same time t (or has some other significant moment
      54                 :  * such as firing a repeat event), SMIL's endpoint-exclusive timing model
      55                 :  * implies that the interval end occurs first. In fact, interval ends can be
      56                 :  * thought of as ending an infinitesimally small time before t. Therefore,
      57                 :  * A should be sampled before B.
      58                 :  *
      59                 :  * Furthermore, this distinction between sampling the end of an interval and
      60                 :  * a regular sample is used within the timing model (specifically in
      61                 :  * nsSMILTimedElement) to ensure that all intervals ending at time t are sampled
      62                 :  * before any new intervals are entered so that we have a fully up-to-date set
      63                 :  * of instance times available before committing to a new interval. Once an
      64                 :  * interval is entered, the begin time is fixed.
      65                 :  */
      66                 : class nsSMILMilestone
      67                 : {
      68                 : public:
      69            1464 :   nsSMILMilestone(nsSMILTime aTime, bool aIsEnd)
      70            1464 :     : mTime(aTime), mIsEnd(aIsEnd)
      71            1464 :   { }
      72                 : 
      73               0 :   nsSMILMilestone()
      74               0 :     : mTime(0), mIsEnd(false)
      75               0 :   { }
      76                 : 
      77               0 :   bool operator==(const nsSMILMilestone& aOther) const
      78                 :   {
      79               0 :     return mTime == aOther.mTime && mIsEnd == aOther.mIsEnd;
      80                 :   }
      81                 : 
      82                 :   bool operator!=(const nsSMILMilestone& aOther) const
      83                 :   {
      84                 :     return !(*this == aOther);
      85                 :   }
      86                 : 
      87               0 :   bool operator<(const nsSMILMilestone& aOther) const
      88                 :   {
      89                 :     // Earlier times sort first, and for equal times end milestones sort first
      90                 :     return mTime < aOther.mTime ||
      91               0 :           (mTime == aOther.mTime && mIsEnd && !aOther.mIsEnd);
      92                 :   }
      93                 : 
      94                 :   bool operator<=(const nsSMILMilestone& aOther) const
      95                 :   {
      96                 :     return *this == aOther || *this < aOther;
      97                 :   }
      98                 : 
      99               0 :   bool operator>=(const nsSMILMilestone& aOther) const
     100                 :   {
     101               0 :     return !(*this < aOther);
     102                 :   }
     103                 : 
     104                 :   nsSMILTime   mTime;  // The milestone time. This may be in container time or
     105                 :                        // parent container time depending on where it is used.
     106                 :   bool mIsEnd; // true if this milestone corresponds to an interval
     107                 :                        // end, false otherwise.
     108                 : };
     109                 : 
     110                 : #endif // NS_SMILMILESTONE_H_

Generated by: LCOV version 1.7