Bug 450717 dep file for pixman-mmx.c isn't generated with GCC, r=ted.mielczarek
[wine-gecko.git] / content / xbl / src / nsXBLService.h
blob62ed170adf586395d085b2779be4c3e27febec14
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Mozilla Communicator client code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Original Author: David W. Hyatt (hyatt@netscape.com)
24 * - Brendan Eich (brendan@mozilla.org)
25 * - Mike Pinkerton (pinkerton@netscape.com)
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
41 //////////////////////////////////////////////////////////////////////////////////////////
43 #include "nsIXBLService.h"
44 #include "nsIObserver.h"
45 #include "nsWeakReference.h"
46 #include "jsapi.h" // nsXBLJSClass derives from JSClass
47 #include "jsclist.h" // nsXBLJSClass derives from JSCList
48 #include "nsFixedSizeAllocator.h"
49 #include "nsTArray.h"
51 class nsXBLBinding;
52 class nsIXBLDocumentInfo;
53 class nsIContent;
54 class nsIDocument;
55 class nsIAtom;
56 class nsString;
57 class nsIURI;
58 class nsSupportsHashtable;
59 class nsHashtable;
61 class nsXBLService : public nsIXBLService,
62 public nsIObserver,
63 public nsSupportsWeakReference
65 NS_DECL_ISUPPORTS
67 // This function loads a particular XBL file and installs all of the bindings
68 // onto the element. aOriginPrincipal must not be null here.
69 NS_IMETHOD LoadBindings(nsIContent* aContent, nsIURI* aURL,
70 nsIPrincipal* aOriginPrincipal, PRBool aAugmentFlag,
71 nsXBLBinding** aBinding, PRBool* aResolveStyle);
73 // Indicates whether or not a binding is fully loaded.
74 NS_IMETHOD BindingReady(nsIContent* aBoundElement, nsIURI* aURI, PRBool* aIsReady);
76 // Gets the object's base class type.
77 NS_IMETHOD ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID, nsIAtom** aResult);
79 // This method checks the hashtable and then calls FetchBindingDocument on a
80 // miss. aOriginPrincipal or aBoundDocument may be null to bypass security
81 // checks.
82 NS_IMETHOD LoadBindingDocumentInfo(nsIContent* aBoundElement,
83 nsIDocument* aBoundDocument,
84 nsIURI* aBindingURI,
85 nsIPrincipal* aOriginPrincipal,
86 PRBool aForceSyncLoad,
87 nsIXBLDocumentInfo** aResult);
89 // Used by XUL key bindings and for window XBL.
90 NS_IMETHOD AttachGlobalKeyHandler(nsPIDOMEventTarget* aTarget);
91 NS_IMETHOD DetachGlobalKeyHandler(nsPIDOMEventTarget* aTarget);
93 NS_DECL_NSIOBSERVER
95 public:
96 nsXBLService();
97 virtual ~nsXBLService();
99 protected:
100 // This function clears out the bindings on a given content node.
101 nsresult FlushStyleBindings(nsIContent* aContent);
103 // Release any memory that we can
104 nsresult FlushMemory();
106 // This method synchronously loads and parses an XBL file.
107 nsresult FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoundDocument,
108 nsIURI* aDocumentURI, nsIURI* aBindingURI,
109 PRBool aForceSyncLoad, nsIDocument** aResult);
111 nsIXBLDocumentInfo* GetXBLDocumentInfo(nsIURI* aURI,
112 nsIContent* aBoundElement);
115 * This method calls the one below with an empty |aDontExtendURIs| array.
117 nsresult GetBinding(nsIContent* aBoundElement, nsIURI* aURI,
118 PRBool aPeekFlag, nsIPrincipal* aOriginPrincipal,
119 PRBool* aIsReady, nsXBLBinding** aResult);
122 * This method loads a binding doc and then builds the specific binding
123 * required. It can also peek without building.
124 * @param aBoundElement the element to get a binding for
125 * @param aURI the binding URI
126 * @param aPeekFlag if true then just peek to see if the binding is ready
127 * @param aIsReady [out] if the binding is ready or not
128 * @param aResult [out] where to store the resulting binding (not used if
129 * aPeekFlag is true, otherwise it must be non-null)
130 * @param aDontExtendURIs a set of URIs that are already bound to this
131 * element. If a binding extends any of these then further loading
132 * is aborted (because it would lead to the binding extending itself)
133 * and NS_ERROR_ILLEGAL_VALUE is returned.
135 * @note This method always calls LoadBindingDocumentInfo(), so it's
136 * enough to funnel all security checks through that function.
138 nsresult GetBinding(nsIContent* aBoundElement, nsIURI* aURI,
139 PRBool aPeekFlag, nsIPrincipal* aOriginPrincipal,
140 PRBool* aIsReady, nsXBLBinding** aResult,
141 nsTArray<nsIURI*>& aDontExtendURIs);
143 // MEMBER VARIABLES
144 public:
145 static PRUint32 gRefCnt; // A count of XBLservice instances.
147 static PRBool gDisableChromeCache;
149 static nsHashtable* gClassTable; // A table of nsXBLJSClass objects.
151 static JSCList gClassLRUList; // LRU list of cached classes.
152 static PRUint32 gClassLRUListLength; // Number of classes on LRU list.
153 static PRUint32 gClassLRUListQuota; // Quota on class LRU list.
154 static PRBool gAllowDataURIs; // Whether we should allow data
155 // urls in -moz-binding. Needed for
156 // testing.
158 nsFixedSizeAllocator mPool;
161 class nsXBLJSClass : public JSCList, public JSClass
163 private:
164 nsrefcnt mRefCnt;
165 nsrefcnt Destroy();
167 public:
168 nsXBLJSClass(const nsAFlatCString& aClassName);
169 ~nsXBLJSClass() { nsMemory::Free((void*) name); }
171 nsrefcnt Hold() { return ++mRefCnt; }
172 nsrefcnt Drop() { return --mRefCnt ? mRefCnt : Destroy(); }