LCOV - code coverage report
Current view: top level - dom/smil - SMILStringType.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 37 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 "SMILStringType.h"
       8             : #include "nsSMILValue.h"
       9             : #include "nsDebug.h"
      10             : #include "nsString.h"
      11             : 
      12             : namespace mozilla {
      13             : 
      14             : void
      15           0 : SMILStringType::Init(nsSMILValue& aValue) const
      16             : {
      17           0 :   NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
      18           0 :   aValue.mU.mPtr = new nsString();
      19           0 :   aValue.mType = this;
      20           0 : }
      21             : 
      22             : void
      23           0 : SMILStringType::Destroy(nsSMILValue& aValue) const
      24             : {
      25           0 :   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
      26           0 :   delete static_cast<nsAString*>(aValue.mU.mPtr);
      27           0 :   aValue.mU.mPtr = nullptr;
      28           0 :   aValue.mType = nsSMILNullType::Singleton();
      29           0 : }
      30             : 
      31             : nsresult
      32           0 : SMILStringType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
      33             : {
      34           0 :   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
      35           0 :   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
      36             : 
      37           0 :   const nsAString* src = static_cast<const nsAString*>(aSrc.mU.mPtr);
      38           0 :   nsAString* dst = static_cast<nsAString*>(aDest.mU.mPtr);
      39           0 :   *dst = *src;
      40           0 :   return NS_OK;
      41             : }
      42             : 
      43             : bool
      44           0 : SMILStringType::IsEqual(const nsSMILValue& aLeft,
      45             :                         const nsSMILValue& aRight) const
      46             : {
      47           0 :   NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
      48           0 :   NS_PRECONDITION(aLeft.mType == this, "Unexpected type for SMIL value");
      49             : 
      50             :   const nsAString* leftString =
      51           0 :     static_cast<const nsAString*>(aLeft.mU.mPtr);
      52             :   const nsAString* rightString =
      53           0 :     static_cast<nsAString*>(aRight.mU.mPtr);
      54           0 :   return *leftString == *rightString;
      55             : }
      56             : 
      57             : nsresult
      58           0 : SMILStringType::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           0 :   return NS_ERROR_FAILURE; // string values can't be added to each other
      65             : }
      66             : 
      67             : nsresult
      68           0 : SMILStringType::ComputeDistance(const nsSMILValue& aFrom,
      69             :                                 const nsSMILValue& aTo,
      70             :                                 double& aDistance) const
      71             : {
      72           0 :   NS_PRECONDITION(aFrom.mType == aTo.mType,"Trying to compare different types");
      73           0 :   NS_PRECONDITION(aFrom.mType == this, "Unexpected source type");
      74           0 :   return NS_ERROR_FAILURE; // there is no concept of distance between string values
      75             : }
      76             : 
      77             : nsresult
      78           0 : SMILStringType::Interpolate(const nsSMILValue& aStartVal,
      79             :                             const nsSMILValue& aEndVal,
      80             :                             double aUnitDistance,
      81             :                             nsSMILValue& aResult) const
      82             : {
      83           0 :   NS_PRECONDITION(aStartVal.mType == aEndVal.mType,
      84             :       "Trying to interpolate different types");
      85           0 :   NS_PRECONDITION(aStartVal.mType == this,
      86             :       "Unexpected types for interpolation");
      87           0 :   NS_PRECONDITION(aResult.mType   == this, "Unexpected result type");
      88           0 :   return NS_ERROR_FAILURE; // string values do not interpolate
      89             : }
      90             : 
      91             : } // namespace mozilla

Generated by: LCOV version 1.13