gecko-dev/widget/nsIDragSession.idl

213 строки
6.6 KiB
Plaintext

/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsITransferable.idl"
%{ C++
#include "mozilla/EventForwards.h"
#include "nsSize.h"
namespace mozilla {
namespace dom {
class BrowserParent;
} // namespace dom
} // namespace mozilla
%}
interface nsIContentSecurityPolicy;
[ptr] native BrowserParentPtr(mozilla::dom::BrowserParent);
native EventMessage(mozilla::EventMessage);
native nsSize(nsSize);
webidl DataTransfer;
webidl Element;
webidl WindowContext;
webidl Node;
webidl Selection;
[scriptable, builtinclass, uuid(25bce737-73f0-43c7-bc20-c71044a73c5a)]
interface nsIDragSession : nsISupports
{
/**
* Set the current state of the drag, whether it can be dropped or not.
* usually the target "frame" sets this so the native system can render the correct feedback
*/
attribute boolean canDrop;
/**
* Indicates if the drop event should be dispatched only to chrome.
*/
attribute boolean onlyChromeDrop;
/**
* Sets the action (copy, move, link, et.c) for the current drag
*/
attribute unsigned long dragAction;
/**
* Get the number of items that were dropped
*/
readonly attribute unsigned long numDropItems;
/**
* The window context where the drag was started, which will be null if the
* drag originated outside the application. Useful for determining if a drop
* originated in the same window context.
*/
[infallible]
attribute WindowContext sourceWindowContext;
/**
* The top-level window context where the drag was started, which will be
* null if the drag originated outside the application. Useful for
* determining if a drop originated in the same top-level window context.
*/
[infallible]
attribute WindowContext sourceTopWindowContext;
/**
* The dom node that was originally dragged to start the session, which will be null if the
* drag originated outside the application.
*/
readonly attribute Node sourceNode;
/**
* Replace source node and selection with new ones.
* If sourceNode is a native anonymous node, it may be replaced at reframing.
* If sourceNode is disconnected from the document, we cannot dispatch
* `dragend` event properly.
* When this is called, sourceNode or aNewSourceNode should be a native
* anonymous node.
*/
[notxpcom, nostdcall] void updateSource(in Node aNewSourceNode,
in Selection aNewSelection);
/**
* the triggering principal. This may be different than sourceNode's
* principal when sourceNode is xul:browser and the drag is
* triggered in a browsing context inside it.
*/
attribute nsIPrincipal triggeringPrincipal;
/**
* the triggering csp. This may be different than sourceNode's
* csp when sourceNode is xul:browser and the drag is
* triggered in a browsing context inside it.
*/
attribute nsIContentSecurityPolicy csp;
/**
* The data transfer object for the current drag.
*/
[binaryname(DataTransferXPCOM)]
attribute DataTransfer dataTransfer;
[notxpcom, nostdcall] DataTransfer getDataTransfer();
[notxpcom, nostdcall] void setDataTransfer(in DataTransfer aDataTransfer);
/**
* Get data from a Drag&Drop. Can be called while the drag is in process
* or after the drop has completed.
*
* @param aTransferable the transferable for the data to be put into
* @param aItemIndex which of multiple drag items, zero-based
*/
void getData ( in nsITransferable aTransferable, in unsigned long aItemIndex ) ;
/**
* Check to set if any of the native data on the clipboard matches this data flavor
*/
boolean isDataFlavorSupported ( in string aDataFlavor ) ;
void userCancelled();
void dragEventDispatchedToChildProcess();
// Called when nsIDragSession implementation should update the UI for the
// drag-and-drop based on the data got from the child process in response to
// NS_DRAGDROP_OVER sent from parent process to child process.
void updateDragEffect();
// Change the drag image, using similar arguments as
// nsIDragService::InvokeDragSessionWithImage.
void updateDragImage(in Node aImage, in long aImageX, in long aImageY);
/**
* Tell Gecko that this session is generated for automated testing.
* This should be called immediately after StartDragSession when testing.
*/
[noscript] void InitForTests(in uint32_t aAllowedEffect);
/**
* Returns effects allowed at starting the session for tests.
*/
[notxpcom, nostdcall] unsigned long getEffectAllowedForTests();
/**
* Returns true if current session was started with synthesized drag start.
*/
[notxpcom, nostdcall] boolean isSynthesizedForTests();
/**
* Sets the drag end point. Position is relative to screen in device coords.
*/
void setDragEndPoint(in long aScreenX, in long aScreenY);
/**
* Sets drag end point of synthesized session when the test does not dispatch
* "drop" event.
*/
void setDragEndPointForTests(in long aScreenX, in long aScreenY);
/**
* Returns true if the session is for dragging text in a text in text control
* element.
*/
[notxpcom, nostdcall] boolean isDraggingTextInTextControl();
/**
* Called when HTMLEditor maybe deleted the source node from the document.
*
* @param aEditingHost The editing host when the editor deletes selection.
*/
[noscript] void maybeEditorDeletedSourceNode(in Element aEditingHost);
/**
* aX and aY are in LayoutDevice pixels.
*/
[noscript] void dragMoved(in long aX, in long aY);
/**
* Fire a drag event at the source of the drag
*/
[noscript, can_run_script]
void fireDragEventAtSource(in EventMessage aEventMessage,
in unsigned long aKeyModifiers);
[notxpcom, nostdcall] boolean maybeAddBrowser(in BrowserParentPtr aBP);
[notxpcom, nostdcall] boolean removeAllBrowsers();
/**
* Tells the Drag Service to end a drag session.
*
* If aDoneDrag is true, the drag has finished, otherwise the drag has
* just left the window.
*
* @param aDoneDrag If true, reports the drag as complete.
* @param aKeyModifiers Key state to assume while ending the session.
*/
[can_run_script]
void endDragSession(in boolean aDoneDrag,
[optional] in unsigned long aKeyModifiers);
/**
* Retrun true if nsIDragSession's data is updated.
*/
[notxpcom, nostdcall] boolean mustUpdateDataTransfer(in EventMessage aMessage);
};