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 NS_SMILVALUE_H_
7 #define NS_SMILVALUE_H_
9 #include "nsISMILType.h"
10 #include "nsSMILNullType.h"
13 * Although objects of this type are generally only created on the stack and
14 * only exist during the taking of a new time sample, that's not always the
15 * case. The nsSMILValue objects obtained from attributes' base values are
16 * cached so that the SMIL engine can make certain optimizations during a
17 * sample if the base value has not changed since the last sample (potentially
18 * avoiding recomposing). These nsSMILValue objects typically live much longer
19 * than a single sample.
24 nsSMILValue() : mU(), mType(nsSMILNullType::Singleton()) { }
25 explicit nsSMILValue(const nsISMILType
* aType
);
26 nsSMILValue(const nsSMILValue
& aVal
);
30 mType
->Destroy(*this);
33 const nsSMILValue
& operator=(const nsSMILValue
& aVal
);
35 // Equality operators. These are allowed to be conservative (return false
36 // more than you'd expect) - see comment above nsISMILType::IsEqual.
37 bool operator==(const nsSMILValue
& aVal
) const;
38 bool operator!=(const nsSMILValue
& aVal
) const {
39 return !(*this == aVal
);
44 return (mType
== nsSMILNullType::Singleton());
47 // Swaps the member data (mU & mPtr) of |this| with |aOther|
48 void Swap(nsSMILValue
& aOther
);
50 nsresult
Add(const nsSMILValue
& aValueToAdd
, uint32_t aCount
= 1);
51 nsresult
SandwichAdd(const nsSMILValue
& aValueToAdd
);
52 nsresult
ComputeDistance(const nsSMILValue
& aTo
, double& aDistance
) const;
53 nsresult
Interpolate(const nsSMILValue
& aEndVal
,
55 nsSMILValue
& aResult
) const;
71 const nsISMILType
* mType
;
74 void InitAndCheckPostcondition(const nsISMILType
* aNewType
);
75 void DestroyAndCheckPostcondition();
76 void DestroyAndReinit(const nsISMILType
* aNewType
);
79 #endif // NS_SMILVALUE_H_