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: 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 nsXBLProtoImpl_h__
7 #define nsXBLProtoImpl_h__
9 #include "nsMemory.h"
10 #include "nsXBLPrototypeHandler.h"
11 #include "nsXBLProtoImplMember.h"
12 #include "nsXBLProtoImplField.h"
13 #include "nsXBLBinding.h"
15 class nsXBLPrototypeBinding;
16 class nsXBLProtoImplAnonymousMethod;
18 class nsXBLProtoImpl MOZ_FINAL
19 {
20 public:
21 nsXBLProtoImpl()
22 : mPrecompiledMemberHolder(nullptr),
23 mMembers(nullptr),
24 mFields(nullptr),
25 mConstructor(nullptr),
26 mDestructor(nullptr)
27 {
28 MOZ_COUNT_CTOR(nsXBLProtoImpl);
29 }
30 ~nsXBLProtoImpl()
31 {
32 MOZ_COUNT_DTOR(nsXBLProtoImpl);
33 // Note: the constructor and destructor are in mMembers, so we'll
34 // clean them up automatically.
35 delete mMembers;
36 delete mFields;
37 }
40 nsresult InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding, nsXBLBinding* aBinding);
42 private:
43 nsresult InitTargetObjects(nsXBLPrototypeBinding* aBinding,
44 nsIContent* aBoundElement,
45 JS::MutableHandle<JSObject*> aTargetClassObject,
46 bool* aTargetIsNew);
48 public:
49 nsresult CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding);
51 bool LookupMember(JSContext* aCx, nsString& aName, JS::Handle<jsid> aNameAsId,
52 JS::MutableHandle<JSPropertyDescriptor> aDesc,
53 JS::Handle<JSObject*> aClassObject);
55 void SetMemberList(nsXBLProtoImplMember* aMemberList)
56 {
57 delete mMembers;
58 mMembers = aMemberList;
59 }
61 void SetFieldList(nsXBLProtoImplField* aFieldList)
62 {
63 delete mFields;
64 mFields = aFieldList;
65 }
67 void Trace(const TraceCallbacks& aCallbacks, void *aClosure);
68 void UnlinkJSObjects();
70 nsXBLProtoImplField* FindField(const nsString& aFieldName) const;
72 // Resolve all the fields for this implementation on the object |obj| False
73 // return means a JS exception was set.
74 bool ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const;
76 // Undefine all our fields from object |obj| (which should be a
77 // JSObject for a bound element).
78 void UndefineFields(JSContext* cx, JS::Handle<JSObject*> obj) const;
80 bool CompiledMembers() const {
81 return mPrecompiledMemberHolder != nullptr;
82 }
84 nsresult Read(nsIObjectInputStream* aStream,
85 nsXBLPrototypeBinding* aBinding);
86 nsresult Write(nsIObjectOutputStream* aStream,
87 nsXBLPrototypeBinding* aBinding);
89 protected:
90 // used by Read to add each member
91 nsXBLProtoImplMember* AddMember(nsXBLProtoImplMember* aMember,
92 nsXBLProtoImplMember* aPreviousMember)
93 {
94 if (aPreviousMember)
95 aPreviousMember->SetNext(aMember);
96 else
97 mMembers = aMember;
98 return aMember;
99 }
101 void DestroyMembers();
103 public:
104 nsCString mClassName; // The name of the class.
106 protected:
107 JSObject* mPrecompiledMemberHolder; // The class object for the binding. We'll use this to pre-compile properties
108 // and methods for the binding.
110 nsXBLProtoImplMember* mMembers; // The members of an implementation are chained in this singly-linked list.
112 nsXBLProtoImplField* mFields; // Our fields
114 public:
115 nsXBLProtoImplAnonymousMethod* mConstructor; // Our class constructor.
116 nsXBLProtoImplAnonymousMethod* mDestructor; // Our class destructor.
117 };
119 nsresult
120 NS_NewXBLProtoImpl(nsXBLPrototypeBinding* aBinding,
121 const char16_t* aClassName,
122 nsXBLProtoImpl** aResult);
124 #endif // nsXBLProtoImpl_h__