Sat, 03 Jan 2015 20:18:00 +0100
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.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsXMLBinding_h__ |
michael@0 | 7 | #define nsXMLBinding_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsAutoPtr.h" |
michael@0 | 10 | #include "nsIAtom.h" |
michael@0 | 11 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 12 | #include "mozilla/Attributes.h" |
michael@0 | 13 | |
michael@0 | 14 | class nsXULTemplateResultXML; |
michael@0 | 15 | class nsXMLBindingValues; |
michael@0 | 16 | |
michael@0 | 17 | /** |
michael@0 | 18 | * Classes related to storing bindings for XML handling. |
michael@0 | 19 | */ |
michael@0 | 20 | |
michael@0 | 21 | /** |
michael@0 | 22 | * a <binding> description |
michael@0 | 23 | */ |
michael@0 | 24 | struct nsXMLBinding { |
michael@0 | 25 | nsCOMPtr<nsIAtom> mVar; |
michael@0 | 26 | nsCOMPtr<nsIDOMXPathExpression> mExpr; |
michael@0 | 27 | |
michael@0 | 28 | nsAutoPtr<nsXMLBinding> mNext; |
michael@0 | 29 | |
michael@0 | 30 | nsXMLBinding(nsIAtom* aVar, nsIDOMXPathExpression* aExpr) |
michael@0 | 31 | : mVar(aVar), mExpr(aExpr), mNext(nullptr) |
michael@0 | 32 | { |
michael@0 | 33 | MOZ_COUNT_CTOR(nsXMLBinding); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | ~nsXMLBinding() |
michael@0 | 37 | { |
michael@0 | 38 | MOZ_COUNT_DTOR(nsXMLBinding); |
michael@0 | 39 | } |
michael@0 | 40 | }; |
michael@0 | 41 | |
michael@0 | 42 | /** |
michael@0 | 43 | * a collection of <binding> descriptors. This object is refcounted by |
michael@0 | 44 | * nsXMLBindingValues objects and the query processor. |
michael@0 | 45 | */ |
michael@0 | 46 | class nsXMLBindingSet MOZ_FINAL |
michael@0 | 47 | { |
michael@0 | 48 | public: |
michael@0 | 49 | |
michael@0 | 50 | // results hold a reference to a binding set in their |
michael@0 | 51 | // nsXMLBindingValues fields |
michael@0 | 52 | nsCycleCollectingAutoRefCnt mRefCnt; |
michael@0 | 53 | |
michael@0 | 54 | // pointer to the first binding in a linked list |
michael@0 | 55 | nsAutoPtr<nsXMLBinding> mFirst; |
michael@0 | 56 | |
michael@0 | 57 | public: |
michael@0 | 58 | |
michael@0 | 59 | NS_METHOD_(MozExternalRefCountType) AddRef(); |
michael@0 | 60 | NS_METHOD_(MozExternalRefCountType) Release(); |
michael@0 | 61 | NS_DECL_OWNINGTHREAD |
michael@0 | 62 | NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsXMLBindingSet) |
michael@0 | 63 | |
michael@0 | 64 | /** |
michael@0 | 65 | * Add a binding to the set |
michael@0 | 66 | */ |
michael@0 | 67 | nsresult |
michael@0 | 68 | AddBinding(nsIAtom* aVar, nsIDOMXPathExpression* aExpr); |
michael@0 | 69 | |
michael@0 | 70 | /** |
michael@0 | 71 | * The nsXMLBindingValues class stores an array of values, one for each |
michael@0 | 72 | * target symbol that could be set by the bindings in the set. |
michael@0 | 73 | * LookupTargetIndex determines the index into the array for a given |
michael@0 | 74 | * target symbol. |
michael@0 | 75 | */ |
michael@0 | 76 | int32_t |
michael@0 | 77 | LookupTargetIndex(nsIAtom* aTargetVariable, nsXMLBinding** aBinding); |
michael@0 | 78 | }; |
michael@0 | 79 | |
michael@0 | 80 | /** |
michael@0 | 81 | * a set of values of bindings. This object is used once per result. |
michael@0 | 82 | */ |
michael@0 | 83 | class nsXMLBindingValues |
michael@0 | 84 | { |
michael@0 | 85 | protected: |
michael@0 | 86 | |
michael@0 | 87 | // the binding set |
michael@0 | 88 | nsRefPtr<nsXMLBindingSet> mBindings; |
michael@0 | 89 | |
michael@0 | 90 | /** |
michael@0 | 91 | * A set of values for variable bindings. To look up a binding value, |
michael@0 | 92 | * scan through the binding set in mBindings for the right target atom. |
michael@0 | 93 | * Its index will correspond to the index in this array. |
michael@0 | 94 | */ |
michael@0 | 95 | nsCOMArray<nsIDOMXPathResult> mValues; |
michael@0 | 96 | |
michael@0 | 97 | public: |
michael@0 | 98 | |
michael@0 | 99 | nsXMLBindingValues() { MOZ_COUNT_CTOR(nsXMLBindingValues); } |
michael@0 | 100 | ~nsXMLBindingValues() { MOZ_COUNT_DTOR(nsXMLBindingValues); } |
michael@0 | 101 | |
michael@0 | 102 | nsXMLBindingSet* GetBindingSet() { return mBindings; } |
michael@0 | 103 | |
michael@0 | 104 | void SetBindingSet(nsXMLBindingSet* aBindings) { mBindings = aBindings; } |
michael@0 | 105 | |
michael@0 | 106 | int32_t |
michael@0 | 107 | LookupTargetIndex(nsIAtom* aTargetVariable, nsXMLBinding** aBinding) |
michael@0 | 108 | { |
michael@0 | 109 | return mBindings ? |
michael@0 | 110 | mBindings->LookupTargetIndex(aTargetVariable, aBinding) : -1; |
michael@0 | 111 | } |
michael@0 | 112 | |
michael@0 | 113 | /** |
michael@0 | 114 | * Retrieve the assignment for a particular variable |
michael@0 | 115 | * |
michael@0 | 116 | * aResult the result generated from the template |
michael@0 | 117 | * aBinding the binding looked up using LookupTargetIndex |
michael@0 | 118 | * aIndex the index of the assignment to retrieve |
michael@0 | 119 | * aType the type of result expected |
michael@0 | 120 | * aValue the value of the assignment |
michael@0 | 121 | */ |
michael@0 | 122 | void |
michael@0 | 123 | GetAssignmentFor(nsXULTemplateResultXML* aResult, |
michael@0 | 124 | nsXMLBinding* aBinding, |
michael@0 | 125 | int32_t idx, |
michael@0 | 126 | uint16_t type, |
michael@0 | 127 | nsIDOMXPathResult** aValue); |
michael@0 | 128 | |
michael@0 | 129 | void |
michael@0 | 130 | GetNodeAssignmentFor(nsXULTemplateResultXML* aResult, |
michael@0 | 131 | nsXMLBinding* aBinding, |
michael@0 | 132 | int32_t idx, |
michael@0 | 133 | nsIDOMNode** aValue); |
michael@0 | 134 | |
michael@0 | 135 | void |
michael@0 | 136 | GetStringAssignmentFor(nsXULTemplateResultXML* aResult, |
michael@0 | 137 | nsXMLBinding* aBinding, |
michael@0 | 138 | int32_t idx, |
michael@0 | 139 | nsAString& aValue); |
michael@0 | 140 | }; |
michael@0 | 141 | |
michael@0 | 142 | #endif // nsXMLBinding_h__ |