dom/smil/SMILBoolType.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "SMILBoolType.h"
michael@0 7 #include "nsSMILValue.h"
michael@0 8 #include "nsDebug.h"
michael@0 9 #include <math.h>
michael@0 10
michael@0 11 namespace mozilla {
michael@0 12
michael@0 13 void
michael@0 14 SMILBoolType::Init(nsSMILValue& aValue) const
michael@0 15 {
michael@0 16 NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
michael@0 17 aValue.mU.mBool = false;
michael@0 18 aValue.mType = this;
michael@0 19 }
michael@0 20
michael@0 21 void
michael@0 22 SMILBoolType::Destroy(nsSMILValue& aValue) const
michael@0 23 {
michael@0 24 NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
michael@0 25 aValue.mU.mBool = false;
michael@0 26 aValue.mType = nsSMILNullType::Singleton();
michael@0 27 }
michael@0 28
michael@0 29 nsresult
michael@0 30 SMILBoolType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
michael@0 31 {
michael@0 32 NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
michael@0 33 NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
michael@0 34 aDest.mU.mBool = aSrc.mU.mBool;
michael@0 35 return NS_OK;
michael@0 36 }
michael@0 37
michael@0 38 bool
michael@0 39 SMILBoolType::IsEqual(const nsSMILValue& aLeft,
michael@0 40 const nsSMILValue& aRight) const
michael@0 41 {
michael@0 42 NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
michael@0 43 NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
michael@0 44
michael@0 45 return aLeft.mU.mBool == aRight.mU.mBool;
michael@0 46 }
michael@0 47
michael@0 48 nsresult
michael@0 49 SMILBoolType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
michael@0 50 uint32_t aCount) const
michael@0 51 {
michael@0 52 NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
michael@0 53 "Trying to add invalid types");
michael@0 54 NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
michael@0 55 return NS_ERROR_FAILURE; // bool values can't be added to each other
michael@0 56 }
michael@0 57
michael@0 58 nsresult
michael@0 59 SMILBoolType::ComputeDistance(const nsSMILValue& aFrom,
michael@0 60 const nsSMILValue& aTo,
michael@0 61 double& aDistance) const
michael@0 62 {
michael@0 63 NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
michael@0 64 NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
michael@0 65 return NS_ERROR_FAILURE; // there is no concept of distance between bool values
michael@0 66 }
michael@0 67
michael@0 68 nsresult
michael@0 69 SMILBoolType::Interpolate(const nsSMILValue& aStartVal,
michael@0 70 const nsSMILValue& aEndVal,
michael@0 71 double aUnitDistance,
michael@0 72 nsSMILValue& aResult) const
michael@0 73 {
michael@0 74 NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
michael@0 75 "Trying to interpolate different types");
michael@0 76 NS_PRECONDITION(aStartVal.mType == this,
michael@0 77 "Unexpected types for interpolation");
michael@0 78 NS_PRECONDITION(aResult.mType == this, "Unexpected result type");
michael@0 79 return NS_ERROR_FAILURE; // bool values do not interpolate
michael@0 80 }
michael@0 81
michael@0 82 } // namespace mozilla

mercurial