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-03-10 22:53:26 +03:00
|
|
|
|
2016-07-09 05:34:41 +03:00
|
|
|
#ifndef mozilla_TextEditRules_h
|
|
|
|
#define mozilla_TextEditRules_h
|
1999-03-10 22:53:26 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
#include "mozilla/EditorBase.h"
|
1999-03-10 22:53:26 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2016-07-07 13:33:32 +03:00
|
|
|
#include "nsIEditRules.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsIEditor.h"
|
2017-07-26 21:18:20 +03:00
|
|
|
#include "nsINamed.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsISupportsImpl.h"
|
2009-11-02 18:37:25 +03:00
|
|
|
#include "nsITimer.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nscore.h"
|
|
|
|
|
|
|
|
class nsIDOMNode;
|
2016-07-09 05:34:41 +03:00
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
namespace mozilla {
|
2016-07-09 05:34:41 +03:00
|
|
|
|
2016-06-24 15:19:18 +03:00
|
|
|
class AutoLockRulesSniffing;
|
2016-07-09 05:54:50 +03:00
|
|
|
class TextEditor;
|
2014-04-10 20:09:40 +04:00
|
|
|
namespace dom {
|
2012-07-13 10:33:42 +04:00
|
|
|
class Selection;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
1999-03-10 22:53:26 +03:00
|
|
|
|
2016-07-09 05:34:41 +03:00
|
|
|
/**
|
|
|
|
* Object that encapsulates HTML text-specific editing rules.
|
|
|
|
*
|
|
|
|
* To be a good citizen, edit rules must live by these restrictions:
|
|
|
|
* 1. All data manipulation is through the editor.
|
|
|
|
* Content nodes in the document tree must <B>not</B> be manipulated
|
|
|
|
* directly. Content nodes in document fragments that are not part of the
|
|
|
|
* document itself may be manipulated at will. Operations on document
|
|
|
|
* fragments must <B>not</B> go through the editor.
|
|
|
|
* 2. Selection must not be explicitly set by the rule method.
|
|
|
|
* Any manipulation of Selection must be done by the editor.
|
|
|
|
*/
|
|
|
|
class TextEditRules : public nsIEditRules
|
|
|
|
, public nsITimerCallback
|
2017-07-26 21:18:20 +03:00
|
|
|
, public nsINamed
|
1999-03-10 22:53:26 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-07-09 05:34:41 +03:00
|
|
|
typedef dom::Element Element;
|
|
|
|
typedef dom::Selection Selection;
|
|
|
|
typedef dom::Text Text;
|
|
|
|
template<typename T> using OwningNonNull = OwningNonNull<T>;
|
2016-05-01 16:15:14 +03:00
|
|
|
|
2009-11-02 18:37:25 +03:00
|
|
|
NS_DECL_NSITIMERCALLBACK
|
2009-05-09 08:59:25 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2016-07-09 05:34:41 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(TextEditRules, nsIEditRules)
|
2014-06-24 02:40:02 +04:00
|
|
|
|
2016-07-09 05:34:41 +03:00
|
|
|
TextEditRules();
|
1999-03-10 22:53:26 +03:00
|
|
|
|
2000-03-24 03:26:47 +03:00
|
|
|
// nsIEditRules methods
|
2016-07-09 05:54:50 +03:00
|
|
|
NS_IMETHOD Init(TextEditor* aTextEditor) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetInitialValue(const nsAString& aValue) override;
|
|
|
|
NS_IMETHOD DetachEditor() override;
|
2012-08-12 22:28:26 +04:00
|
|
|
NS_IMETHOD BeforeEdit(EditAction action,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIEditor::EDirection aDirection) override;
|
2012-08-12 22:28:26 +04:00
|
|
|
NS_IMETHOD AfterEdit(EditAction action,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIEditor::EDirection aDirection) override;
|
2016-07-07 13:33:32 +03:00
|
|
|
NS_IMETHOD WillDoAction(Selection* aSelection, RulesInfo* aInfo,
|
2016-05-01 16:15:14 +03:00
|
|
|
bool* aCancel, bool* aHandled) override;
|
2016-07-07 13:33:32 +03:00
|
|
|
NS_IMETHOD DidDoAction(Selection* aSelection, RulesInfo* aInfo,
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult aResult) override;
|
2017-05-11 08:03:26 +03:00
|
|
|
NS_IMETHOD_(bool) DocumentIsEmpty() override;
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD DocumentModified() override;
|
1999-04-05 21:21:59 +04:00
|
|
|
|
2017-07-26 21:18:20 +03:00
|
|
|
// nsINamed methods
|
|
|
|
NS_DECL_NSINAMED
|
|
|
|
|
2014-06-24 02:40:02 +04:00
|
|
|
protected:
|
2016-07-09 05:34:41 +03:00
|
|
|
virtual ~TextEditRules();
|
2014-06-24 02:40:02 +04:00
|
|
|
|
2001-06-06 05:21:05 +04:00
|
|
|
public:
|
2012-06-01 15:03:17 +04:00
|
|
|
void ResetIMETextPWBuf();
|
2001-06-06 05:21:05 +04:00
|
|
|
|
2010-02-01 21:12:31 +03:00
|
|
|
/**
|
|
|
|
* Handles the newline characters either according to aNewLineHandling
|
|
|
|
* or to the default system prefs if aNewLineHandling is negative.
|
|
|
|
*
|
|
|
|
* @param aString the string to be modified in place.
|
|
|
|
* @param aNewLineHandling determine the desired type of newline handling:
|
|
|
|
* * negative values:
|
|
|
|
* handle newlines according to platform defaults.
|
|
|
|
* * nsIPlaintextEditor::eNewlinesReplaceWithSpaces:
|
|
|
|
* replace newlines with spaces.
|
|
|
|
* * nsIPlaintextEditor::eNewlinesStrip:
|
|
|
|
* remove newlines from the string.
|
|
|
|
* * nsIPlaintextEditor::eNewlinesReplaceWithCommas:
|
|
|
|
* replace newlines with commas.
|
|
|
|
* * nsIPlaintextEditor::eNewlinesStripSurroundingWhitespace:
|
|
|
|
* collapse newlines and surrounding whitespace characters and
|
|
|
|
* remove them from the string.
|
|
|
|
* * nsIPlaintextEditor::eNewlinesPasteIntact:
|
|
|
|
* only remove the leading and trailing newlines.
|
|
|
|
* * nsIPlaintextEditor::eNewlinesPasteToFirst or any other value:
|
|
|
|
* remove the first newline and all characters following it.
|
|
|
|
*/
|
2016-07-09 05:34:41 +03:00
|
|
|
static void HandleNewLines(nsString& aString, int32_t aNewLineHandling);
|
2010-02-01 21:12:31 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare a string buffer for being displayed as the contents of a password
|
|
|
|
* field. This function uses the platform-specific character for representing
|
|
|
|
* characters entered into password fields.
|
|
|
|
*
|
|
|
|
* @param aOutString the output string. When this function returns,
|
|
|
|
* aOutString will contain aLength password characters.
|
|
|
|
* @param aLength the number of password characters that aOutString should
|
|
|
|
* contain.
|
|
|
|
*/
|
2016-07-09 05:34:41 +03:00
|
|
|
static void FillBufWithPWChars(nsAString* aOutString, int32_t aLength);
|
2010-02-01 21:12:31 +03:00
|
|
|
|
2017-08-24 13:53:34 +03:00
|
|
|
bool HasBogusNode()
|
|
|
|
{
|
|
|
|
return !!mBogusNode;
|
|
|
|
}
|
|
|
|
|
1999-04-05 21:21:59 +04:00
|
|
|
protected:
|
1999-03-10 22:53:26 +03:00
|
|
|
|
2014-05-10 01:02:29 +04:00
|
|
|
void InitFields();
|
|
|
|
|
2016-07-09 05:34:41 +03:00
|
|
|
// TextEditRules implementation methods
|
|
|
|
nsresult WillInsertText(EditAction aAction,
|
|
|
|
Selection* aSelection,
|
|
|
|
bool* aCancel,
|
|
|
|
bool* aHandled,
|
|
|
|
const nsAString* inString,
|
|
|
|
nsAString* outString,
|
|
|
|
int32_t aMaxLength);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult DidInsertText(Selection* aSelection, nsresult aResult);
|
1999-03-13 07:53:21 +03:00
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult WillInsertBreak(Selection* aSelection, bool* aCancel,
|
2016-07-09 05:34:41 +03:00
|
|
|
bool* aHandled, int32_t aMaxLength);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult DidInsertBreak(Selection* aSelection, nsresult aResult);
|
Preparation for ender-based text control
* added focus listener. Doesn't do much yet, but when focus notifications start appearing, we'll be ready for them. The code is in
place to hide selection when we lose focus and paint selection when we get focus. That's probably not quite right, but it's a start.
We will need to be able to determine the distinction between losing focus to another control within our app, and losing focus to
another app.
* added support for disabled and readonly states in the editor. This is accomplished by having flags set by the client, and letting the
rules system deal with those flags. The flags I added are:
TEXT_EDITOR_FLAG_PLAINTEXT 0x01 // only plain text editing is allowed
TEXT_EDITOR_FLAG_SINGLELINE 0x02 // enter key and CR-LF handled specially
TEXT_EDITOR_FLAG_PASSWORD 0x04 // text is not entered into content, only a representative character
TEXT_EDITOR_FLAG_READONLY 0x08 // editing events are disabled. Editor may still accept focus.
TEXT_EDITOR_FLAG_DISALBED 0x10 // all events are disabled (like scrolling). Editor will not accept focus.
* added WillInsertBreak/DidInsertBreak into text rules, so flags could be checked. This gets us readonly, disabled, and single line
behavior.
* cleaned up the code that allocates, registers, and destroys event listeners. Thanks to Kin and Simon for cleaning up the
ownership model on the listeners, it was a big help.
* added support for a max text length. You can now tell the text editor, be no bigger than n characters.
1999-05-29 01:24:18 +04:00
|
|
|
|
2017-05-25 08:30:50 +03:00
|
|
|
nsresult WillSetText(Selection& aSelection,
|
|
|
|
bool* aCancel,
|
|
|
|
bool* aHandled,
|
|
|
|
const nsAString* inString,
|
|
|
|
int32_t aMaxLength);
|
|
|
|
nsresult DidSetText(Selection& aSelection, nsresult aResult);
|
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
void WillInsert(Selection& aSelection, bool* aCancel);
|
|
|
|
nsresult DidInsert(Selection* aSelection, nsresult aResult);
|
1999-03-13 07:53:21 +03:00
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult WillDeleteSelection(Selection* aSelection,
|
2015-05-28 18:58:42 +03:00
|
|
|
nsIEditor::EDirection aCollapsedAction,
|
2016-07-09 05:34:41 +03:00
|
|
|
bool* aCancel,
|
|
|
|
bool* aHandled);
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult DidDeleteSelection(Selection* aSelection,
|
2015-05-28 18:58:42 +03:00
|
|
|
nsIEditor::EDirection aCollapsedAction,
|
1999-06-25 03:36:56 +04:00
|
|
|
nsresult aResult);
|
1999-03-12 05:28:24 +03:00
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult WillSetTextProperty(Selection* aSelection, bool* aCancel,
|
|
|
|
bool* aHandled);
|
|
|
|
nsresult DidSetTextProperty(Selection* aSelection, nsresult aResult);
|
1999-06-08 10:04:51 +04:00
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult WillRemoveTextProperty(Selection* aSelection, bool* aCancel,
|
|
|
|
bool* aHandled);
|
|
|
|
nsresult DidRemoveTextProperty(Selection* aSelection, nsresult aResult);
|
1999-06-08 10:04:51 +04:00
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult WillUndo(Selection* aSelection, bool* aCancel, bool* aHandled);
|
|
|
|
nsresult DidUndo(Selection* aSelection, nsresult aResult);
|
1999-03-15 08:08:30 +03:00
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult WillRedo(Selection* aSelection, bool* aCancel, bool* aHandled);
|
|
|
|
nsresult DidRedo(Selection* aSelection, nsresult aResult);
|
1999-03-15 08:08:30 +03:00
|
|
|
|
2016-07-09 05:34:41 +03:00
|
|
|
/**
|
|
|
|
* Called prior to nsIEditor::OutputToString.
|
|
|
|
* @param aSelection
|
|
|
|
* @param aInFormat The format requested for the output, a MIME type.
|
|
|
|
* @param aOutText The string to use for output, if aCancel is set to true.
|
|
|
|
* @param aOutCancel If set to true, the caller should cancel the operation
|
|
|
|
* and use aOutText as the result.
|
|
|
|
*/
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult WillOutputText(Selection* aSelection,
|
2016-07-09 05:34:41 +03:00
|
|
|
const nsAString* aInFormat,
|
|
|
|
nsAString* aOutText,
|
2017-06-16 13:08:10 +03:00
|
|
|
uint32_t aFlags,
|
2016-07-09 05:34:41 +03:00
|
|
|
bool* aOutCancel,
|
|
|
|
bool* aHandled);
|
1999-09-09 23:39:36 +04:00
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult DidOutputText(Selection* aSelection, nsresult aResult);
|
1999-06-25 03:36:56 +04:00
|
|
|
|
2016-07-09 05:34:41 +03:00
|
|
|
/**
|
|
|
|
* Check for and replace a redundant trailing break.
|
|
|
|
*/
|
2011-08-12 23:53:10 +04:00
|
|
|
nsresult RemoveRedundantTrailingBR();
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-07-09 05:34:41 +03:00
|
|
|
/**
|
|
|
|
* Creates a trailing break in the text doc if there is not one already.
|
|
|
|
*/
|
2005-03-24 22:00:01 +03:00
|
|
|
nsresult CreateTrailingBRIfNeeded();
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-07-09 05:34:41 +03:00
|
|
|
/**
|
|
|
|
* Creates a bogus text node if the document has no editable content.
|
|
|
|
*/
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult CreateBogusNodeIfNeeded(Selection* aSelection);
|
1999-06-25 03:36:56 +04:00
|
|
|
|
2016-07-09 05:34:41 +03:00
|
|
|
/**
|
|
|
|
* Returns a truncated insertion string if insertion would place us over
|
|
|
|
* aMaxLength
|
|
|
|
*/
|
|
|
|
nsresult TruncateInsertionIfNeeded(Selection* aSelection,
|
|
|
|
const nsAString* aInString,
|
|
|
|
nsAString* aOutString,
|
|
|
|
int32_t aMaxLength,
|
|
|
|
bool* aTruncated);
|
1999-08-24 12:56:51 +04:00
|
|
|
|
2016-07-09 05:34:41 +03:00
|
|
|
/**
|
|
|
|
* Remove IME composition text from password buffer.
|
|
|
|
*/
|
2017-03-09 22:44:45 +03:00
|
|
|
void RemoveIMETextFromPWBuf(uint32_t& aStart, nsAString* aIMEString);
|
2001-06-06 05:21:05 +04:00
|
|
|
|
2017-08-01 16:38:50 +03:00
|
|
|
/**
|
|
|
|
* Create a normal <br> element and insert it to aOffset at aParent.
|
|
|
|
*
|
|
|
|
* @param aParent The parent node which will have new <br> element.
|
|
|
|
* @param aOffset The offset in aParent where the new <br> element will
|
|
|
|
* be inserted.
|
|
|
|
* @param aOutBRNode Returns created <br> element.
|
|
|
|
*/
|
|
|
|
nsresult CreateBR(nsIDOMNode* aParent, int32_t aOffset,
|
|
|
|
nsIDOMNode** aOutBRNode = nullptr)
|
|
|
|
{
|
|
|
|
return CreateBRInternal(aParent, aOffset, false, aOutBRNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a moz-<br> element and insert it to aOffset at aParent.
|
|
|
|
*
|
|
|
|
* @param aParent The parent node which will have new <br> element.
|
|
|
|
* @param aOffset The offset in aParent where the new <br> element will
|
|
|
|
* be inserted.
|
|
|
|
* @param aOutBRNode Returns created <br> element.
|
|
|
|
*/
|
|
|
|
nsresult CreateMozBR(nsIDOMNode* aParent, int32_t aOffset,
|
|
|
|
nsIDOMNode** aOutBRNode = nullptr)
|
|
|
|
{
|
|
|
|
return CreateBRInternal(aParent, aOffset, true, aOutBRNode);
|
|
|
|
}
|
1999-11-29 11:28:46 +03:00
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
void UndefineCaretBidiLevel(Selection* aSelection);
|
2015-06-01 22:19:57 +03:00
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult CheckBidiLevelForDeletion(Selection* aSelection,
|
2016-07-09 05:34:41 +03:00
|
|
|
nsIDOMNode* aSelNode,
|
|
|
|
int32_t aSelOffset,
|
2001-05-22 03:57:55 +04:00
|
|
|
nsIEditor::EDirection aAction,
|
2016-07-09 05:34:41 +03:00
|
|
|
bool* aCancel);
|
2001-05-22 03:57:55 +04:00
|
|
|
|
2009-11-02 18:37:25 +03:00
|
|
|
nsresult HideLastPWInput();
|
|
|
|
|
2016-05-01 16:15:14 +03:00
|
|
|
nsresult CollapseSelectionToTrailingBRIfNeeded(Selection* aSelection);
|
2010-09-02 02:06:52 +04:00
|
|
|
|
2016-07-09 05:34:41 +03:00
|
|
|
bool IsPasswordEditor() const;
|
|
|
|
bool IsSingleLineEditor() const;
|
|
|
|
bool IsPlaintextEditor() const;
|
|
|
|
bool IsReadonly() const;
|
|
|
|
bool IsDisabled() const;
|
|
|
|
bool IsMailEditor() const;
|
|
|
|
bool DontEchoPassword() const;
|
|
|
|
|
2017-02-08 12:32:32 +03:00
|
|
|
private:
|
2016-07-09 05:34:41 +03:00
|
|
|
// Note that we do not refcount the editor.
|
2016-07-09 05:54:50 +03:00
|
|
|
TextEditor* mTextEditor;
|
2017-02-08 12:32:32 +03:00
|
|
|
|
2017-08-01 16:38:50 +03:00
|
|
|
/**
|
|
|
|
* Create a normal <br> element or a moz-<br> element and insert it to
|
|
|
|
* aOffset at aParent.
|
|
|
|
*
|
|
|
|
* @param aParent The parent node which will have new <br> element.
|
|
|
|
* @param aOffset The offset in aParent where the new <br> element will
|
|
|
|
* be inserted.
|
|
|
|
* @param aMozBR true if the caller wants to create a moz-<br> element.
|
|
|
|
* Otherwise, false.
|
|
|
|
* @param aOutBRNode Returns created <br> element.
|
|
|
|
*/
|
|
|
|
nsresult CreateBRInternal(nsIDOMNode* aParent,
|
|
|
|
int32_t aOffset,
|
|
|
|
bool aMozBR,
|
|
|
|
nsIDOMNode** aOutBRNode = nullptr);
|
|
|
|
|
|
|
|
|
2017-02-08 12:32:32 +03:00
|
|
|
protected:
|
2016-07-09 05:34:41 +03:00
|
|
|
// A buffer we use to store the real value of password editors.
|
|
|
|
nsString mPasswordText;
|
|
|
|
// A buffer we use to track the IME composition string.
|
|
|
|
nsString mPasswordIMEText;
|
|
|
|
uint32_t mPasswordIMEIndex;
|
|
|
|
// Magic node acts as placeholder in empty doc.
|
2017-04-24 13:40:12 +03:00
|
|
|
nsCOMPtr<nsIContent> mBogusNode;
|
2016-07-09 05:34:41 +03:00
|
|
|
// Cached selected node.
|
2017-04-24 13:40:12 +03:00
|
|
|
nsCOMPtr<nsINode> mCachedSelectionNode;
|
2016-07-09 05:34:41 +03:00
|
|
|
// Cached selected offset.
|
|
|
|
int32_t mCachedSelectionOffset;
|
|
|
|
uint32_t mActionNesting;
|
|
|
|
bool mLockRulesSniffing;
|
|
|
|
bool mDidExplicitlySetInterline;
|
|
|
|
// In bidirectional text, delete characters not visually adjacent to the
|
|
|
|
// caret without moving the caret first.
|
|
|
|
bool mDeleteBidiImmediately;
|
|
|
|
// The top level editor action.
|
|
|
|
EditAction mTheAction;
|
|
|
|
nsCOMPtr<nsITimer> mTimer;
|
|
|
|
uint32_t mLastStart;
|
|
|
|
uint32_t mLastLength;
|
2009-11-02 18:37:25 +03:00
|
|
|
|
1999-12-07 11:30:19 +03:00
|
|
|
// friends
|
2016-06-24 15:19:18 +03:00
|
|
|
friend class AutoLockRulesSniffing;
|
1999-03-10 22:53:26 +03:00
|
|
|
};
|
|
|
|
|
2017-06-16 13:08:10 +03:00
|
|
|
// TODO: This class (almost struct, though) is ugly and its size isn't
|
|
|
|
// optimized. Should be refined later.
|
2016-07-07 13:33:32 +03:00
|
|
|
class TextRulesInfo final : public RulesInfo
|
1999-04-12 16:01:32 +04:00
|
|
|
{
|
2016-06-24 15:12:16 +03:00
|
|
|
public:
|
|
|
|
explicit TextRulesInfo(EditAction aAction)
|
2016-07-07 13:33:32 +03:00
|
|
|
: RulesInfo(aAction)
|
2016-06-24 15:12:16 +03:00
|
|
|
, inString(nullptr)
|
|
|
|
, outString(nullptr)
|
|
|
|
, outputFormat(nullptr)
|
|
|
|
, maxLength(-1)
|
2017-06-16 13:08:10 +03:00
|
|
|
, flags(0)
|
2016-06-24 15:12:16 +03:00
|
|
|
, collapsedAction(nsIEditor::eNext)
|
|
|
|
, stripWrappers(nsIEditor::eStrip)
|
|
|
|
, bOrdered(false)
|
|
|
|
, entireList(false)
|
|
|
|
, bulletType(nullptr)
|
|
|
|
, alignType(nullptr)
|
|
|
|
, blockType(nullptr)
|
|
|
|
{}
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2017-01-04 12:51:44 +03:00
|
|
|
// EditAction::insertText / EditAction::insertIMEText
|
2016-06-24 15:12:16 +03:00
|
|
|
const nsAString* inString;
|
|
|
|
nsAString* outString;
|
|
|
|
const nsAString* outputFormat;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t maxLength;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2017-06-16 13:08:10 +03:00
|
|
|
// EditAction::outputText
|
|
|
|
uint32_t flags;
|
|
|
|
|
2017-01-04 12:51:44 +03:00
|
|
|
// EditAction::deleteSelection
|
1999-12-07 11:30:19 +03:00
|
|
|
nsIEditor::EDirection collapsedAction;
|
2012-05-10 18:54:33 +04:00
|
|
|
nsIEditor::EStripWrappers stripWrappers;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2017-01-04 12:51:44 +03:00
|
|
|
// EditAction::removeList
|
2011-09-29 10:19:26 +04:00
|
|
|
bool bOrdered;
|
2017-01-04 12:51:44 +03:00
|
|
|
|
|
|
|
// EditAction::makeList
|
2011-09-29 10:19:26 +04:00
|
|
|
bool entireList;
|
2016-06-24 15:12:16 +03:00
|
|
|
const nsAString* bulletType;
|
2000-09-14 09:59:19 +04:00
|
|
|
|
2017-01-04 12:51:44 +03:00
|
|
|
// EditAction::align
|
2016-06-24 15:12:16 +03:00
|
|
|
const nsAString* alignType;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2017-01-04 12:51:44 +03:00
|
|
|
// EditAction::makeBasicBlock
|
2016-06-24 15:12:16 +03:00
|
|
|
const nsAString* blockType;
|
1999-04-12 16:01:32 +04:00
|
|
|
};
|
|
|
|
|
2016-06-24 15:19:18 +03:00
|
|
|
/**
|
|
|
|
* Stack based helper class for StartOperation()/EndOperation() sandwich.
|
|
|
|
* This class sets a bool letting us know to ignore any rules sniffing
|
2015-05-28 18:58:42 +03:00
|
|
|
* that tries to occur reentrantly.
|
1999-12-07 11:30:19 +03:00
|
|
|
*/
|
2016-06-24 15:19:18 +03:00
|
|
|
class MOZ_STACK_CLASS AutoLockRulesSniffing final
|
1999-12-07 11:30:19 +03:00
|
|
|
{
|
2016-06-24 15:19:18 +03:00
|
|
|
public:
|
|
|
|
explicit AutoLockRulesSniffing(TextEditRules* aRules)
|
|
|
|
: mRules(aRules)
|
|
|
|
{
|
|
|
|
if (mRules) {
|
|
|
|
mRules->mLockRulesSniffing = true;
|
|
|
|
}
|
|
|
|
}
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-06-24 15:19:18 +03:00
|
|
|
~AutoLockRulesSniffing()
|
|
|
|
{
|
|
|
|
if (mRules) {
|
|
|
|
mRules->mLockRulesSniffing = false;
|
|
|
|
}
|
|
|
|
}
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-06-24 15:19:18 +03:00
|
|
|
protected:
|
|
|
|
TextEditRules* mRules;
|
1999-12-07 11:30:19 +03:00
|
|
|
};
|
|
|
|
|
2016-06-24 15:22:26 +03:00
|
|
|
/**
|
|
|
|
* Stack based helper class for turning on/off the edit listener.
|
2000-03-24 03:26:47 +03:00
|
|
|
*/
|
2016-06-24 15:22:26 +03:00
|
|
|
class MOZ_STACK_CLASS AutoLockListener final
|
2000-03-24 03:26:47 +03:00
|
|
|
{
|
2016-01-12 21:16:59 +03:00
|
|
|
public:
|
2016-06-24 15:22:26 +03:00
|
|
|
explicit AutoLockListener(bool* aEnabled)
|
|
|
|
: mEnabled(aEnabled)
|
|
|
|
, mOldState(false)
|
2016-01-12 21:16:59 +03:00
|
|
|
{
|
|
|
|
if (mEnabled) {
|
|
|
|
mOldState = *mEnabled;
|
|
|
|
*mEnabled = false;
|
|
|
|
}
|
|
|
|
}
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-06-24 15:22:26 +03:00
|
|
|
~AutoLockListener()
|
2016-01-12 21:16:59 +03:00
|
|
|
{
|
|
|
|
if (mEnabled) {
|
|
|
|
*mEnabled = mOldState;
|
|
|
|
}
|
|
|
|
}
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2016-01-12 21:16:59 +03:00
|
|
|
protected:
|
2016-06-24 15:22:26 +03:00
|
|
|
bool* mEnabled;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mOldState;
|
2000-03-24 03:26:47 +03:00
|
|
|
};
|
|
|
|
|
2016-06-24 15:22:26 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2016-07-09 05:34:41 +03:00
|
|
|
#endif // #ifndef mozilla_TextEditRules_h
|