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: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
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 nsTemplateMatch_h__ |
michael@0 | 7 | #define nsTemplateMatch_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsIContent.h" |
michael@0 | 10 | #include "nsIXULTemplateQueryProcessor.h" |
michael@0 | 11 | #include "nsIXULTemplateResult.h" |
michael@0 | 12 | #include "nsRuleNetwork.h" |
michael@0 | 13 | |
michael@0 | 14 | /** |
michael@0 | 15 | * A match object, where each match object is associated with one result. |
michael@0 | 16 | * There will be one match list for each unique id generated. However, since |
michael@0 | 17 | * there are multiple querysets and each may generate results with the same |
michael@0 | 18 | * id, they are all chained together in a linked list, ordered in the same |
michael@0 | 19 | * order as the respective <queryset> elements they were generated from. |
michael@0 | 20 | * A match can be identified by the container and id. The id is retrievable |
michael@0 | 21 | * from the result. |
michael@0 | 22 | * |
michael@0 | 23 | * Only one match per container and id pair is active at a time, but which |
michael@0 | 24 | * match is active may change as new results are added or removed. When a |
michael@0 | 25 | * match is active, content is generated for that match. |
michael@0 | 26 | * |
michael@0 | 27 | * Matches are stored and owned by the mMatchToMap hash in the template |
michael@0 | 28 | * builder. |
michael@0 | 29 | */ |
michael@0 | 30 | |
michael@0 | 31 | class nsTemplateRule; |
michael@0 | 32 | class nsTemplateQuerySet; |
michael@0 | 33 | |
michael@0 | 34 | class nsTemplateMatch { |
michael@0 | 35 | private: |
michael@0 | 36 | // Hide so that only Create() and Destroy() can be used to |
michael@0 | 37 | // allocate and deallocate from the heap |
michael@0 | 38 | void* operator new(size_t) CPP_THROW_NEW { MOZ_ASSERT(0); return nullptr; } |
michael@0 | 39 | void operator delete(void*, size_t) { MOZ_ASSERT(0); } |
michael@0 | 40 | |
michael@0 | 41 | public: |
michael@0 | 42 | nsTemplateMatch(uint16_t aQuerySetPriority, |
michael@0 | 43 | nsIXULTemplateResult* aResult, |
michael@0 | 44 | nsIContent* aContainer) |
michael@0 | 45 | : mRuleIndex(-1), |
michael@0 | 46 | mQuerySetPriority(aQuerySetPriority), |
michael@0 | 47 | mContainer(aContainer), |
michael@0 | 48 | mResult(aResult), |
michael@0 | 49 | mNext(nullptr) |
michael@0 | 50 | { |
michael@0 | 51 | MOZ_COUNT_CTOR(nsTemplateMatch); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | ~nsTemplateMatch() |
michael@0 | 55 | { |
michael@0 | 56 | MOZ_COUNT_DTOR(nsTemplateMatch); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | static nsTemplateMatch* |
michael@0 | 60 | Create(uint16_t aQuerySetPriority, |
michael@0 | 61 | nsIXULTemplateResult* aResult, |
michael@0 | 62 | nsIContent* aContainer) { |
michael@0 | 63 | return ::new nsTemplateMatch(aQuerySetPriority, aResult, aContainer); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | static void Destroy(nsTemplateMatch*& aMatch, bool aRemoveResult); |
michael@0 | 67 | |
michael@0 | 68 | // return true if the the match is active, and has generated output |
michael@0 | 69 | bool IsActive() { |
michael@0 | 70 | return mRuleIndex >= 0; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | // indicate that a rule is no longer active, used when a query with a |
michael@0 | 74 | // lower priority has overriden the match |
michael@0 | 75 | void SetInactive() { |
michael@0 | 76 | mRuleIndex = -1; |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | // return matching rule index |
michael@0 | 80 | int16_t RuleIndex() { |
michael@0 | 81 | return mRuleIndex; |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | // return priority of query set |
michael@0 | 85 | uint16_t QuerySetPriority() { |
michael@0 | 86 | return mQuerySetPriority; |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | // return container, not addrefed. May be null. |
michael@0 | 90 | nsIContent* GetContainer() { |
michael@0 | 91 | return mContainer; |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | nsresult RuleMatched(nsTemplateQuerySet* aQuerySet, |
michael@0 | 95 | nsTemplateRule* aRule, |
michael@0 | 96 | int16_t aRuleIndex, |
michael@0 | 97 | nsIXULTemplateResult* aResult); |
michael@0 | 98 | |
michael@0 | 99 | private: |
michael@0 | 100 | |
michael@0 | 101 | /** |
michael@0 | 102 | * The index of the rule that matched, or -1 if the match is not active. |
michael@0 | 103 | */ |
michael@0 | 104 | int16_t mRuleIndex; |
michael@0 | 105 | |
michael@0 | 106 | /** |
michael@0 | 107 | * The priority of the queryset for this rule |
michael@0 | 108 | */ |
michael@0 | 109 | uint16_t mQuerySetPriority; |
michael@0 | 110 | |
michael@0 | 111 | /** |
michael@0 | 112 | * The container the content generated for the match is inside. |
michael@0 | 113 | */ |
michael@0 | 114 | nsCOMPtr<nsIContent> mContainer; |
michael@0 | 115 | |
michael@0 | 116 | public: |
michael@0 | 117 | |
michael@0 | 118 | /** |
michael@0 | 119 | * The result associated with this match |
michael@0 | 120 | */ |
michael@0 | 121 | nsCOMPtr<nsIXULTemplateResult> mResult; |
michael@0 | 122 | |
michael@0 | 123 | /** |
michael@0 | 124 | * Matches are stored in a linked list, in priority order. This first |
michael@0 | 125 | * match that has a rule set (mRule) is the active match and generates |
michael@0 | 126 | * content. The next match is owned by the builder, which will delete |
michael@0 | 127 | * template matches when needed. |
michael@0 | 128 | */ |
michael@0 | 129 | nsTemplateMatch *mNext; |
michael@0 | 130 | |
michael@0 | 131 | private: |
michael@0 | 132 | |
michael@0 | 133 | nsTemplateMatch(const nsTemplateMatch& aMatch); // not to be implemented |
michael@0 | 134 | void operator=(const nsTemplateMatch& aMatch); // not to be implemented |
michael@0 | 135 | }; |
michael@0 | 136 | |
michael@0 | 137 | #endif // nsTemplateMatch_h__ |
michael@0 | 138 |