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.
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/. */
6 #ifndef nsContentSupportMap_h__
7 #define nsContentSupportMap_h__
9 #include "pldhash.h"
10 #include "nsTemplateMatch.h"
12 /**
13 * The nsContentSupportMap maintains a mapping from a "resource element"
14 * in the content tree to the nsTemplateMatch that was used to instantiate it. This
15 * is necessary to allow the XUL content to be built lazily. Specifically,
16 * when building "resumes" on a partially-built content element, the builder
17 * will walk upwards in the content tree to find the first element with an
18 * 'id' attribute. This element is assumed to be the "resource element",
19 * and allows the content builder to access the nsTemplateMatch (variable assignments
20 * and rule information).
21 */
22 class nsContentSupportMap {
23 public:
24 nsContentSupportMap() { Init(); }
25 ~nsContentSupportMap() { Finish(); }
27 nsresult Put(nsIContent* aElement, nsTemplateMatch* aMatch) {
28 if (!mMap.ops)
29 return NS_ERROR_NOT_INITIALIZED;
31 PLDHashEntryHdr* hdr = PL_DHashTableOperate(&mMap, aElement, PL_DHASH_ADD);
32 if (!hdr)
33 return NS_ERROR_OUT_OF_MEMORY;
35 Entry* entry = reinterpret_cast<Entry*>(hdr);
36 NS_ASSERTION(entry->mMatch == nullptr, "over-writing entry");
37 entry->mContent = aElement;
38 entry->mMatch = aMatch;
39 return NS_OK; }
41 bool Get(nsIContent* aElement, nsTemplateMatch** aMatch) {
42 if (!mMap.ops)
43 return false;
45 PLDHashEntryHdr* hdr = PL_DHashTableOperate(&mMap, aElement, PL_DHASH_LOOKUP);
46 if (PL_DHASH_ENTRY_IS_FREE(hdr))
47 return false;
49 Entry* entry = reinterpret_cast<Entry*>(hdr);
50 *aMatch = entry->mMatch;
51 return true; }
53 nsresult Remove(nsIContent* aElement);
55 void Clear() { Finish(); Init(); }
57 protected:
58 PLDHashTable mMap;
60 void Init();
61 void Finish();
63 struct Entry {
64 PLDHashEntryHdr mHdr;
65 nsIContent* mContent;
66 nsTemplateMatch* mMatch;
67 };
68 };
70 #endif