Bumping manifests a=b2g-bump
[gecko.git] / dom / xul / nsXULPrototypeDocument.h
blobaa29bb7e173f3c327fcd793cc44040ed90dd10f3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsXULPrototypeDocument_h__
7 #define nsXULPrototypeDocument_h__
9 #include "js/TracingAPI.h"
10 #include "mozilla/Attributes.h"
11 #include "nsAutoPtr.h"
12 #include "nsCOMArray.h"
13 #include "nsCOMPtr.h"
14 #include "nsTArray.h"
15 #include "nsISerializable.h"
16 #include "nsCycleCollectionParticipant.h"
18 class nsIAtom;
19 class nsIPrincipal;
20 class nsIURI;
21 class nsNodeInfoManager;
22 class nsXULPrototypeElement;
23 class nsXULPrototypePI;
25 namespace mozilla {
26 namespace dom {
27 class XULDocument;
28 } // namespace dom
29 } // namespace mozilla
31 /**
32 * A "prototype" document that stores shared document information
33 * for the XUL cache.
34 * Among other things, stores the tree of nsXULPrototype*
35 * objects, from which the real DOM tree is built later in
36 * XULDocument::ResumeWalk.
38 class nsXULPrototypeDocument MOZ_FINAL : public nsISerializable
40 public:
41 static nsresult
42 Create(nsIURI* aURI, nsXULPrototypeDocument** aResult);
44 // nsISupports interface
45 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
47 // nsISerializable interface
48 NS_DECL_NSISERIALIZABLE
50 nsresult InitPrincipal(nsIURI* aURI, nsIPrincipal* aPrincipal);
51 nsIURI* GetURI();
53 /**
54 * Get/set the root nsXULPrototypeElement of the document.
56 nsXULPrototypeElement* GetRootElement();
57 void SetRootElement(nsXULPrototypeElement* aElement);
59 /**
60 * Add a processing instruction to the prolog. Note that only
61 * PI nodes are currently stored in a XUL prototype document's
62 * prolog and that they're handled separately from the rest of
63 * prototype node tree.
65 * @param aPI an already adrefed PI proto to add. This method takes
66 * ownership of the passed PI.
68 nsresult AddProcessingInstruction(nsXULPrototypePI* aPI);
69 /**
70 * @note GetProcessingInstructions retains the ownership (the PI
71 * protos only get deleted when the proto document is deleted)
73 const nsTArray<nsRefPtr<nsXULPrototypePI> >& GetProcessingInstructions() const;
75 /**
76 * Access the array of style overlays for this document.
78 * Style overlays are stylesheets that need to be applied to the
79 * document, but are not referenced from within the document. They
80 * are currently obtained from the chrome registry via
81 * nsIXULOverlayProvider::getStyleOverlays.)
83 void AddStyleSheetReference(nsIURI* aStyleSheet);
84 const nsCOMArray<nsIURI>& GetStyleSheetReferences() const;
86 /**
87 * Access HTTP header data.
88 * @note Not implemented.
90 NS_IMETHOD GetHeaderData(nsIAtom* aField, nsAString& aData) const;
91 NS_IMETHOD SetHeaderData(nsIAtom* aField, const nsAString& aData);
93 nsIPrincipal *DocumentPrincipal();
94 void SetDocumentPrincipal(nsIPrincipal *aPrincipal);
96 /**
97 * If current prototype document has not yet finished loading,
98 * appends aDocument to the list of documents to notify (via
99 * XULDocument::OnPrototypeLoadDone()) and sets aLoaded to false.
100 * Otherwise sets aLoaded to true.
102 nsresult AwaitLoadDone(mozilla::dom::XULDocument* aDocument, bool* aResult);
105 * Notifies each document registered via AwaitLoadDone on this
106 * prototype document that the prototype has finished loading.
107 * The notification is performed by calling
108 * nsIXULDocument::OnPrototypeLoadDone on the registered documents.
110 nsresult NotifyLoadDone();
112 nsNodeInfoManager *GetNodeInfoManager();
114 void MarkInCCGeneration(uint32_t aCCGeneration);
116 NS_DECL_CYCLE_COLLECTION_CLASS(nsXULPrototypeDocument)
118 void TraceProtos(JSTracer* aTrc, uint32_t aGCNumber);
120 protected:
121 nsCOMPtr<nsIURI> mURI;
122 nsRefPtr<nsXULPrototypeElement> mRoot;
123 nsTArray<nsRefPtr<nsXULPrototypePI> > mProcessingInstructions;
124 nsCOMArray<nsIURI> mStyleSheetReferences;
126 bool mLoaded;
127 nsTArray< nsRefPtr<mozilla::dom::XULDocument> > mPrototypeWaiters;
129 nsRefPtr<nsNodeInfoManager> mNodeInfoManager;
131 uint32_t mCCGeneration;
132 uint32_t mGCNumber;
134 nsXULPrototypeDocument();
135 virtual ~nsXULPrototypeDocument();
136 nsresult Init();
138 friend NS_IMETHODIMP
139 NS_NewXULPrototypeDocument(nsXULPrototypeDocument** aResult);
141 static uint32_t gRefCnt;
144 #endif // nsXULPrototypeDocument_h__