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_SMILVALUE_H_
8 #define DOM_SMIL_SMILVALUE_H_
10 #include "mozilla/SMILNullType.h"
11 #include "mozilla/SMILType.h"
16 * Although objects of this type are generally only created on the stack and
17 * only exist during the taking of a new time sample, that's not always the
18 * case. The SMILValue objects obtained from attributes' base values are
19 * cached so that the SMIL engine can make certain optimizations during a
20 * sample if the base value has not changed since the last sample (potentially
21 * avoiding recomposing). These SMILValue objects typically live much longer
22 * than a single sample.
26 SMILValue() : mU(), mType(SMILNullType::Singleton()) {}
27 explicit SMILValue(const SMILType
* aType
);
28 SMILValue(const SMILValue
& aVal
);
30 ~SMILValue() { mType
->Destroy(*this); }
32 const SMILValue
& operator=(const SMILValue
& aVal
);
34 // Move constructor / reassignment operator:
35 SMILValue(SMILValue
&& aVal
) noexcept
;
36 SMILValue
& operator=(SMILValue
&& aVal
) noexcept
;
38 // Equality operators. These are allowed to be conservative (return false
39 // more than you'd expect) - see comment above SMILType::IsEqual.
40 bool operator==(const SMILValue
& aVal
) const;
41 bool operator!=(const SMILValue
& aVal
) const { return !(*this == aVal
); }
43 bool IsNull() const { return (mType
== SMILNullType::Singleton()); }
45 nsresult
Add(const SMILValue
& aValueToAdd
, uint32_t aCount
= 1);
46 nsresult
SandwichAdd(const SMILValue
& aValueToAdd
);
47 nsresult
ComputeDistance(const SMILValue
& aTo
, double& aDistance
) const;
48 nsresult
Interpolate(const SMILValue
& aEndVal
, double aUnitDistance
,
49 SMILValue
& aResult
) const;
65 const SMILType
* mType
;
68 void InitAndCheckPostcondition(const SMILType
* aNewType
);
69 void DestroyAndCheckPostcondition();
70 void DestroyAndReinit(const SMILType
* aNewType
);
73 } // namespace mozilla
75 #endif // DOM_SMIL_SMILVALUE_H_