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_
15 //----------------------------------------------------------------------
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:
23 // 2. set (with non-negative, non-zero count value)
26 class SMILRepeatCount
{
28 SMILRepeatCount() : mCount(kNotSet
) {}
29 explicit SMILRepeatCount(double aCount
) : mCount(kNotSet
) {
33 operator double() const {
34 MOZ_ASSERT(IsDefinite(),
35 "Converting indefinite or unset repeat count to double");
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
) {
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
; }
54 static const double kNotSet
;
55 static const double kIndefinite
;
60 } // namespace mozilla
62 #endif // DOM_SMIL_SMILREPEATCOUNT_H_