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

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       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 nsXMLBinding_h__
       7             : #define nsXMLBinding_h__
       8             : 
       9             : #include "nsAutoPtr.h"
      10             : #include "nsIAtom.h"
      11             : #include "mozilla/Attributes.h"
      12             : #include "mozilla/dom/XPathExpression.h"
      13             : 
      14             : class nsINode;
      15             : class nsXULTemplateResultXML;
      16             : class nsXMLBindingValues;
      17             : namespace mozilla {
      18             : namespace dom {
      19             : class XPathResult;
      20             : } // namespace dom
      21             : } // namespace mozilla
      22             : 
      23             : /**
      24             :  * Classes related to storing bindings for XML handling.
      25             :  */
      26             : 
      27             : /**
      28             :  * a <binding> description
      29             :  */
      30             : struct nsXMLBinding {
      31             :   nsCOMPtr<nsIAtom> mVar;
      32             :   nsAutoPtr<mozilla::dom::XPathExpression> mExpr;
      33             : 
      34             :   nsAutoPtr<nsXMLBinding> mNext;
      35             : 
      36           0 :   nsXMLBinding(nsIAtom* aVar, nsAutoPtr<mozilla::dom::XPathExpression>&& aExpr)
      37           0 :     : mVar(aVar), mExpr(aExpr), mNext(nullptr)
      38             :   {
      39           0 :     MOZ_COUNT_CTOR(nsXMLBinding);
      40           0 :   }
      41             : 
      42           0 :   ~nsXMLBinding()
      43           0 :   {
      44           0 :     MOZ_COUNT_DTOR(nsXMLBinding);
      45           0 :   }
      46             : };
      47             : 
      48             : /**
      49             :  * a collection of <binding> descriptors. This object is refcounted by
      50             :  * nsXMLBindingValues objects and the query processor.
      51             :  */
      52           0 : class nsXMLBindingSet final
      53             : {
      54             :   ~nsXMLBindingSet();
      55             : 
      56             : public:
      57             :   // pointer to the first binding in a linked list
      58             :   nsAutoPtr<nsXMLBinding> mFirst;
      59             : 
      60           0 :   NS_INLINE_DECL_REFCOUNTING(nsXMLBindingSet);
      61             : 
      62             :   /**
      63             :    * Add a binding to the set
      64             :    */
      65             :   void
      66             :   AddBinding(nsIAtom* aVar, nsAutoPtr<mozilla::dom::XPathExpression>&& aExpr);
      67             : 
      68             :   /**
      69             :    * The nsXMLBindingValues class stores an array of values, one for each
      70             :    * target symbol that could be set by the bindings in the set.
      71             :    * LookupTargetIndex determines the index into the array for a given
      72             :    * target symbol.
      73             :    */
      74             :   int32_t
      75             :   LookupTargetIndex(nsIAtom* aTargetVariable, nsXMLBinding** aBinding);
      76             : };
      77             : 
      78             : /**
      79             :  * a set of values of bindings. This object is used once per result.
      80             :  */
      81             : class nsXMLBindingValues
      82             : {
      83             : protected:
      84             : 
      85             :   // the binding set
      86             :   RefPtr<nsXMLBindingSet> mBindings;
      87             : 
      88             :   /**
      89             :    * A set of values for variable bindings. To look up a binding value,
      90             :    * scan through the binding set in mBindings for the right target atom.
      91             :    * Its index will correspond to the index in this array.
      92             :    */
      93             :   nsTArray<RefPtr<mozilla::dom::XPathResult> > mValues;
      94             : 
      95             : public:
      96             : 
      97           0 :   nsXMLBindingValues() { MOZ_COUNT_CTOR(nsXMLBindingValues); }
      98           0 :   ~nsXMLBindingValues() { MOZ_COUNT_DTOR(nsXMLBindingValues); }
      99             : 
     100             :   nsXMLBindingSet* GetBindingSet() { return mBindings; }
     101             : 
     102           0 :   void SetBindingSet(nsXMLBindingSet* aBindings) { mBindings = aBindings; }
     103             : 
     104             :   int32_t
     105           0 :   LookupTargetIndex(nsIAtom* aTargetVariable, nsXMLBinding** aBinding)
     106             :   {
     107           0 :     return mBindings ?
     108           0 :            mBindings->LookupTargetIndex(aTargetVariable, aBinding) : -1;
     109             :   }
     110             : 
     111             :   /**
     112             :    * Retrieve the assignment for a particular variable
     113             :    *
     114             :    * aResult the result generated from the template
     115             :    * aBinding the binding looked up using LookupTargetIndex
     116             :    * aIndex the index of the assignment to retrieve
     117             :    * aType the type of result expected
     118             :    */
     119             :   mozilla::dom::XPathResult*
     120             :   GetAssignmentFor(nsXULTemplateResultXML* aResult,
     121             :                    nsXMLBinding* aBinding,
     122             :                    int32_t idx,
     123             :                    uint16_t type);
     124             : 
     125             :   nsINode*
     126             :   GetNodeAssignmentFor(nsXULTemplateResultXML* aResult,
     127             :                        nsXMLBinding* aBinding,
     128             :                        int32_t idx);
     129             : 
     130             :   void
     131             :   GetStringAssignmentFor(nsXULTemplateResultXML* aResult,
     132             :                          nsXMLBinding* aBinding,
     133             :                          int32_t idx,
     134             :                          nsAString& aValue);
     135             : };
     136             : 
     137             : #endif // nsXMLBinding_h__

Generated by: LCOV version 1.13