Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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
14 //
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.
17 //
18 // The three states are:
19 // 1. not-set
20 // 2. set (with non-negative, non-zero count value)
21 // 3. indefinite
22 //
23 class nsSMILRepeatCount
24 {
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;
34 }
35 bool IsDefinite() const {
36 return mCount != kNotSet && mCount != kIndefinite;
37 }
38 bool IsIndefinite() const { return mCount == kIndefinite; }
39 bool IsSet() const { return mCount != kNotSet; }
41 nsSMILRepeatCount& operator=(double aCount)
42 {
43 SetCount(aCount);
44 return *this;
45 }
46 void SetCount(double aCount)
47 {
48 NS_ASSERTION(aCount > 0.0, "Negative or zero repeat count");
49 mCount = aCount > 0.0 ? aCount : kNotSet;
50 }
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;
59 };
61 #endif