Copy as Markdown

Other Tools

//
// DO NOT EDIT. THIS FILE IS GENERATED FROM $SRCDIR/widget/nsITaskbarPreviewController.idl
//
/// `interface nsITaskbarPreviewCallback : nsISupports`
///
/// ```text
/// /**
/// * nsITaskbarPreviewCallback
/// *
/// * Provides an interface for async image result callbacks. See
/// * nsITaskbarPreviewController request apis below.
/// */
/// ```
///
// 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 nsITaskbarPreviewCallback {
vtable: &'static nsITaskbarPreviewCallbackVTable,
/// 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 nsITaskbarPreviewCallback.
unsafe impl XpCom for nsITaskbarPreviewCallback {
const IID: nsIID = nsID(0xf3744696, 0x320d, 0x4804,
[0x9c, 0x27, 0x6a, 0x84, 0xc2, 0x9a, 0xca, 0xa6]);
}
// 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 nsITaskbarPreviewCallback {
#[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 nsITaskbarPreviewCallback.
// 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 nsITaskbarPreviewCallbackCoerce {
/// Cheaply cast a value of this type from a `nsITaskbarPreviewCallback`.
fn coerce_from(v: &nsITaskbarPreviewCallback) -> &Self;
}
// The trivial implementation: We can obviously coerce ourselves to ourselves.
impl nsITaskbarPreviewCallbackCoerce for nsITaskbarPreviewCallback {
#[inline]
fn coerce_from(v: &nsITaskbarPreviewCallback) -> &Self {
v
}
}
impl nsITaskbarPreviewCallback {
/// Cast this `nsITaskbarPreviewCallback` to one of its base interfaces.
#[inline]
pub fn coerce<T: nsITaskbarPreviewCallbackCoerce>(&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 nsITaskbarPreviewCallback {
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> nsITaskbarPreviewCallbackCoerce for T {
#[inline]
fn coerce_from(v: &nsITaskbarPreviewCallback) -> &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 nsITaskbarPreviewCallback
// 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 nsITaskbarPreviewCallbackVTable {
/// We need to include the members from the base interface's vtable at the start
/// of the VTable definition.
pub __base: nsISupportsVTable,
/* void done (in nsISupports aCanvas, in boolean aDrawBorder); */
pub Done: unsafe extern "system" fn (this: *const nsITaskbarPreviewCallback, aCanvas: *const nsISupports, aDrawBorder: 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 nsITaskbarPreviewCallback {
/// `void done (in nsISupports aCanvas, in boolean aDrawBorder);`
#[inline]
pub unsafe fn Done(&self, aCanvas: *const nsISupports, aDrawBorder: bool) -> ::nserror::nsresult {
((*self.vtable).Done)(self, aCanvas, aDrawBorder)
}
}
/// `interface nsITaskbarPreviewController : nsISupports`
///
/// ```text
/// /**
/// * nsITaskbarPreviewController
/// *
/// * nsITaskbarPreviewController provides the behavior for the taskbar previews.
/// * Its methods and properties are used by nsITaskbarPreview. Clients are
/// * intended to provide their own implementation of this interface. Depending on
/// * the interface the controller is attached to, only certain methods/attributes
/// * are required to be implemented.
/// */
/// ```
///
// 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 nsITaskbarPreviewController {
vtable: &'static nsITaskbarPreviewControllerVTable,
/// 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 nsITaskbarPreviewController.
unsafe impl XpCom for nsITaskbarPreviewController {
const IID: nsIID = nsID(0x8b427646, 0xe446, 0x4941,
[0xae, 0x0b, 0xc1, 0x12, 0x2a, 0x17, 0x3a, 0x68]);
}
// 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 nsITaskbarPreviewController {
#[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 nsITaskbarPreviewController.
// 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 nsITaskbarPreviewControllerCoerce {
/// Cheaply cast a value of this type from a `nsITaskbarPreviewController`.
fn coerce_from(v: &nsITaskbarPreviewController) -> &Self;
}
// The trivial implementation: We can obviously coerce ourselves to ourselves.
impl nsITaskbarPreviewControllerCoerce for nsITaskbarPreviewController {
#[inline]
fn coerce_from(v: &nsITaskbarPreviewController) -> &Self {
v
}
}
impl nsITaskbarPreviewController {
/// Cast this `nsITaskbarPreviewController` to one of its base interfaces.
#[inline]
pub fn coerce<T: nsITaskbarPreviewControllerCoerce>(&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 nsITaskbarPreviewController {
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> nsITaskbarPreviewControllerCoerce for T {
#[inline]
fn coerce_from(v: &nsITaskbarPreviewController) -> &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 nsITaskbarPreviewController
// 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 nsITaskbarPreviewControllerVTable {
/// We need to include the members from the base interface's vtable at the start
/// of the VTable definition.
pub __base: nsISupportsVTable,
/* readonly attribute unsigned long width; */
pub GetWidth: unsafe extern "system" fn (this: *const nsITaskbarPreviewController, aWidth: *mut u32) -> ::nserror::nsresult,
/* readonly attribute unsigned long height; */
pub GetHeight: unsafe extern "system" fn (this: *const nsITaskbarPreviewController, aHeight: *mut u32) -> ::nserror::nsresult,
/* readonly attribute float thumbnailAspectRatio; */
pub GetThumbnailAspectRatio: unsafe extern "system" fn (this: *const nsITaskbarPreviewController, aThumbnailAspectRatio: *mut libc::c_float) -> ::nserror::nsresult,
/* void requestPreview (in nsITaskbarPreviewCallback aCallback); */
pub RequestPreview: unsafe extern "system" fn (this: *const nsITaskbarPreviewController, aCallback: *const nsITaskbarPreviewCallback) -> ::nserror::nsresult,
/* void requestThumbnail (in nsITaskbarPreviewCallback aCallback, in unsigned long width, in unsigned long height); */
pub RequestThumbnail: unsafe extern "system" fn (this: *const nsITaskbarPreviewController, aCallback: *const nsITaskbarPreviewCallback, width: u32, height: u32) -> ::nserror::nsresult,
/* void onClose (); */
pub OnClose: unsafe extern "system" fn (this: *const nsITaskbarPreviewController) -> ::nserror::nsresult,
/* boolean onActivate (); */
pub OnActivate: unsafe extern "system" fn (this: *const nsITaskbarPreviewController, _retval: *mut bool) -> ::nserror::nsresult,
/* void onClick (in nsITaskbarPreviewButton button); */
pub OnClick: unsafe extern "system" fn (this: *const nsITaskbarPreviewController, button: *const nsITaskbarPreviewButton) -> ::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 nsITaskbarPreviewController {
/// ```text
/// /**
/// * The width of the preview image. This value is allowed to change at any
/// * time. See requestPreview for more information.
/// */
/// ```
///
/// `readonly attribute unsigned long width;`
#[inline]
pub unsafe fn GetWidth(&self, aWidth: *mut u32) -> ::nserror::nsresult {
((*self.vtable).GetWidth)(self, aWidth)
}
/// ```text
/// /**
/// * The height of the preview image. This value is allowed to change at any
/// * time. See requestPreview for more information.
/// */
/// ```
///
/// `readonly attribute unsigned long height;`
#[inline]
pub unsafe fn GetHeight(&self, aHeight: *mut u32) -> ::nserror::nsresult {
((*self.vtable).GetHeight)(self, aHeight)
}
/// ```text
/// /**
/// * The aspect ratio of the thumbnail - this does not need to match the ratio
/// * of the preview. This value is allowed to change at any time. See
/// * requestThumbnail for more information.
/// */
/// ```
///
/// `readonly attribute float thumbnailAspectRatio;`
#[inline]
pub unsafe fn GetThumbnailAspectRatio(&self, aThumbnailAspectRatio: *mut libc::c_float) -> ::nserror::nsresult {
((*self.vtable).GetThumbnailAspectRatio)(self, aThumbnailAspectRatio)
}
/// ```text
/// /**
/// * Invoked by nsITaskbarPreview when it needs to render the preview.
/// *
/// * @param aCallback Async callback the controller should invoke once
/// * the thumbnail is rendered. aCallback receives as its only parameter
/// * a canvas containing the preview image.
/// */
/// ```
///
/// `void requestPreview (in nsITaskbarPreviewCallback aCallback);`
#[inline]
pub unsafe fn RequestPreview(&self, aCallback: *const nsITaskbarPreviewCallback) -> ::nserror::nsresult {
((*self.vtable).RequestPreview)(self, aCallback)
}
/// ```text
/// /**
/// * Note: it is guaranteed that width/height == thumbnailAspectRatio
/// * (modulo rounding errors)
/// *
/// * Also note that the context is not attached to a canvas element.
/// *
/// * @param aCallback Async callback the controller should invoke once
/// * the thumbnail is rendered. aCallback receives as its only parameter
/// * a canvas containing the thumbnail image. Canvas dimensions should
/// * match the requested width or height otherwise setting the thumbnail
/// * will fail.
/// * @param width The width of the requested thumbnail
/// * @param height The height of the requested thumbnail
/// */
/// ```
///
/// `void requestThumbnail (in nsITaskbarPreviewCallback aCallback, in unsigned long width, in unsigned long height);`
#[inline]
pub unsafe fn RequestThumbnail(&self, aCallback: *const nsITaskbarPreviewCallback, width: u32, height: u32) -> ::nserror::nsresult {
((*self.vtable).RequestThumbnail)(self, aCallback, width, height)
}
/// ```text
/// /**
/// * Invoked when the user presses the close button on the tab preview.
/// */
/// ```
///
/// `void onClose ();`
#[inline]
pub unsafe fn OnClose(&self, ) -> ::nserror::nsresult {
((*self.vtable).OnClose)(self, )
}
/// ```text
/// /**
/// * Invoked when the user clicks on the tab preview.
/// *
/// * @return true if the top level window corresponding to the preview should
/// * be activated, false if activation is not accepted.
/// */
/// ```
///
/// `boolean onActivate ();`
#[inline]
pub unsafe fn OnActivate(&self, _retval: *mut bool) -> ::nserror::nsresult {
((*self.vtable).OnActivate)(self, _retval)
}
/// ```text
/// /**
/// * Invoked when one of the buttons on the window preview's toolbar is pressed.
/// *
/// * @param button The button that was pressed. This can be compared with the
/// * buttons returned by nsITaskbarWindowPreview.getButton.
/// */
/// ```
///
/// `void onClick (in nsITaskbarPreviewButton button);`
#[inline]
pub unsafe fn OnClick(&self, button: *const nsITaskbarPreviewButton) -> ::nserror::nsresult {
((*self.vtable).OnClick)(self, button)
}
}