LCOV - code coverage report
Current view: directory - content/svg/content/src - DOMSVGAnimatedNumberList.h (source / functions) Found Hit Coverage
Test: app.info Lines: 5 1 20.0 %
Date: 2012-06-02 Functions: 6 1 16.7 %

       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_DOMSVGANIMATEDNUMBERLIST_H__
      38                 : #define MOZILLA_DOMSVGANIMATEDNUMBERLIST_H__
      39                 : 
      40                 : #include "nsAutoPtr.h"
      41                 : #include "nsCOMPtr.h"
      42                 : #include "nsCycleCollectionParticipant.h"
      43                 : #include "nsIDOMSVGAnimatedNumberList.h"
      44                 : #include "nsSVGElement.h"
      45                 : 
      46                 : namespace mozilla {
      47                 : 
      48                 : class DOMSVGNumberList;
      49                 : class SVGAnimatedNumberList;
      50                 : class SVGNumberList;
      51                 : 
      52                 : /**
      53                 :  * Class DOMSVGAnimatedNumberList
      54                 :  *
      55                 :  * This class is used to create the DOM tearoff objects that wrap internal
      56                 :  * SVGAnimatedNumberList objects.
      57                 :  *
      58                 :  * See the architecture comment in DOMSVGAnimatedLengthList.h (that's
      59                 :  * LENGTH list). The comment for that class largly applies to this one too
      60                 :  * and will go a long way to helping you understand the architecture here.
      61                 :  *
      62                 :  * This class is strongly intertwined with DOMSVGNumberList and DOMSVGNumber.
      63                 :  * Our DOMSVGNumberList base and anim vals are friends and take care of nulling
      64                 :  * out our pointers to them when they die (making our pointers to them true
      65                 :  * weak refs).
      66                 :  */
      67                 : class DOMSVGAnimatedNumberList : public nsIDOMSVGAnimatedNumberList
      68                 : {
      69                 :   friend class DOMSVGNumberList;
      70                 : 
      71                 : public:
      72               0 :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      73            1464 :   NS_DECL_CYCLE_COLLECTION_CLASS(DOMSVGAnimatedNumberList)
      74                 :   NS_DECL_NSIDOMSVGANIMATEDNUMBERLIST
      75                 : 
      76                 :   /**
      77                 :    * Factory method to create and return a DOMSVGAnimatedNumberList wrapper
      78                 :    * for a given internal SVGAnimatedNumberList object. The factory takes care
      79                 :    * of caching the object that it returns so that the same object can be
      80                 :    * returned for the given SVGAnimatedNumberList each time it is requested.
      81                 :    * The cached object is only removed from the cache when it is destroyed due
      82                 :    * to there being no more references to it or to any of its descendant
      83                 :    * objects. If that happens, any subsequent call requesting the DOM wrapper
      84                 :    * for the SVGAnimatedNumberList will naturally result in a new
      85                 :    * DOMSVGAnimatedNumberList being returned.
      86                 :    */
      87                 :   static already_AddRefed<DOMSVGAnimatedNumberList>
      88                 :     GetDOMWrapper(SVGAnimatedNumberList *aList,
      89                 :                   nsSVGElement *aElement,
      90                 :                   PRUint8 aAttrEnum);
      91                 : 
      92                 :   /**
      93                 :    * This method returns the DOMSVGAnimatedNumberList wrapper for an internal
      94                 :    * SVGAnimatedNumberList object if it currently has a wrapper. If it does
      95                 :    * not, then nsnull is returned.
      96                 :    */
      97                 :   static DOMSVGAnimatedNumberList*
      98                 :     GetDOMWrapperIfExists(SVGAnimatedNumberList *aList);
      99                 : 
     100                 :   /**
     101                 :    * Called by internal code to notify us when we need to sync the length of
     102                 :    * our baseVal DOM list with its internal list. This is called just prior to
     103                 :    * the length of the internal baseVal list being changed so that any DOM list
     104                 :    * items that need to be removed from the DOM list can first get their values
     105                 :    * from their internal counterpart.
     106                 :    *
     107                 :    * The only time this method could fail is on OOM when trying to increase the
     108                 :    * length of the DOM list. If that happens then this method simply clears the
     109                 :    * list and returns. Callers just proceed as normal, and we simply accept
     110                 :    * that the DOM list will be empty (until successfully set to a new value).
     111                 :    */
     112                 :   void InternalBaseValListWillChangeTo(const SVGNumberList& aNewValue);
     113                 :   void InternalAnimValListWillChangeTo(const SVGNumberList& aNewValue);
     114                 : 
     115                 :   /**
     116                 :    * Returns true if our attribute is animating (in which case our animVal is
     117                 :    * not simply a mirror of our baseVal).
     118                 :    */
     119                 :   bool IsAnimating() const;
     120                 : 
     121                 : private:
     122                 : 
     123                 :   /**
     124                 :    * Only our static GetDOMWrapper() factory method may create objects of our
     125                 :    * type.
     126                 :    */
     127               0 :   DOMSVGAnimatedNumberList(nsSVGElement *aElement, PRUint8 aAttrEnum)
     128                 :     : mBaseVal(nsnull)
     129                 :     , mAnimVal(nsnull)
     130                 :     , mElement(aElement)
     131               0 :     , mAttrEnum(aAttrEnum)
     132               0 :   {}
     133                 : 
     134                 :   ~DOMSVGAnimatedNumberList();
     135                 : 
     136                 :   /// Get a reference to this DOM wrapper object's internal counterpart.
     137                 :   SVGAnimatedNumberList& InternalAList();
     138                 :   const SVGAnimatedNumberList& InternalAList() const;
     139                 : 
     140                 :   // Weak refs to our DOMSVGNumberList baseVal/animVal objects. These objects
     141                 :   // are friends and take care of clearing these pointers when they die, making
     142                 :   // these true weak references.
     143                 :   DOMSVGNumberList *mBaseVal;
     144                 :   DOMSVGNumberList *mAnimVal;
     145                 : 
     146                 :   // Strong ref to our element to keep it alive. We hold this not only for
     147                 :   // ourself, but also for our base/animVal and all of their items.
     148                 :   nsRefPtr<nsSVGElement> mElement;
     149                 : 
     150                 :   PRUint8 mAttrEnum;
     151                 : };
     152                 : 
     153                 : } // namespace mozilla
     154                 : 
     155                 : #endif // MOZILLA_DOMSVGANIMATEDNUMBERLIST_H__

Generated by: LCOV version 1.7