LCOV - code coverage report
Current view: top level - dom/base - TreeWalker.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 16 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /* vim: set ts=4 et sw=4 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             : /*
       8             :  * Implementation of DOM Traversal's nsIDOMTreeWalker
       9             :  */
      10             : 
      11             : #ifndef mozilla_dom_TreeWalker_h
      12             : #define mozilla_dom_TreeWalker_h
      13             : 
      14             : #include "nsIDOMTreeWalker.h"
      15             : #include "nsTraversal.h"
      16             : #include "nsCOMPtr.h"
      17             : #include "nsTArray.h"
      18             : #include "nsCycleCollectionParticipant.h"
      19             : 
      20             : class nsINode;
      21             : class nsIDOMNode;
      22             : 
      23             : namespace mozilla {
      24             : namespace dom {
      25             : 
      26             : class TreeWalker final : public nsIDOMTreeWalker, public nsTraversal
      27             : {
      28             :     virtual ~TreeWalker();
      29             : 
      30             : public:
      31             :     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      32             :     NS_DECL_NSIDOMTREEWALKER
      33             : 
      34             :     TreeWalker(nsINode *aRoot,
      35             :                uint32_t aWhatToShow,
      36             :                NodeFilterHolder aFilter);
      37             : 
      38           0 :     NS_DECL_CYCLE_COLLECTION_CLASS(TreeWalker)
      39             : 
      40             :     // WebIDL API
      41           0 :     nsINode* Root() const
      42             :     {
      43           0 :         return mRoot;
      44             :     }
      45           0 :     uint32_t WhatToShow() const
      46             :     {
      47           0 :         return mWhatToShow;
      48             :     }
      49           0 :     already_AddRefed<NodeFilter> GetFilter()
      50             :     {
      51           0 :         return mFilter.ToWebIDLCallback();
      52             :     }
      53           0 :     nsINode* CurrentNode() const
      54             :     {
      55           0 :         return mCurrentNode;
      56             :     }
      57             :     void SetCurrentNode(nsINode& aNode, ErrorResult& aResult);
      58             :     // All our traversal methods return strong refs because filtering can
      59             :     // remove nodes from the tree.
      60             :     already_AddRefed<nsINode> ParentNode(ErrorResult& aResult);
      61             :     already_AddRefed<nsINode> FirstChild(ErrorResult& aResult);
      62             :     already_AddRefed<nsINode> LastChild(ErrorResult& aResult);
      63             :     already_AddRefed<nsINode> PreviousSibling(ErrorResult& aResult);
      64             :     already_AddRefed<nsINode> NextSibling(ErrorResult& aResult);
      65             :     already_AddRefed<nsINode> PreviousNode(ErrorResult& aResult);
      66             :     already_AddRefed<nsINode> NextNode(ErrorResult& aResult);
      67             : 
      68             :     bool WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
      69             : 
      70             : private:
      71             :     nsCOMPtr<nsINode> mCurrentNode;
      72             : 
      73             :     /*
      74             :      * Implements FirstChild and LastChild which only vary in which direction
      75             :      * they search.
      76             :      * @param aReversed Controls whether we search forwards or backwards
      77             :      * @param aResult   Whether we threw or not.
      78             :      * @returns         The desired node. Null if no child is found
      79             :      */
      80             :     already_AddRefed<nsINode> FirstChildInternal(bool aReversed,
      81             :                                                  ErrorResult& aResult);
      82             : 
      83             :     /*
      84             :      * Implements NextSibling and PreviousSibling which only vary in which
      85             :      * direction they search.
      86             :      * @param aReversed Controls whether we search forwards or backwards
      87             :      * @param aResult   Whether we threw or not.
      88             :      * @returns         The desired node. Null if no child is found
      89             :      */
      90             :     already_AddRefed<nsINode> NextSiblingInternal(bool aReversed,
      91             :                                                   ErrorResult& aResult);
      92             : 
      93             :     // Implementation for our various XPCOM getters
      94             :     typedef already_AddRefed<nsINode> (TreeWalker::*NodeGetter)(ErrorResult&);
      95           0 :     inline nsresult ImplNodeGetter(NodeGetter aGetter, nsIDOMNode** aRetval)
      96             :     {
      97           0 :         mozilla::ErrorResult rv;
      98           0 :         nsCOMPtr<nsINode> node = (this->*aGetter)(rv);
      99           0 :         if (rv.Failed()) {
     100           0 :             return rv.StealNSResult();
     101             :         }
     102           0 :         *aRetval = node ? node.forget().take()->AsDOMNode() : nullptr;
     103           0 :         return NS_OK;
     104             :     }
     105             : };
     106             : 
     107             : } // namespace dom
     108             : } // namespace mozilla
     109             : 
     110             : #endif // mozilla_dom_TreeWalker_h
     111             : 

Generated by: LCOV version 1.13