2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
// nsISupports interface
|
2007-03-08 14:17:16 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
// nsISerializable interface
|
|
|
|
NS_DECL_NSISERIALIZABLE
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
nsresult InitPrincipal(nsIURI* aURI, nsIPrincipal* aPrincipal);
|
|
|
|
nsIURI* GetURI();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
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);
|
2018-11-30 13:46:48 +03: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;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2007-03-12 08:53:33 +03:00
|
|
|
nsIPrincipal* DocumentPrincipal();
|
2006-12-22 19:11:16 +03:00
|
|
|
void SetDocumentPrincipal(nsIPrincipal* aPrincipal);
|
2018-11-30 13:46:48 +03: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);
|
2018-11-30 13:46:48 +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
|
2018-01-31 22:49:29 +03:00
|
|
|
* XULDocument::OnPrototypeLoadDone on the registered documents.
|
2006-11-12 01:27:00 +03:00
|
|
|
*/
|
2006-12-22 19:11:16 +03:00
|
|
|
nsresult NotifyLoadDone();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
nsNodeInfoManager* GetNodeInfoManager();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-08-20 03:24:28 +04:00
|
|
|
void MarkInCCGeneration(uint32_t aCCGeneration);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-08-20 03:24:27 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(nsXULPrototypeDocument)
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-14 20:10:30 +03:00
|
|
|
void TraceProtos(JSTracer* aTrc);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
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;
|
2018-11-30 13:46:48 +03: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;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsNodeInfoManager> mNodeInfoManager;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mCCGeneration;
|
2012-08-25 00:22:23 +04:00
|
|
|
uint32_t mGCNumber;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
nsXULPrototypeDocument();
|
|
|
|
virtual ~nsXULPrototypeDocument();
|
|
|
|
nsresult Init();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2006-12-22 19:11:16 +03:00
|
|
|
friend NS_IMETHODIMP NS_NewXULPrototypeDocument(
|
|
|
|
nsXULPrototypeDocument** aResult);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
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__
|