/usr/include/thunderbird-11.0.1/nsBindingManager.h is in thunderbird-dev 11.0.1+build1-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: David W. Hyatt (hyatt@netscape.com)
* Alec Flett <alecf@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsBindingManager_h_
#define nsBindingManager_h_
#include "nsStubMutationObserver.h"
#include "pldhash.h"
#include "nsInterfaceHashtable.h"
#include "nsRefPtrHashtable.h"
#include "nsURIHashKey.h"
#include "nsCycleCollectionParticipant.h"
#include "nsXBLBinding.h"
#include "nsTArray.h"
#include "nsThreadUtils.h"
class nsIContent;
class nsIXPConnectWrappedJS;
class nsIAtom;
class nsIDOMNodeList;
class nsIDocument;
class nsIURI;
class nsXBLDocumentInfo;
class nsIStreamListener;
class nsStyleSet;
class nsXBLBinding;
template<class E> class nsRefPtr;
typedef nsTArray<nsRefPtr<nsXBLBinding> > nsBindingList;
class nsIPrincipal;
class nsBindingManager : public nsStubMutationObserver
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
nsBindingManager(nsIDocument* aDocument);
~nsBindingManager();
nsXBLBinding* GetBinding(nsIContent* aContent);
nsresult SetBinding(nsIContent* aContent, nsXBLBinding* aBinding);
nsIContent* GetInsertionParent(nsIContent* aContent);
nsresult SetInsertionParent(nsIContent* aContent, nsIContent* aResult);
/**
* Notify the binding manager that an element
* has been removed from its document,
* so that it can update any bindings or
* nsIAnonymousContentCreator-created anonymous
* content that may depend on the document.
* @param aContent the element that's being moved
* @param aOldDocument the old document in which the
* content resided.
*/
void RemovedFromDocument(nsIContent* aContent, nsIDocument* aOldDocument)
{
if (aContent->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
RemovedFromDocumentInternal(aContent, aOldDocument);
}
}
void RemovedFromDocumentInternal(nsIContent* aContent,
nsIDocument* aOldDocument);
nsIAtom* ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID);
/**
* Return a list of all explicit children, including any children
* that may have been inserted via XBL insertion points.
*/
nsresult GetContentListFor(nsIContent* aContent, nsIDOMNodeList** aResult);
/**
* Non-COMy version of GetContentListFor.
*/
nsINodeList* GetContentListFor(nsIContent* aContent);
/**
* Set the insertion point children for the specified element.
* The binding manager assumes ownership of aList.
*/
nsresult SetContentListFor(nsIContent* aContent,
nsInsertionPointList* aList);
/**
* Determine whether or not the explicit child list has been altered
* by XBL insertion points.
*/
bool HasContentListFor(nsIContent* aContent);
/**
* Return the nodelist of "anonymous" kids for this node. This might
* actually include some of the nodes actual DOM kids, if there are
* <children> tags directly as kids of <content>. This will only end up
* returning a non-null list for nodes which have a binding attached.
*/
nsresult GetAnonymousNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult);
/**
* Same as above, but without the XPCOM goop
*/
nsINodeList* GetAnonymousNodesFor(nsIContent* aContent);
/**
* Set the anonymous child content for the specified element.
* The binding manager assumes ownership of aList.
*/
nsresult SetAnonymousNodesFor(nsIContent* aContent,
nsInsertionPointList* aList);
/**
* Retrieves the anonymous list of children if the element has one;
* otherwise, retrieves the list of explicit children. N.B. that if
* the explicit child list has not been altered by XBL insertion
* points, then aResult will be null.
*/
nsresult GetXBLChildNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult);
/**
* Non-COMy version of GetXBLChildNodesFor
*/
nsINodeList* GetXBLChildNodesFor(nsIContent* aContent);
/**
* Given a parent element and a child content, determine where the
* child content should be inserted in the parent element's
* anonymous content tree. Specifically, aChild should be inserted
* beneath aResult at the index specified by aIndex.
*/
// XXXbz That's false. The aIndex doesn't seem to accurately reflect
// anything resembling reality in terms of inserting content. It's really
// only used to tell apart two different insertion points with the same
// insertion parent when managing our internal data structures. We really
// shouldn't be handing it out in our public API, since it's not useful to
// anyone.
nsIContent* GetInsertionPoint(nsIContent* aParent,
const nsIContent* aChild, PRUint32* aIndex);
/**
* Return the unfiltered insertion point for the specified parent
* element. If other filtered insertion points exist,
* aMultipleInsertionPoints will be set to true.
*/
nsIContent* GetSingleInsertionPoint(nsIContent* aParent, PRUint32* aIndex,
bool* aMultipleInsertionPoints);
nsIContent* GetNestedInsertionPoint(nsIContent* aParent,
const nsIContent* aChild);
nsIContent* GetNestedSingleInsertionPoint(nsIContent* aParent,
bool* aMultipleInsertionPoints);
nsresult AddLayeredBinding(nsIContent* aContent, nsIURI* aURL,
nsIPrincipal* aOriginPrincipal);
nsresult RemoveLayeredBinding(nsIContent* aContent, nsIURI* aURL);
nsresult LoadBindingDocument(nsIDocument* aBoundDoc, nsIURI* aURL,
nsIPrincipal* aOriginPrincipal);
nsresult AddToAttachedQueue(nsXBLBinding* aBinding);
void ProcessAttachedQueue(PRUint32 aSkipSize = 0);
void ExecuteDetachedHandlers();
nsresult PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo);
nsXBLDocumentInfo* GetXBLDocumentInfo(nsIURI* aURI);
void RemoveXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo);
nsresult PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListener);
nsIStreamListener* GetLoadingDocListener(nsIURI* aURL);
void RemoveLoadingDocListener(nsIURI* aURL);
void FlushSkinBindings();
nsresult GetBindingImplementation(nsIContent* aContent, REFNSIID aIID, void** aResult);
// Style rule methods
nsresult WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc,
RuleProcessorData* aData,
bool* aCutOffInheritance);
void WalkAllRules(nsIStyleRuleProcessor::EnumFunc aFunc,
RuleProcessorData* aData);
/**
* Do any processing that needs to happen as a result of a change in
* the characteristics of the medium, and return whether this rule
* processor's rules have changed (e.g., because of media queries).
*/
nsresult MediumFeaturesChanged(nsPresContext* aPresContext,
bool* aRulesChanged);
void AppendAllSheets(nsTArray<nsCSSStyleSheet*>& aArray);
NS_HIDDEN_(void) Traverse(nsIContent *aContent,
nsCycleCollectionTraversalCallback &cb);
NS_DECL_CYCLE_COLLECTION_CLASS(nsBindingManager)
// Notify the binding manager when an outermost update begins and
// ends. The end method can execute script.
void BeginOutermostUpdate();
void EndOutermostUpdate();
// Called when the document is going away
void DropDocumentReference();
protected:
nsIXPConnectWrappedJS* GetWrappedJS(nsIContent* aContent);
nsresult SetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS* aResult);
nsINodeList* GetXBLChildNodesInternal(nsIContent* aContent,
bool* aIsAnonymousContentList);
nsINodeList* GetAnonymousNodesInternal(nsIContent* aContent,
bool* aIsAnonymousContentList);
// Called by ContentAppended and ContentInserted to handle a single child
// insertion. aChild must not be null. aContainer may be null.
// aIndexInContainer is the index of the child in the parent. aAppend is
// true if this child is being appended, not inserted.
void HandleChildInsertion(nsIContent* aContainer, nsIContent* aChild,
PRUint32 aIndexInContainer, bool aAppend);
// For the given container under which a child is being added, given
// insertion parent and given index of the child being inserted, find the
// right nsXBLInsertionPoint and the right index in that insertion point to
// insert it at. If null is returned, aInsertionIndex might be garbage.
// aAppend controls what should be returned as the aInsertionIndex if the
// right index can't be found. If true, the length of the insertion point
// will be returned; otherwise 0 will be returned.
nsXBLInsertionPoint* FindInsertionPointAndIndex(nsIContent* aContainer,
nsIContent* aInsertionParent,
PRUint32 aIndexInContainer,
PRInt32 aAppend,
PRInt32* aInsertionIndex);
// Same as ProcessAttachedQueue, but also nulls out
// mProcessAttachedQueueEvent
void DoProcessAttachedQueue();
// Post an event to process the attached queue.
void PostProcessAttachedQueueEvent();
// MEMBER VARIABLES
protected:
void RemoveInsertionParent(nsIContent* aParent);
// A mapping from nsIContent* to the nsXBLBinding* that is
// installed on that element.
nsRefPtrHashtable<nsISupportsHashKey,nsXBLBinding> mBindingTable;
// A mapping from nsIContent* to an nsAnonymousContentList*. This
// list contains an accurate reflection of our *explicit* children
// (once intermingled with insertion points) in the altered DOM.
// There is an entry for a content node in this table only if that
// content node has some <children> kids.
PLDHashTable mContentListTable;
// A mapping from nsIContent* to an nsAnonymousContentList*. This
// list contains an accurate reflection of our *anonymous* children
// (if and only if they are intermingled with insertion points) in
// the altered DOM. This table is not used if no insertion points
// were defined directly underneath a <content> tag in a binding.
// The NodeList from the <content> is used instead as a performance
// optimization. There is an entry for a content node in this table
// only if that content node has a binding with a <content> attached
// and this <content> contains <children> elements directly.
PLDHashTable mAnonymousNodesTable;
// A mapping from nsIContent* to nsIContent*. The insertion parent
// is our one true parent in the transformed DOM. This gives us a
// more-or-less O(1) way of obtaining our transformed parent.
PLDHashTable mInsertionParentTable;
// A mapping from nsIContent* to nsIXPWrappedJS* (an XPConnect
// wrapper for JS objects). For XBL bindings that implement XPIDL
// interfaces, and that get referred to from C++, this table caches
// the XPConnect wrapper for the binding. By caching it, I control
// its lifetime, and I prevent a re-wrap of the same script object
// (in the case where multiple bindings in an XBL inheritance chain
// both implement an XPIDL interface).
PLDHashTable mWrapperTable;
// A mapping from a URL (a string) to nsXBLDocumentInfo*. This table
// is the cache of all binding documents that have been loaded by a
// given bound document.
nsRefPtrHashtable<nsURIHashKey,nsXBLDocumentInfo> mDocumentTable;
// A mapping from a URL (a string) to a nsIStreamListener. This
// table is the currently loading binding docs. If they're in this
// table, they have not yet finished loading.
nsInterfaceHashtable<nsURIHashKey,nsIStreamListener> mLoadingDocTable;
// A queue of binding attached event handlers that are awaiting execution.
nsBindingList mAttachedStack;
bool mProcessingAttachedStack;
bool mDestroyed;
PRUint32 mAttachedStackSizeOnOutermost;
// Our posted event to process the attached queue, if any
friend class nsRunnableMethod<nsBindingManager>;
nsRefPtr< nsRunnableMethod<nsBindingManager> > mProcessAttachedQueueEvent;
// Our document. This is a weak ref; the document owns us
nsIDocument* mDocument;
};
#endif
|