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