content/xul/templates/src/nsXMLBinding.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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/. */
     6 #ifndef nsXMLBinding_h__
     7 #define nsXMLBinding_h__
     9 #include "nsAutoPtr.h"
    10 #include "nsIAtom.h"
    11 #include "nsCycleCollectionParticipant.h"
    12 #include "mozilla/Attributes.h"
    14 class nsXULTemplateResultXML;
    15 class nsXMLBindingValues;
    17 /**
    18  * Classes related to storing bindings for XML handling.
    19  */
    21 /**
    22  * a <binding> description
    23  */
    24 struct nsXMLBinding {
    25   nsCOMPtr<nsIAtom> mVar;
    26   nsCOMPtr<nsIDOMXPathExpression> mExpr;
    28   nsAutoPtr<nsXMLBinding> mNext;
    30   nsXMLBinding(nsIAtom* aVar, nsIDOMXPathExpression* aExpr)
    31     : mVar(aVar), mExpr(aExpr), mNext(nullptr)
    32   {
    33     MOZ_COUNT_CTOR(nsXMLBinding);
    34   }
    36   ~nsXMLBinding()
    37   {
    38     MOZ_COUNT_DTOR(nsXMLBinding);
    39   }
    40 };
    42 /**
    43  * a collection of <binding> descriptors. This object is refcounted by
    44  * nsXMLBindingValues objects and the query processor.
    45  */
    46 class nsXMLBindingSet MOZ_FINAL
    47 {
    48 public:
    50   // results hold a reference to a binding set in their
    51   // nsXMLBindingValues fields
    52   nsCycleCollectingAutoRefCnt mRefCnt;
    54   // pointer to the first binding in a linked list
    55   nsAutoPtr<nsXMLBinding> mFirst;
    57 public:
    59   NS_METHOD_(MozExternalRefCountType) AddRef();
    60   NS_METHOD_(MozExternalRefCountType) Release();
    61   NS_DECL_OWNINGTHREAD
    62   NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsXMLBindingSet)
    64   /**
    65    * Add a binding to the set
    66    */
    67   nsresult
    68   AddBinding(nsIAtom* aVar, nsIDOMXPathExpression* aExpr);
    70   /**
    71    * The nsXMLBindingValues class stores an array of values, one for each
    72    * target symbol that could be set by the bindings in the set.
    73    * LookupTargetIndex determines the index into the array for a given
    74    * target symbol.
    75    */
    76   int32_t
    77   LookupTargetIndex(nsIAtom* aTargetVariable, nsXMLBinding** aBinding);
    78 };
    80 /**
    81  * a set of values of bindings. This object is used once per result.
    82  */
    83 class nsXMLBindingValues
    84 {
    85 protected:
    87   // the binding set
    88   nsRefPtr<nsXMLBindingSet> mBindings;
    90   /**
    91    * A set of values for variable bindings. To look up a binding value,
    92    * scan through the binding set in mBindings for the right target atom.
    93    * Its index will correspond to the index in this array.
    94    */
    95   nsCOMArray<nsIDOMXPathResult> mValues;
    97 public:
    99   nsXMLBindingValues() { MOZ_COUNT_CTOR(nsXMLBindingValues); }
   100   ~nsXMLBindingValues() { MOZ_COUNT_DTOR(nsXMLBindingValues); }
   102   nsXMLBindingSet* GetBindingSet() { return mBindings; }
   104   void SetBindingSet(nsXMLBindingSet* aBindings) { mBindings = aBindings; }
   106   int32_t
   107   LookupTargetIndex(nsIAtom* aTargetVariable, nsXMLBinding** aBinding)
   108   {
   109     return mBindings ?
   110            mBindings->LookupTargetIndex(aTargetVariable, aBinding) : -1;
   111   }
   113   /**
   114    * Retrieve the assignment for a particular variable
   115    *
   116    * aResult the result generated from the template
   117    * aBinding the binding looked up using LookupTargetIndex
   118    * aIndex the index of the assignment to retrieve
   119    * aType the type of result expected
   120    * aValue the value of the assignment
   121    */
   122   void
   123   GetAssignmentFor(nsXULTemplateResultXML* aResult,
   124                    nsXMLBinding* aBinding,
   125                    int32_t idx,
   126                    uint16_t type,
   127                    nsIDOMXPathResult** aValue);
   129   void
   130   GetNodeAssignmentFor(nsXULTemplateResultXML* aResult,
   131                        nsXMLBinding* aBinding,
   132                        int32_t idx,
   133                        nsIDOMNode** aValue);
   135   void
   136   GetStringAssignmentFor(nsXULTemplateResultXML* aResult,
   137                          nsXMLBinding* aBinding,
   138                          int32_t idx,
   139                          nsAString& aValue);
   140 };
   142 #endif // nsXMLBinding_h__

mercurial