Backed out 2 changesets (bug 1539720) for causing caret related failures. CLOSED...
[gecko.git] / dom / smil / SMILRepeatCount.h
blob0b93aae9948e5b0e425187135335db7b1230b3f0
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/. */
7 #ifndef DOM_SMIL_SMILREPEATCOUNT_H_
8 #define DOM_SMIL_SMILREPEATCOUNT_H_
10 #include "nsDebug.h"
11 #include <math.h>
13 namespace mozilla {
15 //----------------------------------------------------------------------
16 // SMILRepeatCount
18 // A tri-state non-negative floating point number for representing the number of
19 // times an animation repeat, i.e. the SMIL repeatCount attribute.
21 // The three states are:
22 // 1. not-set
23 // 2. set (with non-negative, non-zero count value)
24 // 3. indefinite
26 class SMILRepeatCount {
27 public:
28 SMILRepeatCount() : mCount(kNotSet) {}
29 explicit SMILRepeatCount(double aCount) : mCount(kNotSet) {
30 SetCount(aCount);
33 operator double() const {
34 MOZ_ASSERT(IsDefinite(),
35 "Converting indefinite or unset repeat count to double");
36 return mCount;
38 bool IsDefinite() const { return mCount != kNotSet && mCount != kIndefinite; }
39 bool IsIndefinite() const { return mCount == kIndefinite; }
40 bool IsSet() const { return mCount != kNotSet; }
42 SMILRepeatCount& operator=(double aCount) {
43 SetCount(aCount);
44 return *this;
46 void SetCount(double aCount) {
47 NS_ASSERTION(aCount > 0.0, "Negative or zero repeat count");
48 mCount = aCount > 0.0 ? aCount : kNotSet;
50 void SetIndefinite() { mCount = kIndefinite; }
51 void Unset() { mCount = kNotSet; }
53 private:
54 static const double kNotSet;
55 static const double kIndefinite;
57 double mCount;
60 } // namespace mozilla
62 #endif // DOM_SMIL_SMILREPEATCOUNT_H_