1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/smil/SMILBoolType.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,82 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "SMILBoolType.h" 1.10 +#include "nsSMILValue.h" 1.11 +#include "nsDebug.h" 1.12 +#include <math.h> 1.13 + 1.14 +namespace mozilla { 1.15 + 1.16 +void 1.17 +SMILBoolType::Init(nsSMILValue& aValue) const 1.18 +{ 1.19 + NS_PRECONDITION(aValue.IsNull(), "Unexpected value type"); 1.20 + aValue.mU.mBool = false; 1.21 + aValue.mType = this; 1.22 +} 1.23 + 1.24 +void 1.25 +SMILBoolType::Destroy(nsSMILValue& aValue) const 1.26 +{ 1.27 + NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value"); 1.28 + aValue.mU.mBool = false; 1.29 + aValue.mType = nsSMILNullType::Singleton(); 1.30 +} 1.31 + 1.32 +nsresult 1.33 +SMILBoolType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const 1.34 +{ 1.35 + NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); 1.36 + NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); 1.37 + aDest.mU.mBool = aSrc.mU.mBool; 1.38 + return NS_OK; 1.39 +} 1.40 + 1.41 +bool 1.42 +SMILBoolType::IsEqual(const nsSMILValue& aLeft, 1.43 + const nsSMILValue& aRight) const 1.44 +{ 1.45 + NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); 1.46 + NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); 1.47 + 1.48 + return aLeft.mU.mBool == aRight.mU.mBool; 1.49 +} 1.50 + 1.51 +nsresult 1.52 +SMILBoolType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, 1.53 + uint32_t aCount) const 1.54 +{ 1.55 + NS_PRECONDITION(aValueToAdd.mType == aDest.mType, 1.56 + "Trying to add invalid types"); 1.57 + NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type"); 1.58 + return NS_ERROR_FAILURE; // bool values can't be added to each other 1.59 +} 1.60 + 1.61 +nsresult 1.62 +SMILBoolType::ComputeDistance(const nsSMILValue& aFrom, 1.63 + const nsSMILValue& aTo, 1.64 + double& aDistance) const 1.65 +{ 1.66 + NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types"); 1.67 + NS_PRECONDITION(aFrom.mType == this, "Unexpected source type"); 1.68 + return NS_ERROR_FAILURE; // there is no concept of distance between bool values 1.69 +} 1.70 + 1.71 +nsresult 1.72 +SMILBoolType::Interpolate(const nsSMILValue& aStartVal, 1.73 + const nsSMILValue& aEndVal, 1.74 + double aUnitDistance, 1.75 + nsSMILValue& aResult) const 1.76 +{ 1.77 + NS_PRECONDITION(aStartVal.mType == aEndVal.mType, 1.78 + "Trying to interpolate different types"); 1.79 + NS_PRECONDITION(aStartVal.mType == this, 1.80 + "Unexpected types for interpolation"); 1.81 + NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); 1.82 + return NS_ERROR_FAILURE; // bool values do not interpolate 1.83 +} 1.84 + 1.85 +} // namespace mozilla