LCOV - code coverage report
Current view: directory - content/svg/content/src - SVGAnimatedNumberList.h (source / functions) Found Hit Coverage
Test: app.info Lines: 14 0 0.0 %
Date: 2012-06-02 Functions: 9 0 0.0 %

       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 Mozilla SVG Project code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is the Mozilla Foundation.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2010
      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 the GNU General Public License Version 2 or later (the "GPL"), or
      25                 :  * 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 MOZILLA_SVGANIMATEDNUMBERLIST_H__
      38                 : #define MOZILLA_SVGANIMATEDNUMBERLIST_H__
      39                 : 
      40                 : #include "nsAutoPtr.h"
      41                 : #include "nsISMILAttr.h"
      42                 : #include "SVGNumberList.h"
      43                 : 
      44                 : class nsISMILAnimationElement;
      45                 : class nsSMILValue;
      46                 : class nsSVGElement;
      47                 : 
      48                 : namespace mozilla {
      49                 : 
      50                 : /**
      51                 :  * Class SVGAnimatedNumberList
      52                 :  *
      53                 :  * This class is very different to the SVG DOM interface of the same name found
      54                 :  * in the SVG specification. This is a lightweight internal class - see
      55                 :  * DOMSVGAnimatedNumberList for the heavier DOM class that wraps instances of
      56                 :  * this class and implements the SVG specification's SVGAnimatedNumberList DOM
      57                 :  * interface.
      58                 :  *
      59                 :  * Except where noted otherwise, this class' methods take care of keeping the
      60                 :  * appropriate DOM wrappers in sync (see the comment in
      61                 :  * DOMSVGAnimatedNumberList::InternalBaseValListWillChangeTo) so that their
      62                 :  * consumers don't need to concern themselves with that.
      63                 :  */
      64                 : class SVGAnimatedNumberList
      65               0 : {
      66                 :   // friends so that they can get write access to mBaseVal
      67                 :   friend class DOMSVGNumber;
      68                 :   friend class DOMSVGNumberList;
      69                 : 
      70                 : public:
      71               0 :   SVGAnimatedNumberList() {}
      72                 : 
      73                 :   /**
      74                 :    * Because it's so important that mBaseVal and its DOMSVGNumberList wrapper
      75                 :    * (if any) be kept in sync (see the comment in
      76                 :    * DOMSVGAnimatedNumberList::InternalBaseValListWillChangeTo), this method
      77                 :    * returns a const reference. Only our friend classes may get mutable
      78                 :    * references to mBaseVal.
      79                 :    */
      80               0 :   const SVGNumberList& GetBaseValue() const {
      81               0 :     return mBaseVal;
      82                 :   }
      83                 : 
      84                 :   nsresult SetBaseValueString(const nsAString& aValue);
      85                 : 
      86                 :   void ClearBaseValue(PRUint32 aAttrEnum);
      87                 : 
      88               0 :   const SVGNumberList& GetAnimValue() const {
      89               0 :     return mAnimVal ? *mAnimVal : mBaseVal;
      90                 :   }
      91                 : 
      92                 :   nsresult SetAnimValue(const SVGNumberList& aValue,
      93                 :                         nsSVGElement *aElement,
      94                 :                         PRUint32 aAttrEnum);
      95                 : 
      96                 :   void ClearAnimValue(nsSVGElement *aElement,
      97                 :                       PRUint32 aAttrEnum);
      98                 : 
      99                 :   // Returns true if the animated value of this list has been explicitly
     100                 :   // set (either by animation, or by taking on the base value which has been
     101                 :   // explicitly set by markup or a DOM call), false otherwise.
     102                 :   // If this returns false, the animated value is still valid, that is,
     103                 :   // useable, and represents the default base value of the attribute.
     104               0 :   bool IsExplicitlySet() const
     105               0 :     { return !!mAnimVal || mIsBaseSet; }
     106                 :   
     107               0 :   bool IsAnimating() const {
     108               0 :     return !!mAnimVal;
     109                 :   }
     110                 : 
     111                 :   /// Callers own the returned nsISMILAttr
     112                 :   nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement, PRUint8 aAttrEnum);
     113                 : 
     114                 : private:
     115                 : 
     116                 :   // mAnimVal is a pointer to allow us to determine if we're being animated or
     117                 :   // not. Making it a non-pointer member and using mAnimVal.IsEmpty() to check
     118                 :   // if we're animating is not an option, since that would break animation *to*
     119                 :   // the empty string (<set to="">).
     120                 : 
     121                 :   SVGNumberList mBaseVal;
     122                 :   nsAutoPtr<SVGNumberList> mAnimVal;
     123                 :   bool mIsBaseSet;
     124                 : 
     125                 :   struct SMILAnimatedNumberList : public nsISMILAttr
     126               0 :   {
     127                 :   public:
     128               0 :     SMILAnimatedNumberList(SVGAnimatedNumberList* aVal,
     129                 :                            nsSVGElement* aSVGElement,
     130                 :                            PRUint8 aAttrEnum)
     131                 :       : mVal(aVal)
     132                 :       , mElement(aSVGElement)
     133               0 :       , mAttrEnum(aAttrEnum)
     134               0 :     {}
     135                 : 
     136                 :     // These will stay alive because a nsISMILAttr only lives as long
     137                 :     // as the Compositing step, and DOM elements don't get a chance to
     138                 :     // die during that.
     139                 :     SVGAnimatedNumberList* mVal;
     140                 :     nsSVGElement* mElement;
     141                 :     PRUint8 mAttrEnum;
     142                 : 
     143                 :     // nsISMILAttr methods
     144                 :     virtual nsresult ValueFromString(const nsAString& aStr,
     145                 :                                      const nsISMILAnimationElement* aSrcElement,
     146                 :                                      nsSMILValue& aValue,
     147                 :                                      bool& aPreventCachingOfSandwich) const;
     148                 :     virtual nsSMILValue GetBaseValue() const;
     149                 :     virtual void ClearAnimValue();
     150                 :     virtual nsresult SetAnimValue(const nsSMILValue& aValue);
     151                 :   };
     152                 : };
     153                 : 
     154                 : } // namespace mozilla
     155                 : 
     156                 : #endif // MOZILLA_SVGANIMATEDNUMBERLIST_H__

Generated by: LCOV version 1.7