Line data Source code
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/. */
6 :
7 : #include "SMILBoolType.h"
8 : #include "nsSMILValue.h"
9 : #include "nsDebug.h"
10 : #include <math.h>
11 :
12 : namespace mozilla {
13 :
14 : void
15 0 : SMILBoolType::Init(nsSMILValue& aValue) const
16 : {
17 0 : NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
18 0 : aValue.mU.mBool = false;
19 0 : aValue.mType = this;
20 0 : }
21 :
22 : void
23 0 : SMILBoolType::Destroy(nsSMILValue& aValue) const
24 : {
25 0 : NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
26 0 : aValue.mU.mBool = false;
27 0 : aValue.mType = nsSMILNullType::Singleton();
28 0 : }
29 :
30 : nsresult
31 0 : SMILBoolType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
32 : {
33 0 : NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
34 0 : NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
35 0 : aDest.mU.mBool = aSrc.mU.mBool;
36 0 : return NS_OK;
37 : }
38 :
39 : bool
40 0 : SMILBoolType::IsEqual(const nsSMILValue& aLeft,
41 : const nsSMILValue& aRight) const
42 : {
43 0 : NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
44 0 : NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
45 :
46 0 : return aLeft.mU.mBool == aRight.mU.mBool;
47 : }
48 :
49 : nsresult
50 0 : SMILBoolType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
51 : uint32_t aCount) const
52 : {
53 0 : NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
54 : "Trying to add invalid types");
55 0 : NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
56 0 : return NS_ERROR_FAILURE; // bool values can't be added to each other
57 : }
58 :
59 : nsresult
60 0 : SMILBoolType::ComputeDistance(const nsSMILValue& aFrom,
61 : const nsSMILValue& aTo,
62 : double& aDistance) const
63 : {
64 0 : NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
65 0 : NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
66 0 : return NS_ERROR_FAILURE; // there is no concept of distance between bool values
67 : }
68 :
69 : nsresult
70 0 : SMILBoolType::Interpolate(const nsSMILValue& aStartVal,
71 : const nsSMILValue& aEndVal,
72 : double aUnitDistance,
73 : nsSMILValue& aResult) const
74 : {
75 0 : NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
76 : "Trying to interpolate different types");
77 0 : NS_PRECONDITION(aStartVal.mType == this,
78 : "Unexpected types for interpolation");
79 0 : NS_PRECONDITION(aResult.mType == this, "Unexpected result type");
80 0 : return NS_ERROR_FAILURE; // bool values do not interpolate
81 : }
82 :
83 : } // namespace mozilla
|