LCOV - code coverage report
Current view: top level - dom/xul - nsXULPrototypeDocument.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 1 100.0 %
Date: 2017-07-14 16:53:18 Functions: 2 7 28.6 %
Legend: Lines: hit not hit

          Line data    Source code
       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/. */
       5             : 
       6             : #ifndef nsXULPrototypeDocument_h__
       7             : #define nsXULPrototypeDocument_h__
       8             : 
       9             : #include "js/TracingAPI.h"
      10             : #include "mozilla/Attributes.h"
      11             : #include "nsCOMArray.h"
      12             : #include "nsCOMPtr.h"
      13             : #include "nsTArray.h"
      14             : #include "nsISerializable.h"
      15             : #include "nsCycleCollectionParticipant.h"
      16             : 
      17             : class nsIAtom;
      18             : class nsIPrincipal;
      19             : class nsIURI;
      20             : class nsNodeInfoManager;
      21             : class nsXULPrototypeElement;
      22             : class nsXULPrototypePI;
      23             : 
      24             : namespace mozilla {
      25             : namespace dom {
      26             : class XULDocument;
      27             : } // namespace dom
      28             : } // namespace mozilla
      29             : 
      30             : /**
      31             :  * A "prototype" document that stores shared document information
      32             :  * for the XUL cache.
      33             :  * Among other things, stores the tree of nsXULPrototype*
      34             :  * objects, from which the real DOM tree is built later in
      35             :  * XULDocument::ResumeWalk.
      36             :  */
      37             : class nsXULPrototypeDocument final : public nsISerializable
      38             : {
      39             : public:
      40             :     static nsresult
      41             :     Create(nsIURI* aURI, nsXULPrototypeDocument** aResult);
      42             : 
      43             :     // nsISupports interface
      44             :     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      45             : 
      46             :     // nsISerializable interface
      47             :     NS_DECL_NSISERIALIZABLE
      48             : 
      49             :     nsresult InitPrincipal(nsIURI* aURI, nsIPrincipal* aPrincipal);
      50             :     nsIURI* GetURI();
      51             : 
      52             :     /**
      53             :      * Get/set the root nsXULPrototypeElement of the document.
      54             :      */
      55             :     nsXULPrototypeElement* GetRootElement();
      56             :     void SetRootElement(nsXULPrototypeElement* aElement);
      57             : 
      58             :     /**
      59             :      * Add a processing instruction to the prolog. Note that only
      60             :      * PI nodes are currently stored in a XUL prototype document's
      61             :      * prolog and that they're handled separately from the rest of
      62             :      * prototype node tree.
      63             :      *
      64             :      * @param aPI an already adrefed PI proto to add. This method takes
      65             :      *            ownership of the passed PI.
      66             :      */
      67             :     nsresult AddProcessingInstruction(nsXULPrototypePI* aPI);
      68             :     /**
      69             :      * @note GetProcessingInstructions retains the ownership (the PI
      70             :      *       protos only get deleted when the proto document is deleted)
      71             :      */
      72             :     const nsTArray<RefPtr<nsXULPrototypePI> >& GetProcessingInstructions() const;
      73             : 
      74             :     /**
      75             :      * Access the array of style overlays for this document.
      76             :      *
      77             :      * Style overlays are stylesheets that need to be applied to the
      78             :      * document, but are not referenced from within the document. They
      79             :      * are currently obtained from the chrome registry via
      80             :      * nsIXULOverlayProvider::getStyleOverlays.)
      81             :      */
      82             :     void AddStyleSheetReference(nsIURI* aStyleSheet);
      83             :     const nsCOMArray<nsIURI>& GetStyleSheetReferences() const;
      84             : 
      85             :     /**
      86             :      * Access HTTP header data.
      87             :      * @note Not implemented.
      88             :      */
      89             :     NS_IMETHOD GetHeaderData(nsIAtom* aField, nsAString& aData) const;
      90             :     NS_IMETHOD SetHeaderData(nsIAtom* aField, const nsAString& aData);
      91             : 
      92             :     nsIPrincipal *DocumentPrincipal();
      93             :     void SetDocumentPrincipal(nsIPrincipal *aPrincipal);
      94             : 
      95             :     /**
      96             :      * If current prototype document has not yet finished loading,
      97             :      * appends aDocument to the list of documents to notify (via
      98             :      * XULDocument::OnPrototypeLoadDone()) and sets aLoaded to false.
      99             :      * Otherwise sets aLoaded to true.
     100             :      */
     101             :     nsresult AwaitLoadDone(mozilla::dom::XULDocument* aDocument, bool* aResult);
     102             : 
     103             :     /**
     104             :      * Notifies each document registered via AwaitLoadDone on this
     105             :      * prototype document that the prototype has finished loading.
     106             :      * The notification is performed by calling
     107             :      * nsIXULDocument::OnPrototypeLoadDone on the registered documents.
     108             :      */
     109             :     nsresult NotifyLoadDone();
     110             : 
     111             :     nsNodeInfoManager *GetNodeInfoManager();
     112             : 
     113             :     void MarkInCCGeneration(uint32_t aCCGeneration);
     114             : 
     115          44 :     NS_DECL_CYCLE_COLLECTION_CLASS(nsXULPrototypeDocument)
     116             : 
     117             :     void TraceProtos(JSTracer* aTrc, uint32_t aGCNumber);
     118             : 
     119             : protected:
     120             :     nsCOMPtr<nsIURI> mURI;
     121             :     RefPtr<nsXULPrototypeElement> mRoot;
     122             :     nsTArray<RefPtr<nsXULPrototypePI> > mProcessingInstructions;
     123             :     nsCOMArray<nsIURI> mStyleSheetReferences;
     124             : 
     125             :     bool mLoaded;
     126             :     nsTArray< RefPtr<mozilla::dom::XULDocument> > mPrototypeWaiters;
     127             : 
     128             :     RefPtr<nsNodeInfoManager> mNodeInfoManager;
     129             : 
     130             :     uint32_t mCCGeneration;
     131             :     uint32_t mGCNumber;
     132             : 
     133             :     nsXULPrototypeDocument();
     134             :     virtual ~nsXULPrototypeDocument();
     135             :     nsresult Init();
     136             : 
     137             :     friend NS_IMETHODIMP
     138             :     NS_NewXULPrototypeDocument(nsXULPrototypeDocument** aResult);
     139             : 
     140             :     static uint32_t gRefCnt;
     141             : };
     142             : 
     143             : #endif // nsXULPrototypeDocument_h__

Generated by: LCOV version 1.13