LCOV - code coverage report
Current view: top level - dom/smil - nsSMILFloatType.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 39 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          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 "nsSMILFloatType.h"
       8             : #include "nsSMILValue.h"
       9             : #include "nsDebug.h"
      10             : #include <math.h>
      11             : 
      12             : void
      13           0 : nsSMILFloatType::Init(nsSMILValue& aValue) const
      14             : {
      15           0 :   NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
      16           0 :   aValue.mU.mDouble = 0.0;
      17           0 :   aValue.mType = this;
      18           0 : }
      19             : 
      20             : void
      21           0 : nsSMILFloatType::Destroy(nsSMILValue& aValue) const
      22             : {
      23           0 :   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
      24           0 :   aValue.mU.mDouble = 0.0;
      25           0 :   aValue.mType      = nsSMILNullType::Singleton();
      26           0 : }
      27             : 
      28             : nsresult
      29           0 : nsSMILFloatType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
      30             : {
      31           0 :   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
      32           0 :   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
      33           0 :   aDest.mU.mDouble = aSrc.mU.mDouble;
      34           0 :   return NS_OK;
      35             : }
      36             : 
      37             : bool
      38           0 : nsSMILFloatType::IsEqual(const nsSMILValue& aLeft,
      39             :                          const nsSMILValue& aRight) const
      40             : {
      41           0 :   NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
      42           0 :   NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
      43             : 
      44           0 :   return aLeft.mU.mDouble == aRight.mU.mDouble;
      45             : }
      46             : 
      47             : nsresult
      48           0 : nsSMILFloatType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
      49             :                      uint32_t aCount) const
      50             : {
      51           0 :   NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
      52             :                   "Trying to add invalid types");
      53           0 :   NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
      54           0 :   aDest.mU.mDouble += aValueToAdd.mU.mDouble * aCount;
      55           0 :   return NS_OK;
      56             : }
      57             : 
      58             : nsresult
      59           0 : nsSMILFloatType::ComputeDistance(const nsSMILValue& aFrom,
      60             :                                  const nsSMILValue& aTo,
      61             :                                  double& aDistance) const
      62             : {
      63           0 :   NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
      64           0 :   NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
      65             : 
      66           0 :   const double &from = aFrom.mU.mDouble;
      67           0 :   const double &to   = aTo.mU.mDouble;
      68             : 
      69           0 :   aDistance = fabs(to - from);
      70             : 
      71           0 :   return NS_OK;
      72             : }
      73             : 
      74             : nsresult
      75           0 : nsSMILFloatType::Interpolate(const nsSMILValue& aStartVal,
      76             :                              const nsSMILValue& aEndVal,
      77             :                              double aUnitDistance,
      78             :                              nsSMILValue& aResult) const
      79             : {
      80           0 :   NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
      81             :       "Trying to interpolate different types");
      82           0 :   NS_PRECONDITION(aStartVal.mType == this,
      83             :       "Unexpected types for interpolation");
      84           0 :   NS_PRECONDITION(aResult.mType   == this, "Unexpected result type");
      85             : 
      86           0 :   const double &startVal = aStartVal.mU.mDouble;
      87           0 :   const double &endVal   = aEndVal.mU.mDouble;
      88             : 
      89           0 :   aResult.mU.mDouble = (startVal + (endVal - startVal) * aUnitDistance);
      90             : 
      91           0 :   return NS_OK;
      92             : }

Generated by: LCOV version 1.13