LCOV - code coverage report
Current view: directory - content/base/src - nsDocumentFragment.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 40 26 65.0 %
Date: 2012-06-02 Functions: 52 13 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                 :  * Implementation of DOM Core's nsIDOMDocumentFragment.
      40                 :  */
      41                 : 
      42                 : #include "nsISupports.h"
      43                 : #include "nsIContent.h"
      44                 : #include "nsIDOMDocumentFragment.h"
      45                 : #include "nsGenericElement.h"
      46                 : #include "nsINameSpaceManager.h"
      47                 : #include "nsINodeInfo.h"
      48                 : #include "nsNodeInfoManager.h"
      49                 : #include "nsIDocument.h"
      50                 : #include "nsIDOMDocument.h"
      51                 : #include "nsIDOMAttr.h"
      52                 : #include "nsDOMError.h"
      53                 : #include "nsGkAtoms.h"
      54                 : #include "nsDOMString.h"
      55                 : #include "nsIDOMUserDataHandler.h"
      56                 : 
      57                 : class nsDocumentFragment : public nsGenericElement,
      58                 :                            public nsIDOMDocumentFragment
      59                 : {
      60                 : public:
      61                 :   // nsISupports
      62                 :   NS_DECL_ISUPPORTS_INHERITED
      63                 : 
      64                 :   // interface nsIDOMNode
      65             171 :   NS_FORWARD_NSIDOMNODE(nsGenericElement::)
      66                 : 
      67                 :   // interface nsIDOMDocumentFragment
      68                 :   // NS_DECL_NSIDOCUMENTFRAGMENT  Empty
      69                 : 
      70                 :   nsDocumentFragment(already_AddRefed<nsINodeInfo> aNodeInfo);
      71             136 :   virtual ~nsDocumentFragment()
      72              68 :   {
      73             272 :   }
      74                 : 
      75                 :   // nsIContent
      76                 :   nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
      77                 :                    const nsAString& aValue, bool aNotify)
      78                 :   {
      79                 :     return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
      80                 :   }
      81               0 :   virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
      82                 :                            nsIAtom* aPrefix, const nsAString& aValue,
      83                 :                            bool aNotify)
      84                 :   {
      85               0 :     return NS_OK;
      86                 :   }
      87               0 :   virtual bool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, 
      88                 :                          nsAString& aResult) const
      89                 :   {
      90               0 :     return false;
      91                 :   }
      92               0 :   virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, 
      93                 :                              bool aNotify)
      94                 :   {
      95               0 :     return NS_OK;
      96                 :   }
      97               0 :   virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const
      98                 :   {
      99               0 :     return nsnull;
     100                 :   }
     101                 : 
     102                 :   virtual bool IsNodeOfType(PRUint32 aFlags) const;
     103                 : 
     104                 :   virtual nsXPCClassInfo* GetClassInfo();
     105                 : 
     106                 :   virtual nsIAtom* DoGetID() const;
     107                 :   virtual nsIAtom *GetIDAttributeName() const;
     108                 : 
     109                 : protected:
     110                 :   nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
     111                 : };
     112                 : 
     113                 : nsresult
     114              68 : NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
     115                 :                        nsNodeInfoManager *aNodeInfoManager)
     116                 : {
     117              68 :   NS_ENSURE_ARG(aNodeInfoManager);
     118                 : 
     119             136 :   nsCOMPtr<nsINodeInfo> nodeInfo;
     120                 :   nodeInfo = aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentFragmentNodeName,
     121                 :                                            nsnull, kNameSpaceID_None,
     122              68 :                                            nsIDOMNode::DOCUMENT_FRAGMENT_NODE);
     123              68 :   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
     124                 : 
     125             136 :   nsDocumentFragment *it = new nsDocumentFragment(nodeInfo.forget());
     126              68 :   if (!it) {
     127               0 :     return NS_ERROR_OUT_OF_MEMORY;
     128                 :   }
     129                 : 
     130              68 :   NS_ADDREF(*aInstancePtrResult = it);
     131                 : 
     132              68 :   return NS_OK;
     133                 : }
     134                 : 
     135              68 : nsDocumentFragment::nsDocumentFragment(already_AddRefed<nsINodeInfo> aNodeInfo)
     136              68 :   : nsGenericElement(aNodeInfo)
     137                 : {
     138              68 :   ClearIsElement();
     139              68 : }
     140                 : 
     141                 : bool
     142            1977 : nsDocumentFragment::IsNodeOfType(PRUint32 aFlags) const
     143                 : {
     144            1977 :   return !(aFlags & ~(eCONTENT | eDOCUMENT_FRAGMENT));
     145                 : }
     146                 : 
     147                 : nsIAtom*
     148               0 : nsDocumentFragment::DoGetID() const
     149                 : {
     150               0 :   return nsnull;  
     151                 : }
     152                 : 
     153                 : nsIAtom*
     154               0 : nsDocumentFragment::GetIDAttributeName() const
     155                 : {
     156               0 :   return nsnull;
     157                 : }
     158                 : 
     159              67 : DOMCI_NODE_DATA(DocumentFragment, nsDocumentFragment)
     160                 : 
     161                 : // QueryInterface implementation for nsDocumentFragment
     162            3797 : NS_INTERFACE_TABLE_HEAD(nsDocumentFragment)
     163            3797 :   NS_NODE_INTERFACE_TABLE2(nsDocumentFragment, nsIDOMNode,
     164                 :                            nsIDOMDocumentFragment)
     165            2391 :   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DocumentFragment)
     166            2390 : NS_INTERFACE_MAP_END_INHERITING(nsGenericElement)
     167                 : 
     168                 : 
     169            2305 : NS_IMPL_ADDREF_INHERITED(nsDocumentFragment, nsGenericElement)
     170            2305 : NS_IMPL_RELEASE_INHERITED(nsDocumentFragment, nsGenericElement)
     171                 : 
     172               0 : NS_IMPL_ELEMENT_CLONE(nsDocumentFragment)

Generated by: LCOV version 1.7