1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsXBLDocumentInfo_h__
6 #define nsXBLDocumentInfo_h__
8 #include "mozilla/Attributes.h"
10 #include "nsAutoPtr.h"
11 #include "nsWeakReference.h"
12 #include "nsIDocument.h"
13 #include "nsCycleCollectionParticipant.h"
15 class nsXBLPrototypeBinding
;
16 class nsXBLDocGlobalObject
;
18 class nsXBLDocumentInfo MOZ_FINAL
: public nsSupportsWeakReference
21 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
23 explicit nsXBLDocumentInfo(nsIDocument
* aDocument
);
25 already_AddRefed
<nsIDocument
> GetDocument()
26 { nsCOMPtr
<nsIDocument
> copy
= mDocument
; return copy
.forget(); }
28 bool GetScriptAccess() const { return mScriptAccess
; }
30 nsIURI
* DocumentURI() { return mDocument
->GetDocumentURI(); }
32 nsXBLPrototypeBinding
* GetPrototypeBinding(const nsACString
& aRef
);
33 nsresult
SetPrototypeBinding(const nsACString
& aRef
,
34 nsXBLPrototypeBinding
* aBinding
);
36 // This removes the binding without deleting it
37 void RemovePrototypeBinding(const nsACString
& aRef
);
39 nsresult
WritePrototypeBindings();
41 void SetFirstPrototypeBinding(nsXBLPrototypeBinding
* aBinding
);
43 void FlushSkinStylesheets();
45 bool IsChrome() { return mIsChrome
; }
47 void MarkInCCGeneration(uint32_t aGeneration
);
49 static nsresult
ReadPrototypeBindings(nsIURI
* aURI
, nsXBLDocumentInfo
** aDocInfo
);
51 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsXBLDocumentInfo
)
54 virtual ~nsXBLDocumentInfo();
56 nsCOMPtr
<nsIDocument
> mDocument
;
59 // the binding table owns each nsXBLPrototypeBinding
60 nsAutoPtr
<nsClassHashtable
<nsCStringHashKey
, nsXBLPrototypeBinding
>> mBindingTable
;
62 // non-owning pointer to the first binding in the table
63 nsXBLPrototypeBinding
* mFirstBinding
;
67 void AssertInCompilationScope();
69 inline void AssertInCompilationScope() {}