Bug 1096804 - Add a new asynchronous callback interface for Windows taskbar thumbnail and preview image requests. r=roc

This commit is contained in:
Jim Mathies 2016-01-12 11:08:33 -06:00
parent 93496537f9
commit b0d530c8ed
3 changed files with 46 additions and 18 deletions

View File

@ -11,6 +11,18 @@ interface nsIDocShell;
interface nsITaskbarPreview;
interface nsITaskbarPreviewButton;
/**
* nsITaskbarPreviewCallback
*
* Provides an interface for async image result callbacks. See
* nsITaskbarPreviewController request apis below.
*/
[scriptable, function, uuid(f3744696-320d-4804-9c27-6a84c29acaa6)]
interface nsITaskbarPreviewCallback : nsISupports
{
void done(in nsISupports aCanvas, in boolean aDrawBorder);
};
/**
* nsITaskbarPreviewController
*
@ -20,7 +32,7 @@ interface nsITaskbarPreviewButton;
* the interface the controller is attached to, only certain methods/attributes
* are required to be implemented.
*/
[scriptable, uuid(4FC0AFBB-3E22-4FBA-AC21-953350AF0411)]
[scriptable, uuid(8b427646-e446-4941-ae0b-c1122a173a68)]
interface nsITaskbarPreviewController : nsISupports
{
/**
@ -42,31 +54,40 @@ interface nsITaskbarPreviewController : nsISupports
*/
readonly attribute float thumbnailAspectRatio;
/**
* Invoked by nsITaskbarPreview when it needs to render the preview. The
* context is attached to a surface with the controller's width and height
* which are obtained immediately before the call.
*
* Note that the context is not attached to a canvas element.
*
* @param ctx Canvas drawing context
*/
[deprecated]
boolean drawPreview(in nsISupports ctx);
[deprecated]
boolean drawThumbnail(in nsISupports ctx, in unsigned long width, in unsigned long height);
/**
* Invoked by the taskbar preview when it needs to draw the thumbnail in the
* taskbar's application preview window.
* 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);
/**
* An asynchronous version of drawPreview and drawThumbnail apis
* implemented in nsITaskbarPreviewController.
*
* Note: it is guaranteed that width/height == thumbnailAspectRatio
* (modulo rounding errors)
*
* Also note that the context is not attached to a canvas element.
*
* @param ctx Canvas drawing context
* @param width The width of the surface backing the drawing context
* @param height The height of the surface backing the drawing context
* @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
*/
boolean drawThumbnail(in nsISupports ctx, in unsigned long width, in unsigned long height);
void requestThumbnail(in nsITaskbarPreviewCallback aCallback,
in unsigned long width, in unsigned long height);
/**
* Invoked when the user presses the close button on the tab preview.
@ -89,4 +110,3 @@ interface nsITaskbarPreviewController : nsISupports
*/
void onClick(in nsITaskbarPreviewButton button);
};

View File

@ -13,7 +13,6 @@
{ 0x2d96b3d1, 0xc051, 0x11d1, \
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
/* BA7DE611-6088-11d3-A83E-00105A183419 */
#define NS_POPUP_CID \
{ 0xba7de611, 0x6088, 0x11d3, \
@ -44,6 +43,11 @@
{ 0x2d96b3e0, 0xc051, 0x11d1, \
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
/* 9A0CB62B-D638-4FAF-9588-AE96F5E29093 */
#define NS_TASKBARPREVIEWCALLBACK_CID \
{ 0x9a0cb62b, 0xd638, 0x4faf, \
{0x95, 0x88, 0xae, 0x96, 0xf5, 0xe2, 0x90, 0x93} }
/* XXX the following CID's are not in order. This needs
to be fixed. */

View File

@ -119,6 +119,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
NS_GENERIC_FACTORY_CONSTRUCTOR(TaskbarPreviewCallback)
#ifdef NS_PRINTING
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsWin, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorWin)
@ -156,6 +157,7 @@ NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTSHORTCUT_CID);
NS_DEFINE_NAMED_CID(NS_WINDOWS_UIUTILS_CID);
NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID);
NS_DEFINE_NAMED_CID(NS_TASKBARPREVIEWCALLBACK_CID);
#ifdef NS_PRINTING
NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_PRINTER_ENUMERATOR_CID);
@ -189,6 +191,7 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{ &kNS_WINDOWS_UIUTILS_CID, false, nullptr, WindowsUIUtilsConstructor },
{ &kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceConstructor, Module::MAIN_PROCESS_ONLY },
{ &kNS_BIDIKEYBOARD_CID, false, nullptr, nsBidiKeyboardConstructor },
{ &kNS_TASKBARPREVIEWCALLBACK_CID, false, nullptr, TaskbarPreviewCallbackConstructor },
#ifdef NS_PRINTING
{ &kNS_PRINTSETTINGSSERVICE_CID, false, nullptr, nsPrintOptionsWinConstructor },
{ &kNS_PRINTER_ENUMERATOR_CID, false, nullptr, nsPrinterEnumeratorWinConstructor },
@ -222,6 +225,7 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
{ "@mozilla.org/windows-ui-utils;1", &kNS_WINDOWS_UIUTILS_CID },
{ "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID, Module::MAIN_PROCESS_ONLY },
{ "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID },
{ "@mozilla.org/widget/taskbar-preview-callback;1", &kNS_TASKBARPREVIEWCALLBACK_CID },
#ifdef NS_PRINTING
{ "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID },
{ "@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID },