2002-03-15 01:11:14 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2001-03-28 03:11:08 +04:00
|
|
|
*
|
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-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
#include "domstubs.idl"
|
2001-07-16 06:40:48 +04:00
|
|
|
|
2001-11-01 18:26:34 +03:00
|
|
|
interface nsIURI;
|
2007-01-07 14:01:35 +03:00
|
|
|
interface nsIContent;
|
2001-07-16 06:40:48 +04:00
|
|
|
interface nsISelectionController;
|
|
|
|
interface nsIDocumentStateListener;
|
|
|
|
interface nsIOutputStream;
|
|
|
|
interface nsITransactionManager;
|
|
|
|
interface nsITransaction;
|
2012-11-14 23:23:35 +04:00
|
|
|
interface nsIEditorObserver;
|
2001-07-16 06:40:48 +04:00
|
|
|
interface nsIEditActionListener;
|
2005-02-02 00:12:53 +03:00
|
|
|
interface nsIInlineSpellChecker;
|
2010-01-11 04:45:45 +03:00
|
|
|
interface nsITransferable;
|
2001-04-13 03:37:08 +04:00
|
|
|
|
2018-05-11 20:46:15 +03:00
|
|
|
webidl Document;
|
2018-04-27 06:35:18 +03:00
|
|
|
webidl Element;
|
2018-05-24 20:18:34 +03:00
|
|
|
webidl Node;
|
2018-05-08 20:52:36 +03:00
|
|
|
webidl Selection;
|
2018-04-27 06:35:18 +03:00
|
|
|
|
2016-12-20 15:47:31 +03:00
|
|
|
%{C++
|
|
|
|
namespace mozilla {
|
2017-08-04 09:01:36 +03:00
|
|
|
class EditorBase;
|
|
|
|
class HTMLEditor;
|
|
|
|
class TextEditor;
|
2016-12-20 15:47:31 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
%}
|
|
|
|
|
2017-08-04 07:57:56 +03:00
|
|
|
[scriptable, builtinclass, uuid(094be624-f0bf-400f-89e2-6a84baab9474)]
|
2001-03-28 03:11:08 +04:00
|
|
|
interface nsIEditor : nsISupports
|
|
|
|
{
|
|
|
|
%{C++
|
|
|
|
typedef short EDirection;
|
2012-05-10 18:54:33 +04:00
|
|
|
typedef short EStripWrappers;
|
2001-03-28 03:11:08 +04:00
|
|
|
%}
|
|
|
|
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;
|
|
|
|
|
2012-05-10 18:54:33 +04:00
|
|
|
const short eStrip = 0;
|
|
|
|
const short eNoStrip = 1;
|
|
|
|
|
2018-05-08 20:52:36 +03:00
|
|
|
readonly attribute Selection selection;
|
2002-03-15 01:11:14 +03:00
|
|
|
|
2018-04-27 06:35:18 +03:00
|
|
|
void setAttributeOrEquivalent(in Element element,
|
2002-03-15 01:11:14 +03:00
|
|
|
in AString sourceAttrName,
|
2002-09-17 16:04:59 +04:00
|
|
|
in AString sourceAttrValue,
|
|
|
|
in boolean aSuppressTransaction);
|
2018-04-27 06:35:18 +03:00
|
|
|
void removeAttributeOrEquivalent(in Element element,
|
2018-09-06 11:02:43 +03:00
|
|
|
in AString sourceAttrName,
|
2002-09-17 16:04:59 +04:00
|
|
|
in boolean aSuppressTransaction);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2002-03-15 01:11:14 +03:00
|
|
|
/** edit flags for this editor. May be set at any time. */
|
|
|
|
attribute unsigned long flags;
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2002-09-18 23:42:38 +04:00
|
|
|
/**
|
|
|
|
* the MimeType of the document
|
|
|
|
*/
|
|
|
|
attribute string contentsMIMEType;
|
|
|
|
|
|
|
|
/** Returns true if we have a document that is not marked read-only */
|
|
|
|
readonly attribute boolean isDocumentEditable;
|
|
|
|
|
2011-08-17 21:28:03 +04:00
|
|
|
/** Returns true if the current selection anchor is editable */
|
|
|
|
readonly attribute boolean isSelectionEditable;
|
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* the DOM Document this editor is associated with, refcounted.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2018-05-11 20:46:15 +03:00
|
|
|
readonly attribute Document document;
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2002-03-15 01:11:14 +03:00
|
|
|
/** the body element, i.e. the root of the editable document.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2018-04-27 06:35:18 +03:00
|
|
|
readonly attribute Element rootElement;
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2002-03-15 01:11:14 +03:00
|
|
|
/**
|
|
|
|
* the selection controller for the current presentation, refcounted.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
readonly attribute nsISelectionController selectionController;
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
|
|
|
|
/* ------------ Selected content removal -------------- */
|
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2001-03-28 03:11:08 +04:00
|
|
|
* DeleteSelection removes all nodes in the current selection.
|
2002-09-18 23:42:38 +04:00
|
|
|
* @param aDir if eNext, delete to the right (for example, the DEL key)
|
|
|
|
* if ePrevious, delete to the left (for example, the BACKSPACE key)
|
2012-05-10 18:54:33 +04:00
|
|
|
* @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.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2012-05-10 18:54:33 +04:00
|
|
|
void deleteSelection(in short action, in short stripWrappers);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
|
|
|
|
/* ------------ Document info and file methods -------------- */
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/** Returns true if the document has no *meaningful* content */
|
2002-03-15 01:11:14 +03:00
|
|
|
readonly attribute boolean documentIsEmpty;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/** Returns true if the document is modifed and needs saving */
|
2002-03-15 01:11:14 +03:00
|
|
|
readonly attribute boolean documentModified;
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Sets the current 'Save' document character set */
|
2003-06-17 20:40:34 +04:00
|
|
|
attribute ACString documentCharacterSet;
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2002-03-15 01:11:14 +03:00
|
|
|
/** to be used ONLY when we need to override the doc's modification
|
|
|
|
* state (such as when it's saved).
|
2001-12-10 18:23:11 +03:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void resetModificationCount();
|
2001-12-10 18:23:11 +03:00
|
|
|
|
2002-03-15 01:11:14 +03:00
|
|
|
/** Gets the modification count of the document we are editing.
|
|
|
|
* @return the modification count of the document being edited.
|
|
|
|
* Zero means unchanged.
|
2001-12-10 18:23:11 +03:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
long getModificationCount();
|
2001-12-10 18:23:11 +03:00
|
|
|
|
2002-03-15 01:11:14 +03:00
|
|
|
/** called each time we modify the document.
|
|
|
|
* Increments the modification count of the document.
|
|
|
|
* @param aModCount the number of modifications by which
|
|
|
|
* to increase or decrease the count
|
2001-12-10 18:23:11 +03:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void incrementModificationCount(in long aModCount);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/* ------------ Transaction methods -------------- */
|
|
|
|
|
2002-03-15 01:11:14 +03:00
|
|
|
/** transactionManager Get the transaction manager the editor is using.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2017-03-21 14:57:15 +03:00
|
|
|
readonly attribute nsITransactionManager transactionManager;
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2003-04-05 00:50:25 +04:00
|
|
|
/** doTransaction() fires a transaction.
|
2002-03-15 01:11:14 +03:00
|
|
|
* It is provided here so clients can create their own transactions.
|
2015-05-28 18:58:42 +03:00
|
|
|
* If a transaction manager is present, it is used.
|
2001-03-28 03:11:08 +04:00
|
|
|
* Otherwise, the transaction is just executed directly.
|
|
|
|
*
|
|
|
|
* @param aTxn the transaction to execute
|
|
|
|
*/
|
2003-04-05 00:50:25 +04:00
|
|
|
void doTransaction(in nsITransaction txn);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
|
|
|
|
/** turn the undo system on or off
|
2012-10-25 20:32:24 +04:00
|
|
|
* @param aEnable if PR_TRUE, the undo system is turned on if available
|
|
|
|
* if PR_FALSE the undo system is turned off if it
|
2002-03-15 01:11:14 +03:00
|
|
|
* was previously on
|
2012-10-25 20:32:24 +04:00
|
|
|
* @return if aEnable is PR_TRUE, returns NS_OK if
|
2002-03-15 01:11:14 +03:00
|
|
|
* the undo system could be initialized properly
|
2012-10-25 20:32:24 +04:00
|
|
|
* if aEnable is PR_FALSE, returns NS_OK.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void enableUndo(in boolean enable);
|
|
|
|
|
|
|
|
/** undo reverses the effects of the last Do operation,
|
|
|
|
* if Undo is enabled in the editor.
|
|
|
|
* It is provided here so clients need no knowledge of whether
|
|
|
|
* the editor has a transaction manager or not.
|
|
|
|
* If a transaction manager is present, it is told to undo,
|
2015-05-28 18:58:42 +03:00
|
|
|
* and the result of that undo is returned.
|
2002-03-15 01:11:14 +03:00
|
|
|
* Otherwise, the Undo request is ignored and an
|
|
|
|
* error NS_ERROR_NOT_AVAILABLE is returned.
|
2001-03-28 03:11:08 +04:00
|
|
|
*
|
|
|
|
*/
|
2019-03-12 04:50:41 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void undo(in unsigned long count);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** returns state information about the undo system.
|
2012-10-25 20:32:24 +04:00
|
|
|
* @param aIsEnabled [OUT] PR_TRUE if undo is enabled
|
|
|
|
* @param aCanUndo [OUT] PR_TRUE if at least one transaction is
|
2002-03-15 01:11:14 +03:00
|
|
|
* currently ready to be undone.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void canUndo(out boolean isEnabled, out boolean canUndo);
|
|
|
|
|
|
|
|
/** redo reverses the effects of the last Undo operation
|
|
|
|
* It is provided here so clients need no knowledge of whether
|
|
|
|
* the editor has a transaction manager or not.
|
|
|
|
* If a transaction manager is present, it is told to redo and the
|
|
|
|
* result of the previously undone transaction is reapplied to the document.
|
|
|
|
* If no transaction is available for Redo, or if the document
|
|
|
|
* has no transaction manager, the Redo request is ignored and an
|
|
|
|
* error NS_ERROR_NOT_AVAILABLE is returned.
|
2001-03-28 03:11:08 +04:00
|
|
|
*
|
|
|
|
*/
|
2019-03-12 04:50:41 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void redo(in unsigned long count);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** returns state information about the redo system.
|
2012-10-25 20:32:24 +04:00
|
|
|
* @param aIsEnabled [OUT] PR_TRUE if redo is enabled
|
|
|
|
* @param aCanRedo [OUT] PR_TRUE if at least one transaction is
|
2002-03-15 01:11:14 +03:00
|
|
|
currently ready to be redone.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void canRedo(out boolean isEnabled, out boolean canRedo);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2002-03-15 01:11:14 +03:00
|
|
|
/** beginTransaction is a signal from the caller to the editor that
|
|
|
|
* the caller will execute multiple updates to the content tree
|
|
|
|
* that should be treated as a single logical operation,
|
2001-03-28 03:11:08 +04:00
|
|
|
* in the most efficient way possible.<br>
|
2002-03-15 01:11:14 +03:00
|
|
|
* All transactions executed between a call to beginTransaction and
|
|
|
|
* endTransaction will be undoable as an atomic action.<br>
|
|
|
|
* endTransaction must be called after beginTransaction.<br>
|
|
|
|
* Calls to beginTransaction can be nested, as long as endTransaction
|
|
|
|
* is called once per beginUpdate.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void beginTransaction();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2002-03-15 01:11:14 +03:00
|
|
|
/** endTransaction is a signal to the editor that the caller is
|
|
|
|
* finished updating the content model.<br>
|
|
|
|
* beginUpdate must be called before endTransaction is called.<br>
|
|
|
|
* Calls to beginTransaction can be nested, as long as endTransaction
|
|
|
|
* is called once per beginTransaction.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void endTransaction();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2018-08-01 14:16:30 +03:00
|
|
|
/**
|
|
|
|
* While setting the flag with this method to false, CreateElementTransaction,
|
|
|
|
* DeleteRangeTransaction, DeleteTextTransaction, InsertNodeTransaction,
|
|
|
|
* InsertTextTransaction and SplitNodeTransaction won't change Selection
|
|
|
|
* after modifying the DOM tree.
|
|
|
|
* Note that calling this with false does not guarantee that Selection won't
|
|
|
|
* be changed because other transaction may ignore this flag, editor itself
|
|
|
|
* may change selection, and current selection may become invalid after
|
|
|
|
* changing the DOM tree, etc.
|
|
|
|
* After calling this method with true, the caller should guarantee that
|
|
|
|
* Selection should be positioned where user expects.
|
|
|
|
*
|
|
|
|
* @param should false if you don't want above transactions to modify
|
|
|
|
* Selection automatically after modifying the DOM tree.
|
|
|
|
* Note that calling this with false does not guarantee
|
|
|
|
* that Selection is never changed.
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void setShouldTxnSetSelection(in boolean should);
|
2001-04-12 07:41:06 +04:00
|
|
|
|
2005-02-02 00:12:53 +03:00
|
|
|
/* ------------ Inline Spell Checking methods -------------- */
|
|
|
|
|
2005-12-05 21:07:33 +03:00
|
|
|
/** Returns the inline spell checker associated with this object. The spell
|
|
|
|
* checker is lazily created, so this function may create the object for
|
|
|
|
* you during this call.
|
|
|
|
* @param autoCreate If true, this will create a spell checker object
|
|
|
|
* if one does not exist yet for this editor. If false
|
|
|
|
* and the object has not been created, this function
|
|
|
|
* WILL RETURN NULL.
|
|
|
|
*/
|
|
|
|
nsIInlineSpellChecker getInlineSpellChecker(in boolean autoCreate);
|
2005-02-02 00:12:53 +03:00
|
|
|
|
2006-07-29 04:04:40 +04:00
|
|
|
/** Called when the user manually overrides the spellchecking state for this
|
|
|
|
* editor.
|
|
|
|
* @param enable The new state of spellchecking in this editor, as
|
|
|
|
* requested by the user.
|
|
|
|
*/
|
|
|
|
void setSpellcheckUserOverride(in boolean enable);
|
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/* ------------ Clipboard methods -------------- */
|
|
|
|
|
|
|
|
/** cut the currently selected text, putting it into the OS clipboard
|
|
|
|
* What if no text is selected?
|
|
|
|
* What about mixed selections?
|
|
|
|
* What are the clipboard formats?
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void cut();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Can we cut? True if the doc is modifiable, and we have a non-
|
|
|
|
* collapsed selection.
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
boolean canCut();
|
2015-01-16 00:47:56 +03:00
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/** copy the currently selected text, putting it into the OS clipboard
|
|
|
|
* What if no text is selected?
|
|
|
|
* What about mixed selections?
|
|
|
|
* What are the clipboard formats?
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void copy();
|
2015-01-16 00:47:56 +03:00
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/** Can we copy? True if we have a non-collapsed selection.
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
boolean canCopy();
|
2015-01-16 00:47:56 +03:00
|
|
|
|
|
|
|
/** Can we delete? True if we have a non-collapsed selection.
|
|
|
|
*/
|
|
|
|
boolean canDelete();
|
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/** paste the text in the OS clipboard at the cursor position, replacing
|
|
|
|
* the selected text (if any)
|
|
|
|
*/
|
2019-03-12 04:55:03 +03:00
|
|
|
[can_run_script]
|
2002-03-15 01:11:14 +03:00
|
|
|
void paste(in long aSelectionType);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2010-01-11 04:45:45 +03:00
|
|
|
/** Paste the text in |aTransferable| at the cursor position, replacing the
|
|
|
|
* selected text (if any).
|
|
|
|
*/
|
2019-03-12 04:55:03 +03:00
|
|
|
[can_run_script]
|
2010-01-11 04:45:45 +03:00
|
|
|
void pasteTransferable(in nsITransferable aTransferable);
|
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/** Can we paste? True if the doc is modifiable, and we have
|
|
|
|
* pasteable data in the clipboard.
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
boolean canPaste(in long aSelectionType);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/* ------------ Selection methods -------------- */
|
|
|
|
|
|
|
|
/** sets the document selection to the entire contents of the document */
|
2002-03-15 01:11:14 +03:00
|
|
|
void selectAll();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
Bug 662591 - HTMLEditor should set caret to start of first editable text node or before first editable inline node r=m_kato
Currently, HTMLEditor doesn't initialize caret position when it gets focus by
itself in most cases. Only when it's in designMode, it may move caret to the
first visible (not checking CSS actually).
In most cases, caret position is adjusted when EditorBase::InitializeSelection()
calls Selection::SetAncestorLimiter(). If selected range is outside of
new limiter, it moves caret to start of the new limiter. However, this is
really different behavior from the other browsers. The other browsers try
to move caret to the first editable text node or before the first editable
content such as <img>, <input>, etc.
This difference causes a serious incompatible issue with Draft.js. It doesn't
initialize caret position when it gets focus but it assumes that caret is
always set to before <br> element if there is no other content.
So, let's try to behave as what other browsers do as far as possible.
This patch makes editor behave as:
* if selection is already in the editing host except start of the editing host,
does nothing.
* if there is non-editable element before any editable node, move caret to
start of the editing host.
* if there is editable text node or element node which cannot have a text node,
move its start or before it.
* if there is no editable nodes which can contain text nodes, move caret to
start of the editing host.
Note that before applying this patch, in designMode, BeginningOfDocument() used
document element instead of <body> element. Therefore, it may set odd position
if <head> element has some text nodes with <script> or <style>. However,
this doesn't make sense and for making more consistent behavior between
designMode and contenteditable, this patch makes it use editing host (it's
<body> element if it's in designMode).
MozReview-Commit-ID: 5neYoTMq6Cc
--HG--
extra : rebase_source : c4d06b6864a221d7cd2833a007d73f7d67821e95
2018-03-02 08:20:25 +03:00
|
|
|
/**
|
|
|
|
* Collapses selection at start of the document. If it's an HTML editor,
|
|
|
|
* collapses selection at start of current editing host (<body> element if
|
|
|
|
* it's in designMode) instead. If there is a non-editable node before any
|
|
|
|
* editable text nodes or inline elements which can have text nodes as their
|
|
|
|
* children, collapses selection at start of the editing host. If there is
|
|
|
|
* an editable text node which is not collapsed, collapses selection at
|
|
|
|
* start of the text node. If there is an editable inline element which
|
|
|
|
* cannot have text nodes as its child, collapses selection at before the
|
|
|
|
* element node. Otherwise, collapses selection at start of the editing
|
|
|
|
* host.
|
|
|
|
*/
|
2002-03-15 01:11:14 +03:00
|
|
|
void beginningOfDocument();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** sets the document selection to the end of the document */
|
2002-03-15 01:11:14 +03:00
|
|
|
void endOfDocument();
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/* ------------ Node manipulation methods -------------- */
|
|
|
|
|
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* setAttribute() sets the attribute of aElement.
|
2001-03-28 03:11:08 +04:00
|
|
|
* No checking is done to see if aAttribute is a legal attribute of the node,
|
|
|
|
* or if aValue is a legal value of aAttribute.
|
|
|
|
*
|
|
|
|
* @param aElement the content element to operate on
|
|
|
|
* @param aAttribute the string representation of the attribute to set
|
|
|
|
* @param aValue the value to set aAttribute to
|
|
|
|
*/
|
2018-04-27 06:35:18 +03:00
|
|
|
void setAttribute(in Element aElement, in AString attributestr,
|
2002-03-15 01:11:14 +03:00
|
|
|
in AString attvalue);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* getAttributeValue() retrieves the attribute's value for aElement.
|
2001-03-28 03:11:08 +04:00
|
|
|
*
|
|
|
|
* @param aElement the content element to operate on
|
|
|
|
* @param aAttribute the string representation of the attribute to get
|
2002-03-15 01:11:14 +03:00
|
|
|
* @param aResultValue [OUT] the value of aAttribute.
|
2012-10-25 20:32:24 +04:00
|
|
|
* Only valid if aResultIsSet is PR_TRUE
|
|
|
|
* @return PR_TRUE if aAttribute is set on the current node,
|
|
|
|
* PR_FALSE if it is not.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2018-04-27 06:35:18 +03:00
|
|
|
boolean getAttributeValue(in Element aElement,
|
2015-05-28 18:58:42 +03:00
|
|
|
in AString attributestr,
|
2002-03-15 01:11:14 +03:00
|
|
|
out AString resultValue);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* removeAttribute() deletes aAttribute from the attribute list of aElement.
|
2001-03-28 03:11:08 +04:00
|
|
|
* If aAttribute is not an attribute of aElement, nothing is done.
|
|
|
|
*
|
|
|
|
* @param aElement the content element to operate on
|
|
|
|
* @param aAttribute the string representation of the attribute to get
|
|
|
|
*/
|
2018-04-27 06:35:18 +03:00
|
|
|
void removeAttribute(in Element aElement,
|
2002-03-15 01:11:14 +03:00
|
|
|
in AString aAttribute);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2003-06-17 12:45:54 +04:00
|
|
|
/**
|
|
|
|
* cloneAttribute() copies the attribute from the source node to
|
|
|
|
* the destination node and delete those not in the source.
|
|
|
|
*
|
|
|
|
* The supplied nodes MUST BE ELEMENTS (most callers are working with nodes)
|
2018-05-24 20:18:34 +03:00
|
|
|
* @param aAttribute the name of the attribute to copy
|
|
|
|
* @param aDestElement the destination element to operate on
|
|
|
|
* @param aSourceElement the source element to copy attributes from
|
|
|
|
* @exception NS_ERROR_NULL_POINTER at least one of the elements is null
|
2003-06-17 12:45:54 +04:00
|
|
|
*/
|
|
|
|
void cloneAttribute(in AString aAttribute,
|
2018-05-24 20:18:34 +03:00
|
|
|
in Element aDestElement, in Element aSourceElement);
|
2003-06-17 12:45:54 +04:00
|
|
|
|
2001-03-28 03:11:08 +04:00
|
|
|
/**
|
2018-05-24 20:18:34 +03:00
|
|
|
* cloneAttributes() is similar to Node::cloneNode(),
|
2002-03-15 01:11:14 +03:00
|
|
|
* it assures the attribute nodes of the destination are identical
|
|
|
|
* with the source node by copying all existing attributes from the
|
|
|
|
* source and deleting those not in the source.
|
2018-05-24 20:18:34 +03:00
|
|
|
* This is used when the destination element already exists
|
2001-03-28 03:11:08 +04:00
|
|
|
*
|
|
|
|
* @param aDestNode the destination element to operate on
|
|
|
|
* @param aSourceNode the source element to copy attributes from
|
|
|
|
*/
|
2018-05-24 20:18:34 +03:00
|
|
|
void cloneAttributes(in Element aDestElement, in Element aSourceElement);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* insertNode inserts aNode into aParent at aPosition.
|
|
|
|
* No checking is done to verify the legality of the insertion.
|
|
|
|
* That is the responsibility of the caller.
|
2001-03-28 03:11:08 +04:00
|
|
|
* @param aNode The DOM Node to insert.
|
|
|
|
* @param aParent The node to insert the new object into
|
|
|
|
* @param aPosition The place in aParent to insert the new node
|
|
|
|
* 0=first child, 1=second child, etc.
|
|
|
|
* any number > number of current children = last child
|
|
|
|
*/
|
2018-05-24 20:18:34 +03:00
|
|
|
void insertNode(in Node node,
|
|
|
|
in Node parent,
|
|
|
|
in long aPosition);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* splitNode() creates a new node identical to an existing node,
|
|
|
|
* and split the contents between the two nodes
|
|
|
|
* @param aExistingRightNode the node to split.
|
|
|
|
* It will become the new node's next sibling.
|
|
|
|
* @param aOffset the offset of aExistingRightNode's
|
|
|
|
* content|children to do the split at
|
|
|
|
* @param aNewLeftNode [OUT] the new node resulting from the split,
|
|
|
|
* becomes aExistingRightNode's previous sibling.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2018-05-24 20:18:34 +03:00
|
|
|
void splitNode(in Node existingRightNode,
|
|
|
|
in long offset,
|
|
|
|
out Node newLeftNode);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* joinNodes() takes 2 nodes and merge their content|children.
|
2001-03-28 03:11:08 +04:00
|
|
|
* @param aLeftNode The left node. It will be deleted.
|
|
|
|
* @param aRightNode The right node. It will remain after the join.
|
|
|
|
* @param aParent The parent of aExistingRightNode
|
|
|
|
*
|
2002-03-15 01:11:14 +03:00
|
|
|
* There is no requirement that the two nodes be
|
|
|
|
* of the same type. However, a text node can be
|
|
|
|
* merged only with another text node.
|
2001-03-28 03:11:08 +04:00
|
|
|
*/
|
2018-05-24 20:18:34 +03:00
|
|
|
void joinNodes(in Node leftNode,
|
|
|
|
in Node rightNode,
|
|
|
|
in Node parent);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* deleteNode removes aChild from aParent.
|
2001-03-28 03:11:08 +04:00
|
|
|
* @param aChild The node to delete
|
|
|
|
*/
|
2018-05-24 20:18:34 +03:00
|
|
|
void deleteNode(in Node child);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2015-05-28 18:58:42 +03:00
|
|
|
/**
|
2002-03-15 01:11:14 +03:00
|
|
|
* markNodeDirty() sets a special dirty attribute on the node.
|
2001-03-28 03:11:08 +04:00
|
|
|
* Usually this will be called immediately after creating a new node.
|
|
|
|
* @param aNode The node for which to insert formatting.
|
|
|
|
*/
|
2018-05-24 20:18:34 +03:00
|
|
|
void markNodeDirty(in Node node);
|
2002-03-15 01:11:14 +03:00
|
|
|
|
|
|
|
/* ------------ Output methods -------------- */
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Output methods:
|
|
|
|
* aFormatType is a mime type, like text/plain.
|
|
|
|
*/
|
2002-03-26 01:39:19 +03:00
|
|
|
AString outputToString(in AString formatType,
|
|
|
|
in unsigned long flags);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2007-11-08 07:02:57 +03:00
|
|
|
/* ------------ Various listeners methods --------------
|
|
|
|
* nsIEditor holds strong references to the editor observers, action listeners
|
|
|
|
* and document state listeners.
|
|
|
|
*/
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** add an EditorObserver to the editors list of observers. */
|
2012-11-14 23:23:35 +04:00
|
|
|
void addEditorObserver(in nsIEditorObserver observer);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Remove an EditorObserver from the editor's list of observers. */
|
2012-11-14 23:23:35 +04:00
|
|
|
void removeEditorObserver(in nsIEditorObserver observer);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** add an EditActionListener to the editors list of listeners. */
|
2002-03-15 01:11:14 +03:00
|
|
|
void addEditActionListener(in nsIEditActionListener listener);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Remove an EditActionListener from the editor's list of listeners. */
|
2002-03-15 01:11:14 +03:00
|
|
|
void removeEditActionListener(in nsIEditActionListener listener);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Add a DocumentStateListener to the editors list of doc state listeners. */
|
2002-03-15 01:11:14 +03:00
|
|
|
void addDocumentStateListener(in nsIDocumentStateListener listener);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
|
|
|
/** Remove a DocumentStateListener to the editors list of doc state listeners. */
|
2002-03-15 01:11:14 +03:00
|
|
|
void removeDocumentStateListener(in nsIDocumentStateListener listener);
|
2001-03-28 03:11:08 +04:00
|
|
|
|
2016-12-20 15:47:31 +03:00
|
|
|
/**
|
|
|
|
* forceCompositionEnd() force the composition end
|
|
|
|
*/
|
|
|
|
void forceCompositionEnd();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* whether this editor has active IME transaction
|
|
|
|
*/
|
|
|
|
readonly attribute boolean composing;
|
2017-08-04 09:01:36 +03:00
|
|
|
|
|
|
|
%{C++
|
|
|
|
/**
|
|
|
|
* AsEditorBase() returns a pointer to EditorBase class.
|
|
|
|
*
|
|
|
|
* In order to avoid circular dependency issues, this method is defined
|
|
|
|
* in mozilla/EditorBase.h. Consumers need to #include that header.
|
|
|
|
*/
|
|
|
|
inline mozilla::EditorBase* AsEditorBase();
|
|
|
|
inline const mozilla::EditorBase* AsEditorBase() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AsTextEditor() returns a pointer to TextEditor class.
|
|
|
|
*
|
|
|
|
* In order to avoid circular dependency issues, this method is defined
|
|
|
|
* in mozilla/TextEditor.h. Consumers need to #include that header.
|
|
|
|
*/
|
|
|
|
inline mozilla::TextEditor* AsTextEditor();
|
|
|
|
inline const mozilla::TextEditor* AsTextEditor() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AsHTMLEditor() returns a pointer to HTMLEditor class.
|
|
|
|
*
|
|
|
|
* In order to avoid circular dependency issues, this method is defined
|
|
|
|
* in mozilla/HTMLEditor.h. Consumers need to #include that header.
|
|
|
|
*/
|
|
|
|
inline mozilla::HTMLEditor* AsHTMLEditor();
|
|
|
|
inline const mozilla::HTMLEditor* AsHTMLEditor() const;
|
|
|
|
%}
|
2010-12-07 09:30:05 +03:00
|
|
|
};
|