LCOV - app.info - content/base/src/nsNodeInfoManager.h

LCOV - code coverage report
| Current view: | directory - content/base/src - nsNodeInfoManager.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 5 | 1 | 20.0 %
| Date: | 2012-07-07 | Functions: | 4 | 1 | 25.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 mozilla.org code.
          16                 :  *
          17                 :  * The Initial Developer of the Original Code is
          18                 :  * Netscape Communications Corporation.
          19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
          20                 :  * the Initial Developer. All Rights Reserved.
          21                 :  *
          22                 :  * Contributor(s):
          23                 :  *
          24                 :  * Alternatively, the contents of this file may be used under the terms of
          25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
          26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          28                 :  * of those above. If you wish to allow use of your version of this file only
          29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          30                 :  * use your version of this file under the terms of the MPL, indicate your
          31                 :  * decision by deleting the provisions above and replace them with the notice
          32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          33                 :  * the provisions above, a recipient may use your version of this file under
          34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          35                 :  *
          36                 :  * ***** END LICENSE BLOCK ***** */
          37                 :
          38                 : /*
          39                 :  * A class for handing out nodeinfos and ensuring sharing of them as needed.
          40                 :  */
          41                 :
          42                 : #ifndef nsNodeInfoManager_h___
          43                 : #define nsNodeInfoManager_h___
          44                 :
          45                 : #include "nsCOMPtr.h" // for already_AddRefed
          46                 : #include "plhash.h"
          47                 : #include "nsCycleCollectionParticipant.h"
          48                 :
          49                 : class nsIAtom;
          50                 : class nsIDocument;
          51                 : class nsINodeInfo;
          52                 : class nsNodeInfo;
          53                 : class nsIPrincipal;
          54                 : class nsIURI;
          55                 : class nsDocument;
          56                 : class nsIDOMDocumentType;
          57                 : class nsIDOMDocument;
          58                 : class nsAString;
          59                 : class nsIDOMNamedNodeMap;
          60                 : class nsXULPrototypeDocument;
          61                 : class nsBindingManager;
          62                 :
          63                 : class nsNodeInfoManager
          64                 : {
          65                 : public:
          66                 :   nsNodeInfoManager();
          67                 :   ~nsNodeInfoManager();
          68                 :
          69            1464 :   NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsNodeInfoManager)
          70                 :
          71               0 :   NS_INLINE_DECL_REFCOUNTING(nsNodeInfoManager)
          72                 :
          73                 :   /**
          74                 :    * Initialize the nodeinfo manager with a document.
          75                 :    */
          76                 :   nsresult Init(nsIDocument *aDocument);
          77                 :
          78                 :   /**
          79                 :    * Release the reference to the document, this will be called when
          80                 :    * the document is going away.
          81                 :    */
          82                 :   void DropDocumentReference();
          83                 :
          84                 :   /**
          85                 :    * Methods for creating nodeinfo's from atoms and/or strings.
          86                 :    */
          87                 :   already_AddRefed<nsINodeInfo> GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix,
          88                 :                                             PRInt32 aNamespaceID,
          89                 :                                             PRUint16 aNodeType,
          90                 :                                             nsIAtom* aExtraName = nsnull);
          91                 :   nsresult GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
          92                 :                        PRInt32 aNamespaceID, PRUint16 aNodeType,
          93                 :                        nsINodeInfo** aNodeInfo);
          94                 :   nsresult GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
          95                 :                        const nsAString& aNamespaceURI, PRUint16 aNodeType,
          96                 :                        nsINodeInfo** aNodeInfo);
          97                 :
          98                 :   /**
          99                 :    * Returns the nodeinfo for text nodes. Can return null if OOM.
         100                 :    */
         101                 :   already_AddRefed<nsINodeInfo> GetTextNodeInfo();
         102                 :
         103                 :   /**
         104                 :    * Returns the nodeinfo for comment nodes. Can return null if OOM.
         105                 :    */
         106                 :   already_AddRefed<nsINodeInfo> GetCommentNodeInfo();
         107                 :
         108                 :   /**
         109                 :    * Returns the nodeinfo for the document node. Can return null if OOM.
         110                 :    */
         111                 :   already_AddRefed<nsINodeInfo> GetDocumentNodeInfo();
         112                 :
         113                 :   /**
         114                 :    * Retrieve a pointer to the document that owns this node info
         115                 :    * manager.
         116                 :    */
         117                 :   nsIDocument* GetDocument() const
         118                 :   {
         119                 :     return mDocument;
         120                 :   }
         121                 :
         122                 :   /**
         123                 :    * Gets the principal of the document this nodeinfo manager belongs to.
         124                 :    */
         125               0 :   nsIPrincipal *DocumentPrincipal() const {
         126               0 :     NS_ASSERTION(mPrincipal, "How'd that happen?");
         127               0 :     return mPrincipal;
         128                 :   }
         129                 :
         130                 :   void RemoveNodeInfo(nsNodeInfo *aNodeInfo);
         131                 :
         132                 :   nsBindingManager* GetBindingManager() const
         133                 :   {
         134                 :     return mBindingManager;
         135                 :   }
         136                 :
         137                 : protected:
         138                 :   friend class nsDocument;
         139                 :   friend class nsXULPrototypeDocument;
         140                 :   friend nsresult NS_NewDOMDocumentType(nsIDOMDocumentType** ,
         141                 :                                         nsNodeInfoManager *,
         142                 :                                         nsIAtom *,
         143                 :                                         const nsAString& ,
         144                 :                                         const nsAString& ,
         145                 :                                         const nsAString& );
         146                 :
         147                 :   /**
         148                 :    * Sets the principal of the document this nodeinfo manager belongs to.
         149                 :    */
         150                 :   void SetDocumentPrincipal(nsIPrincipal *aPrincipal);
         151                 :
         152                 : private:
         153                 :   static PRIntn NodeInfoInnerKeyCompare(const void *key1, const void *key2);
         154                 :   static PLHashNumber GetNodeInfoInnerHashValue(const void *key);
         155                 :   static PRIntn DropNodeInfoDocument(PLHashEntry *he, PRIntn hashIndex,
         156                 :                                      void *arg);
         157                 :
         158                 :   PLHashTable *mNodeInfoHash;
         159                 :   nsIDocument *mDocument; // WEAK
         160                 :   PRUint32 mNonDocumentNodeInfos;
         161                 :   nsIPrincipal *mPrincipal; // STRONG, but not nsCOMPtr to avoid include hell
         162                 :                             // while inlining DocumentPrincipal().  Never null
         163                 :                             // after Init() succeeds.
         164                 :   nsCOMPtr<nsIPrincipal> mDefaultPrincipal; // Never null after Init() succeeds
         165                 :   nsINodeInfo *mTextNodeInfo; // WEAK to avoid circular ownership
         166                 :   nsINodeInfo *mCommentNodeInfo; // WEAK to avoid circular ownership
         167                 :   nsINodeInfo *mDocumentNodeInfo; // WEAK to avoid circular ownership
         168                 :   nsBindingManager* mBindingManager; // STRONG, but not nsCOMPtr to avoid
         169                 :                                      // include hell while inlining
         170                 :                                      // GetBindingManager().
         171                 : };
         172                 :
         173                 : #endif /* nsNodeInfoManager_h___ */

Generated by: LCOV version 1.7