Copy as Markdown

Other Tools

//
// DO NOT EDIT. THIS FILE IS GENERATED FROM $SRCDIR/widget/nsIDragService.idl
//
/// `interface nsIDragService : nsISupports`
///
// The actual type definition for the interface. This struct has methods
// declared on it which will call through its vtable. You never want to pass
// this type around by value, always pass it behind a reference.
#[repr(C)]
pub struct nsIDragService {
vtable: &'static nsIDragServiceVTable,
/// This field is a phantomdata to ensure that the VTable type and any
/// struct containing it is not safe to send across threads by default, as
/// XPCOM is generally not threadsafe.
///
/// If this type is marked as [rust_sync], there will be explicit `Send` and
/// `Sync` implementations on this type, which will override the inherited
/// negative impls from `Rc`.
__nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>,
// Make the rust compiler aware that there might be interior mutability
// in what actually implements the interface. This works around UB
// that a rust lint would make blatantly obvious, but doesn't exist.
// This prevents optimizations, but those optimizations weren't available
// before rustc switched to LLVM 16, and they now cause problems because
// of the UB.
// Until there's a lint available to find all our UB, it's simpler to
// avoid the UB in the first place, at the cost of preventing optimizations
// in places that don't cause UB. But again, those optimizations weren't
// available before.
__maybe_interior_mutability: ::std::cell::UnsafeCell<[u8; 0]>,
}
// Implementing XpCom for an interface exposes its IID, which allows for easy
// use of the `.query_interface<T>` helper method. This also defines that
// method for nsIDragService.
unsafe impl XpCom for nsIDragService {
const IID: nsIID = nsID(0xebd6b3a2, 0xaf16, 0x43af,
[0xa6, 0x98, 0x30, 0x91, 0xa0, 0x87, 0xdd, 0x62]);
}
// We need to implement the RefCounted trait so we can be used with `RefPtr`.
// This trait teaches `RefPtr` how to manage our memory.
unsafe impl RefCounted for nsIDragService {
#[inline]
unsafe fn addref(&self) {
self.AddRef();
}
#[inline]
unsafe fn release(&self) {
self.Release();
}
}
// This trait is implemented on all types which can be coerced to from nsIDragService.
// It is used in the implementation of `fn coerce<T>`. We hide it from the
// documentation, because it clutters it up a lot.
#[doc(hidden)]
pub trait nsIDragServiceCoerce {
/// Cheaply cast a value of this type from a `nsIDragService`.
fn coerce_from(v: &nsIDragService) -> &Self;
}
// The trivial implementation: We can obviously coerce ourselves to ourselves.
impl nsIDragServiceCoerce for nsIDragService {
#[inline]
fn coerce_from(v: &nsIDragService) -> &Self {
v
}
}
impl nsIDragService {
/// Cast this `nsIDragService` to one of its base interfaces.
#[inline]
pub fn coerce<T: nsIDragServiceCoerce>(&self) -> &T {
T::coerce_from(self)
}
}
// Every interface struct type implements `Deref` to its base interface. This
// causes methods on the base interfaces to be directly avaliable on the
// object. For example, you can call `.AddRef` or `.QueryInterface` directly
// on any interface which inherits from `nsISupports`.
impl ::std::ops::Deref for nsIDragService {
type Target = nsISupports;
#[inline]
fn deref(&self) -> &nsISupports {
unsafe {
::std::mem::transmute(self)
}
}
}
// Ensure we can use .coerce() to cast to our base types as well. Any type which
// our base interface can coerce from should be coercable from us as well.
impl<T: nsISupportsCoerce> nsIDragServiceCoerce for T {
#[inline]
fn coerce_from(v: &nsIDragService) -> &Self {
T::coerce_from(v)
}
}
// This struct represents the interface's VTable. A pointer to a statically
// allocated version of this struct is at the beginning of every nsIDragService
// object. It contains one pointer field for each method in the interface. In
// the case where we can't generate a binding for a method, we include a void
// pointer.
#[doc(hidden)]
#[repr(C)]
pub struct nsIDragServiceVTable {
/// We need to include the members from the base interface's vtable at the start
/// of the VTable definition.
pub __base: nsISupportsVTable,
/* [can_run_script,noscript] void invokeDragSessionWithImage (in Node aDOMNode, in nsIPrincipal aPrincipal, in nsIContentSecurityPolicy aCsp, in nsICookieJarSettings aCookieJarSettings, in nsIArray aTransferableArray, in unsigned long aActionType, in Node aImage, in long aImageX, in long aImageY, in DragEvent aDragEvent, in DataTransferPtr aDataTransfer); */
/// Unable to generate binding because `native type mozilla::dom::DataTransfer unsupported`
pub InvokeDragSessionWithImage: *const ::libc::c_void,
/* [can_run_script,noscript] void invokeDragSessionWithRemoteImage (in Node aDOMNode, in nsIPrincipal aPrincipal, in nsIContentSecurityPolicy aCsp, in nsICookieJarSettings aCookieJarSettings, in nsIArray aTransferableArray, in unsigned long aActionType, in RemoteDragStartDataPtr aDragStartData, in DragEvent aDragEvent, in DataTransferPtr aDataTransfer); */
/// Unable to generate binding because `native type mozilla::dom::RemoteDragStartData unsupported`
pub InvokeDragSessionWithRemoteImage: *const ::libc::c_void,
/* [can_run_script,noscript] void invokeDragSessionWithSelection (in Selection aSelection, in nsIPrincipal aPrincipal, in nsIContentSecurityPolicy aCsp, in nsICookieJarSettings aCookieJarSettings, in nsIArray aTransferableArray, in unsigned long aActionType, in DragEvent aDragEvent, in DataTransferPtr aDataTransfer, in Node aTargetContent); */
/// Unable to generate binding because `native type mozilla::dom::DataTransfer unsupported`
pub InvokeDragSessionWithSelection: *const ::libc::c_void,
/* nsIDragSession getCurrentSession ([optional] in nsISupports aWidgetProvider); */
pub GetCurrentSession: unsafe extern "system" fn (this: *const nsIDragService, aWidgetProvider: *const nsISupports, _retval: *mut *const nsIDragSession) -> ::nserror::nsresult,
/* [nostdcall,notxpcom] nsIDragSession startDragSession (in nsISupports aWidgetProvider); */
/// Unable to generate binding because `nostdcall is unsupported`
pub StartDragSession: *const ::libc::c_void,
/* void startDragSessionForTests (in nsISupports aWidgetProvider, in unsigned long aAllowedEffect); */
pub StartDragSessionForTests: unsafe extern "system" fn (this: *const nsIDragService, aWidgetProvider: *const nsISupports, aAllowedEffect: u32) -> ::nserror::nsresult,
/* [can_run_script] void suppress (); */
pub Suppress: unsafe extern "system" fn (this: *const nsIDragService) -> ::nserror::nsresult,
/* void unsuppress (); */
pub Unsuppress: unsafe extern "system" fn (this: *const nsIDragService) -> ::nserror::nsresult,
/* [nostdcall,notxpcom] boolean maybeAddBrowser (in BrowserParentPtr aBP); */
/// Unable to generate binding because `native type mozilla::dom::BrowserParent unsupported`
pub MaybeAddBrowser: *const ::libc::c_void,
/* [nostdcall,notxpcom] boolean removeAllBrowsers (); */
/// Unable to generate binding because `nostdcall is unsupported`
pub RemoveAllBrowsers: *const ::libc::c_void,
/* nsIMockDragServiceController getMockDragController (); */
pub GetMockDragController: unsafe extern "system" fn (this: *const nsIDragService, _retval: *mut*const nsIMockDragServiceController) -> ::nserror::nsresult,
/* readonly attribute boolean isMockService; */
pub GetIsMockService: unsafe extern "system" fn (this: *const nsIDragService, aIsMockService: *mut bool) -> ::nserror::nsresult,
/* [infallible] attribute boolean neverAllowSessionIsSynthesizedForTests; */
pub GetNeverAllowSessionIsSynthesizedForTests: unsafe extern "system" fn (this: *const nsIDragService, aNeverAllowSessionIsSynthesizedForTests: *mut bool) -> ::nserror::nsresult,
/* [infallible] attribute boolean neverAllowSessionIsSynthesizedForTests; */
pub SetNeverAllowSessionIsSynthesizedForTests: unsafe extern "system" fn (this: *const nsIDragService, aNeverAllowSessionIsSynthesizedForTests: bool) -> ::nserror::nsresult,
}
// The implementations of the function wrappers which are exposed to rust code.
// Call these methods rather than manually calling through the VTable struct.
impl nsIDragService {
pub const DRAGDROP_ACTION_NONE: i32 = 0;
pub const DRAGDROP_ACTION_COPY: i32 = 1;
pub const DRAGDROP_ACTION_MOVE: i32 = 2;
pub const DRAGDROP_ACTION_LINK: i32 = 4;
pub const DRAGDROP_ACTION_UNINITIALIZED: i32 = 64;
/// ```text
/// /**
/// * Starts a modal drag session using an image. The first four arguments are
/// * the same as invokeDragSession.
/// *
/// * Note: This method is deprecated for non-native code.
/// *
/// * A custom image may be specified using the aImage argument. If this is
/// * supplied, the aImageX and aImageY arguments specify the offset within
/// * the image where the cursor would be positioned. That is, when the image
/// * is drawn, it is offset up and left the amount so that the cursor appears
/// * at that location within the image.
/// *
/// * If aImage is null, aImageX and aImageY are not used and the image is instead
/// * determined from the source node aDOMNode, and the offset calculated so that
/// * the initial location for the image appears in the same screen position as
/// * where the element is located. The node must be within a document.
/// *
/// * Currently, supported images are all DOM nodes. If this is an HTML <image> or
/// * <canvas>, the drag image is taken from the image data. If the element is in
/// * a document, it will be rendered at its displayed size, othewise, it will be
/// * rendered at its real size. For other types of elements, the element is
/// * rendered into an offscreen buffer in the same manner as it is currently
/// * displayed. The document selection is hidden while drawing.
/// *
/// * The aDragEvent must be supplied as the current screen coordinates of the
/// * event are needed to calculate the image location.
/// */
/// ```
///
/// `[can_run_script,noscript] void invokeDragSessionWithImage (in Node aDOMNode, in nsIPrincipal aPrincipal, in nsIContentSecurityPolicy aCsp, in nsICookieJarSettings aCookieJarSettings, in nsIArray aTransferableArray, in unsigned long aActionType, in Node aImage, in long aImageX, in long aImageY, in DragEvent aDragEvent, in DataTransferPtr aDataTransfer);`
const _InvokeDragSessionWithImage: () = ();
/// ```text
/// /** Start a drag session with the data in aDragStartData from a child process.
/// * Other arguments are the same as invokeDragSessionWithImage.
/// */
/// ```
///
/// `[can_run_script,noscript] void invokeDragSessionWithRemoteImage (in Node aDOMNode, in nsIPrincipal aPrincipal, in nsIContentSecurityPolicy aCsp, in nsICookieJarSettings aCookieJarSettings, in nsIArray aTransferableArray, in unsigned long aActionType, in RemoteDragStartDataPtr aDragStartData, in DragEvent aDragEvent, in DataTransferPtr aDataTransfer);`
const _InvokeDragSessionWithRemoteImage: () = ();
/// ```text
/// /**
/// * Start a modal drag session using the selection as the drag image.
/// * The aDragEvent must be supplied as the current screen coordinates of the
/// * event are needed to calculate the image location.
/// *
/// * Note: This method is deprecated for non-native code.
/// */
/// ```
///
/// `[can_run_script,noscript] void invokeDragSessionWithSelection (in Selection aSelection, in nsIPrincipal aPrincipal, in nsIContentSecurityPolicy aCsp, in nsICookieJarSettings aCookieJarSettings, in nsIArray aTransferableArray, in unsigned long aActionType, in DragEvent aDragEvent, in DataTransferPtr aDataTransfer, in Node aTargetContent);`
const _InvokeDragSessionWithSelection: () = ();
/// ```text
/// /**
/// * In the parent process, returns the current drag session. In content,
/// * returns the current drag session for the widget containing the given
/// * window, or the entry global JS context if aWindow is not specified.
/// *
/// * @param aWidgetProvider Either the nsIWidget that is the source or current
/// * target of the drag, or an nsIDOMWindowProxy for a
/// * window that is on the widget.
/// */
/// ```
///
/// `nsIDragSession getCurrentSession ([optional] in nsISupports aWidgetProvider);`
#[inline]
pub unsafe fn GetCurrentSession(&self, aWidgetProvider: *const nsISupports, _retval: *mut *const nsIDragSession) -> ::nserror::nsresult {
((*self.vtable).GetCurrentSession)(self, aWidgetProvider, _retval)
}
/// ```text
/// /**
/// * Tells the Drag Service to start a drag session. This is called when
/// * an external drag occurs.
/// *
/// * @param aWidgetProvider Either the nsIWidget that will be the target of
/// * the drag, or an nsIDOMWindowProxy for a
/// * window that is on that widget.
/// * @returns the new (or pre-existing) session
/// */
/// ```
///
/// `[nostdcall,notxpcom] nsIDragSession startDragSession (in nsISupports aWidgetProvider);`
const _StartDragSession: () = ();
/// ```text
/// /**
/// * Similar to startDragSession(), automated tests may want to start
/// * session for emulating an external drag. At that time, this should
/// * be used instead of startDragSession().
/// *
/// * @param aWidgetProvider Either the nsIWidget that is the source or current
/// * target of the drag, or an nsIDOMWindowProxy for a
/// * window that is on the widget.
/// *
/// * @param aAllowedEffect Set default drag action which means allowed effects
/// * in the session and every DnD events are initialized
/// * with one of specified value. So, the value can be
/// * DRAGDROP_ACTION_NONE, or one or more values of
/// * DRAGDROP_ACTION_(MOVE|COPY|LINK).
/// */
/// ```
///
/// `void startDragSessionForTests (in nsISupports aWidgetProvider, in unsigned long aAllowedEffect);`
#[inline]
pub unsafe fn StartDragSessionForTests(&self, aWidgetProvider: *const nsISupports, aAllowedEffect: u32) -> ::nserror::nsresult {
((*self.vtable).StartDragSessionForTests)(self, aWidgetProvider, aAllowedEffect)
}
/// ```text
/// /**
/// * Increase/decrease dragging suppress level by one.
/// * If level is greater than one, dragging is disabled.
/// */
/// ```
///
/// `[can_run_script] void suppress ();`
#[inline]
pub unsafe fn Suppress(&self, ) -> ::nserror::nsresult {
((*self.vtable).Suppress)(self, )
}
/// `void unsuppress ();`
#[inline]
pub unsafe fn Unsuppress(&self, ) -> ::nserror::nsresult {
((*self.vtable).Unsuppress)(self, )
}
/// `[nostdcall,notxpcom] boolean maybeAddBrowser (in BrowserParentPtr aBP);`
const _MaybeAddBrowser: () = ();
/// `[nostdcall,notxpcom] boolean removeAllBrowsers ();`
const _RemoveAllBrowsers: () = ();
/// ```text
/// /**
/// * The controller is used to issue events that would normally come from
/// * the system (when it is not mocked for testing). This allows us to test
/// * without engaging any native DND behavior.
/// *
/// * In order for the controller to be effective, the existing nsIDragService
/// * needs to be replaced with the one in the controller. See
/// * nsIMockDragServiceController for details.
/// */
/// ```
///
/// `nsIMockDragServiceController getMockDragController ();`
#[inline]
pub unsafe fn GetMockDragController(&self, _retval: *mut*const nsIMockDragServiceController) -> ::nserror::nsresult {
((*self.vtable).GetMockDragController)(self, _retval)
}
/// ```text
/// /**
/// * True if this is a mock nsIDragService, created with
/// * createMockDragController().
/// */
/// ```
///
/// `readonly attribute boolean isMockService;`
#[inline]
pub unsafe fn GetIsMockService(&self, aIsMockService: *mut bool) -> ::nserror::nsresult {
((*self.vtable).GetIsMockService)(self, aIsMockService)
}
/// ```text
/// /**
/// * If this is true, mSessionIsSynthesizedForTests should not become true.
/// * This hack is used to bypass the "old" drag-drop test behavior, which needed
/// * special behavior to pass. The new framework requires the actual browser
/// * behavior. The test for whether we are using the new framework or not can
/// * only be done in the main process with nsBaseDragService::IsMockService.
/// * Unfortunately, mSessionIsSynthesizedForTests is inherited from
/// * synthetic mouse events in content processes (when dragging content) so we
/// * set this early in the relevant tests. Once the old tests are replaced,
/// * this can be removed along with mSessionIsSynthesizedForTests.
/// */
/// ```
///
/// `[infallible] attribute boolean neverAllowSessionIsSynthesizedForTests;`
#[inline]
pub unsafe fn GetNeverAllowSessionIsSynthesizedForTests(&self) -> bool {
let mut result = <bool as ::std::default::Default>::default();
let _rv = ((*self.vtable).GetNeverAllowSessionIsSynthesizedForTests)(self, &mut result);
debug_assert!(_rv.succeeded());
result
}
/// ```text
/// /**
/// * If this is true, mSessionIsSynthesizedForTests should not become true.
/// * This hack is used to bypass the "old" drag-drop test behavior, which needed
/// * special behavior to pass. The new framework requires the actual browser
/// * behavior. The test for whether we are using the new framework or not can
/// * only be done in the main process with nsBaseDragService::IsMockService.
/// * Unfortunately, mSessionIsSynthesizedForTests is inherited from
/// * synthetic mouse events in content processes (when dragging content) so we
/// * set this early in the relevant tests. Once the old tests are replaced,
/// * this can be removed along with mSessionIsSynthesizedForTests.
/// */
/// ```
///
/// `[infallible] attribute boolean neverAllowSessionIsSynthesizedForTests;`
#[inline]
pub unsafe fn SetNeverAllowSessionIsSynthesizedForTests(&self, aNeverAllowSessionIsSynthesizedForTests: bool) -> ::nserror::nsresult {
((*self.vtable).SetNeverAllowSessionIsSynthesizedForTests)(self, aNeverAllowSessionIsSynthesizedForTests)
}
}