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/. */
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2016-07-09 05:54:50 +03:00
|
|
|
#ifndef mozilla_TextEditor_h
|
|
|
|
#define mozilla_TextEditor_h
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
#include "mozilla/EditorBase.h"
|
2001-01-28 23:13:07 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2019-07-22 06:53:36 +03:00
|
|
|
#include "nsINamed.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsISupportsImpl.h"
|
2019-07-22 06:53:36 +03:00
|
|
|
#include "nsITimer.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nscore.h"
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsIContent;
|
2001-01-28 23:13:07 +03:00
|
|
|
class nsIDocumentEncoder;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsIOutputStream;
|
2019-06-10 13:27:07 +03:00
|
|
|
class nsIPrincipal;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsISelectionController;
|
|
|
|
class nsITransferable;
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2014-11-02 15:04:13 +03:00
|
|
|
namespace mozilla {
|
2019-07-22 06:53:36 +03:00
|
|
|
class DeleteNodeTransaction;
|
|
|
|
class InsertNodeTransaction;
|
Bug 1463985 - part 1: Rename EditAction to EditSubAction and related stuff r=m_kato
When we implement InputEvent.inputType, we need to set a stack class to record
which edit action is currently handled. However, currently, we call smaller
jobs as edit action. For example, when user types a character at selecting
some characters, then, EditAction::deleteSelection is performed first, then,
EditAction::insertText is performed. However, for the InputEvent.inputType,
we need inserText information. So, for making new enum EditAction, we need
to rename current EditAction to EditSubAction.
And also this renames related stuff:
EditorBase::mIsInEditAction -> EditorBase::mIsInEditSubAction
EditorBase::IsInEditAction() -> EditorBase::IsInEditSubAction()
EditorBase::mAction -> EditorBase::mTopLevelEditSubAction
TextEditRules::mTheAction -> TextEditRules::mTopLevelEditSubAction
EditorBase::StartOperation() ->
EditorBase::OnStartToHandleTopLevelEditSubAction()
EditorBase::EndOperation() ->
EditorBase::OnEndHandlingTopLevelEditSubAction()
AutoRules -> AutoTopLevelEditSubActionNotifier
RulesInfo -> EditSubActionInfo
MozReview-Commit-ID: cvSkPUjFm1
--HG--
extra : rebase_source : baf527a3e353b7a8ebe9a46be2243b059c500234
2018-05-28 14:12:34 +03:00
|
|
|
enum class EditSubAction : int32_t;
|
2018-01-12 13:01:04 +03:00
|
|
|
|
2014-11-02 15:04:13 +03:00
|
|
|
namespace dom {
|
2018-03-13 23:24:00 +03:00
|
|
|
class DragEvent;
|
2014-11-02 15:04:13 +03:00
|
|
|
class Selection;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2014-11-02 15:04:13 +03:00
|
|
|
|
2001-01-28 23:13:07 +03:00
|
|
|
/**
|
|
|
|
* The text editor implementation.
|
2015-05-28 18:58:42 +03:00
|
|
|
* Use to edit text document represented as a DOM tree.
|
2001-01-28 23:13:07 +03:00
|
|
|
*/
|
2020-01-24 11:33:42 +03:00
|
|
|
class TextEditor : public EditorBase, public nsITimerCallback, public nsINamed {
|
2001-01-28 23:13:07 +03:00
|
|
|
public:
|
2018-05-22 14:15:05 +03:00
|
|
|
/****************************************************************************
|
|
|
|
* NOTE: DO NOT MAKE YOUR NEW METHODS PUBLIC IF they are called by other
|
|
|
|
* classes under libeditor except EditorEventListener and
|
|
|
|
* HTMLEditorEventListener because each public method which may fire
|
|
|
|
* eEditorInput event will need to instantiate new stack class for
|
|
|
|
* managing input type value of eEditorInput and cache some objects
|
|
|
|
* for smarter handling. In other words, when you add new root
|
|
|
|
* method to edit the DOM tree, you can make your new method public.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2001-01-28 23:13:07 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2016-07-08 07:10:13 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextEditor, EditorBase)
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2016-07-09 05:54:50 +03:00
|
|
|
TextEditor();
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2019-07-22 06:53:36 +03:00
|
|
|
NS_DECL_NSITIMERCALLBACK
|
|
|
|
NS_DECL_NSINAMED
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2018-04-11 11:37:49 +03:00
|
|
|
// Overrides of nsIEditor
|
2016-07-09 05:54:50 +03:00
|
|
|
NS_IMETHOD GetDocumentIsEmpty(bool* aDocumentIsEmpty) override;
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2020-03-22 13:46:39 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT NS_IMETHOD
|
|
|
|
SetDocumentCharacterSet(const nsACString& characterSet) override;
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2020-01-24 11:33:42 +03:00
|
|
|
NS_IMETHOD GetTextLength(int32_t* aCount) override;
|
|
|
|
|
2019-06-10 13:27:07 +03:00
|
|
|
/**
|
|
|
|
* Do "undo" or "redo".
|
|
|
|
*
|
|
|
|
* @param aCount How many count of transactions should be
|
|
|
|
* handled.
|
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult UndoAsAction(uint32_t aCount,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult RedoAsAction(uint32_t aCount,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do "cut".
|
|
|
|
*
|
|
|
|
* @param aPrincipal If you know current context is subject
|
|
|
|
* principal or system principal, set it.
|
|
|
|
* When nullptr, this checks it automatically.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult CutAsAction(nsIPrincipal* aPrincipal = nullptr);
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2019-07-29 09:21:14 +03:00
|
|
|
/**
|
2019-07-29 09:21:42 +03:00
|
|
|
* IsCutCommandEnabled() returns whether cut command can be enabled or
|
|
|
|
* disabled. This always returns true if we're in non-chrome HTML/XHTML
|
|
|
|
* document. Otherwise, same as the result of `IsCopyToClipboardAllowed()`.
|
2019-07-29 09:21:14 +03:00
|
|
|
*/
|
2019-07-29 09:21:42 +03:00
|
|
|
bool IsCutCommandEnabled() const;
|
2019-07-29 09:21:14 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Copy() override;
|
2019-07-29 09:21:14 +03:00
|
|
|
|
|
|
|
/**
|
2019-07-29 09:21:42 +03:00
|
|
|
* IsCopyCommandEnabled() returns copy command can be enabled or disabled.
|
|
|
|
* This always returns true if we're in non-chrome HTML/XHTML document.
|
|
|
|
* Otherwise, same as the result of `IsCopyToClipboardAllowed()`.
|
|
|
|
*/
|
|
|
|
bool IsCopyCommandEnabled() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IsCopyToClipboardAllowed() returns true if the selected content can
|
|
|
|
* be copied into the clipboard. This returns true when:
|
2019-07-29 09:21:14 +03:00
|
|
|
* - `Selection` is not collapsed and we're not a password editor.
|
|
|
|
* - `Selection` is not collapsed and we're a password editor but selection
|
2019-07-29 09:21:42 +03:00
|
|
|
* range is in unmasked range.
|
2019-07-29 09:21:14 +03:00
|
|
|
*/
|
2019-07-29 09:21:42 +03:00
|
|
|
bool IsCopyToClipboardAllowed() const {
|
|
|
|
AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
|
|
|
|
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return IsCopyToClipboardAllowedInternal();
|
|
|
|
}
|
2019-07-29 09:21:14 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CanDeleteSelection() returns true if `Selection` is not collapsed and
|
|
|
|
* it's allowed to be removed.
|
|
|
|
*/
|
|
|
|
bool CanDeleteSelection() const;
|
|
|
|
|
2019-04-25 10:14:39 +03:00
|
|
|
virtual bool CanPaste(int32_t aClipboardType) const;
|
|
|
|
|
|
|
|
// Shouldn't be used internally, but we need these using declarations for
|
|
|
|
// avoiding warnings of clang.
|
|
|
|
using EditorBase::CanCopy;
|
|
|
|
using EditorBase::CanCut;
|
|
|
|
using EditorBase::CanPaste;
|
|
|
|
|
2019-06-10 13:27:07 +03:00
|
|
|
/**
|
|
|
|
* Paste aTransferable at Selection.
|
|
|
|
*
|
|
|
|
* @param aTransferable Must not be nullptr.
|
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT virtual nsresult PasteTransferableAsAction(
|
|
|
|
nsITransferable* aTransferable, nsIPrincipal* aPrincipal = nullptr);
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2002-03-26 01:39:19 +03:00
|
|
|
NS_IMETHOD OutputToString(const nsAString& aFormatType, uint32_t aFlags,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAString& aOutputString) override;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2018-05-22 12:23:21 +03:00
|
|
|
/** Can we paste |aTransferable| or, if |aTransferable| is null, will a call
|
|
|
|
* to pasteTransferable later possibly succeed if given an instance of
|
|
|
|
* nsITransferable then? True if the doc is modifiable, and, if
|
|
|
|
* |aTransfeable| is non-null, we have pasteable data in |aTransfeable|.
|
|
|
|
*/
|
|
|
|
virtual bool CanPasteTransferable(nsITransferable* aTransferable);
|
|
|
|
|
2018-04-11 11:37:49 +03:00
|
|
|
// Overrides of EditorBase
|
2020-03-22 13:46:39 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT virtual nsresult Init(Document& aDoc, Element* aRoot,
|
|
|
|
nsISelectionController* aSelCon,
|
|
|
|
uint32_t aFlags,
|
|
|
|
const nsAString& aValue) override;
|
2018-04-11 11:37:49 +03:00
|
|
|
|
2018-07-18 11:44:14 +03:00
|
|
|
/**
|
2019-08-02 08:44:40 +03:00
|
|
|
* IsEmpty() checks whether the editor is empty. If editor has only padding
|
|
|
|
* <br> element for empty editor, returns true. If editor's root element has
|
|
|
|
* non-empty text nodes or other nodes like <br>, returns false.
|
2018-07-18 11:44:14 +03:00
|
|
|
*/
|
2019-09-17 09:58:06 +03:00
|
|
|
virtual bool IsEmpty() const;
|
2018-04-11 11:37:49 +03:00
|
|
|
|
2020-03-22 13:46:39 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT virtual nsresult HandleKeyPressEvent(
|
2017-02-08 14:18:17 +03:00
|
|
|
WidgetKeyboardEvent* aKeyboardEvent) override;
|
2010-06-10 05:16:58 +04:00
|
|
|
|
2020-04-13 04:43:41 +03:00
|
|
|
virtual dom::EventTarget* GetDOMEventTarget() const override;
|
2010-06-17 09:30:10 +04:00
|
|
|
|
2018-08-13 07:37:56 +03:00
|
|
|
/**
|
|
|
|
* PasteAsAction() pastes clipboard content to Selection. This method
|
|
|
|
* may dispatch ePaste event first. If its defaultPrevent() is called,
|
|
|
|
* this does nothing but returns NS_OK.
|
|
|
|
*
|
|
|
|
* @param aClipboardType nsIClipboard::kGlobalClipboard or
|
|
|
|
* nsIClipboard::kSelectionClipboard.
|
2018-10-10 15:05:39 +03:00
|
|
|
* @param aDispatchPasteEvent true if this should dispatch ePaste event
|
|
|
|
* before pasting. Otherwise, false.
|
2019-06-10 13:27:07 +03:00
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
2018-08-13 07:37:56 +03:00
|
|
|
*/
|
2019-06-10 13:27:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult PasteAsAction(int32_t aClipboardType,
|
|
|
|
bool aDispatchPasteEvent,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
2018-08-13 07:37:56 +03:00
|
|
|
|
2018-07-23 10:34:03 +03:00
|
|
|
/**
|
|
|
|
* PasteAsQuotationAsAction() pastes content in clipboard as quotation.
|
|
|
|
* If the editor is TextEditor or in plaintext mode, will paste the content
|
|
|
|
* with appending ">" to start of each line.
|
|
|
|
*
|
|
|
|
* @param aClipboardType nsIClipboard::kGlobalClipboard or
|
|
|
|
* nsIClipboard::kSelectionClipboard.
|
2018-10-10 15:05:39 +03:00
|
|
|
* @param aDispatchPasteEvent true if this should dispatch ePaste event
|
|
|
|
* before pasting. Otherwise, false.
|
2019-06-10 13:27:07 +03:00
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
2018-07-23 10:34:03 +03:00
|
|
|
*/
|
2019-06-10 13:27:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT virtual nsresult PasteAsQuotationAsAction(
|
|
|
|
int32_t aClipboardType, bool aDispatchPasteEvent,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
2018-07-23 10:34:03 +03:00
|
|
|
|
2018-02-21 07:21:57 +03:00
|
|
|
/**
|
|
|
|
* The maximum number of characters allowed.
|
|
|
|
* default: -1 (unlimited).
|
|
|
|
*/
|
2017-06-20 16:57:08 +03:00
|
|
|
int32_t MaxTextLength() const { return mMaxTextLength; }
|
2018-02-21 07:21:57 +03:00
|
|
|
void SetMaxTextLength(int32_t aLength) { mMaxTextLength = aLength; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Replace existed string with a string.
|
|
|
|
* This is fast path to replace all string when using single line control.
|
|
|
|
*
|
2019-06-10 13:27:07 +03:00
|
|
|
* @param aString The string to be set
|
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
2018-02-21 07:21:57 +03:00
|
|
|
*/
|
2019-06-10 13:27:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
SetTextAsAction(const nsAString& aString, nsIPrincipal* aPrincipal = nullptr);
|
2017-06-20 16:57:08 +03:00
|
|
|
|
2018-07-03 16:25:52 +03:00
|
|
|
/**
|
2018-07-04 16:51:55 +03:00
|
|
|
* Replace text in aReplaceRange or all text in this editor with aString and
|
|
|
|
* treat the change as inserting the string.
|
2018-07-03 16:25:52 +03:00
|
|
|
*
|
2018-07-04 16:51:55 +03:00
|
|
|
* @param aString The string to set.
|
|
|
|
* @param aReplaceRange The range to be replaced.
|
|
|
|
* If nullptr, all contents will be replaced.
|
2019-06-10 13:27:07 +03:00
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
2018-07-03 16:25:52 +03:00
|
|
|
*/
|
2019-06-10 13:27:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
ReplaceTextAsAction(const nsAString& aString, nsRange* aReplaceRange,
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
2018-07-03 16:25:52 +03:00
|
|
|
|
2018-11-03 14:22:13 +03:00
|
|
|
/**
|
|
|
|
* InsertLineBreakAsAction() is called when user inputs a line break with
|
|
|
|
* Enter or something.
|
2019-06-10 13:27:07 +03:00
|
|
|
*
|
|
|
|
* @param aPrincipal Set subject principal if it may be called by
|
|
|
|
* JS. If set to nullptr, will be treated as
|
|
|
|
* called by system.
|
2018-11-03 14:22:13 +03:00
|
|
|
*/
|
2019-06-10 13:27:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT virtual nsresult InsertLineBreakAsAction(
|
|
|
|
nsIPrincipal* aPrincipal = nullptr);
|
2018-11-03 14:22:13 +03:00
|
|
|
|
2018-04-18 18:31:51 +03:00
|
|
|
/**
|
|
|
|
* OnCompositionStart() is called when editor receives eCompositionStart
|
|
|
|
* event which should be handled in this editor.
|
|
|
|
*/
|
|
|
|
nsresult OnCompositionStart(WidgetCompositionEvent& aCompositionStartEvent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* OnCompositionChange() is called when editor receives an eCompositioChange
|
|
|
|
* event which should be handled in this editor.
|
|
|
|
*
|
|
|
|
* @param aCompositionChangeEvent eCompositionChange event which should
|
|
|
|
* be handled in this editor.
|
|
|
|
*/
|
2020-03-22 13:46:39 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
OnCompositionChange(WidgetCompositionEvent& aCompositionChangeEvent);
|
2018-04-18 18:31:51 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* OnCompositionEnd() is called when editor receives an eCompositionChange
|
|
|
|
* event and it's followed by eCompositionEnd event and after
|
|
|
|
* OnCompositionChange() is called.
|
|
|
|
*/
|
2020-03-22 13:46:39 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void OnCompositionEnd(
|
|
|
|
WidgetCompositionEvent& aCompositionEndEvent);
|
2018-04-18 18:31:51 +03:00
|
|
|
|
2018-06-08 08:19:51 +03:00
|
|
|
/**
|
|
|
|
* OnDrop() is called from EditorEventListener::Drop that is handler of drop
|
|
|
|
* event.
|
|
|
|
*/
|
2020-03-22 13:46:39 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult OnDrop(dom::DragEvent* aDropEvent);
|
2018-06-08 08:19:51 +03:00
|
|
|
|
2018-07-18 15:27:30 +03:00
|
|
|
/**
|
|
|
|
* ComputeTextValue() computes plaintext value of this editor. This may be
|
|
|
|
* too expensive if it's in hot path.
|
|
|
|
*
|
|
|
|
* @param aDocumentEncoderFlags Flags of nsIDocumentEncoder.
|
|
|
|
* @param aCharset Encoding of the document.
|
|
|
|
*/
|
|
|
|
nsresult ComputeTextValue(uint32_t aDocumentEncoderFlags,
|
|
|
|
nsAString& aOutputString) const {
|
2018-10-30 12:59:33 +03:00
|
|
|
AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
|
|
|
|
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
|
|
|
return NS_ERROR_NOT_INITIALIZED;
|
|
|
|
}
|
2019-02-25 12:07:54 +03:00
|
|
|
nsresult rv = ComputeValueInternal(NS_LITERAL_STRING("text/plain"),
|
|
|
|
aDocumentEncoderFlags, aOutputString);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return EditorBase::ToGenericNSResult(rv);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
2018-07-18 15:27:30 +03:00
|
|
|
}
|
|
|
|
|
2019-07-22 06:53:36 +03:00
|
|
|
/**
|
|
|
|
* The following methods are available only when the instance is a password
|
|
|
|
* editor. They return whether there is unmasked range or not and range
|
|
|
|
* start and length.
|
|
|
|
*/
|
|
|
|
bool IsAllMasked() const {
|
|
|
|
MOZ_ASSERT(IsPasswordEditor());
|
|
|
|
return mUnmaskedStart == UINT32_MAX && mUnmaskedLength == 0;
|
|
|
|
}
|
|
|
|
uint32_t UnmaskedStart() const {
|
|
|
|
MOZ_ASSERT(IsPasswordEditor());
|
|
|
|
return mUnmaskedStart;
|
|
|
|
}
|
|
|
|
uint32_t UnmaskedLength() const {
|
|
|
|
MOZ_ASSERT(IsPasswordEditor());
|
|
|
|
return mUnmaskedLength;
|
|
|
|
}
|
|
|
|
uint32_t UnmaskedEnd() const {
|
|
|
|
MOZ_ASSERT(IsPasswordEditor());
|
|
|
|
return mUnmaskedStart + mUnmaskedLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IsMaskingPassword() returns false when the last caller of `Unmask()`
|
|
|
|
* didn't want to mask again automatically. When this returns true, user
|
|
|
|
* input causes masking the password even before timed-out.
|
|
|
|
*/
|
|
|
|
bool IsMaskingPassword() const {
|
|
|
|
MOZ_ASSERT(IsPasswordEditor());
|
|
|
|
return mIsMaskingPassword;
|
|
|
|
}
|
|
|
|
|
2019-07-22 06:55:13 +03:00
|
|
|
/**
|
|
|
|
* PasswordMask() returns a character which masks each character in password
|
|
|
|
* fields.
|
|
|
|
*/
|
|
|
|
static char16_t PasswordMask();
|
|
|
|
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
protected: // May be called by friends.
|
2018-05-22 14:15:05 +03:00
|
|
|
/****************************************************************************
|
2019-09-18 11:40:08 +03:00
|
|
|
* Some friend classes are allowed to call the following protected methods.
|
|
|
|
* However, those methods won't prepare caches of some objects which are
|
|
|
|
* necessary for them. So, if you call them from friend classes, you need
|
|
|
|
* to make sure that AutoEditActionDataSetter is created.
|
2018-05-22 14:15:05 +03:00
|
|
|
****************************************************************************/
|
|
|
|
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
// Overrides of EditorBase
|
2020-03-22 13:46:39 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT virtual nsresult RemoveAttributeOrEquivalent(
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
Element* aElement, nsAtom* aAttribute,
|
|
|
|
bool aSuppressTransaction) override;
|
2020-03-22 13:46:39 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT virtual nsresult SetAttributeOrEquivalent(
|
|
|
|
Element* aElement, nsAtom* aAttribute, const nsAString& aValue,
|
|
|
|
bool aSuppressTransaction) override;
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
using EditorBase::RemoveAttributeOrEquivalent;
|
|
|
|
using EditorBase::SetAttributeOrEquivalent;
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2019-12-21 15:30:17 +03:00
|
|
|
/**
|
|
|
|
* DeleteSelectionByDragAsAction() removes selection and dispatch "input"
|
|
|
|
* event whose inputType is "deleteByDrag".
|
|
|
|
*/
|
2020-04-02 08:43:31 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult
|
2019-12-21 15:30:17 +03:00
|
|
|
DeleteSelectionByDragAsAction(bool aDispatchInputEvent);
|
|
|
|
|
2018-07-03 16:25:52 +03:00
|
|
|
/**
|
|
|
|
* Replace existed string with aString. Caller must guarantee that there
|
|
|
|
* is a placeholder transaction which will have the transaction.
|
|
|
|
*
|
|
|
|
* @ param aString The string to be set.
|
|
|
|
*/
|
2020-04-02 08:43:31 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult
|
2019-09-17 05:21:35 +03:00
|
|
|
SetTextAsSubAction(const nsAString& aString);
|
2018-07-03 16:25:52 +03:00
|
|
|
|
2018-07-04 16:51:55 +03:00
|
|
|
/**
|
|
|
|
* ReplaceSelectionAsSubAction() replaces selection with aString.
|
|
|
|
*
|
|
|
|
* @param aString The string to replace.
|
|
|
|
*/
|
2020-03-22 13:46:39 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult
|
|
|
|
ReplaceSelectionAsSubAction(const nsAString& aString);
|
2018-07-04 16:51:55 +03:00
|
|
|
|
2019-08-09 11:25:37 +03:00
|
|
|
/**
|
|
|
|
* MaybeDoAutoPasswordMasking() may mask password if we're doing auto-masking.
|
|
|
|
*/
|
|
|
|
void MaybeDoAutoPasswordMasking() {
|
|
|
|
if (IsPasswordEditor() && IsMaskingPassword()) {
|
|
|
|
MaskAllCharacters();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-22 06:53:36 +03:00
|
|
|
/**
|
|
|
|
* SetUnmaskRange() is available only when the instance is a password
|
|
|
|
* editor. This just updates unmask range. I.e., caller needs to
|
|
|
|
* guarantee to update the layout.
|
|
|
|
*
|
|
|
|
* @param aStart First index to show the character.
|
|
|
|
* If aLength is 0, this value is ignored.
|
|
|
|
* @param aLength Optional, Length to show characters.
|
|
|
|
* If UINT32_MAX, it means unmasking all characters after
|
|
|
|
* aStart.
|
|
|
|
* If 0, it means that masking all characters.
|
|
|
|
* @param aTimeout Optional, specify milliseconds to hide the unmasked
|
|
|
|
* characters after this call.
|
|
|
|
* If 0, it means this won't mask the characters
|
|
|
|
* automatically.
|
|
|
|
* If aLength is 0, this value is ignored.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult SetUnmaskRange(
|
|
|
|
uint32_t aStart, uint32_t aLength = UINT32_MAX, uint32_t aTimeout = 0) {
|
|
|
|
return SetUnmaskRangeInternal(aStart, aLength, aTimeout, false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SetUnmaskRangeAndNotify() is available only when the instance is a
|
|
|
|
* password editor. This updates unmask range and notifying the text frame
|
|
|
|
* to update the visible characters.
|
|
|
|
*
|
|
|
|
* @param aStart First index to show the character.
|
|
|
|
* If UINT32_MAX, it means masking all.
|
|
|
|
* @param aLength Optional, Length to show characters.
|
|
|
|
* If UINT32_MAX, it means unmasking all characters after
|
|
|
|
* aStart.
|
|
|
|
* @param aTimeout Optional, specify milliseconds to hide the unmasked
|
|
|
|
* characters after this call.
|
|
|
|
* If 0, it means this won't mask the characters
|
|
|
|
* automatically.
|
|
|
|
* If aLength is 0, this value is ignored.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetUnmaskRangeAndNotify(
|
|
|
|
uint32_t aStart, uint32_t aLength = UINT32_MAX, uint32_t aTimeout = 0) {
|
|
|
|
return SetUnmaskRangeInternal(aStart, aLength, aTimeout, true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MaskAllCharacters() is an alias of SetUnmaskRange() to mask all characters.
|
|
|
|
* In other words, this removes existing unmask range.
|
|
|
|
* After this is called, TextEditor starts masking password automatically.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult MaskAllCharacters() {
|
|
|
|
return SetUnmaskRangeInternal(UINT32_MAX, 0, 0, false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MaskAllCharactersAndNotify() is an alias of SetUnmaskRangeAndNotify() to
|
|
|
|
* mask all characters and notifies the text frame. In other words, this
|
|
|
|
* removes existing unmask range.
|
|
|
|
* After this is called, TextEditor starts masking password automatically.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult MaskAllCharactersAndNotify() {
|
|
|
|
return SetUnmaskRangeInternal(UINT32_MAX, 0, 0, true, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WillDeleteText() is called before `DeleteTextTransaction` or something
|
|
|
|
* removes text in a text node. Note that this won't be called if the
|
|
|
|
* instance is `HTMLEditor` since supporting it makes the code complicated
|
|
|
|
* due to mutation events.
|
|
|
|
*
|
|
|
|
* @param aCurrentLength Current text length of the node.
|
|
|
|
* @param aRemoveStartOffset Start offset of the range to be removed.
|
|
|
|
* @param aRemoveLength Length of the range to be removed.
|
|
|
|
*/
|
|
|
|
void WillDeleteText(uint32_t aCurrentLength, uint32_t aRemoveStartOffset,
|
|
|
|
uint32_t aRemoveLength);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DidInsertText() is called after `InsertTextTransaction` or something
|
|
|
|
* inserts text into a text node. Note that this won't be called if the
|
|
|
|
* instance is `HTMLEditor` since supporting it makes the code complicated
|
|
|
|
* due to mutatione events.
|
|
|
|
*
|
|
|
|
* @param aNewLength New text length after the insertion.
|
|
|
|
* @param aInsertedOffset Start offset of the inserted text.
|
|
|
|
* @param aInsertedLength Length of the inserted text.
|
|
|
|
* @return NS_OK or NS_ERROR_EDITOR_DESTROYED.
|
|
|
|
*/
|
2020-04-02 08:43:31 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult DidInsertText(
|
2019-07-22 06:53:36 +03:00
|
|
|
uint32_t aNewLength, uint32_t aInsertedOffset, uint32_t aInsertedLength);
|
|
|
|
|
2019-09-12 10:48:29 +03:00
|
|
|
protected: // edit sub-action handler
|
|
|
|
/**
|
2020-04-27 04:29:43 +03:00
|
|
|
* MaybeTruncateInsertionStringForMaxLength() truncates aInsertionString to
|
|
|
|
* `maxlength` if it was not pasted in by the user.
|
2019-09-12 10:48:29 +03:00
|
|
|
*
|
|
|
|
* @param aInsertionString [in/out] New insertion string. This is
|
2020-04-27 04:29:43 +03:00
|
|
|
* truncated to `maxlength` if it was not pasted in
|
|
|
|
* by the user.
|
|
|
|
* @return If aInsertionString is truncated, it returns "as
|
|
|
|
* handled", else "as ignored."
|
2019-09-12 10:48:29 +03:00
|
|
|
*/
|
2020-04-27 04:29:43 +03:00
|
|
|
EditActionResult MaybeTruncateInsertionStringForMaxLength(
|
2019-09-13 05:40:09 +03:00
|
|
|
nsAString& aInsertionString);
|
2019-09-12 10:48:29 +03:00
|
|
|
|
2019-09-12 11:03:57 +03:00
|
|
|
/**
|
|
|
|
* InsertLineFeedCharacterAtSelection() inserts a linefeed character at
|
|
|
|
* selection.
|
|
|
|
*/
|
2020-04-02 08:43:31 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT EditActionResult
|
2019-09-12 11:03:57 +03:00
|
|
|
InsertLineFeedCharacterAtSelection();
|
|
|
|
|
2019-09-13 05:40:09 +03:00
|
|
|
/**
|
|
|
|
* Handles the newline characters according to the default system prefs
|
|
|
|
* (editor.singleLine.pasteNewlines).
|
|
|
|
* Each value means:
|
2020-01-24 11:33:42 +03:00
|
|
|
* nsIEditor::eNewlinesReplaceWithSpaces (2, Firefox default):
|
2019-09-13 05:40:09 +03:00
|
|
|
* replace newlines with spaces.
|
2020-01-24 11:33:42 +03:00
|
|
|
* nsIEditor::eNewlinesStrip (3):
|
2019-09-13 05:40:09 +03:00
|
|
|
* remove newlines from the string.
|
2020-01-24 11:33:42 +03:00
|
|
|
* nsIEditor::eNewlinesReplaceWithCommas (4, Thunderbird default):
|
2019-09-13 05:40:09 +03:00
|
|
|
* replace newlines with commas.
|
2020-01-24 11:33:42 +03:00
|
|
|
* nsIEditor::eNewlinesStripSurroundingWhitespace (5):
|
2019-09-13 05:40:09 +03:00
|
|
|
* collapse newlines and surrounding whitespace characters and
|
|
|
|
* remove them from the string.
|
2020-01-24 11:33:42 +03:00
|
|
|
* nsIEditor::eNewlinesPasteIntact (0):
|
2019-09-13 05:40:09 +03:00
|
|
|
* only remove the leading and trailing newlines.
|
2020-01-24 11:33:42 +03:00
|
|
|
* nsIEditor::eNewlinesPasteToFirst (1) or any other value:
|
2019-09-13 05:40:09 +03:00
|
|
|
* remove the first newline and all characters following it.
|
|
|
|
*
|
|
|
|
* @param aString the string to be modified in place.
|
|
|
|
*/
|
|
|
|
void HandleNewLinesInStringForSingleLineEditor(nsString& aString) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* HandleInsertText() handles inserting text at selection.
|
|
|
|
*
|
|
|
|
* @param aEditSubAction Must be EditSubAction::eInsertText or
|
|
|
|
* EditSubAction::eInsertTextComingFromIME.
|
|
|
|
* @param aInsertionString String to be inserted at selection.
|
|
|
|
*/
|
2020-04-02 08:43:31 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT virtual EditActionResult HandleInsertText(
|
2019-09-13 05:40:09 +03:00
|
|
|
EditSubAction aEditSubAction, const nsAString& aInsertionString);
|
|
|
|
|
2019-09-13 05:49:43 +03:00
|
|
|
/**
|
|
|
|
* HandleDeleteSelectionInternal() is a helper method of
|
|
|
|
* HandleDeleteSelection(). Must be called only when the instance is
|
|
|
|
* TextEditor.
|
|
|
|
* NOTE: This method creates SelectionBatcher. Therefore, each caller
|
|
|
|
* needs to check if the editor is still available even if this returns
|
|
|
|
* NS_OK.
|
|
|
|
*/
|
2020-04-02 08:43:31 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT EditActionResult
|
2019-09-13 06:20:04 +03:00
|
|
|
HandleDeleteSelectionInternal(nsIEditor::EDirection aDirectionAndAmount,
|
|
|
|
nsIEditor::EStripWrappers aStripWrappers);
|
2019-09-13 05:49:43 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method handles "delete selection" commands.
|
|
|
|
*
|
|
|
|
* @param aDirectionAndAmount Direction of the deletion.
|
2020-04-27 03:36:10 +03:00
|
|
|
* @param aStripWrappers Must be nsIEditor::eNoStrip.
|
2019-09-13 05:49:43 +03:00
|
|
|
*/
|
2020-04-24 17:55:09 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT EditActionResult
|
2019-09-13 05:49:43 +03:00
|
|
|
HandleDeleteSelection(nsIEditor::EDirection aDirectionAndAmount,
|
2020-04-24 17:55:09 +03:00
|
|
|
nsIEditor::EStripWrappers aStripWrappers) override;
|
2019-09-13 05:49:43 +03:00
|
|
|
|
2019-09-13 06:44:33 +03:00
|
|
|
/**
|
|
|
|
* ComputeValueFromTextNodeAndPaddingBRElement() tries to compute "value" of
|
|
|
|
* this editor content only with text node and padding `<br>` element.
|
|
|
|
* If this succeeds to compute the value, it's returned with aValue and
|
|
|
|
* the result is marked as "handled". Otherwise, the caller needs to
|
|
|
|
* compute it with another way.
|
|
|
|
*/
|
|
|
|
EditActionResult ComputeValueFromTextNodeAndPaddingBRElement(
|
|
|
|
nsAString& aValue) const;
|
|
|
|
|
2019-09-17 05:21:35 +03:00
|
|
|
/**
|
|
|
|
* SetTextWithoutTransaction() is optimized method to set `<input>.value`
|
|
|
|
* and `<textarea>.value` to aValue without transaction. This must be
|
|
|
|
* called only when it's not `HTMLEditor` and undo/redo is disabled.
|
|
|
|
*/
|
2020-04-02 08:43:31 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT EditActionResult
|
2019-09-17 05:21:35 +03:00
|
|
|
SetTextWithoutTransaction(const nsAString& aValue);
|
|
|
|
|
2019-09-17 05:47:49 +03:00
|
|
|
/**
|
|
|
|
* EnsurePaddingBRElementInMultilineEditor() creates a padding `<br>` element
|
|
|
|
* at end of multiline text editor.
|
|
|
|
*/
|
2020-04-02 08:43:31 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult
|
2019-09-17 05:47:49 +03:00
|
|
|
EnsurePaddingBRElementInMultilineEditor();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* EnsureCaretNotAtEndOfTextNode() collapses selection at the padding `<br>`
|
|
|
|
* element (i.e., container becomes the anonymous `<div>` element) if
|
|
|
|
* `Selection` is at end of the text node.
|
|
|
|
*/
|
2020-04-02 08:43:31 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult EnsureCaretNotAtEndOfTextNode();
|
2019-09-17 05:47:49 +03:00
|
|
|
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
protected: // Called by helper classes.
|
2019-09-18 06:01:28 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT virtual void OnStartToHandleTopLevelEditSubAction(
|
|
|
|
EditSubAction aTopLevelEditSubAction,
|
|
|
|
nsIEditor::EDirection aDirectionOfTopLevelEditSubAction,
|
|
|
|
ErrorResult& aRv) override;
|
|
|
|
MOZ_CAN_RUN_SCRIPT virtual nsresult OnEndHandlingTopLevelEditSubAction()
|
|
|
|
override;
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
|
2019-08-09 12:01:56 +03:00
|
|
|
/**
|
2019-08-09 13:19:11 +03:00
|
|
|
* EnsurePaddingBRElementForEmptyEditor() creates padding <br> element for
|
|
|
|
* empty editor or changes padding <br> element for empty last line to for
|
|
|
|
* empty editor when we're empty.
|
2019-08-09 12:01:56 +03:00
|
|
|
*/
|
2019-08-09 13:19:11 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult EnsurePaddingBRElementForEmptyEditor();
|
2019-08-09 12:01:56 +03:00
|
|
|
|
2019-08-13 04:24:01 +03:00
|
|
|
/**
|
|
|
|
* HandleInlineSpellCheckAfterEdit() does spell-check after handling top level
|
|
|
|
* edit subaction.
|
|
|
|
*/
|
2019-08-13 07:41:18 +03:00
|
|
|
nsresult HandleInlineSpellCheckAfterEdit() {
|
2019-08-13 04:24:01 +03:00
|
|
|
MOZ_ASSERT(IsEditActionDataAvailable());
|
|
|
|
if (!GetSpellCheckRestartPoint().IsSet()) {
|
|
|
|
return NS_OK; // Maybe being initialized.
|
|
|
|
}
|
2019-08-20 04:51:59 +03:00
|
|
|
nsresult rv = HandleInlineSpellCheck(GetSpellCheckRestartPoint());
|
2019-08-13 04:24:01 +03:00
|
|
|
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to spellcheck");
|
|
|
|
ClearSpellCheckRestartPoint();
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
protected: // Shouldn't be used by friend classes
|
|
|
|
virtual ~TextEditor();
|
|
|
|
|
2019-09-18 11:21:37 +03:00
|
|
|
/**
|
|
|
|
* InitEditorContentAndSelection() may insert a padding `<br>` element for
|
|
|
|
* if it's required in the anonymous `<div>` element and collapse selection
|
|
|
|
* at the end if there is no selection ranges.
|
|
|
|
*/
|
2020-04-02 08:43:31 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult InitEditorContentAndSelection();
|
2019-09-18 11:21:37 +03:00
|
|
|
|
2019-09-13 05:40:09 +03:00
|
|
|
/**
|
|
|
|
* CanEchoPasswordNow() returns true if currently we can echo password.
|
|
|
|
* If it's direct user input such as pasting or dropping text, this
|
|
|
|
* returns false even if we may echo password.
|
|
|
|
*/
|
|
|
|
bool CanEchoPasswordNow() const;
|
|
|
|
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
/**
|
|
|
|
* Make the given selection span the entire document.
|
|
|
|
*/
|
2020-03-22 13:46:39 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT virtual nsresult SelectEntireDocument() override;
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* OnInputText() is called when user inputs text with keyboard or something.
|
|
|
|
*
|
|
|
|
* @param aStringToInsert The string to insert.
|
|
|
|
*/
|
2020-04-02 08:43:31 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult
|
2019-09-13 05:40:09 +03:00
|
|
|
OnInputText(const nsAString& aStringToInsert);
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
|
2018-11-12 04:40:46 +03:00
|
|
|
/**
|
|
|
|
* PrepareInsertContent() is a helper method of InsertTextAt(),
|
|
|
|
* HTMLEditor::DoInsertHTMLWithContext(). They insert content coming from
|
|
|
|
* clipboard or drag and drop. Before that, they may need to remove selected
|
|
|
|
* contents and adjust selection. This does them instead.
|
|
|
|
*
|
|
|
|
* @param aPointToInsert Point to insert. Must be set. Callers
|
|
|
|
* shouldn't use this instance after calling this
|
|
|
|
* method because this method may cause changing
|
|
|
|
* the DOM tree and Selection.
|
|
|
|
* @param aDoDeleteSelection true if selected content should be removed.
|
|
|
|
*/
|
2020-03-22 13:46:39 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult PrepareToInsertContent(
|
|
|
|
const EditorDOMPoint& aPointToInsert, bool aDoDeleteSelection);
|
2018-11-12 04:40:46 +03:00
|
|
|
|
2018-11-09 11:40:57 +03:00
|
|
|
/**
|
|
|
|
* InsertTextAt() inserts aStringToInsert at aPointToInsert.
|
|
|
|
*
|
|
|
|
* @param aStringToInsert The string which you want to insert.
|
|
|
|
* @param aPointToInsert The insertion point.
|
|
|
|
* @param aDoDeleteSelection true if you want this to delete selected
|
|
|
|
* content. Otherwise, false.
|
|
|
|
*/
|
2020-03-22 13:46:39 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult InsertTextAt(const nsAString& aStringToInsert,
|
|
|
|
const EditorDOMPoint& aPointToInsert,
|
|
|
|
bool aDoDeleteSelection);
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
|
2018-07-23 10:05:30 +03:00
|
|
|
/**
|
|
|
|
* InsertWithQuotationsAsSubAction() inserts aQuotedText with appending ">"
|
|
|
|
* to start of every line.
|
|
|
|
*
|
|
|
|
* @param aQuotedText String to insert. This will be quoted by ">"
|
|
|
|
* automatically.
|
|
|
|
*/
|
2020-04-02 08:43:31 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT virtual nsresult
|
2019-09-13 05:40:09 +03:00
|
|
|
InsertWithQuotationsAsSubAction(const nsAString& aQuotedText);
|
2018-07-23 10:05:30 +03:00
|
|
|
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
/**
|
|
|
|
* Return true if the data is safe to insert as the source and destination
|
|
|
|
* principals match, or we are in a editor context where this doesn't matter.
|
|
|
|
* Otherwise, the data must be sanitized first.
|
|
|
|
*/
|
2019-01-02 16:05:23 +03:00
|
|
|
bool IsSafeToInsertData(Document* aSourceDoc);
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
|
2018-07-18 14:51:55 +03:00
|
|
|
/**
|
|
|
|
* GetAndInitDocEncoder() returns a document encoder instance for aFormatType
|
|
|
|
* after initializing it. The result may be cached for saving recreation
|
|
|
|
* cost.
|
|
|
|
*
|
|
|
|
* @param aFormatType MIME type like "text/plain".
|
|
|
|
* @param aDocumentEncoderFlags Flags of nsIDocumentEncoder.
|
|
|
|
* @param aCharset Encoding of the document.
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsIDocumentEncoder> GetAndInitDocEncoder(
|
|
|
|
const nsAString& aFormatType, uint32_t aDocumentEncoderFlags,
|
|
|
|
const nsACString& aCharset) const;
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
|
2018-07-18 15:27:30 +03:00
|
|
|
/**
|
|
|
|
* ComputeValueInternal() computes string value of this editor for given
|
|
|
|
* format. This may be too expensive if it's in hot path.
|
|
|
|
*
|
|
|
|
* @param aFormatType MIME type like "text/plain".
|
|
|
|
* @param aDocumentEncoderFlags Flags of nsIDocumentEncoder.
|
|
|
|
* @param aCharset Encoding of the document.
|
|
|
|
*/
|
|
|
|
nsresult ComputeValueInternal(const nsAString& aFormatType,
|
|
|
|
uint32_t aDocumentEncoderFlags,
|
|
|
|
nsAString& aOutputString) const;
|
|
|
|
|
2016-07-09 05:54:50 +03:00
|
|
|
/**
|
|
|
|
* Factored methods for handling insertion of data from transferables
|
|
|
|
* (drag&drop or clipboard).
|
|
|
|
*/
|
Bug 1463327 - part 2: Change scope of some methods of TextEditor which won't be called by non-helper classes of editing to protected r=m_kato
TextEditor has 2 type of public methods. One is true-public methods. I.e.,
they should be able to be called by anybody. E.g., command handlers, event
listeners, or JS via nsIEditor interface. The other is semi-public methods.
They are not called by the above examples but called by other classes which
are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules,
HTMLEditUtils, CSSEditUtils and Transaction classes.
When we will implement InputEvent.inputType, we need to create new stack
class and create its instance at every true-public methods to manage current
inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not
happen that new code starts to call semi-public methods without the new
stack class instance.
For preventing this issue, we should make TextEditor have only the true-public
methods as public. The other public methods should be protected and their
users should be friend classes. Then, we can protect such method from external
classes.
Note that this patch just moves the methods without any changes in TextEditor.h.
MozReview-Commit-ID: Db3H6d1V8IU
--HG--
extra : rebase_source : d928a6bb378d02944c5a207de83211c33bb63613
2018-05-22 10:40:44 +03:00
|
|
|
virtual nsresult PrepareTransferable(nsITransferable** transferable);
|
|
|
|
|
2020-04-02 08:43:31 +03:00
|
|
|
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult
|
2019-09-13 05:40:09 +03:00
|
|
|
InsertTextFromTransferable(nsITransferable* transferable);
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2016-07-09 05:54:50 +03:00
|
|
|
/**
|
|
|
|
* Shared outputstring; returns whether selection is collapsed and resulting
|
|
|
|
* string.
|
|
|
|
*/
|
|
|
|
nsresult SharedOutputString(uint32_t aFlags, bool* aIsCollapsed,
|
2019-09-13 06:44:33 +03:00
|
|
|
nsAString& aResult) const;
|
2003-07-28 17:13:50 +04:00
|
|
|
|
2019-07-29 09:21:14 +03:00
|
|
|
/**
|
2019-07-29 09:21:42 +03:00
|
|
|
* See comment of IsCopyToClipboardAllowed() for the detail.
|
2019-07-29 09:21:14 +03:00
|
|
|
*/
|
2019-07-29 09:21:42 +03:00
|
|
|
bool IsCopyToClipboardAllowedInternal() const;
|
2019-07-29 09:21:14 +03:00
|
|
|
|
2016-07-09 05:54:50 +03:00
|
|
|
bool FireClipboardEvent(EventMessage aEventMessage, int32_t aSelectionType,
|
2015-08-26 15:56:59 +03:00
|
|
|
bool* aActionTaken = nullptr);
|
2007-07-26 08:14:33 +04:00
|
|
|
|
2019-05-08 09:26:25 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT bool UpdateMetaCharset(Document& aDocument,
|
|
|
|
const nsACString& aCharacterSet);
|
2012-02-01 14:54:22 +04:00
|
|
|
|
2018-04-18 18:31:51 +03:00
|
|
|
/**
|
|
|
|
* EnsureComposition() should be called by composition event handlers. This
|
|
|
|
* tries to get the composition for the event and set it to mComposition.
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
bool EnsureComposition(WidgetCompositionEvent& aCompositionEvent);
|
|
|
|
|
2020-04-13 04:43:41 +03:00
|
|
|
virtual already_AddRefed<Element> GetInputEventTargetElement() const override;
|
2018-06-06 07:30:44 +03:00
|
|
|
|
2019-07-22 06:53:36 +03:00
|
|
|
/**
|
|
|
|
* See SetUnmaskRange() and SetUnmaskRangeAndNotify() for the detail.
|
|
|
|
*
|
|
|
|
* @param aForceStartMasking If true, forcibly starts masking. This should
|
|
|
|
* be used only when `nsIEditor::Mask()` is called.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT nsresult SetUnmaskRangeInternal(uint32_t aStart,
|
|
|
|
uint32_t aLength,
|
|
|
|
uint32_t aTimeout,
|
|
|
|
bool aNotify,
|
|
|
|
bool aForceStartMasking);
|
|
|
|
|
2001-01-28 23:13:07 +03:00
|
|
|
protected:
|
2018-07-18 14:51:55 +03:00
|
|
|
mutable nsCOMPtr<nsIDocumentEncoder> mCachedDocumentEncoder;
|
2019-07-22 06:53:36 +03:00
|
|
|
|
|
|
|
// Timer to mask unmasked characters automatically. Used only when it's
|
|
|
|
// a password field.
|
|
|
|
nsCOMPtr<nsITimer> mMaskTimer;
|
|
|
|
|
2018-07-18 14:51:55 +03:00
|
|
|
mutable nsString mCachedDocumentEncoderType;
|
2019-07-22 06:53:36 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mMaxTextLength;
|
2001-01-28 23:13:07 +03:00
|
|
|
|
2019-07-22 06:53:36 +03:00
|
|
|
// Unmasked character range. Used only when it's a password field.
|
|
|
|
// If mUnmaskedLength is 0, it means there is no unmasked characters.
|
|
|
|
uint32_t mUnmaskedStart;
|
|
|
|
uint32_t mUnmaskedLength;
|
|
|
|
|
|
|
|
// Set to true if all characters are masked or waiting notification from
|
|
|
|
// `mMaskTimer`. Otherwise, i.e., part of or all of password is unmasked
|
|
|
|
// without setting `mMaskTimer`, set to false.
|
|
|
|
bool mIsMaskingPassword;
|
|
|
|
|
|
|
|
friend class DeleteNodeTransaction;
|
|
|
|
friend class EditorBase;
|
|
|
|
friend class InsertNodeTransaction;
|
2001-01-28 23:13:07 +03:00
|
|
|
};
|
|
|
|
|
2017-08-04 09:01:36 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
mozilla::TextEditor* nsIEditor::AsTextEditor() {
|
|
|
|
return static_cast<mozilla::TextEditor*>(this);
|
2017-08-04 00:18:50 +03:00
|
|
|
}
|
|
|
|
|
2017-08-04 09:01:36 +03:00
|
|
|
const mozilla::TextEditor* nsIEditor::AsTextEditor() const {
|
|
|
|
return static_cast<const mozilla::TextEditor*>(this);
|
2017-08-04 00:18:50 +03:00
|
|
|
}
|
|
|
|
|
2016-07-09 05:54:50 +03:00
|
|
|
#endif // #ifndef mozilla_TextEditor_h
|