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
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
#ifndef mozilla_EditorBase_h
|
|
|
|
#define mozilla_EditorBase_h
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2013-01-29 04:33:17 +04:00
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc.
|
2017-11-01 08:41:03 +03:00
|
|
|
#include "mozilla/EditorDOMPoint.h" // for EditorDOMPoint
|
2017-07-29 09:43:39 +03:00
|
|
|
#include "mozilla/Maybe.h" // for Maybe
|
2015-08-05 15:28:27 +03:00
|
|
|
#include "mozilla/OwningNonNull.h" // for OwningNonNull
|
2017-08-02 01:56:02 +03:00
|
|
|
#include "mozilla/PresShell.h" // for PresShell
|
2017-11-01 08:41:03 +03:00
|
|
|
#include "mozilla/RangeBoundary.h" // for RawRangeBoundary, RangeBoundary
|
2016-07-08 08:15:21 +03:00
|
|
|
#include "mozilla/SelectionState.h" // for RangeUpdater, etc.
|
2017-06-14 13:05:48 +03:00
|
|
|
#include "mozilla/StyleSheet.h" // for StyleSheet
|
|
|
|
#include "mozilla/WeakPtr.h" // for WeakPtr
|
2017-08-02 02:51:25 +03:00
|
|
|
#include "mozilla/dom/Selection.h"
|
2014-05-02 16:15:27 +04:00
|
|
|
#include "mozilla/dom/Text.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#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"
|
2017-06-19 18:55:00 +03:00
|
|
|
#include "nsIDocument.h" // for nsIDocument
|
2017-05-09 09:21:22 +03:00
|
|
|
#include "nsIEditor.h" // for nsIEditor, etc.
|
2016-07-08 08:15:21 +03:00
|
|
|
#include "nsIObserver.h" // for NS_DECL_NSIOBSERVER, etc.
|
|
|
|
#include "nsIPlaintextEditor.h" // for nsIPlaintextEditor, etc.
|
2015-03-08 01:14:07 +03:00
|
|
|
#include "nsISelectionController.h" // for nsISelectionController constants
|
2016-07-08 08:15:21 +03:00
|
|
|
#include "nsISupportsImpl.h" // for EditorBase::Release, etc.
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsIWeakReferenceUtils.h" // for nsWeakPtr
|
|
|
|
#include "nsLiteralString.h" // for NS_LITERAL_STRING
|
|
|
|
#include "nsString.h" // for nsCString
|
2017-02-07 16:26:56 +03:00
|
|
|
#include "nsTArray.h" // for nsTArray and nsAutoTArray
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsWeakReference.h" // for nsSupportsWeakReference
|
2016-07-08 08:15:21 +03:00
|
|
|
#include "nscore.h" // for nsresult, nsAString, etc.
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
class nsAtom;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsIContent;
|
|
|
|
class nsIDOMDocument;
|
|
|
|
class nsIDOMEvent;
|
|
|
|
class nsIDOMEventListener;
|
|
|
|
class nsIDOMEventTarget;
|
|
|
|
class nsIDOMNode;
|
|
|
|
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 nsTransactionManager;
|
|
|
|
|
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.
|
2016-07-08 07:10:13 +03:00
|
|
|
// XXX EditAction causes unnecessary include of EditorBase from some places.
|
|
|
|
// Why don't you move this to nsIEditor.idl?
|
|
|
|
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,
|
2017-05-25 08:30:50 +03:00
|
|
|
setText = 2006,
|
2012-08-01 16:22:07 +04:00
|
|
|
|
|
|
|
// 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
|
2015-01-26 01:22:07 +03:00
|
|
|
};
|
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
|
|
|
}
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class AddStyleSheetTransaction;
|
|
|
|
class AutoRules;
|
|
|
|
class AutoSelectionRestorer;
|
|
|
|
class AutoTransactionsConserveSelection;
|
|
|
|
class ChangeAttributeTransaction;
|
|
|
|
class CompositionTransaction;
|
|
|
|
class CreateElementTransaction;
|
|
|
|
class DeleteNodeTransaction;
|
|
|
|
class DeleteTextTransaction;
|
|
|
|
class EditAggregateTransaction;
|
2017-03-14 16:01:36 +03:00
|
|
|
class EditTransactionBase;
|
2016-07-08 07:10:13 +03:00
|
|
|
class ErrorResult;
|
2017-03-09 12:38:41 +03:00
|
|
|
class HTMLEditor;
|
2016-07-08 07:10:13 +03:00
|
|
|
class InsertNodeTransaction;
|
|
|
|
class InsertTextTransaction;
|
|
|
|
class JoinNodeTransaction;
|
2017-06-14 13:05:48 +03:00
|
|
|
class PlaceholderTransaction;
|
2016-07-08 07:10:13 +03:00
|
|
|
class RemoveStyleSheetTransaction;
|
|
|
|
class SplitNodeTransaction;
|
|
|
|
class TextComposition;
|
2017-03-10 08:05:37 +03:00
|
|
|
class TextEditor;
|
2016-07-08 07:10:13 +03:00
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class DataTransfer;
|
|
|
|
class Element;
|
|
|
|
class EventTarget;
|
|
|
|
class Text;
|
|
|
|
} // namespace dom
|
|
|
|
|
|
|
|
namespace widget {
|
|
|
|
struct IMEState;
|
|
|
|
} // namespace widget
|
|
|
|
|
2017-06-19 18:55:00 +03:00
|
|
|
/**
|
|
|
|
* CachedWeakPtr stores a pointer to a class which inherits nsIWeakReference.
|
|
|
|
* If the instance of the class has already been destroyed, this returns
|
|
|
|
* nullptr. Otherwise, returns cached pointer.
|
2017-06-22 09:02:59 +03:00
|
|
|
* If class T inherits nsISupports a lot, specify Base explicitly for avoiding
|
|
|
|
* ambiguous conversion to nsISupports.
|
2017-06-19 18:55:00 +03:00
|
|
|
*/
|
2017-06-22 09:02:59 +03:00
|
|
|
template<class T, class Base = nsISupports>
|
2017-06-19 18:55:00 +03:00
|
|
|
class CachedWeakPtr final
|
|
|
|
{
|
|
|
|
public:
|
2017-06-22 09:02:59 +03:00
|
|
|
CachedWeakPtr<T, Base>()
|
2017-06-19 18:55:00 +03:00
|
|
|
: mCache(nullptr)
|
|
|
|
{
|
|
|
|
}
|
2017-06-22 09:02:59 +03:00
|
|
|
explicit CachedWeakPtr<T, Base>(T* aObject)
|
|
|
|
{
|
|
|
|
mWeakPtr = do_GetWeakReference(static_cast<Base*>(aObject));
|
|
|
|
mCache = aObject;
|
|
|
|
}
|
|
|
|
explicit CachedWeakPtr<T, Base>(const nsCOMPtr<T>& aOther)
|
|
|
|
{
|
|
|
|
mWeakPtr = do_GetWeakReference(static_cast<Base*>(aOther.get()));
|
|
|
|
mCache = aOther;
|
|
|
|
}
|
|
|
|
explicit CachedWeakPtr<T, Base>(already_AddRefed<T>& aOther)
|
|
|
|
{
|
|
|
|
RefPtr<T> other = aOther;
|
|
|
|
mWeakPtr = do_GetWeakReference(static_cast<Base*>(other.get()));
|
|
|
|
mCache = other;
|
|
|
|
}
|
2017-06-19 18:55:00 +03:00
|
|
|
|
2017-06-22 09:02:59 +03:00
|
|
|
CachedWeakPtr<T, Base>& operator=(T* aObject)
|
2017-06-19 18:55:00 +03:00
|
|
|
{
|
2017-06-22 09:02:59 +03:00
|
|
|
mWeakPtr = do_GetWeakReference(static_cast<Base*>(aObject));
|
2017-06-19 18:55:00 +03:00
|
|
|
mCache = aObject;
|
|
|
|
return *this;
|
|
|
|
}
|
2017-06-22 09:02:59 +03:00
|
|
|
CachedWeakPtr<T, Base>& operator=(const nsCOMPtr<T>& aOther)
|
2017-06-19 18:55:00 +03:00
|
|
|
{
|
2017-06-22 09:02:59 +03:00
|
|
|
mWeakPtr = do_GetWeakReference(static_cast<Base*>(aOther.get()));
|
2017-06-19 18:55:00 +03:00
|
|
|
mCache = aOther;
|
|
|
|
return *this;
|
|
|
|
}
|
2017-06-22 09:02:59 +03:00
|
|
|
CachedWeakPtr<T, Base>& operator=(already_AddRefed<T>& aOther)
|
2017-06-19 18:55:00 +03:00
|
|
|
{
|
2017-06-22 09:02:59 +03:00
|
|
|
RefPtr<T> other = aOther;
|
|
|
|
mWeakPtr = do_GetWeakReference(static_cast<Base*>(other.get()));
|
2017-06-19 18:55:00 +03:00
|
|
|
mCache = other;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsAlive() const { return mWeakPtr && mWeakPtr->IsAlive(); }
|
|
|
|
|
|
|
|
explicit operator bool() const { return mWeakPtr; }
|
|
|
|
operator T*() const { return get(); }
|
|
|
|
T* get() const
|
|
|
|
{
|
|
|
|
if (mCache && !mWeakPtr->IsAlive()) {
|
2017-06-22 09:02:59 +03:00
|
|
|
const_cast<CachedWeakPtr<T, Base>*>(this)->mCache = nullptr;
|
2017-06-19 18:55:00 +03:00
|
|
|
}
|
|
|
|
return mCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsWeakPtr mWeakPtr;
|
|
|
|
T* MOZ_NON_OWNING_REF mCache;
|
|
|
|
};
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
#define kMOZEditorBogusNodeAttrAtom nsGkAtoms::mozeditorbogusnode
|
|
|
|
#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.
|
1999-02-12 20:18:58 +03:00
|
|
|
*/
|
2017-05-09 09:21:22 +03:00
|
|
|
class EditorBase : public nsIEditor
|
2016-07-08 07:10:13 +03:00
|
|
|
, public nsSupportsWeakReference
|
1999-02-12 20:18:58 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-07-08 07:10:13 +03:00
|
|
|
typedef dom::Element Element;
|
|
|
|
typedef dom::Selection Selection;
|
|
|
|
typedef dom::Text Text;
|
1999-05-05 08:05:19 +04:00
|
|
|
|
1999-05-17 16:22:31 +04:00
|
|
|
enum IterDirection
|
|
|
|
{
|
|
|
|
kIterForward,
|
|
|
|
kIterBackward
|
|
|
|
};
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* The default constructor. This should suffice. the setting of the
|
|
|
|
* interfaces is done after the construction of the editor class.
|
1999-02-12 20:18:58 +03:00
|
|
|
*/
|
2016-07-08 07:10:13 +03:00
|
|
|
EditorBase();
|
2014-06-24 02:40:02 +04:00
|
|
|
|
|
|
|
protected:
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* The default destructor. This should suffice. Should this be pure virtual
|
|
|
|
* for someone to derive from the EditorBase later? I don't believe so.
|
1999-02-12 20:18:58 +03:00
|
|
|
*/
|
2016-07-08 07:10:13 +03:00
|
|
|
virtual ~EditorBase();
|
2005-06-16 17:10:58 +04:00
|
|
|
|
2014-06-24 02:40:02 +04:00
|
|
|
public:
|
2009-05-09 08:59:25 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2016-07-08 07:10:13 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(EditorBase, nsIEditor)
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2017-08-02 01:30:49 +03:00
|
|
|
bool IsInitialized() const { return !!mDocument; }
|
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();
|
2017-08-08 05:25:36 +03:00
|
|
|
nsPresContext* GetPresContext()
|
|
|
|
{
|
|
|
|
RefPtr<nsIPresShell> presShell = GetPresShell();
|
|
|
|
return presShell ? presShell->GetPresContext() : nullptr;
|
|
|
|
}
|
2014-04-10 11:11:37 +04:00
|
|
|
already_AddRefed<nsIWidget> GetWidget();
|
2017-08-04 14:41:20 +03:00
|
|
|
nsISelectionController* GetSelectionController() const
|
|
|
|
{
|
|
|
|
if (mSelectionController) {
|
|
|
|
return mSelectionController;
|
|
|
|
}
|
|
|
|
if (!mDocument) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
nsIPresShell* presShell = mDocument->GetShell();
|
|
|
|
if (!presShell) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
nsISelectionController* sc = static_cast<PresShell*>(presShell);
|
|
|
|
return sc;
|
|
|
|
}
|
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
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
// nsIEditor methods
|
2001-04-07 04:45:26 +04:00
|
|
|
NS_DECL_NSIEDITOR
|
2013-01-10 03:05:08 +04:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
public:
|
2016-07-08 07:10:13 +03:00
|
|
|
virtual bool IsModifiableNode(nsINode* aNode);
|
2013-01-10 03:05:08 +04:00
|
|
|
|
2017-11-08 19:00:36 +03:00
|
|
|
/**
|
|
|
|
* InsertTextImpl() inserts aStringToInsert to aPointToInsert or better
|
|
|
|
* insertion point around it. If aPointToInsert isn't in a text node,
|
|
|
|
* this method looks for the nearest point in a text node with
|
|
|
|
* FindBetterInsertionPoint(). If there is no text node, this creates
|
|
|
|
* new text node and put aStringToInsert to it.
|
|
|
|
*
|
|
|
|
* @param aDocument The document of this editor.
|
|
|
|
* @param aStringToInsert The string to insert.
|
|
|
|
* @param aPointToInser The point to insert aStringToInsert.
|
|
|
|
* Must be valid DOM point.
|
|
|
|
* @param aPointAfterInsertedString
|
|
|
|
* The point after inserted aStringToInsert.
|
|
|
|
* So, when this method actually inserts string,
|
|
|
|
* this is set to a point in the text node.
|
|
|
|
* Otherwise, this may be set to aPointToInsert.
|
|
|
|
* @return When this succeeds to insert the string or
|
|
|
|
* does nothing during composition, returns NS_OK.
|
|
|
|
* Otherwise, an error code.
|
|
|
|
*/
|
|
|
|
virtual nsresult
|
|
|
|
InsertTextImpl(nsIDocument& aDocument,
|
|
|
|
const nsAString& aStringToInsert,
|
|
|
|
const EditorRawDOMPoint& aPointToInsert,
|
|
|
|
EditorRawDOMPoint* aPointAfterInsertedString = nullptr);
|
|
|
|
|
2014-05-02 15:11:26 +04:00
|
|
|
nsresult InsertTextIntoTextNodeImpl(const nsAString& aStringToInsert,
|
2016-05-01 16:15:14 +03:00
|
|
|
Text& aTextNode, int32_t aOffset,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aSuppressIME = false);
|
2017-05-25 08:30:50 +03:00
|
|
|
|
2017-07-28 21:49:58 +03:00
|
|
|
nsresult SetTextImpl(Selection& aSelection,
|
|
|
|
const nsAString& aString,
|
2017-05-25 08:30:50 +03:00
|
|
|
Text& aTextNode);
|
|
|
|
|
2012-05-10 18:54:33 +04:00
|
|
|
NS_IMETHOD DeleteSelectionImpl(EDirection aAction,
|
|
|
|
EStripWrappers aStripWrappers);
|
2014-11-02 15:04:13 +03:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
already_AddRefed<Element> DeleteSelectionAndCreateElement(nsAtom& aTag);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2016-07-08 07:10:13 +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 };
|
2016-05-01 16:15:14 +03:00
|
|
|
already_AddRefed<Element> ReplaceContainer(Element* aOldContainer,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aNodeType,
|
|
|
|
nsAtom* aAttribute = nullptr,
|
2016-05-01 16:15:14 +03:00
|
|
|
const nsAString* aValue = nullptr,
|
|
|
|
ECloneAttributes aCloneAttributes
|
|
|
|
= eDontCloneAttributes);
|
|
|
|
void CloneAttributes(Element* aDest, Element* aSource);
|
2000-06-22 09:39:54 +04:00
|
|
|
|
2014-08-20 16:25:16 +04:00
|
|
|
nsresult RemoveContainer(nsIContent* aNode);
|
2016-05-01 16:15:14 +03:00
|
|
|
already_AddRefed<Element> InsertContainerAbove(nsIContent* aNode,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aNodeType,
|
|
|
|
nsAtom* aAttribute = nullptr,
|
2016-05-01 16:15:14 +03:00
|
|
|
const nsAString* aValue =
|
|
|
|
nullptr);
|
2014-11-02 15:04:13 +03:00
|
|
|
nsIContent* SplitNode(nsIContent& aNode, int32_t aOffset,
|
2016-05-01 16:15:14 +03:00
|
|
|
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
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult CloneAttribute(nsAtom* aAttribute, Element* aDestElement,
|
2016-12-20 13:24:08 +03:00
|
|
|
Element* aSourceElement);
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult RemoveAttribute(Element* aElement, nsAtom* aAttribute);
|
2016-12-20 13:24:08 +03:00
|
|
|
virtual nsresult RemoveAttributeOrEquivalent(Element* aElement,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2016-12-20 13:24:08 +03:00
|
|
|
bool aSuppressTransaction) = 0;
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult SetAttribute(Element* aElement, nsAtom* aAttribute,
|
2016-12-20 13:24:08 +03:00
|
|
|
const nsAString& aValue);
|
|
|
|
virtual nsresult SetAttributeOrEquivalent(Element* aElement,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2016-12-20 13:24:08 +03:00
|
|
|
const nsAString& aValue,
|
|
|
|
bool aSuppressTransaction) = 0;
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Method to replace certain CreateElementNS() calls.
|
|
|
|
*
|
|
|
|
* @param aTag Tag you want.
|
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
already_AddRefed<Element> CreateHTMLContent(nsAtom* aTag);
|
2000-07-14 03:15:41 +04:00
|
|
|
|
2017-08-18 10:05:16 +03:00
|
|
|
/**
|
|
|
|
* Creates text node which is marked as "maybe modified frequently".
|
|
|
|
*/
|
|
|
|
static already_AddRefed<nsTextNode> CreateTextNode(nsIDocument& aDocument,
|
|
|
|
const nsAString& aData);
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* IME event handlers.
|
|
|
|
*/
|
|
|
|
virtual nsresult BeginIMEComposition(WidgetCompositionEvent* aEvent);
|
2017-01-17 11:01:17 +03:00
|
|
|
virtual nsresult UpdateIMEComposition(
|
|
|
|
WidgetCompositionEvent* aCompositionChangeEvet) = 0;
|
2012-06-19 17:23:36 +04:00
|
|
|
void EndIMEComposition();
|
2010-06-30 08:05:12 +04:00
|
|
|
|
2017-08-08 05:25:36 +03:00
|
|
|
/**
|
|
|
|
* Commit composition if there is.
|
|
|
|
* Note that when there is a composition, this requests to commit composition
|
|
|
|
* to native IME. Therefore, when there is composition, this can do anything.
|
|
|
|
* For example, the editor instance, the widget or the process itself may
|
|
|
|
* be destroyed.
|
|
|
|
*/
|
|
|
|
nsresult CommitComposition();
|
|
|
|
|
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
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Create a transaction for setting aAttribute to aValue on aElement. Never
|
|
|
|
* returns null.
|
|
|
|
*/
|
|
|
|
already_AddRefed<ChangeAttributeTransaction>
|
2017-10-03 01:05:19 +03:00
|
|
|
CreateTxnForSetAttribute(Element& aElement, nsAtom& aAttribute,
|
2016-07-08 07:10:13 +03:00
|
|
|
const nsAString& aValue);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a transaction for removing aAttribute on aElement. Never returns
|
|
|
|
* null.
|
|
|
|
*/
|
|
|
|
already_AddRefed<ChangeAttributeTransaction>
|
2017-10-03 01:05:19 +03:00
|
|
|
CreateTxnForRemoveAttribute(Element& aElement, nsAtom& aAttribute);
|
2016-07-08 07:10:13 +03:00
|
|
|
|
|
|
|
/**
|
2017-11-08 11:23:28 +03:00
|
|
|
* Create a transaction for creating a new child node of the container of
|
|
|
|
* aPointToInsert of type aTag.
|
|
|
|
*
|
|
|
|
* @param aTag The element name to create.
|
|
|
|
* @param aPointToInsert The insertion point of new element. If this refers
|
|
|
|
* end of the container or after, the transaction
|
|
|
|
* will append the element to the container.
|
|
|
|
* Otherwise, will insert the element before the
|
|
|
|
* child node referred by this.
|
|
|
|
* @return A CreateElementTransaction which are initialized
|
|
|
|
* with the arguments.
|
2016-07-08 07:10:13 +03:00
|
|
|
*/
|
|
|
|
already_AddRefed<CreateElementTransaction>
|
2017-10-03 01:05:19 +03:00
|
|
|
CreateTxnForCreateElement(nsAtom& aTag,
|
2017-11-08 11:23:28 +03:00
|
|
|
const EditorRawDOMPoint& aPointToInsert);
|
2014-08-20 16:25:16 +04:00
|
|
|
|
2017-11-08 14:23:10 +03:00
|
|
|
/**
|
|
|
|
* Create an element node whose name is aTag at before aPointToInsert. When
|
|
|
|
* this succeed to create an element node, this sets aPointToInsert to the
|
|
|
|
* new element because the relation of child and offset may be broken.
|
|
|
|
* If the caller needs to collapse the selection to next to the new element
|
|
|
|
* node, it should call |aPointToInsert.AdvanceOffset()| after calling this.
|
|
|
|
*
|
|
|
|
* @param aTag The element name to create.
|
|
|
|
* @param aPointToInsert The insertion point of new element. If this refers
|
|
|
|
* end of the container or after, the transaction
|
|
|
|
* will append the element to the container.
|
|
|
|
* Otherwise, will insert the element before the
|
|
|
|
* child node referred by this.
|
|
|
|
* @return The created new element node.
|
|
|
|
*/
|
|
|
|
already_AddRefed<Element> CreateNode(nsAtom* aTag,
|
|
|
|
EditorRawDOMPoint& aPointToInsert);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Create a transaction for inserting aNode as a child of aParent.
|
|
|
|
*/
|
|
|
|
already_AddRefed<InsertNodeTransaction>
|
|
|
|
CreateTxnForInsertNode(nsIContent& aNode, nsINode& aParent,
|
|
|
|
int32_t aOffset);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Create a transaction for removing aNode from its parent.
|
|
|
|
*/
|
2017-03-14 14:50:24 +03:00
|
|
|
already_AddRefed<DeleteNodeTransaction>
|
|
|
|
CreateTxnForDeleteNode(nsINode* aNode);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2017-03-15 08:35:43 +03:00
|
|
|
/**
|
|
|
|
* Create an aggregate transaction for delete selection. The result may
|
|
|
|
* include DeleteNodeTransactions and/or DeleteTextTransactions as its
|
|
|
|
* children.
|
|
|
|
*
|
|
|
|
* @param aAction The action caused removing the selection.
|
|
|
|
* @param aRemovingNode The node to be removed.
|
|
|
|
* @param aOffset The start offset of the range in aRemovingNode.
|
|
|
|
* @param aLength The length of the range in aRemovingNode.
|
|
|
|
* @return If it can remove the selection, returns an
|
|
|
|
* aggregate transaction which has some
|
|
|
|
* DeleteNodeTransactions and/or
|
|
|
|
* DeleteTextTransactions as its children.
|
|
|
|
*/
|
|
|
|
already_AddRefed<EditAggregateTransaction>
|
|
|
|
CreateTxnForDeleteSelection(EDirection aAction,
|
|
|
|
nsINode** aNode,
|
|
|
|
int32_t* aOffset,
|
|
|
|
int32_t* aLength);
|
2016-07-07 11:11:30 +03:00
|
|
|
|
2017-03-14 16:01:36 +03:00
|
|
|
/**
|
|
|
|
* Create a transaction for removing the nodes and/or text in aRange.
|
|
|
|
*
|
|
|
|
* @param aRangeToDelete The range to be removed.
|
|
|
|
* @param aAction The action caused removing the range.
|
|
|
|
* @param aRemovingNode The node to be removed.
|
|
|
|
* @param aOffset The start offset of the range in aRemovingNode.
|
|
|
|
* @param aLength The length of the range in aRemovingNode.
|
|
|
|
* @return The transaction to remove the range. Its type
|
|
|
|
* is DeleteNodeTransaction or
|
|
|
|
* DeleteTextTransaction.
|
|
|
|
*/
|
|
|
|
already_AddRefed<EditTransactionBase>
|
|
|
|
CreateTxnForDeleteRange(nsRange* aRangeToDelete,
|
|
|
|
EDirection aAction,
|
|
|
|
nsINode** aRemovingNode,
|
|
|
|
int32_t* aOffset,
|
|
|
|
int32_t* aLength);
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Create a transaction for inserting aStringToInsert into aTextNode. Never
|
|
|
|
* returns null.
|
|
|
|
*/
|
2016-07-07 10:06:41 +03:00
|
|
|
already_AddRefed<mozilla::InsertTextTransaction>
|
2016-07-08 07:10:13 +03:00
|
|
|
CreateTxnForInsertText(const nsAString& aStringToInsert, Text& aTextNode,
|
|
|
|
int32_t aOffset);
|
1999-02-12 20:18:58 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Never returns null.
|
|
|
|
*/
|
2016-07-07 09:42:08 +03:00
|
|
|
already_AddRefed<mozilla::CompositionTransaction>
|
2016-07-08 07:10:13 +03:00
|
|
|
CreateTxnForComposition(const nsAString& aStringToInsert);
|
1999-06-30 00:31:22 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Create a transaction for adding a style sheet.
|
|
|
|
*/
|
2017-01-27 07:29:00 +03:00
|
|
|
already_AddRefed<mozilla::AddStyleSheetTransaction>
|
|
|
|
CreateTxnForAddStyleSheet(StyleSheet* aSheet);
|
1999-07-02 07:57:50 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Create a transaction for removing a style sheet.
|
|
|
|
*/
|
2017-01-27 07:29:00 +03:00
|
|
|
already_AddRefed<mozilla::RemoveStyleSheetTransaction>
|
|
|
|
CreateTxnForRemoveStyleSheet(StyleSheet* aSheet);
|
2015-05-28 18:58:42 +03: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
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
already_AddRefed<DeleteTextTransaction>
|
|
|
|
CreateTxnForDeleteText(nsGenericDOMDataNode& aElement,
|
|
|
|
uint32_t aOffset, uint32_t aLength);
|
2001-05-11 16:43:22 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
already_AddRefed<DeleteTextTransaction>
|
|
|
|
CreateTxnForDeleteCharacter(nsGenericDOMDataNode& aData, uint32_t aOffset,
|
|
|
|
EDirection aDirection);
|
2006-04-04 04:57:55 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
already_AddRefed<SplitNodeTransaction>
|
|
|
|
CreateTxnForSplitNode(nsIContent& aNode, uint32_t aOffset);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
already_AddRefed<JoinNodeTransaction>
|
|
|
|
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();
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Called after a transaction is done successfully.
|
|
|
|
*/
|
2012-07-05 11:45:09 +04:00
|
|
|
void DoAfterDoTransaction(nsITransaction *aTxn);
|
2016-07-08 07:10:13 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called after a transaction is undone successfully.
|
|
|
|
*/
|
|
|
|
|
2012-07-05 11:45:09 +04:00
|
|
|
void DoAfterUndoTransaction();
|
2016-07-08 07:10:13 +03: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
|
|
|
|
2017-07-28 21:49:58 +03:00
|
|
|
// Note that aSelection is optional and can be nullptr.
|
|
|
|
nsresult DoTransaction(Selection* aSelection,
|
|
|
|
nsITransaction* aTxn);
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
enum TDocumentListenerNotification
|
|
|
|
{
|
1999-08-03 04:58:38 +04:00
|
|
|
eDocumentCreated,
|
|
|
|
eDocumentToBeDestroyed,
|
|
|
|
eDocumentStateChanged
|
2016-07-08 07:10:13 +03:00
|
|
|
};
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Tell the doc state listeners that the doc state has changed.
|
|
|
|
*/
|
2017-02-02 07:56:57 +03:00
|
|
|
nsresult NotifyDocumentListeners(
|
|
|
|
TDocumentListenerNotification aNotificationType);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Make the given selection span the entire document.
|
|
|
|
*/
|
2016-05-01 16:15:14 +03:00
|
|
|
virtual nsresult SelectEntireDocument(Selection* aSelection);
|
2001-01-09 00:01:29 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Helper method for scrolling the selection into view after
|
|
|
|
* an edit operation. aScrollToAnchor should be true if you
|
|
|
|
* want to scroll to the point where the selection was started.
|
|
|
|
* If false, it attempts to scroll the end of the selection into view.
|
2002-06-14 00:35:12 +04:00
|
|
|
*
|
2016-07-08 07:10:13 +03: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.
|
2002-06-14 00:35:12 +04:00
|
|
|
*/
|
2017-02-02 07:56:57 +03:00
|
|
|
nsresult ScrollSelectionIntoView(bool aScrollToAnchor);
|
1999-03-14 03:31:35 +03:00
|
|
|
|
2012-07-01 23:53:16 +04:00
|
|
|
virtual bool IsBlockNode(nsINode* aNode);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
Bug 1415800 - part 2: Redesign EditorBase::GetNextNode() with EditorRawDOMPoint r=m_kato
An overload of EditorBase::GetNextNode() takes a set of container, child node
and offset of the child in the container. Replacing it with EditorRawDOMPoint
makes the caller simpler.
Additionally, it has two bool arguments, one is for searching if editable node,
the other is for searching if in same block. So, they can be hidden with
some human readable inline methods.
When I was creating this patch, I realized that
GetNextNodeInternal(const EditorRawDOMPoint& aPoint) may return
aPoint.GetChildAtOffset(). I.e., it starts to search from the specified point
rather than next node. On the other hand, GetNextNodeInternal(nsINode& aNode)
never returns aNode itself. So, it there is better name instead of "Next",
we should take it. But I have no better idea. So, this patch just explains
the difference with comments in EditorBase.h.
MozReview-Commit-ID: 4Lb6o9SJuhy
--HG--
extra : rebase_source : d20d728eae69659ef448b6679ae8f73d64c2d7e9
2017-11-09 11:57:00 +03:00
|
|
|
* Helper for GetPreviousNodeInternal() and GetNextNodeInternal().
|
2016-07-08 07:10:13 +03:00
|
|
|
*/
|
|
|
|
nsIContent* FindNextLeafNode(nsINode* aCurrentNode,
|
|
|
|
bool aGoForward,
|
|
|
|
bool bNoBlockCrossing);
|
Bug 1415800 - part 2: Redesign EditorBase::GetNextNode() with EditorRawDOMPoint r=m_kato
An overload of EditorBase::GetNextNode() takes a set of container, child node
and offset of the child in the container. Replacing it with EditorRawDOMPoint
makes the caller simpler.
Additionally, it has two bool arguments, one is for searching if editable node,
the other is for searching if in same block. So, they can be hidden with
some human readable inline methods.
When I was creating this patch, I realized that
GetNextNodeInternal(const EditorRawDOMPoint& aPoint) may return
aPoint.GetChildAtOffset(). I.e., it starts to search from the specified point
rather than next node. On the other hand, GetNextNodeInternal(nsINode& aNode)
never returns aNode itself. So, it there is better name instead of "Next",
we should take it. But I have no better idea. So, this patch just explains
the difference with comments in EditorBase.h.
MozReview-Commit-ID: 4Lb6o9SJuhy
--HG--
extra : rebase_source : d20d728eae69659ef448b6679ae8f73d64c2d7e9
2017-11-09 11:57:00 +03:00
|
|
|
nsIContent* FindNode(nsINode* aCurrentNode,
|
|
|
|
bool aGoForward,
|
|
|
|
bool aEditableNode,
|
|
|
|
bool bNoBlockCrossing);
|
2001-12-09 12:24:33 +03:00
|
|
|
|
2017-11-09 11:08:10 +03:00
|
|
|
/**
|
|
|
|
* Get the node immediately previous node of aNode.
|
|
|
|
* @param atNode The node from which we start the search.
|
|
|
|
* @param aFindEditableNode If true, only return an editable node.
|
|
|
|
* @param aNoBlockCrossing If true, don't move across "block" nodes,
|
|
|
|
* whatever that means.
|
|
|
|
* @return The node that occurs before aNode in
|
|
|
|
* the tree, skipping non-editable nodes if
|
|
|
|
* aFindEditableNode is true. If there is no
|
|
|
|
* previous node, returns nullptr.
|
|
|
|
*/
|
|
|
|
nsIContent* GetPreviousNodeInternal(nsINode& aNode,
|
|
|
|
bool aFindEditableNode,
|
|
|
|
bool aNoBlockCrossing);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* And another version that takes a point in DOM tree rather than a node.
|
|
|
|
*/
|
|
|
|
nsIContent* GetPreviousNodeInternal(const EditorRawDOMPoint& aPoint,
|
|
|
|
bool aFindEditableNode,
|
|
|
|
bool aNoBlockCrossing);
|
|
|
|
|
Bug 1415800 - part 2: Redesign EditorBase::GetNextNode() with EditorRawDOMPoint r=m_kato
An overload of EditorBase::GetNextNode() takes a set of container, child node
and offset of the child in the container. Replacing it with EditorRawDOMPoint
makes the caller simpler.
Additionally, it has two bool arguments, one is for searching if editable node,
the other is for searching if in same block. So, they can be hidden with
some human readable inline methods.
When I was creating this patch, I realized that
GetNextNodeInternal(const EditorRawDOMPoint& aPoint) may return
aPoint.GetChildAtOffset(). I.e., it starts to search from the specified point
rather than next node. On the other hand, GetNextNodeInternal(nsINode& aNode)
never returns aNode itself. So, it there is better name instead of "Next",
we should take it. But I have no better idea. So, this patch just explains
the difference with comments in EditorBase.h.
MozReview-Commit-ID: 4Lb6o9SJuhy
--HG--
extra : rebase_source : d20d728eae69659ef448b6679ae8f73d64c2d7e9
2017-11-09 11:57:00 +03:00
|
|
|
/**
|
|
|
|
* Get the node immediately next node of aNode.
|
|
|
|
* @param aNode The node from which we start the search.
|
|
|
|
* @param aFindEditableNode If true, only return an editable node.
|
|
|
|
* @param aNoBlockCrossing If true, don't move across "block" nodes,
|
|
|
|
* whatever that means.
|
|
|
|
* @return The node that occurs after aNode in the
|
|
|
|
* tree, skipping non-editable nodes if
|
|
|
|
* aFindEditableNode is true. If there is no
|
|
|
|
* next node, returns nullptr.
|
|
|
|
*/
|
|
|
|
nsIContent* GetNextNodeInternal(nsINode& aNode,
|
|
|
|
bool aFindEditableNode,
|
|
|
|
bool bNoBlockCrossing);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* And another version that takes a point in DOM tree rather than a node.
|
|
|
|
*/
|
|
|
|
nsIContent* GetNextNodeInternal(const EditorRawDOMPoint& aPoint,
|
|
|
|
bool aFindEditableNode,
|
|
|
|
bool aNoBlockCrossing);
|
|
|
|
|
|
|
|
|
2010-04-19 16:20:42 +04:00
|
|
|
virtual nsresult InstallEventListeners();
|
2011-07-15 14:18:35 +04:00
|
|
|
virtual void CreateEventListeners();
|
2005-03-24 22:00:01 +03:00
|
|
|
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
|
2016-07-08 07:10:13 +03: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.
|
2016-11-07 18:36:32 +03:00
|
|
|
* However, this may fail because the composition may be committed before
|
|
|
|
* the event comes to the editor.
|
|
|
|
*
|
|
|
|
* @return true if there is a composition. Otherwise, for example,
|
|
|
|
* a composition event handler in web contents moved focus
|
|
|
|
* for committing the composition, returns false.
|
2014-02-12 17:02:55 +04:00
|
|
|
*/
|
2016-11-07 18:36:32 +03:00
|
|
|
bool EnsureComposition(WidgetCompositionEvent* aCompositionEvent);
|
2014-02-12 17:02:55 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
nsresult GetSelection(SelectionType aSelectionType,
|
2016-06-11 05:06:37 +03:00
|
|
|
nsISelection** aSelection);
|
2015-03-08 01:14:07 +03:00
|
|
|
|
2017-08-14 08:56:39 +03:00
|
|
|
/**
|
|
|
|
* (Begin|End)PlaceholderTransaction() are called by AutoPlaceholderBatch.
|
|
|
|
* This set of methods are similar to the (Begin|End)Transaction(), but do
|
|
|
|
* not use the transaction managers batching feature. Instead we use a
|
|
|
|
* placeholder transaction to wrap up any further transaction while the
|
|
|
|
* batch is open. The advantage of this is that placeholder transactions
|
|
|
|
* can later merge, if needed. Merging is unavailable between transaction
|
|
|
|
* manager batches.
|
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
void BeginPlaceholderTransaction(nsAtom* aTransactionName);
|
2017-08-14 08:56:39 +03:00
|
|
|
void EndPlaceholderTransaction();
|
|
|
|
|
1999-05-05 08:05:19 +04:00
|
|
|
public:
|
2016-07-08 07:10:13 +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
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* All editor operations which alter the doc should be followed
|
|
|
|
* with a call to EndOperation.
|
|
|
|
*/
|
2000-08-14 06:39:37 +04:00
|
|
|
NS_IMETHOD EndOperation();
|
1999-12-07 11:30:19 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Routines for managing the preservation of selection across
|
|
|
|
* various editor actions.
|
|
|
|
*/
|
|
|
|
bool ArePreservingSelection();
|
|
|
|
void PreserveSelectionAcrossActions(Selection* aSel);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult RestorePreservedSelection(Selection* aSel);
|
2016-07-08 07:10:13 +03:00
|
|
|
void StopPreservingSelection();
|
2000-08-26 08:03:50 +04:00
|
|
|
|
2015-05-28 18:58:42 +03: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
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
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.
|
2016-07-08 07:10:13 +03:00
|
|
|
* 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.
|
2017-08-17 10:24:16 +03:00
|
|
|
* FYI: aChild must not be being removed from aParent. In such case, these
|
|
|
|
* methods may return wrong index if aChild doesn't have previous
|
|
|
|
* sibling or next sibling.
|
1999-05-05 08:05:19 +04:00
|
|
|
*/
|
2016-07-08 07:10:13 +03:00
|
|
|
static int32_t GetChildOffset(nsIDOMNode* aChild,
|
|
|
|
nsIDOMNode* aParent);
|
2017-08-17 10:24:16 +03:00
|
|
|
static int32_t GetChildOffset(nsINode* aChild,
|
|
|
|
nsINode* aParent);
|
1999-05-05 08:05:19 +04:00
|
|
|
|
1999-06-16 09:02:43 +04:00
|
|
|
/**
|
2016-07-08 07:10:13 +03: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
|
|
|
|
2016-07-08 07:10:13 +03: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
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
2017-11-09 11:08:10 +03:00
|
|
|
* Get the previous node.
|
2016-07-08 07:10:13 +03:00
|
|
|
*/
|
2017-11-09 11:08:10 +03:00
|
|
|
nsIContent* GetPreviousNode(const EditorRawDOMPoint& aPoint)
|
|
|
|
{
|
|
|
|
return GetPreviousNodeInternal(aPoint, false, false);
|
|
|
|
}
|
|
|
|
nsIContent* GetPreviousEditableNode(const EditorRawDOMPoint& aPoint)
|
|
|
|
{
|
|
|
|
return GetPreviousNodeInternal(aPoint, true, false);
|
|
|
|
}
|
|
|
|
nsIContent* GetPreviousNodeInBlock(const EditorRawDOMPoint& aPoint)
|
|
|
|
{
|
|
|
|
return GetPreviousNodeInternal(aPoint, false, true);
|
|
|
|
}
|
|
|
|
nsIContent* GetPreviousEditableNodeInBlock(
|
|
|
|
const EditorRawDOMPoint& aPoint)
|
|
|
|
{
|
|
|
|
return GetPreviousNodeInternal(aPoint, true, true);
|
|
|
|
}
|
|
|
|
nsIContent* GetPreviousNode(nsINode& aNode)
|
|
|
|
{
|
|
|
|
return GetPreviousNodeInternal(aNode, false, false);
|
|
|
|
}
|
|
|
|
nsIContent* GetPreviousEditableNode(nsINode& aNode)
|
|
|
|
{
|
|
|
|
return GetPreviousNodeInternal(aNode, true, false);
|
|
|
|
}
|
|
|
|
nsIContent* GetPreviousNodeInBlock(nsINode& aNode)
|
|
|
|
{
|
|
|
|
return GetPreviousNodeInternal(aNode, false, true);
|
|
|
|
}
|
|
|
|
nsIContent* GetPreviousEditableNodeInBlock(nsINode& aNode)
|
|
|
|
{
|
|
|
|
return GetPreviousNodeInternal(aNode, true, true);
|
|
|
|
}
|
2012-05-05 13:00:05 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
Bug 1415800 - part 2: Redesign EditorBase::GetNextNode() with EditorRawDOMPoint r=m_kato
An overload of EditorBase::GetNextNode() takes a set of container, child node
and offset of the child in the container. Replacing it with EditorRawDOMPoint
makes the caller simpler.
Additionally, it has two bool arguments, one is for searching if editable node,
the other is for searching if in same block. So, they can be hidden with
some human readable inline methods.
When I was creating this patch, I realized that
GetNextNodeInternal(const EditorRawDOMPoint& aPoint) may return
aPoint.GetChildAtOffset(). I.e., it starts to search from the specified point
rather than next node. On the other hand, GetNextNodeInternal(nsINode& aNode)
never returns aNode itself. So, it there is better name instead of "Next",
we should take it. But I have no better idea. So, this patch just explains
the difference with comments in EditorBase.h.
MozReview-Commit-ID: 4Lb6o9SJuhy
--HG--
extra : rebase_source : d20d728eae69659ef448b6679ae8f73d64c2d7e9
2017-11-09 11:57:00 +03:00
|
|
|
* Get the next node.
|
|
|
|
*
|
|
|
|
* Note that methods taking EditorRawDOMPoint behavior includes the
|
|
|
|
* child at offset as search target. E.g., following code causes infinite
|
|
|
|
* loop.
|
|
|
|
*
|
|
|
|
* EditorRawDOMPoint point(aEditableNode);
|
|
|
|
* while (nsIContent* content = GetNextEditableNode(point)) {
|
|
|
|
* // Do something...
|
|
|
|
* point.Set(content);
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* Following code must be you expected:
|
|
|
|
*
|
|
|
|
* while (nsIContent* content = GetNextEditableNode(point)) {
|
|
|
|
* // Do something...
|
|
|
|
* DebugOnly<bool> advanced = point.Advanced();
|
|
|
|
* MOZ_ASSERT(advanced);
|
|
|
|
* point.Set(point.GetChildAtOffset());
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* On the other hand, the methods taking nsINode behavior must be what
|
|
|
|
* you want. They start to search the result from next node of the given
|
|
|
|
* node.
|
2016-07-08 07:10:13 +03:00
|
|
|
*/
|
Bug 1415800 - part 2: Redesign EditorBase::GetNextNode() with EditorRawDOMPoint r=m_kato
An overload of EditorBase::GetNextNode() takes a set of container, child node
and offset of the child in the container. Replacing it with EditorRawDOMPoint
makes the caller simpler.
Additionally, it has two bool arguments, one is for searching if editable node,
the other is for searching if in same block. So, they can be hidden with
some human readable inline methods.
When I was creating this patch, I realized that
GetNextNodeInternal(const EditorRawDOMPoint& aPoint) may return
aPoint.GetChildAtOffset(). I.e., it starts to search from the specified point
rather than next node. On the other hand, GetNextNodeInternal(nsINode& aNode)
never returns aNode itself. So, it there is better name instead of "Next",
we should take it. But I have no better idea. So, this patch just explains
the difference with comments in EditorBase.h.
MozReview-Commit-ID: 4Lb6o9SJuhy
--HG--
extra : rebase_source : d20d728eae69659ef448b6679ae8f73d64c2d7e9
2017-11-09 11:57:00 +03:00
|
|
|
nsIContent* GetNextNode(const EditorRawDOMPoint& aPoint)
|
|
|
|
{
|
|
|
|
return GetNextNodeInternal(aPoint, false, false);
|
|
|
|
}
|
|
|
|
nsIContent* GetNextEditableNode(const EditorRawDOMPoint& aPoint)
|
|
|
|
{
|
|
|
|
return GetNextNodeInternal(aPoint, true, false);
|
|
|
|
}
|
|
|
|
nsIContent* GetNextNodeInBlock(const EditorRawDOMPoint& aPoint)
|
|
|
|
{
|
|
|
|
return GetNextNodeInternal(aPoint, false, true);
|
|
|
|
}
|
|
|
|
nsIContent* GetNextEditableNodeInBlock(
|
|
|
|
const EditorRawDOMPoint& aPoint)
|
|
|
|
{
|
|
|
|
return GetNextNodeInternal(aPoint, true, true);
|
|
|
|
}
|
|
|
|
nsIContent* GetNextNode(nsINode& aNode)
|
|
|
|
{
|
|
|
|
return GetNextNodeInternal(aNode, false, false);
|
|
|
|
}
|
|
|
|
nsIContent* GetNextEditableNode(nsINode& aNode)
|
|
|
|
{
|
|
|
|
return GetNextNodeInternal(aNode, true, false);
|
|
|
|
}
|
|
|
|
nsIContent* GetNextNodeInBlock(nsINode& aNode)
|
|
|
|
{
|
|
|
|
return GetNextNodeInternal(aNode, false, true);
|
|
|
|
}
|
|
|
|
nsIContent* GetNextEditableNodeInBlock(nsINode& aNode)
|
|
|
|
{
|
|
|
|
return GetNextNodeInternal(aNode, true, true);
|
|
|
|
}
|
2001-08-22 09:32:44 +04:00
|
|
|
|
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
|
|
|
*/
|
2016-07-08 07:10:13 +03: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,
|
2016-07-08 07:10:13 +03:00
|
|
|
bool bNoBlockCrossing = false);
|
1999-05-05 08:05:19 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Returns true if aNode is of the type implied by aTag.
|
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
static inline bool NodeIsType(nsIDOMNode* aNode, nsAtom* 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
|
|
|
}
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Returns true if aParent can contain a child of type aTag.
|
|
|
|
*/
|
2017-10-26 19:27:44 +03:00
|
|
|
bool CanContain(nsINode& aParent, nsIContent& aChild) const;
|
|
|
|
bool CanContainTag(nsINode& aParent, nsAtom& aTag) const;
|
|
|
|
bool TagCanContain(nsAtom& aParentTag, nsIContent& aChild) const;
|
|
|
|
virtual bool TagCanContainTag(nsAtom& aParentTag, nsAtom& aChildTag) const;
|
2000-02-08 15:53:34 +03:00
|
|
|
|
2016-07-08 07:10:13 +03: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
|
|
|
|
2016-07-08 07:10:13 +03: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(nsINode* aNode);
|
2000-05-10 01:06:49 +04:00
|
|
|
|
2016-07-08 07:10:13 +03: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
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* returns true if aNode is an editable node.
|
|
|
|
*/
|
|
|
|
bool IsEditable(nsIDOMNode* aNode);
|
2017-08-02 06:20:42 +03:00
|
|
|
bool IsEditable(nsINode* aNode)
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(aNode, false);
|
|
|
|
|
2017-10-25 18:19:11 +03:00
|
|
|
if (!aNode->IsContent() || IsMozEditorBogusNode(aNode) ||
|
2017-08-02 06:20:42 +03:00
|
|
|
!IsModifiableNode(aNode)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aNode->NodeType()) {
|
|
|
|
case nsIDOMNode::ELEMENT_NODE:
|
|
|
|
// In HTML editors, if we're dealing with an element, then ask it
|
|
|
|
// whether it's editable.
|
|
|
|
return mIsHTMLEditorClass ? aNode->IsEditable() : true;
|
|
|
|
case nsIDOMNode::TEXT_NODE:
|
|
|
|
// Text nodes are considered to be editable by both typed of editors.
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
1999-05-05 08:05:19 +04:00
|
|
|
|
2017-08-04 12:30:13 +03:00
|
|
|
/**
|
|
|
|
* Returns true if selection is in an editable element and both the range
|
|
|
|
* start and the range end are editable. E.g., even if the selection range
|
|
|
|
* includes non-editable elements, returns true when one of common ancestors
|
|
|
|
* of the range start and the range end is editable. Otherwise, false.
|
|
|
|
*/
|
|
|
|
bool IsSelectionEditable();
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Returns true if aNode is a MozEditorBogus node.
|
|
|
|
*/
|
2017-08-02 05:47:37 +03:00
|
|
|
bool IsMozEditorBogusNode(nsINode* aNode)
|
|
|
|
{
|
|
|
|
return aNode && aNode->IsElement() &&
|
|
|
|
aNode->AsElement()->AttrValueIs(kNameSpaceID_None,
|
|
|
|
kMOZEditorBogusNodeAttrAtom, kMOZEditorBogusNodeValue,
|
|
|
|
eCaseMatters);
|
|
|
|
}
|
2000-01-19 02:45:35 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Counts number of editable child nodes.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t CountEditableChildren(nsINode* aNode);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Find the deep first and last children.
|
|
|
|
*/
|
2012-02-01 14:54:22 +04:00
|
|
|
nsINode* GetFirstEditableNode(nsINode* aRoot);
|
1999-06-23 01:42:44 +04:00
|
|
|
|
2014-02-12 17:02:56 +04:00
|
|
|
/**
|
|
|
|
* Returns current composition.
|
|
|
|
*/
|
2016-07-08 07:10:13 +03:00
|
|
|
TextComposition* GetComposition() const;
|
|
|
|
|
2014-02-12 17:02:56 +04:00
|
|
|
/**
|
|
|
|
* Returns true if there is composition string and not fixed.
|
|
|
|
*/
|
|
|
|
bool IsIMEComposing() const;
|
2016-07-08 07:10:13 +03:00
|
|
|
|
2015-06-04 20:06:09 +03:00
|
|
|
/**
|
|
|
|
* Returns true when inserting text should be a part of current composition.
|
|
|
|
*/
|
|
|
|
bool ShouldHandleIMEComposition() const;
|
1999-06-23 01:42:44 +04:00
|
|
|
|
2017-06-19 17:47:02 +03:00
|
|
|
/**
|
|
|
|
* Returns number of undo or redo items. If TransactionManager returns
|
|
|
|
* unexpected error, returns -1.
|
|
|
|
*/
|
|
|
|
int32_t NumberOfUndoItems() const;
|
|
|
|
int32_t NumberOfRedoItems() const;
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* From html rules code - migration in progress.
|
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
static nsAtom* GetTag(nsIDOMNode* aNode);
|
2012-05-18 12:29:38 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
bool NodesSameType(nsIDOMNode* aNode1, nsIDOMNode* aNode2);
|
2012-05-18 12:29:38 +04:00
|
|
|
virtual bool AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2);
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
static bool IsTextNode(nsIDOMNode* aNode);
|
2017-08-24 13:53:34 +03:00
|
|
|
static bool IsTextNode(nsINode* aNode)
|
|
|
|
{
|
|
|
|
return aNode->NodeType() == nsIDOMNode::TEXT_NODE;
|
|
|
|
}
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2017-11-01 08:41:03 +03:00
|
|
|
/**
|
|
|
|
* GetNodeAtRangeOffsetPoint() returns the node at this position in a range,
|
|
|
|
* assuming that the container is the node itself if it's a text node, or
|
|
|
|
* the node's parent otherwise.
|
|
|
|
*/
|
|
|
|
static nsIContent* GetNodeAtRangeOffsetPoint(nsINode* aContainer,
|
|
|
|
int32_t aOffset)
|
|
|
|
{
|
|
|
|
return GetNodeAtRangeOffsetPoint(RawRangeBoundary(aContainer, aOffset));
|
|
|
|
}
|
|
|
|
static nsIContent* GetNodeAtRangeOffsetPoint(const RawRangeBoundary& aPoint);
|
2011-07-14 19:25:07 +04:00
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
static nsresult GetStartNodeAndOffset(Selection* aSelection,
|
2014-11-02 15:04:13 +03:00
|
|
|
nsIDOMNode** outStartNode,
|
|
|
|
int32_t* outStartOffset);
|
2016-05-01 16:15:14 +03:00
|
|
|
static nsresult GetStartNodeAndOffset(Selection* aSelection,
|
2017-07-11 17:10:42 +03:00
|
|
|
nsINode** aStartContainer,
|
2013-07-24 11:39:08 +04:00
|
|
|
int32_t* aStartOffset);
|
2017-11-08 15:55:10 +03:00
|
|
|
static EditorRawDOMPoint GetStartPoint(Selection* aSelection);
|
2016-05-01 16:15:14 +03:00
|
|
|
static nsresult GetEndNodeAndOffset(Selection* aSelection,
|
2014-11-02 15:04:13 +03:00
|
|
|
nsIDOMNode** outEndNode,
|
|
|
|
int32_t* outEndOffset);
|
2016-05-01 16:15:14 +03:00
|
|
|
static nsresult GetEndNodeAndOffset(Selection* aSelection,
|
2017-07-11 18:09:37 +03:00
|
|
|
nsINode** aEndContainer,
|
2013-07-24 11:39:08 +04:00
|
|
|
int32_t* aEndOffset);
|
2017-11-08 19:00:36 +03:00
|
|
|
static EditorRawDOMPoint GetEndPoint(Selection* aSelection);
|
2017-10-04 20:55:29 +03:00
|
|
|
|
|
|
|
static nsresult GetEndChildNode(Selection* aSelection,
|
|
|
|
nsIContent** aEndNode);
|
|
|
|
|
2002-11-22 06:30:59 +03:00
|
|
|
#if DEBUG_JOE
|
2016-07-08 07:10:13 +03:00
|
|
|
static void DumpNode(nsIDOMNode* aNode, int32_t indent = 0);
|
2002-11-22 06:30:59 +03:00
|
|
|
#endif
|
2016-07-08 07:10:13 +03:00
|
|
|
Selection* GetSelection(SelectionType aSelectionType =
|
2017-08-02 02:51:25 +03:00
|
|
|
SelectionType::eNormal)
|
|
|
|
{
|
|
|
|
nsISelectionController* sc = GetSelectionController();
|
|
|
|
if (!sc) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
Selection* selection = sc->GetDOMSelection(ToRawSelectionType(aSelectionType));
|
|
|
|
return selection;
|
|
|
|
}
|
1999-06-09 05:27:08 +04:00
|
|
|
|
2017-08-17 11:08:22 +03:00
|
|
|
/**
|
|
|
|
* CollapseSelectionToEnd() collapses the selection to the end of the editor.
|
|
|
|
*/
|
|
|
|
nsresult CollapseSelectionToEnd(Selection* aSelection);
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Helpers to add a node to the selection.
|
|
|
|
* Used by table cell selection methods.
|
|
|
|
*/
|
2017-07-11 17:10:42 +03:00
|
|
|
nsresult CreateRange(nsIDOMNode* aStartContainer, int32_t aStartOffset,
|
2017-07-11 18:09:37 +03:00
|
|
|
nsIDOMNode* aEndContainer, int32_t aEndOffset,
|
2014-11-02 15:04:13 +03:00
|
|
|
nsRange** aRange);
|
2002-01-14 23:25:29 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Creates a range with just the supplied node and appends that to the
|
|
|
|
* selection.
|
|
|
|
*/
|
2000-02-10 08:14:52 +03:00
|
|
|
nsresult AppendNodeToSelectionAsRange(nsIDOMNode *aNode);
|
2016-07-08 07:10:13 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* When you are using AppendNodeToSelectionAsRange(), call this first to
|
|
|
|
* start a new selection.
|
|
|
|
*/
|
2000-02-10 08:14:52 +03:00
|
|
|
nsresult ClearSelection();
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
nsresult IsPreformatted(nsIDOMNode* aNode, bool* aResult);
|
1999-05-17 16:22:31 +04:00
|
|
|
|
2015-08-05 17:54:36 +03:00
|
|
|
enum class EmptyContainers { no, yes };
|
|
|
|
int32_t SplitNodeDeep(nsIContent& aNode, nsIContent& aSplitPointParent,
|
|
|
|
int32_t aSplitPointOffset,
|
|
|
|
EmptyContainers aEmptyContainers =
|
|
|
|
EmptyContainers::yes,
|
|
|
|
nsIContent** outLeftNode = nullptr,
|
2017-10-11 02:39:54 +03:00
|
|
|
nsIContent** outRightNode = nullptr,
|
2017-10-12 06:16:00 +03:00
|
|
|
nsCOMPtr<nsIContent>* ioChildAtSplitPointOffset =
|
2017-10-11 02:39:54 +03:00
|
|
|
nullptr);
|
2016-07-08 07:10:13 +03:00
|
|
|
EditorDOMPoint 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
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
void BeginUpdateViewBatch();
|
|
|
|
virtual nsresult EndUpdateViewBatch();
|
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
|
|
|
|
2017-02-08 14:18:17 +03:00
|
|
|
virtual nsresult HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent);
|
2010-06-10 05:16:58 +04:00
|
|
|
|
2012-08-12 22:28:26 +04:00
|
|
|
nsresult HandleInlineSpellCheck(EditAction action,
|
2016-05-01 16:15:14 +03:00
|
|
|
Selection* aSelection,
|
2016-07-08 07:10:13 +03:00
|
|
|
nsIDOMNode* previousSelectedNode,
|
|
|
|
int32_t previousSelectedOffset,
|
2017-07-11 17:10:42 +03:00
|
|
|
nsIDOMNode* aStartContainer,
|
2016-07-08 07:10:13 +03:00
|
|
|
int32_t aStartOffset,
|
2017-07-11 18:09:37 +03:00
|
|
|
nsIDOMNode* aEndContainer,
|
2016-07-08 07:10:13 +03:00
|
|
|
int32_t aEndOffset);
|
2005-02-02 00:12:53 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
virtual already_AddRefed<dom::EventTarget> GetDOMEventTarget() = 0;
|
2005-03-24 22:00:01 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Fast non-refcounting editor root element accessor
|
|
|
|
*/
|
2017-09-05 17:32:17 +03:00
|
|
|
Element* GetRoot() const { return mRootElement; }
|
2005-03-24 22:00:01 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Likewise, but gets the editor's root instead, which is different for HTML
|
|
|
|
* editors.
|
|
|
|
*/
|
2016-05-01 16:15:14 +03:00
|
|
|
virtual Element* GetEditorRoot();
|
2012-05-06 11:53:11 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Likewise, but gets the text control element instead of the root for
|
|
|
|
* plaintext editors.
|
|
|
|
*/
|
2016-05-01 16:15:14 +03:00
|
|
|
Element* GetExposedRoot();
|
2014-01-17 19:31:03 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Accessor methods to flags.
|
|
|
|
*/
|
2017-06-20 16:57:08 +03:00
|
|
|
uint32_t Flags() const { return mFlags; }
|
|
|
|
|
2017-08-08 05:25:36 +03:00
|
|
|
nsresult AddFlags(uint32_t aFlags)
|
|
|
|
{
|
|
|
|
const uint32_t kOldFlags = Flags();
|
|
|
|
const uint32_t kNewFlags = (kOldFlags | aFlags);
|
|
|
|
if (kNewFlags == kOldFlags) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return SetFlags(kNewFlags); // virtual call and may be expensive.
|
|
|
|
}
|
|
|
|
nsresult RemoveFlags(uint32_t aFlags)
|
|
|
|
{
|
|
|
|
const uint32_t kOldFlags = Flags();
|
|
|
|
const uint32_t kNewFlags = (kOldFlags & ~aFlags);
|
|
|
|
if (kNewFlags == kOldFlags) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return SetFlags(kNewFlags); // virtual call and may be expensive.
|
|
|
|
}
|
|
|
|
nsresult AddAndRemoveFlags(uint32_t aAddingFlags, uint32_t aRemovingFlags)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!(aAddingFlags & aRemovingFlags),
|
|
|
|
"Same flags are specified both adding and removing");
|
|
|
|
const uint32_t kOldFlags = Flags();
|
|
|
|
const uint32_t kNewFlags = ((kOldFlags | aAddingFlags) & ~aRemovingFlags);
|
|
|
|
if (kNewFlags == kOldFlags) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return SetFlags(kNewFlags); // virtual call and may be expensive.
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-06-20 16:57:08 +03:00
|
|
|
// FYI: Both IsRightToLeft() and IsLeftToRight() may return false if
|
|
|
|
// the editor inherits the content node's direction.
|
|
|
|
bool IsRightToLeft() const
|
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorRightToLeft) != 0;
|
|
|
|
}
|
|
|
|
bool IsLeftToRight() const
|
|
|
|
{
|
|
|
|
return (mFlags & nsIPlaintextEditor::eEditorLeftToRight) != 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;
|
|
|
|
}
|
2015-05-28 18:58:42 +03: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
|
|
|
|
{
|
2017-08-02 00:00:50 +03:00
|
|
|
return !!mSelectionController;
|
2013-05-18 04:07:46 +04:00
|
|
|
}
|
|
|
|
|
2017-02-03 10:22:50 +03:00
|
|
|
bool IsModifiable() const
|
|
|
|
{
|
|
|
|
return !IsReadonly();
|
|
|
|
}
|
|
|
|
|
2017-06-20 16:57:08 +03:00
|
|
|
/**
|
|
|
|
* IsInEditAction() return true while the instance is handling an edit action.
|
|
|
|
* Otherwise, false.
|
|
|
|
*/
|
|
|
|
bool IsInEditAction() const { return mIsInEditAction; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IsSuppressingDispatchingInputEvent() returns true if the editor stops
|
|
|
|
* dispatching input event. Otherwise, false.
|
|
|
|
*/
|
|
|
|
bool IsSuppressingDispatchingInputEvent() const
|
|
|
|
{
|
|
|
|
return !mDispatchInputEvent;
|
|
|
|
}
|
|
|
|
|
2017-07-14 09:48:40 +03:00
|
|
|
bool Destroyed() const
|
|
|
|
{
|
|
|
|
return mDidPreDestroy;
|
|
|
|
}
|
|
|
|
|
2017-06-20 16:57:08 +03:00
|
|
|
/**
|
|
|
|
* GetTransactionManager() returns transaction manager associated with the
|
|
|
|
* editor. This may return nullptr if undo/redo hasn't been enabled.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsITransactionManager> GetTransactionManager() const;
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Get the input event target. This might return null.
|
|
|
|
*/
|
2012-03-27 05:36:44 +04:00
|
|
|
virtual already_AddRefed<nsIContent> GetInputEventTargetContent() = 0;
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Get the focused content, if we're focused. Returns null otherwise.
|
|
|
|
*/
|
2010-10-29 20:30:52 +04:00
|
|
|
virtual already_AddRefed<nsIContent> GetFocusedContent();
|
2010-05-04 21:40:39 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Get the focused content for the argument of some IMEStateManager's
|
|
|
|
* methods.
|
|
|
|
*/
|
2012-11-09 12:40:39 +04:00
|
|
|
virtual already_AddRefed<nsIContent> GetFocusedContentForIME();
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* Whether the editor is active on the DOM window. Note that when this
|
|
|
|
* returns true but GetFocusedContent() returns null, it means that this editor was
|
|
|
|
* 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
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
2017-01-17 11:17:06 +03:00
|
|
|
* Whether the aGUIEvent should be handled by this editor or not. When this
|
|
|
|
* returns false, The aGUIEvent shouldn't be handled on this editor,
|
|
|
|
* i.e., The aGUIEvent should be handled by another inner editor or ancestor
|
2016-07-08 07:10:13 +03:00
|
|
|
* elements.
|
|
|
|
*/
|
2017-01-17 11:17:06 +03:00
|
|
|
virtual bool IsAcceptableInputEvent(WidgetGUIEvent* aGUIEvent);
|
2010-07-22 20:22:44 +04:00
|
|
|
|
2016-07-08 07:10:13 +03: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 nullptr. If this is for
|
|
|
|
* designMode, you should set the document node to aNode except that an
|
|
|
|
* element in the document has focus.
|
|
|
|
*/
|
2010-06-17 09:30:42 +04:00
|
|
|
virtual already_AddRefed<nsIContent> FindSelectionRoot(nsINode* aNode);
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2010-06-17 09:30:42 +04:00
|
|
|
nsresult InitializeSelection(nsIDOMEventTarget* aFocusEventTarget);
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
/**
|
|
|
|
* This method has to be called by EditorEventListener::Focus.
|
|
|
|
* All actions that have to be done when the editor is focused needs to be
|
|
|
|
* added here.
|
|
|
|
*/
|
2011-08-12 23:12:45 +04:00
|
|
|
void OnFocus(nsIDOMEventTarget* aFocusEventTarget);
|
|
|
|
|
2016-07-08 07:10:13 +03: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.
|
|
|
|
*/
|
|
|
|
virtual nsresult InsertFromDataTransfer(dom::DataTransfer* aDataTransfer,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aIndex,
|
2016-07-08 07:10:13 +03: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;
|
|
|
|
|
2015-06-04 20:06:09 +03:00
|
|
|
/**
|
|
|
|
* GetIMESelectionStartOffsetIn() returns the start offset of IME selection in
|
|
|
|
* the aTextNode. If there is no IME selection, returns -1.
|
|
|
|
*/
|
|
|
|
int32_t GetIMESelectionStartOffsetIn(nsINode* aTextNode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* FindBetterInsertionPoint() tries to look for better insertion point which
|
|
|
|
* is typically the nearest text node and offset in it.
|
2017-10-06 21:02:40 +03:00
|
|
|
*
|
2017-11-08 15:55:10 +03:00
|
|
|
* @param aPoint Insertion point which the callers found.
|
|
|
|
* @return Better insertion point if there is. If not returns
|
|
|
|
* same point as aPoint.
|
|
|
|
*/
|
|
|
|
EditorRawDOMPoint FindBetterInsertionPoint(const EditorRawDOMPoint& aPoint);
|
2015-06-04 20:06:09 +03:00
|
|
|
|
2015-08-17 14:58:38 +03:00
|
|
|
/**
|
|
|
|
* HideCaret() hides caret with nsCaret::AddForceHide() or may show carent
|
|
|
|
* with nsCaret::RemoveForceHide(). This does NOT set visibility of
|
|
|
|
* nsCaret. Therefore, this is stateless.
|
|
|
|
*/
|
|
|
|
void HideCaret(bool aHide);
|
|
|
|
|
2017-06-19 18:55:00 +03:00
|
|
|
private:
|
2017-08-02 00:00:50 +03:00
|
|
|
nsCOMPtr<nsISelectionController> mSelectionController;
|
2017-08-02 01:30:49 +03:00
|
|
|
nsCOMPtr<nsIDocument> mDocument;
|
2017-06-19 18:55:00 +03:00
|
|
|
|
1999-08-09 05:37:50 +04:00
|
|
|
protected:
|
2016-07-08 07:10:13 +03:00
|
|
|
enum Tristate
|
|
|
|
{
|
2006-07-29 04:04:40 +04:00
|
|
|
eTriUnset,
|
|
|
|
eTriFalse,
|
|
|
|
eTriTrue
|
2012-04-24 08:54:11 +04:00
|
|
|
};
|
2016-07-08 07:10:13 +03:00
|
|
|
|
|
|
|
// MIME type of the doc we are editing.
|
|
|
|
nsCString mContentMIMEType;
|
2012-04-24 08:54:11 +04:00
|
|
|
|
2006-07-29 04:04:40 +04:00
|
|
|
nsCOMPtr<nsIInlineSpellChecker> mInlineSpellChecker;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsTransactionManager> mTxnMgr;
|
2016-07-08 07:10:13 +03:00
|
|
|
// Cached root node.
|
|
|
|
nsCOMPtr<Element> mRootElement;
|
|
|
|
// Current IME text node.
|
|
|
|
RefPtr<Text> mIMETextNode;
|
|
|
|
// The form field as an event receiver.
|
|
|
|
nsCOMPtr<dom::EventTarget> mEventTarget;
|
2012-04-24 08:54:11 +04:00
|
|
|
nsCOMPtr<nsIDOMEventListener> mEventListener;
|
2017-07-28 21:12:47 +03:00
|
|
|
// Strong reference to placeholder for begin/end batch purposes.
|
|
|
|
RefPtr<PlaceholderTransaction> mPlaceholderTransaction;
|
2016-07-08 07:10:13 +03:00
|
|
|
// Name of placeholder transaction.
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* mPlaceholderName;
|
2016-07-07 12:15:53 +03:00
|
|
|
// Saved selection state for placeholder transaction batching.
|
2017-07-29 09:43:39 +03:00
|
|
|
mozilla::Maybe<SelectionState> mSelState;
|
2014-02-12 17:02:55 +04:00
|
|
|
// IME composition this is not null between compositionstart and
|
|
|
|
// compositionend.
|
2016-07-08 07:10:13 +03:00
|
|
|
RefPtr<TextComposition> mComposition;
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
// Listens to all low level actions on the doc.
|
2017-02-07 16:26:56 +03:00
|
|
|
typedef AutoTArray<OwningNonNull<nsIEditActionListener>, 5>
|
|
|
|
AutoActionListenerArray;
|
|
|
|
AutoActionListenerArray mActionListeners;
|
2016-07-08 07:10:13 +03:00
|
|
|
// Just notify once per high level change.
|
2017-02-07 16:36:16 +03:00
|
|
|
typedef AutoTArray<OwningNonNull<nsIEditorObserver>, 3>
|
|
|
|
AutoEditorObserverArray;
|
|
|
|
AutoEditorObserverArray mEditorObservers;
|
2016-07-08 08:15:21 +03:00
|
|
|
// Listen to overall doc state (dirty or not, just created, etc.).
|
2017-02-07 16:52:23 +03:00
|
|
|
typedef AutoTArray<OwningNonNull<nsIDocumentStateListener>, 1>
|
|
|
|
AutoDocumentStateListenerArray;
|
|
|
|
AutoDocumentStateListenerArray mDocStateListeners;
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2016-07-07 12:15:53 +03:00
|
|
|
// Cached selection for AutoSelectionRestorer.
|
2016-07-08 07:10:13 +03:00
|
|
|
SelectionState mSavedSel;
|
2016-06-24 09:01:40 +03:00
|
|
|
// Utility class object for maintaining preserved ranges.
|
2016-07-08 07:10:13 +03:00
|
|
|
RangeUpdater mRangeUpdater;
|
2012-04-24 08:54:11 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
// Number of modifications (for undo/redo stack).
|
|
|
|
uint32_t mModCount;
|
|
|
|
// Behavior flags. See nsIPlaintextEditor.idl for the flags we use.
|
|
|
|
uint32_t mFlags;
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
int32_t mUpdateCount;
|
2002-12-18 02:38:04 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
// Nesting count for batching.
|
2017-06-14 13:05:48 +03:00
|
|
|
int32_t mPlaceholderBatch;
|
2016-07-08 07:10:13 +03:00
|
|
|
// The current editor action.
|
|
|
|
EditAction mAction;
|
2012-04-24 08:54:11 +04:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
// Offset in text node where IME comp string begins.
|
|
|
|
uint32_t mIMETextOffset;
|
2015-06-04 20:06:09 +03:00
|
|
|
// The Length of the composition string or commit string. If this is length
|
|
|
|
// of commit string, the length is truncated by maxlength attribute.
|
2016-07-08 07:10:13 +03:00
|
|
|
uint32_t mIMETextLength;
|
|
|
|
|
|
|
|
// The current direction of editor action.
|
|
|
|
EDirection mDirection;
|
|
|
|
// -1 = not initialized
|
|
|
|
int8_t mDocDirtyState;
|
|
|
|
// A Tristate value.
|
|
|
|
uint8_t mSpellcheckCheckboxState;
|
|
|
|
|
|
|
|
// Turn off for conservative selection adjustment by transactions.
|
|
|
|
bool mShouldTxnSetSelection;
|
|
|
|
// Whether PreDestroy has been called.
|
|
|
|
bool mDidPreDestroy;
|
|
|
|
// Whether PostCreate has been called.
|
|
|
|
bool mDidPostCreate;
|
2012-03-27 05:36:44 +04:00
|
|
|
bool mDispatchInputEvent;
|
2016-07-08 07:10:13 +03:00
|
|
|
// True while the instance is handling an edit action.
|
|
|
|
bool mIsInEditAction;
|
|
|
|
// Whether caret is hidden forcibly.
|
|
|
|
bool mHidingCaret;
|
2017-04-11 10:51:04 +03:00
|
|
|
// Whether spellchecker dictionary is initialized after focused.
|
|
|
|
bool mSpellCheckerDictionaryUpdated;
|
2017-08-04 00:18:50 +03:00
|
|
|
// Whether we are an HTML editor class.
|
|
|
|
bool mIsHTMLEditorClass;
|
2010-12-07 09:30:05 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
friend bool NSCanUnload(nsISupports* serviceMgr);
|
2017-08-14 08:56:39 +03:00
|
|
|
friend class AutoPlaceholderBatch;
|
2016-07-08 07:10:13 +03:00
|
|
|
friend class AutoRules;
|
|
|
|
friend class AutoSelectionRestorer;
|
|
|
|
friend class AutoTransactionsConserveSelection;
|
|
|
|
friend class RangeUpdater;
|
2017-08-04 09:01:36 +03:00
|
|
|
friend class nsIEditor;
|
1999-06-08 10:04:51 +04:00
|
|
|
};
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
} // namespace mozilla
|
1999-06-03 09:58:20 +04:00
|
|
|
|
2017-08-04 09:01:36 +03:00
|
|
|
mozilla::EditorBase*
|
|
|
|
nsIEditor::AsEditorBase()
|
|
|
|
{
|
|
|
|
return static_cast<mozilla::EditorBase*>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
const mozilla::EditorBase*
|
|
|
|
nsIEditor::AsEditorBase() const
|
|
|
|
{
|
|
|
|
return static_cast<const mozilla::EditorBase*>(this);
|
|
|
|
}
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
#endif // #ifndef mozilla_EditorBase_h
|