Skip to content
Permalink
Browse files
[GTK] Add default color chooser implementation using GtkColorChooserD…
…ialog

https://bugs.webkit.org/show_bug.cgi?id=141392

Reviewed by Gustavo Noronha Silva.

.:

Enable INPUT_TYPE_COLOR by default for GTK+ port.

* Source/cmake/OptionsGTK.cmake:

Source/WebKit2:

* PlatformGTK.cmake: Add new files to compilation.
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::createColorPicker): Call WebColorPickerGtk::create().
* UIProcess/gtk/WebColorPickerGtk.cpp: Added.
(WebKit::WebColorPickerGtk::create):
(WebKit::WebColorPickerGtk::WebColorPickerGtk):
(WebKit::WebColorPickerGtk::~WebColorPickerGtk):
(WebKit::WebColorPickerGtk::cancel): Set initial color.
(WebKit::WebColorPickerGtk::endPicker): Destroy the color chooser dialog.
(WebKit::WebColorPickerGtk::didChooseColor): Notify the client.
(WebKit::WebColorPickerGtk::colorChooserDialogRGBAChangedCallback):
Update the selected color.
(WebKit::WebColorPickerGtk::colorChooserDialogResponseCallback):
Cancel or finish the operation depending on the dialog response.
(WebKit::WebColorPickerGtk::showColorPicker): Create a
GtkColorChooserDialog to handle the color picker operation.
* UIProcess/gtk/WebColorPickerGtk.h: Added.
(WebKit::WebColorPickerGtk::initialColor):

Tools:

Enable INPUT_TYPE_COLOR by default for GTK+ port.

* Scripts/webkitperl/FeatureList.pm:

LayoutTests:

Unskip input color tests.

* platform/gtk/TestExpectations:
* platform/gtk/fast/forms/color/input-appearance-color-expected.txt: Added.

Canonical link: https://commits.webkit.org/159501@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179922 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgcampos committed Feb 11, 2015
1 parent 768b561 commit 025ede5679127524e3506322dcbf19747e7d5339
Showing 12 changed files with 369 additions and 8 deletions.
@@ -1,3 +1,14 @@
2015-02-11 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] Add default color chooser implementation using GtkColorChooserDialog
https://bugs.webkit.org/show_bug.cgi?id=141392

Reviewed by Gustavo Noronha Silva.

Enable INPUT_TYPE_COLOR by default for GTK+ port.

* Source/cmake/OptionsGTK.cmake:

2015-02-09 Sergio Villar Senin <svillar@igalia.com>

ASSERTION FAILED: resolvedInitialPosition <= resolvedFinalPosition in WebCore::GridSpan::GridSpan
@@ -1,3 +1,15 @@
2015-02-11 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] Add default color chooser implementation using GtkColorChooserDialog
https://bugs.webkit.org/show_bug.cgi?id=141392

Reviewed by Gustavo Noronha Silva.

Unskip input color tests.

* platform/gtk/TestExpectations:
* platform/gtk/fast/forms/color/input-appearance-color-expected.txt: Added.

2015-02-11 ChangSeok Oh <changseok.oh@collabora.com>

Div having contentEditable and display:flex cannot be edited if it is empty.
@@ -160,9 +160,6 @@ http/tests/notifications/legacy/double-show.html
# Datalist is not yet enabled.
webkit.org/b/98934 fast/forms/datalist [ Skip ]

# Color input is not yet enabled.
webkit.org/b/98935 fast/forms/color [ Skip ]

# ENABLE_INPUT_TYPE_* are not enabled.
webkit.org/b/98936 fast/forms/date [ Skip ]
webkit.org/b/98936 fast/forms/datetime [ Skip ]
@@ -0,0 +1,115 @@
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {H3} at (0,0) size 784x22
RenderText {#text} at (0,0) size 164x21
text run at (0,0) width 164: "Default Appearance"
RenderBlock (anonymous) at (0,40) size 784x42
RenderText {#text} at (0,0) size 456x17
text run at (0,0) width 456: "List color controls have different appearance if ENABLE(DATALIST)."
RenderBR {BR} at (456,14) size 0x0
RenderBlock {INPUT} at (0,18) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#000000] [border: (1px solid #777777)]
RenderBlock {INPUT} at (44,18) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#000000] [border: (1px solid #777777)]
RenderText {#text} at (0,0) size 0x0
RenderBlock {H3} at (0,100) size 784x23
RenderText {#text} at (0,0) size 160x21
text run at (0,0) width 160: "Different Font Sizes"
RenderBlock (anonymous) at (0,141) size 784x42
RenderText {#text} at (0,0) size 577x17
text run at (0,0) width 577: "List color controls have different sizes depending on font sizes. Normal color controls don't."
RenderBR {BR} at (577,14) size 0x0
RenderBlock {INPUT} at (0,18) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#00FF00] [border: (1px solid #777777)]
RenderText {#text} at (44,19) size 4x17
text run at (44,19) width 4: " "
RenderBlock {INPUT} at (48,18) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#00FF00] [border: (1px solid #777777)]
RenderText {#text} at (92,19) size 4x17
text run at (92,19) width 4: " "
RenderBlock {INPUT} at (96,18) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#00FF00] [border: (1px solid #777777)]
RenderText {#text} at (140,19) size 4x17
text run at (140,19) width 4: " "
RenderBlock {INPUT} at (144,18) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#00FF00] [border: (1px solid #777777)]
RenderText {#text} at (188,19) size 4x17
text run at (188,19) width 4: " "
RenderBlock {INPUT} at (192,18) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#00FF00] [border: (1px solid #777777)]
RenderText {#text} at (236,19) size 4x17
text run at (236,19) width 4: " "
RenderBlock {INPUT} at (240,18) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#00FF00] [border: (1px solid #777777)]
RenderText {#text} at (0,0) size 0x0
RenderBlock {H3} at (0,200) size 784x23
RenderText {#text} at (0,0) size 124x21
text run at (0,0) width 124: "Various Colors"
RenderBlock (anonymous) at (0,241) size 784x24
RenderBlock {INPUT} at (0,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#FF0000] [border: (1px solid #777777)]
RenderText {#text} at (44,1) size 4x17
text run at (44,1) width 4: " "
RenderBlock {INPUT} at (48,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#00FF00] [border: (1px solid #777777)]
RenderText {#text} at (92,1) size 4x17
text run at (92,1) width 4: " "
RenderBlock {INPUT} at (96,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#0000FF] [border: (1px solid #777777)]
RenderText {#text} at (140,1) size 4x17
text run at (140,1) width 4: " "
RenderBlock {INPUT} at (144,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#EC008C] [border: (1px solid #777777)]
RenderText {#text} at (188,1) size 4x17
text run at (188,1) width 4: " "
RenderBlock {INPUT} at (192,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#40E0D0] [border: (1px solid #777777)]
RenderText {#text} at (236,1) size 4x17
text run at (236,1) width 4: " "
RenderBlock {INPUT} at (240,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#FF0000] [border: (1px solid #777777)]
RenderText {#text} at (284,1) size 4x17
text run at (284,1) width 4: " "
RenderBlock {INPUT} at (288,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#00FF00] [border: (1px solid #777777)]
RenderText {#text} at (332,1) size 4x17
text run at (332,1) width 4: " "
RenderBlock {INPUT} at (336,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#0000FF] [border: (1px solid #777777)]
RenderText {#text} at (380,1) size 4x17
text run at (380,1) width 4: " "
RenderBlock {INPUT} at (384,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#EC008C] [border: (1px solid #777777)]
RenderText {#text} at (428,1) size 4x17
text run at (428,1) width 4: " "
RenderBlock {INPUT} at (432,0) size 44x23 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 38x17
RenderBlock {DIV} at (2,4) size 34x9 [bgcolor=#40E0D0] [border: (1px solid #777777)]
RenderText {#text} at (0,0) size 0x0
RenderBlock {H3} at (0,283) size 784x23
RenderText {#text} at (0,0) size 117x21
text run at (0,0) width 117: "Arbitrary Size"
RenderBlock (anonymous) at (0,324) size 784x31
RenderBlock {INPUT} at (0,0) size 100x30 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
RenderFlexibleBox {DIV} at (3,3) size 94x24
RenderBlock {DIV} at (2,4) size 90x16 [bgcolor=#FF0000] [border: (1px solid #777777)]
@@ -1,3 +1,29 @@
2015-02-11 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] Add default color chooser implementation using GtkColorChooserDialog
https://bugs.webkit.org/show_bug.cgi?id=141392

Reviewed by Gustavo Noronha Silva.

* PlatformGTK.cmake: Add new files to compilation.
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::createColorPicker): Call WebColorPickerGtk::create().
* UIProcess/gtk/WebColorPickerGtk.cpp: Added.
(WebKit::WebColorPickerGtk::create):
(WebKit::WebColorPickerGtk::WebColorPickerGtk):
(WebKit::WebColorPickerGtk::~WebColorPickerGtk):
(WebKit::WebColorPickerGtk::cancel): Set initial color.
(WebKit::WebColorPickerGtk::endPicker): Destroy the color chooser dialog.
(WebKit::WebColorPickerGtk::didChooseColor): Notify the client.
(WebKit::WebColorPickerGtk::colorChooserDialogRGBAChangedCallback):
Update the selected color.
(WebKit::WebColorPickerGtk::colorChooserDialogResponseCallback):
Cancel or finish the operation depending on the dialog response.
(WebKit::WebColorPickerGtk::showColorPicker): Create a
GtkColorChooserDialog to handle the color picker operation.
* UIProcess/gtk/WebColorPickerGtk.h: Added.
(WebKit::WebColorPickerGtk::initialColor):

2015-02-11 Commit Queue <commit-queue@webkit.org>

Unreviewed, rolling out r179910.
@@ -274,6 +274,7 @@ list(APPEND WebKit2_SOURCES
UIProcess/gtk/InputMethodFilter.cpp
UIProcess/gtk/RedirectedXCompositeWindow.cpp
UIProcess/gtk/TextCheckerGtk.cpp
UIProcess/gtk/WebColorPickerGtk.cpp
UIProcess/gtk/WebContextMenuProxyGtk.cpp
UIProcess/gtk/WebFullScreenClientGtk.cpp
UIProcess/gtk/WebInspectorClientGtk.cpp
@@ -32,6 +32,7 @@
#include "NativeWebKeyboardEvent.h"
#include "NativeWebMouseEvent.h"
#include "NotImplemented.h"
#include "WebColorPickerGtk.h"
#include "WebContextMenuProxyGtk.h"
#include "WebEventFactory.h"
#include "WebKitWebViewBasePrivate.h"
@@ -226,10 +227,9 @@ PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPagePr
}

#if ENABLE(INPUT_TYPE_COLOR)
PassRefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy*, const WebCore::Color&, const WebCore::IntRect&)
PassRefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy* page, const WebCore::Color& color, const WebCore::IntRect& rect)
{
notImplemented();
return 0;
return WebColorPickerGtk::create(*page, color, rect);
}
#endif

@@ -0,0 +1,115 @@
/*
* Copyright (C) 2015 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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 APPLE INC. AND ITS CONTRIBUTORS AS IS''
* 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 APPLE INC. OR ITS 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 "config.h"
#include "WebColorPickerGtk.h"

#if ENABLE(INPUT_TYPE_COLOR)

#include "WebPageProxy.h"
#include <WebCore/GtkUtilities.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>

using namespace WebCore;

namespace WebKit {

PassRefPtr<WebColorPickerGtk> WebColorPickerGtk::create(WebPageProxy& page, const Color& initialColor, const IntRect& rect)
{
return adoptRef(new WebColorPickerGtk(page, initialColor, rect));
}

WebColorPickerGtk::WebColorPickerGtk(WebPageProxy& page, const Color& initialColor, const IntRect&)
: WebColorPicker(&page)
, m_initialColor(initialColor)
, m_webView(page.viewWidget())
, m_colorChooser(nullptr)
{
}

WebColorPickerGtk::~WebColorPickerGtk()
{
endPicker();
}

void WebColorPickerGtk::cancel()
{
setSelectedColor(m_initialColor);
}

void WebColorPickerGtk::endPicker()
{
if (!m_colorChooser)
return;

gtk_widget_destroy(m_colorChooser);
m_colorChooser = nullptr;
}

void WebColorPickerGtk::didChooseColor(const Color& color)
{
if (!m_client)
return;

m_client->didChooseColor(color);
}

void WebColorPickerGtk::colorChooserDialogRGBAChangedCallback(GtkColorChooser* colorChooser, GParamSpec*, WebColorPickerGtk* colorPicker)
{
GdkRGBA rgba;
gtk_color_chooser_get_rgba(colorChooser, &rgba);
colorPicker->didChooseColor(rgba);
}

void WebColorPickerGtk::colorChooserDialogResponseCallback(GtkColorChooser*, int responseID, WebColorPickerGtk* colorPicker)
{
if (responseID != GTK_RESPONSE_OK)
colorPicker->cancel();
colorPicker->endPicker();
}

void WebColorPickerGtk::showColorPicker(const Color& color)
{
if (!m_client)
return;

m_initialColor = color;

if (!m_colorChooser) {
GtkWidget* toplevel = gtk_widget_get_toplevel(m_webView);
m_colorChooser = gtk_color_chooser_dialog_new(_("Select Color"), WebCore::widgetIsOnscreenToplevelWindow(toplevel) ? GTK_WINDOW(toplevel) : nullptr);
gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(m_colorChooser), &m_initialColor);
g_signal_connect(m_colorChooser, "notify::rgba", G_CALLBACK(WebColorPickerGtk::colorChooserDialogRGBAChangedCallback), this);
g_signal_connect(m_colorChooser, "response", G_CALLBACK(WebColorPickerGtk::colorChooserDialogResponseCallback), this);
} else
gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(m_colorChooser), &m_initialColor);

gtk_widget_show(m_colorChooser);
}

} // namespace WebKit

#endif // ENABLE(INPUT_TYPE_COLOR)

0 comments on commit 025ede5

Please sign in to comment.