michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "SMILBoolType.h" michael@0: #include "nsSMILValue.h" michael@0: #include "nsDebug.h" michael@0: #include michael@0: michael@0: namespace mozilla { michael@0: michael@0: void michael@0: SMILBoolType::Init(nsSMILValue& aValue) const michael@0: { michael@0: NS_PRECONDITION(aValue.IsNull(), "Unexpected value type"); michael@0: aValue.mU.mBool = false; michael@0: aValue.mType = this; michael@0: } michael@0: michael@0: void michael@0: SMILBoolType::Destroy(nsSMILValue& aValue) const michael@0: { michael@0: NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value"); michael@0: aValue.mU.mBool = false; michael@0: aValue.mType = nsSMILNullType::Singleton(); michael@0: } michael@0: michael@0: nsresult michael@0: SMILBoolType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const michael@0: { michael@0: NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types"); michael@0: NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value"); michael@0: aDest.mU.mBool = aSrc.mU.mBool; michael@0: return NS_OK; michael@0: } michael@0: michael@0: bool michael@0: SMILBoolType::IsEqual(const nsSMILValue& aLeft, michael@0: const nsSMILValue& aRight) const michael@0: { michael@0: NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types"); michael@0: NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value"); michael@0: michael@0: return aLeft.mU.mBool == aRight.mU.mBool; michael@0: } michael@0: michael@0: nsresult michael@0: SMILBoolType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, michael@0: uint32_t aCount) const michael@0: { michael@0: NS_PRECONDITION(aValueToAdd.mType == aDest.mType, michael@0: "Trying to add invalid types"); michael@0: NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type"); michael@0: return NS_ERROR_FAILURE; // bool values can't be added to each other michael@0: } michael@0: michael@0: nsresult michael@0: SMILBoolType::ComputeDistance(const nsSMILValue& aFrom, michael@0: const nsSMILValue& aTo, michael@0: double& aDistance) const michael@0: { michael@0: NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types"); michael@0: NS_PRECONDITION(aFrom.mType == this, "Unexpected source type"); michael@0: return NS_ERROR_FAILURE; // there is no concept of distance between bool values michael@0: } michael@0: michael@0: nsresult michael@0: SMILBoolType::Interpolate(const nsSMILValue& aStartVal, michael@0: const nsSMILValue& aEndVal, michael@0: double aUnitDistance, michael@0: nsSMILValue& aResult) const michael@0: { michael@0: NS_PRECONDITION(aStartVal.mType == aEndVal.mType, michael@0: "Trying to interpolate different types"); michael@0: NS_PRECONDITION(aStartVal.mType == this, michael@0: "Unexpected types for interpolation"); michael@0: NS_PRECONDITION(aResult.mType == this, "Unexpected result type"); michael@0: return NS_ERROR_FAILURE; // bool values do not interpolate michael@0: } michael@0: michael@0: } // namespace mozilla