` element) if
* `Selection` is at end of the text node.
*/
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult EnsureCaretNotAtEndOfTextNode();
protected: // Called by helper classes.
MOZ_CAN_RUN_SCRIPT void OnStartToHandleTopLevelEditSubAction(
EditSubAction aTopLevelEditSubAction,
nsIEditor::EDirection aDirectionOfTopLevelEditSubAction,
ErrorResult& aRv) final;
MOZ_CAN_RUN_SCRIPT nsresult OnEndHandlingTopLevelEditSubAction() final;
/**
* HandleInlineSpellCheckAfterEdit() does spell-check after handling top level
* edit subaction.
*/
nsresult HandleInlineSpellCheckAfterEdit() {
MOZ_ASSERT(IsEditActionDataAvailable());
if (!GetSpellCheckRestartPoint().IsSet()) {
return NS_OK; // Maybe being initialized.
}
nsresult rv = HandleInlineSpellCheck(GetSpellCheckRestartPoint());
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to spellcheck");
ClearSpellCheckRestartPoint();
return rv;
}
protected: // Shouldn't be used by friend classes
virtual ~TextEditor();
/**
* 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;
/**
* InitEditorContentAndSelection() may insert a padding `
` element for
* if it's required in the anonymous `
` element or `` element and
* collapse selection at the end if there is no selection ranges.
*/
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult InitEditorContentAndSelection();
/**
* Collapse `Selection` to end of the text node in the anonymous
* element.
*/
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult CollapseSelectionToEndOfTextNode();
/**
* Make the given selection span the entire document.
*/
MOZ_CAN_RUN_SCRIPT nsresult SelectEntireDocument() final;
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult
InsertWithQuotationsAsSubAction(const nsAString& aQuotedText) final;
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult
InsertTextFromTransferable(nsITransferable* transferable);
bool IsCopyToClipboardAllowedInternal() const final;
already_AddRefed
GetInputEventTargetElement() const final;
/**
* 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);
MOZ_ALWAYS_INLINE bool HasAutoMaskingTimer() const {
return mPasswordMaskData && mPasswordMaskData->mTimer;
}
protected:
UniquePtr mPasswordMaskData;
int32_t mMaxTextLength = -1;
friend class DeleteNodeTransaction;
friend class EditorBase;
friend class InsertNodeTransaction;
};
} // namespace mozilla
mozilla::TextEditor* nsIEditor::AsTextEditor() {
MOZ_DIAGNOSTIC_ASSERT(IsTextEditor());
return static_cast(this);
}
const mozilla::TextEditor* nsIEditor::AsTextEditor() const {
MOZ_DIAGNOSTIC_ASSERT(IsTextEditor());
return static_cast(this);
}
mozilla::TextEditor* nsIEditor::GetAsTextEditor() {
return AsEditorBase()->IsTextEditor() ? AsTextEditor() : nullptr;
}
const mozilla::TextEditor* nsIEditor::GetAsTextEditor() const {
return AsEditorBase()->IsTextEditor() ? AsTextEditor() : nullptr;
}
#endif // #ifndef mozilla_TextEditor_h