Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "nsISupports.idl" |
michael@0 | 6 | |
michael@0 | 7 | interface nsITransferable; |
michael@0 | 8 | interface nsIDragSession; |
michael@0 | 9 | interface nsIDOMEvent; |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | /** |
michael@0 | 13 | * Interfaces for overriding the built-in drag, drop, copy, and paste |
michael@0 | 14 | * implementations in the content area and editors. Use this to do things |
michael@0 | 15 | * such as prevent a drag from starting, adding or removing |
michael@0 | 16 | * data and flavors, or preventing the drop. |
michael@0 | 17 | * |
michael@0 | 18 | * Embedders who want to have these hooks made available should implement |
michael@0 | 19 | * nsIClipboardDragDropHooks and use the command manager to send the |
michael@0 | 20 | * appropriate commands with these parameters/settings: |
michael@0 | 21 | * command: cmd_clipboardDragDropHook |
michael@0 | 22 | * |
michael@0 | 23 | * params value type possible values |
michael@0 | 24 | * "addhook" isupports nsIClipboardDragDropHooks as nsISupports |
michael@0 | 25 | * "removehook" isupports nsIClipboardDragDropHooks as nsISupports |
michael@0 | 26 | * |
michael@0 | 27 | * Notes: |
michael@0 | 28 | * * Overrides/hooks need to be added to each window (as appropriate). |
michael@0 | 29 | * Adding them to the first window does not enable them for every window. |
michael@0 | 30 | * * If more than one implementation is set for a window, the hooks will be |
michael@0 | 31 | * called in the order they are added. |
michael@0 | 32 | * * Adding the same hook to the same window will not add a second call. |
michael@0 | 33 | * Each hook can only be called once per user action/api. |
michael@0 | 34 | * * Not all hooks are guaranteed to be called. If there are multiple hooks |
michael@0 | 35 | * set for a window, any of them has an opportunity to cancel the action |
michael@0 | 36 | * so no further processing will occur. |
michael@0 | 37 | * * If any errors occur (without setting the boolean result) the default |
michael@0 | 38 | * action will occur. |
michael@0 | 39 | * * AllowDrop will be called MANY times during drag so ensure that it is |
michael@0 | 40 | * efficient. |
michael@0 | 41 | */ |
michael@0 | 42 | |
michael@0 | 43 | |
michael@0 | 44 | [scriptable,uuid(e03e6c5e-0d84-4c0b-8739-e6b8d51922de)] |
michael@0 | 45 | interface nsIClipboardDragDropHooks : nsISupports |
michael@0 | 46 | { |
michael@0 | 47 | /** |
michael@0 | 48 | * Prevents the drag from starting |
michael@0 | 49 | * |
michael@0 | 50 | * @param event DOM event (drag gesture) |
michael@0 | 51 | * |
michael@0 | 52 | * @return TRUE drag can proceed |
michael@0 | 53 | * @return FALSE drag is cancelled, does not go to OS |
michael@0 | 54 | */ |
michael@0 | 55 | boolean allowStartDrag(in nsIDOMEvent event); |
michael@0 | 56 | |
michael@0 | 57 | /** |
michael@0 | 58 | * Tells gecko whether a drop is allowed on this content area |
michael@0 | 59 | * |
michael@0 | 60 | * @param event DOM event (drag over) |
michael@0 | 61 | * @param session the drag session from which client can get |
michael@0 | 62 | * the flavors present or the actual data |
michael@0 | 63 | * |
michael@0 | 64 | * @return TRUE indicates to OS that if a drop does happen on this |
michael@0 | 65 | * browser, it will be accepted. |
michael@0 | 66 | * @return FALSE indicates to OS drop is not allowed. On win32, this |
michael@0 | 67 | * will change the cursor to "reject". |
michael@0 | 68 | */ |
michael@0 | 69 | boolean allowDrop(in nsIDOMEvent event, in nsIDragSession session); |
michael@0 | 70 | |
michael@0 | 71 | /** |
michael@0 | 72 | * Alter the flavors or data presented to the OS |
michael@0 | 73 | * Used for drag and copy actions |
michael@0 | 74 | * Because this can be called many times, it is highly recommended |
michael@0 | 75 | * that the implementation be very efficient so user feedback is |
michael@0 | 76 | * not negatively impacted. |
michael@0 | 77 | * |
michael@0 | 78 | * @param event DOM event (drag drop); null if triggered by copy. |
michael@0 | 79 | * @param trans the transferable holding the list of flavors |
michael@0 | 80 | * and the data for each flavor |
michael@0 | 81 | * |
michael@0 | 82 | * @return TRUE copy/drag can proceed |
michael@0 | 83 | * @return FALSE copy/drag is cancelled, does not go to OS |
michael@0 | 84 | */ |
michael@0 | 85 | boolean onCopyOrDrag(in nsIDOMEvent aEvent, in nsITransferable trans); |
michael@0 | 86 | |
michael@0 | 87 | /** |
michael@0 | 88 | * Provide an alternative action to the built-in behavior when |
michael@0 | 89 | * something is dropped on the browser or in an editor |
michael@0 | 90 | * |
michael@0 | 91 | * @param event DOM event (drag drop); null if triggered by paste. |
michael@0 | 92 | * @param trans the transferable holding the list of flavors |
michael@0 | 93 | * and the data for each flavor |
michael@0 | 94 | * |
michael@0 | 95 | * @return TRUE action was handled, do not perform built-in |
michael@0 | 96 | * behavior |
michael@0 | 97 | * @return FALSE action was not overridden, do built-in behavior |
michael@0 | 98 | */ |
michael@0 | 99 | boolean onPasteOrDrop(in nsIDOMEvent event, in nsITransferable trans); |
michael@0 | 100 | }; |
michael@0 | 101 |