Bumping manifests a=b2g-bump
[gecko.git] / dom / smil / nsSMILRepeatCount.h
blob8561fe4d8bd45f6d561225c3dce8178e5eee4d1d
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
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.
18 // The three states are:
19 // 1. not-set
20 // 2. set (with non-negative, non-zero count value)
21 // 3. indefinite
23 class nsSMILRepeatCount
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;
35 bool IsDefinite() const {
36 return mCount != kNotSet && mCount != kIndefinite;
38 bool IsIndefinite() const { return mCount == kIndefinite; }
39 bool IsSet() const { return mCount != kNotSet; }
41 nsSMILRepeatCount& operator=(double aCount)
43 SetCount(aCount);
44 return *this;
46 void SetCount(double aCount)
48 NS_ASSERTION(aCount > 0.0, "Negative or zero repeat count");
49 mCount = aCount > 0.0 ? aCount : kNotSet;
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;
61 #endif