LCOV - code coverage report
Current view: top level - dom/smil - nsSMILRepeatCount.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 16 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef nsSMILRepeatCount_h
       8             : #define nsSMILRepeatCount_h
       9             : 
      10             : #include "nsDebug.h"
      11             : #include <math.h>
      12             : 
      13             : //----------------------------------------------------------------------
      14             : // nsSMILRepeatCount
      15             : //
      16             : // A tri-state non-negative floating point number for representing the number of
      17             : // times an animation repeat, i.e. the SMIL repeatCount attribute.
      18             : //
      19             : // The three states are:
      20             : //  1. not-set
      21             : //  2. set (with non-negative, non-zero count value)
      22             : //  3. indefinite
      23             : //
      24             : class nsSMILRepeatCount
      25             : {
      26             : public:
      27           0 :   nsSMILRepeatCount() : mCount(kNotSet) {}
      28             :   explicit nsSMILRepeatCount(double aCount)
      29             :     : mCount(kNotSet) { SetCount(aCount); }
      30             : 
      31           0 :   operator double() const {
      32           0 :     MOZ_ASSERT(IsDefinite(),
      33             :       "Converting indefinite or unset repeat count to double");
      34           0 :     return mCount;
      35             :   }
      36           0 :   bool IsDefinite() const {
      37           0 :     return mCount != kNotSet && mCount != kIndefinite;
      38             :   }
      39             :   bool IsIndefinite() const { return mCount == kIndefinite; }
      40           0 :   bool IsSet() const { return mCount != kNotSet; }
      41             : 
      42           0 :   nsSMILRepeatCount& operator=(double aCount)
      43             :   {
      44           0 :     SetCount(aCount);
      45           0 :     return *this;
      46             :   }
      47           0 :   void SetCount(double aCount)
      48             :   {
      49           0 :     NS_ASSERTION(aCount > 0.0, "Negative or zero repeat count");
      50           0 :     mCount = aCount > 0.0 ? aCount : kNotSet;
      51           0 :   }
      52           0 :   void SetIndefinite() { mCount = kIndefinite; }
      53           0 :   void Unset() { mCount = kNotSet; }
      54             : 
      55             : private:
      56             :   static const double kNotSet;
      57             :   static const double kIndefinite;
      58             : 
      59             :   double  mCount;
      60             : };
      61             : 
      62             : #endif

Generated by: LCOV version 1.13