michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsITransferable; michael@0: interface nsIDragSession; michael@0: interface nsIDOMEvent; michael@0: michael@0: michael@0: /** michael@0: * Interfaces for overriding the built-in drag, drop, copy, and paste michael@0: * implementations in the content area and editors. Use this to do things michael@0: * such as prevent a drag from starting, adding or removing michael@0: * data and flavors, or preventing the drop. michael@0: * michael@0: * Embedders who want to have these hooks made available should implement michael@0: * nsIClipboardDragDropHooks and use the command manager to send the michael@0: * appropriate commands with these parameters/settings: michael@0: * command: cmd_clipboardDragDropHook michael@0: * michael@0: * params value type possible values michael@0: * "addhook" isupports nsIClipboardDragDropHooks as nsISupports michael@0: * "removehook" isupports nsIClipboardDragDropHooks as nsISupports michael@0: * michael@0: * Notes: michael@0: * * Overrides/hooks need to be added to each window (as appropriate). michael@0: * Adding them to the first window does not enable them for every window. michael@0: * * If more than one implementation is set for a window, the hooks will be michael@0: * called in the order they are added. michael@0: * * Adding the same hook to the same window will not add a second call. michael@0: * Each hook can only be called once per user action/api. michael@0: * * Not all hooks are guaranteed to be called. If there are multiple hooks michael@0: * set for a window, any of them has an opportunity to cancel the action michael@0: * so no further processing will occur. michael@0: * * If any errors occur (without setting the boolean result) the default michael@0: * action will occur. michael@0: * * AllowDrop will be called MANY times during drag so ensure that it is michael@0: * efficient. michael@0: */ michael@0: michael@0: michael@0: [scriptable,uuid(e03e6c5e-0d84-4c0b-8739-e6b8d51922de)] michael@0: interface nsIClipboardDragDropHooks : nsISupports michael@0: { michael@0: /** michael@0: * Prevents the drag from starting michael@0: * michael@0: * @param event DOM event (drag gesture) michael@0: * michael@0: * @return TRUE drag can proceed michael@0: * @return FALSE drag is cancelled, does not go to OS michael@0: */ michael@0: boolean allowStartDrag(in nsIDOMEvent event); michael@0: michael@0: /** michael@0: * Tells gecko whether a drop is allowed on this content area michael@0: * michael@0: * @param event DOM event (drag over) michael@0: * @param session the drag session from which client can get michael@0: * the flavors present or the actual data michael@0: * michael@0: * @return TRUE indicates to OS that if a drop does happen on this michael@0: * browser, it will be accepted. michael@0: * @return FALSE indicates to OS drop is not allowed. On win32, this michael@0: * will change the cursor to "reject". michael@0: */ michael@0: boolean allowDrop(in nsIDOMEvent event, in nsIDragSession session); michael@0: michael@0: /** michael@0: * Alter the flavors or data presented to the OS michael@0: * Used for drag and copy actions michael@0: * Because this can be called many times, it is highly recommended michael@0: * that the implementation be very efficient so user feedback is michael@0: * not negatively impacted. michael@0: * michael@0: * @param event DOM event (drag drop); null if triggered by copy. michael@0: * @param trans the transferable holding the list of flavors michael@0: * and the data for each flavor michael@0: * michael@0: * @return TRUE copy/drag can proceed michael@0: * @return FALSE copy/drag is cancelled, does not go to OS michael@0: */ michael@0: boolean onCopyOrDrag(in nsIDOMEvent aEvent, in nsITransferable trans); michael@0: michael@0: /** michael@0: * Provide an alternative action to the built-in behavior when michael@0: * something is dropped on the browser or in an editor michael@0: * michael@0: * @param event DOM event (drag drop); null if triggered by paste. michael@0: * @param trans the transferable holding the list of flavors michael@0: * and the data for each flavor michael@0: * michael@0: * @return TRUE action was handled, do not perform built-in michael@0: * behavior michael@0: * @return FALSE action was not overridden, do built-in behavior michael@0: */ michael@0: boolean onPasteOrDrop(in nsIDOMEvent event, in nsITransferable trans); michael@0: }; michael@0: