gecko-dev/content/base/src/nsDocument.h

787 lines
26 KiB
C
Raw Normal View History

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
1998-04-13 20:24:54 +00:00
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
1998-04-13 20:24:54 +00:00
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
1998-04-13 20:24:54 +00:00
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
1998-04-13 20:24:54 +00:00
#ifndef nsDocument_h___
#define nsDocument_h___
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsCRT.h"
1998-04-13 20:24:54 +00:00
#include "nsIDocument.h"
#include "nsWeakReference.h"
#include "nsWeakPtr.h"
1998-04-13 20:24:54 +00:00
#include "nsVoidArray.h"
#include "nsHashSets.h"
#include "nsIDOMXMLDocument.h"
#include "nsIDOM3Document.h"
#include "nsIDOMDocumentView.h"
2000-06-02 08:13:29 +00:00
#include "nsIDOMDocumentXBL.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMNSDocumentStyle.h"
#include "nsIDOMDocumentRange.h"
#include "nsIDOMDocumentTraversal.h"
#include "nsStubDocumentObserver.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOM3EventTarget.h"
#include "nsIDOMNSEventTarget.h"
#include "nsIDOMStyleSheetList.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDOMEventTarget.h"
1998-08-28 15:57:59 +00:00
#include "nsIContent.h"
#include "nsIEventListenerManager.h"
#include "nsGenericDOMNodeList.h"
#include "nsIDOM3Node.h"
#include "nsIPrincipal.h"
#include "nsIParser.h"
#include "nsIBindingManager.h"
#include "nsINodeInfo.h"
#include "nsIDOMDocumentEvent.h"
#include "nsIDOM3DocumentEvent.h"
#include "nsCOMArray.h"
#include "nsHashtable.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIURI.h"
#include "nsScriptLoader.h"
#include "nsICSSLoader.h"
#include "nsIDOMXPathEvaluator.h"
#include "nsIRadioGroupContainer.h"
#include "nsIScriptEventManager.h"
#include "nsILayoutHistoryState.h"
#include "nsIRequest.h"
#include "nsILoadGroup.h"
1998-04-30 19:53:05 +00:00
2004-01-13 23:53:23 +00:00
// Put these here so all document impls get them automatically
#include "nsHTMLStyleSheet.h"
2004-01-13 23:53:23 +00:00
#include "nsIHTMLCSSStyleSheet.h"
#include "nsStyleSet.h"
#include "nsXMLEventsManager.h"
#include "pldhash.h"
#include "nsAttrAndChildArray.h"
#define XML_DECLARATION_BITS_DECLARATION_EXISTS (1 << 0)
#define XML_DECLARATION_BITS_ENCODING_EXISTS (1 << 1)
#define XML_DECLARATION_BITS_STANDALONE_EXISTS (1 << 2)
#define XML_DECLARATION_BITS_STANDALONE_YES (1 << 3)
class nsIEventListenerManager;
class nsDOMStyleSheetList;
class nsIOutputStream;
class nsDocument;
2000-08-28 23:46:11 +00:00
class nsIDTD;
class nsXPathDocumentTearoff;
class nsIRadioVisitor;
class nsIFormControl;
struct nsRadioGroupStruct;
class nsOnloadBlocker;
struct PLEvent;
PR_BEGIN_EXTERN_C
/* Note that these typedefs declare functions, not pointer to
functions. That's the only way in which they differ from
PLHandleEventProc and PLDestroyEventProc. */
typedef void*
(PR_CALLBACK EventHandlerFunc)(PLEvent* self);
typedef void
(PR_CALLBACK EventDestructorFunc)(PLEvent* self);
PR_END_EXTERN_C
/**
* Hashentry using a PRUint32 key and a cheap set of nsIContent* owning
* pointers for the value.
*
* @see nsTHashtable::EntryType for specification
*/
class nsUint32ToContentHashEntry : public PLDHashEntryHdr
{
public:
typedef const PRUint32& KeyType;
typedef const PRUint32* KeyTypePointer;
nsUint32ToContentHashEntry(const KeyTypePointer key) :
mValue(*key), mValOrHash(nsnull) { }
nsUint32ToContentHashEntry(const nsUint32ToContentHashEntry& toCopy) :
mValue(toCopy.mValue), mValOrHash(toCopy.mValOrHash)
{
// Pathetic attempt to not die: clear out the other mValOrHash so we're
// effectively stealing it. If toCopy is destroyed right after this,
// we'll be OK.
NS_CONST_CAST(nsUint32ToContentHashEntry&, toCopy).mValOrHash = nsnull;
NS_ERROR("Copying not supported. Fasten your seat belt.");
}
~nsUint32ToContentHashEntry() { Destroy(); }
KeyType GetKey() const { return mValue; }
KeyTypePointer GetKeyPointer() const { return &mValue; }
PRBool KeyEquals(KeyTypePointer aKey) const { return mValue == *aKey; }
static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
static PLDHashNumber HashKey(KeyTypePointer aKey) { return *aKey; }
enum { ALLOW_MEMMOVE = PR_TRUE };
// Content set methods
nsresult PutContent(nsIContent* aContent);
void RemoveContent(nsIContent* aContent);
struct Visitor {
virtual void Visit(nsIContent* aContent) = 0;
};
void VisitContent(Visitor* aVisitor);
PRBool IsEmpty() { return mValOrHash == nsnull; }
private:
typedef unsigned long PtrBits;
typedef nsTHashtable<nsISupportsHashKey> HashSet;
/** Get the hash pointer (or null if we're not a hash) */
HashSet* GetHashSet()
{
return (PtrBits(mValOrHash) & 0x1) ? nsnull : (HashSet*)mValOrHash;
}
/** Find out whether it is an nsIContent (returns weak) */
nsIContent* GetContent()
{
return (PtrBits(mValOrHash) & 0x1)
? (nsIContent*)(PtrBits(mValOrHash) & ~0x1)
: nsnull;
}
/** Set the single element, adding a reference */
nsresult SetContent(nsIContent* aVal)
{
NS_IF_ADDREF(aVal);
mValOrHash = (void*)(PtrBits(aVal) | 0x1);
return NS_OK;
}
/** Initialize the hash */
nsresult InitHashSet(HashSet** aSet);
void Destroy();
private:
const PRUint32 mValue;
/** A hash or nsIContent ptr, depending on the lower bit (0=hash, 1=ptr) */
void* mValOrHash;
};
class nsDocHeaderData
{
public:
nsDocHeaderData(nsIAtom* aField, const nsAString& aData)
: mField(aField), mData(aData), mNext(nsnull)
{
}
~nsDocHeaderData(void)
{
delete mNext;
}
nsCOMPtr<nsIAtom> mField;
nsString mData;
nsDocHeaderData* mNext;
};
// Represents the children of a document (prolog, epilog and
// document element)
class nsDocumentChildNodes : public nsGenericDOMNodeList
{
public:
nsDocumentChildNodes(nsIDocument* aDocument);
~nsDocumentChildNodes();
NS_IMETHOD GetLength(PRUint32* aLength);
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
void DropReference();
protected:
nsDocumentChildNodes(); // Not implemented
nsIDocument* mDocument;
};
class nsDOMStyleSheetList : public nsIDOMStyleSheetList,
public nsStubDocumentObserver
{
public:
nsDOMStyleSheetList(nsIDocument *aDocument);
virtual ~nsDOMStyleSheetList();
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMSTYLESHEETLIST
// nsIDocumentObserver
virtual void DocumentWillBeDestroyed(nsIDocument *aDocument);
virtual void StyleSheetAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
PRBool aDocumentSheet);
virtual void StyleSheetRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
PRBool aDocumentSheet);
protected:
PRInt32 mLength;
nsIDocument* mDocument;
};
class nsOnloadBlocker : public nsIRequest
{
public:
nsOnloadBlocker() {}
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUEST
private:
~nsOnloadBlocker() {}
};
// Base class for our document implementations.
//
// Note that this class *implements* nsIDOMXMLDocument, but it's not
// really an nsIDOMXMLDocument. The reason for implementing
// nsIDOMXMLDocument on this class is to avoid having to duplicate all
// its inherited methods on document classes that *are*
// nsIDOMXMLDocument's. nsDocument's QI should *not* claim to support
// nsIDOMXMLDocument unless someone writes a real implementation of
// the interface.
class nsDocument : public nsIDocument,
public nsIDOMXMLDocument, // inherits nsIDOMDocument
public nsIDOMNSDocument,
public nsIDOMDocumentEvent,
public nsIDOM3DocumentEvent,
public nsIDOMNSDocumentStyle,
public nsIDOMDocumentView,
public nsIDOMDocumentRange,
public nsIDOMDocumentTraversal,
2000-06-02 08:13:29 +00:00
public nsIDOMDocumentXBL,
public nsIDOM3Document,
public nsSupportsWeakReference,
public nsIDOMEventReceiver,
public nsIDOM3EventTarget,
public nsIDOMNSEventTarget,
public nsIScriptObjectPrincipal,
public nsIRadioGroupContainer
{
1998-04-13 20:24:54 +00:00
public:
NS_DECL_ISUPPORTS
virtual void Reset(nsIChannel *aChannel, nsILoadGroup *aLoadGroup);
virtual void ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup);
virtual nsresult StartDocumentLoad(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
nsIStreamListener **aDocListener,
PRBool aReset = PR_TRUE,
nsIContentSink* aContentSink = nsnull);
virtual void StopDocumentLoad();
Landing changes Vidur made while the tree was closed for beta1 work, here's a list of the changes. r=me [1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner [2] Cutting down the size of content. Made nsITextContent inherit from nsIContent. [3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done. dom/public/nsDOMPropEnums.h,v - bug 12559 dom/public/nsIJSScriptObject.h,v - [1] dom/public/html/MANIFEST,v - bug 12559 dom/public/html/Makefile.in,v - bug 12559 dom/public/html/makefile.win,v - bug 12559 dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544 dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559 dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559 dom/public/idl/html/HTMLInputElement.idl,v - bug 17544 dom/src/base/nsGlobalWindow.cpp,v - bug 30700 dom/src/base/nsGlobalWindow.h,v - [1] dom/src/base/nsLocation.cpp,v - [1] dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559 dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559 dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544 layout/base/public/nsIDocument.h,v - bug 27953 layout/base/public/nsITextContent.h,v - [2] layout/base/src/nsCommentNode.cpp,v - [2] layout/base/src/nsDocument.cpp,v - bug 27953 layout/base/src/nsDocument.h,v - bug 27953 layout/base/src/nsDocumentViewer.cpp,v - bug 27953 layout/base/src/nsGenericDOMDataNode.cpp,v - [3] layout/base/src/nsGenericDOMDataNode.h,v - [3] layout/base/src/nsGenericElement.cpp,v - [3] layout/base/src/nsGenericElement.h,v - [3] layout/base/src/nsNameSpaceManager.cpp,v - bug 7834 layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow layout/base/src/nsTextNode.cpp,v - [2] layout/events/src/nsEventListenerManager.cpp,v - [3] layout/events/src/nsEventListenerManager.h,v - [3] layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString layout/html/content/src/nsAttributeContent.cpp,v - [2] layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3] layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3] layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3] layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3] layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3] layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3] layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3] layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3] layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3] layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3] layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3] layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3] layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3] layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3] layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3] layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3] layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3] layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3] layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3] layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3] layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3] layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3] layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3] layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3] layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3] layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3] layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3] layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3] layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3] layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3] layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3] layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3] layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3] layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3] layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3] layout/html/content/src/nsHTMLModElement.cpp,v - [1][3] layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3] layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3] layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3] layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3] layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3] layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3] layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3] layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3] layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3] layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3] layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3] layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3] layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3] layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3] layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3] layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953 layout/html/document/src/nsHTMLDocument.h,v - bug 27953 layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2] layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2] layout/xml/content/src/nsXMLElement.h,v - [1][2] layout/xml/content/src/nsXMLEntity.cpp,v - [1][2] layout/xml/content/src/nsXMLNotation.cpp,v - [1][2] layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2] layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString rdf/content/src/nsXULDocument.cpp,v - bug 27953 rdf/content/src/nsXULDocument.h,v - bug 27953 rdf/content/src/nsXULElement.h,v - [1] xpcom/base/IIDS.h,v - bug 12559
2000-03-17 13:27:00 +00:00
/**
* Return the principal responsible for this document.
*/
virtual nsIPrincipal* GetPrincipal();
/**
* Set the principal responsible for this document.
*/
virtual void SetPrincipal(nsIPrincipal *aPrincipal);
/**
* Get the Content-Type of this document.
*/
// NS_IMETHOD GetContentType(nsAString& aContentType);
// Already declared in nsIDOMNSDocument
/**
* Set the Content-Type of this document.
*/
virtual void SetContentType(const nsAString& aContentType);
1998-10-01 21:43:49 +00:00
virtual nsresult SetBaseURI(nsIURI* aURI);
/**
* Get/Set the base target of a link in a document.
*/
virtual void GetBaseTarget(nsAString &aBaseTarget) const;
virtual void SetBaseTarget(const nsAString &aBaseTarget);
1998-04-13 20:24:54 +00:00
/**
* Return a standard name for the document's character set. This will
* trigger a startDocumentLoad if necessary to answer the question.
*/
virtual void SetDocumentCharacterSet(const nsACString& aCharSetID);
/**
* Add an observer that gets notified whenever the charset changes.
*/
virtual nsresult AddCharSetObserver(nsIObserver* aObserver);
/**
* Remove a charset observer.
*/
virtual void RemoveCharSetObserver(nsIObserver* aObserver);
/**
* Access HTTP header data (this may also get set from other sources, like
* HTML META tags).
*/
virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const;
virtual void SetHeaderData(nsIAtom* aheaderField,
const nsAString& aData);
1998-04-13 20:24:54 +00:00
/**
* Create a new presentation shell that will use aContext for
* it's presentation context (presentation context's <b>must not</b> be
* shared among multiple presentation shell's).
*/
virtual nsresult CreateShell(nsPresContext* aContext,
nsIViewManager* aViewManager,
nsStyleSet* aStyleSet,
nsIPresShell** aInstancePtrResult);
virtual PRBool DeleteShell(nsIPresShell* aShell);
virtual PRUint32 GetNumberOfShells() const;
virtual nsIPresShell *GetShellAt(PRUint32 aIndex) const;
virtual void SetShellsHidden(PRBool aHide);
virtual nsresult SetSubDocumentFor(nsIContent *aContent,
nsIDocument* aSubDoc);
virtual nsIDocument* GetSubDocumentFor(nsIContent *aContent) const;
virtual nsIContent* FindContentForSubDocument(nsIDocument *aDocument) const;
1998-04-13 20:24:54 +00:00
virtual nsresult SetRootContent(nsIContent* aRoot);
1998-04-13 20:24:54 +00:00
/**
* Get the direct children of the document - content in
* the prolog, the root content and content in the epilog.
*/
virtual nsIContent *GetChildAt(PRUint32 aIndex) const;
virtual PRInt32 IndexOf(nsIContent* aPossibleChild) const;
virtual PRUint32 GetChildCount() const;
1998-04-13 20:24:54 +00:00
/**
* Get the style sheets owned by this document.
1998-09-02 02:02:30 +00:00
* These are ordered, highest priority last
1998-04-13 20:24:54 +00:00
*/
virtual PRInt32 GetNumberOfStyleSheets() const;
virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex) const;
virtual PRInt32 GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const;
virtual void AddStyleSheet(nsIStyleSheet* aSheet);
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet);
virtual void UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
nsCOMArray<nsIStyleSheet>& aNewSheets);
2000-05-27 20:03:14 +00:00
virtual void AddStyleSheetToStyleSets(nsIStyleSheet* aSheet);
virtual void RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet);
virtual void InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex);
virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
PRBool aApplicable);
1998-04-13 20:24:54 +00:00
virtual PRInt32 GetNumberOfCatalogStyleSheets() const;
virtual nsIStyleSheet* GetCatalogStyleSheetAt(PRInt32 aIndex) const;
virtual void AddCatalogStyleSheet(nsIStyleSheet* aSheet);
virtual void EnsureCatalogStyleSheet(const char *aStyleSheetURI);
virtual nsIChannel* GetChannel() const {
return mChannel;
}
2004-01-13 23:53:23 +00:00
/**
* Get this document's attribute stylesheet. May return null if
* there isn't one.
*/
virtual nsHTMLStyleSheet* GetAttributeStyleSheet() const {
2004-01-13 23:53:23 +00:00
return mAttrStyleSheet;
}
/**
* Get this document's inline style sheet. May return null if there
* isn't one
*/
virtual nsIHTMLCSSStyleSheet* GetInlineStyleSheet() const {
2004-01-13 23:53:23 +00:00
return mStyleAttrStyleSheet;
}
/**
* Set the object from which a document can get a script context.
* This is the context within which all scripts (during document
* creation and during event handling) will run.
*/
virtual nsIScriptGlobalObject* GetScriptGlobalObject() const;
virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject);
/**
* Return the window containing the document (the outer window).
*/
virtual nsPIDOMWindow *GetWindow();
/**
* Get the script loader for this document
*/
virtual nsIScriptLoader* GetScriptLoader();
1998-04-13 20:24:54 +00:00
/**
* Add a new observer of document change notifications. Whenever
* content is changed, appended, inserted or removed the observers are
* informed.
*/
virtual void AddObserver(nsIDocumentObserver* aObserver);
/**
* Remove an observer of document change notifications. This will
* return false if the observer cannot be found.
*/
virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver);
// Observation hooks used to propagate notifications to document
// observers.
virtual void BeginUpdate(nsUpdateType aUpdateType);
virtual void EndUpdate(nsUpdateType aUpdateType);
virtual void BeginLoad();
virtual void EndLoad();
virtual void CharacterDataChanged(nsIContent* aContent,
PRBool aAppend);
virtual void ContentStatesChanged(nsIContent* aContent1,
nsIContent* aContent2,
PRInt32 aStateMask);
virtual void AttributeWillChange(nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute);
virtual void AttributeChanged(nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType);
virtual void ContentAppended(nsIContent* aContainer,
PRInt32 aNewIndexInContainer);
virtual void ContentInserted(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
virtual void ContentRemoved(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet,
nsIStyleRule* aOldStyleRule,
nsIStyleRule* aNewStyleRule);
virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet,
1998-11-26 01:34:53 +00:00
nsIStyleRule* aStyleRule);
virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule);
virtual void FlushPendingNotifications(mozFlushType aType);
virtual nsIScriptEventManager* GetScriptEventManager();
virtual void SetXMLDeclaration(const PRUnichar *aVersion,
const PRUnichar *aEncoding,
const PRInt32 aStandalone);
virtual void GetXMLDeclaration(nsAString& aVersion,
nsAString& aEncoding,
nsAString& Standalone);
virtual PRBool IsScriptEnabled();
virtual nsresult HandleDOMEvent(nsPresContext* aPresContext,
nsEvent* aEvent, nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus* aEventStatus);
virtual void OnPageShow(PRBool aPersisted);
virtual void OnPageHide(PRBool aPersisted);
// nsIRadioGroupContainer
NS_IMETHOD WalkRadioGroup(const nsAString& aName,
nsIRadioVisitor* aVisitor);
NS_IMETHOD SetCurrentRadioButton(const nsAString& aName,
nsIDOMHTMLInputElement* aRadio);
NS_IMETHOD GetCurrentRadioButton(const nsAString& aName,
nsIDOMHTMLInputElement** aRadio);
NS_IMETHOD GetPositionInGroup(nsIDOMHTMLInputElement *aRadio,
PRInt32 *aPositionIndex,
PRInt32 *aItemsInGroup);
NS_IMETHOD GetNextRadioButton(const nsAString& aName,
const PRBool aPrevious,
nsIDOMHTMLInputElement* aFocusedRadio,
nsIDOMHTMLInputElement** aRadioOut);
NS_IMETHOD AddToRadioGroup(const nsAString& aName,
nsIFormControl* aRadio);
NS_IMETHOD RemoveFromRadioGroup(const nsAString& aName,
nsIFormControl* aRadio);
// for radio group
nsresult GetRadioGroup(const nsAString& aName,
nsRadioGroupStruct **aRadioGroup);
// nsIDOMNode
NS_DECL_NSIDOMNODE
// nsIDOM3Node
NS_DECL_NSIDOM3NODE
// nsIDOMDocument
NS_DECL_NSIDOMDOCUMENT
// nsIDOM3Document
NS_DECL_NSIDOM3DOCUMENT
// nsIDOMXMLDocument
NS_DECL_NSIDOMXMLDOCUMENT
// nsIDOMNSDocument
NS_DECL_NSIDOMNSDOCUMENT
// nsIDOMDocumentEvent
NS_DECL_NSIDOMDOCUMENTEVENT
// nsIDOM3DocumentEvent
NS_DECL_NSIDOM3DOCUMENTEVENT
// nsIDOMDocumentStyle
NS_DECL_NSIDOMDOCUMENTSTYLE
1998-04-13 20:24:54 +00:00
// nsIDOMNSDocumentStyle
NS_DECL_NSIDOMNSDOCUMENTSTYLE
// nsIDOMDocumentView
NS_DECL_NSIDOMDOCUMENTVIEW
// nsIDOMDocumentRange
NS_DECL_NSIDOMDOCUMENTRANGE
2000-06-02 08:13:29 +00:00
// nsIDOMDocumentTraversal
NS_DECL_NSIDOMDOCUMENTTRAVERSAL
// nsIDOMDocumentXBL
NS_DECL_NSIDOMDOCUMENTXBL
// nsIDOMEventReceiver interface
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
NS_IMETHOD GetSystemEventGroup(nsIDOMEventGroup** aGroup);
// nsIDOMEventTarget
NS_DECL_NSIDOMEVENTTARGET
// nsIDOM3EventTarget
NS_DECL_NSIDOM3EVENTTARGET
// nsIDOMNSEventTarget
NS_DECL_NSIDOMNSEVENTTARGET
// nsIScriptObjectPrincipal
// virtual nsIPrincipal* GetPrincipal();
// Already declared in nsIDocument
virtual nsresult Init();
virtual nsresult AddXMLEventsContent(nsIContent * aXMLEventsElement);
virtual nsresult CreateElem(nsIAtom *aName, nsIAtom *aPrefix,
PRInt32 aNamespaceID,
PRBool aDocumentDefaultType,
nsIContent **aResult);
virtual NS_HIDDEN_(void*) GetProperty(nsIAtom *aPropertyName,
nsresult *aStatus = nsnull) const;
virtual NS_HIDDEN_(nsresult) SetProperty(nsIAtom *aPropertyName,
void *aValue,
NSPropertyDtorFunc aDtor = nsnull);
virtual NS_HIDDEN_(nsresult) DeleteProperty(nsIAtom *aPropertyName);
virtual NS_HIDDEN_(void*) UnsetProperty(nsIAtom *aPropertyName,
nsresult *aStatus = nsnull);
virtual NS_HIDDEN_(nsresult) Sanitize();
virtual NS_HIDDEN_(void) EnumerateSubDocuments(nsSubDocEnumFunc aCallback,
void *aData);
virtual NS_HIDDEN_(PRBool) CanSavePresentation(nsIRequest *aNewRequest);
virtual NS_HIDDEN_(void) Destroy();
virtual NS_HIDDEN_(already_AddRefed<nsILayoutHistoryState>) GetLayoutHistoryState() const;
virtual NS_HIDDEN_(void) BlockOnload();
virtual NS_HIDDEN_(void) UnblockOnload(PRBool aFireSync);
virtual NS_HIDDEN_(void) AddStyleRelevantLink(nsIContent* aContent, nsIURI* aURI);
virtual NS_HIDDEN_(void) ForgetLink(nsIContent* aContent);
virtual NS_HIDDEN_(void) NotifyURIVisitednessChanged(nsIURI* aURI);
protected:
void DispatchContentLoadedEvents();
void RetrieveRelevantHeaders(nsIChannel *aChannel);
static PRBool TryChannelCharset(nsIChannel *aChannel,
PRInt32& aCharsetSource,
nsACString& aCharset);
void UpdateLinkMap();
// Call this before the document does something that will unbind all content.
// That will stop us from resolving URIs for all links as they are removed.
void DestroyLinkMap();
nsresult doCreateShell(nsPresContext* aContext,
nsIViewManager* aViewManager, nsStyleSet* aStyleSet,
nsCompatibility aCompatMode,
nsIPresShell** aInstancePtrResult);
nsresult ResetStylesheetsToURI(nsIURI* aURI);
virtual nsStyleSet::sheetType GetAttrSheetType();
void FillStyleSet(nsStyleSet* aStyleSet);
nsresult CreateElement(nsINodeInfo *aNodeInfo, PRInt32 aElementType,
nsIContent** aResult);
// Return whether all the presshells for this document are safe to flush
PRBool IsSafeToFlush() const;
virtual PRInt32 GetDefaultNamespaceID() const
{
return kNameSpaceID_None;
};
nsDocument();
virtual ~nsDocument();
1998-04-13 20:24:54 +00:00
nsCString mReferrer;
nsString mLastModified;
nsCOMPtr<nsIPrincipal> mPrincipal;
nsVoidArray mCharSetObservers;
PLDHashTable *mSubDocuments;
// Array of owning references to all children
nsAttrAndChildArray mChildren;
// Pointer to our parser if we're currently in the process of being
// parsed into.
nsCOMPtr<nsIParser> mParser;
nsCOMArray<nsIStyleSheet> mStyleSheets;
nsCOMArray<nsIStyleSheet> mCatalogSheets;
// Basically always has at least 1 entry
nsAutoVoidArray mObservers;
// The document's script global object, the object from which the
// document can get its script context and scope. This is the
// *inner* window object.
nsCOMPtr<nsIScriptGlobalObject> mScriptGlobalObject;
nsCOMPtr<nsIEventListenerManager> mListenerManager;
nsCOMPtr<nsIDOMStyleSheetList> mDOMStyleSheets;
nsCOMPtr<nsIScriptLoader> mScriptLoader;
nsDocHeaderData* mHeaderData;
nsRefPtr<nsDocumentChildNodes> mChildNodes;
nsHashtable mRadioGroups;
// True if the document has been detached from its content viewer.
PRPackedBool mIsGoingAway:1;
// True if the document is being destroyed.
PRPackedBool mInDestructor:1;
// True if the document "page" is not hidden
PRPackedBool mVisible:1;
PRPackedBool mShellsAreHidden:1;
PRUint8 mXMLDeclarationBits;
PRUint8 mDefaultElementType;
nsSupportsHashtable* mBoxObjectTable;
// The channel that got passed to StartDocumentLoad(), if any
nsCOMPtr<nsIChannel> mChannel;
nsRefPtr<nsHTMLStyleSheet> mAttrStyleSheet;
2004-01-13 23:53:23 +00:00
nsCOMPtr<nsIHTMLCSSStyleSheet> mStyleAttrStyleSheet;
nsRefPtr<nsXMLEventsManager> mXMLEventsManager;
nsCOMPtr<nsIScriptEventManager> mScriptEventManager;
nsString mBaseTarget;
private:
nsresult IsAllowedAsChild(PRUint16 aNodeType, nsIContent* aRefContent);
void PostUnblockOnloadEvent();
static EventHandlerFunc HandleOnloadBlockerEvent;
static EventDestructorFunc DestroyOnloadBlockerEvent;
void DoUnblockOnload();
// These are not implemented and not supported.
nsDocument(const nsDocument& aOther);
nsDocument& operator=(const nsDocument& aOther);
nsSmallVoidArray mPresShells;
nsXPathDocumentTearoff* mXPathDocument;
// The layout history state that should be used by nodes in this
// document. We only actually store a pointer to it when:
// 1) We have no script global object.
// 2) We haven't had Destroy() called on us yet.
nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
PRUint32 mOnloadBlockCount;
nsCOMPtr<nsIRequest> mOnloadBlocker;
// A map from unvisited URI hashes to content elements
nsTHashtable<nsUint32ToContentHashEntry> mLinkMap;
// URIs whose visitedness has changed while we were hidden
nsCOMArray<nsIURI> mVisitednessChangedURIs;
1998-04-13 20:24:54 +00:00
};
1998-04-13 20:24:54 +00:00
#endif /* nsDocument_h___ */