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 nsXBLBinding_h_ |
michael@0 | 7 | #define nsXBLBinding_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsXBLService.h" |
michael@0 | 10 | #include "nsCOMPtr.h" |
michael@0 | 11 | #include "nsAutoPtr.h" |
michael@0 | 12 | #include "nsINodeList.h" |
michael@0 | 13 | #include "nsIStyleRuleProcessor.h" |
michael@0 | 14 | #include "nsClassHashtable.h" |
michael@0 | 15 | #include "nsTArray.h" |
michael@0 | 16 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 17 | #include "nsISupportsImpl.h" |
michael@0 | 18 | #include "js/TypeDecls.h" |
michael@0 | 19 | |
michael@0 | 20 | class nsXBLPrototypeBinding; |
michael@0 | 21 | class nsIContent; |
michael@0 | 22 | class nsIAtom; |
michael@0 | 23 | class nsIDocument; |
michael@0 | 24 | class nsIScriptContext; |
michael@0 | 25 | |
michael@0 | 26 | namespace mozilla { |
michael@0 | 27 | namespace dom { |
michael@0 | 28 | |
michael@0 | 29 | class ShadowRoot; |
michael@0 | 30 | class XBLChildrenElement; |
michael@0 | 31 | |
michael@0 | 32 | } // namespace dom |
michael@0 | 33 | } // namespace mozilla |
michael@0 | 34 | |
michael@0 | 35 | class nsAnonymousContentList; |
michael@0 | 36 | |
michael@0 | 37 | // *********************************************************************/ |
michael@0 | 38 | // The XBLBinding class |
michael@0 | 39 | |
michael@0 | 40 | class nsXBLBinding MOZ_FINAL |
michael@0 | 41 | { |
michael@0 | 42 | public: |
michael@0 | 43 | nsXBLBinding(nsXBLPrototypeBinding* aProtoBinding); |
michael@0 | 44 | nsXBLBinding(mozilla::dom::ShadowRoot* aShadowRoot, nsXBLPrototypeBinding* aProtoBinding); |
michael@0 | 45 | ~nsXBLBinding(); |
michael@0 | 46 | |
michael@0 | 47 | /** |
michael@0 | 48 | * XBLBindings are refcounted. They are held onto in 3 ways: |
michael@0 | 49 | * 1. The binding manager's binding table holds onto all bindings that are |
michael@0 | 50 | * currently attached to a content node. |
michael@0 | 51 | * 2. Bindings hold onto their base binding. This is important since |
michael@0 | 52 | * the base binding itself may not be attached to anything. |
michael@0 | 53 | * 3. The binding manager holds an additional reference to bindings |
michael@0 | 54 | * which are queued to fire their constructors. |
michael@0 | 55 | */ |
michael@0 | 56 | |
michael@0 | 57 | NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsXBLBinding) |
michael@0 | 58 | |
michael@0 | 59 | NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsXBLBinding) |
michael@0 | 60 | |
michael@0 | 61 | nsXBLPrototypeBinding* PrototypeBinding() const { return mPrototypeBinding; } |
michael@0 | 62 | nsIContent* GetAnonymousContent() { return mContent.get(); } |
michael@0 | 63 | nsXBLBinding* GetBindingWithContent(); |
michael@0 | 64 | |
michael@0 | 65 | nsXBLBinding* GetBaseBinding() const { return mNextBinding; } |
michael@0 | 66 | void SetBaseBinding(nsXBLBinding *aBinding); |
michael@0 | 67 | |
michael@0 | 68 | nsIContent* GetBoundElement() { return mBoundElement; } |
michael@0 | 69 | void SetBoundElement(nsIContent *aElement); |
michael@0 | 70 | |
michael@0 | 71 | /* |
michael@0 | 72 | * Does a lookup for a method or attribute provided by one of the bindings' |
michael@0 | 73 | * prototype implementation. If found, |desc| will be set up appropriately, |
michael@0 | 74 | * and wrapped into cx->compartment. |
michael@0 | 75 | * |
michael@0 | 76 | * May only be called when XBL code is being run in a separate scope, because |
michael@0 | 77 | * otherwise we don't have untainted data with which to do a proper lookup. |
michael@0 | 78 | */ |
michael@0 | 79 | bool LookupMember(JSContext* aCx, JS::Handle<jsid> aId, |
michael@0 | 80 | JS::MutableHandle<JSPropertyDescriptor> aDesc); |
michael@0 | 81 | |
michael@0 | 82 | /* |
michael@0 | 83 | * Determines whether the binding has a field with the given name. |
michael@0 | 84 | */ |
michael@0 | 85 | bool HasField(nsString& aName); |
michael@0 | 86 | |
michael@0 | 87 | protected: |
michael@0 | 88 | |
michael@0 | 89 | /* |
michael@0 | 90 | * Internal version. Requires that aCx is in appropriate xbl scope. |
michael@0 | 91 | */ |
michael@0 | 92 | bool LookupMemberInternal(JSContext* aCx, nsString& aName, |
michael@0 | 93 | JS::Handle<jsid> aNameAsId, |
michael@0 | 94 | JS::MutableHandle<JSPropertyDescriptor> aDesc, |
michael@0 | 95 | JS::Handle<JSObject*> aXBLScope); |
michael@0 | 96 | |
michael@0 | 97 | public: |
michael@0 | 98 | |
michael@0 | 99 | void MarkForDeath(); |
michael@0 | 100 | bool MarkedForDeath() const { return mMarkedForDeath; } |
michael@0 | 101 | |
michael@0 | 102 | bool HasStyleSheets() const; |
michael@0 | 103 | bool InheritsStyle() const; |
michael@0 | 104 | bool ImplementsInterface(REFNSIID aIID) const; |
michael@0 | 105 | |
michael@0 | 106 | void GenerateAnonymousContent(); |
michael@0 | 107 | void InstallAnonymousContent(nsIContent* aAnonParent, nsIContent* aElement, |
michael@0 | 108 | bool aNativeAnon); |
michael@0 | 109 | static void UninstallAnonymousContent(nsIDocument* aDocument, |
michael@0 | 110 | nsIContent* aAnonParent); |
michael@0 | 111 | void InstallEventHandlers(); |
michael@0 | 112 | nsresult InstallImplementation(); |
michael@0 | 113 | |
michael@0 | 114 | void ExecuteAttachedHandler(); |
michael@0 | 115 | void ExecuteDetachedHandler(); |
michael@0 | 116 | void UnhookEventHandlers(); |
michael@0 | 117 | |
michael@0 | 118 | nsIAtom* GetBaseTag(int32_t* aNameSpaceID); |
michael@0 | 119 | nsXBLBinding* RootBinding(); |
michael@0 | 120 | |
michael@0 | 121 | // Resolve all the fields for this binding and all ancestor bindings on the |
michael@0 | 122 | // object |obj|. False return means a JS exception was set. |
michael@0 | 123 | bool ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const; |
michael@0 | 124 | |
michael@0 | 125 | void AttributeChanged(nsIAtom* aAttribute, int32_t aNameSpaceID, |
michael@0 | 126 | bool aRemoveFlag, bool aNotify); |
michael@0 | 127 | |
michael@0 | 128 | void ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocument); |
michael@0 | 129 | |
michael@0 | 130 | void WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc, void* aData); |
michael@0 | 131 | |
michael@0 | 132 | static nsresult DoInitJSClass(JSContext *cx, JS::Handle<JSObject*> obj, |
michael@0 | 133 | const nsAFlatCString& aClassName, |
michael@0 | 134 | nsXBLPrototypeBinding* aProtoBinding, |
michael@0 | 135 | JS::MutableHandle<JSObject*> aClassObject, |
michael@0 | 136 | bool* aNew); |
michael@0 | 137 | |
michael@0 | 138 | bool AllowScripts(); |
michael@0 | 139 | |
michael@0 | 140 | mozilla::dom::XBLChildrenElement* FindInsertionPointFor(nsIContent* aChild); |
michael@0 | 141 | |
michael@0 | 142 | bool HasFilteredInsertionPoints() |
michael@0 | 143 | { |
michael@0 | 144 | return !mInsertionPoints.IsEmpty(); |
michael@0 | 145 | } |
michael@0 | 146 | |
michael@0 | 147 | mozilla::dom::XBLChildrenElement* GetDefaultInsertionPoint() |
michael@0 | 148 | { |
michael@0 | 149 | return mDefaultInsertionPoint; |
michael@0 | 150 | } |
michael@0 | 151 | |
michael@0 | 152 | // Removes all inserted node from <xbl:children> insertion points under us. |
michael@0 | 153 | void ClearInsertionPoints(); |
michael@0 | 154 | |
michael@0 | 155 | // Returns a live node list that iterates over the anonymous nodes generated |
michael@0 | 156 | // by this binding. |
michael@0 | 157 | nsAnonymousContentList* GetAnonymousNodeList(); |
michael@0 | 158 | |
michael@0 | 159 | // MEMBER VARIABLES |
michael@0 | 160 | protected: |
michael@0 | 161 | |
michael@0 | 162 | bool mMarkedForDeath; |
michael@0 | 163 | bool mUsingXBLScope; |
michael@0 | 164 | |
michael@0 | 165 | nsXBLPrototypeBinding* mPrototypeBinding; // Weak, but we're holding a ref to the docinfo |
michael@0 | 166 | nsCOMPtr<nsIContent> mContent; // Strong. Our anonymous content stays around with us. |
michael@0 | 167 | nsRefPtr<nsXBLBinding> mNextBinding; // Strong. The derived binding owns the base class bindings. |
michael@0 | 168 | |
michael@0 | 169 | nsIContent* mBoundElement; // [WEAK] We have a reference, but we don't own it. |
michael@0 | 170 | |
michael@0 | 171 | // The <xbl:children> elements that we found in our <xbl:content> when we |
michael@0 | 172 | // processed this binding. The default insertion point has no includes |
michael@0 | 173 | // attribute and all other insertion points must have at least one includes |
michael@0 | 174 | // attribute. These points must be up-to-date with respect to their parent's |
michael@0 | 175 | // children, even if their parent has another binding attached to it, |
michael@0 | 176 | // preventing us from rendering their contents directly. |
michael@0 | 177 | nsRefPtr<mozilla::dom::XBLChildrenElement> mDefaultInsertionPoint; |
michael@0 | 178 | nsTArray<nsRefPtr<mozilla::dom::XBLChildrenElement> > mInsertionPoints; |
michael@0 | 179 | nsRefPtr<nsAnonymousContentList> mAnonymousContentList; |
michael@0 | 180 | |
michael@0 | 181 | mozilla::dom::XBLChildrenElement* FindInsertionPointForInternal(nsIContent* aChild); |
michael@0 | 182 | }; |
michael@0 | 183 | |
michael@0 | 184 | #endif // nsXBLBinding_h_ |