Back to index

lightning-sunbird  0.9+nobinonly
nsIDocument.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #ifndef nsIDocument_h___
00038 #define nsIDocument_h___
00039 
00040 #include "nsISupports.h"
00041 #include "nsEvent.h"
00042 #include "nsString.h"
00043 #include "nsCOMArray.h"
00044 #include "nsIDocumentObserver.h"
00045 #include "nsCOMPtr.h"
00046 #include "nsIURI.h"
00047 #include "nsIBindingManager.h"
00048 #include "nsWeakPtr.h"
00049 #include "nsIWeakReferenceUtils.h"
00050 #include "nsILoadGroup.h"
00051 #include "nsReadableUtils.h"
00052 #include "nsCRT.h"
00053 #include "mozFlushType.h"
00054 #include "nsPropertyTable.h"
00055 #include "nsHashSets.h"
00056 #include "nsAutoPtr.h"
00057 
00058 class nsIAtom;
00059 class nsIContent;
00060 class nsPresContext;
00061 class nsIPresShell;
00062 
00063 class nsIStreamListener;
00064 class nsIStreamObserver;
00065 class nsStyleSet;
00066 class nsIStyleSheet;
00067 class nsIStyleRule;
00068 class nsIViewManager;
00069 class nsIScriptGlobalObject;
00070 class nsPIDOMWindow;
00071 class nsIDOMEvent;
00072 class nsIDeviceContext;
00073 class nsIParser;
00074 class nsIDOMNode;
00075 class nsIDOMDocumentFragment;
00076 class nsILineBreaker;
00077 class nsIWordBreaker;
00078 class nsISelection;
00079 class nsIChannel;
00080 class nsIPrincipal;
00081 class nsIDOMDocument;
00082 class nsIDOMDocumentType;
00083 class nsIObserver;
00084 class nsISupportsArray;
00085 class nsIScriptLoader;
00086 class nsIContentSink;
00087 class nsIScriptEventManager;
00088 class nsNodeInfoManager;
00089 class nsICSSLoader;
00090 class nsHTMLStyleSheet;
00091 class nsIHTMLCSSStyleSheet;
00092 class nsILayoutHistoryState;
00093 
00094 // IID for the nsIDocument interface
00095 #define NS_IDOCUMENT_IID      \
00096 { 0xd7c47f55, 0x480b, 0x4a60, \
00097   { 0x9a, 0xdf, 0xca, 0x49, 0x87, 0x3c, 0x71, 0xe2 } }
00098 
00099 // The base value for the content ID counter.
00100 // This counter is used by the document to 
00101 // assign a monotonically increasing ID to each content
00102 // object it creates
00103 #define NS_CONTENT_ID_COUNTER_BASE 10000
00104 
00105 
00106 // Flag for AddStyleSheet().
00107 #define NS_STYLESHEET_FROM_CATALOG                (1 << 0)
00108 
00109 //----------------------------------------------------------------------
00110 
00111 // Document interface
00112 class nsIDocument : public nsISupports
00113 {
00114 public:
00115   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_IID)
00116   NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
00117 
00118   nsIDocument()
00119     : mCharacterSet(NS_LITERAL_CSTRING("ISO-8859-1")),
00120       mNextContentID(NS_CONTENT_ID_COUNTER_BASE),
00121       mNodeInfoManager(nsnull),
00122       mPartID(0)
00123   {
00124   }
00125 
00126   virtual nsresult StartDocumentLoad(const char* aCommand,
00127                                      nsIChannel* aChannel,
00128                                      nsILoadGroup* aLoadGroup,
00129                                      nsISupports* aContainer,
00130                                      nsIStreamListener **aDocListener,
00131                                      PRBool aReset,
00132                                      nsIContentSink* aSink = nsnull) = 0;
00133 
00134   virtual void StopDocumentLoad() = 0;
00135 
00139   const nsAFlatString& GetDocumentTitle() const
00140   {
00141     return mDocumentTitle;
00142   }
00143 
00147   nsIURI* GetDocumentURI() const
00148   {
00149     return mDocumentURI;
00150   }
00151   void SetDocumentURI(nsIURI* aURI)
00152   {
00153     mDocumentURI = aURI;
00154   }
00155 
00159   virtual nsIPrincipal* GetPrincipal() = 0;
00160 
00164   virtual void SetPrincipal(nsIPrincipal *aPrincipal) = 0;
00165 
00169   already_AddRefed<nsILoadGroup> GetDocumentLoadGroup() const
00170   {
00171     nsILoadGroup *group = nsnull;
00172     if (mDocumentLoadGroup)
00173       CallQueryReferent(mDocumentLoadGroup.get(), &group);
00174 
00175     return group;
00176   }
00177 
00183   nsIURI* GetBaseURI() const
00184   {
00185     return mDocumentBaseURI ? mDocumentBaseURI : mDocumentURI;
00186   }
00187   virtual nsresult SetBaseURI(nsIURI* aURI) = 0;
00188 
00192   virtual void GetBaseTarget(nsAString &aBaseTarget) const = 0;
00193   virtual void SetBaseTarget(const nsAString &aBaseTarget) = 0;
00194 
00200   const nsAFlatCString& GetDocumentCharacterSet() const
00201   {
00202     return mCharacterSet;
00203   }
00204 
00209   virtual void SetDocumentCharacterSet(const nsACString& aCharSetID) = 0;
00210 
00211   PRInt32 GetDocumentCharacterSetSource() const
00212   {
00213     return mCharacterSetSource;
00214   }
00215 
00216   void SetDocumentCharacterSetSource(PRInt32 aCharsetSource)
00217   {
00218     mCharacterSetSource = aCharsetSource;
00219   }
00220 
00224   virtual nsresult AddCharSetObserver(nsIObserver* aObserver) = 0;
00225 
00229   virtual void RemoveCharSetObserver(nsIObserver* aObserver) = 0;
00230 
00236   NS_IMETHOD GetContentType(nsAString& aContentType) = 0;
00237 
00241   virtual void SetContentType(const nsAString& aContentType) = 0;
00242 
00246   void GetContentLanguage(nsAString& aContentLanguage) const
00247   {
00248     CopyASCIItoUCS2(mContentLanguage, aContentLanguage);
00249   }
00250 
00251   // The state BidiEnabled should persist across multiple views
00252   // (screen, print) of the same document.
00253 
00258   PRBool GetBidiEnabled() const
00259   {
00260     return mBidiEnabled;
00261   }
00262 
00269   void SetBidiEnabled(PRBool aBidiEnabled)
00270   {
00271     mBidiEnabled = aBidiEnabled;
00272   }
00273 
00277   virtual nsILineBreaker* GetLineBreaker() = 0;
00278   virtual void SetLineBreaker(nsILineBreaker* aLineBreaker) = 0;
00279   virtual nsIWordBreaker* GetWordBreaker() = 0;
00280   virtual void SetWordBreaker(nsIWordBreaker* aWordBreaker) = 0;
00281 
00286   virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const = 0;
00287   virtual void SetHeaderData(nsIAtom* aheaderField, const nsAString& aData) = 0;
00288 
00294   virtual nsresult CreateShell(nsPresContext* aContext,
00295                                nsIViewManager* aViewManager,
00296                                nsStyleSet* aStyleSet,
00297                                nsIPresShell** aInstancePtrResult) = 0;
00298   virtual PRBool DeleteShell(nsIPresShell* aShell) = 0;
00299   virtual PRUint32 GetNumberOfShells() const = 0;
00300   virtual nsIPresShell *GetShellAt(PRUint32 aIndex) const = 0;
00301 
00307   nsIDocument *GetParentDocument() const
00308   {
00309     return mParentDocument;
00310   }
00311 
00315   void SetParentDocument(nsIDocument* aParent)
00316   {
00317     mParentDocument = aParent;
00318   }
00319 
00323   virtual nsresult SetSubDocumentFor(nsIContent *aContent,
00324                                      nsIDocument* aSubDoc) = 0;
00325 
00329   virtual nsIDocument *GetSubDocumentFor(nsIContent *aContent) const = 0;
00330 
00334   virtual nsIContent *FindContentForSubDocument(nsIDocument *aDocument) const = 0;
00335 
00339   nsIContent *GetRootContent() const
00340   {
00341     return mRootContent;
00342   }
00343 
00354   virtual nsresult SetRootContent(nsIContent* aRoot) = 0;
00355 
00360   virtual nsIContent *GetChildAt(PRUint32 aIndex) const = 0;
00361   virtual PRInt32 IndexOf(nsIContent* aPossibleChild) const = 0;
00362   virtual PRUint32 GetChildCount() const = 0;
00363 
00375   virtual PRInt32 GetNumberOfStyleSheets() const = 0;
00376   
00383   virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex) const = 0;
00384   
00392   virtual void InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex) = 0;
00393 
00400   virtual PRInt32 GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const = 0;
00401 
00410   virtual void UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
00411                                  nsCOMArray<nsIStyleSheet>& aNewSheets) = 0;
00412 
00416   virtual void AddStyleSheet(nsIStyleSheet* aSheet) = 0;
00417 
00421   virtual void RemoveStyleSheet(nsIStyleSheet* aSheet) = 0;
00422 
00427   virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
00428                                             PRBool aApplicable) = 0;  
00429 
00434   virtual PRInt32 GetNumberOfCatalogStyleSheets() const = 0;
00435   virtual nsIStyleSheet* GetCatalogStyleSheetAt(PRInt32 aIndex) const = 0;
00436   virtual void AddCatalogStyleSheet(nsIStyleSheet* aSheet) = 0;
00437   virtual void EnsureCatalogStyleSheet(const char *aStyleSheetURI) = 0;
00438 
00442   nsICSSLoader* CSSLoader() const {
00443     return mCSSLoader;
00444   }
00445 
00451   virtual nsIChannel* GetChannel() const = 0;
00452 
00457   virtual nsHTMLStyleSheet* GetAttributeStyleSheet() const = 0;
00458 
00463   virtual nsIHTMLCSSStyleSheet* GetInlineStyleSheet() const = 0;
00464   
00471   virtual nsIScriptGlobalObject* GetScriptGlobalObject() const = 0;
00472   virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) = 0;
00473 
00477   virtual nsPIDOMWindow *GetWindow() = 0;
00478 
00482   virtual nsIScriptLoader* GetScriptLoader() = 0;
00483 
00484   //----------------------------------------------------------------------
00485 
00486   // Document notification API's
00487 
00493   virtual void AddObserver(nsIDocumentObserver* aObserver) = 0;
00494 
00499   virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver) = 0;
00500 
00501   // Observation hooks used to propagate notifications to document observers.
00502   // BeginUpdate must be called before any batch of modifications of the
00503   // content model or of style data, EndUpdate must be called afterward.
00504   // To make this easy and painless, use the mozAutoDocUpdate helper class.
00505   virtual void BeginUpdate(nsUpdateType aUpdateType) = 0;
00506   virtual void EndUpdate(nsUpdateType aUpdateType) = 0;
00507   virtual void BeginLoad() = 0;
00508   virtual void EndLoad() = 0;
00509   virtual void CharacterDataChanged(nsIContent* aContent, PRBool aAppend) = 0;
00510   // notify that one or two content nodes changed state
00511   // either may be nsnull, but not both
00512   virtual void ContentStatesChanged(nsIContent* aContent1,
00513                                     nsIContent* aContent2,
00514                                     PRInt32 aStateMask) = 0;
00515   virtual void AttributeWillChange(nsIContent* aChild,
00516                                    PRInt32 aNameSpaceID,
00517                                    nsIAtom* aAttribute) = 0;
00518   virtual void AttributeChanged(nsIContent* aChild,
00519                                 PRInt32 aNameSpaceID,
00520                                 nsIAtom* aAttribute,
00521                                 PRInt32 aModType) = 0;
00522   virtual void ContentAppended(nsIContent* aContainer,
00523                                PRInt32 aNewIndexInContainer) = 0;
00524   virtual void ContentInserted(nsIContent* aContainer,
00525                                nsIContent* aChild,
00526                                PRInt32 aIndexInContainer) = 0;
00527   virtual void ContentRemoved(nsIContent* aContainer,
00528                               nsIContent* aChild,
00529                               PRInt32 aIndexInContainer) = 0;
00530 
00531   // Observation hooks for style data to propagate notifications
00532   // to document observers
00533   virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet,
00534                                 nsIStyleRule* aOldStyleRule,
00535                                 nsIStyleRule* aNewStyleRule) = 0;
00536   virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet,
00537                               nsIStyleRule* aStyleRule) = 0;
00538   virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
00539                                 nsIStyleRule* aStyleRule) = 0;
00540 
00541   virtual nsresult HandleDOMEvent(nsPresContext* aPresContext,
00542                                   nsEvent* aEvent, nsIDOMEvent** aDOMEvent,
00543                                   PRUint32 aFlags,
00544                                   nsEventStatus* aEventStatus) = 0;
00545 
00550   virtual void FlushPendingNotifications(mozFlushType aType) = 0;
00551 
00552   PRInt32 GetAndIncrementContentID()
00553   {
00554     return mNextContentID++;
00555   }
00556 
00557   nsIBindingManager* BindingManager() const
00558   {
00559     return mBindingManager;
00560   }
00561 
00566   nsNodeInfoManager* NodeInfoManager() const
00567   {
00568     return mNodeInfoManager;
00569   }
00570 
00575   virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) = 0;
00576 
00580   virtual void ResetToURI(nsIURI *aURI, nsILoadGroup* aLoadGroup) = 0;
00581 
00585   void SetContainer(nsISupports *aContainer)
00586   {
00587     mDocumentContainer = do_GetWeakReference(aContainer);
00588   }
00589 
00593   already_AddRefed<nsISupports> GetContainer() const
00594   {
00595     nsISupports* container = nsnull;
00596     if (mDocumentContainer)
00597       CallQueryReferent(mDocumentContainer.get(), &container);
00598 
00599     return container;
00600   }
00601 
00602   virtual nsIScriptEventManager* GetScriptEventManager() = 0;
00603 
00610   virtual void SetXMLDeclaration(const PRUnichar *aVersion,
00611                                  const PRUnichar *aEncoding,
00612                                  const PRInt32 aStandalone) = 0;
00613   virtual void GetXMLDeclaration(nsAString& aVersion,
00614                                  nsAString& aEncoding,
00615                                  nsAString& Standalone) = 0;
00616 
00617   virtual PRBool IsCaseSensitive()
00618   {
00619     return PR_TRUE;
00620   }
00621 
00622   virtual PRBool IsScriptEnabled() = 0;
00623 
00624   virtual nsresult AddXMLEventsContent(nsIContent * aXMLEventsElement) = 0;
00625 
00626   virtual PRBool IsLoadedAsData()
00627   {
00628     return PR_FALSE;
00629   }
00630 
00637   virtual nsresult CreateElem(nsIAtom *aName, nsIAtom *aPrefix,
00638                               PRInt32 aNamespaceID,
00639                               PRBool aDocumentDefaultType,
00640                               nsIContent** aResult) = 0;
00641 
00649   nsISupports *GetSecurityInfo()
00650   {
00651     return mSecurityInfo;
00652   }
00653 
00658   virtual PRInt32 GetDefaultNamespaceID() const = 0;
00659 
00660   virtual void* GetProperty(nsIAtom *aPropertyName,
00661                             nsresult *aStatus = nsnull) const = 0;
00662 
00663   virtual nsresult SetProperty(nsIAtom            *aPropertyName,
00664                                void               *aValue,
00665                                NSPropertyDtorFunc  aDtor = nsnull) = 0;
00666 
00667   virtual nsresult DeleteProperty(nsIAtom *aPropertyName) = 0;
00668 
00669   virtual void* UnsetProperty(nsIAtom  *aPropertyName,
00670                               nsresult *aStatus = nsnull) = 0;
00671 
00672   nsPropertyTable* PropertyTable() { return &mPropertyTable; }
00673 
00677   void SetPartID(PRUint32 aID) {
00678     mPartID = aID;
00679   }
00680 
00684   PRUint32 GetPartID() const {
00685     return mPartID;
00686   }
00687 
00692   virtual nsresult Sanitize() = 0;
00693 
00699   typedef PRBool (*nsSubDocEnumFunc)(nsIDocument *aDocument, void *aData);
00700   virtual void EnumerateSubDocuments(nsSubDocEnumFunc aCallback,
00701                                      void *aData) = 0;
00702 
00720   virtual PRBool CanSavePresentation(nsIRequest *aNewRequest) = 0;
00721 
00727   virtual void Destroy() = 0;
00728 
00734   virtual already_AddRefed<nsILayoutHistoryState> GetLayoutHistoryState() const = 0;
00735 
00744   virtual void BlockOnload() = 0;
00745   virtual void UnblockOnload() = 0;
00746 
00755   virtual void OnPageShow(PRBool aPersisted) = 0;
00756 
00765   virtual void OnPageHide(PRBool aPersisted) = 0;
00766   
00767   /*
00768    * We record the set of links in the document that are relevant to
00769    * style.
00770    */
00775   virtual void AddStyleRelevantLink(nsIContent* aContent, nsIURI* aURI) = 0;
00782   virtual void ForgetLink(nsIContent* aContent) = 0;
00787   virtual void NotifyURIVisitednessChanged(nsIURI* aURI) = 0;
00788 
00789 protected:
00790   ~nsIDocument()
00791   {
00792     // XXX The cleanup of mNodeInfoManager (calling DropDocumentReference and
00793     //     releasing it) happens in the nsDocument destructor. We'd prefer to
00794     //     do it here but nsNodeInfoManager is a concrete class that we don't
00795     //     want to expose to users of the nsIDocument API outside of Gecko.
00796   }
00797 
00798   nsString mDocumentTitle;
00799   nsCOMPtr<nsIURI> mDocumentURI;
00800   nsCOMPtr<nsIURI> mDocumentBaseURI;
00801 
00802   nsWeakPtr mDocumentLoadGroup;
00803 
00804   nsWeakPtr mDocumentContainer;
00805 
00806   nsCString mCharacterSet;
00807   PRInt32 mCharacterSetSource;
00808 
00809   // This is just a weak pointer; the parent document owns its children.
00810   nsIDocument* mParentDocument;
00811 
00812   // A weak reference to the only child element, or null if no
00813   // such element exists.
00814   nsIContent* mRootContent;
00815 
00816   // A content ID counter used to give a monotonically increasing ID
00817   // to the content objects in the document's content model
00818   PRInt32 mNextContentID;
00819 
00820   nsCOMPtr<nsIBindingManager> mBindingManager;
00821   nsNodeInfoManager* mNodeInfoManager; // [STRONG]
00822 
00823   nsICSSLoader* mCSSLoader; // [STRONG; not a COMPtr to avoid
00824                             // including nsICSSLoader.h; the ownership
00825                             // is managed by nsDocument]
00826 
00827   // Table of element properties for this document.
00828   nsPropertyTable mPropertyTable;
00829 
00830   // True if BIDI is enabled.
00831   PRBool mBidiEnabled;
00832 
00833   nsXPIDLCString mContentLanguage;
00834   nsCString mContentType;
00835 
00836   // The document's security info
00837   nsCOMPtr<nsISupports> mSecurityInfo;
00838 
00839   // if this document is part of a multipart document,
00840   // the ID can be used to distinguish it from the other parts.
00841   PRUint32 mPartID;
00842 };
00843 
00844 // IID for the nsIDocument_MOZILLA_1_8_0_BRANCH interface
00845 #define NS_IDOCUMENT_MOZILLA_1_8_0_BRANCH_IID      \
00846 { 0x7d001ad2, 0x01ac, 0x4bf2, \
00847   { 0xb8, 0x3a, 0x50, 0xaa, 0xed, 0xc6, 0x1d, 0xfa } }
00848 
00849 class nsIDocument_MOZILLA_1_8_0_BRANCH : public nsISupports
00850 {
00851 public:
00852   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_MOZILLA_1_8_0_BRANCH_IID)
00853 
00854   
00861   virtual nsIScriptGlobalObject* GetScopeObject() = 0;
00862 
00870   virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify) = 0;
00871 };
00872 
00873 // IID for the nsIDocument_MOZILLA_1_8_BRANCH2 interface
00874 #define NS_IDOCUMENT_MOZILLA_1_8_BRANCH2_IID      \
00875 { 0x095024b5, 0x57d1, 0x4117, \
00876  { 0xb6, 0x02, 0x5c, 0x6d, 0xf2, 0x81, 0xe0, 0xba } }
00877 
00878 class nsIDocument_MOZILLA_1_8_BRANCH2 : public nsISupports
00879 {
00880 public:
00881   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_MOZILLA_1_8_BRANCH2_IID)
00882 
00883   nsIDocument_MOZILLA_1_8_BRANCH2() :
00884     mIsInitialDocumentInWindow(PR_FALSE)
00885   {
00886   }
00887 
00891   PRBool IsInitialDocument() const
00892   {
00893     return mIsInitialDocumentInWindow;
00894   }
00895   
00900   void SetIsInitialDocument(PRBool aIsInitialDocument)
00901   {
00902     mIsInitialDocumentInWindow = aIsInitialDocument;
00903   }
00904 
00905 protected:   
00906   // True if this document is the initial document for a window.  This should
00907   // basically be true only for documents that exist in newly-opened windows or
00908   // documents created to satisfy a GetDocument() on a window when there's no
00909   // document in it.
00910   PRBool mIsInitialDocumentInWindow;
00911 };
00912 
00913 #define NS_IDOCUMENT_MOZILLA_1_8_BRANCH3_IID      \
00914 { 0x23da8ffb, 0x095d, 0x4215, \
00915   { 0x9a, 0x93, 0x3e, 0x0f, 0xe4, 0x10, 0x89, 0x0b } }
00916 
00917 class nsIDocument_MOZILLA_1_8_BRANCH3 : public nsISupports
00918 {
00919 public:
00920   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_MOZILLA_1_8_BRANCH3_IID)
00930   virtual nsIScriptGlobalObject*
00931     GetScriptHandlingObject(PRBool& aHasHadScriptHandlingObject) const = 0;
00932   virtual void SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject) = 0;
00933 protected:
00934 
00935 };
00936 
00944 class mozAutoDocUpdate
00945 {
00946 public:
00947   mozAutoDocUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType,
00948                    PRBool aNotify) :
00949     mDocument(aNotify ? aDocument : nsnull),
00950     mUpdateType(aUpdateType)
00951   {
00952     if (mDocument) {
00953       mDocument->BeginUpdate(mUpdateType);
00954     }
00955   }
00956 
00957   ~mozAutoDocUpdate()
00958   {
00959     if (mDocument) {
00960       mDocument->EndUpdate(mUpdateType);
00961     }
00962   }
00963 
00964 private:
00965   nsCOMPtr<nsIDocument> mDocument;
00966   nsUpdateType mUpdateType;
00967 };
00968 
00969 // XXX These belong somewhere else
00970 nsresult
00971 NS_NewHTMLDocument(nsIDocument** aInstancePtrResult);
00972 
00973 nsresult
00974 NS_NewXMLDocument(nsIDocument** aInstancePtrResult);
00975 
00976 #ifdef MOZ_SVG
00977 nsresult
00978 NS_NewSVGDocument(nsIDocument** aInstancePtrResult);
00979 #endif
00980 
00981 nsresult
00982 NS_NewImageDocument(nsIDocument** aInstancePtrResult);
00983 
00984 nsresult
00985 NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
00986                        nsNodeInfoManager *aNodeInfoManager);
00987 nsresult
00988 NS_NewDOMDocument_MOZILLA_1_8_BRANCH(nsIDOMDocument** aInstancePtrResult,
00989                                      const nsAString& aNamespaceURI,
00990                                      const nsAString& aQualifiedName,
00991                                      nsIDOMDocumentType* aDoctype,
00992                                      nsIURI* aBaseURI,
00993                                      nsIScriptGlobalObject* aScriptHandler,
00994                                      PRBool aLoadedAsData);
00995 
00996 nsresult
00997 NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
00998                   const nsAString& aNamespaceURI, 
00999                   const nsAString& aQualifiedName, 
01000                   nsIDOMDocumentType* aDoctype,
01001                   nsIURI* aBaseURI);
01002 nsresult
01003 NS_NewPluginDocument(nsIDocument** aInstancePtrResult);
01004 
01005 #endif /* nsIDocument_h___ */