LCOV - code coverage report
Current view: top level - dom/svg - nsSVGInteger.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 27 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 11 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             : #ifndef __NS_SVGINTEGER_H__
       8             : #define __NS_SVGINTEGER_H__
       9             : 
      10             : #include "nsCycleCollectionParticipant.h"
      11             : #include "nsError.h"
      12             : #include "SVGAnimatedInteger.h"
      13             : #include "nsISMILAttr.h"
      14             : #include "nsSVGElement.h"
      15             : #include "mozilla/Attributes.h"
      16             : #include "mozilla/UniquePtr.h"
      17             : 
      18             : class nsSMILValue;
      19             : 
      20             : namespace mozilla {
      21             : namespace dom {
      22             : class SVGAnimationElement;
      23             : } // namespace dom
      24             : } // namespace mozilla
      25             : 
      26             : class nsSVGInteger
      27             : {
      28             : 
      29             : public:
      30           0 :   void Init(uint8_t aAttrEnum = 0xff, int32_t aValue = 0) {
      31           0 :     mAnimVal = mBaseVal = aValue;
      32           0 :     mAttrEnum = aAttrEnum;
      33           0 :     mIsAnimated = false;
      34           0 :     mIsBaseSet = false;
      35           0 :   }
      36             : 
      37             :   nsresult SetBaseValueString(const nsAString& aValue,
      38             :                               nsSVGElement *aSVGElement);
      39             :   void GetBaseValueString(nsAString& aValue);
      40             : 
      41             :   void SetBaseValue(int32_t aValue, nsSVGElement *aSVGElement);
      42           0 :   int32_t GetBaseValue() const
      43           0 :     { return mBaseVal; }
      44             : 
      45             :   void SetAnimValue(int aValue, nsSVGElement *aSVGElement);
      46           0 :   int GetAnimValue() const
      47           0 :     { return mAnimVal; }
      48             : 
      49             :   // Returns true if the animated value of this integer has been explicitly
      50             :   // set (either by animation, or by taking on the base value which has been
      51             :   // explicitly set by markup or a DOM call), false otherwise.
      52             :   // If this returns false, the animated value is still valid, that is,
      53             :   // useable, and represents the default base value of the attribute.
      54           0 :   bool IsExplicitlySet() const
      55           0 :     { return mIsAnimated || mIsBaseSet; }
      56             : 
      57             :   already_AddRefed<mozilla::dom::SVGAnimatedInteger>
      58             :     ToDOMAnimatedInteger(nsSVGElement* aSVGElement);
      59             :   mozilla::UniquePtr<nsISMILAttr> ToSMILAttr(nsSVGElement* aSVGElement);
      60             : 
      61             : private:
      62             : 
      63             :   int32_t mAnimVal;
      64             :   int32_t mBaseVal;
      65             :   uint8_t mAttrEnum; // element specified tracking for attribute
      66             :   bool mIsAnimated;
      67             :   bool mIsBaseSet;
      68             : 
      69             : public:
      70             :   struct DOMAnimatedInteger final : public mozilla::dom::SVGAnimatedInteger
      71             :   {
      72           0 :     DOMAnimatedInteger(nsSVGInteger* aVal, nsSVGElement* aSVGElement)
      73           0 :       : mozilla::dom::SVGAnimatedInteger(aSVGElement)
      74           0 :       , mVal(aVal)
      75           0 :     {}
      76             :     virtual ~DOMAnimatedInteger();
      77             : 
      78             :     nsSVGInteger* mVal; // kept alive because it belongs to content
      79             : 
      80           0 :     virtual int32_t BaseVal() override
      81             :     {
      82           0 :       return mVal->GetBaseValue();
      83             :     }
      84           0 :     virtual void SetBaseVal(int32_t aValue) override
      85             :     {
      86           0 :       mVal->SetBaseValue(aValue, mSVGElement);
      87           0 :     }
      88             : 
      89             :     // Script may have modified animation parameters or timeline -- DOM getters
      90             :     // need to flush any resample requests to reflect these modifications.
      91           0 :     virtual int32_t AnimVal() override
      92             :     {
      93           0 :       mSVGElement->FlushAnimations();
      94           0 :       return mVal->GetAnimValue();
      95             :     }
      96             :   };
      97             : 
      98           0 :   struct SMILInteger : public nsISMILAttr
      99             :   {
     100             :   public:
     101           0 :     SMILInteger(nsSVGInteger* aVal, nsSVGElement* aSVGElement)
     102           0 :       : mVal(aVal), mSVGElement(aSVGElement) {}
     103             : 
     104             :     // These will stay alive because a nsISMILAttr only lives as long
     105             :     // as the Compositing step, and DOM elements don't get a chance to
     106             :     // die during that.
     107             :     nsSVGInteger* mVal;
     108             :     nsSVGElement* mSVGElement;
     109             : 
     110             :     // nsISMILAttr methods
     111             :     virtual nsresult ValueFromString(const nsAString& aStr,
     112             :                                      const mozilla::dom::SVGAnimationElement* aSrcElement,
     113             :                                      nsSMILValue& aValue,
     114             :                                      bool& aPreventCachingOfSandwich) const override;
     115             :     virtual nsSMILValue GetBaseValue() const override;
     116             :     virtual void ClearAnimValue() override;
     117             :     virtual nsresult SetAnimValue(const nsSMILValue& aValue) override;
     118             :   };
     119             : };
     120             : 
     121             : #endif //__NS_SVGINTEGER_H__

Generated by: LCOV version 1.13