LCOV - code coverage report
Current view: top level - dom/svg - SVGMarkerElement.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 29 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 15 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_SVGMarkerElement_h
       8             : #define mozilla_dom_SVGMarkerElement_h
       9             : 
      10             : #include "nsAutoPtr.h"
      11             : #include "nsSVGAngle.h"
      12             : #include "nsSVGEnum.h"
      13             : #include "nsSVGLength2.h"
      14             : #include "nsSVGViewBox.h"
      15             : #include "SVGAnimatedPreserveAspectRatio.h"
      16             : #include "nsSVGElement.h"
      17             : #include "mozilla/Attributes.h"
      18             : #include "mozilla/dom/SVGAnimatedEnumeration.h"
      19             : 
      20             : class nsSVGMarkerFrame;
      21             : struct nsSVGMark;
      22             : 
      23             : nsresult NS_NewSVGMarkerElement(nsIContent **aResult,
      24             :                                 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
      25             : 
      26             : namespace mozilla {
      27             : namespace dom {
      28             : 
      29             : // Marker Unit Types
      30             : static const unsigned short SVG_MARKERUNITS_UNKNOWN         = 0;
      31             : static const unsigned short SVG_MARKERUNITS_USERSPACEONUSE = 1;
      32             : static const unsigned short SVG_MARKERUNITS_STROKEWIDTH    = 2;
      33             : 
      34             : // Marker Orientation Types
      35             : static const unsigned short SVG_MARKER_ORIENT_UNKNOWN            = 0;
      36             : static const unsigned short SVG_MARKER_ORIENT_AUTO               = 1;
      37             : static const unsigned short SVG_MARKER_ORIENT_ANGLE              = 2;
      38             : static const unsigned short SVG_MARKER_ORIENT_AUTO_START_REVERSE = 3;
      39             : 
      40             : class nsSVGOrientType
      41             : {
      42             : public:
      43           0 :   nsSVGOrientType()
      44           0 :    : mAnimVal(SVG_MARKER_ORIENT_ANGLE),
      45           0 :      mBaseVal(SVG_MARKER_ORIENT_ANGLE) {}
      46             : 
      47             :   nsresult SetBaseValue(uint16_t aValue,
      48             :                         nsSVGElement *aSVGElement);
      49             : 
      50             :   // XXX FIXME like https://bugzilla.mozilla.org/show_bug.cgi?id=545550 but
      51             :   // without adding an mIsAnimated member...?
      52           0 :   void SetBaseValue(uint16_t aValue)
      53           0 :     { mAnimVal = mBaseVal = uint8_t(aValue); }
      54             :   // no need to notify, since nsSVGAngle does that
      55           0 :   void SetAnimValue(uint16_t aValue)
      56           0 :     { mAnimVal = uint8_t(aValue); }
      57             : 
      58             :   // we want to avoid exposing SVG_MARKER_ORIENT_AUTO_START_REVERSE to
      59             :   // Web content
      60           0 :   uint16_t GetBaseValue() const
      61           0 :     { return mAnimVal == SVG_MARKER_ORIENT_AUTO_START_REVERSE ?
      62           0 :                SVG_MARKER_ORIENT_UNKNOWN : mBaseVal; }
      63           0 :   uint16_t GetAnimValue() const
      64           0 :     { return mAnimVal == SVG_MARKER_ORIENT_AUTO_START_REVERSE ?
      65           0 :                SVG_MARKER_ORIENT_UNKNOWN : mAnimVal; }
      66           0 :   uint16_t GetAnimValueInternal() const
      67           0 :     { return mAnimVal; }
      68             : 
      69             :   already_AddRefed<SVGAnimatedEnumeration>
      70             :     ToDOMAnimatedEnum(nsSVGElement* aSVGElement);
      71             : 
      72             : private:
      73             :   nsSVGEnumValue mAnimVal;
      74             :   nsSVGEnumValue mBaseVal;
      75             : 
      76           0 :   struct DOMAnimatedEnum final : public SVGAnimatedEnumeration
      77             :   {
      78           0 :     DOMAnimatedEnum(nsSVGOrientType* aVal,
      79             :                     nsSVGElement *aSVGElement)
      80           0 :       : SVGAnimatedEnumeration(aSVGElement)
      81           0 :       , mVal(aVal)
      82           0 :     {}
      83             : 
      84             :     nsSVGOrientType *mVal; // kept alive because it belongs to content
      85             : 
      86             :     using mozilla::dom::SVGAnimatedEnumeration::SetBaseVal;
      87           0 :     virtual uint16_t BaseVal() override
      88             :     {
      89           0 :       return mVal->GetBaseValue();
      90             :     }
      91           0 :     virtual void SetBaseVal(uint16_t aBaseVal, ErrorResult& aRv) override
      92             :     {
      93           0 :       aRv = mVal->SetBaseValue(aBaseVal, mSVGElement);
      94           0 :     }
      95           0 :     virtual uint16_t AnimVal() override
      96             :     {
      97           0 :       return mVal->GetAnimValue();
      98             :     }
      99             :   };
     100             : };
     101             : 
     102             : typedef nsSVGElement SVGMarkerElementBase;
     103             : 
     104           0 : class SVGMarkerElement : public SVGMarkerElementBase
     105             : {
     106             :   friend class ::nsSVGMarkerFrame;
     107             : 
     108             : protected:
     109             :   friend nsresult (::NS_NewSVGMarkerElement(nsIContent **aResult,
     110             :                                             already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
     111             :   explicit SVGMarkerElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
     112             :   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
     113             : 
     114             : public:
     115             :   // nsIContent interface
     116             :   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const override;
     117             : 
     118             :   virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
     119             :                              bool aNotify) override;
     120             : 
     121             :   // nsSVGSVGElement methods:
     122             :   virtual bool HasValidDimensions() const override;
     123             : 
     124             :   // public helpers
     125             :   gfx::Matrix GetMarkerTransform(float aStrokeWidth, const nsSVGMark& aMark);
     126             :   nsSVGViewBoxRect GetViewBoxRect();
     127             :   gfx::Matrix GetViewBoxTransform();
     128             : 
     129             :   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
     130             :                          bool aPreallocateChildren) const override;
     131             : 
     132           0 :   nsSVGOrientType* GetOrientType() { return &mOrientType; }
     133             : 
     134             :   // Returns the value of svg.marker-improvements.enabled.
     135             :   static bool MarkerImprovementsPrefEnabled();
     136             : 
     137             :   // WebIDL
     138             :   already_AddRefed<SVGAnimatedRect> ViewBox();
     139             :   already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
     140             :   already_AddRefed<SVGAnimatedLength> RefX();
     141             :   already_AddRefed<SVGAnimatedLength> RefY();
     142             :   already_AddRefed<SVGAnimatedEnumeration> MarkerUnits();
     143             :   already_AddRefed<SVGAnimatedLength> MarkerWidth();
     144             :   already_AddRefed<SVGAnimatedLength> MarkerHeight();
     145             :   already_AddRefed<SVGAnimatedEnumeration> OrientType();
     146             :   already_AddRefed<SVGAnimatedAngle> OrientAngle();
     147             :   void SetOrientToAuto();
     148             :   void SetOrientToAngle(SVGAngle& angle, ErrorResult& rv);
     149             : 
     150             : protected:
     151             : 
     152             :   virtual bool ParseAttribute(int32_t aNameSpaceID, nsIAtom* aName,
     153             :                                 const nsAString& aValue,
     154             :                                 nsAttrValue& aResult) override;
     155             : 
     156             :   void SetParentCoordCtxProvider(SVGSVGElement *aContext);
     157             : 
     158             :   virtual LengthAttributesInfo GetLengthInfo() override;
     159             :   virtual AngleAttributesInfo GetAngleInfo() override;
     160             :   virtual EnumAttributesInfo GetEnumInfo() override;
     161             :   virtual nsSVGViewBox *GetViewBox() override;
     162             :   virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio() override;
     163             : 
     164             :   enum { REFX, REFY, MARKERWIDTH, MARKERHEIGHT };
     165             :   nsSVGLength2 mLengthAttributes[4];
     166             :   static LengthInfo sLengthInfo[4];
     167             : 
     168             :   enum { MARKERUNITS };
     169             :   nsSVGEnum mEnumAttributes[1];
     170             :   static nsSVGEnumMapping sUnitsMap[];
     171             :   static EnumInfo sEnumInfo[1];
     172             : 
     173             :   enum { ORIENT };
     174             :   nsSVGAngle mAngleAttributes[1];
     175             :   static AngleInfo sAngleInfo[1];
     176             : 
     177             :   nsSVGViewBox             mViewBox;
     178             :   SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
     179             : 
     180             :   // derived properties (from 'orient') handled separately
     181             :   nsSVGOrientType                        mOrientType;
     182             : 
     183             :   SVGSVGElement                         *mCoordCtx;
     184             :   nsAutoPtr<gfx::Matrix>                 mViewBoxToViewportTransform;
     185             : };
     186             : 
     187             : } // namespace dom
     188             : } // namespace mozilla
     189             : 
     190             : #endif // mozilla_dom_SVGMarkerElement_h

Generated by: LCOV version 1.13