2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-10-29 05:21:15 +04:00
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
#ifndef nsXULPrototypeDocument_h__
|
|
|
|
#define nsXULPrototypeDocument_h__
|
1999-10-29 05:21:15 +04:00
|
|
|
|
2014-04-12 02:19:05 +04:00
|
|
|
#include "js/TracingAPI.h"
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2006-12-22 19:11:16 +03:00
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2006-11-12 01:27:00 +03:00
|
|
|
#include "nsTArray.h"
|
2006-12-22 19:11:16 +03:00
|
|
|
#include "nsISerializable.h"
|
2007-03-08 14:17:16 +03:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
1999-10-29 05:21:15 +04:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
class nsAtom;
|
1999-11-18 05:25:33 +03:00
|
|
|
class nsIPrincipal;
|
2000-01-23 01:00:35 +03:00
|
|
|
class nsIURI;
|
2006-12-22 19:11:16 +03:00
|
|
|
class nsNodeInfoManager;
|
1999-10-29 05:21:15 +04:00
|
|
|
class nsXULPrototypeElement;
|
2006-11-12 01:27:00 +03:00
|
|
|
class nsXULPrototypePI;
|
1999-10-29 05:21:15 +04:00
|
|
|
|
2013-03-26 19:31:53 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class XULDocument;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2006-11-12 01:27:00 +03:00
|
|
|
/**
|
|
|
|
* A "prototype" document that stores shared document information
|
|
|
|
* for the XUL cache.
|
2006-12-22 19:11:16 +03:00
|
|
|
* Among other things, stores the tree of nsXULPrototype*
|
|
|
|
* objects, from which the real DOM tree is built later in
|
2013-03-26 19:31:53 +04:00
|
|
|
* XULDocument::ResumeWalk.
|
2006-11-12 01:27:00 +03:00
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsXULPrototypeDocument final : public nsISerializable
|
1999-10-29 05:21:15 +04:00
|
|
|
{
|
|
|
|
public:
|
2006-12-22 19:11:16 +03:00
|
|
|
static nsresult
|
|
|
|
Create(nsIURI* aURI, nsXULPrototypeDocument** aResult);
|
1999-10-29 05:21:15 +04:00
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
// nsISupports interface
|
2007-03-08 14:17:16 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2006-11-22 21:27:54 +03:00
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
// nsISerializable interface
|
|
|
|
NS_DECL_NSISERIALIZABLE
|
|
|
|
|
|
|
|
nsresult InitPrincipal(nsIURI* aURI, nsIPrincipal* aPrincipal);
|
|
|
|
nsIURI* GetURI();
|
1999-10-29 05:21:15 +04:00
|
|
|
|
|
|
|
/**
|
2006-12-22 19:11:16 +03:00
|
|
|
* Get/set the root nsXULPrototypeElement of the document.
|
1999-10-29 05:21:15 +04:00
|
|
|
*/
|
2006-12-22 19:11:16 +03:00
|
|
|
nsXULPrototypeElement* GetRootElement();
|
|
|
|
void SetRootElement(nsXULPrototypeElement* aElement);
|
1999-10-29 05:21:15 +04:00
|
|
|
|
2006-11-12 01:27:00 +03:00
|
|
|
/**
|
|
|
|
* Add a processing instruction to the prolog. Note that only
|
|
|
|
* PI nodes are currently stored in a XUL prototype document's
|
|
|
|
* prolog and that they're handled separately from the rest of
|
|
|
|
* prototype node tree.
|
|
|
|
*
|
|
|
|
* @param aPI an already adrefed PI proto to add. This method takes
|
|
|
|
* ownership of the passed PI.
|
|
|
|
*/
|
2006-12-22 19:11:16 +03:00
|
|
|
nsresult AddProcessingInstruction(nsXULPrototypePI* aPI);
|
2006-11-12 01:27:00 +03:00
|
|
|
/**
|
|
|
|
* @note GetProcessingInstructions retains the ownership (the PI
|
|
|
|
* protos only get deleted when the proto document is deleted)
|
|
|
|
*/
|
2015-10-18 08:24:48 +03:00
|
|
|
const nsTArray<RefPtr<nsXULPrototypePI> >& GetProcessingInstructions() const;
|
2006-11-12 01:27:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Access the array of style overlays for this document.
|
|
|
|
*
|
2006-12-22 19:11:16 +03:00
|
|
|
* Style overlays are stylesheets that need to be applied to the
|
|
|
|
* document, but are not referenced from within the document. They
|
|
|
|
* are currently obtained from the chrome registry via
|
|
|
|
* nsIXULOverlayProvider::getStyleOverlays.)
|
2006-11-12 01:27:00 +03:00
|
|
|
*/
|
2006-12-22 19:11:16 +03:00
|
|
|
void AddStyleSheetReference(nsIURI* aStyleSheet);
|
|
|
|
const nsCOMArray<nsIURI>& GetStyleSheetReferences() const;
|
1999-10-29 05:21:15 +04:00
|
|
|
|
2006-11-12 01:27:00 +03:00
|
|
|
/**
|
|
|
|
* Access HTTP header data.
|
|
|
|
* @note Not implemented.
|
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
NS_IMETHOD GetHeaderData(nsAtom* aField, nsAString& aData) const;
|
|
|
|
NS_IMETHOD SetHeaderData(nsAtom* aField, const nsAString& aData);
|
2001-07-31 23:05:34 +04:00
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
nsIPrincipal *DocumentPrincipal();
|
2006-12-22 19:11:16 +03:00
|
|
|
void SetDocumentPrincipal(nsIPrincipal *aPrincipal);
|
2002-07-24 02:16:45 +04:00
|
|
|
|
2006-11-12 01:27:00 +03:00
|
|
|
/**
|
|
|
|
* If current prototype document has not yet finished loading,
|
|
|
|
* appends aDocument to the list of documents to notify (via
|
2013-03-26 19:31:53 +04:00
|
|
|
* XULDocument::OnPrototypeLoadDone()) and sets aLoaded to false.
|
2011-10-17 18:59:28 +04:00
|
|
|
* Otherwise sets aLoaded to true.
|
2006-11-12 01:27:00 +03:00
|
|
|
*/
|
2013-03-26 19:31:53 +04:00
|
|
|
nsresult AwaitLoadDone(mozilla::dom::XULDocument* aDocument, bool* aResult);
|
2006-12-22 19:11:16 +03:00
|
|
|
|
2006-11-12 01:27:00 +03:00
|
|
|
/**
|
|
|
|
* Notifies each document registered via AwaitLoadDone on this
|
|
|
|
* prototype document that the prototype has finished loading.
|
|
|
|
* The notification is performed by calling
|
|
|
|
* nsIXULDocument::OnPrototypeLoadDone on the registered documents.
|
|
|
|
*/
|
2006-12-22 19:11:16 +03:00
|
|
|
nsresult NotifyLoadDone();
|
|
|
|
|
|
|
|
nsNodeInfoManager *GetNodeInfoManager();
|
|
|
|
|
2013-08-20 03:24:28 +04:00
|
|
|
void MarkInCCGeneration(uint32_t aCCGeneration);
|
2011-12-29 18:34:05 +04:00
|
|
|
|
2013-08-20 03:24:27 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(nsXULPrototypeDocument)
|
2007-03-08 14:17:16 +03:00
|
|
|
|
2012-08-25 00:22:23 +04:00
|
|
|
void TraceProtos(JSTracer* aTrc, uint32_t aGCNumber);
|
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
protected:
|
|
|
|
nsCOMPtr<nsIURI> mURI;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsXULPrototypeElement> mRoot;
|
|
|
|
nsTArray<RefPtr<nsXULPrototypePI> > mProcessingInstructions;
|
2006-12-22 19:11:16 +03:00
|
|
|
nsCOMArray<nsIURI> mStyleSheetReferences;
|
1999-10-29 05:21:15 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mLoaded;
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray< RefPtr<mozilla::dom::XULDocument> > mPrototypeWaiters;
|
2001-07-31 23:05:34 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsNodeInfoManager> mNodeInfoManager;
|
2001-07-31 23:05:34 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mCCGeneration;
|
2012-08-25 00:22:23 +04:00
|
|
|
uint32_t mGCNumber;
|
2011-12-29 18:34:05 +04:00
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
nsXULPrototypeDocument();
|
|
|
|
virtual ~nsXULPrototypeDocument();
|
|
|
|
nsresult Init();
|
|
|
|
|
|
|
|
friend NS_IMETHODIMP
|
|
|
|
NS_NewXULPrototypeDocument(nsXULPrototypeDocument** aResult);
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint32_t gRefCnt;
|
2006-12-22 19:11:16 +03:00
|
|
|
};
|
1999-10-29 05:21:15 +04:00
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
#endif // nsXULPrototypeDocument_h__
|