1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#ifndef nsIDocument_h___
|
|
|
|
#define nsIDocument_h___
|
|
|
|
|
|
|
|
#include "nslayout.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsIUnicharInputStream.h"
|
1998-06-08 04:57:15 +04:00
|
|
|
#include "nsGUIEvent.h"
|
1998-06-26 02:26:52 +04:00
|
|
|
|
1998-09-25 01:39:16 +04:00
|
|
|
class nsIAtom;
|
1998-04-14 00:24:54 +04:00
|
|
|
class nsIArena;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIDocumentContainer;
|
|
|
|
class nsIDocumentObserver;
|
|
|
|
class nsIPresContext;
|
|
|
|
class nsIPresShell;
|
1998-12-04 00:42:58 +03:00
|
|
|
|
1998-06-01 23:52:39 +04:00
|
|
|
class nsIStreamListener;
|
1998-07-01 15:16:09 +04:00
|
|
|
class nsIStreamObserver;
|
1998-04-14 00:24:54 +04:00
|
|
|
class nsIStyleSet;
|
|
|
|
class nsIStyleSheet;
|
1998-11-26 04:24:52 +03:00
|
|
|
class nsIStyleRule;
|
1998-04-14 00:24:54 +04:00
|
|
|
class nsIURL;
|
1998-10-02 01:43:02 +04:00
|
|
|
class nsIURLGroup;
|
1998-04-14 00:24:54 +04:00
|
|
|
class nsIViewManager;
|
|
|
|
class nsString;
|
1998-06-26 02:26:52 +04:00
|
|
|
class nsIScriptContextOwner;
|
1998-07-19 01:47:56 +04:00
|
|
|
class nsIContentViewerContainer;
|
1998-06-24 01:53:02 +04:00
|
|
|
class nsIDOMEvent;
|
1998-06-25 08:24:45 +04:00
|
|
|
class nsIDeviceContext;
|
1998-07-14 22:44:44 +04:00
|
|
|
class nsIParser;
|
1998-07-18 03:00:54 +04:00
|
|
|
class nsIDOMNode;
|
|
|
|
class nsXIFConverter;
|
1998-12-11 05:30:23 +03:00
|
|
|
class nsINameSpaceManager;
|
1999-02-12 02:12:28 +03:00
|
|
|
class nsIDOMSelection;
|
1999-01-19 06:54:26 +03:00
|
|
|
class nsIDOMDocumentFragment;
|
1999-02-23 06:31:26 +03:00
|
|
|
class nsILineBreaker;
|
1999-03-27 03:58:41 +03:00
|
|
|
class nsIWordBreaker;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// IID for the nsIDocument interface
|
|
|
|
#define NS_IDOCUMENT_IID \
|
|
|
|
{ 0x94c6ceb0, 0x9447, 0x11d1, \
|
|
|
|
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
|
|
|
|
1998-05-27 21:51:41 +04:00
|
|
|
// specification for data to be sent via form "post"
|
1998-07-01 15:16:09 +04:00
|
|
|
// IID for the nsIPostData interface - 152ab6e0-ff13-11d1-beb9-00805f8a66dc
|
|
|
|
#define NS_IPOSTDATA_IID \
|
|
|
|
{ 0x152ab6e0, 0xff13, 0x11d1, \
|
|
|
|
{0xbe, 0xb9, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc} }
|
|
|
|
|
|
|
|
class nsIPostData : public nsISupports {
|
1998-05-27 21:51:41 +04:00
|
|
|
public:
|
|
|
|
virtual PRBool IsFile() = 0; // is the data a file (or raw data)
|
|
|
|
virtual const char* GetData() = 0; // get the file name or raw data
|
1998-07-01 15:16:09 +04:00
|
|
|
virtual PRInt32 GetDataLength() = 0;
|
1998-05-27 21:51:41 +04:00
|
|
|
};
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Document interface
|
|
|
|
class nsIDocument : public nsISupports {
|
|
|
|
public:
|
|
|
|
// All documents have a memory arena associated with them which is
|
|
|
|
// used for memory allocation during document creation. This call
|
|
|
|
// returns the arena associated with this document.
|
|
|
|
virtual nsIArena* GetArena() = 0;
|
|
|
|
|
1998-07-01 15:16:09 +04:00
|
|
|
NS_IMETHOD StartDocumentLoad(nsIURL *aUrl,
|
1998-07-19 01:47:56 +04:00
|
|
|
nsIContentViewerContainer* aContainer,
|
1998-11-11 14:55:32 +03:00
|
|
|
nsIStreamListener **aDocListener,
|
|
|
|
const char* aCommand) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the title of the document. May return null.
|
|
|
|
*/
|
|
|
|
virtual const nsString* GetDocumentTitle() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the URL for the document. May return null.
|
|
|
|
*/
|
|
|
|
virtual nsIURL* GetDocumentURL() const = 0;
|
|
|
|
|
1998-10-02 01:43:02 +04:00
|
|
|
/**
|
|
|
|
* Return the URLGroup for the document. May return null.
|
|
|
|
*/
|
|
|
|
virtual nsIURLGroup* GetDocumentURLGroup() const = 0;
|
|
|
|
|
1999-01-15 04:53:50 +03:00
|
|
|
/**
|
|
|
|
* Return the base URL for realtive URLs in the document. May return null (or the document URL).
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetBaseURL(nsIURL*& aURL) const = 0;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
|
|
|
* Return a standard name for the document's character set. This will
|
|
|
|
* trigger a startDocumentLoad if necessary to answer the question.
|
|
|
|
*/
|
1999-01-25 19:05:04 +03:00
|
|
|
virtual nsString* GetDocumentCharacterSet() const = 0;
|
|
|
|
virtual void SetDocumentCharacterSet(nsString* aCharSetID) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-02-23 06:31:26 +03:00
|
|
|
/**
|
|
|
|
* Return the Line Breaker for the document
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetLineBreaker(nsILineBreaker** aResult) = 0;
|
|
|
|
NS_IMETHOD SetLineBreaker(nsILineBreaker* aLineBreaker) = 0;
|
1999-03-27 03:58:41 +03:00
|
|
|
NS_IMETHOD GetWordBreaker(nsIWordBreaker** aResult) = 0;
|
|
|
|
NS_IMETHOD SetWordBreaker(nsIWordBreaker* aWordBreaker) = 0;
|
1999-02-23 06:31:26 +03:00
|
|
|
|
1999-01-23 10:00:10 +03:00
|
|
|
/**
|
|
|
|
* Access HTTP header data (this may also get set from other sources, like
|
|
|
|
* HTML META tags).
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetHeaderData(nsIAtom* aHeaderField, nsString& aData) const = 0;
|
|
|
|
NS_IMETHOD SetHeaderData(nsIAtom* aheaderField, const nsString& aData) = 0;
|
|
|
|
|
1998-04-14 00:24:54 +04: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).
|
|
|
|
*/
|
1998-04-25 22:32:59 +04:00
|
|
|
virtual nsresult CreateShell(nsIPresContext* aContext,
|
|
|
|
nsIViewManager* aViewManager,
|
|
|
|
nsIStyleSet* aStyleSet,
|
|
|
|
nsIPresShell** aInstancePtrResult) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
virtual PRBool DeleteShell(nsIPresShell* aShell) = 0;
|
|
|
|
virtual PRInt32 GetNumberOfShells() = 0;
|
|
|
|
virtual nsIPresShell* GetShellAt(PRInt32 aIndex) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the parent document of this document. Will return null
|
|
|
|
* unless this document is within a compound document and has a parent.
|
|
|
|
*/
|
|
|
|
virtual nsIDocument* GetParentDocument() = 0;
|
|
|
|
virtual void SetParentDocument(nsIDocument* aParent) = 0;
|
|
|
|
virtual void AddSubDocument(nsIDocument* aSubDoc) = 0;
|
|
|
|
virtual PRInt32 GetNumberOfSubDocuments() = 0;
|
|
|
|
virtual nsIDocument* GetSubDocumentAt(PRInt32 aIndex) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the root content object for this document.
|
|
|
|
*/
|
|
|
|
virtual nsIContent* GetRootContent() = 0;
|
|
|
|
virtual void SetRootContent(nsIContent* aRoot) = 0;
|
|
|
|
|
1999-04-01 00:49:25 +04:00
|
|
|
/**
|
|
|
|
* Methods to append to the prolog and epilog of
|
|
|
|
* a document. The prolog is the content before the document
|
|
|
|
* element, the epilog after.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD AppendToProlog(nsIContent* aContent) = 0;
|
|
|
|
NS_IMETHOD AppendToEpilog(nsIContent* aContent) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the direct children of the document - content in
|
|
|
|
* the prolog, the root content and content in the epilog.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const = 0;
|
|
|
|
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const = 0;
|
|
|
|
NS_IMETHOD GetChildCount(PRInt32& aCount) = 0;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
|
|
|
* Get the style sheets owned by this document.
|
1998-09-02 06:00:24 +04:00
|
|
|
* Style sheets are ordered, most significant last.
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
|
|
|
virtual PRInt32 GetNumberOfStyleSheets() = 0;
|
|
|
|
virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex) = 0;
|
1999-01-23 10:00:10 +03:00
|
|
|
virtual PRInt32 GetIndexOfStyleSheet(nsIStyleSheet* aSheet) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
virtual void AddStyleSheet(nsIStyleSheet* aSheet) = 0;
|
1998-11-17 05:14:38 +03:00
|
|
|
virtual void SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
|
|
|
|
PRBool mDisabled) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-26 02:26:52 +04:00
|
|
|
/**
|
|
|
|
* 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 nsIScriptContextOwner *GetScriptContextOwner() = 0;
|
|
|
|
virtual void SetScriptContextOwner(nsIScriptContextOwner *aScriptContextOwner) = 0;
|
|
|
|
|
1998-12-11 05:30:23 +03:00
|
|
|
/**
|
|
|
|
* Get the name space manager for this document
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager) = 0;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Document notification API's
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove an observer of document change notifications. This will
|
|
|
|
* return false if the observer cannot be found.
|
|
|
|
*/
|
|
|
|
virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver) = 0;
|
|
|
|
|
|
|
|
// Observation hooks used by content nodes to propagate
|
|
|
|
// notifications to document observers.
|
1998-06-03 19:39:45 +04:00
|
|
|
NS_IMETHOD BeginLoad() = 0;
|
|
|
|
NS_IMETHOD EndLoad() = 0;
|
1998-09-25 01:39:16 +04:00
|
|
|
NS_IMETHOD ContentChanged(nsIContent* aContent,
|
|
|
|
nsISupports* aSubContent) = 0;
|
1999-04-20 04:02:22 +04:00
|
|
|
// notify that one or two content nodes changed state
|
|
|
|
// either may be nsnull, but not both
|
|
|
|
NS_IMETHOD ContentStatesChanged(nsIContent* aContent1,
|
|
|
|
nsIContent* aContent2) = 0;
|
1998-09-25 01:39:16 +04:00
|
|
|
NS_IMETHOD AttributeChanged(nsIContent* aChild,
|
1998-09-30 03:41:59 +04:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aHint) = 0; // See nsStyleConsts fot hint values
|
1998-09-25 01:39:16 +04:00
|
|
|
NS_IMETHOD ContentAppended(nsIContent* aContainer,
|
|
|
|
PRInt32 aNewIndexInContainer) = 0;
|
|
|
|
NS_IMETHOD ContentInserted(nsIContent* aContainer,
|
|
|
|
nsIContent* aChild,
|
|
|
|
PRInt32 aIndexInContainer) = 0;
|
|
|
|
NS_IMETHOD ContentReplaced(nsIContent* aContainer,
|
|
|
|
nsIContent* aOldChild,
|
|
|
|
nsIContent* aNewChild,
|
|
|
|
PRInt32 aIndexInContainer) = 0;
|
|
|
|
NS_IMETHOD ContentRemoved(nsIContent* aContainer,
|
|
|
|
nsIContent* aChild,
|
|
|
|
PRInt32 aIndexInContainer) = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-11-26 04:24:52 +03:00
|
|
|
// Observation hooks for style data to propogate notifications
|
|
|
|
// to document observers
|
|
|
|
NS_IMETHOD StyleRuleChanged(nsIStyleSheet* aStyleSheet,
|
|
|
|
nsIStyleRule* aStyleRule,
|
|
|
|
PRInt32 aHint) = 0; // See nsStyleConsts fot hint values
|
|
|
|
NS_IMETHOD StyleRuleAdded(nsIStyleSheet* aStyleSheet,
|
|
|
|
nsIStyleRule* aStyleRule) = 0;
|
|
|
|
NS_IMETHOD StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
|
|
|
|
nsIStyleRule* aStyleRule) = 0;
|
|
|
|
|
1998-04-30 22:21:59 +04:00
|
|
|
/**
|
|
|
|
* Returns the Selection Object
|
|
|
|
*/
|
1999-02-12 02:12:28 +03:00
|
|
|
NS_IMETHOD GetSelection(nsIDOMSelection ** aSelection) = 0;
|
1998-05-08 19:07:41 +04:00
|
|
|
/**
|
|
|
|
* Selects all the Content
|
|
|
|
*/
|
1998-09-09 20:11:59 +04:00
|
|
|
NS_IMETHOD SelectAll() = 0;
|
1998-05-08 19:07:41 +04:00
|
|
|
|
1998-08-28 19:59:24 +04:00
|
|
|
/**
|
|
|
|
* Finds text in content
|
|
|
|
*/
|
|
|
|
NS_IMETHOD FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound) = 0;
|
|
|
|
|
1998-07-15 02:34:27 +04:00
|
|
|
/**
|
|
|
|
* Converts the document or a selection of the
|
|
|
|
* document to XIF (XML Interchange Format)
|
|
|
|
* and places the result in aBuffer.
|
|
|
|
|
|
|
|
* NOTE: we may way to place the result in a stream,
|
|
|
|
* but we will use a string for now -- gpk
|
|
|
|
*/
|
1999-02-12 02:12:28 +03:00
|
|
|
virtual void CreateXIF(nsString & aBuffer, nsIDOMSelection* aSelection = nsnull) = 0;
|
1998-07-18 03:00:54 +04:00
|
|
|
virtual void ToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode) = 0;
|
|
|
|
virtual void BeginConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode) = 0;
|
|
|
|
virtual void ConvertChildrenToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode) = 0;
|
|
|
|
virtual void FinishConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode) = 0;
|
|
|
|
|
|
|
|
/* Helper methods to help determine the logical positioning of content */
|
1998-07-27 22:03:16 +04:00
|
|
|
virtual PRBool IsInRange(const nsIContent *aStartContent, const nsIContent* aEndContent, const nsIContent* aContent) const = 0;
|
|
|
|
virtual PRBool IsBefore(const nsIContent *aNewContent, const nsIContent* aCurrentContent) const = 0;
|
1999-02-12 02:12:28 +03:00
|
|
|
virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const = 0;
|
1998-07-27 22:03:16 +04:00
|
|
|
virtual nsIContent* GetPrevContent(const nsIContent *aContent) const = 0;
|
|
|
|
virtual nsIContent* GetNextContent(const nsIContent *aContent) const = 0;
|
|
|
|
virtual void SetDisplaySelection(PRBool aToggle) = 0;
|
|
|
|
virtual PRBool GetDisplaySelection() const = 0;
|
1998-07-15 02:34:27 +04:00
|
|
|
|
1998-06-08 04:57:15 +04:00
|
|
|
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext,
|
1998-07-23 06:55:33 +04:00
|
|
|
nsEvent* aEvent,
|
|
|
|
nsIDOMEvent** aDOMEvent,
|
|
|
|
PRUint32 aFlags,
|
|
|
|
nsEventStatus& aEventStatus) = 0;
|
1998-06-08 04:57:15 +04:00
|
|
|
|
1998-07-18 03:00:54 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
1998-06-08 04:57:15 +04:00
|
|
|
|
1998-07-27 21:51:42 +04:00
|
|
|
// XXX These belong somewhere else
|
1998-04-14 00:24:54 +04:00
|
|
|
extern NS_LAYOUT nsresult
|
|
|
|
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult);
|
1998-07-01 15:16:09 +04:00
|
|
|
|
1998-11-12 01:06:16 +03:00
|
|
|
extern NS_LAYOUT nsresult
|
|
|
|
NS_NewXMLDocument(nsIDocument** aInstancePtrResult);
|
|
|
|
|
1998-07-27 21:51:42 +04:00
|
|
|
extern NS_LAYOUT nsresult
|
|
|
|
NS_NewImageDocument(nsIDocument** aInstancePtrResult);
|
|
|
|
|
1999-01-19 06:54:26 +03:00
|
|
|
extern NS_LAYOUT nsresult
|
|
|
|
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
|
|
|
nsIDocument* aOwnerDocument);
|
|
|
|
|
1998-07-01 15:16:09 +04:00
|
|
|
// Note: The buffer passed into NewPostData(...) becomes owned by the IPostData
|
|
|
|
// instance and is freed when the instance is destroyed...
|
|
|
|
//
|
1998-05-27 21:51:41 +04:00
|
|
|
extern NS_LAYOUT nsresult
|
1998-07-01 15:16:09 +04:00
|
|
|
NS_NewPostData(PRBool aIsFile, char *aData, nsIPostData** aInstancePtrResult);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#endif /* nsIDocument_h___ */
|