Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsISupports.idl" |
michael@0 | 8 | #include "domstubs.idl" |
michael@0 | 9 | |
michael@0 | 10 | interface nsIURI; |
michael@0 | 11 | interface nsIAtom; |
michael@0 | 12 | interface nsIContent; |
michael@0 | 13 | interface nsISelection; |
michael@0 | 14 | interface nsISelectionController; |
michael@0 | 15 | interface nsIDocumentStateListener; |
michael@0 | 16 | interface nsIOutputStream; |
michael@0 | 17 | interface nsITransactionManager; |
michael@0 | 18 | interface nsITransaction; |
michael@0 | 19 | interface nsIEditorObserver; |
michael@0 | 20 | interface nsIEditActionListener; |
michael@0 | 21 | interface nsIInlineSpellChecker; |
michael@0 | 22 | interface nsITransferable; |
michael@0 | 23 | |
michael@0 | 24 | [scriptable, uuid(65523eab-db1f-44aa-893e-dfe57ad306f0)] |
michael@0 | 25 | |
michael@0 | 26 | interface nsIEditor : nsISupports |
michael@0 | 27 | { |
michael@0 | 28 | %{C++ |
michael@0 | 29 | typedef short EDirection; |
michael@0 | 30 | typedef short EStripWrappers; |
michael@0 | 31 | %} |
michael@0 | 32 | const short eNone = 0; |
michael@0 | 33 | const short eNext = 1; |
michael@0 | 34 | const short ePrevious = 2; |
michael@0 | 35 | const short eNextWord = 3; |
michael@0 | 36 | const short ePreviousWord = 4; |
michael@0 | 37 | const short eToBeginningOfLine = 5; |
michael@0 | 38 | const short eToEndOfLine = 6; |
michael@0 | 39 | |
michael@0 | 40 | const short eStrip = 0; |
michael@0 | 41 | const short eNoStrip = 1; |
michael@0 | 42 | |
michael@0 | 43 | readonly attribute nsISelection selection; |
michael@0 | 44 | |
michael@0 | 45 | /** |
michael@0 | 46 | * Init is to tell the implementation of nsIEditor to begin its services |
michael@0 | 47 | * @param aDoc The dom document interface being observed |
michael@0 | 48 | * @param aRoot This is the root of the editable section of this |
michael@0 | 49 | * document. If it is null then we get root |
michael@0 | 50 | * from document body. |
michael@0 | 51 | * @param aSelCon this should be used to get the selection location |
michael@0 | 52 | * (will be null for HTML editors) |
michael@0 | 53 | * @param aFlags A bitmask of flags for specifying the behavior |
michael@0 | 54 | * of the editor. |
michael@0 | 55 | */ |
michael@0 | 56 | [noscript] void init(in nsIDOMDocument doc, |
michael@0 | 57 | in nsIContent aRoot, |
michael@0 | 58 | in nsISelectionController aSelCon, |
michael@0 | 59 | in unsigned long aFlags, |
michael@0 | 60 | in AString initialValue); |
michael@0 | 61 | |
michael@0 | 62 | void setAttributeOrEquivalent(in nsIDOMElement element, |
michael@0 | 63 | in AString sourceAttrName, |
michael@0 | 64 | in AString sourceAttrValue, |
michael@0 | 65 | in boolean aSuppressTransaction); |
michael@0 | 66 | void removeAttributeOrEquivalent(in nsIDOMElement element, |
michael@0 | 67 | in DOMString sourceAttrName, |
michael@0 | 68 | in boolean aSuppressTransaction); |
michael@0 | 69 | |
michael@0 | 70 | /** |
michael@0 | 71 | * postCreate should be called after Init, and is the time that the editor |
michael@0 | 72 | * tells its documentStateObservers that the document has been created. |
michael@0 | 73 | */ |
michael@0 | 74 | void postCreate(); |
michael@0 | 75 | |
michael@0 | 76 | /** |
michael@0 | 77 | * preDestroy is called before the editor goes away, and gives the editor a |
michael@0 | 78 | * chance to tell its documentStateObservers that the document is going away. |
michael@0 | 79 | * @param aDestroyingFrames set to true when the frames being edited |
michael@0 | 80 | * are being destroyed (so there is no need to modify any nsISelections, |
michael@0 | 81 | * nor is it safe to do so) |
michael@0 | 82 | */ |
michael@0 | 83 | void preDestroy(in boolean aDestroyingFrames); |
michael@0 | 84 | |
michael@0 | 85 | /** edit flags for this editor. May be set at any time. */ |
michael@0 | 86 | attribute unsigned long flags; |
michael@0 | 87 | |
michael@0 | 88 | /** |
michael@0 | 89 | * the MimeType of the document |
michael@0 | 90 | */ |
michael@0 | 91 | attribute string contentsMIMEType; |
michael@0 | 92 | |
michael@0 | 93 | /** Returns true if we have a document that is not marked read-only */ |
michael@0 | 94 | readonly attribute boolean isDocumentEditable; |
michael@0 | 95 | |
michael@0 | 96 | /** Returns true if the current selection anchor is editable */ |
michael@0 | 97 | readonly attribute boolean isSelectionEditable; |
michael@0 | 98 | |
michael@0 | 99 | /** |
michael@0 | 100 | * the DOM Document this editor is associated with, refcounted. |
michael@0 | 101 | */ |
michael@0 | 102 | readonly attribute nsIDOMDocument document; |
michael@0 | 103 | |
michael@0 | 104 | /** the body element, i.e. the root of the editable document. |
michael@0 | 105 | */ |
michael@0 | 106 | readonly attribute nsIDOMElement rootElement; |
michael@0 | 107 | |
michael@0 | 108 | /** |
michael@0 | 109 | * the selection controller for the current presentation, refcounted. |
michael@0 | 110 | */ |
michael@0 | 111 | readonly attribute nsISelectionController selectionController; |
michael@0 | 112 | |
michael@0 | 113 | |
michael@0 | 114 | /* ------------ Selected content removal -------------- */ |
michael@0 | 115 | |
michael@0 | 116 | /** |
michael@0 | 117 | * DeleteSelection removes all nodes in the current selection. |
michael@0 | 118 | * @param aDir if eNext, delete to the right (for example, the DEL key) |
michael@0 | 119 | * if ePrevious, delete to the left (for example, the BACKSPACE key) |
michael@0 | 120 | * @param stripWrappers If eStrip, strip any empty inline elements left |
michael@0 | 121 | * behind after the deletion; if eNoStrip, don't. If in |
michael@0 | 122 | * doubt, pass eStrip -- eNoStrip is only for if you're |
michael@0 | 123 | * about to insert text or similar right after. |
michael@0 | 124 | */ |
michael@0 | 125 | void deleteSelection(in short action, in short stripWrappers); |
michael@0 | 126 | |
michael@0 | 127 | |
michael@0 | 128 | /* ------------ Document info and file methods -------------- */ |
michael@0 | 129 | |
michael@0 | 130 | /** Returns true if the document has no *meaningful* content */ |
michael@0 | 131 | readonly attribute boolean documentIsEmpty; |
michael@0 | 132 | |
michael@0 | 133 | /** Returns true if the document is modifed and needs saving */ |
michael@0 | 134 | readonly attribute boolean documentModified; |
michael@0 | 135 | |
michael@0 | 136 | /** Sets the current 'Save' document character set */ |
michael@0 | 137 | attribute ACString documentCharacterSet; |
michael@0 | 138 | |
michael@0 | 139 | /** to be used ONLY when we need to override the doc's modification |
michael@0 | 140 | * state (such as when it's saved). |
michael@0 | 141 | */ |
michael@0 | 142 | void resetModificationCount(); |
michael@0 | 143 | |
michael@0 | 144 | /** Gets the modification count of the document we are editing. |
michael@0 | 145 | * @return the modification count of the document being edited. |
michael@0 | 146 | * Zero means unchanged. |
michael@0 | 147 | */ |
michael@0 | 148 | long getModificationCount(); |
michael@0 | 149 | |
michael@0 | 150 | /** called each time we modify the document. |
michael@0 | 151 | * Increments the modification count of the document. |
michael@0 | 152 | * @param aModCount the number of modifications by which |
michael@0 | 153 | * to increase or decrease the count |
michael@0 | 154 | */ |
michael@0 | 155 | void incrementModificationCount(in long aModCount); |
michael@0 | 156 | |
michael@0 | 157 | /* ------------ Transaction methods -------------- */ |
michael@0 | 158 | |
michael@0 | 159 | /** transactionManager Get the transaction manager the editor is using. |
michael@0 | 160 | */ |
michael@0 | 161 | attribute nsITransactionManager transactionManager; |
michael@0 | 162 | |
michael@0 | 163 | /** doTransaction() fires a transaction. |
michael@0 | 164 | * It is provided here so clients can create their own transactions. |
michael@0 | 165 | * If a transaction manager is present, it is used. |
michael@0 | 166 | * Otherwise, the transaction is just executed directly. |
michael@0 | 167 | * |
michael@0 | 168 | * @param aTxn the transaction to execute |
michael@0 | 169 | */ |
michael@0 | 170 | void doTransaction(in nsITransaction txn); |
michael@0 | 171 | |
michael@0 | 172 | |
michael@0 | 173 | /** turn the undo system on or off |
michael@0 | 174 | * @param aEnable if PR_TRUE, the undo system is turned on if available |
michael@0 | 175 | * if PR_FALSE the undo system is turned off if it |
michael@0 | 176 | * was previously on |
michael@0 | 177 | * @return if aEnable is PR_TRUE, returns NS_OK if |
michael@0 | 178 | * the undo system could be initialized properly |
michael@0 | 179 | * if aEnable is PR_FALSE, returns NS_OK. |
michael@0 | 180 | */ |
michael@0 | 181 | void enableUndo(in boolean enable); |
michael@0 | 182 | |
michael@0 | 183 | /** |
michael@0 | 184 | * The number of items on the undo stack. |
michael@0 | 185 | */ |
michael@0 | 186 | readonly attribute long numberOfUndoItems; |
michael@0 | 187 | |
michael@0 | 188 | /** |
michael@0 | 189 | * The number of items on the redo stack. |
michael@0 | 190 | */ |
michael@0 | 191 | readonly attribute long numberOfRedoItems; |
michael@0 | 192 | |
michael@0 | 193 | /** undo reverses the effects of the last Do operation, |
michael@0 | 194 | * if Undo is enabled in the editor. |
michael@0 | 195 | * It is provided here so clients need no knowledge of whether |
michael@0 | 196 | * the editor has a transaction manager or not. |
michael@0 | 197 | * If a transaction manager is present, it is told to undo, |
michael@0 | 198 | * and the result of that undo is returned. |
michael@0 | 199 | * Otherwise, the Undo request is ignored and an |
michael@0 | 200 | * error NS_ERROR_NOT_AVAILABLE is returned. |
michael@0 | 201 | * |
michael@0 | 202 | */ |
michael@0 | 203 | void undo(in unsigned long count); |
michael@0 | 204 | |
michael@0 | 205 | /** returns state information about the undo system. |
michael@0 | 206 | * @param aIsEnabled [OUT] PR_TRUE if undo is enabled |
michael@0 | 207 | * @param aCanUndo [OUT] PR_TRUE if at least one transaction is |
michael@0 | 208 | * currently ready to be undone. |
michael@0 | 209 | */ |
michael@0 | 210 | void canUndo(out boolean isEnabled, out boolean canUndo); |
michael@0 | 211 | |
michael@0 | 212 | /** redo reverses the effects of the last Undo operation |
michael@0 | 213 | * It is provided here so clients need no knowledge of whether |
michael@0 | 214 | * the editor has a transaction manager or not. |
michael@0 | 215 | * If a transaction manager is present, it is told to redo and the |
michael@0 | 216 | * result of the previously undone transaction is reapplied to the document. |
michael@0 | 217 | * If no transaction is available for Redo, or if the document |
michael@0 | 218 | * has no transaction manager, the Redo request is ignored and an |
michael@0 | 219 | * error NS_ERROR_NOT_AVAILABLE is returned. |
michael@0 | 220 | * |
michael@0 | 221 | */ |
michael@0 | 222 | void redo(in unsigned long count); |
michael@0 | 223 | |
michael@0 | 224 | /** returns state information about the redo system. |
michael@0 | 225 | * @param aIsEnabled [OUT] PR_TRUE if redo is enabled |
michael@0 | 226 | * @param aCanRedo [OUT] PR_TRUE if at least one transaction is |
michael@0 | 227 | currently ready to be redone. |
michael@0 | 228 | */ |
michael@0 | 229 | void canRedo(out boolean isEnabled, out boolean canRedo); |
michael@0 | 230 | |
michael@0 | 231 | /** beginTransaction is a signal from the caller to the editor that |
michael@0 | 232 | * the caller will execute multiple updates to the content tree |
michael@0 | 233 | * that should be treated as a single logical operation, |
michael@0 | 234 | * in the most efficient way possible.<br> |
michael@0 | 235 | * All transactions executed between a call to beginTransaction and |
michael@0 | 236 | * endTransaction will be undoable as an atomic action.<br> |
michael@0 | 237 | * endTransaction must be called after beginTransaction.<br> |
michael@0 | 238 | * Calls to beginTransaction can be nested, as long as endTransaction |
michael@0 | 239 | * is called once per beginUpdate. |
michael@0 | 240 | */ |
michael@0 | 241 | void beginTransaction(); |
michael@0 | 242 | |
michael@0 | 243 | /** endTransaction is a signal to the editor that the caller is |
michael@0 | 244 | * finished updating the content model.<br> |
michael@0 | 245 | * beginUpdate must be called before endTransaction is called.<br> |
michael@0 | 246 | * Calls to beginTransaction can be nested, as long as endTransaction |
michael@0 | 247 | * is called once per beginTransaction. |
michael@0 | 248 | */ |
michael@0 | 249 | void endTransaction(); |
michael@0 | 250 | |
michael@0 | 251 | void beginPlaceHolderTransaction(in nsIAtom name); |
michael@0 | 252 | void endPlaceHolderTransaction(); |
michael@0 | 253 | boolean shouldTxnSetSelection(); |
michael@0 | 254 | |
michael@0 | 255 | /** Set the flag that prevents insertElementTxn from changing the selection |
michael@0 | 256 | * @param should Set false to suppress changing the selection; |
michael@0 | 257 | * i.e., before using InsertElement() to insert |
michael@0 | 258 | * under <head> element |
michael@0 | 259 | * WARNING: You must be very careful to reset back to PR_TRUE after |
michael@0 | 260 | * setting PR_FALSE, else selection/caret is trashed |
michael@0 | 261 | * for further editing. |
michael@0 | 262 | */ |
michael@0 | 263 | void setShouldTxnSetSelection(in boolean should); |
michael@0 | 264 | |
michael@0 | 265 | /* ------------ Inline Spell Checking methods -------------- */ |
michael@0 | 266 | |
michael@0 | 267 | /** Returns the inline spell checker associated with this object. The spell |
michael@0 | 268 | * checker is lazily created, so this function may create the object for |
michael@0 | 269 | * you during this call. |
michael@0 | 270 | * @param autoCreate If true, this will create a spell checker object |
michael@0 | 271 | * if one does not exist yet for this editor. If false |
michael@0 | 272 | * and the object has not been created, this function |
michael@0 | 273 | * WILL RETURN NULL. |
michael@0 | 274 | */ |
michael@0 | 275 | nsIInlineSpellChecker getInlineSpellChecker(in boolean autoCreate); |
michael@0 | 276 | |
michael@0 | 277 | /** Resyncs spellchecking state (enabled/disabled). This should be called |
michael@0 | 278 | * when anything that affects spellchecking state changes, such as the |
michael@0 | 279 | * spellcheck attribute value. |
michael@0 | 280 | */ |
michael@0 | 281 | void syncRealTimeSpell(); |
michael@0 | 282 | |
michael@0 | 283 | /** Called when the user manually overrides the spellchecking state for this |
michael@0 | 284 | * editor. |
michael@0 | 285 | * @param enable The new state of spellchecking in this editor, as |
michael@0 | 286 | * requested by the user. |
michael@0 | 287 | */ |
michael@0 | 288 | void setSpellcheckUserOverride(in boolean enable); |
michael@0 | 289 | |
michael@0 | 290 | /* ------------ Clipboard methods -------------- */ |
michael@0 | 291 | |
michael@0 | 292 | /** cut the currently selected text, putting it into the OS clipboard |
michael@0 | 293 | * What if no text is selected? |
michael@0 | 294 | * What about mixed selections? |
michael@0 | 295 | * What are the clipboard formats? |
michael@0 | 296 | */ |
michael@0 | 297 | void cut(); |
michael@0 | 298 | |
michael@0 | 299 | /** Can we cut? True if the doc is modifiable, and we have a non- |
michael@0 | 300 | * collapsed selection. |
michael@0 | 301 | */ |
michael@0 | 302 | boolean canCut(); |
michael@0 | 303 | |
michael@0 | 304 | /** copy the currently selected text, putting it into the OS clipboard |
michael@0 | 305 | * What if no text is selected? |
michael@0 | 306 | * What about mixed selections? |
michael@0 | 307 | * What are the clipboard formats? |
michael@0 | 308 | */ |
michael@0 | 309 | void copy(); |
michael@0 | 310 | |
michael@0 | 311 | /** Can we copy? True if we have a non-collapsed selection. |
michael@0 | 312 | */ |
michael@0 | 313 | boolean canCopy(); |
michael@0 | 314 | |
michael@0 | 315 | /** paste the text in the OS clipboard at the cursor position, replacing |
michael@0 | 316 | * the selected text (if any) |
michael@0 | 317 | */ |
michael@0 | 318 | void paste(in long aSelectionType); |
michael@0 | 319 | |
michael@0 | 320 | /** Paste the text in |aTransferable| at the cursor position, replacing the |
michael@0 | 321 | * selected text (if any). |
michael@0 | 322 | */ |
michael@0 | 323 | void pasteTransferable(in nsITransferable aTransferable); |
michael@0 | 324 | |
michael@0 | 325 | /** Can we paste? True if the doc is modifiable, and we have |
michael@0 | 326 | * pasteable data in the clipboard. |
michael@0 | 327 | */ |
michael@0 | 328 | boolean canPaste(in long aSelectionType); |
michael@0 | 329 | |
michael@0 | 330 | /** Can we paste |aTransferable| or, if |aTransferable| is null, will a call |
michael@0 | 331 | * to pasteTransferable later possibly succeed if given an instance of |
michael@0 | 332 | * nsITransferable then? True if the doc is modifiable, and, if |
michael@0 | 333 | * |aTransfeable| is non-null, we have pasteable data in |aTransfeable|. |
michael@0 | 334 | */ |
michael@0 | 335 | boolean canPasteTransferable([optional] in nsITransferable aTransferable); |
michael@0 | 336 | |
michael@0 | 337 | /* ------------ Selection methods -------------- */ |
michael@0 | 338 | |
michael@0 | 339 | /** sets the document selection to the entire contents of the document */ |
michael@0 | 340 | void selectAll(); |
michael@0 | 341 | |
michael@0 | 342 | /** sets the document selection to the beginning of the document */ |
michael@0 | 343 | void beginningOfDocument(); |
michael@0 | 344 | |
michael@0 | 345 | /** sets the document selection to the end of the document */ |
michael@0 | 346 | void endOfDocument(); |
michael@0 | 347 | |
michael@0 | 348 | /* ------------ Node manipulation methods -------------- */ |
michael@0 | 349 | |
michael@0 | 350 | /** |
michael@0 | 351 | * setAttribute() sets the attribute of aElement. |
michael@0 | 352 | * No checking is done to see if aAttribute is a legal attribute of the node, |
michael@0 | 353 | * or if aValue is a legal value of aAttribute. |
michael@0 | 354 | * |
michael@0 | 355 | * @param aElement the content element to operate on |
michael@0 | 356 | * @param aAttribute the string representation of the attribute to set |
michael@0 | 357 | * @param aValue the value to set aAttribute to |
michael@0 | 358 | */ |
michael@0 | 359 | void setAttribute(in nsIDOMElement aElement, in AString attributestr, |
michael@0 | 360 | in AString attvalue); |
michael@0 | 361 | |
michael@0 | 362 | /** |
michael@0 | 363 | * getAttributeValue() retrieves the attribute's value for aElement. |
michael@0 | 364 | * |
michael@0 | 365 | * @param aElement the content element to operate on |
michael@0 | 366 | * @param aAttribute the string representation of the attribute to get |
michael@0 | 367 | * @param aResultValue [OUT] the value of aAttribute. |
michael@0 | 368 | * Only valid if aResultIsSet is PR_TRUE |
michael@0 | 369 | * @return PR_TRUE if aAttribute is set on the current node, |
michael@0 | 370 | * PR_FALSE if it is not. |
michael@0 | 371 | */ |
michael@0 | 372 | boolean getAttributeValue(in nsIDOMElement aElement, |
michael@0 | 373 | in AString attributestr, |
michael@0 | 374 | out AString resultValue); |
michael@0 | 375 | |
michael@0 | 376 | /** |
michael@0 | 377 | * removeAttribute() deletes aAttribute from the attribute list of aElement. |
michael@0 | 378 | * If aAttribute is not an attribute of aElement, nothing is done. |
michael@0 | 379 | * |
michael@0 | 380 | * @param aElement the content element to operate on |
michael@0 | 381 | * @param aAttribute the string representation of the attribute to get |
michael@0 | 382 | */ |
michael@0 | 383 | void removeAttribute(in nsIDOMElement aElement, |
michael@0 | 384 | in AString aAttribute); |
michael@0 | 385 | |
michael@0 | 386 | /** |
michael@0 | 387 | * cloneAttribute() copies the attribute from the source node to |
michael@0 | 388 | * the destination node and delete those not in the source. |
michael@0 | 389 | * |
michael@0 | 390 | * The supplied nodes MUST BE ELEMENTS (most callers are working with nodes) |
michael@0 | 391 | * @param aAttribute the name of the attribute to copy |
michael@0 | 392 | * @param aDestNode the destination element to operate on |
michael@0 | 393 | * @param aSourceNode the source element to copy attributes from |
michael@0 | 394 | * @exception NS_ERROR_NULL_POINTER at least one of the nodes is null |
michael@0 | 395 | * @exception NS_ERROR_NO_INTERFACE at least one of the nodes is not an |
michael@0 | 396 | * element |
michael@0 | 397 | */ |
michael@0 | 398 | void cloneAttribute(in AString aAttribute, |
michael@0 | 399 | in nsIDOMNode aDestNode, in nsIDOMNode aSourceNode); |
michael@0 | 400 | |
michael@0 | 401 | /** |
michael@0 | 402 | * cloneAttributes() is similar to nsIDOMNode::cloneNode(), |
michael@0 | 403 | * it assures the attribute nodes of the destination are identical |
michael@0 | 404 | * with the source node by copying all existing attributes from the |
michael@0 | 405 | * source and deleting those not in the source. |
michael@0 | 406 | * This is used when the destination node (element) already exists |
michael@0 | 407 | * |
michael@0 | 408 | * The supplied nodes MUST BE ELEMENTS (most callers are working with nodes) |
michael@0 | 409 | * @param aDestNode the destination element to operate on |
michael@0 | 410 | * @param aSourceNode the source element to copy attributes from |
michael@0 | 411 | */ |
michael@0 | 412 | void cloneAttributes(in nsIDOMNode destNode, in nsIDOMNode sourceNode); |
michael@0 | 413 | |
michael@0 | 414 | /** |
michael@0 | 415 | * createNode instantiates a new element of type aTag and inserts it |
michael@0 | 416 | * into aParent at aPosition. |
michael@0 | 417 | * @param aTag The type of object to create |
michael@0 | 418 | * @param aParent The node to insert the new object into |
michael@0 | 419 | * @param aPosition The place in aParent to insert the new node |
michael@0 | 420 | * @return The node created. Caller must release aNewNode. |
michael@0 | 421 | */ |
michael@0 | 422 | nsIDOMNode createNode(in AString tag, |
michael@0 | 423 | in nsIDOMNode parent, |
michael@0 | 424 | in long position); |
michael@0 | 425 | |
michael@0 | 426 | /** |
michael@0 | 427 | * insertNode inserts aNode into aParent at aPosition. |
michael@0 | 428 | * No checking is done to verify the legality of the insertion. |
michael@0 | 429 | * That is the responsibility of the caller. |
michael@0 | 430 | * @param aNode The DOM Node to insert. |
michael@0 | 431 | * @param aParent The node to insert the new object into |
michael@0 | 432 | * @param aPosition The place in aParent to insert the new node |
michael@0 | 433 | * 0=first child, 1=second child, etc. |
michael@0 | 434 | * any number > number of current children = last child |
michael@0 | 435 | */ |
michael@0 | 436 | void insertNode(in nsIDOMNode node, |
michael@0 | 437 | in nsIDOMNode parent, |
michael@0 | 438 | in long aPosition); |
michael@0 | 439 | |
michael@0 | 440 | |
michael@0 | 441 | /** |
michael@0 | 442 | * splitNode() creates a new node identical to an existing node, |
michael@0 | 443 | * and split the contents between the two nodes |
michael@0 | 444 | * @param aExistingRightNode the node to split. |
michael@0 | 445 | * It will become the new node's next sibling. |
michael@0 | 446 | * @param aOffset the offset of aExistingRightNode's |
michael@0 | 447 | * content|children to do the split at |
michael@0 | 448 | * @param aNewLeftNode [OUT] the new node resulting from the split, |
michael@0 | 449 | * becomes aExistingRightNode's previous sibling. |
michael@0 | 450 | */ |
michael@0 | 451 | void splitNode(in nsIDOMNode existingRightNode, |
michael@0 | 452 | in long offset, |
michael@0 | 453 | out nsIDOMNode newLeftNode); |
michael@0 | 454 | |
michael@0 | 455 | /** |
michael@0 | 456 | * joinNodes() takes 2 nodes and merge their content|children. |
michael@0 | 457 | * @param aLeftNode The left node. It will be deleted. |
michael@0 | 458 | * @param aRightNode The right node. It will remain after the join. |
michael@0 | 459 | * @param aParent The parent of aExistingRightNode |
michael@0 | 460 | * |
michael@0 | 461 | * There is no requirement that the two nodes be |
michael@0 | 462 | * of the same type. However, a text node can be |
michael@0 | 463 | * merged only with another text node. |
michael@0 | 464 | */ |
michael@0 | 465 | void joinNodes(in nsIDOMNode leftNode, |
michael@0 | 466 | in nsIDOMNode rightNode, |
michael@0 | 467 | in nsIDOMNode parent); |
michael@0 | 468 | |
michael@0 | 469 | /** |
michael@0 | 470 | * deleteNode removes aChild from aParent. |
michael@0 | 471 | * @param aChild The node to delete |
michael@0 | 472 | */ |
michael@0 | 473 | void deleteNode(in nsIDOMNode child); |
michael@0 | 474 | |
michael@0 | 475 | /** |
michael@0 | 476 | * Returns true if markNodeDirty() has any effect. Returns false if |
michael@0 | 477 | * markNodeDirty() is a no-op. |
michael@0 | 478 | */ |
michael@0 | 479 | [notxpcom] boolean outputsMozDirty(); |
michael@0 | 480 | |
michael@0 | 481 | /** |
michael@0 | 482 | * markNodeDirty() sets a special dirty attribute on the node. |
michael@0 | 483 | * Usually this will be called immediately after creating a new node. |
michael@0 | 484 | * @param aNode The node for which to insert formatting. |
michael@0 | 485 | */ |
michael@0 | 486 | void markNodeDirty(in nsIDOMNode node); |
michael@0 | 487 | |
michael@0 | 488 | /* ---------- direction controller ---------- */ |
michael@0 | 489 | |
michael@0 | 490 | /** |
michael@0 | 491 | * Switches the editor element direction; from "Left-to-Right" to |
michael@0 | 492 | * "Right-to-Left", and vice versa. |
michael@0 | 493 | */ |
michael@0 | 494 | void switchTextDirection(); |
michael@0 | 495 | |
michael@0 | 496 | /* ------------ Output methods -------------- */ |
michael@0 | 497 | |
michael@0 | 498 | /** |
michael@0 | 499 | * Output methods: |
michael@0 | 500 | * aFormatType is a mime type, like text/plain. |
michael@0 | 501 | */ |
michael@0 | 502 | AString outputToString(in AString formatType, |
michael@0 | 503 | in unsigned long flags); |
michael@0 | 504 | void outputToStream(in nsIOutputStream aStream, |
michael@0 | 505 | in AString formatType, |
michael@0 | 506 | in ACString charsetOverride, |
michael@0 | 507 | in unsigned long flags); |
michael@0 | 508 | |
michael@0 | 509 | |
michael@0 | 510 | /* ------------ Various listeners methods -------------- |
michael@0 | 511 | * nsIEditor holds strong references to the editor observers, action listeners |
michael@0 | 512 | * and document state listeners. |
michael@0 | 513 | */ |
michael@0 | 514 | |
michael@0 | 515 | /** add an EditorObserver to the editors list of observers. */ |
michael@0 | 516 | void addEditorObserver(in nsIEditorObserver observer); |
michael@0 | 517 | |
michael@0 | 518 | /** Remove an EditorObserver from the editor's list of observers. */ |
michael@0 | 519 | void removeEditorObserver(in nsIEditorObserver observer); |
michael@0 | 520 | |
michael@0 | 521 | /** add an EditActionListener to the editors list of listeners. */ |
michael@0 | 522 | void addEditActionListener(in nsIEditActionListener listener); |
michael@0 | 523 | |
michael@0 | 524 | /** Remove an EditActionListener from the editor's list of listeners. */ |
michael@0 | 525 | void removeEditActionListener(in nsIEditActionListener listener); |
michael@0 | 526 | |
michael@0 | 527 | /** Add a DocumentStateListener to the editors list of doc state listeners. */ |
michael@0 | 528 | void addDocumentStateListener(in nsIDocumentStateListener listener); |
michael@0 | 529 | |
michael@0 | 530 | /** Remove a DocumentStateListener to the editors list of doc state listeners. */ |
michael@0 | 531 | void removeDocumentStateListener(in nsIDocumentStateListener listener); |
michael@0 | 532 | |
michael@0 | 533 | |
michael@0 | 534 | /* ------------ Debug methods -------------- */ |
michael@0 | 535 | |
michael@0 | 536 | /** |
michael@0 | 537 | * And a debug method -- show us what the tree looks like right now |
michael@0 | 538 | */ |
michael@0 | 539 | void dumpContentTree(); |
michael@0 | 540 | |
michael@0 | 541 | /** Dumps a text representation of the content tree to standard out */ |
michael@0 | 542 | void debugDumpContent() ; |
michael@0 | 543 | |
michael@0 | 544 | /* Run unit tests. Noop in optimized builds */ |
michael@0 | 545 | void debugUnitTests(out long outNumTests, out long outNumTestsFailed); |
michael@0 | 546 | |
michael@0 | 547 | /* checks if a node is read-only or not */ |
michael@0 | 548 | [notxpcom] boolean isModifiableNode(in nsIDOMNode aNode); |
michael@0 | 549 | |
michael@0 | 550 | /* Set true if you want to suppress dispatching input event. */ |
michael@0 | 551 | attribute boolean suppressDispatchingInputEvent; |
michael@0 | 552 | }; |