LCOV - code coverage report
Current view: directory - content/svg/content/src - nsSVGString.h (source / functions) Found Hit Coverage
Test: app.info Lines: 25 1 4.0 %
Date: 2012-06-02 Functions: 18 1 5.6 %

       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) 2008
      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_SVGSTRING_H__
      38                 : #define __NS_SVGSTRING_H__
      39                 : 
      40                 : #include "nsDOMError.h"
      41                 : #include "nsIDOMSVGAnimatedString.h"
      42                 : #include "nsSVGElement.h"
      43                 : 
      44                 : class nsSVGString
      45               0 : {
      46                 : 
      47                 : public:
      48               0 :   void Init(PRUint8 aAttrEnum) {
      49               0 :     mAnimVal = nsnull;
      50               0 :     mAttrEnum = aAttrEnum;
      51               0 :     mIsBaseSet = false;
      52               0 :   }
      53                 : 
      54                 :   void SetBaseValue(const nsAString& aValue,
      55                 :                     nsSVGElement *aSVGElement,
      56                 :                     bool aDoSetAttr);
      57               0 :   void GetBaseValue(nsAString& aValue, const nsSVGElement *aSVGElement) const
      58               0 :     { aSVGElement->GetStringBaseValue(mAttrEnum, aValue); }
      59                 : 
      60                 :   void SetAnimValue(const nsAString& aValue, nsSVGElement *aSVGElement);
      61                 :   void GetAnimValue(nsAString& aValue, const nsSVGElement *aSVGElement) const;
      62                 : 
      63                 :   // Returns true if the animated value of this string has been explicitly
      64                 :   // set (either by animation, or by taking on the base value which has been
      65                 :   // explicitly set by markup or a DOM call), false otherwise.
      66                 :   // If this returns false, the animated value is still valid, that is,
      67                 :   // useable, and represents the default base value of the attribute.
      68               0 :   bool IsExplicitlySet() const
      69               0 :     { return !!mAnimVal || mIsBaseSet; }
      70                 : 
      71                 :   nsresult ToDOMAnimatedString(nsIDOMSVGAnimatedString **aResult,
      72                 :                                nsSVGElement *aSVGElement);
      73                 :   // Returns a new nsISMILAttr object that the caller must delete
      74                 :   nsISMILAttr* ToSMILAttr(nsSVGElement *aSVGElement);
      75                 : 
      76                 : private:
      77                 : 
      78                 :   nsAutoPtr<nsString> mAnimVal;
      79                 :   PRUint8 mAttrEnum; // element specified tracking for attribute
      80                 :   bool mIsBaseSet;
      81                 : 
      82                 : public:
      83                 :   struct DOMAnimatedString : public nsIDOMSVGAnimatedString
      84               0 :   {
      85               0 :     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      86            1464 :     NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimatedString)
      87                 : 
      88               0 :     DOMAnimatedString(nsSVGString *aVal, nsSVGElement *aSVGElement)
      89               0 :       : mVal(aVal), mSVGElement(aSVGElement) {}
      90                 : 
      91                 :     nsSVGString* mVal; // kept alive because it belongs to content
      92                 :     nsRefPtr<nsSVGElement> mSVGElement;
      93                 : 
      94               0 :     NS_IMETHOD GetBaseVal(nsAString & aResult)
      95               0 :       { mVal->GetBaseValue(aResult, mSVGElement); return NS_OK; }
      96               0 :     NS_IMETHOD SetBaseVal(const nsAString & aValue)
      97               0 :       { mVal->SetBaseValue(aValue, mSVGElement, true); return NS_OK; }
      98                 : 
      99               0 :     NS_IMETHOD GetAnimVal(nsAString & aResult)
     100                 :     { 
     101               0 :       mSVGElement->FlushAnimations();
     102               0 :       mVal->GetAnimValue(aResult, mSVGElement); return NS_OK;
     103                 :     }
     104                 : 
     105                 :   };
     106                 :   struct SMILString : public nsISMILAttr
     107               0 :   {
     108                 :   public:
     109               0 :     SMILString(nsSVGString *aVal, nsSVGElement *aSVGElement)
     110               0 :       : mVal(aVal), mSVGElement(aSVGElement) {}
     111                 : 
     112                 :     // These will stay alive because a nsISMILAttr only lives as long
     113                 :     // as the Compositing step, and DOM elements don't get a chance to
     114                 :     // die during that.
     115                 :     nsSVGString* mVal;
     116                 :     nsSVGElement* mSVGElement;
     117                 : 
     118                 :     // nsISMILAttr methods
     119                 :     virtual nsresult ValueFromString(const nsAString& aStr,
     120                 :                                      const nsISMILAnimationElement *aSrcElement,
     121                 :                                      nsSMILValue& aValue,
     122                 :                                      bool& aPreventCachingOfSandwich) const;
     123                 :     virtual nsSMILValue GetBaseValue() const;
     124                 :     virtual void ClearAnimValue();
     125                 :     virtual nsresult SetAnimValue(const nsSMILValue& aValue);
     126                 :   };
     127                 : };
     128                 : #endif //__NS_SVGSTRING_H__

Generated by: LCOV version 1.7