LCOV - code coverage report
Current view: top level - dom/base - nsChildContentList.h (source / functions) Hit Total Coverage
Test: output.info Lines: 6 10 60.0 %
Date: 2017-07-14 16:53:18 Functions: 6 11 54.5 %
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 nsChildContentList_h__
       8             : #define nsChildContentList_h__
       9             : 
      10             : #include "nsISupportsImpl.h"
      11             : #include "nsINodeList.h"            // base class
      12             : #include "js/TypeDecls.h"     // for Handle, Value, JSObject, JSContext
      13             : 
      14             : class nsIContent;
      15             : class nsINode;
      16             : 
      17             : /**
      18             :  * Class that implements the nsIDOMNodeList interface (a list of children of
      19             :  * the content), by holding a reference to the content and delegating GetLength
      20             :  * and Item to its existing child list.
      21             :  * @see nsIDOMNodeList
      22             :  */
      23             : class nsChildContentList final : public nsINodeList
      24             : {
      25             : public:
      26          10 :   explicit nsChildContentList(nsINode* aNode)
      27          10 :     : mNode(aNode)
      28             :   {
      29          10 :   }
      30             : 
      31             :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      32         164 :   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(nsChildContentList)
      33             : 
      34             :   // nsWrapperCache
      35             :   virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
      36             : 
      37             :   // nsIDOMNodeList interface
      38             :   NS_DECL_NSIDOMNODELIST
      39             : 
      40             :   // nsINodeList interface
      41             :   virtual int32_t IndexOf(nsIContent* aContent) override;
      42             :   virtual nsIContent* Item(uint32_t aIndex) override;
      43             : 
      44           0 :   void DropReference()
      45             :   {
      46           0 :     mNode = nullptr;
      47           0 :   }
      48             : 
      49           8 :   virtual nsINode* GetParentObject() override
      50             :   {
      51           8 :     return mNode;
      52             :   }
      53             : 
      54             : private:
      55           0 :   ~nsChildContentList() {}
      56             : 
      57             :   // The node whose children make up the list.
      58             :   // This is a non-owning ref which is safe because it's set to nullptr by
      59             :   // DropReference() by the node slots get destroyed.
      60             :   nsINode* MOZ_NON_OWNING_REF mNode;
      61             : };
      62             : 
      63             : #endif /* nsChildContentList_h__ */

Generated by: LCOV version 1.13