LCOV - code coverage report
Current view: top level - dom/xul/templates - nsXULTemplateQueryProcessorXML.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 25 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 18 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             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef nsXULTemplateQueryProcessorXML_h__
       7             : #define nsXULTemplateQueryProcessorXML_h__
       8             : 
       9             : #include "nsIXULTemplateBuilder.h"
      10             : #include "nsIXULTemplateQueryProcessor.h"
      11             : 
      12             : #include "nsAutoPtr.h"
      13             : #include "nsISimpleEnumerator.h"
      14             : #include "nsString.h"
      15             : #include "nsCOMArray.h"
      16             : #include "nsRefPtrHashtable.h"
      17             : #include "nsIDOMEventListener.h"
      18             : #include "nsIDOMXPathEvaluator.h"
      19             : #include "nsXMLBinding.h"
      20             : #include "nsCycleCollectionParticipant.h"
      21             : #include "nsIXMLHttpRequest.h"
      22             : #include "mozilla/Attributes.h"
      23             : #include "mozilla/dom/Element.h"
      24             : #include "mozilla/dom/XPathEvaluator.h"
      25             : #include "mozilla/dom/XPathResult.h"
      26             : 
      27             : class nsXULTemplateQueryProcessorXML;
      28             : 
      29             : #define NS_IXMLQUERY_IID \
      30             :   {0x0358d692, 0xccce, 0x4a97, \
      31             :     { 0xb2, 0x51, 0xba, 0x8f, 0x17, 0x0f, 0x3b, 0x6f }}
      32             : 
      33             : class nsXMLQuery final : public nsISupports
      34             : {
      35             :   public:
      36             :     NS_DECLARE_STATIC_IID_ACCESSOR(NS_IXMLQUERY_IID)
      37             : 
      38             :     NS_DECL_ISUPPORTS
      39             : 
      40             :     // return a weak reference to the processor the query was created from
      41           0 :     nsXULTemplateQueryProcessorXML* Processor() { return mProcessor; }
      42             : 
      43             :     // return a weak reference t the member variable for the query
      44           0 :     nsIAtom* GetMemberVariable() { return mMemberVariable; }
      45             : 
      46             :     // return a weak reference to the expression used to generate results
      47           0 :     mozilla::dom::XPathExpression* GetResultsExpression()
      48           0 :       { return mResultsExpr; }
      49             : 
      50             :     // return a weak reference to the additional required bindings
      51           0 :     nsXMLBindingSet* GetBindingSet() { return mRequiredBindings; }
      52             : 
      53             :     // add a required binding for the query
      54             :     void
      55           0 :     AddBinding(nsIAtom* aVar, nsAutoPtr<mozilla::dom::XPathExpression>&& aExpr)
      56             :     {
      57           0 :         if (!mRequiredBindings) {
      58           0 :             mRequiredBindings = new nsXMLBindingSet();
      59             :         }
      60             : 
      61           0 :         mRequiredBindings->AddBinding(aVar, mozilla::Move(aExpr));
      62           0 :     }
      63             : 
      64           0 :     nsXMLQuery(nsXULTemplateQueryProcessorXML* aProcessor,
      65             :                nsIAtom* aMemberVariable,
      66             :                nsAutoPtr<mozilla::dom::XPathExpression>&& aResultsExpr)
      67           0 :         : mProcessor(aProcessor),
      68             :           mMemberVariable(aMemberVariable),
      69           0 :           mResultsExpr(aResultsExpr)
      70           0 :     { }
      71             : 
      72             :   protected:
      73           0 :     ~nsXMLQuery() {}
      74             : 
      75             :     nsXULTemplateQueryProcessorXML* mProcessor;
      76             : 
      77             :     nsCOMPtr<nsIAtom> mMemberVariable;
      78             : 
      79             :     nsAutoPtr<mozilla::dom::XPathExpression> mResultsExpr;
      80             : 
      81             :     RefPtr<nsXMLBindingSet> mRequiredBindings;
      82             : };
      83             : 
      84             : NS_DEFINE_STATIC_IID_ACCESSOR(nsXMLQuery, NS_IXMLQUERY_IID)
      85             : 
      86             : class nsXULTemplateResultSetXML final : public nsISimpleEnumerator
      87             : {
      88             : private:
      89             : 
      90             :     // reference back to the query
      91             :     nsCOMPtr<nsXMLQuery> mQuery;
      92             : 
      93             :     // the binding set created from <assign> nodes
      94             :     RefPtr<nsXMLBindingSet> mBindingSet;
      95             : 
      96             :     // set of results contained in this enumerator
      97             :     RefPtr<mozilla::dom::XPathResult> mResults;
      98             : 
      99             :     // current position within the list of results
     100             :     uint32_t mPosition;
     101             : 
     102           0 :     ~nsXULTemplateResultSetXML() {}
     103             : 
     104             : public:
     105             : 
     106             :     // nsISupports interface
     107             :     NS_DECL_ISUPPORTS
     108             : 
     109             :     // nsISimpleEnumerator interface
     110             :     NS_DECL_NSISIMPLEENUMERATOR
     111             : 
     112           0 :     nsXULTemplateResultSetXML(nsXMLQuery* aQuery,
     113             :                               already_AddRefed<mozilla::dom::XPathResult> aResults,
     114             :                               nsXMLBindingSet* aBindingSet)
     115           0 :         : mQuery(aQuery),
     116             :           mBindingSet(aBindingSet),
     117             :           mResults(aResults),
     118           0 :           mPosition(0)
     119           0 :     {}
     120             : };
     121             : 
     122             : class nsXULTemplateQueryProcessorXML final : public nsIXULTemplateQueryProcessor,
     123             :                                              public nsIDOMEventListener
     124             : {
     125             : public:
     126             : 
     127           0 :     nsXULTemplateQueryProcessorXML()
     128           0 :         : mGenerationStarted(false)
     129           0 :     {}
     130             : 
     131             :     // nsISupports interface
     132             :     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     133           0 :     NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsXULTemplateQueryProcessorXML,
     134             :                                              nsIXULTemplateQueryProcessor)
     135             : 
     136             :     // nsIXULTemplateQueryProcessor interface
     137             :     NS_DECL_NSIXULTEMPLATEQUERYPROCESSOR
     138             : 
     139             :     // nsIDOMEventListener interface
     140             :     NS_DECL_NSIDOMEVENTLISTENER
     141             : 
     142             :     nsXMLBindingSet*
     143             :     GetOptionalBindingsForRule(nsIDOMNode* aRuleNode);
     144             : 
     145             :     // create an XPath expression from aExpr, using aNode for
     146             :     // resolving namespaces
     147             :     mozilla::dom::XPathExpression*
     148             :     CreateExpression(const nsAString& aExpr,
     149             :                      nsINode* aNode,
     150             :                      mozilla::ErrorResult& aRv);
     151             : 
     152             : private:
     153             : 
     154           0 :     ~nsXULTemplateQueryProcessorXML() {}
     155             : 
     156             :     bool mGenerationStarted;
     157             : 
     158             :     nsRefPtrHashtable<nsISupportsHashKey, nsXMLBindingSet> mRuleToBindingsMap;
     159             : 
     160             :     nsCOMPtr<mozilla::dom::Element> mRoot;
     161             : 
     162             :     RefPtr<mozilla::dom::XPathEvaluator> mEvaluator;
     163             : 
     164             :     nsCOMPtr<nsIXULTemplateBuilder> mTemplateBuilder;
     165             : 
     166             :     nsCOMPtr<nsIXMLHttpRequest> mRequest;
     167             : };
     168             : 
     169             : 
     170             : #endif // nsXULTemplateQueryProcessorXML_h__

Generated by: LCOV version 1.13