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 nsBindingManager_h_ |
michael@0 | 7 | #define nsBindingManager_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsIContent.h" |
michael@0 | 10 | #include "nsStubMutationObserver.h" |
michael@0 | 11 | #include "nsHashKeys.h" |
michael@0 | 12 | #include "nsInterfaceHashtable.h" |
michael@0 | 13 | #include "nsRefPtrHashtable.h" |
michael@0 | 14 | #include "nsURIHashKey.h" |
michael@0 | 15 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 16 | #include "nsXBLBinding.h" |
michael@0 | 17 | #include "nsTArray.h" |
michael@0 | 18 | #include "nsThreadUtils.h" |
michael@0 | 19 | |
michael@0 | 20 | struct ElementDependentRuleProcessorData; |
michael@0 | 21 | class nsIXPConnectWrappedJS; |
michael@0 | 22 | class nsIAtom; |
michael@0 | 23 | class nsIDOMNodeList; |
michael@0 | 24 | class nsIDocument; |
michael@0 | 25 | class nsIURI; |
michael@0 | 26 | class nsXBLDocumentInfo; |
michael@0 | 27 | class nsIStreamListener; |
michael@0 | 28 | class nsStyleSet; |
michael@0 | 29 | class nsXBLBinding; |
michael@0 | 30 | template<class E> class nsRefPtr; |
michael@0 | 31 | typedef nsTArray<nsRefPtr<nsXBLBinding> > nsBindingList; |
michael@0 | 32 | class nsIPrincipal; |
michael@0 | 33 | class nsCSSStyleSheet; |
michael@0 | 34 | |
michael@0 | 35 | class nsBindingManager MOZ_FINAL : public nsStubMutationObserver |
michael@0 | 36 | { |
michael@0 | 37 | public: |
michael@0 | 38 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 39 | |
michael@0 | 40 | NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED |
michael@0 | 41 | NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED |
michael@0 | 42 | NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED |
michael@0 | 43 | |
michael@0 | 44 | nsBindingManager(nsIDocument* aDocument); |
michael@0 | 45 | ~nsBindingManager(); |
michael@0 | 46 | |
michael@0 | 47 | nsXBLBinding* GetBindingWithContent(nsIContent* aContent); |
michael@0 | 48 | |
michael@0 | 49 | void AddBoundContent(nsIContent* aContent); |
michael@0 | 50 | void RemoveBoundContent(nsIContent* aContent); |
michael@0 | 51 | |
michael@0 | 52 | /** |
michael@0 | 53 | * Notify the binding manager that an element |
michael@0 | 54 | * has been removed from its document, |
michael@0 | 55 | * so that it can update any bindings or |
michael@0 | 56 | * nsIAnonymousContentCreator-created anonymous |
michael@0 | 57 | * content that may depend on the document. |
michael@0 | 58 | * @param aContent the element that's being moved |
michael@0 | 59 | * @param aOldDocument the old document in which the |
michael@0 | 60 | * content resided. |
michael@0 | 61 | */ |
michael@0 | 62 | void RemovedFromDocument(nsIContent* aContent, nsIDocument* aOldDocument) |
michael@0 | 63 | { |
michael@0 | 64 | if (aContent->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) { |
michael@0 | 65 | RemovedFromDocumentInternal(aContent, aOldDocument); |
michael@0 | 66 | } |
michael@0 | 67 | } |
michael@0 | 68 | void RemovedFromDocumentInternal(nsIContent* aContent, |
michael@0 | 69 | nsIDocument* aOldDocument); |
michael@0 | 70 | |
michael@0 | 71 | nsIAtom* ResolveTag(nsIContent* aContent, int32_t* aNameSpaceID); |
michael@0 | 72 | |
michael@0 | 73 | /** |
michael@0 | 74 | * Return the nodelist of "anonymous" kids for this node. This might |
michael@0 | 75 | * actually include some of the nodes actual DOM kids, if there are |
michael@0 | 76 | * <children> tags directly as kids of <content>. This will only end up |
michael@0 | 77 | * returning a non-null list for nodes which have a binding attached. |
michael@0 | 78 | */ |
michael@0 | 79 | nsresult GetAnonymousNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult); |
michael@0 | 80 | nsINodeList* GetAnonymousNodesFor(nsIContent* aContent); |
michael@0 | 81 | |
michael@0 | 82 | nsresult ClearBinding(nsIContent* aContent); |
michael@0 | 83 | nsresult LoadBindingDocument(nsIDocument* aBoundDoc, nsIURI* aURL, |
michael@0 | 84 | nsIPrincipal* aOriginPrincipal); |
michael@0 | 85 | |
michael@0 | 86 | nsresult AddToAttachedQueue(nsXBLBinding* aBinding); |
michael@0 | 87 | void RemoveFromAttachedQueue(nsXBLBinding* aBinding); |
michael@0 | 88 | void ProcessAttachedQueue(uint32_t aSkipSize = 0); |
michael@0 | 89 | |
michael@0 | 90 | void ExecuteDetachedHandlers(); |
michael@0 | 91 | |
michael@0 | 92 | nsresult PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo); |
michael@0 | 93 | nsXBLDocumentInfo* GetXBLDocumentInfo(nsIURI* aURI); |
michael@0 | 94 | void RemoveXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo); |
michael@0 | 95 | |
michael@0 | 96 | nsresult PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListener); |
michael@0 | 97 | nsIStreamListener* GetLoadingDocListener(nsIURI* aURL); |
michael@0 | 98 | void RemoveLoadingDocListener(nsIURI* aURL); |
michael@0 | 99 | |
michael@0 | 100 | void FlushSkinBindings(); |
michael@0 | 101 | |
michael@0 | 102 | nsresult GetBindingImplementation(nsIContent* aContent, REFNSIID aIID, void** aResult); |
michael@0 | 103 | |
michael@0 | 104 | // Style rule methods |
michael@0 | 105 | nsresult WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc, |
michael@0 | 106 | ElementDependentRuleProcessorData* aData, |
michael@0 | 107 | bool* aCutOffInheritance); |
michael@0 | 108 | |
michael@0 | 109 | void WalkAllRules(nsIStyleRuleProcessor::EnumFunc aFunc, |
michael@0 | 110 | ElementDependentRuleProcessorData* aData); |
michael@0 | 111 | /** |
michael@0 | 112 | * Do any processing that needs to happen as a result of a change in |
michael@0 | 113 | * the characteristics of the medium, and return whether this rule |
michael@0 | 114 | * processor's rules have changed (e.g., because of media queries). |
michael@0 | 115 | */ |
michael@0 | 116 | nsresult MediumFeaturesChanged(nsPresContext* aPresContext, |
michael@0 | 117 | bool* aRulesChanged); |
michael@0 | 118 | |
michael@0 | 119 | void AppendAllSheets(nsTArray<nsCSSStyleSheet*>& aArray); |
michael@0 | 120 | |
michael@0 | 121 | NS_HIDDEN_(void) Traverse(nsIContent *aContent, |
michael@0 | 122 | nsCycleCollectionTraversalCallback &cb); |
michael@0 | 123 | |
michael@0 | 124 | NS_DECL_CYCLE_COLLECTION_CLASS(nsBindingManager) |
michael@0 | 125 | |
michael@0 | 126 | // Notify the binding manager when an outermost update begins and |
michael@0 | 127 | // ends. The end method can execute script. |
michael@0 | 128 | void BeginOutermostUpdate(); |
michael@0 | 129 | void EndOutermostUpdate(); |
michael@0 | 130 | |
michael@0 | 131 | // When removing an insertion point or a parent of one, clear the insertion |
michael@0 | 132 | // points and their insertion parents. |
michael@0 | 133 | void ClearInsertionPointsRecursively(nsIContent* aContent); |
michael@0 | 134 | |
michael@0 | 135 | // Called when the document is going away |
michael@0 | 136 | void DropDocumentReference(); |
michael@0 | 137 | |
michael@0 | 138 | nsIContent* FindNestedInsertionPoint(nsIContent* aContainer, |
michael@0 | 139 | nsIContent* aChild); |
michael@0 | 140 | |
michael@0 | 141 | nsIContent* FindNestedSingleInsertionPoint(nsIContent* aContainer, bool* aMulti); |
michael@0 | 142 | |
michael@0 | 143 | protected: |
michael@0 | 144 | nsIXPConnectWrappedJS* GetWrappedJS(nsIContent* aContent); |
michael@0 | 145 | nsresult SetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS* aResult); |
michael@0 | 146 | |
michael@0 | 147 | // Called by ContentAppended and ContentInserted to handle a single child |
michael@0 | 148 | // insertion. aChild must not be null. aContainer may be null. |
michael@0 | 149 | // aIndexInContainer is the index of the child in the parent. aAppend is |
michael@0 | 150 | // true if this child is being appended, not inserted. |
michael@0 | 151 | void HandleChildInsertion(nsIContent* aContainer, nsIContent* aChild, |
michael@0 | 152 | uint32_t aIndexInContainer, bool aAppend); |
michael@0 | 153 | |
michael@0 | 154 | // Same as ProcessAttachedQueue, but also nulls out |
michael@0 | 155 | // mProcessAttachedQueueEvent |
michael@0 | 156 | void DoProcessAttachedQueue(); |
michael@0 | 157 | |
michael@0 | 158 | // Post an event to process the attached queue. |
michael@0 | 159 | void PostProcessAttachedQueueEvent(); |
michael@0 | 160 | |
michael@0 | 161 | // MEMBER VARIABLES |
michael@0 | 162 | protected: |
michael@0 | 163 | // A set of nsIContent that currently have a binding installed. |
michael@0 | 164 | nsAutoPtr<nsTHashtable<nsRefPtrHashKey<nsIContent> > > mBoundContentSet; |
michael@0 | 165 | |
michael@0 | 166 | // A mapping from nsIContent* to nsIXPWrappedJS* (an XPConnect |
michael@0 | 167 | // wrapper for JS objects). For XBL bindings that implement XPIDL |
michael@0 | 168 | // interfaces, and that get referred to from C++, this table caches |
michael@0 | 169 | // the XPConnect wrapper for the binding. By caching it, I control |
michael@0 | 170 | // its lifetime, and I prevent a re-wrap of the same script object |
michael@0 | 171 | // (in the case where multiple bindings in an XBL inheritance chain |
michael@0 | 172 | // both implement an XPIDL interface). |
michael@0 | 173 | typedef nsInterfaceHashtable<nsISupportsHashKey, nsIXPConnectWrappedJS> WrapperHashtable; |
michael@0 | 174 | nsAutoPtr<WrapperHashtable> mWrapperTable; |
michael@0 | 175 | |
michael@0 | 176 | // A mapping from a URL (a string) to nsXBLDocumentInfo*. This table |
michael@0 | 177 | // is the cache of all binding documents that have been loaded by a |
michael@0 | 178 | // given bound document. |
michael@0 | 179 | nsAutoPtr<nsRefPtrHashtable<nsURIHashKey,nsXBLDocumentInfo> > mDocumentTable; |
michael@0 | 180 | |
michael@0 | 181 | // A mapping from a URL (a string) to a nsIStreamListener. This |
michael@0 | 182 | // table is the currently loading binding docs. If they're in this |
michael@0 | 183 | // table, they have not yet finished loading. |
michael@0 | 184 | nsAutoPtr<nsInterfaceHashtable<nsURIHashKey,nsIStreamListener> > mLoadingDocTable; |
michael@0 | 185 | |
michael@0 | 186 | // A queue of binding attached event handlers that are awaiting execution. |
michael@0 | 187 | nsBindingList mAttachedStack; |
michael@0 | 188 | bool mProcessingAttachedStack; |
michael@0 | 189 | bool mDestroyed; |
michael@0 | 190 | uint32_t mAttachedStackSizeOnOutermost; |
michael@0 | 191 | |
michael@0 | 192 | // Our posted event to process the attached queue, if any |
michael@0 | 193 | friend class nsRunnableMethod<nsBindingManager>; |
michael@0 | 194 | nsRefPtr< nsRunnableMethod<nsBindingManager> > mProcessAttachedQueueEvent; |
michael@0 | 195 | |
michael@0 | 196 | // Our document. This is a weak ref; the document owns us |
michael@0 | 197 | nsIDocument* mDocument; |
michael@0 | 198 | }; |
michael@0 | 199 | |
michael@0 | 200 | #endif |