2007-03-22 10:30:00 -07:00
|
|
|
/* -*- 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
|
|
|
|
*
|
|
|
|
* 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/
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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):
|
|
|
|
* Daniel Glazman <glazman@netscape.com>
|
|
|
|
*
|
|
|
|
* 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 ***** */
|
|
|
|
|
|
|
|
#ifndef __editor_h__
|
|
|
|
#define __editor_h__
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
|
|
|
|
#include "nsIEditor.h"
|
2010-04-11 19:35:18 -07:00
|
|
|
#include "nsIPlaintextEditor.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIEditorIMESupport.h"
|
|
|
|
#include "nsIPhonetic.h"
|
|
|
|
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsISelection.h"
|
|
|
|
#include "nsIDOMCharacterData.h"
|
|
|
|
#include "nsIPrivateTextRange.h"
|
|
|
|
#include "nsITransactionManager.h"
|
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsIEditActionListener.h"
|
|
|
|
#include "nsIEditorObserver.h"
|
|
|
|
#include "nsIDocumentStateListener.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsSelectionState.h"
|
|
|
|
#include "nsIEditorSpellCheck.h"
|
|
|
|
#include "nsIInlineSpellChecker.h"
|
2011-06-23 19:18:00 -07:00
|
|
|
#include "nsIDOMEventTarget.h"
|
2007-10-03 05:16:50 -07:00
|
|
|
#include "nsStubMutationObserver.h"
|
2008-01-26 15:59:50 -08:00
|
|
|
#include "nsIViewManager.h"
|
2009-05-08 21:59:25 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2011-09-13 11:58:54 -07:00
|
|
|
#include "nsIObserver.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIDOMCharacterData;
|
|
|
|
class nsIDOMRange;
|
|
|
|
class nsIPresShell;
|
|
|
|
class ChangeAttributeTxn;
|
|
|
|
class CreateElementTxn;
|
|
|
|
class InsertElementTxn;
|
|
|
|
class DeleteElementTxn;
|
|
|
|
class InsertTextTxn;
|
|
|
|
class DeleteTextTxn;
|
|
|
|
class SplitElementTxn;
|
|
|
|
class JoinElementTxn;
|
|
|
|
class EditAggregateTxn;
|
|
|
|
class IMETextTxn;
|
|
|
|
class AddStyleSheetTxn;
|
|
|
|
class RemoveStyleSheetTxn;
|
|
|
|
class nsIFile;
|
|
|
|
class nsISelectionController;
|
2007-05-14 02:11:38 -07:00
|
|
|
class nsIDOMEventTarget;
|
2010-05-11 13:41:47 -07:00
|
|
|
class nsCSSStyleSheet;
|
2010-06-09 18:16:58 -07:00
|
|
|
class nsKeyEvent;
|
2010-12-06 22:30:05 -08:00
|
|
|
class nsIDOMNSEvent;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-27 03:51:53 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
struct IMEState;
|
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2010-05-03 06:23:36 -07:00
|
|
|
#define kMOZEditorBogusNodeAttrAtom nsEditProperty::mozEditorBogusNode
|
2007-03-22 10:30:00 -07:00
|
|
|
#define kMOZEditorBogusNodeValue NS_LITERAL_STRING("TRUE")
|
|
|
|
|
|
|
|
/** implementation of an editor object. it will be the controller/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.
|
|
|
|
*/
|
|
|
|
class nsEditor : public nsIEditor,
|
|
|
|
public nsIEditorIMESupport,
|
|
|
|
public nsSupportsWeakReference,
|
2011-09-13 11:58:54 -07:00
|
|
|
public nsIObserver,
|
2011-04-11 13:00:32 -07:00
|
|
|
public nsIPhonetic
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum IterDirection
|
|
|
|
{
|
|
|
|
kIterForward,
|
|
|
|
kIterBackward
|
|
|
|
};
|
|
|
|
|
|
|
|
enum OperationID
|
|
|
|
{
|
|
|
|
kOpIgnore = -1,
|
|
|
|
kOpNone = 0,
|
|
|
|
kOpUndo,
|
|
|
|
kOpRedo,
|
|
|
|
kOpInsertNode,
|
|
|
|
kOpCreateNode,
|
|
|
|
kOpDeleteNode,
|
|
|
|
kOpSplitNode,
|
|
|
|
kOpJoinNode,
|
|
|
|
kOpDeleteSelection,
|
|
|
|
// text commands
|
|
|
|
kOpInsertBreak = 1000,
|
|
|
|
kOpInsertText = 1001,
|
|
|
|
kOpInsertIMEText = 1002,
|
|
|
|
kOpDeleteText = 1003
|
|
|
|
};
|
|
|
|
|
|
|
|
/** 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 don't believe so.
|
|
|
|
*/
|
|
|
|
virtual ~nsEditor();
|
|
|
|
|
|
|
|
//Interfaces for addref and release and queryinterface
|
|
|
|
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
|
2009-05-08 21:59:25 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsEditor,
|
|
|
|
nsIEditor)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* ------------ utility methods -------------- */
|
2011-05-22 05:43:13 -07:00
|
|
|
already_AddRefed<nsIPresShell> GetPresShell();
|
|
|
|
void NotifyEditorObservers();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* ------------ nsIEditor methods -------------- */
|
|
|
|
NS_DECL_NSIEDITOR
|
|
|
|
/* ------------ nsIEditorIMESupport methods -------------- */
|
|
|
|
NS_DECL_NSIEDITORIMESUPPORT
|
|
|
|
|
2011-09-13 11:58:54 -07:00
|
|
|
/* ------------ nsIObserver methods -------------- */
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIPhonetic
|
|
|
|
NS_DECL_NSIPHONETIC
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2011-11-28 04:53:29 -08:00
|
|
|
virtual bool IsModifiableNode(nsINode *aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD InsertTextImpl(const nsAString& aStringToInsert,
|
|
|
|
nsCOMPtr<nsIDOMNode> *aInOutNode,
|
|
|
|
PRInt32 *aInOutOffset,
|
|
|
|
nsIDOMDocument *aDoc);
|
2010-01-12 18:35:50 -08:00
|
|
|
nsresult InsertTextIntoTextNodeImpl(const nsAString& aStringToInsert,
|
|
|
|
nsIDOMCharacterData *aTextNode,
|
|
|
|
PRInt32 aOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aSuppressIME = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD DeleteSelectionImpl(EDirection aAction);
|
|
|
|
NS_IMETHOD DeleteSelectionAndCreateNode(const nsAString& aTag,
|
|
|
|
nsIDOMNode ** aNewNode);
|
|
|
|
|
|
|
|
/* helper routines for node/parent manipulations */
|
|
|
|
nsresult ReplaceContainer(nsIDOMNode *inNode,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outNode,
|
|
|
|
const nsAString &aNodeType,
|
|
|
|
const nsAString *aAttribute = nsnull,
|
|
|
|
const nsAString *aValue = nsnull,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCloneAttributes = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsresult RemoveContainer(nsIDOMNode *inNode);
|
|
|
|
nsresult InsertContainerAbove(nsIDOMNode *inNode,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outNode,
|
|
|
|
const nsAString &aNodeType,
|
|
|
|
const nsAString *aAttribute = nsnull,
|
|
|
|
const nsAString *aValue = nsnull);
|
|
|
|
nsresult MoveNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset);
|
|
|
|
|
|
|
|
/* Method to replace certain CreateElementNS() calls.
|
|
|
|
Arguments:
|
|
|
|
nsString& aTag - tag you want
|
|
|
|
nsIContent** aContent - returned Content that was created with above namespace.
|
|
|
|
*/
|
|
|
|
nsresult CreateHTMLContent(const nsAString& aTag, nsIContent** aContent);
|
|
|
|
|
2010-06-29 21:05:12 -07:00
|
|
|
// IME event handlers
|
|
|
|
virtual nsresult BeginIMEComposition();
|
|
|
|
virtual nsresult UpdateIMEComposition(const nsAString &aCompositionString,
|
|
|
|
nsIPrivateTextRangeList *aTextRange)=0;
|
|
|
|
nsresult EndIMEComposition();
|
|
|
|
|
2011-09-15 07:54:50 -07:00
|
|
|
void SwitchTextDirectionTo(PRUint32 aDirection);
|
|
|
|
|
2011-01-15 20:16:45 -08:00
|
|
|
void BeginKeypressHandling() { mLastKeypressEventWasTrusted = eTriTrue; }
|
2010-12-06 22:30:05 -08:00
|
|
|
void BeginKeypressHandling(nsIDOMNSEvent* aEvent);
|
|
|
|
void EndKeypressHandling() { mLastKeypressEventWasTrusted = eTriUnset; }
|
|
|
|
|
2011-01-15 20:16:45 -08:00
|
|
|
class FireTrustedInputEvent {
|
|
|
|
public:
|
2011-09-28 23:19:26 -07:00
|
|
|
explicit FireTrustedInputEvent(nsEditor* aSelf, bool aActive = true)
|
2011-01-15 20:16:45 -08:00
|
|
|
: mEditor(aSelf)
|
|
|
|
, mShouldAct(aActive && mEditor->mLastKeypressEventWasTrusted == eTriUnset) {
|
|
|
|
if (mShouldAct) {
|
|
|
|
mEditor->BeginKeypressHandling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
~FireTrustedInputEvent() {
|
|
|
|
if (mShouldAct) {
|
|
|
|
mEditor->EndKeypressHandling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsEditor* mEditor;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mShouldAct;
|
2011-01-15 20:16:45 -08:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
nsCString mContentMIMEType; // MIME type of the doc we are editing.
|
|
|
|
|
2011-09-15 07:54:50 -07:00
|
|
|
nsresult DetermineCurrentDirection();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/** create a transaction for setting aAttribute to aValue on aElement
|
|
|
|
*/
|
|
|
|
NS_IMETHOD CreateTxnForSetAttribute(nsIDOMElement *aElement,
|
|
|
|
const nsAString & aAttribute,
|
|
|
|
const nsAString & aValue,
|
|
|
|
ChangeAttributeTxn ** aTxn);
|
|
|
|
|
|
|
|
/** create a transaction for removing aAttribute on aElement
|
|
|
|
*/
|
|
|
|
NS_IMETHOD CreateTxnForRemoveAttribute(nsIDOMElement *aElement,
|
|
|
|
const nsAString & aAttribute,
|
|
|
|
ChangeAttributeTxn ** aTxn);
|
|
|
|
|
|
|
|
/** create a transaction for creating a new child node of aParent of type aTag.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD CreateTxnForCreateElement(const nsAString & aTag,
|
|
|
|
nsIDOMNode *aParent,
|
|
|
|
PRInt32 aPosition,
|
|
|
|
CreateElementTxn ** aTxn);
|
|
|
|
|
|
|
|
/** create a transaction for inserting aNode as a child of aParent.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD CreateTxnForInsertElement(nsIDOMNode * aNode,
|
|
|
|
nsIDOMNode * aParent,
|
|
|
|
PRInt32 aOffset,
|
|
|
|
InsertElementTxn ** aTxn);
|
|
|
|
|
|
|
|
/** create a transaction for removing aElement from its parent.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD CreateTxnForDeleteElement(nsIDOMNode * aElement,
|
|
|
|
DeleteElementTxn ** aTxn);
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHOD CreateTxnForDeleteSelection(EDirection aAction,
|
|
|
|
EditAggregateTxn ** aTxn,
|
|
|
|
nsIDOMNode ** aNode,
|
|
|
|
PRInt32 *aOffset,
|
|
|
|
PRInt32 *aLength);
|
|
|
|
|
|
|
|
NS_IMETHOD CreateTxnForDeleteInsertionPoint(nsIDOMRange *aRange,
|
|
|
|
EDirection aAction,
|
|
|
|
EditAggregateTxn *aTxn,
|
|
|
|
nsIDOMNode ** aNode,
|
|
|
|
PRInt32 *aOffset,
|
|
|
|
PRInt32 *aLength);
|
|
|
|
|
|
|
|
|
|
|
|
/** create a transaction for inserting aStringToInsert into aTextNode
|
|
|
|
* if aTextNode is null, the string is inserted at the current selection.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD CreateTxnForInsertText(const nsAString & aStringToInsert,
|
|
|
|
nsIDOMCharacterData *aTextNode,
|
|
|
|
PRInt32 aOffset,
|
|
|
|
InsertTextTxn ** aTxn);
|
|
|
|
|
|
|
|
NS_IMETHOD CreateTxnForIMEText(const nsAString & aStringToInsert,
|
|
|
|
IMETextTxn ** aTxn);
|
|
|
|
|
|
|
|
/** create a transaction for adding a style sheet
|
|
|
|
*/
|
2010-05-11 13:41:47 -07:00
|
|
|
NS_IMETHOD CreateTxnForAddStyleSheet(nsCSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** create a transaction for removing a style sheet
|
|
|
|
*/
|
2010-05-11 13:41:47 -07:00
|
|
|
NS_IMETHOD CreateTxnForRemoveStyleSheet(nsCSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD DeleteText(nsIDOMCharacterData *aElement,
|
|
|
|
PRUint32 aOffset,
|
|
|
|
PRUint32 aLength);
|
|
|
|
|
|
|
|
// NS_IMETHOD DeleteRange(nsIDOMRange *aRange);
|
|
|
|
|
|
|
|
NS_IMETHOD CreateTxnForDeleteText(nsIDOMCharacterData *aElement,
|
|
|
|
PRUint32 aOffset,
|
|
|
|
PRUint32 aLength,
|
|
|
|
DeleteTextTxn **aTxn);
|
|
|
|
|
|
|
|
nsresult CreateTxnForDeleteCharacter(nsIDOMCharacterData *aData,
|
|
|
|
PRUint32 aOffset,
|
|
|
|
nsIEditor::EDirection aDirection,
|
|
|
|
DeleteTextTxn **aTxn);
|
|
|
|
|
|
|
|
NS_IMETHOD CreateTxnForSplitNode(nsIDOMNode *aNode,
|
|
|
|
PRUint32 aOffset,
|
|
|
|
SplitElementTxn **aTxn);
|
|
|
|
|
|
|
|
NS_IMETHOD CreateTxnForJoinNode(nsIDOMNode *aLeftNode,
|
|
|
|
nsIDOMNode *aRightNode,
|
|
|
|
JoinElementTxn **aTxn);
|
|
|
|
|
|
|
|
NS_IMETHOD DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNode> &parentSelectedNode,
|
|
|
|
PRInt32& offsetOfNewNode);
|
|
|
|
|
|
|
|
// called after a transaction is done successfully
|
|
|
|
NS_IMETHOD DoAfterDoTransaction(nsITransaction *aTxn);
|
|
|
|
// called after a transaction is undone successfully
|
|
|
|
NS_IMETHOD DoAfterUndoTransaction();
|
|
|
|
// called after a transaction is redone successfully
|
|
|
|
NS_IMETHOD DoAfterRedoTransaction();
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
eDocumentCreated,
|
|
|
|
eDocumentToBeDestroyed,
|
|
|
|
eDocumentStateChanged
|
|
|
|
} TDocumentListenerNotification;
|
|
|
|
|
|
|
|
// tell the doc state listeners that the doc state has changed
|
|
|
|
NS_IMETHOD NotifyDocumentListeners(TDocumentListenerNotification aNotificationType);
|
|
|
|
|
|
|
|
/** make the given selection span the entire document */
|
|
|
|
NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
|
|
|
|
|
|
|
|
/** helper method for scrolling the selection into view after
|
2011-10-17 07:59:28 -07:00
|
|
|
* an edit operation. aScrollToAnchor should be true if you
|
2007-03-22 10:30:00 -07:00
|
|
|
* want to scroll to the point where the selection was started.
|
2011-10-17 07:59:28 -07:00
|
|
|
* If false, it attempts to scroll the end of the selection into view.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* Editor methods *should* call this method instead of the versions
|
|
|
|
* in the various selection interfaces, since this version makes sure
|
|
|
|
* that the editor's sync/async settings for reflowing, painting, and
|
|
|
|
* scrolling match.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD ScrollSelectionIntoView(bool aScrollToAnchor);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// stub. see comment in source.
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsBlockNode(nsIDOMNode *aNode);
|
2011-11-28 04:53:29 -08:00
|
|
|
virtual bool IsBlockNode(nsINode *aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-28 04:54:03 -08:00
|
|
|
// helper for GetPriorNode and GetNextNode
|
|
|
|
nsIContent* FindNextLeafNode(nsINode *aCurrentNode,
|
|
|
|
bool aGoForward,
|
2011-11-28 04:54:32 -08:00
|
|
|
bool bNoBlockCrossing,
|
|
|
|
nsIContent *aActiveEditorRoot);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-07-13 19:56:18 -07:00
|
|
|
// Get nsIWidget interface
|
|
|
|
nsresult GetWidget(nsIWidget **aWidget);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
// install the event listeners for the editor
|
2010-04-19 05:20:42 -07:00
|
|
|
virtual nsresult InstallEventListeners();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-07-15 03:18:35 -07:00
|
|
|
virtual void CreateEventListeners();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// unregister and release our event listeners
|
|
|
|
virtual void RemoveEventListeners();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if spellchecking should be enabled for this editor.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetDesiredSpellCheckState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-09 18:16:58 -07:00
|
|
|
nsKeyEvent* GetNativeKeyEvent(nsIDOMKeyEvent* aDOMKeyEvent);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool CanEnableSpellCheck()
|
2010-08-19 04:27:04 -07:00
|
|
|
{
|
|
|
|
// Check for password/readonly/disabled, which are not spellchecked
|
2011-10-16 19:06:24 -07:00
|
|
|
// regardless of DOM. Also, check to see if spell check should be skipped or not.
|
|
|
|
return !IsPasswordEditor() && !IsReadonly() && !IsDisabled() && !ShouldSkipSpellCheck();
|
2010-08-19 04:27:04 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
|
|
|
|
/** 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 */
|
|
|
|
NS_IMETHOD EndOperation();
|
|
|
|
|
|
|
|
/** routines for managing the preservation of selection across
|
|
|
|
* various editor actions */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ArePreservingSelection();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult PreserveSelectionAcrossActions(nsISelection *aSel);
|
|
|
|
nsresult RestorePreservedSelection(nsISelection *aSel);
|
|
|
|
void StopPreservingSelection();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
nsresult SplitNodeImpl(nsIDOMNode *aExistingRightNode,
|
|
|
|
PRInt32 aOffset,
|
|
|
|
nsIDOMNode *aNewLeftNode,
|
|
|
|
nsIDOMNode *aParent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* @param aParent The parent of aNodeToKeep
|
2011-10-17 07:59:28 -07:00
|
|
|
* @param aNodeToKeepIsFirst if true, the contents|children of aNodeToKeep come before the
|
2007-03-22 10:30:00 -07:00
|
|
|
* contents|children of aNodeToJoin, otherwise their positions are switched.
|
|
|
|
*/
|
|
|
|
nsresult JoinNodesImpl(nsIDOMNode *aNodeToKeep,
|
|
|
|
nsIDOMNode *aNodeToJoin,
|
|
|
|
nsIDOMNode *aParent,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNodeToKeepIsFirst);
|
2007-03-22 10:30:00 -07: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);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
/** 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);
|
|
|
|
|
|
|
|
/** get the node immediately prior to aCurrentNode
|
|
|
|
* @param aCurrentNode the node from which we start the search
|
2011-10-17 07:59:28 -07:00
|
|
|
* @param aEditableNode if true, only return an editable node
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aResultNode [OUT] the node that occurs before aCurrentNode in the tree,
|
2011-10-17 07:59:28 -07:00
|
|
|
* skipping non-editable nodes if aEditableNode is true.
|
2007-03-22 10:30:00 -07:00
|
|
|
* If there is no prior node, aResultNode will be nsnull.
|
2011-11-28 04:54:32 -08:00
|
|
|
* @param bNoBlockCrossing If true, don't move across "block" nodes, whatever that means.
|
|
|
|
* @param aActiveEditorRoot If non-null, only return descendants of aActiveEditorRoot.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
nsresult GetPriorNode(nsIDOMNode *aCurrentNode,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aEditableNode,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIDOMNode> *aResultNode,
|
2011-11-28 04:54:32 -08:00
|
|
|
bool bNoBlockCrossing = false,
|
|
|
|
nsIContent *aActiveEditorRoot = nsnull);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// and another version that takes a {parent,offset} pair rather than a node
|
|
|
|
nsresult GetPriorNode(nsIDOMNode *aParentNode,
|
|
|
|
PRInt32 aOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aEditableNode,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIDOMNode> *aResultNode,
|
2011-11-28 04:54:32 -08:00
|
|
|
bool bNoBlockCrossing = false,
|
|
|
|
nsIContent *aActiveEditorRoot = nsnull);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** get the node immediately after to aCurrentNode
|
|
|
|
* @param aCurrentNode the node from which we start the search
|
2011-10-17 07:59:28 -07:00
|
|
|
* @param aEditableNode if true, only return an editable node
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aResultNode [OUT] the node that occurs after aCurrentNode in the tree,
|
2011-10-17 07:59:28 -07:00
|
|
|
* skipping non-editable nodes if aEditableNode is true.
|
2007-03-22 10:30:00 -07:00
|
|
|
* If there is no prior node, aResultNode will be nsnull.
|
|
|
|
*/
|
|
|
|
nsresult GetNextNode(nsIDOMNode *aCurrentNode,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aEditableNode,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIDOMNode> *aResultNode,
|
2011-11-28 04:54:32 -08:00
|
|
|
bool bNoBlockCrossing = false,
|
|
|
|
nsIContent *aActiveEditorRoot = nsnull);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// and another version that takes a {parent,offset} pair rather than a node
|
|
|
|
nsresult GetNextNode(nsIDOMNode *aParentNode,
|
|
|
|
PRInt32 aOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aEditableNode,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIDOMNode> *aResultNode,
|
2011-11-28 04:54:32 -08:00
|
|
|
bool bNoBlockCrossing = false,
|
|
|
|
nsIContent *aActiveEditorRoot = nsnull);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-28 04:54:14 -08:00
|
|
|
// Helper for GetNextNode and GetPriorNode
|
|
|
|
nsIContent* FindNode(nsINode *aCurrentNode,
|
|
|
|
bool aGoForward,
|
|
|
|
bool aEditableNode,
|
2011-11-28 04:54:32 -08:00
|
|
|
bool bNoBlockCrossing,
|
|
|
|
nsIContent *aActiveEditorRoot);
|
2011-08-11 06:29:59 -07:00
|
|
|
/**
|
|
|
|
* Get the rightmost child of aCurrentNode;
|
|
|
|
* return nsnull if aCurrentNode has no children.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsIDOMNode> GetRightmostChild(nsIDOMNode *aCurrentNode,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool bNoBlockCrossing = false);
|
2011-11-28 04:53:29 -08:00
|
|
|
nsIContent* GetRightmostChild(nsINode *aCurrentNode,
|
|
|
|
bool bNoBlockCrossing = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-08-11 06:29:59 -07:00
|
|
|
/**
|
|
|
|
* Get the leftmost child of aCurrentNode;
|
|
|
|
* return nsnull if aCurrentNode has no children.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsIDOMNode> GetLeftmostChild(nsIDOMNode *aCurrentNode,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool bNoBlockCrossing = false);
|
2011-11-28 04:53:29 -08:00
|
|
|
nsIContent* GetLeftmostChild(nsINode *aCurrentNode,
|
|
|
|
bool bNoBlockCrossing = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
/** returns true if aNode is of the type implied by aTag */
|
2011-09-28 23:19:26 -07:00
|
|
|
static inline bool NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return GetTag(aNode) == aTag;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we should get rid of this method if we can
|
2011-09-28 23:19:26 -07:00
|
|
|
static inline bool NodeIsTypeString(nsIDOMNode *aNode, const nsAString &aTag)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsIAtom *nodeAtom = GetTag(aNode);
|
|
|
|
return nodeAtom && nodeAtom->Equals(aTag);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
/** returns true if aParent can contain a child of type aTag */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool CanContainTag(nsIDOMNode* aParent, const nsAString &aTag);
|
|
|
|
bool TagCanContain(const nsAString &aParentTag, nsIDOMNode* aChild);
|
|
|
|
virtual bool TagCanContainTag(const nsAString &aParentTag, const nsAString &aChildTag);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
/** returns true if aNode is our root node */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsRootNode(nsIDOMNode *inNode);
|
2011-11-28 04:53:29 -08:00
|
|
|
bool IsRootNode(nsINode *inNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
/** returns true if aNode is a descendant of our root node */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsDescendantOfBody(nsIDOMNode *inNode);
|
2011-11-28 04:53:29 -08:00
|
|
|
bool IsDescendantOfBody(nsINode *inNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
/** returns true if aNode is a container */
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsContainer(nsIDOMNode *aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
/** returns true if aNode is an editable node */
|
2011-10-25 19:32:55 -07:00
|
|
|
bool IsEditable(nsIDOMNode *aNode);
|
2011-11-28 04:53:29 -08:00
|
|
|
bool IsEditable(nsIContent *aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-28 04:53:29 -08:00
|
|
|
virtual bool IsTextInDirtyFrameVisible(nsIContent *aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
/** returns true if aNode is a MozEditorBogus node */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsMozEditorBogusNode(nsIDOMNode *aNode);
|
2011-11-28 04:53:29 -08:00
|
|
|
bool IsMozEditorBogusNode(nsIContent *aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/** counts number of editable child nodes */
|
|
|
|
nsresult CountEditableChildren(nsIDOMNode *aNode, PRUint32 &outCount);
|
|
|
|
|
|
|
|
/** Find the deep first and last children. Returned nodes are AddReffed */
|
|
|
|
nsresult GetFirstEditableNode(nsIDOMNode *aRoot, nsCOMPtr<nsIDOMNode> *outFirstNode);
|
|
|
|
#ifdef XXX_DEAD_CODE
|
|
|
|
nsresult GetLastEditableNode(nsIDOMNode *aRoot, nsCOMPtr<nsIDOMNode> *outLastNode);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsresult GetIMEBufferLength(PRInt32* length);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsIMEComposing(); /* test if IME is in composition state */
|
2007-03-22 10:30:00 -07:00
|
|
|
void SetIsIMEComposing(); /* call this before |IsIMEComposing()| */
|
|
|
|
|
|
|
|
/** from html rules code - migration in progress */
|
|
|
|
static nsresult GetTagString(nsIDOMNode *aNode, nsAString& outString);
|
|
|
|
static nsIAtom *GetTag(nsIDOMNode *aNode);
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2);
|
|
|
|
static bool IsTextOrElementNode(nsIDOMNode *aNode);
|
|
|
|
static bool IsTextNode(nsIDOMNode *aNode);
|
2011-11-28 04:53:29 -08:00
|
|
|
static bool IsTextNode(nsINode *aNode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static PRInt32 GetIndexOf(nsIDOMNode *aParent, nsIDOMNode *aChild);
|
|
|
|
static nsCOMPtr<nsIDOMNode> GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset);
|
2011-07-14 08:25:07 -07:00
|
|
|
static nsCOMPtr<nsIDOMNode> GetNodeAtRangeOffsetPoint(nsIDOMNode* aParentOrNode, PRInt32 aOffset);
|
|
|
|
|
2010-06-10 19:46:51 -07:00
|
|
|
static nsresult GetStartNodeAndOffset(nsISelection *aSelection, nsIDOMNode **outStartNode, PRInt32 *outStartOffset);
|
|
|
|
static nsresult GetEndNodeAndOffset(nsISelection *aSelection, nsIDOMNode **outEndNode, PRInt32 *outEndOffset);
|
2007-03-22 10:30:00 -07:00
|
|
|
#if DEBUG_JOE
|
|
|
|
static void DumpNode(nsIDOMNode *aNode, PRInt32 indent=0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Helpers to add a node to the selection.
|
|
|
|
// Used by table cell selection methods
|
|
|
|
nsresult CreateRange(nsIDOMNode *aStartParent, PRInt32 aStartOffset,
|
|
|
|
nsIDOMNode *aEndParent, PRInt32 aEndOffset,
|
|
|
|
nsIDOMRange **aRange);
|
|
|
|
|
|
|
|
// Creates a range with just the supplied node and appends that to the selection
|
|
|
|
nsresult AppendNodeToSelectionAsRange(nsIDOMNode *aNode);
|
|
|
|
// When you are using AppendNodeToSelectionAsRange, call this first to start a new selection
|
|
|
|
nsresult ClearSelection();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult IsPreformatted(nsIDOMNode *aNode, bool *aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsresult SplitNodeDeep(nsIDOMNode *aNode,
|
|
|
|
nsIDOMNode *aSplitPointParent,
|
|
|
|
PRInt32 aSplitPointOffset,
|
|
|
|
PRInt32 *outOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNoEmptyContainers = false,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIDOMNode> *outLeftNode = 0,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outRightNode = 0);
|
|
|
|
nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsCOMPtr<nsIDOMNode> *aOutJoinNode, PRInt32 *outOffset);
|
|
|
|
|
|
|
|
nsresult GetString(const nsAString& name, nsAString& value);
|
|
|
|
|
|
|
|
nsresult BeginUpdateViewBatch(void);
|
|
|
|
virtual nsresult EndUpdateViewBatch(void);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetShouldTxnSetSelection();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-09 18:16:58 -07:00
|
|
|
virtual nsresult HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult HandleInlineSpellCheck(PRInt32 action,
|
|
|
|
nsISelection *aSelection,
|
|
|
|
nsIDOMNode *previousSelectedNode,
|
|
|
|
PRInt32 previousSelectedOffset,
|
|
|
|
nsIDOMNode *aStartNode,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
nsIDOMNode *aEndNode,
|
|
|
|
PRInt32 aEndOffset);
|
|
|
|
|
2011-06-23 19:18:01 -07:00
|
|
|
virtual already_AddRefed<nsIDOMEventTarget> GetDOMEventTarget() = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Fast non-refcounting editor root element accessor
|
2011-12-03 13:50:15 -08:00
|
|
|
mozilla::dom::Element *GetRoot();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-11 19:35:18 -07:00
|
|
|
// Accessor methods to flags
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsPlaintextEditor() const
|
2010-04-11 19:35:18 -07:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorPlaintextMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsSingleLineEditor() const
|
2010-04-11 19:35:18 -07:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorSingleLineMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsPasswordEditor() const
|
2010-04-11 19:35:18 -07:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorPasswordMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsReadonly() const
|
2010-04-11 19:35:18 -07:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorReadonlyMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsDisabled() const
|
2010-04-11 19:35:18 -07:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorDisabledMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsInputFiltered() const
|
2010-04-11 19:35:18 -07:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorFilterInputMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsMailEditor() const
|
2010-04-11 19:35:18 -07:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorMailMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsWrapHackEnabled() const
|
2010-04-11 19:35:18 -07:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorEnableWrapHackMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsFormWidget() const
|
2010-04-11 19:35:18 -07:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorWidgetMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool NoCSS() const
|
2010-04-11 19:35:18 -07:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorNoCSSMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsInteractionAllowed() const
|
2010-04-11 19:35:18 -07:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorAllowInteraction) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool DontEchoPassword() const
|
2010-04-11 19:35:18 -07:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorDontEchoPassword) != 0;
|
|
|
|
}
|
2011-10-16 19:06:24 -07:00
|
|
|
|
|
|
|
PRBool ShouldSkipSpellCheck() const
|
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorSkipSpellCheck) != 0;
|
|
|
|
}
|
2010-04-11 19:35:18 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsTabbable() const
|
2010-06-09 18:16:58 -07:00
|
|
|
{
|
|
|
|
return IsSingleLineEditor() || IsPasswordEditor() || IsFormWidget() ||
|
|
|
|
IsInteractionAllowed();
|
|
|
|
}
|
|
|
|
|
2010-10-29 09:30:52 -07:00
|
|
|
// Get the focused content, if we're focused. Returns null otherwise.
|
|
|
|
virtual already_AddRefed<nsIContent> GetFocusedContent();
|
2010-05-04 10:40:39 -07:00
|
|
|
|
2010-07-22 09:22:44 -07:00
|
|
|
// Whether the editor is active on the DOM window. Note that when this
|
2010-10-29 09:30:52 -07:00
|
|
|
// returns true but GetFocusedContent() returns null, it means that this editor was
|
2010-07-22 09:22:44 -07:00
|
|
|
// focused when the DOM window was active.
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsActiveInDOMWindow();
|
2010-07-22 09:22:44 -07:00
|
|
|
|
|
|
|
// Whether the aEvent should be handled by this editor or not. When this
|
|
|
|
// returns FALSE, The aEvent shouldn't be handled on this editor,
|
|
|
|
// i.e., The aEvent should be handled by another inner editor or ancestor
|
|
|
|
// elements.
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsAcceptableInputEvent(nsIDOMEvent* aEvent);
|
2010-07-22 09:22:44 -07:00
|
|
|
|
2010-06-16 22:30:42 -07:00
|
|
|
// FindSelectionRoot() returns a selection root of this editor when aNode
|
|
|
|
// gets focus. aNode must be a content node or a document node. When the
|
|
|
|
// target isn't a part of this editor, returns NULL. If this is for
|
|
|
|
// designMode, you should set the document node to aNode except that an
|
|
|
|
// element in the document has focus.
|
|
|
|
virtual already_AddRefed<nsIContent> FindSelectionRoot(nsINode* aNode);
|
|
|
|
|
|
|
|
// Initializes selection and caret for the editor. If aEventTarget isn't
|
|
|
|
// a host of the editor, i.e., the editor doesn't get focus, this does
|
|
|
|
// nothing.
|
|
|
|
nsresult InitializeSelection(nsIDOMEventTarget* aFocusEventTarget);
|
|
|
|
|
2011-08-12 12:12:45 -07:00
|
|
|
// This method has to be called by nsEditorEventListener::Focus.
|
|
|
|
// All actions that have to be done when the editor is focused needs to be
|
|
|
|
// added here.
|
|
|
|
void OnFocus(nsIDOMEventTarget* aFocusEventTarget);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
|
2011-12-03 13:50:15 -08:00
|
|
|
PRUint32 mModCount; // number of modifications (for undo/redo stack)
|
|
|
|
PRUint32 mFlags; // behavior flags. See nsIPlaintextEditor.idl for the flags we use.
|
2011-03-10 21:40:31 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsWeakPtr mSelConWeak; // weak reference to the nsISelectionController
|
|
|
|
PRInt32 mUpdateCount;
|
2008-01-26 15:59:50 -08:00
|
|
|
nsIViewManager::UpdateViewBatch mBatch;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Spellchecking
|
|
|
|
enum Tristate {
|
|
|
|
eTriUnset,
|
|
|
|
eTriFalse,
|
|
|
|
eTriTrue
|
|
|
|
} mSpellcheckCheckboxState;
|
|
|
|
nsCOMPtr<nsIInlineSpellChecker> mInlineSpellChecker;
|
|
|
|
|
|
|
|
nsCOMPtr<nsITransactionManager> mTxnMgr;
|
|
|
|
nsWeakPtr mPlaceHolderTxn; // weak reference to placeholder for begin/end batch purposes
|
|
|
|
nsIAtom *mPlaceHolderName; // name of placeholder transaction
|
|
|
|
PRInt32 mPlaceHolderBatch; // nesting count for batching
|
|
|
|
nsSelectionState *mSelState; // saved selection state for placeholder txn batching
|
|
|
|
nsSelectionState mSavedSel; // cached selection for nsAutoSelectionReset
|
|
|
|
nsRangeUpdater mRangeUpdater; // utility class object for maintaining preserved ranges
|
2011-12-03 13:50:15 -08:00
|
|
|
nsCOMPtr<mozilla::dom::Element> mRootElement; // cached root node
|
2007-03-22 10:30:00 -07:00
|
|
|
PRInt32 mAction; // the current editor action
|
|
|
|
EDirection mDirection; // the current direction of editor action
|
|
|
|
|
|
|
|
// data necessary to build IME transactions
|
|
|
|
nsCOMPtr<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
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mInIMEMode; // are we inside an IME composition?
|
|
|
|
bool mIsIMEComposing; // is IME in composition state?
|
2007-03-22 10:30:00 -07:00
|
|
|
// This is different from mInIMEMode. see Bug 98434.
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mShouldTxnSetSelection; // turn off for conservative selection adjustment by txns
|
|
|
|
bool mDidPreDestroy; // whether PreDestroy has been called
|
|
|
|
bool mDidPostCreate; // whether PostCreate has been called
|
2007-03-22 10:30:00 -07:00
|
|
|
// various listeners
|
|
|
|
nsCOMArray<nsIEditActionListener> mActionListeners; // listens to all low level actions on the doc
|
|
|
|
nsCOMArray<nsIEditorObserver> mEditorObservers; // just notify once per high level change
|
|
|
|
nsCOMArray<nsIDocumentStateListener> mDocStateListeners;// listen to overall doc state (dirty or not, just created, etc)
|
|
|
|
|
|
|
|
PRInt8 mDocDirtyState; // -1 = not initialized
|
|
|
|
nsWeakPtr mDocWeak; // weak reference to the nsIDOMDocument
|
|
|
|
// The form field as an event receiver
|
2011-06-23 19:18:00 -07:00
|
|
|
nsCOMPtr<nsIDOMEventTarget> mEventTarget;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsString* mPhonetic;
|
|
|
|
|
2010-03-05 20:01:28 -08:00
|
|
|
nsCOMPtr<nsIDOMEventListener> mEventListener;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-12-06 22:30:05 -08:00
|
|
|
Tristate mLastKeypressEventWasTrusted;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
friend bool NSCanUnload(nsISupports* serviceMgr);
|
2007-03-22 10:30:00 -07:00
|
|
|
friend class nsAutoTxnsConserveSelection;
|
|
|
|
friend class nsAutoSelectionReset;
|
|
|
|
friend class nsAutoRules;
|
|
|
|
friend class nsRangeUpdater;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|