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

Generated by: LCOV version 1.13