Bug 875747 - Add interface for nsIColorPicker widget. f=arnaud sr=roc
authorMounir Lamouri <mounir.lamouri@gmail.com>
Wed, 03 Jul 2013 11:17:26 +0100
changeset 149592 3f3153ceaba003163298778cd1838dc9985fd84e
parent 149591 370e660265f389f1897cd839a95cf0b2ec564476
child 149593 f472b2101d587e36c3bfe80392050ae94fc3d826
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs875747
milestone25.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 875747 - Add interface for nsIColorPicker widget. f=arnaud sr=roc
widget/moz.build
widget/nsIColorPicker.idl
widget/nsWidgetsCID.h
--- a/widget/moz.build
+++ b/widget/moz.build
@@ -64,16 +64,17 @@ XPIDL_SOURCES += [
     'nsIAppShell.idl',
     'nsIBaseWindow.idl',
     'nsIBidiKeyboard.idl',
     'nsIClipboard.idl',
     'nsIClipboardDragDropHookList.idl',
     'nsIClipboardDragDropHooks.idl',
     'nsIClipboardHelper.idl',
     'nsIClipboardOwner.idl',
+    'nsIColorPicker.idl',
     'nsIDragService.idl',
     'nsIDragSession.idl',
     'nsIFilePicker.idl',
     'nsIFormatConverter.idl',
     'nsIGfxInfo.idl',
     'nsIGfxInfoDebug.idl',
     'nsIIMEPicker.idl',
     'nsIIdleService.idl',
new file mode 100644
--- /dev/null
+++ b/widget/nsIColorPicker.idl
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; 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"
+
+interface nsIDOMWindow;
+
+/**
+ * nsIColorPicker is representing colors as strings because the internal
+ * representation will depend on the underlying backend.
+ * The format of the colors taken in input and returned will always follow the
+ * format of the <input type='color'> value as described in the HTML
+ * specifications.
+ */
+
+[scriptable, uuid(d2ce78d1-40b5-49d1-b66d-5801fcb9a385)]
+interface nsIColorPickerShownCallback : nsISupports
+{
+ /**
+  * Callback called when the color picker requests a color update.
+  * This callback can not be called after done() was called.
+  * When this callback is used, the consumer can assume that the color value has
+  * changed.
+  *
+  * @param  color  The new selected color value following the format specifed on
+  *                top of this file.
+  */
+ void update(in ACString color);
+
+ /**
+  * Callback called when the color picker is dismissed.
+  * When this callback is used, the color might have changed or could stay the
+  * same.
+  * If the color has not changed, the color parameter will be the empty string.
+  *
+  * @param  color  The new selected color value following the format specifed on
+  *                top of this file or the empty string.
+  */
+  void done(in ACString color);
+};
+
+[scriptable, uuid(3c3bdcce-54b1-4ae2-8647-1a8d4712ef2e)]
+interface nsIColorPicker : nsISupports
+{
+ /**
+  * Initialize the color picker widget. The color picker will not be shown until
+  * open() is called.
+  * If the backend doesn't support setting a title to the native color picker
+  * widget, the title parameter might be ignored.
+  * If the initialColor parameter does not follow the format specified on top of
+  * this file, the behavior will be unspecified. The initialColor could be the
+  * one used by the underlying backend or an arbitrary one. The backend could
+  * also assert.
+  *
+  * @param      parent       nsIDOMWindow parent. This dialog will be dependent
+  *                          on this parent. parent must be non-null.
+  * @param      title        The title for the color picker widget.
+  * @param      initialColor The color to show when the widget is opened. The
+  *                          parameter has to follow the format specified on top
+  *                          of this file.
+  */
+  void init(in nsIDOMWindow parent, in AString title, in ACString initialColor);
+
+ /**
+  * Opens the color dialog asynchrounously.
+  * The results are provided via the callback object.
+  */
+  void open(in nsIColorPickerShownCallback aColorPickerShownCallback);
+};
--- a/widget/nsWidgetsCID.h
+++ b/widget/nsWidgetsCID.h
@@ -19,16 +19,21 @@
 { 0xba7de611, 0x6088, 0x11d3,  \
     { 0xa8, 0x3e, 0x0, 0x10, 0x5a, 0x18, 0x34, 0x19 } }
 
 /* bd57cee8-1dd1-11b2-9fe7-95cf4709aea3 */
 #define NS_FILEPICKER_CID \
 { 0xbd57cee8, 0x1dd1, 0x11b2, \
     {0x9f, 0xe7, 0x95, 0xcf, 0x47, 0x09, 0xae, 0xa3} }
 
+/* 0f872c8c-3ee6-46bd-92a2-69652c6b474e */
+#define NS_COLORPICKER_CID \
+{ 0x0f872c8c, 0x3ee6, 0x46bd, \
+  { 0x92, 0xa2, 0x69, 0x65, 0x2c, 0x6b, 0x47, 0x4e } }
+
 /* 2d96b3df-c051-11d1-a827-0040959a28c9 */
 #define NS_APPSHELL_CID \
 { 0x2d96b3df, 0xc051, 0x11d1, \
     {0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
 
 /* 2d96b3e0-c051-11d1-a827-0040959a28c9 */
 #define NS_TOOLKIT_CID \
  { 0x2d96b3e0, 0xc051, 0x11d1, \