<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[179984] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/179984">179984</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2015-02-12 00:50:00 -0800 (Thu, 12 Feb 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] Add API to allow overriding the default color chooser implementation
https://bugs.webkit.org/show_bug.cgi?id=98935

Reviewed by Gustavo Noronha Silva.

Source/WebKit2:

Add API to allow the user to override the default UI of color
chooser. Similar to the file chooser API, a new run-color-chooser
signal is added to WebKitWebView that passes a WebKitColorChooserRequest
parameter to the signal.

Initial patch by Arnaud Renevier &lt;a.renevier@sisa.samsung.com&gt;.

* PlatformGTK.cmake: Add new files to compilation.
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::createColorPicker): Create a
WebKitColorChooser is the view widget is a WebKitWebView or a
WebColorPicker otherwise,
* UIProcess/API/gtk/WebKitColorChooser.cpp: Added.
(WebKit::WebKitColorChooser::create):
(WebKit::WebKitColorChooser::WebKitColorChooser):
(WebKit::WebKitColorChooser::~WebKitColorChooser):
(WebKit::WebKitColorChooser::endPicker): Chain up to parent class
when not having a request, or finish the request if we have one.
(WebKit::WebKitColorChooser::colorChooserRequestFinished):
(WebKit::WebKitColorChooser::colorChooserRequestRGBAChanged):
(WebKit::WebKitColorChooser::showColorPicker): Create a new
WebKitColorChooserRequest and emit WebKitWebView::run-color-chooser.
If the signal is not handled, fallback to the default color
chooser dialog implemented by the parent class.
* UIProcess/API/gtk/WebKitColorChooser.h: Added.
* UIProcess/API/gtk/WebKitColorChooserRequest.cpp: Added.
(webkitColorChooserRequestGetProperty):
(webkitColorChooserRequestSetProperty):
(webkit_color_chooser_request_class_init):
(webkit_color_chooser_request_set_rgba):
(webkit_color_chooser_request_get_rgba):
(webkit_color_chooser_request_get_element_rectangle):
(webkit_color_chooser_request_finish):
(webkit_color_chooser_request_cancel):
(webkitColorChooserRequestCreate):
* UIProcess/API/gtk/WebKitColorChooserRequest.h: Added.
* UIProcess/API/gtk/WebKitColorChooserRequestPrivate.h: Added.
* UIProcess/API/gtk/WebKitWebView.cpp:
(webkit_web_view_class_init): Add run-color-chooser signal.
(webkitWebViewEmitRunColorChooser): Emit run-color-chooser signal.
* UIProcess/API/gtk/WebKitWebView.h:
* UIProcess/API/gtk/WebKitWebViewPrivate.h:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Add new symbols.
* UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new section for WebKitColorChooserRequest.
* UIProcess/API/gtk/webkit2.h: Include WebKitColorChooserRequest.h

Tools:

Add a color chooser implementation for MiniBrowser using
GtkPopover when the GTK+ version is recent enough.
And a test case to check the new color chooser API.

* MiniBrowser/gtk/BrowserWindow.c:
(colorChooserRGBAChanged):
(popoverColorClosed):
(colorChooserRequestFinished):
(runColorChooserCallback):
(browserWindowConstructed):
* TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp:
(testWebViewColorChooserRequest):
(beforeAll):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformGTKcmake">trunk/Source/WebKit2/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkPageClientImplcpp">trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewcpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewPrivateh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtk40sectionstxt">trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtkdocssgml">trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkwebkit2h">trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsMiniBrowsergtkBrowserWindowc">trunk/Tools/MiniBrowser/gtk/BrowserWindow.c</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestUIClientcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitColorChoosercpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooser.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitColorChooserh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooser.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitColorChooserRequestcpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooserRequest.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitColorChooserRequesth">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooserRequest.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitColorChooserRequestPrivateh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooserRequestPrivate.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (179983 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-02-12 07:08:48 UTC (rev 179983)
+++ trunk/Source/WebKit2/ChangeLog        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -1,3 +1,56 @@
</span><ins>+2015-02-12  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Add API to allow overriding the default color chooser implementation
+        https://bugs.webkit.org/show_bug.cgi?id=98935
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Add API to allow the user to override the default UI of color
+        chooser. Similar to the file chooser API, a new run-color-chooser
+        signal is added to WebKitWebView that passes a WebKitColorChooserRequest
+        parameter to the signal.
+
+        Initial patch by Arnaud Renevier &lt;a.renevier@sisa.samsung.com&gt;.
+
+        * PlatformGTK.cmake: Add new files to compilation.
+        * UIProcess/API/gtk/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::createColorPicker): Create a
+        WebKitColorChooser is the view widget is a WebKitWebView or a
+        WebColorPicker otherwise,
+        * UIProcess/API/gtk/WebKitColorChooser.cpp: Added.
+        (WebKit::WebKitColorChooser::create):
+        (WebKit::WebKitColorChooser::WebKitColorChooser):
+        (WebKit::WebKitColorChooser::~WebKitColorChooser):
+        (WebKit::WebKitColorChooser::endPicker): Chain up to parent class
+        when not having a request, or finish the request if we have one.
+        (WebKit::WebKitColorChooser::colorChooserRequestFinished):
+        (WebKit::WebKitColorChooser::colorChooserRequestRGBAChanged):
+        (WebKit::WebKitColorChooser::showColorPicker): Create a new
+        WebKitColorChooserRequest and emit WebKitWebView::run-color-chooser.
+        If the signal is not handled, fallback to the default color
+        chooser dialog implemented by the parent class.
+        * UIProcess/API/gtk/WebKitColorChooser.h: Added.
+        * UIProcess/API/gtk/WebKitColorChooserRequest.cpp: Added.
+        (webkitColorChooserRequestGetProperty):
+        (webkitColorChooserRequestSetProperty):
+        (webkit_color_chooser_request_class_init):
+        (webkit_color_chooser_request_set_rgba):
+        (webkit_color_chooser_request_get_rgba):
+        (webkit_color_chooser_request_get_element_rectangle):
+        (webkit_color_chooser_request_finish):
+        (webkit_color_chooser_request_cancel):
+        (webkitColorChooserRequestCreate):
+        * UIProcess/API/gtk/WebKitColorChooserRequest.h: Added.
+        * UIProcess/API/gtk/WebKitColorChooserRequestPrivate.h: Added.
+        * UIProcess/API/gtk/WebKitWebView.cpp:
+        (webkit_web_view_class_init): Add run-color-chooser signal.
+        (webkitWebViewEmitRunColorChooser): Emit run-color-chooser signal.
+        * UIProcess/API/gtk/WebKitWebView.h:
+        * UIProcess/API/gtk/WebKitWebViewPrivate.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Add new symbols.
+        * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new section for WebKitColorChooserRequest.
+        * UIProcess/API/gtk/webkit2.h: Include WebKitColorChooserRequest.h
+
</ins><span class="cx"> 2015-02-11  Enrica Casucci  &lt;enrica@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         iOS build fix.
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PlatformGTK.cmake (179983 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PlatformGTK.cmake        2015-02-12 07:08:48 UTC (rev 179983)
+++ trunk/Source/WebKit2/PlatformGTK.cmake        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -101,6 +101,8 @@
</span><span class="cx">     UIProcess/API/gtk/WebKitBackForwardListItem.cpp
</span><span class="cx">     UIProcess/API/gtk/WebKitBackForwardListItem.h
</span><span class="cx">     UIProcess/API/gtk/WebKitBackForwardListPrivate.h
</span><ins>+    UIProcess/API/gtk/WebKitColorChooser.cpp
+    UIProcess/API/gtk/WebKitColorChooserRequest.cpp
</ins><span class="cx">     UIProcess/API/gtk/WebKitContextMenu.cpp
</span><span class="cx">     UIProcess/API/gtk/WebKitContextMenu.h
</span><span class="cx">     UIProcess/API/gtk/WebKitContextMenuActions.cpp
</span><span class="lines">@@ -347,6 +349,7 @@
</span><span class="cx">     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitAuthenticationRequest.h
</span><span class="cx">     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitBackForwardList.h
</span><span class="cx">     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitBackForwardListItem.h
</span><ins>+    ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitColorChooserRequest.h
</ins><span class="cx">     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitCredential.h
</span><span class="cx">     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitContextMenu.h
</span><span class="cx">     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitContextMenuActions.h
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkPageClientImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp (179983 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp        2015-02-12 07:08:48 UTC (rev 179983)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -35,6 +35,8 @@
</span><span class="cx"> #include &quot;WebColorPickerGtk.h&quot;
</span><span class="cx"> #include &quot;WebContextMenuProxyGtk.h&quot;
</span><span class="cx"> #include &quot;WebEventFactory.h&quot;
</span><ins>+#include &quot;WebKitColorChooser.h&quot;
+#include &quot;WebKitWebView.h&quot;
</ins><span class="cx"> #include &quot;WebKitWebViewBasePrivate.h&quot;
</span><span class="cx"> #include &quot;WebPageProxy.h&quot;
</span><span class="cx"> #include &quot;WebPopupMenuProxyGtk.h&quot;
</span><span class="lines">@@ -226,12 +228,12 @@
</span><span class="cx">     return WebContextMenuProxyGtk::create(m_viewWidget, page);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if ENABLE(INPUT_TYPE_COLOR)
</del><span class="cx"> PassRefPtr&lt;WebColorPicker&gt; PageClientImpl::createColorPicker(WebPageProxy* page, const WebCore::Color&amp; color, const WebCore::IntRect&amp; rect)
</span><span class="cx"> {
</span><ins>+    if (WEBKIT_IS_WEB_VIEW(m_viewWidget))
+        return WebKitColorChooser::create(*page, color, rect);
</ins><span class="cx">     return WebColorPickerGtk::create(*page, color, rect);
</span><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> void PageClientImpl::setTextIndicator(PassRefPtr&lt;WebCore::TextIndicator&gt;, bool /* fadeOut */)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitColorChoosercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooser.cpp (0 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooser.cpp                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooser.cpp        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -0,0 +1,83 @@
</span><ins>+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;WebKitColorChooser.h&quot;
+
+#include &quot;WebKitColorChooserRequestPrivate.h&quot;
+#include &quot;WebKitWebViewPrivate.h&quot;
+#include &lt;WebCore/Color.h&gt;
+#include &lt;WebCore/IntRect.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr&lt;WebKitColorChooser&gt; WebKitColorChooser::create(WebPageProxy&amp; page, const WebCore::Color&amp; initialColor, const WebCore::IntRect&amp; rect)
+{
+    return adoptRef(new WebKitColorChooser(page, initialColor, rect));
+}
+
+WebKitColorChooser::WebKitColorChooser(WebPageProxy&amp; page, const Color&amp; initialColor, const IntRect&amp; rect)
+    : WebColorPickerGtk(page, initialColor, rect)
+    , m_elementRect(rect)
+{
+}
+
+WebKitColorChooser::~WebKitColorChooser()
+{
+    endPicker();
+}
+
+void WebKitColorChooser::endPicker()
+{
+    if (!m_request) {
+        WebColorPickerGtk::endPicker();
+        return;
+    }
+
+    webkit_color_chooser_request_finish(m_request.get());
+}
+
+void WebKitColorChooser::colorChooserRequestFinished(WebKitColorChooserRequest*, WebKitColorChooser* colorChooser)
+{
+    colorChooser-&gt;m_request = nullptr;
+}
+
+void WebKitColorChooser::colorChooserRequestRGBAChanged(WebKitColorChooserRequest* request, GParamSpec*, WebKitColorChooser* colorChooser)
+{
+    GdkRGBA rgba;
+    webkit_color_chooser_request_get_rgba(request, &amp;rgba);
+    colorChooser-&gt;didChooseColor(rgba);
+}
+
+void WebKitColorChooser::showColorPicker(const Color&amp; color)
+{
+    m_initialColor = color;
+    GRefPtr&lt;WebKitColorChooserRequest&gt; request = adoptGRef(webkitColorChooserRequestCreate(this));
+    g_signal_connect(request.get(), &quot;notify::rgba&quot;, G_CALLBACK(WebKitColorChooser::colorChooserRequestRGBAChanged), this);
+    g_signal_connect(request.get(), &quot;finished&quot;, G_CALLBACK(WebKitColorChooser::colorChooserRequestFinished), this);
+
+    if (webkitWebViewEmitRunColorChooser(WEBKIT_WEB_VIEW(m_webView), request.get()))
+        m_request = request;
+    else
+        WebColorPickerGtk::showColorPicker(color);
+}
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitColorChooserh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooser.h (0 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooser.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooser.h        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitColorChooser_h
+#define WebKitColorChooser_h
+
+#include &quot;WebColorPickerGtk.h&quot;
+#include &quot;WebKitPrivate.h&quot;
+#include &lt;wtf/gobject/GRefPtr.h&gt;
+
+typedef struct _WebKitColorChooserRequest WebKitColorChooserRequest;
+
+namespace WebCore {
+class Color;
+class IntRect;
+}
+
+namespace WebKit {
+
+class WebKitColorChooser final : public WebColorPickerGtk {
+public:
+    static PassRefPtr&lt;WebKitColorChooser&gt; create(WebPageProxy&amp;, const WebCore::Color&amp;, const WebCore::IntRect&amp;);
+    virtual ~WebKitColorChooser();
+
+    const WebCore::IntRect&amp; elementRect() const { return m_elementRect; }
+
+private:
+    WebKitColorChooser(WebPageProxy&amp;, const WebCore::Color&amp;, const WebCore::IntRect&amp;);
+
+    virtual void endPicker() override;
+    virtual void showColorPicker(const WebCore::Color&amp;) override;
+
+    static void colorChooserRequestFinished(WebKitColorChooserRequest*, WebKitColorChooser*);
+    static void colorChooserRequestRGBAChanged(WebKitColorChooserRequest*, GParamSpec*, WebKitColorChooser*);
+
+    GRefPtr&lt;WebKitColorChooserRequest&gt; m_request;
+    WebCore::IntRect m_elementRect;
+};
+
+} // namespace WebKit
+
+#endif // WebKitColorChooser_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitColorChooserRequestcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooserRequest.cpp (0 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooserRequest.cpp                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooserRequest.cpp        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -0,0 +1,264 @@
</span><ins>+/*
+ * Copyright (C) 2015 Igalia S.L.
+ * Copyright (c) 2012, Samsung Electronics
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot;
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;WebKitColorChooserRequest.h&quot;
+
+#include &quot;WebKitColorChooserRequestPrivate.h&quot;
+#include &lt;glib/gi18n-lib.h&gt;
+
+using namespace WebKit;
+using namespace WebCore;
+
+/**
+ * SECTION: WebKitColorChooserRequest
+ * @Short_description: A request to open a color chooser
+ * @Title: WebKitColorChooserRequest
+ * @See_also: #WebKitWebView
+ *
+ * Whenever the user interacts with an &amp;lt;input type='color' /&amp;gt;
+ * HTML element, WebKit will need to show a dialog to choose a color. For that
+ * to happen in a general way, instead of just opening a #GtkColorChooser
+ * (which might be not desirable in some cases, which could prefer to use their
+ * own color chooser dialog), WebKit will fire the
+ * #WebKitWebView::run-color-chooser signal with a #WebKitColorChooserRequest
+ * object, which will allow the client application to specify the color to be
+ * selected, to inspect the details of the request (e.g. to get initial color)
+ * and to cancel the request, in case nothing was selected.
+ *
+ * In case the client application does not wish to handle this signal,
+ * WebKit will provide a default handler which will asynchronously run
+ * a regular #GtkColorChooserDialog for the user to interact with.
+ */
+
+enum {
+    PROP_0,
+
+    PROP_RGBA
+};
+
+enum {
+    FINISHED,
+
+    LAST_SIGNAL
+};
+
+struct _WebKitColorChooserRequestPrivate {
+    WebKitColorChooser* colorChooser;
+    GdkRGBA rgba;
+    bool handled;
+};
+
+static guint signals[LAST_SIGNAL] = { 0, };
+
+WEBKIT_DEFINE_TYPE(WebKitColorChooserRequest, webkit_color_chooser_request, G_TYPE_OBJECT)
+
+static void webkitColorChooserRequestDispose(GObject* object)
+{
+    WebKitColorChooserRequest* request = WEBKIT_COLOR_CHOOSER_REQUEST(object);
+    if (!request-&gt;priv-&gt;handled)
+        webkit_color_chooser_request_finish(request);
+
+    G_OBJECT_CLASS(webkit_color_chooser_request_parent_class)-&gt;dispose(object);
+}
+
+static void webkitColorChooserRequestGetProperty(GObject* object, guint propertyID, GValue* value, GParamSpec* paramSpec)
+{
+    WebKitColorChooserRequest* request = WEBKIT_COLOR_CHOOSER_REQUEST(object);
+
+    switch (propertyID) {
+    case PROP_RGBA:
+        g_value_set_boxed(value, &amp;request-&gt;priv-&gt;rgba);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, paramSpec);
+    }
+}
+
+static void webkitColorChooserRequestSetProperty(GObject* object, guint propertyID, const GValue* value, GParamSpec* paramSpec)
+{
+    WebKitColorChooserRequest* request = WEBKIT_COLOR_CHOOSER_REQUEST(object);
+
+    switch (propertyID) {
+    case PROP_RGBA:
+        webkit_color_chooser_request_set_rgba(request, static_cast&lt;GdkRGBA*&gt;(g_value_get_boxed(value)));
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, paramSpec);
+    }
+}
+
+static void webkit_color_chooser_request_class_init(WebKitColorChooserRequestClass* requestClass)
+{
+    GObjectClass* objectClass = G_OBJECT_CLASS(requestClass);
+    objectClass-&gt;dispose = webkitColorChooserRequestDispose;
+    objectClass-&gt;get_property = webkitColorChooserRequestGetProperty;
+    objectClass-&gt;set_property = webkitColorChooserRequestSetProperty;
+
+    /**
+     * WebKitWebView:rgba:
+     *
+     * The #GdkRGBA color of the request
+     *
+     * Since: 2.8
+     */
+    g_object_class_install_property(objectClass,
+        PROP_RGBA,
+        g_param_spec_boxed(&quot;rgba&quot;,
+            _(&quot;Current RGBA color&quot;),
+            _(&quot;The current RGBA color for the request&quot;),
+            GDK_TYPE_RGBA,
+            static_cast&lt;GParamFlags&gt;(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT)));
+
+    /**
+     * WebKitColorChooserRequest::finished:
+     * @request: the #WebKitColorChooserRequest on which the signal is emitted
+     *
+     * Emitted when the @request finishes. This signal can be emitted because the
+     * user completed the @request calling webkit_color_chooser_request_finish(),
+     * or cancelled it with webkit_color_chooser_request_cancel() or because the
+     * color input element is removed from the DOM.
+     *
+     * Since: 2.8
+     */
+    signals[FINISHED] =
+        g_signal_new(
+            &quot;finished&quot;,
+            G_TYPE_FROM_CLASS(requestClass),
+            G_SIGNAL_RUN_LAST,
+            0, 0,
+            nullptr,
+            g_cclosure_marshal_VOID__VOID,
+            G_TYPE_NONE, 0);
+}
+
+/**
+ * webkit_color_chooser_request_set_rgba:
+ * @request: a #WebKitFileChooserRequest
+ * @rgba: a pointer #GdkRGBA
+ *
+ * Sets the current #GdkRGBA color of @request
+ *
+ * Since: 2.8
+ */
+void webkit_color_chooser_request_set_rgba(WebKitColorChooserRequest* request, const GdkRGBA* rgba)
+{
+    g_return_if_fail(WEBKIT_IS_COLOR_CHOOSER_REQUEST(request));
+    g_return_if_fail(rgba);
+
+    if (gdk_rgba_equal(&amp;request-&gt;priv-&gt;rgba, rgba))
+        return;
+
+    request-&gt;priv-&gt;rgba = *rgba;
+    g_object_notify(G_OBJECT(request), &quot;rgba&quot;);
+}
+
+/**
+ * webkit_color_chooser_request_get_rgba:
+ * @request: a #WebKitColorChooserRequest
+ * @rgba: (out): a #GdkRGBA to fill in with the current color.
+ *
+ * Gets the current #GdkRGBA color of @request
+ *
+ * Since: 2.8
+ */
+void webkit_color_chooser_request_get_rgba(WebKitColorChooserRequest* request, GdkRGBA* rgba)
+{
+    g_return_if_fail(WEBKIT_IS_COLOR_CHOOSER_REQUEST(request));
+    g_return_if_fail(rgba);
+
+    *rgba = request-&gt;priv-&gt;rgba;
+}
+
+/**
+ * webkit_color_chooser_request_get_element_rectangle:
+ * @request: a #WebKitColorChooserRequest
+ * @rect: (out): a #GdkRectangle to fill in with the element area
+ *
+ * Gets the bounding box of the color input element.
+ *
+ * Since: 2.8
+ */
+void webkit_color_chooser_request_get_element_rectangle(WebKitColorChooserRequest* request, GdkRectangle* rect)
+{
+    g_return_if_fail(WEBKIT_IS_COLOR_CHOOSER_REQUEST(request));
+    g_return_if_fail(rect);
+
+    *rect = request-&gt;priv-&gt;colorChooser-&gt;elementRect();
+}
+
+/**
+ * webkit_color_chooser_request_finish:
+ * @request: a #WebKitColorChooserRequest
+ *
+ * Finishes @request and the input element keeps the current value of
+ * #WebKitColorChooserRequest:rgba.
+ * The signal #WebKitColorChooserRequest::finished
+ * is emitted to notify that the request has finished.
+ *
+ * Since: 2.8
+ */
+void webkit_color_chooser_request_finish(WebKitColorChooserRequest* request)
+{
+    g_return_if_fail(WEBKIT_IS_COLOR_CHOOSER_REQUEST(request));
+
+    if (request-&gt;priv-&gt;handled)
+        return;
+
+    request-&gt;priv-&gt;handled = true;
+    g_signal_emit(request, signals[FINISHED], 0);
+}
+
+/**
+ * webkit_color_chooser_request_cancel:
+ * @request: a #WebKitColorChooserRequest
+ *
+ * Cancels @request and the input element changes to use the initial color
+ * it has before the request started.
+ * The signal #WebKitColorChooserRequest::finished
+ * is emitted to notify that the request has finished.
+ *
+ * Since: 2.8
+ */
+void webkit_color_chooser_request_cancel(WebKitColorChooserRequest* request)
+{
+    g_return_if_fail(WEBKIT_IS_COLOR_CHOOSER_REQUEST(request));
+
+    if (request-&gt;priv-&gt;handled)
+        return;
+
+    request-&gt;priv-&gt;handled = true;
+    request-&gt;priv-&gt;colorChooser-&gt;cancel();
+    g_signal_emit(request, signals[FINISHED], 0);
+}
+
+WebKitColorChooserRequest* webkitColorChooserRequestCreate(WebKitColorChooser* colorChooser)
+{
+    WebKitColorChooserRequest* request = WEBKIT_COLOR_CHOOSER_REQUEST(
+        g_object_new(WEBKIT_TYPE_COLOR_CHOOSER_REQUEST, &quot;rgba&quot;, colorChooser-&gt;initialColor(), nullptr));
+    request-&gt;priv-&gt;colorChooser = colorChooser;
+    return request;
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitColorChooserRequesth"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooserRequest.h (0 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooserRequest.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooserRequest.h        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -0,0 +1,84 @@
</span><ins>+/*
+ * Copyright (C) 2015 Igalia S.L.
+ * Copyright (c) 2012, Samsung Electronics
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot;
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) &amp;&amp; !defined(WEBKIT2_COMPILATION)
+#error &quot;Only &lt;webkit2/webkit2.h&gt; can be included directly.&quot;
+#endif
+
+#ifndef WebKitColorChooserRequest_h
+#define WebKitColorChooserRequest_h
+
+#include &lt;gtk/gtk.h&gt;
+#include &lt;webkit2/WebKitDefines.h&gt;
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_COLOR_CHOOSER_REQUEST            (webkit_color_chooser_request_get_type())
+#define WEBKIT_COLOR_CHOOSER_REQUEST(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_COLOR_CHOOSER_REQUEST, WebKitColorChooserRequest))
+#define WEBKIT_IS_COLOR_CHOOSER_REQUEST(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_COLOR_CHOOSER_REQUEST))
+#define WEBKIT_COLOR_CHOOSER_REQUEST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_COLOR_CHOOSER_REQUEST, WebKitColorChooserRequestClass))
+#define WEBKIT_IS_COLOR_CHOOSER_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_COLOR_CHOOSER_REQUEST))
+#define WEBKIT_COLOR_CHOOSER_REQUEST_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_COLOR_CHOOSER_REQUEST, WebKitColorChooserRequestClass))
+
+typedef struct _WebKitColorChooserRequest        WebKitColorChooserRequest;
+typedef struct _WebKitColorChooserRequestClass   WebKitColorChooserRequestClass;
+typedef struct _WebKitColorChooserRequestPrivate WebKitColorChooserRequestPrivate;
+
+struct _WebKitColorChooserRequest {
+    GObject parent;
+
+    /*&lt; private &gt;*/
+    WebKitColorChooserRequestPrivate *priv;
+};
+
+struct _WebKitColorChooserRequestClass {
+    GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_color_chooser_request_get_type              (void);
+
+WEBKIT_API void
+webkit_color_chooser_request_get_rgba              (WebKitColorChooserRequest *request,
+                                                    GdkRGBA                   *rgba);
+
+WEBKIT_API void
+webkit_color_chooser_request_set_rgba              (WebKitColorChooserRequest *request,
+                                                    const GdkRGBA             *rgba);
+
+WEBKIT_API void
+webkit_color_chooser_request_get_element_rectangle (WebKitColorChooserRequest *request,
+                                                    GdkRectangle              *rect);
+
+WEBKIT_API void
+webkit_color_chooser_request_finish                (WebKitColorChooserRequest *request);
+
+WEBKIT_API void
+webkit_color_chooser_request_cancel                (WebKitColorChooserRequest *request);
+
+G_END_DECLS
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitColorChooserRequestPrivateh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooserRequestPrivate.h (0 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooserRequestPrivate.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitColorChooserRequestPrivate.h        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+/*
+ * Copyright (C) 2015 Igalia S.L.
+ * Copyright (c) 2012, Samsung Electronics
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot;
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebKitColorChooserRequestPrivate_h
+#define WebKitColorChooserRequestPrivate_h
+
+#include &quot;WebKitColorChooser.h&quot;
+#include &quot;WebKitColorChooserRequest.h&quot;
+
+WebKitColorChooserRequest* webkitColorChooserRequestCreate(WebKit::WebKitColorChooser*);
+
+#endif // WebKitColorChooserRequestPrivate_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (179983 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp        2015-02-12 07:08:48 UTC (rev 179983)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -132,6 +132,8 @@
</span><span class="cx"> 
</span><span class="cx">     SHOW_NOTIFICATION,
</span><span class="cx"> 
</span><ins>+    RUN_COLOR_CHOOSER,
+
</ins><span class="cx">     LAST_SIGNAL
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="lines">@@ -1714,6 +1716,40 @@
</span><span class="cx">             webkit_marshal_BOOLEAN__OBJECT,
</span><span class="cx">             G_TYPE_BOOLEAN, 1,
</span><span class="cx">             WEBKIT_TYPE_NOTIFICATION);
</span><ins>+
+     /**
+      * WebKitWebView::run-color-chooser:
+      * @web_view: the #WebKitWebView on which the signal is emitted
+      * @request: a #WebKitColorChooserRequest
+      *
+      * This signal is emitted when the user interacts with a &amp;lt;input
+      * type='color' /&amp;gt; HTML element, requesting from WebKit to show
+      * a dialog to select a color. To let the application know the details of
+      * the color chooser, as well as to allow the client application to either
+      * cancel the request or perform an actual color selection, the signal will
+      * pass an instance of the #WebKitColorChooserRequest in the @request
+      * argument.
+      *
+      * It is possible to handle this request asynchronously by increasing the
+      * reference count of the request.
+      *
+      * The default signal handler will asynchronously run a regular
+      * #GtkColorChooser for the user to interact with.
+      *
+      * Returns: %TRUE to stop other handlers from being invoked for the event.
+      *   %FALSE to propagate the event further.
+      *
+      * Since: 2.8
+      */
+    signals[RUN_COLOR_CHOOSER] =
+        g_signal_new(&quot;run-color-chooser&quot;,
+            G_TYPE_FROM_CLASS(webViewClass),
+            G_SIGNAL_RUN_LAST,
+            G_STRUCT_OFFSET(WebKitWebViewClass, run_color_chooser),
+            g_signal_accumulator_true_handled, nullptr,
+            webkit_marshal_BOOLEAN__OBJECT,
+            G_TYPE_BOOLEAN, 1,
+            WEBKIT_TYPE_COLOR_CHOOSER_REQUEST);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void webkitWebViewCancelAuthenticationRequest(WebKitWebView* webView)
</span><span class="lines">@@ -2091,6 +2127,13 @@
</span><span class="cx">     return handled;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool webkitWebViewEmitRunColorChooser(WebKitWebView* webView, WebKitColorChooserRequest* request)
+{
+    gboolean handled;
+    g_signal_emit(webView, signals[RUN_COLOR_CHOOSER], 0, request, &amp;handled);
+    return handled;
+}
+
</ins><span class="cx"> /**
</span><span class="cx">  * webkit_web_view_new:
</span><span class="cx">  *
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h (179983 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h        2015-02-12 07:08:48 UTC (rev 179983)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include &lt;webkit2/WebKitAuthenticationRequest.h&gt;
</span><span class="cx"> #include &lt;webkit2/WebKitBackForwardList.h&gt;
</span><span class="cx"> #include &lt;webkit2/WebKitDefines.h&gt;
</span><ins>+#include &lt;webkit2/WebKitColorChooserRequest.h&gt;
</ins><span class="cx"> #include &lt;webkit2/WebKitFileChooserRequest.h&gt;
</span><span class="cx"> #include &lt;webkit2/WebKitFindController.h&gt;
</span><span class="cx"> #include &lt;webkit2/WebKitFormSubmissionRequest.h&gt;
</span><span class="lines">@@ -244,12 +245,13 @@
</span><span class="cx">                                                 GTlsCertificateFlags         errors);
</span><span class="cx">     gboolean   (* show_notification)           (WebKitWebView               *web_view,
</span><span class="cx">                                                 WebKitNotification          *notification);
</span><ins>+    gboolean   (* run_color_chooser)           (WebKitWebView               *web_view,
+                                                WebKitColorChooserRequest   *request);
</ins><span class="cx"> 
</span><span class="cx">     void (*_webkit_reserved0) (void);
</span><span class="cx">     void (*_webkit_reserved1) (void);
</span><span class="cx">     void (*_webkit_reserved2) (void);
</span><span class="cx">     void (*_webkit_reserved3) (void);
</span><del>-    void (*_webkit_reserved4) (void);
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> WEBKIT_API GType
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h (179983 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h        2015-02-12 07:08:48 UTC (rev 179983)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx"> void webkitWebViewHandleAuthenticationChallenge(WebKitWebView*, WebKit::AuthenticationChallengeProxy*);
</span><span class="cx"> void webkitWebViewInsecureContentDetected(WebKitWebView*, WebKitInsecureContentEvent);
</span><span class="cx"> bool webkitWebViewEmitShowNotification(WebKitWebView*, WebKitNotification*);
</span><ins>+bool webkitWebViewEmitRunColorChooser(WebKitWebView*, WebKitColorChooserRequest*);
</ins><span class="cx"> void webkitWebViewWebProcessCrashed(WebKitWebView*);
</span><span class="cx"> void webkitWebViewIsPlayingAudioChanged(WebKitWebView*);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtk40sectionstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt (179983 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt        2015-02-12 07:08:48 UTC (rev 179983)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -1247,3 +1247,26 @@
</span><span class="cx"> WebKitWebHitTestResultPrivate
</span><span class="cx"> webkit_web_hit_test_result_get_type
</span><span class="cx"> &lt;/SECTION&gt;
</span><ins>+
+&lt;SECTION&gt;
+&lt;FILE&gt;WebKitColorChooserRequest&lt;/FILE&gt;
+WebKitColorChooserRequest
+webkit_color_chooser_request_get_rgba
+webkit_color_chooser_request_set_rgba
+webkit_color_chooser_request_get_element_rectangle
+webkit_color_chooser_request_finish
+webkit_color_chooser_request_cancel
+
+&lt;SUBSECTION Standard&gt;
+WebKitColorChooserRequestClass
+WEBKIT_TYPE_COLOR_CHOOSER_REQUEST
+WEBKIT_COLOR_CHOOSER_REQUEST
+WEBKIT_IS_COLOR_CHOOSER_REQUEST
+WEBKIT_COLOR_CHOOSER_REQUEST_CLASS
+WEBKIT_IS_COLOR_CHOOSER_REQUEST_CLASS
+WEBKIT_COLOR_CHOOSER_REQUEST_GET_CLASS
+
+&lt;SUBSECTION Private&gt;
+WebKitColorChooserRequestPrivate
+webkit_color_chooser_request_get_type
+&lt;/SECTION&gt;
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtkdocssgml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml (179983 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml        2015-02-12 07:08:48 UTC (rev 179983)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx">     &lt;xi:include href=&quot;xml/WebKitWebResource.xml&quot;/&gt;
</span><span class="cx">     &lt;xi:include href=&quot;xml/WebKitError.xml&quot;/&gt;
</span><span class="cx">     &lt;xi:include href=&quot;xml/WebKitFaviconDatabase.xml&quot;/&gt;
</span><ins>+    &lt;xi:include href=&quot;xml/WebKitColorChooserRequest.xml&quot;/&gt;
</ins><span class="cx">     &lt;xi:include href=&quot;xml/WebKitFileChooserRequest.xml&quot;/&gt;
</span><span class="cx">     &lt;xi:include href=&quot;xml/WebKitFindController.xml&quot;/&gt;
</span><span class="cx">     &lt;xi:include href=&quot;xml/WebKitCookieManager.xml&quot;/&gt;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkwebkit2h"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h (179983 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h        2015-02-12 07:08:48 UTC (rev 179983)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> #include &lt;webkit2/WebKitEnumTypes.h&gt;
</span><span class="cx"> #include &lt;webkit2/WebKitError.h&gt;
</span><span class="cx"> #include &lt;webkit2/WebKitFaviconDatabase.h&gt;
</span><ins>+#include &lt;webkit2/WebKitColorChooserRequest.h&gt;
</ins><span class="cx"> #include &lt;webkit2/WebKitFileChooserRequest.h&gt;
</span><span class="cx"> #include &lt;webkit2/WebKitFindController.h&gt;
</span><span class="cx"> #include &lt;webkit2/WebKitFormSubmissionRequest.h&gt;
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (179983 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-02-12 07:08:48 UTC (rev 179983)
+++ trunk/Tools/ChangeLog        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2015-02-12  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Add API to allow overriding the default color chooser implementation
+        https://bugs.webkit.org/show_bug.cgi?id=98935
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Add a color chooser implementation for MiniBrowser using
+        GtkPopover when the GTK+ version is recent enough.
+        And a test case to check the new color chooser API.
+
+        * MiniBrowser/gtk/BrowserWindow.c:
+        (colorChooserRGBAChanged):
+        (popoverColorClosed):
+        (colorChooserRequestFinished):
+        (runColorChooserCallback):
+        (browserWindowConstructed):
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp:
+        (testWebViewColorChooserRequest):
+        (beforeAll):
+
</ins><span class="cx"> 2015-02-11  Csaba Osztrogon√°c  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Make run-jsc-stress-tests --remote work with make-based runner
</span></span></pre></div>
<a id="trunkToolsMiniBrowsergtkBrowserWindowc"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/gtk/BrowserWindow.c (179983 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/gtk/BrowserWindow.c        2015-02-12 07:08:48 UTC (rev 179983)
+++ trunk/Tools/MiniBrowser/gtk/BrowserWindow.c        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -501,6 +501,51 @@
</span><span class="cx">     return browserWindowZoomOut(window);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if GTK_CHECK_VERSION(3, 12, 0)
+static void colorChooserRGBAChanged(GtkColorChooser *colorChooser, GParamSpec *paramSpec, WebKitColorChooserRequest *request)
+{
+    GdkRGBA rgba;
+    gtk_color_chooser_get_rgba(colorChooser, &amp;rgba);
+    webkit_color_chooser_request_set_rgba(request, &amp;rgba);
+}
+
+static void popoverColorClosed(GtkWidget *popover, WebKitColorChooserRequest *request)
+{
+    webkit_color_chooser_request_finish(request);
+}
+
+static void colorChooserRequestFinished(WebKitColorChooserRequest *request, GtkWidget *popover)
+{
+    g_object_unref(request);
+    gtk_widget_destroy(popover);
+}
+
+static gboolean runColorChooserCallback(WebKitWebView *webView, WebKitColorChooserRequest *request, BrowserWindow *window)
+{
+    GtkWidget *popover = gtk_popover_new(GTK_WIDGET(webView));
+
+    GdkRectangle rectangle;
+    webkit_color_chooser_request_get_element_rectangle(request, &amp;rectangle);
+    gtk_popover_set_pointing_to(GTK_POPOVER(popover), &amp;rectangle);
+
+    GtkWidget *colorChooser = gtk_color_chooser_widget_new();
+    GdkRGBA rgba;
+    webkit_color_chooser_request_get_rgba(request, &amp;rgba);
+    gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(colorChooser), &amp;rgba);
+    g_signal_connect(colorChooser, &quot;notify::rgba&quot;, G_CALLBACK(colorChooserRGBAChanged), request);
+    gtk_container_add(GTK_CONTAINER(popover), colorChooser);
+    gtk_widget_show(colorChooser);
+
+    g_object_ref(request);
+    g_signal_connect_object(popover, &quot;hide&quot;, G_CALLBACK(popoverColorClosed), request, 0);
+    g_signal_connect_object(request, &quot;finished&quot;, G_CALLBACK(colorChooserRequestFinished), popover, 0);
+
+    gtk_widget_show(popover);
+
+    return TRUE;
+}
+#endif /* GTK_CHECK_VERSION(3, 12, 0) */
+
</ins><span class="cx"> static void browserWindowUpdateZoomActions(BrowserWindow *window)
</span><span class="cx"> {
</span><span class="cx">     gtk_widget_set_sensitive(window-&gt;zoomInItem, browserWindowCanZoomIn(window));
</span><span class="lines">@@ -838,6 +883,9 @@
</span><span class="cx">     g_signal_connect(window-&gt;webView, &quot;leave-fullscreen&quot;, G_CALLBACK(webViewLeaveFullScreen), window);
</span><span class="cx">     g_signal_connect(window-&gt;webView, &quot;notify::is-loading&quot;, G_CALLBACK(webViewIsLoadingChanged), window);
</span><span class="cx">     g_signal_connect(window-&gt;webView, &quot;scroll-event&quot;, G_CALLBACK(scrollEventCallback), window);
</span><ins>+#if GTK_CHECK_VERSION(3, 12, 0)
+    g_signal_connect(window-&gt;webView, &quot;run-color-chooser&quot;, G_CALLBACK(runColorChooserCallback), window);
+#endif
</ins><span class="cx"> 
</span><span class="cx">     g_signal_connect(webkit_web_view_get_context(window-&gt;webView), &quot;download-started&quot;, G_CALLBACK(downloadStarted), window);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestUIClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp (179983 => 179984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp        2015-02-12 07:08:48 UTC (rev 179983)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestUIClient.cpp        2015-02-12 08:50:00 UTC (rev 179984)
</span><span class="lines">@@ -857,6 +857,108 @@
</span><span class="cx">     webkit_file_chooser_request_cancel(fileChooserRequest);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+class ColorChooserTest: public WebViewTest {
+public:
+    MAKE_GLIB_TEST_FIXTURE(ColorChooserTest);
+
+    static gboolean runColorChooserCallback(WebKitWebView*, WebKitColorChooserRequest* request, ColorChooserTest* test)
+    {
+        test-&gt;runColorChooser(request);
+        return TRUE;
+    }
+
+    static void requestFinishedCallback(WebKitColorChooserRequest* request, ColorChooserTest* test)
+    {
+        g_assert(test-&gt;m_request.get() == request);
+        test-&gt;m_request = nullptr;
+        if (g_main_loop_is_running(test-&gt;m_mainLoop))
+            g_main_loop_quit(test-&gt;m_mainLoop);
+    }
+
+    ColorChooserTest()
+    {
+        g_signal_connect(m_webView, &quot;run-color-chooser&quot;, G_CALLBACK(runColorChooserCallback), this);
+    }
+
+    void runColorChooser(WebKitColorChooserRequest* request)
+    {
+        g_assert(WEBKIT_IS_COLOR_CHOOSER_REQUEST(request));
+        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+        m_request = request;
+        g_signal_connect(request, &quot;finished&quot;, G_CALLBACK(requestFinishedCallback), this);
+        g_main_loop_quit(m_mainLoop);
+    }
+
+    void finishRequest()
+    {
+        g_assert(m_request.get());
+        webkit_color_chooser_request_finish(m_request.get());
+        g_assert(!m_request);
+    }
+
+    void cancelRequest()
+    {
+        g_assert(m_request.get());
+        webkit_color_chooser_request_cancel(m_request.get());
+        g_assert(!m_request);
+    }
+
+    WebKitColorChooserRequest* clickMouseButtonAndWaitForColorChooserRequest(int x, int y)
+    {
+        clickMouseButton(x, y);
+        g_main_loop_run(m_mainLoop);
+        g_assert(m_request.get());
+        return m_request.get();
+    }
+
+private:
+    GRefPtr&lt;WebKitColorChooserRequest&gt; m_request;
+};
+
+static void testWebViewColorChooserRequest(ColorChooserTest* test, gconstpointer)
+{
+    static const char* colorChooserHTMLFormat = &quot;&lt;html&gt;&lt;body&gt;&lt;input style='position:absolute;left:1;top:1;margin:0;padding:0;width:45;height:25' type='color' %s/&gt;&lt;/body&gt;&lt;/html&gt;&quot;;
+    test-&gt;showInWindowAndWaitUntilMapped();
+
+    GUniquePtr&lt;char&gt; defaultColorHTML(g_strdup_printf(colorChooserHTMLFormat, &quot;&quot;));
+    test-&gt;loadHtml(defaultColorHTML.get(), nullptr);
+    test-&gt;waitUntilLoadFinished();
+    WebKitColorChooserRequest* request = test-&gt;clickMouseButtonAndWaitForColorChooserRequest(5, 5);
+
+    // Default color is black (#000000).
+    GdkRGBA rgba1;
+    GdkRGBA rgba2 = { 0., 0., 0., 1. };
+    webkit_color_chooser_request_get_rgba(request, &amp;rgba1);
+    g_assert(gdk_rgba_equal(&amp;rgba1, &amp;rgba2));
+
+    // Set a different color.
+    rgba2.green = 1;
+    webkit_color_chooser_request_set_rgba(request, &amp;rgba2);
+    webkit_color_chooser_request_get_rgba(request, &amp;rgba1);
+    g_assert(gdk_rgba_equal(&amp;rgba1, &amp;rgba2));
+
+    GdkRectangle rect;
+    webkit_color_chooser_request_get_element_rectangle(request, &amp;rect);
+    g_assert_cmpint(rect.x, == , 1);
+    g_assert_cmpint(rect.y, == , 1);
+    g_assert_cmpint(rect.width, == , 45);
+    g_assert_cmpint(rect.height, == , 25);
+
+    test-&gt;finishRequest();
+
+    // Use an initial color.
+    GUniquePtr&lt;char&gt; initialColorHTML(g_strdup_printf(colorChooserHTMLFormat, &quot;value='#FF00FF'&quot;));
+    test-&gt;loadHtml(initialColorHTML.get(), nullptr);
+    test-&gt;waitUntilLoadFinished();
+    request = test-&gt;clickMouseButtonAndWaitForColorChooserRequest(5, 5);
+
+    webkit_color_chooser_request_get_rgba(request, &amp;rgba1);
+    GdkRGBA rgba3 = { 1., 0., 1., 1. };
+    g_assert(gdk_rgba_equal(&amp;rgba1, &amp;rgba3));
+
+    test-&gt;cancelRequest();
+}
+
</ins><span class="cx"> void beforeAll()
</span><span class="cx"> {
</span><span class="cx">     UIClientTest::add(&quot;WebKitWebView&quot;, &quot;create-ready-close&quot;, testWebViewCreateReadyClose);
</span><span class="lines">@@ -870,6 +972,7 @@
</span><span class="cx">     UIClientTest::add(&quot;WebKitWebView&quot;, &quot;usermedia-permission-requests&quot;, testWebViewUserMediaPermissionRequests);
</span><span class="cx">     UIClientTest::add(&quot;WebKitWebView&quot;, &quot;audio-usermedia-permission-request&quot;, testWebViewAudioOnlyUserMediaPermissionRequests);
</span><span class="cx">     FileChooserTest::add(&quot;WebKitWebView&quot;, &quot;file-chooser-request&quot;, testWebViewFileChooserRequest);
</span><ins>+    ColorChooserTest::add(&quot;WebKitWebView&quot;, &quot;color-chooser-request&quot;, testWebViewColorChooserRequest);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void afterAll()
</span></span></pre>
</div>
</div>

</body>
</html>