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 "nsSMILNullType.h"
8 #include "nsSMILValue.h"
9 #include "nsDebug.h"
10 
Singleton()11 /*static*/ nsSMILNullType* nsSMILNullType::Singleton() {
12   static nsSMILNullType sSingleton;
13   return &sSingleton;
14 }
15 
Assign(nsSMILValue & aDest,const nsSMILValue & aSrc) const16 nsresult nsSMILNullType::Assign(nsSMILValue& aDest,
17                                 const nsSMILValue& aSrc) const {
18   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
19   NS_PRECONDITION(aSrc.mType == this, "Unexpected source type");
20   aDest.mU = aSrc.mU;
21   aDest.mType = Singleton();
22   return NS_OK;
23 }
24 
IsEqual(const nsSMILValue & aLeft,const nsSMILValue & aRight) const25 bool nsSMILNullType::IsEqual(const nsSMILValue& aLeft,
26                              const nsSMILValue& aRight) const {
27   NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
28   NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
29 
30   return true;  // All null-typed values are equivalent.
31 }
32 
Add(nsSMILValue & aDest,const nsSMILValue & aValueToAdd,uint32_t aCount) const33 nsresult nsSMILNullType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
34                              uint32_t aCount) const {
35   NS_NOTREACHED("Adding NULL type");
36   return NS_ERROR_FAILURE;
37 }
38 
ComputeDistance(const nsSMILValue & aFrom,const nsSMILValue & aTo,double & aDistance) const39 nsresult nsSMILNullType::ComputeDistance(const nsSMILValue& aFrom,
40                                          const nsSMILValue& aTo,
41                                          double& aDistance) const {
42   NS_NOTREACHED("Computing distance for NULL type");
43   return NS_ERROR_FAILURE;
44 }
45 
Interpolate(const nsSMILValue & aStartVal,const nsSMILValue & aEndVal,double aUnitDistance,nsSMILValue & aResult) const46 nsresult nsSMILNullType::Interpolate(const nsSMILValue& aStartVal,
47                                      const nsSMILValue& aEndVal,
48                                      double aUnitDistance,
49                                      nsSMILValue& aResult) const {
50   NS_NOTREACHED("Interpolating NULL type");
51   return NS_ERROR_FAILURE;
52 }
53