Bug 1835710 - Cancel off-thread JIT compilation before changing nursery allocation...
[gecko.git] / dom / smil / SMILEnumType.cpp
blobfbc5c6d2b8fe8725ab0dc308167ff2dcc44b5bd6
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 #include "SMILEnumType.h"
9 #include "mozilla/SMILValue.h"
10 #include "nsDebug.h"
11 #include <math.h>
13 namespace mozilla {
15 void SMILEnumType::Init(SMILValue& aValue) const {
16 MOZ_ASSERT(aValue.IsNull(), "Unexpected value type");
17 aValue.mU.mUint = 0;
18 aValue.mType = this;
21 void SMILEnumType::Destroy(SMILValue& aValue) const {
22 MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value");
23 aValue.mU.mUint = 0;
24 aValue.mType = SMILNullType::Singleton();
27 nsresult SMILEnumType::Assign(SMILValue& aDest, const SMILValue& aSrc) const {
28 MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
29 MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
30 aDest.mU.mUint = aSrc.mU.mUint;
31 return NS_OK;
34 bool SMILEnumType::IsEqual(const SMILValue& aLeft,
35 const SMILValue& aRight) const {
36 MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
37 MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
39 return aLeft.mU.mUint == aRight.mU.mUint;
42 nsresult SMILEnumType::Add(SMILValue& aDest, const SMILValue& aValueToAdd,
43 uint32_t aCount) const {
44 MOZ_ASSERT(aValueToAdd.mType == aDest.mType, "Trying to add invalid types");
45 MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type");
46 return NS_ERROR_FAILURE; // enum values can't be added to each other
49 nsresult SMILEnumType::ComputeDistance(const SMILValue& aFrom,
50 const SMILValue& aTo,
51 double& aDistance) const {
52 MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types");
53 MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
54 return NS_ERROR_FAILURE; // there is no concept of distance between enum
55 // values
58 nsresult SMILEnumType::Interpolate(const SMILValue& aStartVal,
59 const SMILValue& aEndVal,
60 double aUnitDistance,
61 SMILValue& aResult) const {
62 MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
63 "Trying to interpolate different types");
64 MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation");
65 MOZ_ASSERT(aResult.mType == this, "Unexpected result type");
66 return NS_ERROR_FAILURE; // enum values do not interpolate
69 } // namespace mozilla