editor/idl/nsIContentFilter.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "nsISupports.idl"
     7 #include "domstubs.idl"
     9 interface nsIURL;
    11 [scriptable, uuid(c18c49a8-62f0-4045-9884-4aa91e388f14)]
    12 interface nsIContentFilter : nsISupports
    13 {
    14   /**
    15    * This notification occurs in an editor during these events:
    16    *    * open of document (once rendered in window but before editable)
    17    *    * paste from clipboard
    18    *    * drop from mouse
    19    *    * insertion of html (such as with "cmd_insertHTML")
    20    * It provides a hook so the above actions can be canceled or the data
    21    * can be modified (using standard DOM APIs) or left untouched.  The data
    22    * that results (if any) from all filter callbacks is what will be used
    23    * for transaction purposes (undo/redo) except for the open event.
    24    *
    25    * The willDeleteSelection parameter is offered for filters who want to
    26    * handle the insertion themselves and need to handle drag/drop correctly.
    27    * The flag is true when the editor intends to delete the selection.
    28    *
    29    * Callers who want to cancel all insertion can simply set
    30    * continueWithInsertion to PR_FALSE and return.
    31    * Note: If cancellation occurs during the "open" event, the editor will
    32    * still be available but will be empty.
    33    *
    34    * Callers who want to allow insertion of the data with no changes
    35    * can simply set continueWithInsertion to PR_TRUE and return.
    36    *
    37    * Callers who want to modify the content (docFragment) being inserted are 
    38    * responsible for updating contentStartNode, contentStartOffset, 
    39    * contentEndNode, and contentEndOffset (if necessary).  
    40    * Callers are responsible for freeing and addref'ing if they want to 
    41    * completely replace any of the DOM nodes passed in.
    42    *
    43    * The location where insertion will occur should be considered an
    44    * approximation since the editor may need to adjust it if it deletes
    45    * the selection as part of the event and later determines that insertion
    46    * point is an empty container which should also be removed (or in other
    47    * scenarios such as -moz-user-select:none).
    48    *
    49    * In some scenarios the selection will be deleted.  If callers choose
    50    * to adjust the insertion point, they should be careful that the insertion
    51    * point is not in the current selection.
    52    *
    53    * The contentStartNode and contentEndNode are not necessarily
    54    * immediate children of the docFragment.  Any nodes outside of the range
    55    * set by contentStartNode and contentEndNode are for context from the
    56    * source document.
    57    *
    58    * @param mimeType          the mimetype used for retrieving data
    59    * @param contentSourceURL  location where docFragment came from
    60    * @param sourceDocument      document where content came from (can be null)
    61    * @param willDeleteSelection tells hook if selection will/should be deleted
    62    * @param docFragment         fragment of node to be inserted
    63    * @param contentStartNode    node under which content to be inserted begins
    64    * @param contentStartOffset  start offset within contentStartNode
    65    * @param contentEndNode      node under which content to be inserted ends
    66    * @param contentEndOffset    ending offset withing contentEndNode
    67    * @param insertionPointNode     location where insertion will occur
    68    * @param insertionPointOffset   offset within node where insertion occurs
    69    * @param continueWithInsertion  flag to cancel insertion (if desired)
    70    */
    72   void notifyOfInsertion(in AString mimeType,
    73                          in nsIURL contentSourceURL,
    74                          in nsIDOMDocument sourceDocument,
    75                          in boolean willDeleteSelection,
    76                          inout nsIDOMNode docFragment,
    77                          inout nsIDOMNode contentStartNode,
    78                          inout long contentStartOffset,
    79                          inout nsIDOMNode contentEndNode,
    80                          inout long contentEndOffset,
    81                          inout nsIDOMNode insertionPointNode,
    82                          inout long insertionPointOffset,
    83                          out boolean continueWithInsertion);
    85 };

mercurial