LCOV - code coverage report
Current view: directory - content/svg/content/src - nsSVGInteger.h (source / functions) Found Hit Coverage
Test: app.info Lines: 28 1 3.6 %
Date: 2012-06-02 Functions: 17 1 5.9 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is the Mozilla SVG project.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is Robert Longson.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2007
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *
      23                 :  * Alternatively, the contents of this file may be used under the terms of
      24                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      25                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      26                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      27                 :  * of those above. If you wish to allow use of your version of this file only
      28                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      29                 :  * use your version of this file under the terms of the MPL, indicate your
      30                 :  * decision by deleting the provisions above and replace them with the notice
      31                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      32                 :  * the provisions above, a recipient may use your version of this file under
      33                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      34                 :  *
      35                 :  * ***** END LICENSE BLOCK ***** */
      36                 : 
      37                 : #ifndef __NS_SVGINTEGER_H__
      38                 : #define __NS_SVGINTEGER_H__
      39                 : 
      40                 : #include "nsAutoPtr.h"
      41                 : #include "nsCycleCollectionParticipant.h"
      42                 : #include "nsError.h"
      43                 : #include "nsIDOMSVGAnimatedInteger.h"
      44                 : #include "nsISMILAttr.h"
      45                 : #include "nsSVGElement.h"
      46                 : 
      47                 : class nsISMILAnimationElement;
      48                 : class nsSMILValue;
      49                 : 
      50                 : class nsSVGInteger
      51                 : {
      52                 : 
      53                 : public:
      54               0 :   void Init(PRUint8 aAttrEnum = 0xff, PRInt32 aValue = 0) {
      55               0 :     mAnimVal = mBaseVal = aValue;
      56               0 :     mAttrEnum = aAttrEnum;
      57               0 :     mIsAnimated = false;
      58               0 :     mIsBaseSet = false;
      59               0 :   }
      60                 : 
      61                 :   nsresult SetBaseValueString(const nsAString& aValue,
      62                 :                               nsSVGElement *aSVGElement);
      63                 :   void GetBaseValueString(nsAString& aValue);
      64                 : 
      65                 :   void SetBaseValue(PRInt32 aValue, nsSVGElement *aSVGElement);
      66               0 :   PRInt32 GetBaseValue() const
      67               0 :     { return mBaseVal; }
      68                 : 
      69                 :   void SetAnimValue(int aValue, nsSVGElement *aSVGElement);
      70               0 :   int GetAnimValue() const
      71               0 :     { return mAnimVal; }
      72                 : 
      73                 :   // Returns true if the animated value of this integer has been explicitly
      74                 :   // set (either by animation, or by taking on the base value which has been
      75                 :   // explicitly set by markup or a DOM call), false otherwise.
      76                 :   // If this returns false, the animated value is still valid, that is,
      77                 :   // useable, and represents the default base value of the attribute.
      78               0 :   bool IsExplicitlySet() const
      79               0 :     { return mIsAnimated || mIsBaseSet; }
      80                 :   
      81                 :   nsresult ToDOMAnimatedInteger(nsIDOMSVGAnimatedInteger **aResult,
      82                 :                                 nsSVGElement* aSVGElement);
      83                 :   // Returns a new nsISMILAttr object that the caller must delete
      84                 :   nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement);
      85                 :   
      86                 : private:
      87                 : 
      88                 :   PRInt32 mAnimVal;
      89                 :   PRInt32 mBaseVal;
      90                 :   PRUint8 mAttrEnum; // element specified tracking for attribute
      91                 :   bool mIsAnimated;
      92                 :   bool mIsBaseSet;
      93                 : 
      94                 : public:
      95                 :   struct DOMAnimatedInteger : public nsIDOMSVGAnimatedInteger
      96               0 :   {
      97               0 :     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      98            1464 :     NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimatedInteger)
      99                 : 
     100               0 :     DOMAnimatedInteger(nsSVGInteger* aVal, nsSVGElement *aSVGElement)
     101               0 :       : mVal(aVal), mSVGElement(aSVGElement) {}
     102                 : 
     103                 :     nsSVGInteger* mVal; // kept alive because it belongs to content
     104                 :     nsRefPtr<nsSVGElement> mSVGElement;
     105                 : 
     106               0 :     NS_IMETHOD GetBaseVal(PRInt32* aResult)
     107               0 :       { *aResult = mVal->GetBaseValue(); return NS_OK; }
     108               0 :     NS_IMETHOD SetBaseVal(PRInt32 aValue)
     109               0 :       { mVal->SetBaseValue(aValue, mSVGElement); return NS_OK; }
     110                 : 
     111                 :     // Script may have modified animation parameters or timeline -- DOM getters
     112                 :     // need to flush any resample requests to reflect these modifications.
     113               0 :     NS_IMETHOD GetAnimVal(PRInt32* aResult)
     114                 :     {
     115               0 :       mSVGElement->FlushAnimations();
     116               0 :       *aResult = mVal->GetAnimValue();
     117               0 :       return NS_OK;
     118                 :     }
     119                 :   };
     120                 : 
     121                 :   struct SMILInteger : public nsISMILAttr
     122               0 :   {
     123                 :   public:
     124               0 :     SMILInteger(nsSVGInteger* aVal, nsSVGElement* aSVGElement)
     125               0 :       : mVal(aVal), mSVGElement(aSVGElement) {}
     126                 : 
     127                 :     // These will stay alive because a nsISMILAttr only lives as long
     128                 :     // as the Compositing step, and DOM elements don't get a chance to
     129                 :     // die during that.
     130                 :     nsSVGInteger* mVal;
     131                 :     nsSVGElement* mSVGElement;
     132                 : 
     133                 :     // nsISMILAttr methods
     134                 :     virtual nsresult ValueFromString(const nsAString& aStr,
     135                 :                                      const nsISMILAnimationElement* aSrcElement,
     136                 :                                      nsSMILValue& aValue,
     137                 :                                      bool& aPreventCachingOfSandwich) const;
     138                 :     virtual nsSMILValue GetBaseValue() const;
     139                 :     virtual void ClearAnimValue();
     140                 :     virtual nsresult SetAnimValue(const nsSMILValue& aValue);
     141                 :   };
     142                 : };
     143                 : 
     144                 : #endif //__NS_SVGINTEGER_H__

Generated by: LCOV version 1.7