LCOV - code coverage report
Current view: top level - dom/svg - SVGNumberPairSMILType.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 47 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 "SVGNumberPairSMILType.h"
       8             : #include "nsSMILValue.h"
       9             : #include "nsMathUtils.h"
      10             : #include "nsDebug.h"
      11             : 
      12             : namespace mozilla {
      13             : 
      14             : /*static*/ SVGNumberPairSMILType SVGNumberPairSMILType::sSingleton;
      15             : 
      16             : void
      17           0 : SVGNumberPairSMILType::Init(nsSMILValue& aValue) const
      18             : {
      19           0 :   MOZ_ASSERT(aValue.IsNull(), "Unexpected value type");
      20             : 
      21           0 :   aValue.mU.mNumberPair[0] = 0;
      22           0 :   aValue.mU.mNumberPair[1] = 0;
      23           0 :   aValue.mType = this;
      24           0 : }
      25             : 
      26             : void
      27           0 : SVGNumberPairSMILType::Destroy(nsSMILValue& aValue) const
      28             : {
      29           0 :   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
      30           0 :   aValue.mU.mNumberPair[0] = 0;
      31           0 :   aValue.mU.mNumberPair[1] = 0;
      32           0 :   aValue.mType = nsSMILNullType::Singleton();
      33           0 : }
      34             : 
      35             : nsresult
      36           0 : SVGNumberPairSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
      37             : {
      38           0 :   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
      39           0 :   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
      40             : 
      41           0 :   aDest.mU.mNumberPair[0] = aSrc.mU.mNumberPair[0];
      42           0 :   aDest.mU.mNumberPair[1] = aSrc.mU.mNumberPair[1];
      43           0 :   return NS_OK;
      44             : }
      45             : 
      46             : bool
      47           0 : SVGNumberPairSMILType::IsEqual(const nsSMILValue& aLeft,
      48             :                                const nsSMILValue& aRight) const
      49             : {
      50           0 :   NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
      51           0 :   NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
      52             : 
      53           0 :   return aLeft.mU.mNumberPair[0] == aRight.mU.mNumberPair[0] &&
      54           0 :          aLeft.mU.mNumberPair[1] == aRight.mU.mNumberPair[1];
      55             : }
      56             : 
      57             : nsresult
      58           0 : SVGNumberPairSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
      59             :                            uint32_t aCount) const
      60             : {
      61           0 :   NS_PRECONDITION(aValueToAdd.mType == aDest.mType,
      62             :                   "Trying to add invalid types");
      63           0 :   NS_PRECONDITION(aValueToAdd.mType == this, "Unexpected source type");
      64             : 
      65           0 :   aDest.mU.mNumberPair[0] += aValueToAdd.mU.mNumberPair[0] * aCount;
      66           0 :   aDest.mU.mNumberPair[1] += aValueToAdd.mU.mNumberPair[1] * aCount;
      67             : 
      68           0 :   return NS_OK;
      69             : }
      70             : 
      71             : nsresult
      72           0 : SVGNumberPairSMILType::ComputeDistance(const nsSMILValue& aFrom,
      73             :                                        const nsSMILValue& aTo,
      74             :                                        double& aDistance) const
      75             : {
      76           0 :   NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
      77           0 :   NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
      78             : 
      79             :   double delta[2];
      80           0 :   delta[0] = aTo.mU.mNumberPair[0] - aFrom.mU.mNumberPair[0];
      81           0 :   delta[1] = aTo.mU.mNumberPair[1] - aFrom.mU.mNumberPair[1];
      82             : 
      83           0 :   aDistance = NS_hypot(delta[0], delta[1]);
      84           0 :   return NS_OK;
      85             : }
      86             : 
      87             : nsresult
      88           0 : SVGNumberPairSMILType::Interpolate(const nsSMILValue& aStartVal,
      89             :                                    const nsSMILValue& aEndVal,
      90             :                                    double aUnitDistance,
      91             :                                    nsSMILValue& aResult) const
      92             : {
      93           0 :   NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
      94             :                   "Trying to interpolate different types");
      95           0 :   NS_PRECONDITION(aStartVal.mType == this,
      96             :                   "Unexpected types for interpolation");
      97           0 :   NS_PRECONDITION(aResult.mType == this, "Unexpected result type");
      98             : 
      99           0 :   aResult.mU.mNumberPair[0] =
     100           0 :     float(aStartVal.mU.mNumberPair[0] +
     101           0 :           (aEndVal.mU.mNumberPair[0] - aStartVal.mU.mNumberPair[0]) * aUnitDistance);
     102           0 :   aResult.mU.mNumberPair[1] =
     103           0 :     float(aStartVal.mU.mNumberPair[1] +
     104           0 :           (aEndVal.mU.mNumberPair[1] - aStartVal.mU.mNumberPair[1]) * aUnitDistance);
     105           0 :   return NS_OK;
     106             : }
     107             : 
     108             : } // namespace mozilla

Generated by: LCOV version 1.13