LCOV - code coverage report
Current view: top level - dom/svg - nsISVGPoint.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 31 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 18 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             : #pragma once
       8             : 
       9             : #include "nsCycleCollectionParticipant.h"
      10             : #include "nsWrapperCache.h"
      11             : #include "mozilla/dom/SVGPointBinding.h"
      12             : #include "DOMSVGPointList.h"
      13             : 
      14             : // {d6b6c440-af8d-40ee-856b-02a317cab275}
      15             : #define MOZILLA_NSISVGPOINT_IID \
      16             :   { 0xd6b6c440, 0xaf8d, 0x40ee, \
      17             :     { 0x85, 0x6b, 0x02, 0xa3, 0x17, 0xca, 0xb2, 0x75 } }
      18             : 
      19             : #define MOZ_SVG_LIST_INDEX_BIT_COUNT 29
      20             : 
      21             : namespace mozilla {
      22             : 
      23             : namespace dom {
      24             : class SVGMatrix;
      25             : } // namespace dom
      26             : 
      27             : /**
      28             :  * Class nsISVGPoint
      29             :  *
      30             :  * This class creates the DOM objects that wrap internal SVGPoint objects.
      31             :  * An nsISVGPoint can be either a DOMSVGPoint or a DOMSVGTranslatePoint
      32             :  */
      33             : class nsISVGPoint : public nsISupports,
      34             :                     public nsWrapperCache
      35             : {
      36             : public:
      37             :   NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_NSISVGPOINT_IID)
      38             :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      39           0 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsISVGPoint)
      40             : 
      41             :   /**
      42             :    * Generic ctor for DOMSVGPoint objects that are created for an attribute.
      43             :    */
      44           0 :   explicit nsISVGPoint()
      45           0 :     : mList(nullptr)
      46             :     , mListIndex(0)
      47             :     , mIsReadonly(false)
      48             :     , mIsAnimValItem(false)
      49           0 :     , mIsTranslatePoint(false)
      50             :   {
      51           0 :   }
      52             : 
      53           0 :   explicit nsISVGPoint(SVGPoint* aPt, bool aIsTranslatePoint)
      54           0 :     : mList(nullptr)
      55             :     , mListIndex(0)
      56             :     , mIsReadonly(false)
      57             :     , mIsAnimValItem(false)
      58           0 :     , mIsTranslatePoint(aIsTranslatePoint)
      59             :   {
      60           0 :     mPt.mX = aPt->GetX();
      61           0 :     mPt.mY = aPt->GetY();
      62           0 :   }
      63             : 
      64             : protected:
      65           0 :   virtual ~nsISVGPoint()
      66           0 :   {
      67             :     // Our mList's weak ref to us must be nulled out when we die. If GC has
      68             :     // unlinked us using the cycle collector code, then that has already
      69             :     // happened, and mList is null.
      70           0 :     if (mList) {
      71           0 :       mList->mItems[mListIndex] = nullptr;
      72             :     }
      73           0 :   }
      74             : 
      75             : public:
      76             :   /**
      77             :    * Creates an unowned copy of this object's point as a DOMSVGPoint.
      78             :    */
      79             :   virtual DOMSVGPoint* Copy() = 0;
      80             : 
      81           0 :   SVGPoint ToSVGPoint() const {
      82           0 :     return HasOwner() ? const_cast<nsISVGPoint*>(this)->InternalItem() : mPt;
      83             :   }
      84             : 
      85             :   bool IsInList() const {
      86             :     return !!mList;
      87             :   }
      88             : 
      89             :   /**
      90             :    * In future, if this class is used for non-list points, this will be
      91             :    * different to IsInList(). "Owner" here means that the instance has an
      92             :    * internal counterpart from which it gets its values. (A better name may
      93             :    * be HasWrappee().)
      94             :    */
      95           0 :   bool HasOwner() const {
      96           0 :     return !!mList;
      97             :   }
      98             : 
      99           0 :   bool IsTranslatePoint() const {
     100           0 :     return mIsTranslatePoint;
     101             :   }
     102             : 
     103             :   /**
     104             :    * This method is called to notify this DOM object that it is being inserted
     105             :    * into a list, and give it the information it needs as a result.
     106             :    *
     107             :    * This object MUST NOT already belong to a list when this method is called.
     108             :    * That's not to say that script can't move these DOM objects between
     109             :    * lists - it can - it's just that the logic to handle that (and send out
     110             :    * the necessary notifications) is located elsewhere (in DOMSVGPointList).)
     111             :    */
     112             :   void InsertingIntoList(DOMSVGPointList *aList,
     113             :                          uint32_t aListIndex,
     114             :                          bool aIsAnimValItem);
     115             : 
     116           0 :   static uint32_t MaxListIndex() {
     117           0 :     return (1U << MOZ_SVG_LIST_INDEX_BIT_COUNT) - 1;
     118             :   }
     119             : 
     120             :   /// This method is called to notify this object that its list index changed.
     121           0 :   void UpdateListIndex(uint32_t aListIndex) {
     122           0 :     mListIndex = aListIndex;
     123           0 :   }
     124             : 
     125             :   /**
     126             :    * This method is called to notify this DOM object that it is about to be
     127             :    * removed from its current DOM list so that it can first make a copy of its
     128             :    * internal counterpart's values. (If it didn't do this, then it would
     129             :    * "lose" its value on being removed.)
     130             :    */
     131             :   void RemovingFromList();
     132             : 
     133           0 :   bool IsReadonly() const {
     134           0 :     return mIsReadonly;
     135             :   }
     136             :   void SetReadonly(bool aReadonly) {
     137             :     mIsReadonly = aReadonly;
     138             :   }
     139             : 
     140             :   // WebIDL
     141             :   virtual float X() = 0;
     142             :   virtual void SetX(float aX, ErrorResult& rv) = 0;
     143             :   virtual float Y() = 0;
     144             :   virtual void SetY(float aY, ErrorResult& rv) = 0;
     145             :   virtual already_AddRefed<nsISVGPoint> MatrixTransform(dom::SVGMatrix& matrix) = 0;
     146           0 :   virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override
     147           0 :     { return dom::SVGPointBinding::Wrap(cx, this, aGivenProto); }
     148             : 
     149             :   virtual nsISupports* GetParentObject() = 0;
     150             : 
     151             : protected:
     152             : #ifdef DEBUG
     153             :   bool IndexIsValid();
     154             : #endif
     155             : 
     156             :   RefPtr<DOMSVGPointList> mList;
     157             : 
     158             :   // Bounds for the following are checked in the ctor, so be sure to update
     159             :   // that if you change the capacity of any of the following.
     160             : 
     161             :   uint32_t mListIndex:MOZ_SVG_LIST_INDEX_BIT_COUNT;
     162             :   uint32_t mIsReadonly:1;       // These flags are uint32_t because MSVC won't
     163             :   uint32_t mIsAnimValItem:1;    // pack otherwise.
     164             :   uint32_t mIsTranslatePoint:1;
     165             : 
     166             :   /**
     167             :    * Get a reference to the internal SVGPoint list item that this DOM wrapper
     168             :    * object currently wraps.
     169             :    *
     170             :    * To simplify the code we just have this one method for obtaining both
     171             :    * baseVal and animVal internal items. This means that animVal items don't
     172             :    * get const protection, but then our setter methods guard against changing
     173             :    * animVal items.
     174             :    */
     175             :   SVGPoint& InternalItem();
     176             : 
     177             :   // The following member is only used when we're not in a list:
     178             :   SVGPoint mPt;
     179             : };
     180             : 
     181             : NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGPoint, MOZILLA_NSISVGPOINT_IID)
     182             : 
     183             : } // namespace mozilla
     184             : 
     185             : #undef MOZ_SVG_LIST_INDEX_BIT_COUNT
     186             : 
     187             : 

Generated by: LCOV version 1.13