LCOV - code coverage report
Current view: directory - content/xslt/src/xpath - nsXPathResult.h (source / functions) Found Hit Coverage
Test: app.info Lines: 15 13 86.7 %
Date: 2012-06-02 Functions: 12 11 91.7 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       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 TransforMiiX XSLT processor 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) 2001
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Peter Van der Beken <peterv@propagandism.org>
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef nsXPathResult_h__
      40                 : #define nsXPathResult_h__
      41                 : 
      42                 : #include "txExprResult.h"
      43                 : #include "nsIDOMXPathResult.h"
      44                 : #include "nsIDocument.h"
      45                 : #include "nsStubMutationObserver.h"
      46                 : #include "nsCOMPtr.h"
      47                 : #include "nsCOMArray.h"
      48                 : #include "nsWeakPtr.h"
      49                 : #include "nsCycleCollectionParticipant.h"
      50                 : 
      51                 : // {662f2c9a-c7cd-4cab-9349-e733df5a838c}
      52                 : #define NS_IXPATHRESULT_IID \
      53                 : { 0x662f2c9a, 0xc7cd, 0x4cab, {0x93, 0x49, 0xe7, 0x33, 0xdf, 0x5a, 0x83, 0x8c }}
      54                 : 
      55                 : class nsIXPathResult : public nsISupports
      56              42 : {
      57                 : public:
      58                 :     NS_DECLARE_STATIC_IID_ACCESSOR(NS_IXPATHRESULT_IID)
      59                 :     virtual nsresult SetExprResult(txAExprResult *aExprResult,
      60                 :                                    PRUint16 aResultType,
      61                 :                                    nsINode* aContextNode) = 0;
      62                 :     virtual nsresult GetExprResult(txAExprResult **aExprResult) = 0;
      63                 :     virtual nsresult Clone(nsIXPathResult **aResult) = 0;
      64                 : };
      65                 : 
      66                 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIXPathResult, NS_IXPATHRESULT_IID)
      67                 : 
      68                 : /**
      69                 :  * A class for evaluating an XPath expression string
      70                 :  */
      71                 : class nsXPathResult : public nsIDOMXPathResult,
      72                 :                       public nsStubMutationObserver,
      73                 :                       public nsIXPathResult
      74                 : {
      75                 : public:
      76                 :     nsXPathResult();
      77                 :     nsXPathResult(const nsXPathResult &aResult);
      78                 :     ~nsXPathResult();
      79                 : 
      80                 :     // nsISupports interface
      81              26 :     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      82            2228 :     NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsXPathResult, nsIDOMXPathResult)
      83                 : 
      84                 :     // nsIDOMXPathResult interface
      85                 :     NS_DECL_NSIDOMXPATHRESULT
      86                 : 
      87                 :     // nsIMutationObserver interface
      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                 :     // nsIXPathResult interface
      96                 :     nsresult SetExprResult(txAExprResult *aExprResult, PRUint16 aResultType,
      97                 :                            nsINode* aContextNode);
      98                 :     nsresult GetExprResult(txAExprResult **aExprResult);
      99                 :     nsresult Clone(nsIXPathResult **aResult);
     100                 :     void RemoveObserver();
     101                 : private:
     102              42 :     static bool isSnapshot(PRUint16 aResultType)
     103                 :     {
     104                 :         return aResultType == UNORDERED_NODE_SNAPSHOT_TYPE ||
     105              42 :                aResultType == ORDERED_NODE_SNAPSHOT_TYPE;
     106                 :     }
     107              84 :     static bool isIterator(PRUint16 aResultType)
     108                 :     {
     109                 :         return aResultType == UNORDERED_NODE_ITERATOR_TYPE ||
     110              84 :                aResultType == ORDERED_NODE_ITERATOR_TYPE;
     111                 :     }
     112              84 :     static bool isNode(PRUint16 aResultType)
     113                 :     {
     114                 :         return aResultType == FIRST_ORDERED_NODE_TYPE ||
     115              84 :                aResultType == ANY_UNORDERED_NODE_TYPE;
     116                 :     }
     117               0 :     bool isSnapshot() const
     118                 :     {
     119               0 :         return isSnapshot(mResultType);
     120                 :     }
     121              42 :     bool isIterator() const
     122                 :     {
     123              42 :         return isIterator(mResultType);
     124                 :     }
     125              42 :     bool isNode() const
     126                 :     {
     127              42 :         return isNode(mResultType);
     128                 :     }
     129                 : 
     130                 :     void Invalidate(const nsIContent* aChangeRoot);
     131                 : 
     132                 :     nsRefPtr<txAExprResult> mResult;
     133                 :     nsCOMArray<nsIDOMNode> mResultNodes;
     134                 :     nsCOMPtr<nsIDocument> mDocument;
     135                 :     PRUint32 mCurrentPos;
     136                 :     PRUint16 mResultType;
     137                 :     nsWeakPtr mContextNode;
     138                 :     bool mInvalidIteratorState;
     139                 :     bool mBooleanResult;
     140                 :     double mNumberResult;
     141                 :     nsString mStringResult;
     142                 : };
     143                 : 
     144                 : #endif

Generated by: LCOV version 1.7