LCOV - code coverage report
Current view: directory - content/svg/content/src - nsSVGCircleElement.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 32 0 0.0 %
Date: 2012-06-02 Functions: 75 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is the Mozilla SVG project.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Crocodile Clips Ltd..
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2001
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      27                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #include "mozilla/Util.h"
      40                 : 
      41                 : #include "nsSVGPathGeometryElement.h"
      42                 : #include "nsIDOMSVGCircleElement.h"
      43                 : #include "nsSVGLength2.h"
      44                 : #include "nsGkAtoms.h"
      45                 : #include "nsSVGUtils.h"
      46                 : #include "gfxContext.h"
      47                 : 
      48                 : using namespace mozilla;
      49                 : 
      50                 : typedef nsSVGPathGeometryElement nsSVGCircleElementBase;
      51                 : 
      52                 : class nsSVGCircleElement : public nsSVGCircleElementBase,
      53                 :                            public nsIDOMSVGCircleElement
      54               0 : {
      55                 : protected:
      56                 :   friend nsresult NS_NewSVGCircleElement(nsIContent **aResult,
      57                 :                                          already_AddRefed<nsINodeInfo> aNodeInfo);
      58                 :   nsSVGCircleElement(already_AddRefed<nsINodeInfo> aNodeInfo);
      59                 : 
      60                 : public:
      61                 :   // interfaces:
      62                 :   NS_DECL_ISUPPORTS_INHERITED
      63                 :   NS_DECL_NSIDOMSVGCIRCLEELEMENT
      64                 : 
      65                 :   // xxx I wish we could use virtual inheritance
      66               0 :   NS_FORWARD_NSIDOMNODE(nsSVGCircleElementBase::)
      67               0 :   NS_FORWARD_NSIDOMELEMENT(nsSVGCircleElementBase::)
      68               0 :   NS_FORWARD_NSIDOMSVGELEMENT(nsSVGCircleElementBase::)
      69                 : 
      70                 :   // nsSVGSVGElement methods:
      71                 :   virtual bool HasValidDimensions() const;
      72                 : 
      73                 :   // nsSVGPathGeometryElement methods:
      74                 :   virtual void ConstructPath(gfxContext *aCtx);
      75                 : 
      76                 :   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
      77                 : 
      78                 :   virtual nsXPCClassInfo* GetClassInfo();
      79                 : protected:
      80                 : 
      81                 :   virtual LengthAttributesInfo GetLengthInfo();
      82                 : 
      83                 :   enum { CX, CY, R };
      84                 :   nsSVGLength2 mLengthAttributes[3];
      85                 :   static LengthInfo sLengthInfo[3];
      86                 : };
      87                 : 
      88                 : nsSVGElement::LengthInfo nsSVGCircleElement::sLengthInfo[3] =
      89                 : {
      90                 :   { &nsGkAtoms::cx, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, nsSVGUtils::X },
      91                 :   { &nsGkAtoms::cy, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, nsSVGUtils::Y },
      92                 :   { &nsGkAtoms::r, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, nsSVGUtils::XY }
      93                 : };
      94                 : 
      95               0 : NS_IMPL_NS_NEW_SVG_ELEMENT(Circle)
      96                 : 
      97                 : //----------------------------------------------------------------------
      98                 : // nsISupports methods
      99                 : 
     100               0 : NS_IMPL_ADDREF_INHERITED(nsSVGCircleElement,nsSVGCircleElementBase)
     101               0 : NS_IMPL_RELEASE_INHERITED(nsSVGCircleElement,nsSVGCircleElementBase)
     102                 : 
     103               0 : DOMCI_NODE_DATA(SVGCircleElement, nsSVGCircleElement)
     104                 : 
     105               0 : NS_INTERFACE_TABLE_HEAD(nsSVGCircleElement)
     106               0 :   NS_NODE_INTERFACE_TABLE5(nsSVGCircleElement, nsIDOMNode, nsIDOMElement,
     107                 :                            nsIDOMSVGElement, nsIDOMSVGTests,
     108                 :                            nsIDOMSVGCircleElement)
     109               0 :   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGCircleElement)
     110               0 : NS_INTERFACE_MAP_END_INHERITING(nsSVGCircleElementBase)
     111                 : 
     112                 : //----------------------------------------------------------------------
     113                 : // Implementation
     114                 : 
     115               0 : nsSVGCircleElement::nsSVGCircleElement(already_AddRefed<nsINodeInfo> aNodeInfo)
     116               0 :   : nsSVGCircleElementBase(aNodeInfo)
     117                 : {
     118               0 : }
     119                 : 
     120                 : //----------------------------------------------------------------------
     121                 : // nsIDOMNode methods
     122                 : 
     123               0 : NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGCircleElement)
     124                 : 
     125                 : //----------------------------------------------------------------------
     126                 : // nsIDOMSVGCircleElement methods
     127                 : 
     128                 : /* readonly attribute nsIDOMSVGAnimatedLength cx; */
     129               0 : NS_IMETHODIMP nsSVGCircleElement::GetCx(nsIDOMSVGAnimatedLength * *aCx)
     130                 : {
     131               0 :   return mLengthAttributes[CX].ToDOMAnimatedLength(aCx, this);
     132                 : }
     133                 : 
     134                 : /* readonly attribute nsIDOMSVGAnimatedLength cy; */
     135               0 : NS_IMETHODIMP nsSVGCircleElement::GetCy(nsIDOMSVGAnimatedLength * *aCy)
     136                 : {
     137               0 :   return mLengthAttributes[CY].ToDOMAnimatedLength(aCy, this);
     138                 : }
     139                 : 
     140                 : /* readonly attribute nsIDOMSVGAnimatedLength r; */
     141               0 : NS_IMETHODIMP nsSVGCircleElement::GetR(nsIDOMSVGAnimatedLength * *aR)
     142                 : {
     143               0 :   return mLengthAttributes[R].ToDOMAnimatedLength(aR, this);
     144                 : }
     145                 : 
     146                 : //----------------------------------------------------------------------
     147                 : // nsSVGElement methods
     148                 : 
     149                 : /* virtual */ bool
     150               0 : nsSVGCircleElement::HasValidDimensions() const
     151                 : {
     152               0 :   return mLengthAttributes[R].IsExplicitlySet() &&
     153               0 :          mLengthAttributes[R].GetAnimValInSpecifiedUnits() > 0;
     154                 : }
     155                 : 
     156                 : nsSVGElement::LengthAttributesInfo
     157               0 : nsSVGCircleElement::GetLengthInfo()
     158                 : {
     159                 :   return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
     160               0 :                               ArrayLength(sLengthInfo));
     161                 : }
     162                 : 
     163                 : //----------------------------------------------------------------------
     164                 : // nsSVGPathGeometryElement methods
     165                 : 
     166                 : void
     167               0 : nsSVGCircleElement::ConstructPath(gfxContext *aCtx)
     168                 : {
     169                 :   float x, y, r;
     170                 : 
     171               0 :   GetAnimatedLengthValues(&x, &y, &r, nsnull);
     172                 : 
     173               0 :   if (r > 0.0f)
     174               0 :     aCtx->Arc(gfxPoint(x, y), r, 0, 2*M_PI);
     175               0 : }

Generated by: LCOV version 1.7