LCOV - code coverage report
Current view: top level - dom/svg - nsSVGString.h (source / functions) Hit Total Coverage
Test: output.info Lines: 8 28 28.6 %
Date: 2017-07-14 16:53:18 Functions: 3 19 15.8 %
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_SVGSTRING_H__
       8             : #define __NS_SVGSTRING_H__
       9             : 
      10             : #include "nsAutoPtr.h"
      11             : #include "nsError.h"
      12             : #include "nsSVGElement.h"
      13             : #include "mozilla/Attributes.h"
      14             : #include "mozilla/dom/SVGAnimatedString.h"
      15             : #include "mozilla/UniquePtr.h"
      16             : 
      17          58 : class nsSVGString
      18             : {
      19             : 
      20             : public:
      21          58 :   void Init(uint8_t aAttrEnum) {
      22          58 :     mAnimVal = nullptr;
      23          58 :     mAttrEnum = aAttrEnum;
      24          58 :     mIsBaseSet = false;
      25          58 :   }
      26             : 
      27             :   void SetBaseValue(const nsAString& aValue,
      28             :                     nsSVGElement *aSVGElement,
      29             :                     bool aDoSetAttr);
      30           0 :   void GetBaseValue(nsAString& aValue, const nsSVGElement *aSVGElement) const
      31           0 :     { aSVGElement->GetStringBaseValue(mAttrEnum, aValue); }
      32             : 
      33             :   void SetAnimValue(const nsAString& aValue, nsSVGElement *aSVGElement);
      34             :   void GetAnimValue(nsAString& aValue, const nsSVGElement *aSVGElement) const;
      35             : 
      36             :   // Returns true if the animated value of this string has been explicitly
      37             :   // set (either by animation, or by taking on the base value which has been
      38             :   // explicitly set by markup or a DOM call), false otherwise.
      39             :   // If this returns false, the animated value is still valid, that is,
      40             :   // useable, and represents the default base value of the attribute.
      41          23 :   bool IsExplicitlySet() const
      42          23 :     { return !!mAnimVal || mIsBaseSet; }
      43             : 
      44             :   already_AddRefed<mozilla::dom::SVGAnimatedString>
      45             :   ToDOMAnimatedString(nsSVGElement* aSVGElement);
      46             : 
      47             :   mozilla::UniquePtr<nsISMILAttr> ToSMILAttr(nsSVGElement *aSVGElement);
      48             : 
      49             : private:
      50             :   nsAutoPtr<nsString> mAnimVal;
      51             :   uint8_t mAttrEnum; // element specified tracking for attribute
      52             :   bool mIsBaseSet;
      53             : 
      54             : public:
      55             :   struct DOMAnimatedString final : public mozilla::dom::SVGAnimatedString
      56             :   {
      57             :     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      58           0 :     NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMAnimatedString)
      59             : 
      60           0 :     DOMAnimatedString(nsSVGString* aVal, nsSVGElement* aSVGElement)
      61           0 :       : mozilla::dom::SVGAnimatedString(aSVGElement)
      62           0 :       , mVal(aVal)
      63           0 :     {}
      64             : 
      65             :     nsSVGString* mVal; // kept alive because it belongs to content
      66             : 
      67           0 :     void GetBaseVal(nsAString & aResult) override
      68             :     {
      69           0 :       mVal->GetBaseValue(aResult, mSVGElement);
      70           0 :     }
      71             : 
      72           0 :     void SetBaseVal(const nsAString & aValue) override
      73             :     {
      74           0 :       mVal->SetBaseValue(aValue, mSVGElement, true);
      75           0 :     }
      76             : 
      77           0 :     void GetAnimVal(nsAString & aResult) override
      78             :     {
      79           0 :       mSVGElement->FlushAnimations();
      80           0 :       mVal->GetAnimValue(aResult, mSVGElement);
      81           0 :     }
      82             : 
      83             :   private:
      84             :     virtual ~DOMAnimatedString();
      85             :   };
      86           0 :   struct SMILString : public nsISMILAttr
      87             :   {
      88             :   public:
      89           0 :     SMILString(nsSVGString *aVal, nsSVGElement *aSVGElement)
      90           0 :       : mVal(aVal), mSVGElement(aSVGElement) {}
      91             : 
      92             :     // These will stay alive because a nsISMILAttr only lives as long
      93             :     // as the Compositing step, and DOM elements don't get a chance to
      94             :     // die during that.
      95             :     nsSVGString* mVal;
      96             :     nsSVGElement* mSVGElement;
      97             : 
      98             :     // nsISMILAttr methods
      99             :     virtual nsresult ValueFromString(const nsAString& aStr,
     100             :                                      const mozilla::dom::SVGAnimationElement *aSrcElement,
     101             :                                      nsSMILValue& aValue,
     102             :                                      bool& aPreventCachingOfSandwich) const override;
     103             :     virtual nsSMILValue GetBaseValue() const override;
     104             :     virtual void ClearAnimValue() override;
     105             :     virtual nsresult SetAnimValue(const nsSMILValue& aValue) override;
     106             :   };
     107             : };
     108             : #endif //__NS_SVGSTRING_H__

Generated by: LCOV version 1.13