From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- editor/nsIEditor.idl | 675 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 675 insertions(+) create mode 100644 editor/nsIEditor.idl (limited to 'editor/nsIEditor.idl') diff --git a/editor/nsIEditor.idl b/editor/nsIEditor.idl new file mode 100644 index 0000000000..9193dc1b8b --- /dev/null +++ b/editor/nsIEditor.idl @@ -0,0 +1,675 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * 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/. */ + +#include "nsISupports.idl" +#include "domstubs.idl" + +%{C++ +#include "mozilla/Debug.h" +%} + +interface nsISelectionController; +interface nsIDocumentStateListener; +interface nsIEditActionListener; +interface nsIInlineSpellChecker; +interface nsITransferable; + +webidl Document; +webidl Element; +webidl Node; +webidl Selection; + +%{C++ +namespace mozilla { +class EditorBase; +class HTMLEditor; +class TextEditor; +} // namespace mozilla +%} + +[scriptable, builtinclass, uuid(094be624-f0bf-400f-89e2-6a84baab9474)] +interface nsIEditor : nsISupports +{ +%{C++ + typedef short EDirection; + typedef short EStripWrappers; +%} + const short eNone = 0; + const short eNext = 1; + const short ePrevious = 2; + const short eNextWord = 3; + const short ePreviousWord = 4; + const short eToBeginningOfLine = 5; + const short eToEndOfLine = 6; + +%{C++ + static bool EDirectionIsValid(EDirection aDirectionAndAmount) { + return aDirectionAndAmount == nsIEditor::eNone || + aDirectionAndAmount == nsIEditor::eNext || + aDirectionAndAmount == nsIEditor::ePrevious || + aDirectionAndAmount == nsIEditor::eNextWord || + aDirectionAndAmount == nsIEditor::ePreviousWord || + aDirectionAndAmount == nsIEditor::eToBeginningOfLine || + aDirectionAndAmount == nsIEditor::eToEndOfLine; + } + static bool EDirectionIsValidExceptNone(EDirection aDirectionAndAmount) { + return aDirectionAndAmount != nsIEditor::eNone && + EDirectionIsValid(aDirectionAndAmount); + } + + /** + * Return true if nsIEditor::EDirection value means the direction of pressing + * `Backspace` key. + */ + [[nodiscard]] static bool DirectionIsBackspace( + EDirection aDirectionAndAmount) { + MOZ_ASSERT(EDirectionIsValid(aDirectionAndAmount)); + return aDirectionAndAmount == nsIEditor::ePrevious || + aDirectionAndAmount == nsIEditor::ePreviousWord || + aDirectionAndAmount == nsIEditor::eToBeginningOfLine; + } + + /** + * Return true if nsIEditor::EDirection value means the direction of pressing + * `Delete` key (forwardDelete). + */ + [[nodiscard]] static bool DirectionIsDelete( + EDirection aDirectionAndAmount) { + MOZ_ASSERT(EDirectionIsValid(aDirectionAndAmount)); + return aDirectionAndAmount == nsIEditor::eNext || + aDirectionAndAmount == nsIEditor::eNextWord || + aDirectionAndAmount == nsIEditor::eToEndOfLine; + } +%} + + const short eStrip = 0; + const short eNoStrip = 1; + + // If you want an HTML editor to behave as a plaintext editor, specify this + // flag. This is currently used only with plaintext email composer. + const long eEditorPlaintextMask = 0x0001; + // We don't support single line editor mode with HTML editors. Therefore, + // don't specify this for HTML editor. + const long eEditorSingleLineMask = 0x0002; + // We don't support password editor mode with HTML editors. Therefore, + // don't specify this for HTML editor. + const long eEditorPasswordMask = 0x0004; + // When the editor should be in readonly mode (currently, same as "disabled"), + // you can specify this flag with any editor instances. + // NOTE: Setting this flag does not change the style of editor. This just + // changes the internal editor's readonly state. + // NOTE: The readonly mode does NOT block XPCOM APIs which modify the editor + // content. This just blocks edit operations from user input and editing + // commands (both HTML Document.execCommand and the XUL commands). + // FIXME: XPCOM methods of TextEditor may be blocked by this flag. If you + // find it, file a bug. + const long eEditorReadonlyMask = 0x0008; + // If you want an HTML editor to work as an email composer, specify this flag. + // And you can specify this to text editor too for making spellchecker for + // the text editor should work exactly same as email composer's. + const long eEditorMailMask = 0x0020; + // allow the editor to set font: monospace on the root node + const long eEditorEnableWrapHackMask = 0x0040; + // If you want to move focus from an HTML editor with tab navigation, + // specify this flag. This is not available with text editors becase + // it's always tabbable. + // Note that if this is not specified, link navigation is also enabled in + // the editable content. + const long eEditorAllowInteraction = 0x0200; + // when this flag is set, the internal direction of the editor is RTL. + // if neither of the direction flags are set, the direction is determined + // from the text control's content node. + const long eEditorRightToLeft = 0x0800; + // when this flag is set, the internal direction of the editor is LTR. + const long eEditorLeftToRight = 0x1000; + // when this flag is set, the editor's text content is not spell checked. + const long eEditorSkipSpellCheck = 0x2000; + + /* + * The valid values for newlines handling. + * Can't change the values unless we remove + * use of the pref. + */ + const long eNewlinesPasteIntact = 0; + const long eNewlinesPasteToFirst = 1; + const long eNewlinesReplaceWithSpaces = 2; + const long eNewlinesStrip = 3; + const long eNewlinesReplaceWithCommas = 4; + const long eNewlinesStripSurroundingWhitespace = 5; + + readonly attribute Selection selection; + + [can_run_script] + void setAttributeOrEquivalent(in Element element, + in AString sourceAttrName, + in AString sourceAttrValue, + in boolean aSuppressTransaction); + [can_run_script] + void removeAttributeOrEquivalent(in Element element, + in AString sourceAttrName, + in boolean aSuppressTransaction); + + /** edit flags for this editor. May be set at any time. */ + [setter_can_run_script] attribute unsigned long flags; + + /** + * the MimeType of the document + */ + attribute AString contentsMIMEType; + + /** Returns true if we have a document that is not marked read-only */ + readonly attribute boolean isDocumentEditable; + + /** Returns true if the current selection anchor is editable */ + readonly attribute boolean isSelectionEditable; + + /** + * the DOM Document this editor is associated with, refcounted. + */ + readonly attribute Document document; + + /** the body element, i.e. the root of the editable document. + */ + readonly attribute Element rootElement; + + /** + * the selection controller for the current presentation, refcounted. + */ + readonly attribute nsISelectionController selectionController; + + + /* ------------ Selected content removal -------------- */ + + /** + * DeleteSelection removes all nodes in the current selection. + * @param aDir if eNext, delete to the right (for example, the DEL key) + * if ePrevious, delete to the left (for example, the BACKSPACE key) + * @param stripWrappers If eStrip, strip any empty inline elements left + * behind after the deletion; if eNoStrip, don't. If in + * doubt, pass eStrip -- eNoStrip is only for if you're + * about to insert text or similar right after. + */ + [can_run_script] + void deleteSelection(in short action, in short stripWrappers); + + + /* ------------ Document info and file methods -------------- */ + + /** Returns true if the document has no *meaningful* content */ + readonly attribute boolean documentIsEmpty; + + /** Returns true if the document is modifed and needs saving */ + readonly attribute boolean documentModified; + + /** + * Sets document's character set. This is available only when the editor + * instance is an HTMLEditor since it's odd to change character set of + * parent document of `` and `