dom/smil/nsSMILRepeatCount.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 nsSMILRepeatCount_h
     7 #define nsSMILRepeatCount_h
     9 #include "nsDebug.h"
    10 #include <math.h>
    12 //----------------------------------------------------------------------
    13 // nsSMILRepeatCount
    14 //
    15 // A tri-state non-negative floating point number for representing the number of
    16 // times an animation repeat, i.e. the SMIL repeatCount attribute.
    17 //
    18 // The three states are:
    19 //  1. not-set
    20 //  2. set (with non-negative, non-zero count value)
    21 //  3. indefinite
    22 //
    23 class nsSMILRepeatCount
    24 {
    25 public:
    26   nsSMILRepeatCount() : mCount(kNotSet) {}
    27   explicit nsSMILRepeatCount(double aCount)
    28     : mCount(kNotSet) { SetCount(aCount); }
    30   operator double() const {
    31     MOZ_ASSERT(IsDefinite(),
    32       "Converting indefinite or unset repeat count to double");
    33     return mCount;
    34   }
    35   bool IsDefinite() const {
    36     return mCount != kNotSet && mCount != kIndefinite;
    37   }
    38   bool IsIndefinite() const { return mCount == kIndefinite; }
    39   bool IsSet() const { return mCount != kNotSet; }
    41   nsSMILRepeatCount& operator=(double aCount)
    42   {
    43     SetCount(aCount);
    44     return *this;
    45   }
    46   void SetCount(double aCount)
    47   {
    48     NS_ASSERTION(aCount > 0.0, "Negative or zero repeat count");
    49     mCount = aCount > 0.0 ? aCount : kNotSet;
    50   }
    51   void SetIndefinite() { mCount = kIndefinite; }
    52   void Unset() { mCount = kNotSet; }
    54 private:
    55   static const double kNotSet;
    56   static const double kIndefinite;
    58   double  mCount;
    59 };
    61 #endif

mercurial