LCOV - code coverage report
Current view: directory - content/svg/content/src - nsSVGUseElement.h (source / functions) Found Hit Coverage
Test: app.info Lines: 13 1 7.7 %
Date: 2012-06-02 Functions: 66 1 1.5 %

       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 IBM Corporation.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2004
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *
      23                 :  * Alternatively, the contents of this file may be used under the terms of
      24                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      25                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      26                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      27                 :  * of those above. If you wish to allow use of your version of this file only
      28                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      29                 :  * use your version of this file under the terms of the MPL, indicate your
      30                 :  * decision by deleting the provisions above and replace them with the notice
      31                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      32                 :  * the provisions above, a recipient may use your version of this file under
      33                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      34                 :  *
      35                 :  * ***** END LICENSE BLOCK ***** */
      36                 : 
      37                 : #ifndef __NS_SVGUSEELEMENT_H__
      38                 : #define __NS_SVGUSEELEMENT_H__
      39                 : 
      40                 : #include "DOMSVGTests.h"
      41                 : #include "mozilla/dom/FromParser.h"
      42                 : #include "nsIDOMSVGURIReference.h"
      43                 : #include "nsIDOMSVGUseElement.h"
      44                 : #include "nsReferencedElement.h"
      45                 : #include "nsStubMutationObserver.h"
      46                 : #include "nsSVGGraphicElement.h"
      47                 : #include "nsSVGLength2.h"
      48                 : #include "nsSVGString.h"
      49                 : #include "nsTArray.h"
      50                 : 
      51                 : class nsIContent;
      52                 : class nsINodeInfo;
      53                 : 
      54                 : #define NS_SVG_USE_ELEMENT_IMPL_CID \
      55                 : { 0x55fb86fe, 0xd81f, 0x4ae4, \
      56                 :   { 0x80, 0x3f, 0xeb, 0x90, 0xfe, 0xe0, 0x7a, 0xe9 } }
      57                 : 
      58                 : nsresult
      59                 : NS_NewSVGSVGElement(nsIContent **aResult,
      60                 :                     already_AddRefed<nsINodeInfo> aNodeInfo,
      61                 :                     mozilla::dom::FromParser aFromParser);
      62                 : 
      63                 : typedef nsSVGGraphicElement nsSVGUseElementBase;
      64                 : 
      65                 : class nsSVGUseElement : public nsSVGUseElementBase,
      66                 :                         public nsIDOMSVGUseElement,
      67                 :                         public DOMSVGTests,
      68                 :                         public nsIDOMSVGURIReference,
      69                 :                         public nsStubMutationObserver
      70                 : {
      71                 :   friend class nsSVGUseFrame;
      72                 : protected:
      73                 :   friend nsresult NS_NewSVGUseElement(nsIContent **aResult,
      74                 :                                       already_AddRefed<nsINodeInfo> aNodeInfo);
      75                 :   nsSVGUseElement(already_AddRefed<nsINodeInfo> aNodeInfo);
      76                 :   virtual ~nsSVGUseElement();
      77                 :   
      78                 : public:
      79                 :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_SVG_USE_ELEMENT_IMPL_CID)
      80                 : 
      81                 :   // interfaces:
      82                 :   
      83                 :   NS_DECL_ISUPPORTS_INHERITED
      84            1464 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGUseElement, nsSVGUseElementBase)
      85                 :   NS_DECL_NSIDOMSVGUSEELEMENT
      86                 :   NS_DECL_NSIDOMSVGURIREFERENCE
      87                 : 
      88                 :   NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
      89                 :   NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
      90                 :   NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
      91                 :   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
      92                 :   NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
      93                 :   NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
      94                 : 
      95                 :   // xxx I wish we could use virtual inheritance
      96               0 :   NS_FORWARD_NSIDOMNODE(nsSVGUseElementBase::)
      97               0 :   NS_FORWARD_NSIDOMELEMENT(nsSVGUseElementBase::)
      98               0 :   NS_FORWARD_NSIDOMSVGELEMENT(nsSVGUseElementBase::)
      99                 : 
     100                 :   // for nsSVGUseFrame's nsIAnonymousContentCreator implementation.
     101                 :   nsIContent* CreateAnonymousContent();
     102               0 :   nsIContent* GetAnonymousContent() const { return mClone; }
     103                 :   void DestroyAnonymousContent();
     104                 : 
     105                 :   // nsSVGElement specializations:
     106                 :   virtual gfxMatrix PrependLocalTransformsTo(const gfxMatrix &aMatrix,
     107                 :                       TransformTypes aWhich = eAllTransforms) const;
     108                 :   virtual bool HasValidDimensions() const;
     109                 : 
     110                 :   // nsIContent interface
     111                 :   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
     112                 :   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
     113                 : 
     114                 :   virtual nsXPCClassInfo* GetClassInfo();
     115                 : protected:
     116               0 :   class SourceReference : public nsReferencedElement {
     117                 :   public:
     118               0 :     SourceReference(nsSVGUseElement* aContainer) : mContainer(aContainer) {}
     119                 :   protected:
     120               0 :     virtual void ElementChanged(Element* aFrom, Element* aTo) {
     121               0 :       nsReferencedElement::ElementChanged(aFrom, aTo);
     122               0 :       if (aFrom) {
     123               0 :         aFrom->RemoveMutationObserver(mContainer);
     124                 :       }
     125               0 :       mContainer->TriggerReclone();
     126               0 :     }
     127                 :   private:
     128                 :     nsSVGUseElement* mContainer;
     129                 :   };
     130                 : 
     131                 :   virtual LengthAttributesInfo GetLengthInfo();
     132                 :   virtual StringAttributesInfo GetStringInfo();
     133                 : 
     134                 :   void SyncWidthOrHeight(nsIAtom *aName);
     135                 :   void LookupHref();
     136                 :   void TriggerReclone();
     137                 :   void UnlinkSource();
     138                 : 
     139                 :   enum { X, Y, WIDTH, HEIGHT };
     140                 :   nsSVGLength2 mLengthAttributes[4];
     141                 :   static LengthInfo sLengthInfo[4];
     142                 : 
     143                 :   enum { HREF };
     144                 :   nsSVGString mStringAttributes[1];
     145                 :   static StringInfo sStringInfo[1];
     146                 : 
     147                 :   nsCOMPtr<nsIContent> mOriginal; // if we've been cloned, our "real" copy
     148                 :   nsCOMPtr<nsIContent> mClone;    // cloned tree
     149                 :   SourceReference      mSource;   // observed element
     150                 : };
     151                 : 
     152                 : NS_DEFINE_STATIC_IID_ACCESSOR(nsSVGUseElement, NS_SVG_USE_ELEMENT_IMPL_CID)
     153                 : 
     154                 : #endif

Generated by: LCOV version 1.7