LCOV - app.info - content/svg/content/src/DOMSVGAnimatedTransformList.h

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

           1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
           2                 :  * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
           3                 :  * ***** BEGIN LICENSE BLOCK *****
           4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           5                 :  *
           6                 :  * The contents of this file are subject to the Mozilla Public License Version
           7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           8                 :  * the License. You may obtain a copy of the License at
           9                 :  * http://www.mozilla.org/MPL/
          10                 :  *
          11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          13                 :  * for the specific language governing rights and limitations under the
          14                 :  * License.
          15                 :  *
          16                 :  * The Original Code is the Mozilla SVG project.
          17                 :  *
          18                 :  * The Initial Developer of the Original Code is
          19                 :  * Crocodile Clips Ltd..
          20                 :  * Portions created by the Initial Developer are Copyright (C) 2001
          21                 :  * the Initial Developer. All Rights Reserved.
          22                 :  *
          23                 :  * Contributor(s):
          24                 :  *   Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
          25                 :  *
          26                 :  * Alternatively, the contents of this file may be used under the terms of
          27                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
          28                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          30                 :  * of those above. If you wish to allow use of your version of this file only
          31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          32                 :  * use your version of this file under the terms of the MPL, indicate your
          33                 :  * decision by deleting the provisions above and replace them with the notice
          34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          35                 :  * the provisions above, a recipient may use your version of this file under
          36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          37                 :  *
          38                 :  * ***** END LICENSE BLOCK ***** */
          39                 :
          40                 : #ifndef MOZILLA_DOMSVGANIMATEDTRANSFORMLIST_H__
          41                 : #define MOZILLA_DOMSVGANIMATEDTRANSFORMLIST_H__
          42                 :
          43                 : #include "nsAutoPtr.h"
          44                 : #include "nsCOMPtr.h"
          45                 : #include "nsCycleCollectionParticipant.h"
          46                 : #include "nsIDOMSVGAnimTransformList.h"
          47                 : #include "nsSVGElement.h"
          48                 :
          49                 : namespace mozilla {
          50                 :
          51                 : class DOMSVGTransformList;
          52                 : class SVGAnimatedTransformList;
          53                 :
          54                 : /**
          55                 :  * Class DOMSVGAnimatedTransformList
          56                 :  *
          57                 :  * This class is used to create the DOM tearoff objects that wrap internal
          58                 :  * SVGAnimatedTransformList objects.
          59                 :  *
          60                 :  * See the architecture comment in DOMSVGAnimatedLengthList.h (that's
          61                 :  * LENGTH list). The comment for that class largly applies to this one too
          62                 :  * and will go a long way to helping you understand the architecture here.
          63                 :  *
          64                 :  * This class is strongly intertwined with DOMSVGTransformList and
          65                 :  * DOMSVGTransform.
          66                 :  * Our DOMSVGTransformList base and anim vals are friends and take care of
          67                 :  * nulling out our pointers to them when they die (making our pointers to them
          68                 :  * true weak refs).
          69                 :  */
          70                 : class DOMSVGAnimatedTransformList : public nsIDOMSVGAnimatedTransformList
          71                 : {
          72                 :   friend class DOMSVGTransformList;
          73                 :
          74                 : public:
          75               0 :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
          76            1396 :   NS_DECL_CYCLE_COLLECTION_CLASS(DOMSVGAnimatedTransformList)
          77                 :   NS_DECL_NSIDOMSVGANIMATEDTRANSFORMLIST
          78                 :
          79                 :   /**
          80                 :    * Factory method to create and return a DOMSVGAnimatedTransformList wrapper
          81                 :    * for a given internal SVGAnimatedTransformList object. The factory takes
          82                 :    * care of caching the object that it returns so that the same object can be
          83                 :    * returned for the given SVGAnimatedTransformList each time it is requested.
          84                 :    * The cached object is only removed from the cache when it is destroyed due
          85                 :    * to there being no more references to it or to any of its descendant
          86                 :    * objects. If that happens, any subsequent call requesting the DOM wrapper
          87                 :    * for the SVGAnimatedTransformList will naturally result in a new
          88                 :    * DOMSVGAnimatedTransformList being returned.
          89                 :    */
          90                 :   static already_AddRefed<DOMSVGAnimatedTransformList>
          91                 :     GetDOMWrapper(SVGAnimatedTransformList *aList, nsSVGElement *aElement);
          92                 :
          93                 :   /**
          94                 :    * This method returns the DOMSVGAnimatedTransformList wrapper for an internal
          95                 :    * SVGAnimatedTransformList object if it currently has a wrapper. If it does
          96                 :    * not, then nsnull is returned.
          97                 :    */
          98                 :   static DOMSVGAnimatedTransformList*
          99                 :     GetDOMWrapperIfExists(SVGAnimatedTransformList *aList);
         100                 :
         101                 :   /**
         102                 :    * Called by internal code to notify us when we need to sync the length of
         103                 :    * our baseVal DOM list with its internal list. This is called just prior to
         104                 :    * the length of the internal baseVal list being changed so that any DOM list
         105                 :    * items that need to be removed from the DOM list can first get their values
         106                 :    * from their internal counterpart.
         107                 :    *
         108                 :    * The only time this method could fail is on OOM when trying to increase the
         109                 :    * length of the DOM list. If that happens then this method simply clears the
         110                 :    * list and returns. Callers just proceed as normal, and we simply accept
         111                 :    * that the DOM list will be empty (until successfully set to a new value).
         112                 :    */
         113                 :   void InternalBaseValListWillChangeLengthTo(PRUint32 aNewLength);
         114                 :   void InternalAnimValListWillChangeLengthTo(PRUint32 aNewLength);
         115                 :
         116                 :   /**
         117                 :    * Returns true if our attribute is animating (in which case our animVal is
         118                 :    * not simply a mirror of our baseVal).
         119                 :    */
         120                 :   bool IsAnimating() const;
         121                 :
         122                 : private:
         123                 :
         124                 :   /**
         125                 :    * Only our static GetDOMWrapper() factory method may create objects of our
         126                 :    * type.
         127                 :    */
         128               0 :   DOMSVGAnimatedTransformList(nsSVGElement *aElement)
         129                 :     : mBaseVal(nsnull)
         130                 :     , mAnimVal(nsnull)
         131               0 :     , mElement(aElement)
         132               0 :   {}
         133                 :
         134                 :   ~DOMSVGAnimatedTransformList();
         135                 :
         136                 :   /// Get a reference to this DOM wrapper object's internal counterpart.
         137                 :   SVGAnimatedTransformList& InternalAList();
         138                 :   const SVGAnimatedTransformList& InternalAList() const;
         139                 :
         140                 :   // Weak refs to our DOMSVGTransformList 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                 :   DOMSVGTransformList *mBaseVal;
         144                 :   DOMSVGTransformList *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                 :
         151                 : } // namespace mozilla
         152                 :
         153                 : #endif // MOZILLA_DOMSVGANIMATEDTRANSFORMLIST_H__

Generated by: LCOV version 1.7