2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-02-12 20:18:58 +03:00
|
|
|
|
|
|
|
#ifndef __editor_h__
|
|
|
|
#define __editor_h__
|
|
|
|
|
2013-01-29 04:33:17 +04:00
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc.
|
|
|
|
#include "mozilla/TypedEnum.h" // for MOZ_BEGIN_ENUM_CLASS, etc.
|
2014-05-02 16:15:27 +04:00
|
|
|
#include "mozilla/dom/Text.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsAutoPtr.h" // for nsRefPtr
|
|
|
|
#include "nsCOMArray.h" // for nsCOMArray
|
|
|
|
#include "nsCOMPtr.h" // for already_AddRefed, nsCOMPtr
|
2009-05-09 08:59:25 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2014-08-29 15:43:24 +04:00
|
|
|
#include "nsGkAtoms.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsIEditor.h" // for nsIEditor::EDirection, etc
|
|
|
|
#include "nsIEditorIMESupport.h" // for NS_DECL_NSIEDITORIMESUPPORT, etc
|
|
|
|
#include "nsIObserver.h" // for NS_DECL_NSIOBSERVER, etc
|
|
|
|
#include "nsIPhonetic.h" // for NS_DECL_NSIPHONETIC, etc
|
|
|
|
#include "nsIPlaintextEditor.h" // for nsIPlaintextEditor, etc
|
|
|
|
#include "nsISupportsImpl.h" // for nsEditor::Release, etc
|
|
|
|
#include "nsIWeakReferenceUtils.h" // for nsWeakPtr
|
|
|
|
#include "nsLiteralString.h" // for NS_LITERAL_STRING
|
|
|
|
#include "nsSelectionState.h" // for nsRangeUpdater, etc
|
|
|
|
#include "nsString.h" // for nsCString
|
|
|
|
#include "nsWeakReference.h" // for nsSupportsWeakReference
|
|
|
|
#include "nscore.h" // for nsresult, nsAString, etc
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
class AddStyleSheetTxn;
|
2012-06-19 17:23:36 +04:00
|
|
|
class DeleteNodeTxn;
|
1999-02-12 20:18:58 +03:00
|
|
|
class EditAggregateTxn;
|
1999-07-02 07:57:50 +04:00
|
|
|
class RemoveStyleSheetTxn;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsIAtom;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIDOMCharacterData;
|
|
|
|
class nsIDOMDataTransfer;
|
|
|
|
class nsIDOMDocument;
|
|
|
|
class nsIDOMElement;
|
|
|
|
class nsIDOMEvent;
|
|
|
|
class nsIDOMEventListener;
|
|
|
|
class nsIDOMEventTarget;
|
|
|
|
class nsIDOMKeyEvent;
|
|
|
|
class nsIDOMNode;
|
|
|
|
class nsIDocument;
|
|
|
|
class nsIDocumentStateListener;
|
|
|
|
class nsIEditActionListener;
|
2012-11-14 23:23:35 +04:00
|
|
|
class nsIEditorObserver;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsIInlineSpellChecker;
|
|
|
|
class nsINode;
|
|
|
|
class nsIPresShell;
|
|
|
|
class nsISupports;
|
|
|
|
class nsITransaction;
|
|
|
|
class nsIWidget;
|
|
|
|
class nsRange;
|
|
|
|
class nsString;
|
|
|
|
class nsTransactionManager;
|
2014-11-02 15:04:13 +03:00
|
|
|
struct DOMPoint;
|
2012-07-13 10:33:42 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2014-06-20 14:32:49 +04:00
|
|
|
class CSSStyleSheet;
|
2014-04-28 15:54:47 +04:00
|
|
|
class ErrorResult;
|
2014-02-12 17:02:55 +04:00
|
|
|
class TextComposition;
|
2012-07-13 10:33:42 +04:00
|
|
|
|
|
|
|
namespace dom {
|
2014-08-29 15:43:23 +04:00
|
|
|
class ChangeAttributeTxn;
|
2014-08-20 16:25:16 +04:00
|
|
|
class CreateElementTxn;
|
2013-07-09 21:54:21 +04:00
|
|
|
class DataTransfer;
|
2014-08-20 16:25:16 +04:00
|
|
|
class DeleteTextTxn;
|
2012-07-13 10:33:42 +04:00
|
|
|
class Element;
|
2013-10-23 03:32:04 +04:00
|
|
|
class EventTarget;
|
2014-08-29 15:43:24 +04:00
|
|
|
class IMETextTxn;
|
2014-08-29 15:43:23 +04:00
|
|
|
class InsertTextTxn;
|
2014-08-20 16:25:17 +04:00
|
|
|
class InsertNodeTxn;
|
2014-11-02 15:04:12 +03:00
|
|
|
class JoinNodeTxn;
|
2014-04-10 20:09:40 +04:00
|
|
|
class Selection;
|
2014-11-02 15:04:13 +03:00
|
|
|
class SplitNodeTxn;
|
2014-05-02 15:11:26 +04:00
|
|
|
class Text;
|
2012-07-13 10:33:42 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2005-06-17 01:52:44 +04:00
|
|
|
|
2011-11-27 15:51:53 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
struct IMEState;
|
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-08-29 15:43:24 +04:00
|
|
|
#define kMOZEditorBogusNodeAttrAtom nsGkAtoms::mozeditorbogusnode
|
2001-11-14 04:33:42 +03:00
|
|
|
#define kMOZEditorBogusNodeValue NS_LITERAL_STRING("TRUE")
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
// This is int32_t instead of int16_t because nsIInlineSpellChecker.idl's
|
2012-08-01 16:22:07 +04:00
|
|
|
// spellCheckAfterEditorChange is defined to take it as a long.
|
2012-08-22 19:56:38 +04:00
|
|
|
MOZ_BEGIN_ENUM_CLASS(EditAction, int32_t)
|
2012-08-01 16:22:07 +04:00
|
|
|
ignore = -1,
|
|
|
|
none = 0,
|
|
|
|
undo,
|
|
|
|
redo,
|
|
|
|
insertNode,
|
|
|
|
createNode,
|
|
|
|
deleteNode,
|
|
|
|
splitNode,
|
|
|
|
joinNode,
|
|
|
|
deleteText = 1003,
|
|
|
|
|
|
|
|
// text commands
|
|
|
|
insertText = 2000,
|
|
|
|
insertIMEText = 2001,
|
|
|
|
deleteSelection = 2002,
|
|
|
|
setTextProperty = 2003,
|
|
|
|
removeTextProperty = 2004,
|
|
|
|
outputText = 2005,
|
|
|
|
|
|
|
|
// html only action
|
|
|
|
insertBreak = 3000,
|
|
|
|
makeList = 3001,
|
|
|
|
indent = 3002,
|
|
|
|
outdent = 3003,
|
|
|
|
align = 3004,
|
|
|
|
makeBasicBlock = 3005,
|
|
|
|
removeList = 3006,
|
|
|
|
makeDefListItem = 3007,
|
|
|
|
insertElement = 3008,
|
|
|
|
insertQuotation = 3009,
|
|
|
|
htmlPaste = 3012,
|
|
|
|
loadHTML = 3013,
|
|
|
|
resetTextProperties = 3014,
|
|
|
|
setAbsolutePosition = 3015,
|
|
|
|
removeAbsolutePosition = 3016,
|
|
|
|
decreaseZIndex = 3017,
|
|
|
|
increaseZIndex = 3018
|
2012-08-12 22:28:26 +04:00
|
|
|
MOZ_END_ENUM_CLASS(EditAction)
|
2012-08-01 16:22:07 +04:00
|
|
|
|
2012-08-12 22:28:26 +04:00
|
|
|
inline bool operator!(const EditAction& aOp)
|
2012-08-01 16:22:07 +04:00
|
|
|
{
|
2012-08-12 22:28:26 +04:00
|
|
|
return aOp == EditAction::none;
|
2012-08-01 16:22:07 +04:00
|
|
|
}
|
|
|
|
|
2000-03-24 03:26:47 +03:00
|
|
|
/** implementation of an editor object. it will be the controller/focal point
|
1999-02-12 20:18:58 +03:00
|
|
|
* 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,
|
2000-04-27 11:37:12 +04:00
|
|
|
public nsIEditorIMESupport,
|
2002-12-18 02:38:04 +03:00
|
|
|
public nsSupportsWeakReference,
|
2011-09-13 22:58:54 +04:00
|
|
|
public nsIObserver,
|
2011-04-12 00:00:32 +04:00
|
|
|
public nsIPhonetic
|
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-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();
|
2014-06-24 02:40:02 +04:00
|
|
|
|
|
|
|
protected:
|
1999-02-12 20:18:58 +03:00
|
|
|
/** The default destructor. This should suffice. Should this be pure virtual
|
2005-11-25 11:16:51 +03:00
|
|
|
* for someone to derive from the nsEditor later? I don't believe so.
|
1999-02-12 20:18:58 +03:00
|
|
|
*/
|
|
|
|
virtual ~nsEditor();
|
2005-06-16 17:10:58 +04:00
|
|
|
|
2014-06-24 02:40:02 +04:00
|
|
|
public:
|
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
|
2009-05-09 08:59:25 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsEditor,
|
|
|
|
nsIEditor)
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2001-04-07 04:45:26 +04:00
|
|
|
/* ------------ utility methods -------------- */
|
2012-03-24 12:19:14 +04:00
|
|
|
already_AddRefed<nsIDOMDocument> GetDOMDocument();
|
|
|
|
already_AddRefed<nsIDocument> GetDocument();
|
2011-05-22 16:43:13 +04:00
|
|
|
already_AddRefed<nsIPresShell> GetPresShell();
|
2014-04-10 11:11:37 +04:00
|
|
|
already_AddRefed<nsIWidget> GetWidget();
|
2014-07-31 08:37:59 +04:00
|
|
|
enum NotificationForEditorObservers
|
|
|
|
{
|
|
|
|
eNotifyEditorObserversOfEnd,
|
|
|
|
eNotifyEditorObserversOfBefore,
|
|
|
|
eNotifyEditorObserversOfCancel
|
|
|
|
};
|
|
|
|
void NotifyEditorObservers(NotificationForEditorObservers aNotification);
|
2002-01-09 16:51:37 +03:00
|
|
|
|
2001-04-07 04:45:26 +04:00
|
|
|
/* ------------ nsIEditor methods -------------- */
|
|
|
|
NS_DECL_NSIEDITOR
|
2013-01-10 03:05:08 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
/* ------------ nsIEditorIMESupport methods -------------- */
|
2004-09-12 09:00:57 +04:00
|
|
|
NS_DECL_NSIEDITORIMESUPPORT
|
2013-01-10 03:05:08 +04:00
|
|
|
|
2011-09-13 22:58:54 +04:00
|
|
|
/* ------------ nsIObserver methods -------------- */
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2002-12-18 02:38:04 +03:00
|
|
|
// nsIPhonetic
|
|
|
|
NS_DECL_NSIPHONETIC
|
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
public:
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2011-11-28 16:53:29 +04:00
|
|
|
virtual bool IsModifiableNode(nsINode *aNode);
|
2013-01-10 03:05:08 +04:00
|
|
|
|
2014-11-02 15:04:13 +03:00
|
|
|
virtual nsresult InsertTextImpl(const nsAString& aStringToInsert,
|
|
|
|
nsCOMPtr<nsINode>* aInOutNode,
|
|
|
|
int32_t* aInOutOffset,
|
|
|
|
nsIDocument* aDoc);
|
2014-05-02 15:11:26 +04:00
|
|
|
nsresult InsertTextIntoTextNodeImpl(const nsAString& aStringToInsert,
|
2014-08-29 15:43:23 +04:00
|
|
|
mozilla::dom::Text& aTextNode,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aOffset,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aSuppressIME = false);
|
2012-05-10 18:54:33 +04:00
|
|
|
NS_IMETHOD DeleteSelectionImpl(EDirection aAction,
|
|
|
|
EStripWrappers aStripWrappers);
|
2014-11-02 15:04:13 +03:00
|
|
|
|
|
|
|
already_AddRefed<mozilla::dom::Element>
|
|
|
|
DeleteSelectionAndCreateElement(nsIAtom& aTag);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2000-03-24 03:26:47 +03:00
|
|
|
/* helper routines for node/parent manipulations */
|
2012-06-19 17:23:36 +04:00
|
|
|
nsresult DeleteNode(nsINode* aNode);
|
2014-08-20 16:25:17 +04:00
|
|
|
nsresult InsertNode(nsIContent& aNode, nsINode& aParent, int32_t aPosition);
|
2014-08-13 15:53:33 +04:00
|
|
|
enum ECloneAttributes { eDontCloneAttributes, eCloneAttributes };
|
|
|
|
already_AddRefed<mozilla::dom::Element> ReplaceContainer(
|
|
|
|
mozilla::dom::Element* aOldContainer,
|
|
|
|
nsIAtom* aNodeType,
|
|
|
|
nsIAtom* aAttribute = nullptr,
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsAString* aValue = nullptr,
|
2014-08-13 15:53:33 +04:00
|
|
|
ECloneAttributes aCloneAttributes = eDontCloneAttributes);
|
2014-08-18 18:44:50 +04:00
|
|
|
void CloneAttributes(mozilla::dom::Element* aDest,
|
|
|
|
mozilla::dom::Element* aSource);
|
2000-06-22 09:39:54 +04:00
|
|
|
|
2014-08-20 16:25:16 +04:00
|
|
|
nsresult RemoveContainer(nsIContent* aNode);
|
2014-08-20 16:25:16 +04:00
|
|
|
already_AddRefed<mozilla::dom::Element> InsertContainerAbove(
|
|
|
|
nsIContent* aNode,
|
|
|
|
nsIAtom* aNodeType,
|
|
|
|
nsIAtom* aAttribute = nullptr,
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsAString* aValue = nullptr);
|
2014-11-02 15:04:13 +03:00
|
|
|
nsIContent* SplitNode(nsIContent& aNode, int32_t aOffset,
|
|
|
|
mozilla::ErrorResult& aResult);
|
2014-11-02 15:04:12 +03:00
|
|
|
nsresult JoinNodes(nsINode& aLeftNode, nsINode& aRightNode);
|
2014-08-20 16:25:16 +04:00
|
|
|
nsresult MoveNode(nsIContent* aNode, nsINode* aParent, int32_t aOffset);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2000-07-14 03:15:41 +04:00
|
|
|
/* Method to replace certain CreateElementNS() calls.
|
|
|
|
Arguments:
|
2014-08-13 15:53:33 +04:00
|
|
|
nsIAtom* aTag - tag you want
|
2000-07-14 03:15:41 +04:00
|
|
|
*/
|
2014-08-13 15:53:33 +04:00
|
|
|
already_AddRefed<mozilla::dom::Element> CreateHTMLContent(nsIAtom* aTag);
|
2000-07-14 03:15:41 +04:00
|
|
|
|
2010-06-30 08:05:12 +04:00
|
|
|
// IME event handlers
|
2014-02-12 17:02:55 +04:00
|
|
|
virtual nsresult BeginIMEComposition(mozilla::WidgetCompositionEvent* aEvent);
|
|
|
|
virtual nsresult UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent) = 0;
|
2012-06-19 17:23:36 +04:00
|
|
|
void EndIMEComposition();
|
2010-06-30 08:05:12 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void SwitchTextDirectionTo(uint32_t aDirection);
|
2011-09-15 18:54:50 +04:00
|
|
|
|
1999-02-12 20:18:58 +03:00
|
|
|
protected:
|
2011-09-15 18:54:50 +04:00
|
|
|
nsresult DetermineCurrentDirection();
|
2014-01-17 19:31:18 +04:00
|
|
|
void FireInputEvent();
|
2011-09-15 18:54:50 +04:00
|
|
|
|
2014-08-29 15:43:23 +04:00
|
|
|
/** Create a transaction for setting aAttribute to aValue on aElement. Never
|
|
|
|
* returns null.
|
1999-03-10 22:48:13 +03:00
|
|
|
*/
|
2014-08-29 15:43:23 +04:00
|
|
|
already_AddRefed<mozilla::dom::ChangeAttributeTxn>
|
|
|
|
CreateTxnForSetAttribute(mozilla::dom::Element& aElement,
|
|
|
|
nsIAtom& aAttribute, const nsAString& aValue);
|
1999-03-02 08:30:53 +03:00
|
|
|
|
2014-08-29 15:43:23 +04:00
|
|
|
/** Create a transaction for removing aAttribute on aElement. Never returns
|
|
|
|
* null.
|
1999-03-10 22:48:13 +03:00
|
|
|
*/
|
2014-08-29 15:43:23 +04:00
|
|
|
already_AddRefed<mozilla::dom::ChangeAttributeTxn>
|
|
|
|
CreateTxnForRemoveAttribute(mozilla::dom::Element& aElement,
|
|
|
|
nsIAtom& aAttribute);
|
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.
|
|
|
|
*/
|
2014-08-20 16:25:16 +04:00
|
|
|
already_AddRefed<mozilla::dom::CreateElementTxn>
|
|
|
|
CreateTxnForCreateElement(nsIAtom& aTag,
|
|
|
|
nsINode& aParent,
|
|
|
|
int32_t aPosition);
|
|
|
|
|
|
|
|
already_AddRefed<mozilla::dom::Element> CreateNode(nsIAtom* aTag,
|
|
|
|
nsINode* aParent,
|
|
|
|
int32_t aPosition);
|
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.
|
|
|
|
*/
|
2014-08-20 16:25:17 +04:00
|
|
|
already_AddRefed<mozilla::dom::InsertNodeTxn>
|
|
|
|
CreateTxnForInsertNode(nsIContent& aNode, nsINode& aParent, int32_t aOffset);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2012-06-19 17:23:36 +04:00
|
|
|
/** create a transaction for removing aNode from its parent.
|
1999-03-10 22:48:13 +03:00
|
|
|
*/
|
2012-06-19 17:23:36 +04:00
|
|
|
nsresult CreateTxnForDeleteNode(nsINode* aNode, DeleteNodeTxn** aTxn);
|
1999-02-24 20:24:37 +03:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2012-06-12 19:44:44 +04:00
|
|
|
nsresult CreateTxnForDeleteSelection(EDirection aAction,
|
|
|
|
EditAggregateTxn** aTxn,
|
|
|
|
nsINode** aNode,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t* aOffset,
|
|
|
|
int32_t* aLength);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2012-06-12 19:44:44 +04:00
|
|
|
nsresult CreateTxnForDeleteInsertionPoint(nsRange* aRange,
|
|
|
|
EDirection aAction,
|
|
|
|
EditAggregateTxn* aTxn,
|
|
|
|
nsINode** aNode,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t* aOffset,
|
|
|
|
int32_t* aLength);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
|
|
|
|
2014-08-29 15:43:23 +04:00
|
|
|
/** Create a transaction for inserting aStringToInsert into aTextNode. Never
|
|
|
|
* returns null.
|
1999-03-10 22:48:13 +03:00
|
|
|
*/
|
2014-08-29 15:43:23 +04:00
|
|
|
already_AddRefed<mozilla::dom::InsertTextTxn>
|
|
|
|
CreateTxnForInsertText(const nsAString& aStringToInsert,
|
|
|
|
mozilla::dom::Text& aTextNode, int32_t aOffset);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2014-08-29 15:43:24 +04:00
|
|
|
// Never returns null.
|
|
|
|
already_AddRefed<mozilla::dom::IMETextTxn>
|
|
|
|
CreateTxnForIMEText(const nsAString & aStringToInsert);
|
1999-06-30 00:31:22 +04:00
|
|
|
|
1999-07-02 07:57:50 +04:00
|
|
|
/** create a transaction for adding a style sheet
|
|
|
|
*/
|
2014-06-20 14:32:49 +04:00
|
|
|
NS_IMETHOD CreateTxnForAddStyleSheet(mozilla::CSSStyleSheet* aSheet,
|
|
|
|
AddStyleSheetTxn* *aTxn);
|
1999-07-02 07:57:50 +04:00
|
|
|
|
|
|
|
/** create a transaction for removing a style sheet
|
|
|
|
*/
|
2014-06-20 14:32:49 +04:00
|
|
|
NS_IMETHOD CreateTxnForRemoveStyleSheet(mozilla::CSSStyleSheet* aSheet,
|
|
|
|
RemoveStyleSheetTxn* *aTxn);
|
1999-07-02 07:57:50 +04:00
|
|
|
|
2014-08-20 16:25:16 +04:00
|
|
|
nsresult DeleteText(nsGenericDOMDataNode& aElement,
|
|
|
|
uint32_t aOffset, uint32_t aLength);
|
2014-05-02 16:15:27 +04:00
|
|
|
|
2001-05-11 16:43:22 +04:00
|
|
|
// NS_IMETHOD DeleteRange(nsIDOMRange *aRange);
|
|
|
|
|
2014-08-20 16:25:16 +04:00
|
|
|
already_AddRefed<mozilla::dom::DeleteTextTxn>
|
|
|
|
CreateTxnForDeleteText(nsGenericDOMDataNode& aElement,
|
|
|
|
uint32_t aOffset, uint32_t aLength);
|
2006-04-04 04:57:55 +04:00
|
|
|
|
2014-08-20 16:25:16 +04:00
|
|
|
already_AddRefed<mozilla::dom::DeleteTextTxn>
|
|
|
|
CreateTxnForDeleteCharacter(nsGenericDOMDataNode& aData, uint32_t aOffset,
|
|
|
|
EDirection aDirection);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2014-11-02 15:04:13 +03:00
|
|
|
already_AddRefed<mozilla::dom::SplitNodeTxn>
|
|
|
|
CreateTxnForSplitNode(nsIContent& aNode, uint32_t aOffset);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2014-11-02 15:04:12 +03:00
|
|
|
already_AddRefed<mozilla::dom::JoinNodeTxn>
|
|
|
|
CreateTxnForJoinNode(nsINode& aLeftNode, nsINode& aRightNode);
|
1999-02-17 22:42:29 +03:00
|
|
|
|
2012-06-21 16:54:26 +04:00
|
|
|
/**
|
|
|
|
* This method first deletes the selection, if it's not collapsed. Then if
|
|
|
|
* the selection lies in a CharacterData node, it splits it. If the
|
|
|
|
* selection is at this point collapsed in a CharacterData node, it's
|
|
|
|
* adjusted to be collapsed right before or after the node instead (which is
|
|
|
|
* always possible, since the node was split).
|
|
|
|
*/
|
|
|
|
nsresult DeleteSelectionAndPrepareToCreateNode();
|
|
|
|
|
1999-04-04 22:01:35 +04:00
|
|
|
|
1999-05-27 08:10:04 +04:00
|
|
|
// called after a transaction is done successfully
|
2012-07-05 11:45:09 +04:00
|
|
|
void DoAfterDoTransaction(nsITransaction *aTxn);
|
1999-05-27 08:10:04 +04:00
|
|
|
// called after a transaction is undone successfully
|
2012-07-05 11:45:09 +04:00
|
|
|
void DoAfterUndoTransaction();
|
1999-07-15 02:29:39 +04:00
|
|
|
// called after a transaction is redone successfully
|
2012-07-05 11:45:09 +04:00
|
|
|
void DoAfterRedoTransaction();
|
2002-01-14 23:25:29 +03:00
|
|
|
|
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 */
|
2014-11-02 15:04:13 +03:00
|
|
|
virtual nsresult SelectEntireDocument(mozilla::dom::Selection* aSelection);
|
2001-01-09 00:01:29 +03:00
|
|
|
|
2002-06-14 00:35:12 +04:00
|
|
|
/** helper method for scrolling the selection into view after
|
2011-10-17 18:59:28 +04:00
|
|
|
* an edit operation. aScrollToAnchor should be true if you
|
2002-06-14 00:35:12 +04:00
|
|
|
* want to scroll to the point where the selection was started.
|
2011-10-17 18:59:28 +04:00
|
|
|
* If false, it attempts to scroll the end of the selection into view.
|
2002-06-14 00:35:12 +04: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-29 10:19:26 +04:00
|
|
|
NS_IMETHOD ScrollSelectionIntoView(bool aScrollToAnchor);
|
1999-03-14 03:31:35 +03:00
|
|
|
|
2012-07-01 23:53:16 +04:00
|
|
|
// Convenience method; forwards to IsBlockNode(nsINode*).
|
|
|
|
bool IsBlockNode(nsIDOMNode* aNode);
|
2001-12-09 12:24:33 +03:00
|
|
|
// stub. see comment in source.
|
2012-07-01 23:53:16 +04:00
|
|
|
virtual bool IsBlockNode(nsINode* aNode);
|
2001-12-09 12:24:33 +03:00
|
|
|
|
2011-11-28 16:54:03 +04:00
|
|
|
// helper for GetPriorNode and GetNextNode
|
|
|
|
nsIContent* FindNextLeafNode(nsINode *aCurrentNode,
|
|
|
|
bool aGoForward,
|
2012-05-06 11:53:11 +04:00
|
|
|
bool bNoBlockCrossing);
|
2001-12-09 12:24:33 +03:00
|
|
|
|
2005-03-24 22:00:01 +03:00
|
|
|
// install the event listeners for the editor
|
2010-04-19 16:20:42 +04:00
|
|
|
virtual nsresult InstallEventListeners();
|
2005-03-24 22:00:01 +03:00
|
|
|
|
2011-07-15 14:18:35 +04:00
|
|
|
virtual void CreateEventListeners();
|
2005-03-24 22:00:01 +03:00
|
|
|
|
|
|
|
// unregister and release our event listeners
|
|
|
|
virtual void RemoveEventListeners();
|
|
|
|
|
2006-07-29 04:04:40 +04:00
|
|
|
/**
|
|
|
|
* Return true if spellchecking should be enabled for this editor.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GetDesiredSpellCheckState();
|
2006-07-29 04:04:40 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool CanEnableSpellCheck()
|
2010-08-19 15:27:04 +04:00
|
|
|
{
|
|
|
|
// Check for password/readonly/disabled, which are not spellchecked
|
2011-10-17 06:06:24 +04:00
|
|
|
// regardless of DOM. Also, check to see if spell check should be skipped or not.
|
|
|
|
return !IsPasswordEditor() && !IsReadonly() && !IsDisabled() && !ShouldSkipSpellCheck();
|
2010-08-19 15:27:04 +04:00
|
|
|
}
|
|
|
|
|
2014-02-12 17:02:55 +04:00
|
|
|
/**
|
2014-10-07 14:01:47 +04:00
|
|
|
* EnsureComposition() should be called by composition event handlers. This
|
|
|
|
* tries to get the composition for the event and set it to mComposition.
|
2014-02-12 17:02:55 +04:00
|
|
|
*/
|
|
|
|
void EnsureComposition(mozilla::WidgetGUIEvent* aEvent);
|
|
|
|
|
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
|
|
|
/** All editor operations which alter the doc should be prefaced
|
|
|
|
* with a call to StartOperation, naming the action and direction */
|
2012-08-12 22:28:26 +04:00
|
|
|
NS_IMETHOD StartOperation(EditAction opID,
|
2012-05-05 22:52:29 +04:00
|
|
|
nsIEditor::EDirection aDirection);
|
1999-12-07 11:30:19 +03:00
|
|
|
|
|
|
|
/** All editor operations which alter the doc should be followed
|
2000-08-14 06:39:37 +04:00
|
|
|
* with a call to EndOperation */
|
|
|
|
NS_IMETHOD EndOperation();
|
1999-12-07 11:30:19 +03:00
|
|
|
|
2000-08-26 08:03:50 +04:00
|
|
|
/** routines for managing the preservation of selection across
|
|
|
|
* various editor actions */
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ArePreservingSelection();
|
2014-04-10 20:09:40 +04:00
|
|
|
void PreserveSelectionAcrossActions(mozilla::dom::Selection* aSel);
|
2014-11-02 15:04:13 +03:00
|
|
|
nsresult RestorePreservedSelection(mozilla::dom::Selection* aSel);
|
2000-08-26 08:03:50 +04:00
|
|
|
void StopPreservingSelection();
|
|
|
|
|
1999-05-05 08:05:19 +04:00
|
|
|
/**
|
2014-11-02 15:04:13 +03: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 The new node resulting from the split, becomes
|
|
|
|
* aExistingRightNode's previous sibling.
|
1999-05-05 08:05:19 +04:00
|
|
|
*/
|
2014-11-02 15:04:13 +03:00
|
|
|
nsresult SplitNodeImpl(nsIContent& aExistingRightNode,
|
|
|
|
int32_t aOffset,
|
|
|
|
nsIContent& aNewLeftNode);
|
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
|
|
|
*/
|
2013-07-24 11:39:08 +04:00
|
|
|
nsresult JoinNodesImpl(nsINode* aNodeToKeep,
|
|
|
|
nsINode* aNodeToJoin,
|
|
|
|
nsINode* aParent);
|
1999-05-05 08:05:19 +04:00
|
|
|
|
|
|
|
/**
|
2012-07-02 15:42:19 +04:00
|
|
|
* Return the offset of aChild in aParent. Asserts fatally if parent or
|
|
|
|
* child is null, or parent is not child's parent.
|
1999-05-05 08:05:19 +04:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t GetChildOffset(nsIDOMNode *aChild,
|
2012-07-02 15:42:19 +04:00
|
|
|
nsIDOMNode *aParent);
|
1999-05-05 08:05:19 +04:00
|
|
|
|
1999-06-16 09:02:43 +04:00
|
|
|
/**
|
2012-07-09 04:45:12 +04:00
|
|
|
* Set outOffset to the offset of aChild in the parent.
|
|
|
|
* Returns the parent of aChild.
|
1999-06-16 09:02:43 +04:00
|
|
|
*/
|
2012-07-09 04:45:12 +04:00
|
|
|
static already_AddRefed<nsIDOMNode> GetNodeLocation(nsIDOMNode* aChild,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t* outOffset);
|
2013-07-10 14:03:38 +04:00
|
|
|
static nsINode* GetNodeLocation(nsINode* aChild, int32_t* aOffset);
|
1999-06-16 09:02:43 +04:00
|
|
|
|
1999-05-05 08:05:19 +04:00
|
|
|
/** 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.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
static nsresult GetLengthOfDOMNode(nsIDOMNode *aNode, uint32_t &aCount);
|
1999-05-05 08:05:19 +04:00
|
|
|
|
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
|
2011-10-17 18:59:28 +04:00
|
|
|
* @param aEditableNode if true, only return an editable node
|
1999-05-05 08:51:54 +04:00
|
|
|
* @param aResultNode [OUT] the node that occurs before aCurrentNode in the tree,
|
2011-10-17 18:59:28 +04:00
|
|
|
* skipping non-editable nodes if aEditableNode is true.
|
2012-07-30 18:20:58 +04:00
|
|
|
* If there is no prior node, aResultNode will be nullptr.
|
2011-11-28 16:54:32 +04:00
|
|
|
* @param bNoBlockCrossing If true, don't move across "block" nodes, whatever that means.
|
1999-05-05 08:51:54 +04:00
|
|
|
*/
|
2012-05-05 13:00:05 +04:00
|
|
|
nsIContent* GetPriorNode(nsINode* aCurrentNode, bool aEditableNode,
|
2012-05-06 11:53:11 +04:00
|
|
|
bool aNoBlockCrossing = false);
|
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
|
2012-05-05 13:00:05 +04:00
|
|
|
nsIContent* GetPriorNode(nsINode* aParentNode,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aOffset,
|
2012-05-05 13:00:05 +04:00
|
|
|
bool aEditableNode,
|
2012-05-06 11:53:11 +04:00
|
|
|
bool aNoBlockCrossing = false);
|
2012-05-05 13:00:05 +04:00
|
|
|
|
|
|
|
|
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
|
2011-10-17 18:59:28 +04:00
|
|
|
* @param aEditableNode if true, only return an editable node
|
1999-05-05 08:51:54 +04:00
|
|
|
* @param aResultNode [OUT] the node that occurs after aCurrentNode in the tree,
|
2011-10-17 18:59:28 +04:00
|
|
|
* skipping non-editable nodes if aEditableNode is true.
|
2012-07-30 18:20:58 +04:00
|
|
|
* If there is no prior node, aResultNode will be nullptr.
|
1999-05-05 08:51:54 +04:00
|
|
|
*/
|
2012-02-01 14:54:22 +04:00
|
|
|
nsIContent* GetNextNode(nsINode* aCurrentNode,
|
|
|
|
bool aEditableNode,
|
2012-05-06 11:53:11 +04:00
|
|
|
bool bNoBlockCrossing = false);
|
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
|
2012-05-05 13:00:05 +04:00
|
|
|
nsIContent* GetNextNode(nsINode* aParentNode,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aOffset,
|
2012-05-05 13:00:05 +04:00
|
|
|
bool aEditableNode,
|
2012-05-06 11:53:11 +04:00
|
|
|
bool aNoBlockCrossing = false);
|
2001-08-22 09:32:44 +04:00
|
|
|
|
2011-11-28 16:54:14 +04:00
|
|
|
// Helper for GetNextNode and GetPriorNode
|
|
|
|
nsIContent* FindNode(nsINode *aCurrentNode,
|
|
|
|
bool aGoForward,
|
|
|
|
bool aEditableNode,
|
2012-05-06 11:53:11 +04:00
|
|
|
bool bNoBlockCrossing);
|
2011-08-11 17:29:59 +04:00
|
|
|
/**
|
|
|
|
* Get the rightmost child of aCurrentNode;
|
2012-07-30 18:20:58 +04:00
|
|
|
* return nullptr if aCurrentNode has no children.
|
2011-08-11 17:29:59 +04:00
|
|
|
*/
|
2011-11-28 16:53:29 +04:00
|
|
|
nsIContent* GetRightmostChild(nsINode *aCurrentNode,
|
|
|
|
bool bNoBlockCrossing = false);
|
1999-05-05 08:05:19 +04:00
|
|
|
|
2011-08-11 17:29:59 +04:00
|
|
|
/**
|
|
|
|
* Get the leftmost child of aCurrentNode;
|
2012-07-30 18:20:58 +04:00
|
|
|
* return nullptr if aCurrentNode has no children.
|
2011-08-11 17:29:59 +04:00
|
|
|
*/
|
2011-11-28 16:53:29 +04:00
|
|
|
nsIContent* GetLeftmostChild(nsINode *aCurrentNode,
|
|
|
|
bool bNoBlockCrossing = false);
|
1999-05-05 08:05:19 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
/** returns true if aNode is of the type implied by aTag */
|
2011-09-29 10:19:26 +04:00
|
|
|
static inline bool NodeIsType(nsIDOMNode *aNode, nsIAtom *aTag)
|
2003-07-15 17:47:15 +04:00
|
|
|
{
|
2003-11-19 04:20:56 +03:00
|
|
|
return GetTag(aNode) == aTag;
|
2003-07-15 17:47:15 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
/** returns true if aParent can contain a child of type aTag */
|
2014-11-02 15:04:13 +03:00
|
|
|
bool CanContain(nsINode& aParent, nsIContent& aChild);
|
|
|
|
bool CanContainTag(nsINode& aParent, nsIAtom& aTag);
|
|
|
|
bool TagCanContain(nsIAtom& aParentTag, nsIContent& aChild);
|
|
|
|
virtual bool TagCanContainTag(nsIAtom& aParentTag, nsIAtom& aChildTag);
|
2000-02-08 15:53:34 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
/** returns true if aNode is our root node */
|
2012-05-01 14:01:28 +04:00
|
|
|
bool IsRoot(nsIDOMNode* inNode);
|
|
|
|
bool IsRoot(nsINode* inNode);
|
2012-05-06 11:53:11 +04:00
|
|
|
bool IsEditorRoot(nsINode* aNode);
|
2001-08-28 22:21:12 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
/** returns true if aNode is a descendant of our root node */
|
2012-05-01 14:01:28 +04:00
|
|
|
bool IsDescendantOfRoot(nsIDOMNode* inNode);
|
|
|
|
bool IsDescendantOfRoot(nsINode* inNode);
|
2012-05-06 11:53:11 +04:00
|
|
|
bool IsDescendantOfEditorRoot(nsIDOMNode* aNode);
|
2012-05-06 11:53:11 +04:00
|
|
|
bool IsDescendantOfEditorRoot(nsINode* aNode);
|
2000-05-10 01:06:49 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
/** returns true if aNode is a container */
|
2014-04-28 15:54:46 +04:00
|
|
|
virtual bool IsContainer(nsINode* aNode);
|
|
|
|
virtual bool IsContainer(nsIDOMNode* aNode);
|
1999-09-30 00:08:15 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
/** returns true if aNode is an editable node */
|
2011-10-26 06:32:55 +04:00
|
|
|
bool IsEditable(nsIDOMNode *aNode);
|
2014-04-28 20:03:12 +04:00
|
|
|
virtual bool IsEditable(nsINode* aNode);
|
1999-05-05 08:05:19 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
/** returns true if aNode is a MozEditorBogus node */
|
2014-04-28 20:03:12 +04:00
|
|
|
bool IsMozEditorBogusNode(nsINode* aNode);
|
2000-01-19 02:45:35 +03:00
|
|
|
|
1999-06-25 13:33:02 +04:00
|
|
|
/** counts number of editable child nodes */
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t CountEditableChildren(nsINode* aNode);
|
1999-06-25 13:33:02 +04:00
|
|
|
|
2012-02-01 14:54:22 +04:00
|
|
|
/** Find the deep first and last children. */
|
|
|
|
nsINode* GetFirstEditableNode(nsINode* aRoot);
|
1999-06-23 01:42:44 +04:00
|
|
|
|
2014-02-12 17:02:56 +04:00
|
|
|
/**
|
|
|
|
* Returns current composition.
|
|
|
|
*/
|
|
|
|
mozilla::TextComposition* GetComposition() const;
|
2014-02-12 17:02:56 +04:00
|
|
|
/**
|
|
|
|
* Returns true if there is composition string and not fixed.
|
|
|
|
*/
|
|
|
|
bool IsIMEComposing() const;
|
1999-06-23 01:42:44 +04:00
|
|
|
|
1999-05-17 16:22:31 +04:00
|
|
|
/** from html rules code - migration in progress */
|
2002-03-24 01:16:54 +03:00
|
|
|
static nsresult GetTagString(nsIDOMNode *aNode, nsAString& outString);
|
2003-11-19 04:20:56 +03:00
|
|
|
static nsIAtom *GetTag(nsIDOMNode *aNode);
|
2012-05-18 12:29:38 +04:00
|
|
|
|
|
|
|
bool NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2);
|
|
|
|
virtual bool AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2);
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool IsTextNode(nsIDOMNode *aNode);
|
2011-11-28 16:53:29 +04:00
|
|
|
static bool IsTextNode(nsINode *aNode);
|
1999-05-17 16:22:31 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static nsCOMPtr<nsIDOMNode> GetChildAt(nsIDOMNode *aParent, int32_t aOffset);
|
|
|
|
static nsCOMPtr<nsIDOMNode> GetNodeAtRangeOffsetPoint(nsIDOMNode* aParentOrNode, int32_t aOffset);
|
2011-07-14 19:25:07 +04:00
|
|
|
|
2014-11-02 15:04:13 +03:00
|
|
|
static nsresult GetStartNodeAndOffset(mozilla::dom::Selection* aSelection,
|
|
|
|
nsIDOMNode** outStartNode,
|
|
|
|
int32_t* outStartOffset);
|
2014-04-10 20:09:40 +04:00
|
|
|
static nsresult GetStartNodeAndOffset(mozilla::dom::Selection* aSelection,
|
2013-07-24 11:39:08 +04:00
|
|
|
nsINode** aStartNode,
|
|
|
|
int32_t* aStartOffset);
|
2014-11-02 15:04:13 +03:00
|
|
|
static nsresult GetEndNodeAndOffset(mozilla::dom::Selection* aSelection,
|
|
|
|
nsIDOMNode** outEndNode,
|
|
|
|
int32_t* outEndOffset);
|
2014-04-10 20:09:40 +04:00
|
|
|
static nsresult GetEndNodeAndOffset(mozilla::dom::Selection* aSelection,
|
2013-07-24 11:39:08 +04:00
|
|
|
nsINode** aEndNode,
|
|
|
|
int32_t* aEndOffset);
|
2002-11-22 06:30:59 +03:00
|
|
|
#if DEBUG_JOE
|
2012-08-22 19:56:38 +04:00
|
|
|
static void DumpNode(nsIDOMNode *aNode, int32_t indent=0);
|
2002-11-22 06:30:59 +03:00
|
|
|
#endif
|
2014-04-10 20:09:40 +04:00
|
|
|
mozilla::dom::Selection* GetSelection();
|
1999-06-09 05:27:08 +04:00
|
|
|
|
2000-02-10 08:14:52 +03:00
|
|
|
// Helpers to add a node to the selection.
|
|
|
|
// Used by table cell selection methods
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult CreateRange(nsIDOMNode *aStartParent, int32_t aStartOffset,
|
|
|
|
nsIDOMNode *aEndParent, int32_t aEndOffset,
|
2014-11-02 15:04:13 +03:00
|
|
|
nsRange** aRange);
|
2002-01-14 23:25:29 +03:00
|
|
|
|
2000-02-10 08:14:52 +03:00
|
|
|
// 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-29 10:19:26 +04:00
|
|
|
nsresult IsPreformatted(nsIDOMNode *aNode, bool *aResult);
|
1999-05-17 16:22:31 +04:00
|
|
|
|
2000-04-24 15:51:12 +04:00
|
|
|
nsresult SplitNodeDeep(nsIDOMNode *aNode,
|
|
|
|
nsIDOMNode *aSplitPointParent,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aSplitPointOffset,
|
|
|
|
int32_t *outOffset,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aNoEmptyContainers = false,
|
2000-04-24 15:51:12 +04:00
|
|
|
nsCOMPtr<nsIDOMNode> *outLeftNode = 0,
|
|
|
|
nsCOMPtr<nsIDOMNode> *outRightNode = 0);
|
2014-11-02 15:04:13 +03:00
|
|
|
::DOMPoint JoinNodeDeep(nsIContent& aLeftNode, nsIContent& aRightNode);
|
1999-08-31 17:55:18 +04:00
|
|
|
|
2002-03-24 01:16:54 +03:00
|
|
|
nsresult GetString(const nsAString& name, nsAString& value);
|
1999-05-04 02:57:48 +04:00
|
|
|
|
2012-06-01 15:03:17 +04:00
|
|
|
void BeginUpdateViewBatch(void);
|
2003-03-25 18:24:08 +03:00
|
|
|
virtual nsresult EndUpdateViewBatch(void);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GetShouldTxnSetSelection();
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2010-06-10 05:16:58 +04:00
|
|
|
virtual nsresult HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent);
|
|
|
|
|
2012-08-12 22:28:26 +04:00
|
|
|
nsresult HandleInlineSpellCheck(EditAction action,
|
2014-11-02 15:04:13 +03:00
|
|
|
mozilla::dom::Selection* aSelection,
|
2005-02-02 00:12:53 +03:00
|
|
|
nsIDOMNode *previousSelectedNode,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t previousSelectedOffset,
|
2005-02-02 00:12:53 +03:00
|
|
|
nsIDOMNode *aStartNode,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aStartOffset,
|
2005-02-02 00:12:53 +03:00
|
|
|
nsIDOMNode *aEndNode,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aEndOffset);
|
2005-02-02 00:12:53 +03:00
|
|
|
|
2013-10-23 03:32:04 +04:00
|
|
|
virtual already_AddRefed<mozilla::dom::EventTarget> GetDOMEventTarget() = 0;
|
2005-03-24 22:00:01 +03:00
|
|
|
|
|
|
|
// Fast non-refcounting editor root element accessor
|
2011-12-04 01:50:15 +04:00
|
|
|
mozilla::dom::Element *GetRoot();
|
2005-03-24 22:00:01 +03:00
|
|
|
|
2012-05-06 11:53:11 +04:00
|
|
|
// Likewise, but gets the editor's root instead, which is different for HTML
|
|
|
|
// editors
|
|
|
|
virtual mozilla::dom::Element* GetEditorRoot();
|
|
|
|
|
2014-01-17 19:31:03 +04:00
|
|
|
// Likewise, but gets the text control element instead of the root for
|
|
|
|
// plaintext editors
|
|
|
|
mozilla::dom::Element* GetExposedRoot();
|
|
|
|
|
2010-04-12 06:35:18 +04:00
|
|
|
// Accessor methods to flags
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsPlaintextEditor() const
|
2010-04-12 06:35:18 +04:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorPlaintextMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsSingleLineEditor() const
|
2010-04-12 06:35:18 +04:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorSingleLineMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsPasswordEditor() const
|
2010-04-12 06:35:18 +04:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorPasswordMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsReadonly() const
|
2010-04-12 06:35:18 +04:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorReadonlyMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsDisabled() const
|
2010-04-12 06:35:18 +04:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorDisabledMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsInputFiltered() const
|
2010-04-12 06:35:18 +04:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorFilterInputMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsMailEditor() const
|
2010-04-12 06:35:18 +04:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorMailMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsWrapHackEnabled() const
|
2010-04-12 06:35:18 +04:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorEnableWrapHackMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsFormWidget() const
|
2010-04-12 06:35:18 +04:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorWidgetMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool NoCSS() const
|
2010-04-12 06:35:18 +04:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorNoCSSMask) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsInteractionAllowed() const
|
2010-04-12 06:35:18 +04:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorAllowInteraction) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool DontEchoPassword() const
|
2010-04-12 06:35:18 +04:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorDontEchoPassword) != 0;
|
|
|
|
}
|
2011-10-17 06:06:24 +04:00
|
|
|
|
2012-04-04 13:15:10 +04:00
|
|
|
bool ShouldSkipSpellCheck() const
|
2011-10-17 06:06:24 +04:00
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorSkipSpellCheck) != 0;
|
|
|
|
}
|
2010-04-12 06:35:18 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsTabbable() const
|
2010-06-10 05:16:58 +04:00
|
|
|
{
|
|
|
|
return IsSingleLineEditor() || IsPasswordEditor() || IsFormWidget() ||
|
|
|
|
IsInteractionAllowed();
|
|
|
|
}
|
|
|
|
|
2013-05-18 04:07:46 +04:00
|
|
|
bool HasIndependentSelection() const
|
|
|
|
{
|
|
|
|
return !!mSelConWeak;
|
|
|
|
}
|
|
|
|
|
2012-03-27 05:36:44 +04:00
|
|
|
// Get the input event target. This might return null.
|
|
|
|
virtual already_AddRefed<nsIContent> GetInputEventTargetContent() = 0;
|
|
|
|
|
2010-10-29 20:30:52 +04:00
|
|
|
// Get the focused content, if we're focused. Returns null otherwise.
|
|
|
|
virtual already_AddRefed<nsIContent> GetFocusedContent();
|
2010-05-04 21:40:39 +04:00
|
|
|
|
2014-03-08 05:20:07 +04:00
|
|
|
// Get the focused content for the argument of some IMEStateManager's
|
2012-11-09 12:40:39 +04:00
|
|
|
// methods.
|
|
|
|
virtual already_AddRefed<nsIContent> GetFocusedContentForIME();
|
|
|
|
|
2010-07-22 20:22:44 +04:00
|
|
|
// Whether the editor is active on the DOM window. Note that when this
|
2010-10-29 20:30:52 +04:00
|
|
|
// returns true but GetFocusedContent() returns null, it means that this editor was
|
2010-07-22 20:22:44 +04:00
|
|
|
// focused when the DOM window was active.
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool IsActiveInDOMWindow();
|
2010-07-22 20:22:44 +04: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-29 10:19:26 +04:00
|
|
|
virtual bool IsAcceptableInputEvent(nsIDOMEvent* aEvent);
|
2010-07-22 20:22:44 +04:00
|
|
|
|
2010-06-17 09:30:42 +04: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
|
2013-04-03 04:13:10 +04:00
|
|
|
// target isn't a part of this editor, returns nullptr. If this is for
|
2010-06-17 09:30:42 +04:00
|
|
|
// 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 23:12:45 +04: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);
|
|
|
|
|
2012-02-17 18:16:59 +04:00
|
|
|
// Used to insert content from a data transfer into the editable area.
|
|
|
|
// This is called for each item in the data transfer, with the index of
|
|
|
|
// each item passed as aIndex.
|
2013-07-09 21:54:21 +04:00
|
|
|
virtual nsresult InsertFromDataTransfer(mozilla::dom::DataTransfer *aDataTransfer,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aIndex,
|
2012-02-17 18:16:59 +04:00
|
|
|
nsIDOMDocument *aSourceDoc,
|
|
|
|
nsIDOMNode *aDestinationNode,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aDestOffset,
|
2012-02-17 18:16:59 +04:00
|
|
|
bool aDoDeleteSelection) = 0;
|
|
|
|
|
|
|
|
virtual nsresult InsertFromDrop(nsIDOMEvent* aDropEvent) = 0;
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
virtual already_AddRefed<nsIDOMNode> FindUserSelectAllNode(nsIDOMNode* aNode) { return nullptr; }
|
2012-02-17 18:16:59 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
protected:
|
2006-07-29 04:04:40 +04:00
|
|
|
enum Tristate {
|
|
|
|
eTriUnset,
|
|
|
|
eTriFalse,
|
|
|
|
eTriTrue
|
2012-04-24 08:54:11 +04:00
|
|
|
};
|
|
|
|
// Spellchecking
|
|
|
|
nsCString mContentMIMEType; // MIME type of the doc we are editing.
|
|
|
|
|
2006-07-29 04:04:40 +04:00
|
|
|
nsCOMPtr<nsIInlineSpellChecker> mInlineSpellChecker;
|
|
|
|
|
2012-06-19 17:23:36 +04:00
|
|
|
nsRefPtr<nsTransactionManager> mTxnMgr;
|
2012-04-24 08:54:11 +04:00
|
|
|
nsCOMPtr<mozilla::dom::Element> mRootElement; // cached root node
|
2014-08-29 15:43:24 +04:00
|
|
|
nsRefPtr<mozilla::dom::Text> mIMETextNode; // current IME text node
|
2013-10-23 03:32:04 +04:00
|
|
|
nsCOMPtr<mozilla::dom::EventTarget> mEventTarget; // The form field as an event receiver
|
2012-04-24 08:54:11 +04:00
|
|
|
nsCOMPtr<nsIDOMEventListener> mEventListener;
|
|
|
|
nsWeakPtr mSelConWeak; // weak reference to the nsISelectionController
|
|
|
|
nsWeakPtr mPlaceHolderTxn; // weak reference to placeholder for begin/end batch purposes
|
|
|
|
nsWeakPtr mDocWeak; // weak reference to the nsIDOMDocument
|
|
|
|
nsIAtom *mPlaceHolderName; // name of placeholder transaction
|
|
|
|
nsSelectionState *mSelState; // saved selection state for placeholder txn batching
|
|
|
|
nsString *mPhonetic;
|
2014-02-12 17:02:55 +04:00
|
|
|
// IME composition this is not null between compositionstart and
|
|
|
|
// compositionend.
|
|
|
|
nsRefPtr<mozilla::TextComposition> mComposition;
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2012-04-24 08:54:11 +04:00
|
|
|
// various listeners
|
2006-10-09 19:41:26 +04:00
|
|
|
nsCOMArray<nsIEditActionListener> mActionListeners; // listens to all low level actions on the doc
|
2012-11-14 23:23:35 +04:00
|
|
|
nsCOMArray<nsIEditorObserver> mEditorObservers; // just notify once per high level change
|
2006-10-09 19:41:26 +04:00
|
|
|
nsCOMArray<nsIDocumentStateListener> mDocStateListeners;// listen to overall doc state (dirty or not, just created, etc)
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2012-04-24 08:54:11 +04:00
|
|
|
nsSelectionState mSavedSel; // cached selection for nsAutoSelectionReset
|
|
|
|
nsRangeUpdater mRangeUpdater; // utility class object for maintaining preserved ranges
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mModCount; // number of modifications (for undo/redo stack)
|
|
|
|
uint32_t mFlags; // behavior flags. See nsIPlaintextEditor.idl for the flags we use.
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mUpdateCount;
|
2002-12-18 02:38:04 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mPlaceHolderBatch; // nesting count for batching
|
2012-08-12 22:28:26 +04:00
|
|
|
EditAction mAction; // the current editor action
|
2012-04-24 08:54:11 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mIMETextOffset; // offset in text node where IME comp string begins
|
2012-04-24 08:54:11 +04:00
|
|
|
|
|
|
|
EDirection mDirection; // the current direction of editor action
|
2012-08-22 19:56:38 +04:00
|
|
|
int8_t mDocDirtyState; // -1 = not initialized
|
|
|
|
uint8_t mSpellcheckCheckboxState; // a Tristate value
|
2012-04-24 08:54:11 +04: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
|
2012-03-27 05:36:44 +04:00
|
|
|
bool mDispatchInputEvent;
|
2014-08-19 15:54:08 +04:00
|
|
|
bool mIsInEditAction; // true while the instance is handling an edit action
|
2010-12-07 09:30:05 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
friend bool NSCanUnload(nsISupports* serviceMgr);
|
2000-01-04 06:09:41 +03:00
|
|
|
friend class nsAutoTxnsConserveSelection;
|
2000-03-24 03:26:47 +03:00
|
|
|
friend class nsAutoSelectionReset;
|
2000-08-14 06:39:37 +04:00
|
|
|
friend class nsAutoRules;
|
2002-11-10 18:11:08 +03:00
|
|
|
friend class nsRangeUpdater;
|
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
|