1999-03-01 22:54:47 +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-03-01 22:54:47 +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-03-01 22:54:47 +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-03-01 22:54:47 +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-03-01 22:54:47 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsHTMLEditor_h__
|
|
|
|
#define nsHTMLEditor_h__
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
1999-08-09 05:37:50 +04:00
|
|
|
|
|
|
|
#include "nsIHTMLEditor.h"
|
|
|
|
#include "nsITableEditor.h"
|
|
|
|
#include "nsIEditorMailSupport.h"
|
|
|
|
#include "nsIEditorStyleSheets.h"
|
|
|
|
|
|
|
|
#include "nsEditor.h"
|
|
|
|
#include "nsIDOMElement.h"
|
1999-03-01 22:54:47 +03:00
|
|
|
#include "nsIDOMEventListener.h"
|
1999-09-30 01:45:50 +04:00
|
|
|
#include "nsICSSLoader.h"
|
1999-12-04 04:29:18 +03:00
|
|
|
#include "nsICSSLoaderObserver.h"
|
1999-08-02 02:37:58 +04:00
|
|
|
#include "nsITableLayout.h"
|
1999-03-01 22:54:47 +03:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
#include "TypeInState.h"
|
|
|
|
#include "nsEditRules.h"
|
2000-02-08 04:11:13 +03:00
|
|
|
|
1999-11-03 10:11:45 +03:00
|
|
|
class nsIDOMKeyEvent;
|
|
|
|
|
1999-03-01 22:54:47 +03:00
|
|
|
/**
|
|
|
|
* The HTML editor implementation.<br>
|
|
|
|
* Use to edit HTML document represented as a DOM tree.
|
|
|
|
*/
|
1999-08-09 05:37:50 +04:00
|
|
|
class nsHTMLEditor : public nsEditor,
|
|
|
|
public nsIHTMLEditor,
|
|
|
|
public nsIEditorMailSupport,
|
|
|
|
public nsITableEditor,
|
1999-12-04 04:29:18 +03:00
|
|
|
public nsIEditorStyleSheets,
|
|
|
|
public nsICSSLoaderObserver
|
2000-02-08 04:11:13 +03:00
|
|
|
|
1999-03-01 22:54:47 +03:00
|
|
|
{
|
1999-05-01 02:40:18 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
typedef enum {eNoOp, eReplaceParent=1, eInsertParent=2} BlockTransformationType;
|
1999-05-01 02:40:18 +04:00
|
|
|
|
1999-03-01 22:54:47 +03:00
|
|
|
public:
|
1999-12-07 11:30:19 +03:00
|
|
|
|
|
|
|
enum OperationID
|
|
|
|
{
|
|
|
|
kOpInsertBreak = 3000,
|
|
|
|
kOpMakeList = 3001,
|
|
|
|
kOpIndent = 3002,
|
|
|
|
kOpOutdent = 3003,
|
|
|
|
kOpAlign = 3004,
|
|
|
|
kOpMakeBasicBlock = 3005,
|
|
|
|
kOpRemoveList = 3006,
|
2000-02-25 07:39:30 +03:00
|
|
|
kOpInsertElement = 3008,
|
|
|
|
kOpInsertQuotation = 3009
|
1999-12-07 11:30:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-03-01 22:54:47 +03:00
|
|
|
// see nsIHTMLEditor for documentation
|
|
|
|
|
|
|
|
//Interfaces for addref and release and queryinterface
|
1999-03-06 00:05:35 +03:00
|
|
|
//NOTE macro used is for classes that inherit from
|
|
|
|
// another class. Only the base class should use NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
1999-03-01 22:54:47 +03:00
|
|
|
|
2000-02-08 04:11:13 +03:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
nsHTMLEditor();
|
|
|
|
virtual ~nsHTMLEditor();
|
1999-03-01 22:54:47 +03:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
/* ------------ nsIHTMLEditor methods -------------- */
|
1999-03-06 00:05:35 +03:00
|
|
|
|
1999-11-03 10:11:45 +03:00
|
|
|
NS_IMETHOD EditorKeyPress(nsIDOMKeyEvent* aKeyEvent);
|
1999-10-06 23:34:09 +04:00
|
|
|
NS_IMETHOD TypedText(const nsString& aString, PRInt32 aAction);
|
1999-09-13 13:37:51 +04:00
|
|
|
|
1999-09-09 03:32:04 +04:00
|
|
|
NS_IMETHOD GetDocumentIsEmpty(PRBool *aDocumentIsEmpty);
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD GetDocumentLength(PRInt32 *aCount);
|
|
|
|
NS_IMETHOD SetMaxTextLength(PRInt32 aMaxTextLength);
|
|
|
|
NS_IMETHOD GetMaxTextLength(PRInt32& aMaxTextLength);
|
1999-03-01 22:54:47 +03:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD SetInlineProperty(nsIAtom *aProperty,
|
1999-04-15 10:06:33 +04:00
|
|
|
const nsString *aAttribute,
|
|
|
|
const nsString *aValue);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
|
|
|
NS_IMETHOD GetInlineProperty(nsIAtom *aProperty,
|
|
|
|
const nsString *aAttribute,
|
|
|
|
const nsString *aValue,
|
1999-04-15 10:06:33 +04:00
|
|
|
PRBool &aFirst, PRBool &aAny, PRBool &aAll);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
|
|
|
NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsString *aAttribute);
|
1999-11-13 19:37:58 +03:00
|
|
|
NS_IMETHOD IncreaseFontSize();
|
|
|
|
NS_IMETHOD DecreaseFontSize();
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-03-10 22:49:18 +03:00
|
|
|
NS_IMETHOD InsertBreak();
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD InsertText(const nsString& aStringToInsert);
|
|
|
|
NS_IMETHOD InsertHTML(const nsString &aInputString);
|
2000-01-04 23:38:12 +03:00
|
|
|
NS_IMETHOD InsertHTMLWithCharset(const nsString& aInputString,
|
|
|
|
const nsString& aCharset);
|
1999-10-14 04:13:27 +04:00
|
|
|
NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-12-07 11:30:19 +03:00
|
|
|
NS_IMETHOD DeleteSelection(EDirection aAction);
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD DeleteSelectionAndCreateNode(const nsString& aTag, nsIDOMNode ** aNewNode);
|
|
|
|
NS_IMETHOD SelectElement(nsIDOMElement* aElement);
|
|
|
|
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
|
|
|
|
|
|
|
|
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat);
|
|
|
|
|
1999-09-22 09:52:44 +04:00
|
|
|
NS_IMETHOD GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists);
|
|
|
|
NS_IMETHOD GetParagraphTags(nsStringArray *aTagList);
|
|
|
|
NS_IMETHOD GetListTags(nsStringArray *aTagList);
|
1999-12-07 11:30:19 +03:00
|
|
|
// NS_IMETHOD RemoveParagraphStyle();
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-12-07 11:30:19 +03:00
|
|
|
// NS_IMETHOD AddBlockParent(nsString& aParentTag);
|
|
|
|
// NS_IMETHOD ReplaceBlockParent(nsString& aParentTag);
|
|
|
|
// NS_IMETHOD RemoveParent(const nsString &aParentTag);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-10-27 03:13:00 +04:00
|
|
|
NS_IMETHOD MakeOrChangeList(const nsString& aListType);
|
1999-09-06 23:47:25 +04:00
|
|
|
NS_IMETHOD RemoveList(const nsString& aListType);
|
1999-08-18 12:13:06 +04:00
|
|
|
NS_IMETHOD InsertBasicBlock(const nsString& aBlockType);
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD Indent(const nsString& aIndent);
|
|
|
|
NS_IMETHOD Align(const nsString& aAlign);
|
|
|
|
|
|
|
|
NS_IMETHOD GetElementOrParentByTagName(const nsString& aTagName, nsIDOMNode *aNode, nsIDOMElement** aReturn);
|
|
|
|
NS_IMETHOD GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn);
|
|
|
|
NS_IMETHOD CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement** aReturn);
|
2000-01-26 17:57:43 +03:00
|
|
|
NS_IMETHOD GetNextElementByTagName(nsIDOMElement *aCurrentElement, const nsString *aTagName, nsIDOMElement **aReturn);
|
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
|
|
|
|
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
|
|
|
|
|
1999-09-18 03:15:12 +04:00
|
|
|
/* ------------ nsIEditorIMESupport overrides -------------- */
|
|
|
|
|
|
|
|
NS_IMETHOD SetCompositionString(const nsString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
|
|
|
/* ------------ nsIEditorStyleSheets methods -------------- */
|
|
|
|
|
|
|
|
NS_IMETHOD ApplyStyleSheet(const nsString& aURL);
|
1999-09-30 01:45:50 +04:00
|
|
|
NS_IMETHOD ApplyOverrideStyleSheet(const nsString& aURL);
|
|
|
|
/* Above 2 methods call this with appropriate aOverride value
|
|
|
|
* Not exposed to IDL interface
|
|
|
|
*/
|
|
|
|
nsresult ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride);
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD AddStyleSheet(nsICSSStyleSheet* aSheet);
|
|
|
|
NS_IMETHOD RemoveStyleSheet(nsICSSStyleSheet* aSheet);
|
|
|
|
|
|
|
|
/* ------------ nsIEditorMailSupport methods -------------- */
|
|
|
|
|
|
|
|
NS_IMETHOD GetBodyWrapWidth(PRInt32 *aWrapColumn);
|
|
|
|
NS_IMETHOD SetBodyWrapWidth(PRInt32 aWrapColumn);
|
|
|
|
NS_IMETHOD PasteAsQuotation();
|
1999-11-24 23:48:59 +03:00
|
|
|
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText, nsIDOMNode **aNodeInserted);
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD PasteAsCitedQuotation(const nsString& aCitation);
|
2000-01-04 23:38:12 +03:00
|
|
|
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText,
|
|
|
|
const nsString& aCitation,
|
2000-03-21 02:13:25 +03:00
|
|
|
PRBool aInsertHTML,
|
2000-01-04 23:38:12 +03:00
|
|
|
const nsString& aCharset,
|
|
|
|
nsIDOMNode **aNodeInserted);
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD GetEmbeddedObjects(nsISupportsArray** aNodeList);
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------ nsITableEditor methods -------------- */
|
|
|
|
|
|
|
|
NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter);
|
|
|
|
NS_IMETHOD InsertTableColumn(PRInt32 aNumber, PRBool aAfter);
|
|
|
|
NS_IMETHOD InsertTableRow(PRInt32 aNumber, PRBool aAfter);
|
|
|
|
NS_IMETHOD DeleteTable();
|
|
|
|
NS_IMETHOD DeleteTableCell(PRInt32 aNumber);
|
2000-01-14 02:33:00 +03:00
|
|
|
NS_IMETHOD DeleteTableCellContents();
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD DeleteTableColumn(PRInt32 aNumber);
|
|
|
|
NS_IMETHOD DeleteTableRow(PRInt32 aNumber);
|
2000-02-10 08:14:52 +03:00
|
|
|
NS_IMETHOD SelectTableCell();
|
2000-03-17 02:45:41 +03:00
|
|
|
NS_IMETHOD SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndCell);
|
2000-02-10 08:14:52 +03:00
|
|
|
NS_IMETHOD SelectTableRow();
|
|
|
|
NS_IMETHOD SelectTableColumn();
|
|
|
|
NS_IMETHOD SelectTable();
|
|
|
|
NS_IMETHOD SelectAllTableCells();
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD JoinTableCells();
|
|
|
|
NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
|
|
|
|
NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell, PRInt32& aRowIndex, PRInt32& aColIndex);
|
|
|
|
NS_IMETHOD GetTableSize(nsIDOMElement *aTable, PRInt32& aRowCount, PRInt32& aColCount);
|
|
|
|
NS_IMETHOD GetCellAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell);
|
|
|
|
NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 aColIndex, nsIDOMElement* &aCell,
|
|
|
|
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
2000-01-26 17:57:43 +03:00
|
|
|
PRInt32& aRowSpan, PRInt32& aColSpan,
|
|
|
|
PRInt32& aActualRowSpan, PRInt32& aActualColSpan,
|
|
|
|
PRBool& aIsSelected);
|
2000-02-03 05:06:10 +03:00
|
|
|
NS_IMETHOD GetFirstRow(nsIDOMElement* aTableElement, nsIDOMElement* &aRow);
|
|
|
|
NS_IMETHOD GetNextRow(nsIDOMElement* aTableElement, nsIDOMElement* &aRow);
|
2000-01-14 02:33:00 +03:00
|
|
|
NS_IMETHOD SetCaretAfterTableEdit(nsIDOMElement* aTable, PRInt32 aRow, PRInt32 aCol, PRInt32 aDirection);
|
2000-02-03 05:06:10 +03:00
|
|
|
NS_IMETHOD GetSelectedOrParentTableElement(nsIDOMElement* &aTableElement, nsString& aTagName, PRBool &aIsSelected);
|
2000-01-14 02:33:00 +03:00
|
|
|
|
1999-03-01 22:54:47 +03:00
|
|
|
|
1999-04-21 22:53:55 +04:00
|
|
|
// Selection and navigation
|
1999-08-09 05:37:50 +04:00
|
|
|
/* obsolete
|
1999-03-02 08:30:53 +03:00
|
|
|
NS_IMETHOD MoveSelectionUp(nsIAtom *aIncrement, PRBool aExtendSelection);
|
|
|
|
NS_IMETHOD MoveSelectionDown(nsIAtom *aIncrement, PRBool aExtendSelection);
|
|
|
|
NS_IMETHOD MoveSelectionNext(nsIAtom *aIncrement, PRBool aExtendSelection);
|
|
|
|
NS_IMETHOD MoveSelectionPrevious(nsIAtom *aIncrement, PRBool aExtendSelection);
|
|
|
|
NS_IMETHOD SelectNext(nsIAtom *aIncrement, PRBool aExtendSelection);
|
|
|
|
NS_IMETHOD SelectPrevious(nsIAtom *aIncrement, PRBool aExtendSelection);
|
|
|
|
NS_IMETHOD ScrollUp(nsIAtom *aIncrement);
|
|
|
|
NS_IMETHOD ScrollDown(nsIAtom *aIncrement);
|
|
|
|
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin);
|
1999-08-09 05:37:50 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* miscellaneous */
|
|
|
|
// This sets background on the appropriate container element (table, cell,)
|
|
|
|
// or calls into nsTextEditor to set the page background
|
|
|
|
NS_IMETHOD SetBackgroundColor(const nsString& aColor);
|
|
|
|
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);
|
|
|
|
|
|
|
|
/* ------------ Overrides of nsEditor interface methods -------------- */
|
|
|
|
|
1999-08-23 10:42:04 +04:00
|
|
|
/** prepare the editor for use */
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIPresShell *aPresShell, PRUint32 aFlags);
|
1999-08-23 10:42:04 +04:00
|
|
|
|
1999-10-05 03:50:27 +04:00
|
|
|
NS_IMETHOD SetDocumentCharacterSet(const PRUnichar* characterSet);
|
|
|
|
|
1999-08-23 10:42:04 +04:00
|
|
|
/** we override this here to install event listeners */
|
|
|
|
NS_IMETHOD PostCreate();
|
1999-08-09 05:37:50 +04:00
|
|
|
|
|
|
|
NS_IMETHOD GetFlags(PRUint32 *aFlags);
|
|
|
|
NS_IMETHOD SetFlags(PRUint32 aFlags);
|
1999-05-07 09:02:35 +04:00
|
|
|
|
1999-11-18 22:43:14 +03:00
|
|
|
/** Inherited from nsEditor with special cases for some html nodes **/
|
|
|
|
NS_IMETHOD InsertFormattingForNode(nsIDOMNode* aNode);
|
|
|
|
|
1999-09-19 14:32:21 +04:00
|
|
|
NS_IMETHOD Undo(PRUint32 aCount);
|
|
|
|
NS_IMETHOD Redo(PRUint32 aCount);
|
|
|
|
|
1999-03-11 00:29:41 +03:00
|
|
|
NS_IMETHOD Cut();
|
2000-01-19 00:50:15 +03:00
|
|
|
NS_IMETHOD CanCut(PRBool &aCanCut);
|
1999-03-11 00:29:41 +03:00
|
|
|
NS_IMETHOD Copy();
|
2000-01-19 00:50:15 +03:00
|
|
|
NS_IMETHOD CanCopy(PRBool &aCanCopy);
|
1999-03-11 00:29:41 +03:00
|
|
|
NS_IMETHOD Paste();
|
2000-01-19 00:50:15 +03:00
|
|
|
NS_IMETHOD CanPaste(PRBool &aCanPaste);
|
1999-07-14 22:54:29 +04:00
|
|
|
|
|
|
|
NS_IMETHOD OutputToString(nsString& aOutputString,
|
|
|
|
const nsString& aFormatType,
|
|
|
|
PRUint32 aFlags);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
1999-07-14 22:54:29 +04:00
|
|
|
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
|
|
|
const nsString& aFormatType,
|
|
|
|
const nsString* aCharsetOverride,
|
|
|
|
PRUint32 aFlags);
|
1999-03-01 22:54:47 +03:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed);
|
1999-07-01 23:32:35 +04:00
|
|
|
|
1999-12-07 11:30:19 +03:00
|
|
|
/** 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
|
|
|
|
2000-01-10 13:13:58 +03:00
|
|
|
/** returns PR_TRUE if aParent can contain a child of type aTag */
|
|
|
|
PRBool CanContainTag(nsIDOMNode* aParent, const nsString &aTag);
|
|
|
|
|
2000-01-13 13:17:35 +03:00
|
|
|
/** make the given selection span the entire document */
|
|
|
|
NS_IMETHOD SelectEntireDocument(nsIDOMSelection *aSelection);
|
|
|
|
|
|
|
|
/* ------------ nsICSSLoaderObserver -------------- */
|
|
|
|
NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify);
|
|
|
|
|
1999-08-20 02:11:58 +04:00
|
|
|
/* ------------ Utility Routines, not part of public API -------------- */
|
|
|
|
NS_IMETHOD GetBodyStyleContext(nsIStyleContext** aStyleContext);
|
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
protected:
|
1999-06-15 00:02:46 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
virtual void InitRules();
|
1999-06-15 00:02:46 +04:00
|
|
|
|
1999-08-23 10:42:04 +04:00
|
|
|
/** install the event listeners for the editor
|
|
|
|
* used to be part of Init, but now broken out into a separate method
|
|
|
|
* called by PostCreate, giving the caller the chance to interpose
|
|
|
|
* their own listeners before we install our own backstops.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD InstallEventListeners();
|
|
|
|
|
1999-08-19 17:30:48 +04:00
|
|
|
/** returns the layout object (nsIFrame in the real world) for aNode
|
|
|
|
* @param aNode the content to get a frame for
|
|
|
|
* @param aLayoutObject the "primary frame" for aNode, if one exists. May be null
|
|
|
|
* @return NS_OK whether a frame is found or not
|
|
|
|
* an error if some serious error occurs
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetLayoutObject(nsIDOMNode *aInNode, nsISupports **aOutLayoutObject);
|
|
|
|
|
|
|
|
NS_IMETHOD CollapseAdjacentTextNodes(nsIDOMSelection *aInSelection);
|
1999-07-14 19:24:33 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
NS_IMETHOD DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNode> &parentSelectedNode, PRInt32& offsetOfNewNode);
|
1999-04-20 21:47:12 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
/* StyleSheet load callback */
|
|
|
|
static void ApplyStyleSheetToPresShellDocument(nsICSSStyleSheet* aSheet, void *aData);
|
1999-05-06 03:29:18 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
/* remove the old style sheet, and apply the supplied one */
|
|
|
|
NS_IMETHOD ReplaceStyleSheet(nsICSSStyleSheet *aNewSheet);
|
1999-03-01 22:54:47 +03:00
|
|
|
|
1999-07-28 03:59:22 +04:00
|
|
|
|
1999-07-23 04:52:17 +04:00
|
|
|
// Return TRUE if aElement is a table-related elemet and caret was set
|
1999-12-04 04:46:23 +03:00
|
|
|
PRBool SetCaretInTableCell(nsIDOMElement* aElement);
|
|
|
|
PRBool IsElementInBody(nsIDOMElement* aElement);
|
|
|
|
|
2000-01-31 13:30:12 +03:00
|
|
|
// inline style caching
|
|
|
|
void CacheInlineStyles(nsIDOMNode *aNode);
|
|
|
|
void ClearInlineStylesCache();
|
|
|
|
|
2000-02-03 01:47:43 +03:00
|
|
|
// typing state getters
|
|
|
|
NS_IMETHOD GetTypingState(nsIAtom *aProperty, PRBool &aPropIsSet, PRBool &aSetting);
|
|
|
|
NS_IMETHOD GetTypingStateValue(nsIAtom *aProperty, PRBool &aPropIsSet, nsString &aValue);
|
|
|
|
|
1999-09-13 13:37:51 +04:00
|
|
|
// key event helpers
|
|
|
|
NS_IMETHOD TabInTable(PRBool inIsShift, PRBool *outHandled);
|
2000-02-25 07:39:30 +03:00
|
|
|
NS_IMETHOD CreateBR(nsIDOMNode *aNode, PRInt32 aOffset,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outBRNode, EDirection aSelect = eNone);
|
1999-09-30 00:08:15 +04:00
|
|
|
NS_IMETHOD InsertBR(nsCOMPtr<nsIDOMNode> *outBRNode);
|
1999-09-13 13:37:51 +04:00
|
|
|
|
2000-02-10 08:14:52 +03:00
|
|
|
// Table Editing (implemented in nsTableEditor.cpp)
|
1999-08-02 02:37:58 +04:00
|
|
|
|
1999-12-04 04:46:23 +03:00
|
|
|
// Table utilities
|
|
|
|
|
2000-02-03 05:06:10 +03:00
|
|
|
// Insert a new cell after or before supplied aCell.
|
|
|
|
// Optional: If aNewCell supplied, returns the newly-created cell (addref'd, of course)
|
|
|
|
// This doesn't change or use the current selection
|
|
|
|
NS_IMETHOD InsertCell(nsIDOMElement *aCell, PRInt32 aRowSpan, PRInt32 aColSpan,
|
|
|
|
PRBool aAfter, nsIDOMElement **aNewCell);
|
2000-01-14 02:33:00 +03:00
|
|
|
NS_IMETHOD DeleteTable(nsCOMPtr<nsIDOMElement> &aTable, nsCOMPtr<nsIDOMSelection> &aSelection);
|
2000-02-03 05:06:10 +03:00
|
|
|
NS_IMETHOD SetColSpan(nsIDOMElement *aCell, PRInt32 aColSpan);
|
|
|
|
NS_IMETHOD SetRowSpan(nsIDOMElement *aCell, PRInt32 aRowSpan);
|
|
|
|
|
1999-08-02 02:37:58 +04:00
|
|
|
// Helper used to get nsITableLayout interface for methods implemented in nsTableFrame
|
|
|
|
NS_IMETHOD GetTableLayoutObject(nsIDOMElement* aTable, nsITableLayout **tableLayoutObject);
|
1999-12-07 04:12:10 +03:00
|
|
|
// Needed to do appropriate deleting when last cell or row is about to be deleted
|
|
|
|
// This doesn't count cells that don't start in the given row (are spanning from row above)
|
2000-01-26 17:57:43 +03:00
|
|
|
PRInt32 GetNumberOfCellsInRow(nsIDOMElement* aTable, PRInt32 rowIndex);
|
1999-08-04 06:06:03 +04:00
|
|
|
|
1999-12-04 04:46:23 +03:00
|
|
|
// Most insert methods need to get the same basic context data
|
1999-08-04 06:06:03 +04:00
|
|
|
NS_IMETHOD GetCellContext(nsCOMPtr<nsIDOMSelection> &aSelection,
|
|
|
|
nsCOMPtr<nsIDOMElement> &aTable, nsCOMPtr<nsIDOMElement> &aCell,
|
|
|
|
nsCOMPtr<nsIDOMNode> &aCellParent, PRInt32& aCellOffset,
|
|
|
|
PRInt32& aRow, PRInt32& aCol);
|
|
|
|
|
2000-02-10 08:14:52 +03:00
|
|
|
// Finds the first selected cell in first range of selection
|
|
|
|
// This is in the *order of selection*, not order in the table
|
|
|
|
// (i.e., each cell added to selection is added in another range
|
|
|
|
// in the selection's rangelist, independent of location in table)
|
|
|
|
NS_IMETHOD GetFirstSelectedCell(nsIDOMElement **aCell);
|
|
|
|
|
|
|
|
// Fallback method: Call this after using ClearSelection() and you
|
|
|
|
// failed to set selection to some other content in the document
|
|
|
|
NS_IMETHOD SetSelectionAtDocumentStart(nsIDOMSelection *aSelection);
|
1999-08-06 00:04:58 +04:00
|
|
|
|
2000-03-17 02:45:41 +03:00
|
|
|
// end of table editing utilities
|
|
|
|
|
1999-05-01 02:40:18 +04:00
|
|
|
NS_IMETHOD ReParentContentOfNode(nsIDOMNode *aNode,
|
|
|
|
nsString &aParentTag,
|
|
|
|
BlockTransformationType aTranformation);
|
1999-04-20 21:47:12 +04:00
|
|
|
|
|
|
|
NS_IMETHOD ReParentBlockContent(nsIDOMNode *aNode,
|
|
|
|
nsString &aParentTag,
|
|
|
|
nsIDOMNode *aBlockParentNode,
|
|
|
|
nsString &aBlockParentTag,
|
1999-05-01 02:40:18 +04:00
|
|
|
BlockTransformationType aTranformation,
|
1999-04-20 21:47:12 +04:00
|
|
|
nsIDOMNode **aNewParentNode);
|
1999-03-29 12:02:05 +04:00
|
|
|
|
1999-12-07 11:30:19 +03:00
|
|
|
/* NS_IMETHOD ReParentContentOfRange(nsIDOMRange *aRange,
|
1999-05-01 02:40:18 +04:00
|
|
|
nsString &aParentTag,
|
|
|
|
BlockTransformationType aTranformation);
|
1999-12-07 11:30:19 +03:00
|
|
|
*/
|
1999-05-05 08:05:19 +04:00
|
|
|
NS_IMETHOD RemoveParagraphStyleFromRange(nsIDOMRange *aRange);
|
|
|
|
|
|
|
|
NS_IMETHOD RemoveParagraphStyleFromBlockContent(nsIDOMRange *aRange);
|
|
|
|
|
|
|
|
NS_IMETHOD RemoveParentFromRange(const nsString &aParentTag, nsIDOMRange *aRange);
|
|
|
|
|
|
|
|
NS_IMETHOD RemoveParentFromBlockContent(const nsString &aParentTag, nsIDOMRange *aRange);
|
|
|
|
|
|
|
|
NS_IMETHOD IsRootTag(nsString &aTag, PRBool &aIsTag);
|
|
|
|
|
1999-09-23 08:01:10 +04:00
|
|
|
NS_IMETHOD IsLeafThatTakesInlineStyle(const nsString *aTag, PRBool &aResult);
|
|
|
|
|
1999-05-05 08:05:19 +04:00
|
|
|
NS_IMETHOD IsSubordinateBlock(nsString &aTag, PRBool &aIsTag);
|
|
|
|
|
1999-09-19 14:32:21 +04:00
|
|
|
static PRBool IsTable(nsIDOMNode *aNode);
|
|
|
|
static PRBool IsTableCell(nsIDOMNode *aNode);
|
|
|
|
static PRBool IsTableElement(nsIDOMNode *aNode);
|
|
|
|
static nsCOMPtr<nsIDOMNode> GetEnclosingTable(nsIDOMNode *aNode);
|
1999-05-05 08:05:19 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
/** content-based query returns PR_TRUE if <aProperty aAttribute=aValue> effects aNode
|
|
|
|
* If <aProperty aAttribute=aValue> contains aNode,
|
|
|
|
* but <aProperty aAttribute=SomeOtherValue> also contains aNode and the second is
|
|
|
|
* more deeply nested than the first, then the first does not effect aNode.
|
|
|
|
*
|
|
|
|
* @param aNode The target of the query
|
|
|
|
* @param aProperty The property that we are querying for
|
|
|
|
* @param aAttribute The attribute of aProperty, example: color in <FONT color="blue">
|
|
|
|
* May be null.
|
|
|
|
* @param aValue The value of aAttribute, example: blue in <FONT color="blue">
|
|
|
|
* May be null. Ignored if aAttribute is null.
|
|
|
|
* @param aIsSet [OUT] PR_TRUE if <aProperty aAttribute=aValue> effects aNode.
|
|
|
|
* @param aStyleNode [OUT] set to the node representing <aProperty aAttribute=aValue>, if found.
|
|
|
|
* null if aIsSet is returned as PR_FALSE;
|
|
|
|
*/
|
|
|
|
virtual void IsTextPropertySetByContent(nsIDOMNode *aNode,
|
|
|
|
nsIAtom *aProperty,
|
|
|
|
const nsString *aAttribute,
|
|
|
|
const nsString *aValue,
|
|
|
|
PRBool &aIsSet,
|
|
|
|
nsIDOMNode **aStyleNode) const;
|
|
|
|
|
|
|
|
/** style-based query returns PR_TRUE if (aProperty, aAttribute) is set in aSC.
|
|
|
|
* WARNING: not well tested yet since we don't do style-based queries anywhere.
|
|
|
|
*/
|
|
|
|
virtual void IsTextStyleSet(nsIStyleContext *aSC,
|
|
|
|
nsIAtom *aProperty,
|
|
|
|
const nsString *aAttributes,
|
|
|
|
PRBool &aIsSet) const;
|
|
|
|
|
|
|
|
/** Moves the content between (aNode, aStartOffset) and (aNode, aEndOffset)
|
|
|
|
* into aNewParentNode, splitting aNode as necessary to maintain the relative
|
|
|
|
* position of all leaf content.
|
|
|
|
* @param aNode The node whose content we're repositioning.
|
|
|
|
* aNode can be either a text node or a container node.
|
|
|
|
* @param aNewParentNode The node that will be the repositioned contents' parent.
|
|
|
|
* The caller is responsible for allocating aNewParentNode
|
|
|
|
* @param aStartOffset The start offset of the content of aNode
|
|
|
|
* @param aEndOffset The end offset of the content of aNode.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD MoveContentOfNodeIntoNewParent(nsIDOMNode *aNode,
|
|
|
|
nsIDOMNode *aNewParentNode,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
PRInt32 aEndOffset);
|
|
|
|
|
|
|
|
/** Moves the content between (aStartNode, aStartOffset) and (aEndNode, aEndOffset)
|
|
|
|
* into aNewParentNode, splitting aStartNode and aEndNode as necessary to maintain
|
|
|
|
* the relative position of all leaf content.
|
|
|
|
* The content between the two endpoints MUST be "contiguous" in the sense that
|
|
|
|
* it is all in the same block. Another way of saying this is all content nodes
|
|
|
|
* between aStartNode and aEndNode must be inline.
|
|
|
|
* @see IntermediateNodesAreInline
|
|
|
|
*
|
|
|
|
* @param aStartNode The left node, can be either a text node or a container node.
|
|
|
|
* @param aStartOffset The start offset in the content of aStartNode
|
|
|
|
* @param aEndNode The right node, can be either a text node or a container node.
|
|
|
|
* @param aEndOffset The end offset in the content of aEndNode.
|
|
|
|
* @param aGrandParentNode The common ancestor of aStartNode and aEndNode.
|
|
|
|
* aGrandParentNode will be the parent of aNewParentNode.
|
|
|
|
* @param aNewParentNode The node that will be the repositioned contents' parent.
|
|
|
|
* The caller is responsible for allocating aNewParentNode
|
|
|
|
*/
|
|
|
|
NS_IMETHOD MoveContiguousContentIntoNewParent(nsIDOMNode *aStartNode,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
nsIDOMNode *aEndNode,
|
|
|
|
PRInt32 aEndOffset,
|
|
|
|
nsIDOMNode *aGrandParentNode,
|
|
|
|
nsIDOMNode *aNewParentNode);
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHOD SetTextPropertiesForNode(nsIDOMNode *aNode,
|
|
|
|
nsIDOMNode *aParent,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
PRInt32 aEndOffset,
|
|
|
|
nsIAtom *aPropName,
|
|
|
|
const nsString *aAttribute,
|
|
|
|
const nsString *aValue);
|
|
|
|
|
|
|
|
NS_IMETHOD SetTextPropertiesForNodesWithSameParent(nsIDOMNode *aStartNode,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
nsIDOMNode *aEndNode,
|
|
|
|
PRInt32 aEndOffset,
|
|
|
|
nsIDOMNode *aParent,
|
|
|
|
nsIAtom *aPropName,
|
|
|
|
const nsString *aAttribute,
|
|
|
|
const nsString *aValue);
|
|
|
|
|
|
|
|
NS_IMETHOD SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange,
|
|
|
|
nsIDOMNode *aStartNode,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
nsIDOMNode *aEndNode,
|
|
|
|
PRInt32 aEndOffset,
|
|
|
|
nsIDOMNode *aParent,
|
|
|
|
nsIAtom *aPropName,
|
|
|
|
const nsString *aAttribute,
|
|
|
|
const nsString *aValue);
|
|
|
|
|
|
|
|
NS_IMETHOD RemoveTextPropertiesForNode(nsIDOMNode *aNode,
|
|
|
|
nsIDOMNode *aParent,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
PRInt32 aEndOffset,
|
|
|
|
nsIAtom *aPropName,
|
|
|
|
const nsString *aAttribute);
|
|
|
|
|
|
|
|
NS_IMETHOD RemoveTextPropertiesForNodesWithSameParent(nsIDOMNode *aStartNode,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
nsIDOMNode *aEndNode,
|
|
|
|
PRInt32 aEndOffset,
|
|
|
|
nsIDOMNode *aParent,
|
|
|
|
nsIAtom *aPropName,
|
|
|
|
const nsString *aAttribute);
|
|
|
|
|
|
|
|
NS_IMETHOD RemoveTextPropertiesForNodeWithDifferentParents(nsIDOMNode *aStartNode,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
nsIDOMNode *aEndNode,
|
|
|
|
PRInt32 aEndOffset,
|
|
|
|
nsIDOMNode *aParent,
|
|
|
|
nsIAtom *aPropName,
|
|
|
|
const nsString *aAttribute);
|
|
|
|
|
|
|
|
NS_IMETHOD SetTypeInStateForProperty(TypeInState &aTypeInState,
|
|
|
|
nsIAtom *aPropName,
|
|
|
|
const nsString *aAttribute,
|
|
|
|
const nsString *aValue);
|
|
|
|
|
1999-08-19 17:30:48 +04:00
|
|
|
NS_IMETHOD GetTextSelectionOffsetsForRange(nsIDOMSelection *aSelection,
|
|
|
|
nsIDOMNode **aParent,
|
|
|
|
PRInt32 &aStartOffset,
|
|
|
|
PRInt32 &aEndOffset);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
|
|
|
void ResetTextSelectionForRange(nsIDOMNode *aParent,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
PRInt32 aEndOffset,
|
|
|
|
nsIDOMSelection *aSelection);
|
|
|
|
|
|
|
|
/** returns the absolute position of the end points of aSelection
|
|
|
|
* in the document as a text stream.
|
|
|
|
*/
|
|
|
|
nsresult GetTextSelectionOffsets(nsIDOMSelection *aSelection,
|
|
|
|
PRInt32 &aStartOffset,
|
|
|
|
PRInt32 &aEndOffset);
|
1999-03-01 22:54:47 +03:00
|
|
|
|
1999-09-14 00:44:38 +04:00
|
|
|
nsresult GetAbsoluteOffsetsForPoints(nsIDOMNode *aInStartNode,
|
|
|
|
PRInt32 aInStartOffset,
|
|
|
|
nsIDOMNode *aInEndNode,
|
|
|
|
PRInt32 aInEndOffset,
|
|
|
|
nsIDOMNode *aInCommonParentNode,
|
|
|
|
PRInt32 &aOutStartOffset,
|
|
|
|
PRInt32 &aEndOffset);
|
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
// Methods for handling plaintext quotations
|
|
|
|
NS_IMETHOD PasteAsPlaintextQuotation();
|
1999-11-24 23:48:59 +03:00
|
|
|
NS_IMETHOD InsertAsPlaintextQuotation(const nsString& aQuotedText,
|
|
|
|
nsIDOMNode **aNodeInserted);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
|
|
|
TypeInState *GetTypeInState();
|
|
|
|
|
|
|
|
/** simple utility to handle any error with event listener allocation or registration */
|
|
|
|
void HandleEventListenerError();
|
|
|
|
|
2000-01-19 00:50:15 +03:00
|
|
|
/* small utility routine to test the eEditorReadonly bit */
|
|
|
|
PRBool IsModifiable();
|
|
|
|
|
2000-02-08 15:53:34 +03:00
|
|
|
/* increase/decrease the font size of selection */
|
|
|
|
nsresult RelativeFontChange( PRInt32 aSizeChange);
|
|
|
|
|
|
|
|
/* helper routines for font size changing */
|
|
|
|
nsresult RelativeFontChangeOnTextNode( PRInt32 aSizeChange,
|
|
|
|
nsIDOMCharacterData *aTextNode,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
PRInt32 aEndOffset);
|
|
|
|
nsresult RelativeFontChangeOnNode( PRInt32 aSizeChange,
|
|
|
|
nsIDOMNode *aNode);
|
|
|
|
|
|
|
|
/* helper routines for node/parent manipulations */
|
|
|
|
nsresult ReplaceContainer(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, const nsString &aNodeType);
|
|
|
|
nsresult RemoveContainer(nsIDOMNode *inNode);
|
|
|
|
nsresult InsertContainerAbove(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, const nsString &aNodeType);
|
|
|
|
|
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
// Data members
|
|
|
|
protected:
|
|
|
|
|
|
|
|
TypeInState* mTypeInState;
|
|
|
|
nsEditRules* mRules;
|
|
|
|
nsCOMPtr<nsIDOMEventListener> mKeyListenerP;
|
|
|
|
nsCOMPtr<nsIDOMEventListener> mMouseListenerP;
|
|
|
|
nsCOMPtr<nsIDOMEventListener> mTextListenerP;
|
|
|
|
nsCOMPtr<nsIDOMEventListener> mCompositionListenerP;
|
|
|
|
nsCOMPtr<nsIDOMEventListener> mDragListenerP;
|
|
|
|
nsCOMPtr<nsIDOMEventListener> mFocusListenerP;
|
|
|
|
PRBool mIsComposing;
|
|
|
|
PRInt32 mMaxTextLength;
|
2000-01-31 13:30:12 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAtom> mBoldAtom;
|
|
|
|
nsCOMPtr<nsIAtom> mItalicAtom;
|
|
|
|
nsCOMPtr<nsIAtom> mUnderlineAtom;
|
|
|
|
nsCOMPtr<nsIAtom> mFontAtom;
|
2000-02-17 22:40:18 +03:00
|
|
|
nsCOMPtr<nsIAtom> mLinkAtom;
|
2000-01-31 13:30:12 +03:00
|
|
|
nsCOMPtr<nsIDOMNode> mCachedNode;
|
|
|
|
|
|
|
|
PRBool mCachedBoldStyle;
|
|
|
|
PRBool mCachedItalicStyle;
|
|
|
|
PRBool mCachedUnderlineStyle;
|
|
|
|
nsString mCachedFontName;
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2000-03-17 02:45:41 +03:00
|
|
|
// True when selection consists of table cell(s)
|
|
|
|
PRBool mSelectingTableCells;
|
|
|
|
|
|
|
|
// Used to monitor block of cells selected
|
|
|
|
// by dragging mouse across the table
|
|
|
|
nsCOMPtr<nsIDOMElement> mStartSelectedCell;
|
|
|
|
nsCOMPtr<nsIDOMElement> mCurrentSelectedCell;
|
|
|
|
|
1999-09-30 00:08:15 +04:00
|
|
|
public:
|
|
|
|
static nsIAtom *gTypingTxnName;
|
1999-10-26 22:54:47 +04:00
|
|
|
static nsIAtom *gIMETxnName;
|
1999-10-06 23:34:09 +04:00
|
|
|
static nsIAtom *gDeleteTxnName;
|
1999-09-30 00:08:15 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
// friends
|
|
|
|
friend class nsHTMLEditRules;
|
|
|
|
friend class nsTextEditRules;
|
1999-05-03 22:48:39 +04:00
|
|
|
|
1999-03-01 22:54:47 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //nsHTMLEditor_h__
|
|
|
|
|