Bug 1096804 - Add a new asynchronous callback interface for Windows taskbar thumbnail and preview image requests. r=roc
authorJim Mathies <jmathies@mozilla.com>
Tue, 12 Jan 2016 11:08:33 -0600
changeset 279615 8afe4f072efd11c8d41a3718f71c01f429c264c8
parent 279614 49de4e1f40e6f0173e51b2e9f53b308341d5d2ac
child 279616 d71559a657745024ef2c2ef8835fcb070c387464
push id29885
push usercbook@mozilla.com
push dateWed, 13 Jan 2016 10:57:28 +0000
treeherdermozilla-central@531d1f6d1cde [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1096804
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1096804 - Add a new asynchronous callback interface for Windows taskbar thumbnail and preview image requests. r=roc
widget/nsITaskbarPreviewController.idl
widget/nsWidgetsCID.h
widget/windows/nsWidgetFactory.cpp
--- a/widget/nsITaskbarPreviewController.idl
+++ b/widget/nsITaskbarPreviewController.idl
@@ -7,25 +7,37 @@
 
 #include "nsISupports.idl"
 
 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
  *
  * 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.
  */
-[scriptable, uuid(4FC0AFBB-3E22-4FBA-AC21-953350AF0411)]
+[scriptable, uuid(8b427646-e446-4941-ae0b-c1122a173a68)]
 interface nsITaskbarPreviewController : nsISupports
 {
   /**
    * The width of the preview image. This value is allowed to change at any
    * time. See drawPreview for more information.
    */
   readonly attribute unsigned long width;
 
@@ -37,41 +49,50 @@ interface nsITaskbarPreviewController : 
 
   /**
    * 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
    * drawThumbnail for more information.
    */
   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.
    */
   void onClose();
 
   /**
    * Invoked when the user clicks on the tab preview.
@@ -84,9 +105,8 @@ interface nsITaskbarPreviewController : 
   /**
    * 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);
 };
-
--- a/widget/nsWidgetsCID.h
+++ b/widget/nsWidgetsCID.h
@@ -8,17 +8,16 @@
 { 0x2d96b3d0, 0xc051, 0x11d1, \
     {0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9}}
 
 /* 2d96b3d1-c051-11d1-a827-0040959a28c9 */
 #define NS_CHILD_CID \
 { 0x2d96b3d1, 0xc051, 0x11d1, \
     {0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
 
-
 /* BA7DE611-6088-11d3-A83E-00105A183419 */
 #define NS_POPUP_CID \
 { 0xba7de611, 0x6088, 0x11d3,  \
     { 0xa8, 0x3e, 0x0, 0x10, 0x5a, 0x18, 0x34, 0x19 } }
 
 /* bd57cee8-1dd1-11b2-9fe7-95cf4709aea3 */
 #define NS_FILEPICKER_CID \
 { 0xbd57cee8, 0x1dd1, 0x11b2, \
@@ -39,16 +38,21 @@
 { 0x2d96b3df, 0xc051, 0x11d1, \
     {0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
 
 /* 2d96b3e0-c051-11d1-a827-0040959a28c9 */
 #define NS_TOOLKIT_CID \
  { 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. */
 
 //-----------------------------------------------------------
 // Menus 
 //-----------------------------------------------------------
 
 // {0B3FE5AA-BC72-4303-85AE-76365DF1251D}
--- a/widget/windows/nsWidgetFactory.cpp
+++ b/widget/windows/nsWidgetFactory.cpp
@@ -114,16 +114,17 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListI
 NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListSeparator)
 NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListLink)
 NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListShortcut)
 NS_GENERIC_FACTORY_CONSTRUCTOR(WindowsUIUtils)
 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)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecWin)
 #endif
 
 namespace mozilla {
@@ -151,16 +152,17 @@ NS_DEFINE_NAMED_CID(NS_WIN_TASKBAR_CID);
 NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTBUILDER_CID);
 NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTITEM_CID);
 NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTSEPARATOR_CID);
 NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTLINK_CID);
 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);
 NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
 NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
 #endif
 
 
@@ -184,16 +186,17 @@ static const mozilla::Module::CIDEntry k
   { &kNS_WIN_JUMPLISTBUILDER_CID, false, nullptr, JumpListBuilderConstructor },
   { &kNS_WIN_JUMPLISTITEM_CID, false, nullptr, JumpListItemConstructor },
   { &kNS_WIN_JUMPLISTSEPARATOR_CID, false, nullptr, JumpListSeparatorConstructor },
   { &kNS_WIN_JUMPLISTLINK_CID, false, nullptr, JumpListLinkConstructor },
   { &kNS_WIN_JUMPLISTSHORTCUT_CID, false, nullptr, JumpListShortcutConstructor },
   { &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 },
   { &kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor },
   { &kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr, nsDeviceContextSpecWinConstructor },
 #endif
   { nullptr }
 };
@@ -217,16 +220,17 @@ static const mozilla::Module::ContractID
   { "@mozilla.org/windows-jumplistbuilder;1", &kNS_WIN_JUMPLISTBUILDER_CID },
   { "@mozilla.org/windows-jumplistitem;1", &kNS_WIN_JUMPLISTITEM_CID },
   { "@mozilla.org/windows-jumplistseparator;1", &kNS_WIN_JUMPLISTSEPARATOR_CID },
   { "@mozilla.org/windows-jumplistlink;1", &kNS_WIN_JUMPLISTLINK_CID },
   { "@mozilla.org/windows-jumplistshortcut;1", &kNS_WIN_JUMPLISTSHORTCUT_CID },
   { "@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 },
   { "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID },
   { "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID },
 #endif
   { nullptr }
 };