LCOV - code coverage report
Current view: top level - dom/svg - SVGTransform.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 25 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 17 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_SVGTransform_h
       8             : #define mozilla_dom_SVGTransform_h
       9             : 
      10             : #include "DOMSVGTransformList.h"
      11             : #include "gfxMatrix.h"
      12             : #include "nsAutoPtr.h"
      13             : #include "nsCycleCollectionParticipant.h"
      14             : #include "nsDebug.h"
      15             : #include "nsID.h"
      16             : #include "nsSVGTransform.h"
      17             : #include "nsWrapperCache.h"
      18             : #include "mozilla/Attributes.h"
      19             : 
      20             : class nsSVGElement;
      21             : 
      22             : #define MOZ_SVG_LIST_INDEX_BIT_COUNT 31 // supports > 2 billion list items
      23             : 
      24             : namespace mozilla {
      25             : namespace dom {
      26             : 
      27             : class SVGMatrix;
      28             : 
      29             : /**
      30             :  * DOM wrapper for an SVG transform. See DOMSVGLength.h.
      31             :  */
      32             : class SVGTransform final : public nsWrapperCache
      33             : {
      34             :   friend class AutoChangeTransformNotifier;
      35             : 
      36             : public:
      37           0 :   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(SVGTransform)
      38           0 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(SVGTransform)
      39             : 
      40             :   /**
      41             :    * Generic ctor for SVGTransform objects that are created for an attribute.
      42             :    */
      43             :   SVGTransform(DOMSVGTransformList *aList,
      44             :                uint32_t aListIndex,
      45             :                bool aIsAnimValItem);
      46             : 
      47             :   /**
      48             :    * Ctors for creating the objects returned by:
      49             :    *   SVGSVGElement.createSVGTransform(),
      50             :    *   SVGSVGElement.createSVGTransformFromMatrix(in SVGMatrix matrix),
      51             :    *   SVGTransformList.createSVGTransformFromMatrix(in SVGMatrix matrix)
      52             :    * which do not initially belong to an attribute.
      53             :    */
      54             :   explicit SVGTransform();
      55             :   explicit SVGTransform(const gfxMatrix &aMatrix);
      56             : 
      57             :   /**
      58             :    * Ctor for creating an unowned copy. Used with Clone().
      59             :    */
      60             :   explicit SVGTransform(const nsSVGTransform &aMatrix);
      61             : 
      62             :   /**
      63             :    * Create an unowned copy of an owned transform. The caller is responsible for
      64             :    * the first AddRef().
      65             :    */
      66           0 :   SVGTransform* Clone() {
      67           0 :     NS_ASSERTION(mList, "unexpected caller");
      68           0 :     return new SVGTransform(InternalItem());
      69             :   }
      70             : 
      71             :   bool IsInList() const {
      72             :     return !!mList;
      73             :   }
      74             : 
      75             :   /**
      76             :    * In future, if this class is used for non-list transforms, this will be
      77             :    * different to IsInList().
      78             :    */
      79           0 :   bool HasOwner() const {
      80           0 :     return !!mList;
      81             :   }
      82             : 
      83             :   /**
      84             :    * This method is called to notify this DOM object that it is being inserted
      85             :    * into a list, and give it the information it needs as a result.
      86             :    *
      87             :    * This object MUST NOT already belong to a list when this method is called.
      88             :    * That's not to say that script can't move these DOM objects between
      89             :    * lists - it can - it's just that the logic to handle that (and send out
      90             :    * the necessary notifications) is located elsewhere (in
      91             :    * DOMSVGTransformList).)
      92             :    */
      93             :   void InsertingIntoList(DOMSVGTransformList *aList,
      94             :                          uint32_t aListIndex,
      95             :                          bool aIsAnimValItem);
      96             : 
      97           0 :   static uint32_t MaxListIndex() {
      98           0 :     return (1U << MOZ_SVG_LIST_INDEX_BIT_COUNT) - 1;
      99             :   }
     100             : 
     101             :   /// This method is called to notify this object that its list index changed.
     102           0 :   void UpdateListIndex(uint32_t aListIndex) {
     103           0 :     mListIndex = aListIndex;
     104           0 :   }
     105             : 
     106             :   /**
     107             :    * This method is called to notify this DOM object that it is about to be
     108             :    * removed from its current DOM list so that it can first make a copy of its
     109             :    * internal counterpart's values. (If it didn't do this, then it would
     110             :    * "lose" its value on being removed.)
     111             :    */
     112             :   void RemovingFromList();
     113             : 
     114           0 :   nsSVGTransform ToSVGTransform() const {
     115           0 :     return Transform();
     116             :   }
     117             : 
     118             :   // WebIDL
     119           0 :   DOMSVGTransformList* GetParentObject() const { return mList; }
     120             :   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
     121             :   uint16_t Type() const;
     122             :   dom::SVGMatrix* GetMatrix();
     123             :   float Angle() const;
     124             :   void SetMatrix(dom::SVGMatrix& matrix, ErrorResult& rv);
     125             :   void SetTranslate(float tx, float ty, ErrorResult& rv);
     126             :   void SetScale(float sx, float sy, ErrorResult& rv);
     127             :   void SetRotate(float angle, float cx, float cy, ErrorResult& rv);
     128             :   void SetSkewX(float angle, ErrorResult& rv);
     129             :   void SetSkewY(float angle, ErrorResult& rv);
     130             : 
     131             : protected:
     132             :   ~SVGTransform();
     133             : 
     134             :   // Interface for SVGMatrix's use
     135             :   friend class dom::SVGMatrix;
     136           0 :   bool IsAnimVal() const {
     137           0 :     return mIsAnimValItem;
     138             :   }
     139           0 :   const gfxMatrix& Matrixgfx() const {
     140           0 :     return Transform().GetMatrix();
     141             :   }
     142             :   void SetMatrix(const gfxMatrix& aMatrix);
     143             : 
     144             : private:
     145           0 :   nsSVGElement* Element() {
     146           0 :     return mList->Element();
     147             :   }
     148             : 
     149             :   /**
     150             :    * Get a reference to the internal nsSVGTransform list item that this DOM
     151             :    * wrapper object currently wraps.
     152             :    */
     153             :   nsSVGTransform& InternalItem();
     154             :   const nsSVGTransform& InternalItem() const;
     155             : 
     156             : #ifdef DEBUG
     157             :   bool IndexIsValid();
     158             : #endif
     159             : 
     160           0 :   const nsSVGTransform& Transform() const {
     161           0 :     return HasOwner() ? InternalItem() : *mTransform;
     162             :   }
     163           0 :   nsSVGTransform& Transform() {
     164           0 :     return HasOwner() ? InternalItem() : *mTransform;
     165             :   }
     166             : 
     167             :   RefPtr<DOMSVGTransformList> mList;
     168             : 
     169             :   // Bounds for the following are checked in the ctor, so be sure to update
     170             :   // that if you change the capacity of any of the following.
     171             : 
     172             :   uint32_t mListIndex:MOZ_SVG_LIST_INDEX_BIT_COUNT;
     173             :   uint32_t mIsAnimValItem:1;
     174             : 
     175             :   // Usually this class acts as a wrapper for an nsSVGTransform object which is
     176             :   // part of a list and is accessed by going via the owning Element.
     177             :   //
     178             :   // However, in some circumstances, objects of this class may not be associated
     179             :   // with any particular list and thus, no internal nsSVGTransform object. In
     180             :   // that case we allocate an nsSVGTransform object on the heap to store the data.
     181             :   nsAutoPtr<nsSVGTransform> mTransform;
     182             : };
     183             : 
     184             : } // namespace dom
     185             : } // namespace mozilla
     186             : 
     187             : #undef MOZ_SVG_LIST_INDEX_BIT_COUNT
     188             : 
     189             : #endif // mozilla_dom_SVGTransform_h

Generated by: LCOV version 1.13