LCOV - code coverage report
Current view: top level - dom/svg - nsSVGAngle.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 17 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 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_SVGANGLE_H__
       8             : #define __NS_SVGANGLE_H__
       9             : 
      10             : #include "nsCOMPtr.h"
      11             : #include "nsError.h"
      12             : #include "nsISMILAttr.h"
      13             : #include "mozilla/Attributes.h"
      14             : #include "mozilla/UniquePtr.h"
      15             : 
      16             : class nsISupports;
      17             : class nsSMILValue;
      18             : class nsSVGElement;
      19             : 
      20             : namespace mozilla {
      21             : 
      22             : // Angle Unit Types
      23             : static const unsigned short SVG_ANGLETYPE_UNKNOWN     = 0;
      24             : static const unsigned short SVG_ANGLETYPE_UNSPECIFIED = 1;
      25             : static const unsigned short SVG_ANGLETYPE_DEG         = 2;
      26             : static const unsigned short SVG_ANGLETYPE_RAD         = 3;
      27             : static const unsigned short SVG_ANGLETYPE_GRAD        = 4;
      28             : 
      29             : namespace dom {
      30             : class nsSVGOrientType;
      31             : class SVGAngle;
      32             : class SVGAnimatedAngle;
      33             : class SVGAnimationElement;
      34             : } // namespace dom
      35             : } // namespace mozilla
      36             : 
      37             : class nsSVGAngle
      38             : {
      39             :   friend class mozilla::dom::SVGAngle;
      40             :   friend class mozilla::dom::SVGAnimatedAngle;
      41             : 
      42             : public:
      43           0 :   void Init(uint8_t aAttrEnum = 0xff,
      44             :             float aValue = 0,
      45             :             uint8_t aUnitType = mozilla::SVG_ANGLETYPE_UNSPECIFIED) {
      46           0 :     mAnimVal = mBaseVal = aValue;
      47           0 :     mAnimValUnit = mBaseValUnit = aUnitType;
      48           0 :     mAttrEnum = aAttrEnum;
      49           0 :     mIsAnimated = false;
      50           0 :   }
      51             : 
      52             :   nsresult SetBaseValueString(const nsAString& aValue,
      53             :                               nsSVGElement *aSVGElement,
      54             :                               bool aDoSetAttr);
      55             :   void GetBaseValueString(nsAString& aValue) const;
      56             :   void GetAnimValueString(nsAString& aValue) const;
      57             : 
      58           0 :   float GetBaseValue() const
      59           0 :     { return mBaseVal * GetDegreesPerUnit(mBaseValUnit); }
      60           0 :   float GetAnimValue() const
      61           0 :     { return mAnimVal * GetDegreesPerUnit(mAnimValUnit); }
      62             : 
      63             :   void SetBaseValue(float aValue, nsSVGElement *aSVGElement, bool aDoSetAttr);
      64             :   void SetAnimValue(float aValue, uint8_t aUnit, nsSVGElement *aSVGElement);
      65             : 
      66           0 :   uint8_t GetBaseValueUnit() const { return mBaseValUnit; }
      67             :   uint8_t GetAnimValueUnit() const { return mAnimValUnit; }
      68           0 :   float GetBaseValInSpecifiedUnits() const { return mBaseVal; }
      69             :   float GetAnimValInSpecifiedUnits() const { return mAnimVal; }
      70             : 
      71             :   static nsresult ToDOMSVGAngle(nsISupports **aResult);
      72             :   already_AddRefed<mozilla::dom::SVGAnimatedAngle>
      73             :     ToDOMAnimatedAngle(nsSVGElement* aSVGElement);
      74             :   mozilla::UniquePtr<nsISMILAttr> ToSMILAttr(nsSVGElement* aSVGElement);
      75             : 
      76             :   static float GetDegreesPerUnit(uint8_t aUnit);
      77             : 
      78             : private:
      79             : 
      80             :   float mAnimVal;
      81             :   float mBaseVal;
      82             :   uint8_t mAnimValUnit;
      83             :   uint8_t mBaseValUnit;
      84             :   uint8_t mAttrEnum; // element specified tracking for attribute
      85             :   bool mIsAnimated;
      86             : 
      87             :   void SetBaseValueInSpecifiedUnits(float aValue, nsSVGElement *aSVGElement);
      88             :   nsresult NewValueSpecifiedUnits(uint16_t aUnitType, float aValue,
      89             :                                   nsSVGElement *aSVGElement);
      90             :   nsresult ConvertToSpecifiedUnits(uint16_t aUnitType, nsSVGElement *aSVGElement);
      91             :   already_AddRefed<mozilla::dom::SVGAngle> ToDOMBaseVal(nsSVGElement* aSVGElement);
      92             :   already_AddRefed<mozilla::dom::SVGAngle> ToDOMAnimVal(nsSVGElement* aSVGElement);
      93             : 
      94             : public:
      95             :   // We do not currently implemente a SMILAngle struct because in SVG 1.1 the
      96             :   // only *animatable* attribute that takes an <angle> is 'orient', on the
      97             :   // 'marker' element, and 'orient' must be special cased since it can also
      98             :   // take the value 'auto', making it a more complex type.
      99             : 
     100           0 :   struct SMILOrient final : public nsISMILAttr
     101             :   {
     102             :   public:
     103           0 :     SMILOrient(mozilla::dom::nsSVGOrientType* aOrientType,
     104             :                nsSVGAngle* aAngle,
     105             :                nsSVGElement* aSVGElement)
     106           0 :       : mOrientType(aOrientType)
     107             :       , mAngle(aAngle)
     108           0 :       , mSVGElement(aSVGElement)
     109           0 :     {}
     110             : 
     111             :     // These will stay alive because a nsISMILAttr only lives as long
     112             :     // as the Compositing step, and DOM elements don't get a chance to
     113             :     // die during that.
     114             :     mozilla::dom::nsSVGOrientType* mOrientType;
     115             :     nsSVGAngle* mAngle;
     116             :     nsSVGElement* mSVGElement;
     117             : 
     118             :     // nsISMILAttr methods
     119             :     virtual nsresult ValueFromString(const nsAString& aStr,
     120             :                                      const mozilla::dom::SVGAnimationElement* aSrcElement,
     121             :                                      nsSMILValue& aValue,
     122             :                                      bool& aPreventCachingOfSandwich) const override;
     123             :     virtual nsSMILValue GetBaseValue() const override;
     124             :     virtual void ClearAnimValue() override;
     125             :     virtual nsresult SetAnimValue(const nsSMILValue& aValue) override;
     126             :   };
     127             : };
     128             : 
     129             : #endif //__NS_SVGANGLE_H__

Generated by: LCOV version 1.13