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
12 //----------------------------------------------------------------------
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:
20 // 2. set (with non-negative, non-zero count value)
23 class nsSMILRepeatCount
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");
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
)
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
; }
55 static const double kNotSet
;
56 static const double kIndefinite
;