1999-02-12 20:18:58 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
1999-02-12 20:18:58 +03:00
|
|
|
*
|
1999-11-06 06:43:54 +03: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.
|
1999-02-12 20:18:58 +03:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-02-12 20:18:58 +03:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:43:54 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-02-12 20:18:58 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __editor_h__
|
|
|
|
#define __editor_h__
|
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
#include "nsCOMPtr.h"
|
1999-08-25 14:51:55 +04:00
|
|
|
#include "nsWeakPtr.h"
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-02-12 20:18:58 +03:00
|
|
|
#include "nsIEditor.h"
|
1999-08-09 05:37:50 +04:00
|
|
|
#include "nsIEditorIMESupport.h"
|
|
|
|
|
1999-02-12 20:18:58 +03:00
|
|
|
#include "nsIDOMDocument.h"
|
1999-09-01 23:58:25 +04:00
|
|
|
#include "nsIDiskDocument.h"
|
1999-06-08 10:04:51 +04:00
|
|
|
#include "nsIDOMSelection.h"
|
1999-07-01 22:42:28 +04:00
|
|
|
#include "nsIDOMCharacterData.h"
|
1999-02-12 20:18:58 +03:00
|
|
|
#include "nsIDOMEventListener.h"
|
1999-05-04 02:57:48 +04:00
|
|
|
#include "nsIDOMRange.h"
|
1999-08-06 06:32:13 +04:00
|
|
|
#include "nsIPrivateTextRange.h"
|
1999-02-12 20:18:58 +03:00
|
|
|
#include "nsITransactionManager.h"
|
|
|
|
#include "TransactionFactory.h"
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1999-07-28 06:55:40 +04:00
|
|
|
#include "nsISupportsArray.h"
|
1999-06-13 01:15:14 +04:00
|
|
|
#include "nsIEditProperty.h"
|
1999-06-15 00:02:46 +04:00
|
|
|
#include "nsIFileSpec.h"
|
1999-06-30 04:52:25 +04:00
|
|
|
#include "nsIDOMCharacterData.h"
|
1999-07-02 09:20:31 +04:00
|
|
|
#include "nsICSSStyleSheet.h"
|
1999-07-20 02:49:21 +04:00
|
|
|
#include "nsIDTD.h"
|
2000-01-10 13:44:18 +03:00
|
|
|
#include "nsIDOMElement.h"
|
2000-01-31 13:30:12 +03:00
|
|
|
#include "nsVoidArray.h"
|
1999-02-12 20:18:58 +03:00
|
|
|
|
1999-04-27 21:14:28 +04:00
|
|
|
class nsIEditActionListener;
|
1999-07-28 06:55:40 +04:00
|
|
|
class nsIDocumentStateListener;
|
1999-02-12 20:18:58 +03:00
|
|
|
class nsIDOMCharacterData;
|
|
|
|
class nsIDOMRange;
|
|
|
|
class nsIPresShell;
|
|
|
|
class nsIViewManager;
|
|
|
|
class ChangeAttributeTxn;
|
|
|
|
class CreateElementTxn;
|
1999-02-24 20:24:37 +03:00
|
|
|
class InsertElementTxn;
|
1999-02-12 20:18:58 +03:00
|
|
|
class DeleteElementTxn;
|
|
|
|
class InsertTextTxn;
|
|
|
|
class DeleteTextTxn;
|
|
|
|
class SplitElementTxn;
|
|
|
|
class JoinElementTxn;
|
|
|
|
class EditAggregateTxn;
|
|
|
|
class nsVoidArray;
|
1999-05-05 08:05:19 +04:00
|
|
|
class nsISupportsArray;
|
1999-06-09 05:27:08 +04:00
|
|
|
class nsILocale;
|
1999-06-30 00:31:22 +04:00
|
|
|
class IMETextTxn;
|
1999-07-02 07:57:50 +04:00
|
|
|
class AddStyleSheetTxn;
|
|
|
|
class RemoveStyleSheetTxn;
|
1999-08-28 06:40:18 +04:00
|
|
|
class nsFileSpec;
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2000-01-31 13:30:12 +03:00
|
|
|
/***************************************************************************
|
|
|
|
* class for recording selection info. stores selection as collection of
|
|
|
|
* { {startnode, startoffset} , {endnode, endoffset} } tuples. Cant store
|
|
|
|
* ranges since dom gravity will possibly change the ranges.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// first a helper struct for saving/setting ranges
|
|
|
|
struct SelRangeStore
|
|
|
|
{
|
|
|
|
nsresult StoreRange(nsIDOMRange *aRange);
|
|
|
|
nsresult GetRange(nsCOMPtr<nsIDOMRange> *outRange);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> startNode;
|
|
|
|
PRInt32 startOffset;
|
|
|
|
nsCOMPtr<nsIDOMNode> endNode;
|
|
|
|
PRInt32 endOffset;
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsSelectionState
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsSelectionState();
|
|
|
|
~nsSelectionState();
|
|
|
|
|
|
|
|
nsresult SaveSelection(nsIDOMSelection *aSel);
|
|
|
|
nsresult RestoreSelection(nsIDOMSelection *aSel);
|
|
|
|
PRBool IsCollapsed();
|
|
|
|
PRBool IsEqual(nsSelectionState *aSelState);
|
|
|
|
|
|
|
|
nsVoidArray mArray;
|
|
|
|
};
|
1999-02-12 20:18:58 +03:00
|
|
|
|
|
|
|
/** implementation of an editor object. it will be the controler/focal point
|
|
|
|
* for the main editor services. i.e. the GUIManager, publishing, transaction
|
|
|
|
* manager, event interfaces. the idea for the event interfaces is to have them
|
|
|
|
* delegate the actual commands to the editor independent of the XPFE implementation.
|
|
|
|
*/
|
1999-08-09 05:37:50 +04:00
|
|
|
class nsEditor : public nsIEditor,
|
1999-08-19 17:19:10 +04:00
|
|
|
public nsIEditorIMESupport
|
1999-02-12 20:18:58 +03:00
|
|
|
{
|
|
|
|
public:
|
1999-05-05 08:05:19 +04:00
|
|
|
|
1999-05-17 16:22:31 +04:00
|
|
|
enum IterDirection
|
|
|
|
{
|
|
|
|
kIterForward,
|
|
|
|
kIterBackward
|
|
|
|
};
|
|
|
|
|
1999-12-07 11:30:19 +03:00
|
|
|
enum OperationID
|
|
|
|
{
|
|
|
|
kOpIgnore = -1,
|
|
|
|
kOpNone = 0,
|
|
|
|
kOpUndo,
|
|
|
|
kOpRedo,
|
|
|
|
kOpSetTextProperty,
|
|
|
|
kOpRemoveTextProperty,
|
|
|
|
kOpInsertNode,
|
|
|
|
kOpCreateNode,
|
|
|
|
kOpDeleteNode,
|
|
|
|
kOpSplitNode,
|
|
|
|
kOpJoinNode,
|
|
|
|
kOpDeleteText,
|
|
|
|
kOpInsertText,
|
|
|
|
kOpInsertIMEText,
|
|
|
|
kOpDeleteSelection
|
|
|
|
};
|
|
|
|
|
1999-05-06 03:27:17 +04:00
|
|
|
static const char* kMOZEditorBogusNodeAttr;
|
|
|
|
static const char* kMOZEditorBogusNodeValue;
|
1999-05-05 08:05:19 +04:00
|
|
|
|
1999-02-12 20:18:58 +03:00
|
|
|
/** The default constructor. This should suffice. the setting of the interfaces is done
|
|
|
|
* after the construction of the editor class.
|
|
|
|
*/
|
|
|
|
nsEditor();
|
|
|
|
/** The default destructor. This should suffice. Should this be pure virtual
|
|
|
|
* for someone to derive from the nsEditor later? I dont believe so.
|
|
|
|
*/
|
|
|
|
virtual ~nsEditor();
|
|
|
|
|
1999-03-06 00:05:35 +03:00
|
|
|
//Interfaces for addref and release and queryinterface
|
1999-04-13 05:33:32 +04:00
|
|
|
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
|
1999-02-12 20:18:58 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
/* ------------ nsIEditor methods -------------- */
|
|
|
|
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, PRUint32 aFlags);
|
1999-08-03 10:53:45 +04:00
|
|
|
NS_IMETHOD PostCreate();
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD GetFlags(PRUint32 *aFlags) = 0;
|
|
|
|
NS_IMETHOD SetFlags(PRUint32 aFlags) = 0;
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD GetDocument(nsIDOMDocument **aDoc);
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD GetPresShell(nsIPresShell **aPS);
|
|
|
|
NS_IMETHOD GetSelection(nsIDOMSelection **aSelection);
|
|
|
|
|
|
|
|
NS_IMETHOD EnableUndo(PRBool aEnable);
|
|
|
|
NS_IMETHOD Do(nsITransaction *aTxn);
|
|
|
|
NS_IMETHOD Undo(PRUint32 aCount);
|
|
|
|
NS_IMETHOD CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo);
|
|
|
|
NS_IMETHOD Redo(PRUint32 aCount);
|
|
|
|
NS_IMETHOD CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD BeginTransaction();
|
|
|
|
NS_IMETHOD EndTransaction();
|
1999-05-27 01:40:51 +04:00
|
|
|
|
1999-09-30 00:08:15 +04:00
|
|
|
NS_IMETHOD BeginPlaceHolderTransaction(nsIAtom *aName);
|
|
|
|
NS_IMETHOD EndPlaceHolderTransaction();
|
2000-01-04 06:09:41 +03:00
|
|
|
NS_IMETHOD ShouldTxnSetSelection(PRBool *aResult);
|
1999-09-30 00:08:15 +04:00
|
|
|
|
1999-09-09 03:32:04 +04:00
|
|
|
// pure virtual, because the definition of 'empty' depends on the doc type
|
|
|
|
NS_IMETHOD GetDocumentIsEmpty(PRBool *aDocumentIsEmpty)=0;
|
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
// file handling
|
|
|
|
NS_IMETHOD GetDocumentModified(PRBool *outDocModified);
|
1999-08-14 02:26:50 +04:00
|
|
|
NS_IMETHOD GetDocumentCharacterSet(PRUnichar** characterSet);
|
|
|
|
NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet);
|
1999-09-01 23:58:25 +04:00
|
|
|
NS_IMETHOD SaveFile(nsFileSpec *aFileSpec, PRBool aReplaceExisting, PRBool aSaveCopy, nsIDiskDocument::ESaveFileType aSaveFileType);
|
1999-03-02 10:52:41 +03:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
// these are pure virtual in this base class
|
|
|
|
NS_IMETHOD Cut() = 0;
|
2000-01-19 00:50:15 +03:00
|
|
|
NS_IMETHOD CanCut(PRBool &aCanCut)=0;
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD Copy() = 0;
|
2000-01-19 00:50:15 +03:00
|
|
|
NS_IMETHOD CanCopy(PRBool &aCanCopy)=0;
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD Paste() = 0;
|
2000-01-19 00:50:15 +03:00
|
|
|
NS_IMETHOD CanPaste(PRBool &aCanPaste)=0;
|
1999-02-17 22:42:29 +03:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD SelectAll();
|
|
|
|
|
|
|
|
NS_IMETHOD BeginningOfDocument();
|
|
|
|
NS_IMETHOD EndOfDocument();
|
1999-02-12 20:18:58 +03:00
|
|
|
|
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
/* Node and element manipulation */
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD SetAttribute(nsIDOMElement * aElement,
|
|
|
|
const nsString& aAttribute,
|
|
|
|
const nsString& aValue);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD GetAttributeValue(nsIDOMElement * aElement,
|
|
|
|
const nsString& aAttribute,
|
|
|
|
nsString& aResultValue,
|
|
|
|
PRBool& aResultIsSet);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD RemoveAttribute(nsIDOMElement *aElement, const nsString& aAttribute);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD CreateNode(const nsString& aTag,
|
|
|
|
nsIDOMNode * aParent,
|
|
|
|
PRInt32 aPosition,
|
|
|
|
nsIDOMNode ** aNewNode);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD InsertNode(nsIDOMNode * aNode,
|
|
|
|
nsIDOMNode * aParent,
|
|
|
|
PRInt32 aPosition);
|
Preparation for ender-based text control
* added focus listener. Doesn't do much yet, but when focus notifications start appearing, we'll be ready for them. The code is in
place to hide selection when we lose focus and paint selection when we get focus. That's probably not quite right, but it's a start.
We will need to be able to determine the distinction between losing focus to another control within our app, and losing focus to
another app.
* added support for disabled and readonly states in the editor. This is accomplished by having flags set by the client, and letting the
rules system deal with those flags. The flags I added are:
TEXT_EDITOR_FLAG_PLAINTEXT 0x01 // only plain text editing is allowed
TEXT_EDITOR_FLAG_SINGLELINE 0x02 // enter key and CR-LF handled specially
TEXT_EDITOR_FLAG_PASSWORD 0x04 // text is not entered into content, only a representative character
TEXT_EDITOR_FLAG_READONLY 0x08 // editing events are disabled. Editor may still accept focus.
TEXT_EDITOR_FLAG_DISALBED 0x10 // all events are disabled (like scrolling). Editor will not accept focus.
* added WillInsertBreak/DidInsertBreak into text rules, so flags could be checked. This gets us readonly, disabled, and single line
behavior.
* cleaned up the code that allocates, registers, and destroys event listeners. Thanks to Kin and Simon for cleaning up the
ownership model on the listeners, it was a big help.
* added support for a max text length. You can now tell the text editor, be no bigger than n characters.
1999-05-29 01:24:18 +04:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD SplitNode(nsIDOMNode * aExistingRightNode,
|
|
|
|
PRInt32 aOffset,
|
|
|
|
nsIDOMNode ** aNewLeftNode);
|
|
|
|
|
1999-03-16 19:38:09 +03:00
|
|
|
NS_IMETHOD JoinNodes(nsIDOMNode * aLeftNode,
|
|
|
|
nsIDOMNode * aRightNode,
|
|
|
|
nsIDOMNode * aParent);
|
1999-03-02 10:52:41 +03:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD DeleteNode(nsIDOMNode * aChild);
|
1999-05-27 04:08:15 +04:00
|
|
|
|
1999-09-10 22:54:13 +04:00
|
|
|
/* formatting within the dom tree */
|
|
|
|
NS_IMETHOD InsertNoneditableTextNode(nsIDOMNode* aParent,
|
|
|
|
PRInt32 aOffset,
|
|
|
|
nsString& aStr);
|
|
|
|
NS_IMETHOD InsertFormattingForNode(nsIDOMNode* aNode);
|
|
|
|
|
1999-05-27 04:08:15 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
/* output */
|
|
|
|
NS_IMETHOD OutputToString(nsString& aOutputString,
|
|
|
|
const nsString& aFormatType,
|
|
|
|
PRUint32 aFlags);
|
|
|
|
|
|
|
|
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
|
|
|
const nsString& aFormatType,
|
|
|
|
const nsString* aCharsetOverride,
|
|
|
|
PRUint32 aFlags);
|
1999-07-01 23:32:35 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
/* Listeners */
|
1999-04-27 21:14:28 +04:00
|
|
|
NS_IMETHOD AddEditActionListener(nsIEditActionListener *aListener);
|
|
|
|
NS_IMETHOD RemoveEditActionListener(nsIEditActionListener *aListener);
|
|
|
|
|
1999-07-28 06:55:40 +04:00
|
|
|
NS_IMETHOD AddDocumentStateListener(nsIDocumentStateListener *aListener);
|
|
|
|
NS_IMETHOD RemoveDocumentStateListener(nsIDocumentStateListener *aListener);
|
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
|
|
|
|
NS_IMETHOD DumpContentTree();
|
|
|
|
NS_IMETHOD DebugDumpContent() const;
|
1999-05-27 08:10:04 +04:00
|
|
|
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
Preparation for ender-based text control
* added focus listener. Doesn't do much yet, but when focus notifications start appearing, we'll be ready for them. The code is in
place to hide selection when we lose focus and paint selection when we get focus. That's probably not quite right, but it's a start.
We will need to be able to determine the distinction between losing focus to another control within our app, and losing focus to
another app.
* added support for disabled and readonly states in the editor. This is accomplished by having flags set by the client, and letting the
rules system deal with those flags. The flags I added are:
TEXT_EDITOR_FLAG_PLAINTEXT 0x01 // only plain text editing is allowed
TEXT_EDITOR_FLAG_SINGLELINE 0x02 // enter key and CR-LF handled specially
TEXT_EDITOR_FLAG_PASSWORD 0x04 // text is not entered into content, only a representative character
TEXT_EDITOR_FLAG_READONLY 0x08 // editing events are disabled. Editor may still accept focus.
TEXT_EDITOR_FLAG_DISALBED 0x10 // all events are disabled (like scrolling). Editor will not accept focus.
* added WillInsertBreak/DidInsertBreak into text rules, so flags could be checked. This gets us readonly, disabled, and single line
behavior.
* cleaned up the code that allocates, registers, and destroys event listeners. Thanks to Kin and Simon for cleaning up the
ownership model on the listeners, it was a big help.
* added support for a max text length. You can now tell the text editor, be no bigger than n characters.
1999-05-29 01:24:18 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
/* ------------ nsIEditorIMESupport methods -------------- */
|
|
|
|
|
1999-08-31 05:20:32 +04:00
|
|
|
NS_IMETHOD BeginComposition(nsTextEventReply* aReply);
|
1999-12-07 04:29:00 +03:00
|
|
|
NS_IMETHOD QueryComposition(nsTextEventReply* aReply);
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
|
|
|
|
NS_IMETHOD EndComposition(void);
|
1999-12-08 06:39:36 +03:00
|
|
|
NS_IMETHOD ForceCompositionEnd(void);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
|
|
|
public:
|
1999-02-12 20:18:58 +03:00
|
|
|
|
1999-07-02 07:57:50 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD InsertTextImpl(const nsString& aStringToInsert);
|
1999-12-07 11:30:19 +03:00
|
|
|
NS_IMETHOD DeleteSelectionImpl(EDirection aAction);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-02-12 20:18:58 +03:00
|
|
|
|
|
|
|
protected:
|
1999-08-09 05:37:50 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//NOTE: Most callers are dealing with Nodes,
|
|
|
|
// but these objects must supports nsIDOMElement
|
1999-09-02 05:47:18 +04:00
|
|
|
NS_IMETHOD CloneAttributes(nsIDOMNode *aDestNode, nsIDOMNode *aSourceNode);
|
1999-08-09 05:37:50 +04:00
|
|
|
/*
|
|
|
|
NS_IMETHOD SetProperties(nsVoidArray *aPropList);
|
|
|
|
NS_IMETHOD GetProperties(nsVoidArray *aPropList);
|
|
|
|
*/
|
|
|
|
|
1999-03-10 22:48:13 +03:00
|
|
|
/** create a transaction for setting aAttribute to aValue on aElement
|
|
|
|
*/
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD CreateTxnForSetAttribute(nsIDOMElement *aElement,
|
|
|
|
const nsString& aAttribute,
|
|
|
|
const nsString& aValue,
|
|
|
|
ChangeAttributeTxn ** aTxn);
|
|
|
|
|
1999-03-10 22:48:13 +03:00
|
|
|
/** create a transaction for removing aAttribute on aElement
|
|
|
|
*/
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD CreateTxnForRemoveAttribute(nsIDOMElement *aElement,
|
|
|
|
const nsString& aAttribute,
|
|
|
|
ChangeAttributeTxn ** aTxn);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
1999-03-10 22:48:13 +03:00
|
|
|
/** create a transaction for creating a new child node of aParent of type aTag.
|
|
|
|
*/
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD CreateTxnForCreateElement(const nsString& aTag,
|
|
|
|
nsIDOMNode *aParent,
|
|
|
|
PRInt32 aPosition,
|
|
|
|
CreateElementTxn ** aTxn);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
1999-03-10 22:48:13 +03:00
|
|
|
/** create a transaction for inserting aNode as a child of aParent.
|
|
|
|
*/
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD CreateTxnForInsertElement(nsIDOMNode * aNode,
|
|
|
|
nsIDOMNode * aParent,
|
|
|
|
PRInt32 aOffset,
|
|
|
|
InsertElementTxn ** aTxn);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
1999-03-10 22:48:13 +03:00
|
|
|
/** create a transaction for removing aElement from its parent.
|
|
|
|
*/
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD CreateTxnForDeleteElement(nsIDOMNode * aElement,
|
|
|
|
DeleteElementTxn ** aTxn);
|
1999-02-24 20:24:37 +03:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-12-07 11:30:19 +03:00
|
|
|
NS_IMETHOD CreateTxnForDeleteSelection(EDirection aAction,
|
1999-08-09 05:37:50 +04:00
|
|
|
EditAggregateTxn ** aTxn);
|
|
|
|
|
|
|
|
NS_IMETHOD CreateTxnForDeleteInsertionPoint(nsIDOMRange *aRange,
|
1999-12-07 11:30:19 +03:00
|
|
|
EDirection aAction,
|
1999-08-09 05:37:50 +04:00
|
|
|
EditAggregateTxn *aTxn);
|
|
|
|
|
|
|
|
|
1999-03-10 22:48:13 +03:00
|
|
|
/** create a transaction for inserting aStringToInsert into aTextNode
|
|
|
|
* if aTextNode is null, the string is inserted at the current selection.
|
|
|
|
*/
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD CreateTxnForInsertText(const nsString & aStringToInsert,
|
1999-03-10 22:48:13 +03:00
|
|
|
nsIDOMCharacterData *aTextNode,
|
1999-10-26 22:54:47 +04:00
|
|
|
PRInt32 aOffset,
|
1999-03-02 08:30:53 +03:00
|
|
|
InsertTextTxn ** aTxn);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
1999-06-30 00:31:22 +04:00
|
|
|
NS_IMETHOD CreateTxnForIMEText(const nsString & aStringToInsert,
|
|
|
|
IMETextTxn ** aTxn);
|
|
|
|
|
1999-07-02 07:57:50 +04:00
|
|
|
/** create a transaction for adding a style sheet
|
|
|
|
*/
|
|
|
|
NS_IMETHOD CreateTxnForAddStyleSheet(nsICSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn);
|
|
|
|
|
|
|
|
/** create a transaction for removing a style sheet
|
|
|
|
*/
|
|
|
|
NS_IMETHOD CreateTxnForRemoveStyleSheet(nsICSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn);
|
|
|
|
|
1999-10-26 22:54:47 +04:00
|
|
|
NS_IMETHOD PrepareToInsertText(nsCOMPtr<nsIDOMCharacterData> *aOutTextNode, PRInt32 *aOutOffset);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD DeleteText(nsIDOMCharacterData *aElement,
|
|
|
|
PRUint32 aOffset,
|
|
|
|
PRUint32 aLength);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD CreateTxnForDeleteText(nsIDOMCharacterData *aElement,
|
|
|
|
PRUint32 aOffset,
|
|
|
|
PRUint32 aLength,
|
|
|
|
DeleteTextTxn **aTxn);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD CreateTxnForSplitNode(nsIDOMNode *aNode,
|
|
|
|
PRUint32 aOffset,
|
|
|
|
SplitElementTxn **aTxn);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD CreateTxnForJoinNode(nsIDOMNode *aLeftNode,
|
|
|
|
nsIDOMNode *aRightNode,
|
|
|
|
JoinElementTxn **aTxn);
|
1999-02-17 22:42:29 +03:00
|
|
|
|
1999-04-04 22:01:35 +04:00
|
|
|
|
1999-05-13 02:24:47 +04:00
|
|
|
// called each time we modify the document. Increments the mod
|
|
|
|
// count of the doc.
|
|
|
|
NS_IMETHOD IncDocModCount(PRInt32 inNumMods);
|
|
|
|
|
|
|
|
// return the mod count of the doc we are editing. Zero means unchanged.
|
|
|
|
NS_IMETHOD GetDocModCount(PRInt32 &outModCount);
|
|
|
|
|
|
|
|
// called ONLY when we need to override the doc's modification
|
|
|
|
// state. This should already be handled by nsIDiskDocument.
|
|
|
|
NS_IMETHOD ResetDocModCount();
|
|
|
|
|
1999-05-27 08:10:04 +04:00
|
|
|
// called after a transaction is done successfully
|
|
|
|
NS_IMETHOD DoAfterDoTransaction(nsITransaction *aTxn);
|
|
|
|
// called after a transaction is undone successfully
|
|
|
|
NS_IMETHOD DoAfterUndoTransaction();
|
1999-07-15 02:29:39 +04:00
|
|
|
// called after a transaction is redone successfully
|
|
|
|
NS_IMETHOD DoAfterRedoTransaction();
|
|
|
|
|
|
|
|
// called after the document has been saved
|
|
|
|
NS_IMETHOD DoAfterDocumentSave();
|
|
|
|
|
1999-08-03 04:58:38 +04:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
eDocumentCreated,
|
|
|
|
eDocumentToBeDestroyed,
|
|
|
|
eDocumentStateChanged
|
|
|
|
} TDocumentListenerNotification;
|
|
|
|
|
1999-07-28 06:55:40 +04:00
|
|
|
// tell the doc state listeners that the doc state has changed
|
1999-08-03 04:58:38 +04:00
|
|
|
NS_IMETHOD NotifyDocumentListeners(TDocumentListenerNotification aNotificationType);
|
1999-07-28 06:55:40 +04:00
|
|
|
|
1999-06-26 02:57:26 +04:00
|
|
|
/** make the given selection span the entire document */
|
|
|
|
NS_IMETHOD SelectEntireDocument(nsIDOMSelection *aSelection);
|
1999-05-27 08:10:04 +04:00
|
|
|
|
1999-03-14 03:31:35 +03:00
|
|
|
protected:
|
|
|
|
// XXXX: Horrible hack! We are doing this because
|
|
|
|
// of an error in Gecko which is not rendering the
|
|
|
|
// document after a change via the DOM - gpk 2/13/99
|
|
|
|
void HACKForceRedraw(void);
|
1999-05-04 02:57:48 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin);
|
1999-03-14 03:31:35 +03:00
|
|
|
|
1999-05-05 08:05:19 +04:00
|
|
|
public:
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-12-07 11:30:19 +03:00
|
|
|
/** return the body element */
|
|
|
|
/** It would make more sense for this to be in nsHTMLEditor, no? */
|
|
|
|
NS_IMETHOD GetBodyElement(nsIDOMElement **aElement);
|
|
|
|
|
|
|
|
/** All editor operations which alter the doc should be prefaced
|
|
|
|
* with a call to StartOperation, naming the action and direction */
|
|
|
|
NS_IMETHOD StartOperation(PRInt32 opID, nsIEditor::EDirection aDirection);
|
|
|
|
|
|
|
|
/** All editor operations which alter the doc should be followed
|
|
|
|
* with a call to EndOperation, naming the action and direction */
|
2000-02-08 15:53:34 +03:00
|
|
|
NS_IMETHOD EndOperation(PRInt32 opID, nsIEditor::EDirection aDirection, PRBool aSetSelection);
|
1999-12-07 11:30:19 +03:00
|
|
|
|
1999-08-31 02:12:11 +04:00
|
|
|
/** return the string that represents text nodes in the content tree */
|
|
|
|
static nsresult GetTextNodeTag(nsString& aOutString);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-05-05 08:05:19 +04:00
|
|
|
/**
|
|
|
|
* SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes
|
|
|
|
* @param aExistingRightNode the node to split. It will become the new node's next sibling.
|
|
|
|
* @param aOffset the offset of aExistingRightNode's content|children to do the split at
|
|
|
|
* @param aNewLeftNode [OUT] the new node resulting from the split, becomes aExistingRightNode's previous sibling.
|
|
|
|
* @param aParent the parent of aExistingRightNode
|
|
|
|
*/
|
2000-01-04 06:09:41 +03:00
|
|
|
nsresult SplitNodeImpl(nsIDOMNode *aExistingRightNode,
|
|
|
|
PRInt32 aOffset,
|
|
|
|
nsIDOMNode *aNewLeftNode,
|
|
|
|
nsIDOMNode *aParent);
|
1999-05-05 08:05:19 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* JoinNodes() takes 2 nodes and merge their content|children.
|
|
|
|
* @param aNodeToKeep The node that will remain after the join.
|
|
|
|
* @param aNodeToJoin The node that will be joined with aNodeToKeep.
|
|
|
|
* There is no requirement that the two nodes be of the same type.
|
1999-08-19 17:30:48 +04:00
|
|
|
* @param aParent The parent of aNodeToKeep
|
1999-05-05 08:05:19 +04:00
|
|
|
* @param aNodeToKeepIsFirst if PR_TRUE, the contents|children of aNodeToKeep come before the
|
|
|
|
* contents|children of aNodeToJoin, otherwise their positions are switched.
|
|
|
|
*/
|
2000-01-04 06:09:41 +03:00
|
|
|
nsresult JoinNodesImpl(nsIDOMNode *aNodeToKeep,
|
|
|
|
nsIDOMNode *aNodeToJoin,
|
|
|
|
nsIDOMNode *aParent,
|
|
|
|
PRBool aNodeToKeepIsFirst);
|
1999-05-05 08:05:19 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set aOffset to the offset of aChild in aParent.
|
|
|
|
* Returns an error if aChild is not an immediate child of aParent.
|
|
|
|
*/
|
|
|
|
static nsresult GetChildOffset(nsIDOMNode *aChild,
|
|
|
|
nsIDOMNode *aParent,
|
|
|
|
PRInt32 &aOffset);
|
|
|
|
|
1999-06-16 09:02:43 +04:00
|
|
|
/**
|
|
|
|
* Set aParent to the parent of aChild.
|
|
|
|
* Set aOffset to the offset of aChild in aParent.
|
|
|
|
*/
|
|
|
|
static nsresult GetNodeLocation(nsIDOMNode *aChild,
|
|
|
|
nsCOMPtr<nsIDOMNode> *aParent,
|
|
|
|
PRInt32 *aOffset);
|
|
|
|
|
1999-05-05 08:05:19 +04:00
|
|
|
/** set aIsInline to PR_TRUE if aNode is inline as defined by HTML DTD */
|
|
|
|
static nsresult IsNodeInline(nsIDOMNode *aNode, PRBool &aIsInline);
|
|
|
|
|
1999-09-22 09:52:44 +04:00
|
|
|
/** set aIsBlock to PR_TRUE if aNode is block as defined by HTML DTD */
|
1999-06-25 07:18:42 +04:00
|
|
|
static nsresult IsNodeBlock(nsIDOMNode *aNode, PRBool &aIsBlock);
|
|
|
|
|
1999-09-01 05:22:37 +04:00
|
|
|
/** This version is for exposure to JavaScript */
|
1999-09-01 23:58:25 +04:00
|
|
|
NS_IMETHOD NodeIsBlock(nsIDOMNode *aNode, PRBool &aIsBlock);
|
1999-09-01 05:22:37 +04:00
|
|
|
|
1999-05-05 08:05:19 +04:00
|
|
|
/** returns the closest block parent of aNode, not including aNode itself.
|
|
|
|
* can return null, for example if aNode is in a document fragment.
|
|
|
|
* @param aNode The node whose parent we seek.
|
|
|
|
* @param aBlockParent [OUT] The block parent, if any.
|
|
|
|
* @return a success value unless an unexpected error occurs.
|
|
|
|
*/
|
|
|
|
static nsresult GetBlockParent(nsIDOMNode *aNode,
|
|
|
|
nsIDOMElement **aBlockParent);
|
|
|
|
|
|
|
|
/** Determines the bounding nodes for the block section containing aNode.
|
|
|
|
* The calculation is based on some nodes intrinsically being block elements
|
|
|
|
* acording to HTML. Style sheets are not considered in this calculation.
|
|
|
|
* <BR> tags separate block content sections. So the HTML markup:
|
|
|
|
* <PRE>
|
|
|
|
* <P>text1<BR>text2<B>text3</B></P>
|
|
|
|
* </PRE>
|
|
|
|
* contains two block content sections. The first has the text node "text1"
|
|
|
|
* for both endpoints. The second has "text2" as the left endpoint and
|
|
|
|
* "text3" as the right endpoint.
|
|
|
|
* Notice that offsets aren't required, only leaf nodes. Offsets are implicit.
|
|
|
|
*
|
|
|
|
* @param aNode the block content returned includes aNode
|
|
|
|
* @param aLeftNode [OUT] the left endpoint of the block content containing aNode
|
|
|
|
* @param aRightNode [OUT] the right endpoint of the block content containing aNode
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static nsresult GetBlockSection(nsIDOMNode *aNode,
|
|
|
|
nsIDOMNode **aLeftNode,
|
|
|
|
nsIDOMNode **aRightNode);
|
|
|
|
|
|
|
|
/** Compute the set of block sections in a given range.
|
|
|
|
* A block section is the set of (leftNode, rightNode) pairs given
|
|
|
|
* by GetBlockSection. The set is computed by computing the
|
|
|
|
* block section for every leaf node in the range and throwing
|
|
|
|
* out duplicates.
|
|
|
|
*
|
|
|
|
* @param aRange The range to compute block sections for.
|
|
|
|
* @param aSections Allocated storage for the resulting set, stored as nsIDOMRanges.
|
|
|
|
*/
|
|
|
|
static nsresult GetBlockSectionsForRange(nsIDOMRange *aRange,
|
|
|
|
nsISupportsArray *aSections);
|
|
|
|
|
|
|
|
/** returns PR_TRUE in out-param aResult if all nodes between (aStartNode, aStartOffset)
|
|
|
|
* and (aEndNode, aEndOffset) are inline as defined by HTML DTD.
|
|
|
|
*/
|
|
|
|
static nsresult IntermediateNodesAreInline(nsIDOMRange *aRange,
|
|
|
|
nsIDOMNode *aStartNode,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
nsIDOMNode *aEndNode,
|
|
|
|
PRInt32 aEndOffset,
|
|
|
|
PRBool &aResult);
|
|
|
|
|
|
|
|
/** returns the number of things inside aNode in the out-param aCount.
|
|
|
|
* @param aNode is the node to get the length of.
|
|
|
|
* If aNode is text, returns number of characters.
|
|
|
|
* If not, returns number of children nodes.
|
|
|
|
* @param aCount [OUT] the result of the above calculation.
|
|
|
|
*/
|
|
|
|
static nsresult GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount);
|
|
|
|
|
1999-05-05 08:51:54 +04:00
|
|
|
/** get the node immediately prior to aCurrentNode
|
|
|
|
* @param aCurrentNode the node from which we start the search
|
|
|
|
* @param aEditableNode if PR_TRUE, only return an editable node
|
|
|
|
* @param aResultNode [OUT] the node that occurs before aCurrentNode in the tree,
|
|
|
|
* skipping non-editable nodes if aEditableNode is PR_TRUE.
|
|
|
|
* If there is no prior node, aResultNode will be nsnull.
|
|
|
|
*/
|
1999-07-01 22:42:28 +04:00
|
|
|
nsresult GetPriorNode(nsIDOMNode *aCurrentNode,
|
|
|
|
PRBool aEditableNode,
|
|
|
|
nsIDOMNode **aResultNode);
|
1999-05-05 08:51:54 +04:00
|
|
|
|
1999-08-31 17:55:18 +04:00
|
|
|
// and another version that takes a {parent,offset} pair rather than a node
|
|
|
|
nsresult GetPriorNode(nsIDOMNode *aParentNode,
|
|
|
|
PRInt32 aOffset,
|
|
|
|
PRBool aEditableNode,
|
|
|
|
nsIDOMNode **aResultNode);
|
|
|
|
|
1999-05-05 08:51:54 +04:00
|
|
|
/** get the node immediately after to aCurrentNode
|
|
|
|
* @param aCurrentNode the node from which we start the search
|
|
|
|
* @param aEditableNode if PR_TRUE, only return an editable node
|
|
|
|
* @param aResultNode [OUT] the node that occurs after aCurrentNode in the tree,
|
|
|
|
* skipping non-editable nodes if aEditableNode is PR_TRUE.
|
|
|
|
* If there is no prior node, aResultNode will be nsnull.
|
|
|
|
*/
|
1999-07-01 22:42:28 +04:00
|
|
|
nsresult GetNextNode(nsIDOMNode *aCurrentNode,
|
|
|
|
PRBool aEditableNode,
|
|
|
|
nsIDOMNode **aResultNode);
|
1999-05-05 08:05:19 +04:00
|
|
|
|
1999-08-31 17:55:18 +04:00
|
|
|
// and another version that takes a {parent,offset} pair rather than a node
|
|
|
|
nsresult GetNextNode(nsIDOMNode *aParentNode,
|
|
|
|
PRInt32 aOffset,
|
|
|
|
PRBool aEditableNode,
|
|
|
|
nsIDOMNode **aResultNode);
|
|
|
|
|
1999-05-05 08:51:54 +04:00
|
|
|
/** Get the rightmost child of aCurrentNode, and return it in aResultNode
|
|
|
|
* aResultNode is set to nsnull if aCurrentNode has no children.
|
|
|
|
*/
|
1999-05-05 08:05:19 +04:00
|
|
|
static nsresult GetRightmostChild(nsIDOMNode *aCurrentNode, nsIDOMNode **aResultNode);
|
|
|
|
|
1999-05-05 08:51:54 +04:00
|
|
|
/** Get the leftmost child of aCurrentNode, and return it in aResultNode
|
|
|
|
* aResultNode is set to nsnull if aCurrentNode has no children.
|
|
|
|
*/
|
1999-05-05 08:05:19 +04:00
|
|
|
static nsresult GetLeftmostChild(nsIDOMNode *aCurrentNode, nsIDOMNode **aResultNode);
|
|
|
|
|
|
|
|
/** GetFirstTextNode ADDREFFS and will get the next available text node from the passed
|
|
|
|
* in node parameter it can also return NS_ERROR_FAILURE if no text nodes are available
|
|
|
|
* now it simply returns the first node in the dom
|
|
|
|
* @param nsIDOMNode *aNode is the node to start looking from
|
|
|
|
* @param nsIDOMNode **aRetNode is the return location of the text dom node
|
|
|
|
*
|
|
|
|
* NOTE: this method will probably be removed.
|
|
|
|
*/
|
|
|
|
static nsresult GetFirstTextNode(nsIDOMNode *aNode, nsIDOMNode **aRetNode);
|
|
|
|
|
|
|
|
/** GetFirstNodeOfType ADDREFFS and will get the next available node from the passed
|
|
|
|
* in aStartNode parameter of type aTag.
|
|
|
|
* It can also return NS_ERROR_FAILURE if no such nodes are available
|
|
|
|
* @param aStartNode is the node to start looking from
|
|
|
|
* @param aTag is the type of node we are searching for
|
|
|
|
* @param aResult is the node we found, or nsnull if there is none
|
|
|
|
*/
|
|
|
|
static nsresult GetFirstNodeOfType(nsIDOMNode *aStartNode,
|
|
|
|
const nsString &aTag,
|
|
|
|
nsIDOMNode **aResult);
|
|
|
|
|
|
|
|
/** returns PR_TRUE if aNode is of the type implied by aTag */
|
|
|
|
static PRBool NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag);
|
|
|
|
|
1999-07-20 02:49:21 +04:00
|
|
|
/** returns PR_TRUE if aParent can contain a child of type aTag */
|
1999-09-30 00:08:15 +04:00
|
|
|
PRBool CanContainTag(nsIDOMNode* aParent, const nsString &aTag);
|
2000-02-08 15:53:34 +03:00
|
|
|
PRBool TagCanContain(const nsString &aParentTag, nsIDOMNode* aChild);
|
|
|
|
PRBool TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag);
|
|
|
|
|
1999-09-30 00:08:15 +04:00
|
|
|
/** returns PR_TRUE if aNode is a container */
|
|
|
|
PRBool IsContainer(nsIDOMNode *aNode);
|
|
|
|
|
1999-05-05 08:05:19 +04:00
|
|
|
/** returns PR_TRUE if aNode is an editable node */
|
1999-07-01 22:42:28 +04:00
|
|
|
PRBool IsEditable(nsIDOMNode *aNode);
|
1999-05-05 08:05:19 +04:00
|
|
|
|
2000-01-19 02:45:35 +03:00
|
|
|
/** returns PR_TRUE if aNode is a MozEditorBogus node */
|
|
|
|
PRBool IsMozEditorBogusNode(nsIDOMNode *aNode);
|
|
|
|
|
1999-09-30 00:08:15 +04:00
|
|
|
/** returns PR_TRUE if content is an merely formatting whitespacce */
|
|
|
|
PRBool IsEmptyTextContent(nsIContent* aContent);
|
|
|
|
|
1999-06-25 13:33:02 +04:00
|
|
|
/** counts number of editable child nodes */
|
1999-07-01 22:42:28 +04:00
|
|
|
nsresult CountEditableChildren(nsIDOMNode *aNode, PRUint32 &outCount);
|
1999-06-25 13:33:02 +04:00
|
|
|
|
1999-09-22 05:23:58 +04:00
|
|
|
/** Find the deep first and last children. Returned nodes are AddReffed */
|
1999-11-17 14:03:25 +03:00
|
|
|
nsresult GetFirstEditableNode(nsIDOMNode *aRoot, nsCOMPtr<nsIDOMNode> *outFirstNode);
|
|
|
|
nsresult GetLastEditableNode(nsIDOMNode *aRoot, nsCOMPtr<nsIDOMNode> *outLastNode);
|
1999-06-23 01:42:44 +04:00
|
|
|
|
|
|
|
|
1999-05-17 16:22:31 +04:00
|
|
|
/** from html rules code - migration in progress */
|
1999-05-29 01:17:30 +04:00
|
|
|
static nsresult GetTagString(nsIDOMNode *aNode, nsString& outString);
|
1999-05-17 16:22:31 +04:00
|
|
|
static nsCOMPtr<nsIAtom> GetTag(nsIDOMNode *aNode);
|
|
|
|
static PRBool NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2);
|
|
|
|
static PRBool IsBlockNode(nsIDOMNode *aNode);
|
|
|
|
static PRBool IsInlineNode(nsIDOMNode *aNode);
|
|
|
|
static nsCOMPtr<nsIDOMNode> GetBlockNodeParent(nsIDOMNode *aNode);
|
|
|
|
static PRBool HasSameBlockNodeParent(nsIDOMNode *aNode1, nsIDOMNode *aNode2);
|
|
|
|
|
|
|
|
static PRBool IsTextOrElementNode(nsIDOMNode *aNode);
|
|
|
|
static PRBool IsTextNode(nsIDOMNode *aNode);
|
|
|
|
|
|
|
|
static PRInt32 GetIndexOf(nsIDOMNode *aParent, nsIDOMNode *aChild);
|
|
|
|
static nsCOMPtr<nsIDOMNode> GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset);
|
|
|
|
|
|
|
|
static nsCOMPtr<nsIDOMNode> NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir);
|
|
|
|
static nsresult GetStartNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr<nsIDOMNode> *outStartNode, PRInt32 *outStartOffset);
|
|
|
|
static nsresult GetEndNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr<nsIDOMNode> *outEndNode, PRInt32 *outEndOffset);
|
1999-06-09 05:27:08 +04:00
|
|
|
|
1999-05-17 16:22:31 +04:00
|
|
|
nsresult IsPreformatted(nsIDOMNode *aNode, PRBool *aResult);
|
1999-11-25 03:16:56 +03:00
|
|
|
nsresult IsNextCharWhitespace(nsIDOMNode *aParentNode,
|
|
|
|
PRInt32 aOffset,
|
|
|
|
PRBool *outIsSpace,
|
|
|
|
PRBool *outIsNBSP,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outNode = 0,
|
|
|
|
PRInt32 *outOffset = 0);
|
|
|
|
nsresult IsPrevCharWhitespace(nsIDOMNode *aParentNode,
|
|
|
|
PRInt32 aOffset,
|
|
|
|
PRBool *outIsSpace,
|
|
|
|
PRBool *outIsNBSP,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outNode = 0,
|
|
|
|
PRInt32 *outOffset = 0);
|
1999-05-17 16:22:31 +04:00
|
|
|
|
1999-08-10 01:45:52 +04:00
|
|
|
nsresult SplitNodeDeep(nsIDOMNode *aNode, nsIDOMNode *aSplitPointParent, PRInt32 aSplitPointOffset, PRInt32 *outOffset);
|
1999-08-31 17:55:18 +04:00
|
|
|
nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsCOMPtr<nsIDOMNode> *aOutJoinNode, PRInt32 *outOffset);
|
|
|
|
|
|
|
|
nsresult GetString(const nsString& name, nsString& value);
|
1999-05-04 02:57:48 +04:00
|
|
|
|
1999-06-15 00:02:46 +04:00
|
|
|
nsresult BeginUpdateViewBatch(void);
|
|
|
|
nsresult EndUpdateViewBatch(void);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2000-01-04 06:09:41 +03:00
|
|
|
PRBool GetShouldTxnSetSelection();
|
|
|
|
void SetShouldTxnSetSelection(PRBool aShould);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
protected:
|
1999-06-03 09:58:20 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
PRUint32 mFlags; // behavior flags. See nsIHTMLEditor.h for the flags we use.
|
|
|
|
|
1999-08-25 14:51:55 +04:00
|
|
|
nsWeakPtr mPresShellWeak; // weak reference to the nsIPresShell
|
1999-08-09 05:37:50 +04:00
|
|
|
nsIViewManager *mViewManager;
|
1999-09-03 00:37:19 +04:00
|
|
|
PRInt32 mUpdateCount;
|
1999-08-09 05:37:50 +04:00
|
|
|
nsCOMPtr<nsITransactionManager> mTxnMgr;
|
|
|
|
nsCOMPtr<nsIEditProperty> mEditProperty;
|
|
|
|
nsCOMPtr<nsICSSStyleSheet> mLastStyleSheet; // is owning this dangerous?
|
1999-10-06 23:34:09 +04:00
|
|
|
nsWeakPtr mPlaceHolderTxn; // weak reference to placeholder for begin/end batch purposes
|
|
|
|
nsIAtom *mPlaceHolderName; // name of placeholder transaction
|
|
|
|
PRInt32 mPlaceHolderBatch; // nesting count for batching
|
2000-01-31 13:30:12 +03:00
|
|
|
nsSelectionState *mSelState; // saved selection state for placeholder txn batching
|
2000-01-04 06:09:41 +03:00
|
|
|
PRBool mShouldTxnSetSelection; // turn off for conservative selection adjustment by txns
|
2000-01-10 13:13:58 +03:00
|
|
|
nsCOMPtr<nsIDOMElement> mBodyElement; // cached body node
|
1999-08-09 05:37:50 +04:00
|
|
|
//
|
|
|
|
// data necessary to build IME transactions
|
|
|
|
//
|
1999-10-26 22:54:47 +04:00
|
|
|
PRBool mInIMEMode; // are we inside an IME composition?
|
|
|
|
nsIPrivateTextRangeList* mIMETextRangeList; // IME special selection ranges
|
|
|
|
nsCOMPtr<nsIDOMCharacterData> mIMETextNode; // current IME text node
|
|
|
|
PRUint32 mIMETextOffset; // offset in text node where IME comp string begins
|
|
|
|
PRUint32 mIMEBufferLength; // current length of IME comp string
|
1999-08-09 05:37:50 +04:00
|
|
|
|
|
|
|
nsVoidArray* mActionListeners;
|
|
|
|
nsCOMPtr<nsISupportsArray> mDocStateListeners;
|
|
|
|
|
|
|
|
PRInt8 mDocDirtyState; // -1 = not initialized
|
|
|
|
|
1999-08-25 14:51:55 +04:00
|
|
|
nsWeakPtr mDocWeak; // weak reference to the nsIDOMDocument
|
1999-08-09 05:37:50 +04:00
|
|
|
nsCOMPtr<nsIDTD> mDTD;
|
|
|
|
|
|
|
|
static PRInt32 gInstanceCount;
|
|
|
|
|
|
|
|
friend PRBool NSCanUnload(nsISupports* serviceMgr);
|
2000-01-04 06:09:41 +03:00
|
|
|
friend class nsAutoTxnsConserveSelection;
|
1999-06-08 10:04:51 +04:00
|
|
|
};
|
|
|
|
|
1999-06-03 09:58:20 +04:00
|
|
|
|
1999-02-18 15:14:59 +03:00
|
|
|
#endif
|