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