LCOV - code coverage report
Current view: top level - dom/svg - SVGAnimatedTransformList.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 7 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_dom_SVGAnimatedTransformList_h
       8             : #define mozilla_dom_SVGAnimatedTransformList_h
       9             : 
      10             : #include "nsAutoPtr.h"
      11             : #include "nsCOMPtr.h"
      12             : #include "nsCycleCollectionParticipant.h"
      13             : #include "nsSVGElement.h"
      14             : #include "nsWrapperCache.h"
      15             : #include "mozilla/Attributes.h"
      16             : 
      17             : namespace mozilla {
      18             : 
      19             : class DOMSVGTransformList;
      20             : class nsSVGAnimatedTransformList;
      21             : 
      22             : namespace dom {
      23             : 
      24             : /**
      25             :  * Class SVGAnimatedTransformList
      26             :  *
      27             :  * This class is used to create the DOM tearoff objects that wrap internal
      28             :  * nsSVGAnimatedTransformList objects.
      29             :  *
      30             :  * See the architecture comment in DOMSVGAnimatedLengthList.h (that's
      31             :  * LENGTH list). The comment for that class largly applies to this one too
      32             :  * and will go a long way to helping you understand the architecture here.
      33             :  *
      34             :  * This class is strongly intertwined with DOMSVGTransformList and
      35             :  * DOMSVGTransform.
      36             :  * Our DOMSVGTransformList base and anim vals are friends and take care of
      37             :  * nulling out our pointers to them when they die (making our pointers to them
      38             :  * true weak refs).
      39             :  */
      40             : class SVGAnimatedTransformList final : public nsWrapperCache
      41             : {
      42             :   friend class mozilla::DOMSVGTransformList;
      43             : 
      44             : public:
      45           0 :   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(SVGAnimatedTransformList)
      46           0 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(SVGAnimatedTransformList)
      47             : 
      48             :   /**
      49             :    * Factory method to create and return a SVGAnimatedTransformList wrapper
      50             :    * for a given internal nsSVGAnimatedTransformList object. The factory takes
      51             :    * care of caching the object that it returns so that the same object can be
      52             :    * returned for the given nsSVGAnimatedTransformList each time it is requested.
      53             :    * The cached object is only removed from the cache when it is destroyed due
      54             :    * to there being no more references to it or to any of its descendant
      55             :    * objects. If that happens, any subsequent call requesting the DOM wrapper
      56             :    * for the nsSVGAnimatedTransformList will naturally result in a new
      57             :    * SVGAnimatedTransformList being returned.
      58             :    */
      59             :   static already_AddRefed<SVGAnimatedTransformList>
      60             :     GetDOMWrapper(nsSVGAnimatedTransformList *aList, nsSVGElement *aElement);
      61             : 
      62             :   /**
      63             :    * This method returns the SVGAnimatedTransformList wrapper for an internal
      64             :    * nsSVGAnimatedTransformList object if it currently has a wrapper. If it does
      65             :    * not, then nullptr is returned.
      66             :    */
      67             :   static SVGAnimatedTransformList*
      68             :     GetDOMWrapperIfExists(nsSVGAnimatedTransformList *aList);
      69             : 
      70             :   /**
      71             :    * Called by internal code to notify us when we need to sync the length of
      72             :    * our baseVal DOM list with its internal list. This is called just prior to
      73             :    * the length of the internal baseVal list being changed so that any DOM list
      74             :    * items that need to be removed from the DOM list can first get their values
      75             :    * from their internal counterpart.
      76             :    *
      77             :    * The only time this method could fail is on OOM when trying to increase the
      78             :    * length of the DOM list. If that happens then this method simply clears the
      79             :    * list and returns. Callers just proceed as normal, and we simply accept
      80             :    * that the DOM list will be empty (until successfully set to a new value).
      81             :    */
      82             :   void InternalBaseValListWillChangeLengthTo(uint32_t aNewLength);
      83             :   void InternalAnimValListWillChangeLengthTo(uint32_t aNewLength);
      84             : 
      85             :   /**
      86             :    * Returns true if our attribute is animating (in which case our animVal is
      87             :    * not simply a mirror of our baseVal).
      88             :    */
      89             :   bool IsAnimating() const;
      90             : 
      91             :   // WebIDL
      92           0 :   nsSVGElement* GetParentObject() const { return mElement; }
      93             :   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
      94             :   // These aren't weak refs because mBaseVal and mAnimVal are weak
      95             :   already_AddRefed<DOMSVGTransformList> BaseVal();
      96             :   already_AddRefed<DOMSVGTransformList> AnimVal();
      97             : 
      98             : private:
      99             : 
     100             :   /**
     101             :    * Only our static GetDOMWrapper() factory method may create objects of our
     102             :    * type.
     103             :    */
     104           0 :   explicit SVGAnimatedTransformList(nsSVGElement *aElement)
     105           0 :     : mBaseVal(nullptr)
     106             :     , mAnimVal(nullptr)
     107           0 :     , mElement(aElement)
     108             :   {
     109           0 :   }
     110             : 
     111             :   ~SVGAnimatedTransformList();
     112             : 
     113             :   /// Get a reference to this DOM wrapper object's internal counterpart.
     114             :   nsSVGAnimatedTransformList& InternalAList();
     115             :   const nsSVGAnimatedTransformList& InternalAList() const;
     116             : 
     117             :   // Weak refs to our DOMSVGTransformList baseVal/animVal objects. These objects
     118             :   // are friends and take care of clearing these pointers when they die, making
     119             :   // these true weak references.
     120             :   DOMSVGTransformList *mBaseVal;
     121             :   DOMSVGTransformList *mAnimVal;
     122             : 
     123             :   // Strong ref to our element to keep it alive. We hold this not only for
     124             :   // ourself, but also for our base/animVal and all of their items.
     125             :   RefPtr<nsSVGElement> mElement;
     126             : };
     127             : 
     128             : } // namespace dom
     129             : } // namespace mozilla
     130             : 
     131             : #endif // mozilla_dom_SVGAnimatedTransformList_h

Generated by: LCOV version 1.13