Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / dom / smil / nsSMILValue.h
blob6eb8e5454ad2dfc3f345386af9111ca203d5d03e
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"
12 /**
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.
21 class nsSMILValue
23 public:
24 nsSMILValue() : mU(), mType(nsSMILNullType::Singleton()) { }
25 explicit nsSMILValue(const nsISMILType* aType);
26 nsSMILValue(const nsSMILValue& aVal);
28 ~nsSMILValue()
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);
42 bool IsNull() const
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,
54 double aUnitDistance,
55 nsSMILValue& aResult) const;
57 union {
58 bool mBool;
59 uint64_t mUint;
60 int64_t mInt;
61 double mDouble;
62 struct {
63 float mAngle;
64 uint16_t mUnit;
65 uint16_t mOrientType;
66 } mOrient;
67 int32_t mIntPair[2];
68 float mNumberPair[2];
69 void* mPtr;
70 } mU;
71 const nsISMILType* mType;
73 protected:
74 void InitAndCheckPostcondition(const nsISMILType* aNewType);
75 void DestroyAndCheckPostcondition();
76 void DestroyAndReinit(const nsISMILType* aNewType);
79 #endif // NS_SMILVALUE_H_