Title: [132617] trunk/Source/WebKit2
Revision
132617
Author
[email protected]
Date
2012-10-26 04:32:25 -0700 (Fri, 26 Oct 2012)

Log Message

[EFL][WK2] Add Ewk_Color_Picker API
https://bugs.webkit.org/show_bug.cgi?id=100472

Patch by Christophe Dumez <[email protected]> on 2012-10-26
Reviewed by Kenneth Rohde Christiansen.

Move the color picker code out of EwkViewImpl and into
a new Ewk_Color_Picker class to avoid cluttering the
view code.

* PlatformEfl.cmake:
* UIProcess/API/efl/EWebKit2.h:
* UIProcess/API/efl/EwkViewImpl.cpp:
(EwkViewImpl::requestColorPicker):
(EwkViewImpl::dismissColorPicker):
* UIProcess/API/efl/EwkViewImpl.h:
(EwkViewImpl):
* UIProcess/API/efl/ewk_color_picker.cpp: Added.
(Ewk_Color_Picker::Ewk_Color_Picker):
(Ewk_Color_Picker::setColor):
(Ewk_Color_Picker::color):
(ewk_color_picker_color_set):
(ewk_color_picker_color_get):
* UIProcess/API/efl/ewk_color_picker.h: Added.
* UIProcess/API/efl/ewk_color_picker_private.h: Added.
(Ewk_Color_Picker):
(Ewk_Color_Picker::create):
* UIProcess/API/efl/ewk_view.cpp:
* UIProcess/API/efl/ewk_view.h:
* UIProcess/API/efl/tests/test_ewk2_color_picker.cpp: Added.
(onColorPickerDone):
(setColorPickerColor):
(showColorPicker):
(hideColorPicker):
(hideColorPickerByRemovingElement):
(TEST_F):
* UIProcess/API/efl/tests/test_ewk2_view.cpp:
* UIProcess/efl/PageUIClientEfl.cpp:
(WebKit::PageUIClientEfl::showColorPicker):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (132616 => 132617)


--- trunk/Source/WebKit2/ChangeLog	2012-10-26 11:26:28 UTC (rev 132616)
+++ trunk/Source/WebKit2/ChangeLog	2012-10-26 11:32:25 UTC (rev 132617)
@@ -1,3 +1,44 @@
+2012-10-26  Christophe Dumez  <[email protected]>
+
+        [EFL][WK2] Add Ewk_Color_Picker API
+        https://bugs.webkit.org/show_bug.cgi?id=100472
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Move the color picker code out of EwkViewImpl and into
+        a new Ewk_Color_Picker class to avoid cluttering the
+        view code.
+
+        * PlatformEfl.cmake:
+        * UIProcess/API/efl/EWebKit2.h:
+        * UIProcess/API/efl/EwkViewImpl.cpp:
+        (EwkViewImpl::requestColorPicker):
+        (EwkViewImpl::dismissColorPicker):
+        * UIProcess/API/efl/EwkViewImpl.h:
+        (EwkViewImpl):
+        * UIProcess/API/efl/ewk_color_picker.cpp: Added.
+        (Ewk_Color_Picker::Ewk_Color_Picker):
+        (Ewk_Color_Picker::setColor):
+        (Ewk_Color_Picker::color):
+        (ewk_color_picker_color_set):
+        (ewk_color_picker_color_get):
+        * UIProcess/API/efl/ewk_color_picker.h: Added.
+        * UIProcess/API/efl/ewk_color_picker_private.h: Added.
+        (Ewk_Color_Picker):
+        (Ewk_Color_Picker::create):
+        * UIProcess/API/efl/ewk_view.cpp:
+        * UIProcess/API/efl/ewk_view.h:
+        * UIProcess/API/efl/tests/test_ewk2_color_picker.cpp: Added.
+        (onColorPickerDone):
+        (setColorPickerColor):
+        (showColorPicker):
+        (hideColorPicker):
+        (hideColorPickerByRemovingElement):
+        (TEST_F):
+        * UIProcess/API/efl/tests/test_ewk2_view.cpp:
+        * UIProcess/efl/PageUIClientEfl.cpp:
+        (WebKit::PageUIClientEfl::showColorPicker):
+
 2012-10-26  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r132601.

Modified: trunk/Source/WebKit2/PlatformEfl.cmake (132616 => 132617)


--- trunk/Source/WebKit2/PlatformEfl.cmake	2012-10-26 11:26:28 UTC (rev 132616)
+++ trunk/Source/WebKit2/PlatformEfl.cmake	2012-10-26 11:32:25 UTC (rev 132617)
@@ -44,6 +44,7 @@
     UIProcess/API/efl/EwkViewImpl.cpp
     UIProcess/API/efl/ewk_back_forward_list.cpp
     UIProcess/API/efl/ewk_back_forward_list_item.cpp
+    UIProcess/API/efl/ewk_color_picker.cpp
     UIProcess/API/efl/ewk_context.cpp
     UIProcess/API/efl/ewk_cookie_manager.cpp
     UIProcess/API/efl/ewk_download_job.cpp
@@ -241,6 +242,7 @@
     "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/EWebKit2.h"
     "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_back_forward_list.h"
     "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_back_forward_list_item.h"
+    "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_color_picker.h"
     "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_context.h"
     "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_cookie_manager.h"
     "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_download_job.h"
@@ -341,6 +343,7 @@
 # will clash with tests from the WebKit 1 test suite.
 SET(EWK2UnitTests_BINARIES
     test_ewk2_back_forward_list
+    test_ewk2_color_picker
     test_ewk2_context
     test_ewk2_context_history_callbacks
     test_ewk2_cookie_manager

Modified: trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h (132616 => 132617)


--- trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h	2012-10-26 11:26:28 UTC (rev 132616)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EWebKit2.h	2012-10-26 11:32:25 UTC (rev 132617)
@@ -30,6 +30,7 @@
 
 #include "ewk_back_forward_list.h"
 #include "ewk_back_forward_list_item.h"
+#include "ewk_color_picker.h"
 #include "ewk_context.h"
 #include "ewk_cookie_manager.h"
 #include "ewk_download_job.h"

Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp (132616 => 132617)


--- trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp	2012-10-26 11:26:28 UTC (rev 132616)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp	2012-10-26 11:32:25 UTC (rev 132617)
@@ -32,11 +32,11 @@
 #include "PageViewportController.h"
 #include "PageViewportControllerClientEfl.h"
 #include "ResourceLoadClientEfl.h"
-#include "WKColorPickerResultListener.h"
 #include "WKString.h"
 #include "WebPageProxy.h"
 #include "WebPopupMenuProxyEfl.h"
 #include "ewk_back_forward_list_private.h"
+#include "ewk_color_picker_private.h"
 #include "ewk_context_private.h"
 #include "ewk_favicon_database_private.h"
 #include "ewk_popup_menu_item_private.h"
@@ -311,20 +311,6 @@
     evas_object_image_data_copy_set(sd->image, imageData);
 }
 
-#if ENABLE(INPUT_TYPE_COLOR)
-bool EwkViewImpl::setColorPickerColor(const WebCore::Color& color)
-{
-    if (!m_colorPickerResultListener)
-        return false;
-
-    WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(color.serialized().utf8().data()));
-    WKColorPickerResultListenerSetColor(m_colorPickerResultListener.get(), colorString.get());
-    m_colorPickerResultListener.clear();
-
-    return true;
-}
-#endif
-
 /**
  * @internal
  * informs load failed with error information.
@@ -756,14 +742,20 @@
  * @internal
  * Requests to show external color picker.
  */
-void EwkViewImpl::requestColorPicker(int r, int g, int b, int a, WKColorPickerResultListenerRef listener)
+void EwkViewImpl::requestColorPicker(WKColorPickerResultListenerRef listener, const WebCore::Color& color)
 {
     Ewk_View_Smart_Data* sd = smartData();
     EINA_SAFETY_ON_NULL_RETURN(sd->api->input_picker_color_request);
 
-    m_colorPickerResultListener = listener;
+    if (!sd->api->input_picker_color_request)
+        return;
 
-    sd->api->input_picker_color_request(sd, r, g, b, a);
+    if (m_colorPicker)
+        dismissColorPicker();
+
+    m_colorPicker = Ewk_Color_Picker::create(listener, color);
+
+    sd->api->input_picker_color_request(sd, m_colorPicker.get());
 }
 
 /**
@@ -772,12 +764,16 @@
  */
 void EwkViewImpl::dismissColorPicker()
 {
+    if (!m_colorPicker)
+        return;
+
     Ewk_View_Smart_Data* sd = smartData();
     EINA_SAFETY_ON_NULL_RETURN(sd->api->input_picker_color_dismiss);
 
-    m_colorPickerResultListener.clear();
+    if (sd->api->input_picker_color_dismiss)
+        sd->api->input_picker_color_dismiss(sd);
 
-    sd->api->input_picker_color_dismiss(sd);
+    m_colorPicker.clear();
 }
 #endif
 

Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h (132616 => 132617)


--- trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h	2012-10-26 11:26:28 UTC (rev 132616)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h	2012-10-26 11:32:25 UTC (rev 132617)
@@ -82,6 +82,7 @@
 }
 
 class Ewk_Back_Forward_List;
+class Ewk_Color_Picker;
 class Ewk_Context;
 class Ewk_Download_Job;
 class Ewk_Error;
@@ -135,10 +136,6 @@
     void redrawRegion(const WebCore::IntRect& rect);
     void setImageData(void* imageData, const WebCore::IntSize& size);
 
-#if ENABLE(INPUT_TYPE_COLOR)
-    bool setColorPickerColor(const WebCore::Color& color);
-#endif
-
     static void addToPageViewMap(const Evas_Object* ewkView);
     static void removeFromPageViewMap(const Evas_Object* ewkView);
     static const Evas_Object* viewFromPageViewMap(const WKPageRef);
@@ -155,7 +152,7 @@
 #endif
 
 #if ENABLE(INPUT_TYPE_COLOR)
-    void requestColorPicker(int r, int g, int b, int a, WKColorPickerResultListenerRef listener);
+    void requestColorPicker(WKColorPickerResultListenerRef listener, const WebCore::Color&);
     void dismissColorPicker();
 #endif
 
@@ -263,11 +260,11 @@
 #if ENABLE(TOUCH_EVENTS)
     bool m_touchEventsEnabled;
 #endif
-    WKRetainPtr<WKColorPickerResultListenerRef> m_colorPickerResultListener;
     WebCore::Timer<EwkViewImpl> m_displayTimer;
     WTF::Vector <WebCore::IntRect> m_dirtyRects;
     OwnPtr<Ewk_Popup_Menu> m_popupMenu;
     OwnPtr<WebKit::InputMethodContextEfl> m_inputMethodContext;
+    OwnPtr<Ewk_Color_Picker> m_colorPicker;
 
     typedef HashMap<WKPageRef, const Evas_Object*> PageViewMap;
     static PageViewMap pageViewMap;

Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_color_picker.cpp (0 => 132617)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_color_picker.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_color_picker.cpp	2012-10-26 11:32:25 UTC (rev 132617)
@@ -0,0 +1,84 @@
+/*
+   Copyright (C) 2011 Samsung Electronics
+   Copyright (C) 2012 Intel Corporation. All rights reserved.
+
+    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 "config.h"
+#include "ewk_color_picker.h"
+
+#include "WKColorPickerResultListener.h"
+#include "WKString.h"
+#include "ewk_color_picker_private.h"
+#include <WebCore/Color.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+#if ENABLE(INPUT_TYPE_COLOR)
+Ewk_Color_Picker::Ewk_Color_Picker(WKColorPickerResultListenerRef colorPickerListener, const Color& initialColor)
+    : m_colorPickerListener(colorPickerListener)
+    , m_color(initialColor)
+{
+}
+
+void Ewk_Color_Picker::setColor(const Color& color)
+{
+    WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(color.serialized().utf8().data()));
+    WKColorPickerResultListenerSetColor(m_colorPickerListener.get(), colorString.get());
+}
+
+const Color& Ewk_Color_Picker::color() const
+{
+    return m_color;
+}
+#endif
+
+Eina_Bool ewk_color_picker_color_set(Ewk_Color_Picker* colorPicker, int r, int g, int b, int a)
+{
+#if ENABLE(INPUT_TYPE_COLOR)
+    EINA_SAFETY_ON_NULL_RETURN_VAL(colorPicker, false);
+
+    colorPicker->setColor(Color(r, g, b, a));
+
+    return true;
+#else
+    return false;
+#endif
+}
+
+Eina_Bool ewk_color_picker_color_get(const Ewk_Color_Picker* colorPicker, int* r, int* g, int* b, int* a)
+{
+#if ENABLE(INPUT_TYPE_COLOR)
+    EINA_SAFETY_ON_NULL_RETURN_VAL(colorPicker, false);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(r, false);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(g, false);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(b, false);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(a, false);
+
+    const Color& color = colorPicker->color();
+    *r = color.red();
+    *g = color.green();
+    *b = color.blue();
+    *a = color.alpha();
+
+    return true;
+#else
+    return false;
+#endif
+}

Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_color_picker.h (0 => 132617)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_color_picker.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_color_picker.h	2012-10-26 11:32:25 UTC (rev 132617)
@@ -0,0 +1,67 @@
+/*
+   Copyright (C) 2011 Samsung Electronics
+   Copyright (C) 2012 Intel Corporation. All rights reserved.
+
+    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 ewk_color_picker_h
+#define ewk_color_picker_h
+
+#include <Evas.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Creates a type name for @a Ewk_Color_Picker. */
+typedef struct Ewk_Color_Picker Ewk_Color_Picker;
+
+/**
+ * Sets the selected color.
+ *
+ * The function should only be called when a color has been requested by the document.
+ * If called when this is not the case or when the input picker has been dismissed, this
+ * function will fail and return EINA_FALSE.
+ *
+ * @param color_picker color picker object
+ * @param r red channel value to be set
+ * @param g green channel value to be set
+ * @param b blue channel value to be set
+ * @param a alpha channel value to be set
+ *
+ * @return @c EINA_TRUE on success @c EINA_FALSE otherwise
+ */
+EAPI Eina_Bool ewk_color_picker_color_set(Ewk_Color_Picker *color_picker, int r, int g, int b, int a);
+
+/**
+ * Gets the currently selected color.
+ *
+ * @param color_picker color picker object
+ * @param r red channel value to be get
+ * @param g green channel value to be get
+ * @param b blue channel value to be get
+ * @param a alpha channel value to be get
+ *
+ * @return @c EINA_TRUE on success @c EINA_FALSE otherwise
+ */
+EAPI Eina_Bool ewk_color_picker_color_get(const Ewk_Color_Picker *color_picker, int *r, int *g, int *b, int *a);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ewk_color_picker_h */

Added: trunk/Source/WebKit2/UIProcess/API/efl/ewk_color_picker_private.h (0 => 132617)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_color_picker_private.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_color_picker_private.h	2012-10-26 11:32:25 UTC (rev 132617)
@@ -0,0 +1,49 @@
+/*
+   Copyright (C) 2011 Samsung Electronics
+   Copyright (C) 2012 Intel Corporation. All rights reserved.
+
+    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 ewk_color_picker_private_h
+#define ewk_color_picker_private_h
+
+#if ENABLE(INPUT_TYPE_COLOR)
+
+#include "WKRetainPtr.h"
+#include <WebCore/Color.h>
+#include <wtf/PassOwnPtr.h>
+
+class Ewk_Color_Picker {
+public:
+    static PassOwnPtr<Ewk_Color_Picker> create(WKColorPickerResultListenerRef colorPickerListener, const WebCore::Color& initialColor)
+    {
+        return adoptPtr(new Ewk_Color_Picker(colorPickerListener, initialColor));
+    }
+
+    const WebCore::Color& color() const;
+    void setColor(const WebCore::Color&);
+
+private:
+    Ewk_Color_Picker(WKColorPickerResultListenerRef colorPickerListener, const WebCore::Color& initialColor);
+
+    WKRetainPtr<WKColorPickerResultListenerRef> m_colorPickerListener;
+    WebCore::Color m_color;
+};
+
+#endif // ENABLE(INPUT_TYPE_COLOR)
+
+#endif // ewk_color_picker_private_h

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp (132616 => 132617)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-10-26 11:26:28 UTC (rev 132616)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp	2012-10-26 11:32:25 UTC (rev 132617)
@@ -986,18 +986,6 @@
     return impl->mouseEventsEnabled();
 }
 
-Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
-{
-#if ENABLE(INPUT_TYPE_COLOR)
-    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
-    EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
-
-    return impl->setColorPickerColor(WebCore::Color(r, g, b, a));
-#else
-    return false;
-#endif
-}
-
 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
 {
 #if ENABLE(TOUCH_EVENTS)

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h (132616 => 132617)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h	2012-10-26 11:26:28 UTC (rev 132616)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h	2012-10-26 11:32:25 UTC (rev 132617)
@@ -75,6 +75,7 @@
 #define ewk_view_h
 
 #include "ewk_back_forward_list.h"
+#include "ewk_color_picker.h"
 #include "ewk_context.h"
 #include "ewk_download_job.h"
 #include "ewk_error.h"
@@ -130,7 +131,7 @@
 
     // color picker:
     //   - Shows and hides color picker.
-    Eina_Bool (*input_picker_color_request)(Ewk_View_Smart_Data *sd, int r, int g, int b, int a);
+    Eina_Bool (*input_picker_color_request)(Ewk_View_Smart_Data *sd, Ewk_Color_Picker *color_picker);
     Eina_Bool (*input_picker_color_dismiss)(Ewk_View_Smart_Data *sd);
 
     // storage:
@@ -711,23 +712,6 @@
  */
 EAPI Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object *o);
 
-/*
- * Sets the user chosen color. To be used when implementing a color picker.
- *
- * The function should only be called when a color has been requested by the document.
- * If called when this is not the case or when the input picker has been dismissed, this
- * function will fail and return EINA_FALSE.
- *
- * @param o view object contains color picker
- * @param r red channel value to be set
- * @param g green channel value to be set
- * @param b blue channel value to be set
- * @param a alpha channel value to be set
- *
- * @return @c EINA_TRUE on success @c EINA_FALSE otherwise
- */
-EAPI Eina_Bool ewk_view_color_picker_color_set(Evas_Object *o, int r, int g, int b, int a);
-
 /**
  * Feeds the touch event to the view.
  *

Added: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_color_picker.cpp (0 => 132617)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_color_picker.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_color_picker.cpp	2012-10-26 11:32:25 UTC (rev 132617)
@@ -0,0 +1,164 @@
+/*
+    Copyright (C) 2012 Samsung Electronics
+    Copyright (C) 2012 Intel Corporation. All rights reserved.
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with this library; if not, write to the Free Software Foundation,
+    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "config.h"
+
+#include "UnitTestUtils/EWK2UnitTestBase.h"
+#include "UnitTestUtils/EWK2UnitTestEnvironment.h"
+#include <EWebKit2.h>
+#include <Ecore.h>
+
+using namespace EWK2UnitTest;
+
+extern EWK2UnitTestEnvironment* environment;
+
+#if ENABLE(INPUT_TYPE_COLOR)
+static const int initialRed = 0x12;
+static const int initialGreen = 0x34;
+static const int initialBlue = 0x56;
+static const int initialAlpha = 0xff;
+static const int changedRed = 0x98;
+static const int changedGreen = 0x76;
+static const int changedBlue = 0x54;
+static const int changedAlpha = 0xff;
+
+static bool s_isColorPickerShown = false;
+static Ewk_Color_Picker* s_colorPicker = 0;
+
+
+static void onColorPickerDone(void* userData, Evas_Object*, void*)
+{
+    bool* handled = static_cast<bool*>(userData);
+
+    *handled = true;
+}
+
+static unsigned char setColorPickerColor(void* data)
+{
+    Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
+
+    // 4. Change color to changed color.
+    EXPECT_TRUE(ewk_color_picker_color_set(s_colorPicker, changedRed, changedGreen, changedBlue, changedAlpha));
+
+    evas_object_smart_callback_call(smartData->self, "input,type,color,request", 0);
+
+    return 0;
+}
+
+static Eina_Bool showColorPicker(Ewk_View_Smart_Data* smartData, Ewk_Color_Picker* colorPicker)
+{
+    static bool isFirstRun = true;
+
+    s_colorPicker = colorPicker;
+    s_isColorPickerShown = true;
+
+    int r, g, b, a;
+    EXPECT_TRUE(ewk_color_picker_color_get(colorPicker, &r, &g, &b, &a));
+
+    if (isFirstRun) {
+        // 2. Check initial value from html file.
+        EXPECT_EQ(initialRed, r);
+        EXPECT_EQ(initialGreen, g);
+        EXPECT_EQ(initialBlue, b);
+        EXPECT_EQ(initialAlpha, a);
+
+        isFirstRun = false;
+    } else {
+        // 7. Input values should be same as changed color.
+        EXPECT_EQ(changedRed, r);
+        EXPECT_EQ(changedGreen, g);
+        EXPECT_EQ(changedBlue, b);
+        EXPECT_EQ(changedAlpha, a);
+
+        evas_object_smart_callback_call(smartData->self, "input,type,color,request", 0);
+        return true;
+    }
+
+    // 3. Return after making a color picker.
+    ecore_timer_add(0.0, setColorPickerColor, smartData);
+    return true;
+}
+
+static Eina_Bool hideColorPicker(Ewk_View_Smart_Data*)
+{
+    // 5. Test color picker is shown.
+    EXPECT_TRUE(s_isColorPickerShown);
+    s_isColorPickerShown = false;
+}
+
+static Eina_Bool hideColorPickerByRemovingElement(Ewk_View_Smart_Data* smartData)
+{
+    // 9. input_picker_color_dismiss() is called if the element is removed.
+    EXPECT_TRUE(s_isColorPickerShown);
+    s_isColorPickerShown = false;
+    evas_object_smart_callback_call(smartData->self, "input,type,color,request", 0);
+}
+
+TEST_F(EWK2UnitTestBase, ewk_color_picker_color_set)
+{
+    Ewk_View_Smart_Class* api = ewkViewClass();
+    api->input_picker_color_request = showColorPicker;
+    api->input_picker_color_dismiss = hideColorPicker;
+
+    const char colorPickerHTML[] =
+        "<!DOCTYPE html>"
+        "<html>"
+        "<head>"
+        "<script>function removeInputElement(){"
+        "var parentElement = document.getElementById('parent');"
+        "var inputElement = document.getElementById('color');"
+        "parentElement.removeChild(inputElement);"
+        "}</script>"
+        "</head>"
+        "<body>"
+        "<div id='parent'>"
+        "<input type='color' value='#123456' id='color'>"
+        "<button _onclick_='removeInputElement();'>Remove Element</button>"
+        "</div>"
+        "</body>"
+        "</html>";
+
+    ewk_view_html_string_load(webView(), colorPickerHTML, 0, 0);
+    waitUntilLoadFinished();
+
+    // 1. Click input element to show color picker.
+    mouseClick(30, 20);
+
+    bool handled = false;
+    evas_object_smart_callback_add(webView(), "input,type,color,request", onColorPickerDone, &handled);
+    while (!handled)
+        ecore_main_loop_iterate();
+
+    // 6. Click input element to show color picker again.
+    mouseClick(30, 20);
+
+    handled = false;
+    while (!handled)
+        ecore_main_loop_iterate();
+
+    // 8. Click button to remove input element durlng color picker is shown.
+    api->input_picker_color_dismiss = hideColorPickerByRemovingElement;
+    mouseClick(80, 20);
+
+    handled = false;
+    while (!handled)
+        ecore_main_loop_iterate();
+    evas_object_smart_callback_del(webView(), "input,type,color,request", onColorPickerDone);
+}
+#endif // ENABLE(INPUT_TYPE_COLOR)

Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp (132616 => 132617)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp	2012-10-26 11:26:28 UTC (rev 132616)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp	2012-10-26 11:32:25 UTC (rev 132617)
@@ -550,135 +550,6 @@
     EXPECT_FALSE(promptCallbackData.called);
 }
 
-#if ENABLE(INPUT_TYPE_COLOR)
-static const int initialRed = 0x12;
-static const int initialGreen = 0x34;
-static const int initialBlue = 0x56;
-static const int initialAlpha = 0xff;
-static const int changedRed = 0x98;
-static const int changedGreen = 0x76;
-static const int changedBlue = 0x54;
-static const int changedAlpha = 0xff;
-
-static bool isColorPickerShown = false;
-
-static void onColorPickerDone(void* userData, Evas_Object*, void*)
-{
-    bool* handled = static_cast<bool*>(userData);
-
-    *handled = true;
-}
-
-static unsigned char setColorPickerColor(void* data)
-{
-    Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
-
-    // 4. Change color to changed color.
-    EXPECT_TRUE(ewk_view_color_picker_color_set(smartData->self, changedRed, changedGreen, changedBlue, changedAlpha));
-
-    evas_object_smart_callback_call(smartData->self, "input,type,color,request", 0);
-
-    return 0;
-}
-
-static Eina_Bool showColorPicker(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
-{
-    static bool isFirstRun = true;
-
-    isColorPickerShown = true;
-
-    if (isFirstRun) {
-        // 2. Check initial value from html file.
-        EXPECT_EQ(initialRed, r);
-        EXPECT_EQ(initialGreen, g);
-        EXPECT_EQ(initialBlue, b);
-        EXPECT_EQ(initialAlpha, a);
-
-        isFirstRun = false;
-    } else {
-        // 7. Input values should be same as changed color.
-        EXPECT_EQ(changedRed, r);
-        EXPECT_EQ(changedGreen, g);
-        EXPECT_EQ(changedBlue, b);
-        EXPECT_EQ(changedAlpha, a);
-
-        evas_object_smart_callback_call(smartData->self, "input,type,color,request", 0);
-        return true;
-    }
-
-    // 3. Return after making a color picker.
-    ecore_timer_add(0.0, setColorPickerColor, smartData);
-    return true;
-}
-
-static Eina_Bool hideColorPicker(Ewk_View_Smart_Data*)
-{
-    // 5. Test color picker is shown.
-    EXPECT_TRUE(isColorPickerShown);
-    isColorPickerShown = false;
-}
-
-static Eina_Bool hideColorPickerByRemovingElement(Ewk_View_Smart_Data* smartData)
-{
-    // 9. input_picker_color_dismiss() is called if the element is removed.
-    EXPECT_TRUE(isColorPickerShown);
-    isColorPickerShown = false;
-    evas_object_smart_callback_call(smartData->self, "input,type,color,request", 0);
-}
-
-TEST_F(EWK2UnitTestBase, ewk_view_color_picker_color_set)
-{
-    Ewk_View_Smart_Class* api = ewkViewClass();
-    api->input_picker_color_request = showColorPicker;
-    api->input_picker_color_dismiss = hideColorPicker;
-
-    const char colorPickerHTML[] =
-        "<!DOCTYPE html>"
-        "<html>"
-        "<head>"
-        "<script>function removeInputElement(){"
-        "var parentElement = document.getElementById('parent');"
-        "var inputElement = document.getElementById('color');"
-        "parentElement.removeChild(inputElement);"
-        "}</script>"
-        "</head>"
-        "<body>"
-        "<div id='parent'>"
-        "<input type='color' value='#123456' id='color'>"
-        "<button _onclick_='removeInputElement();'>Remove Element</button>"
-        "</div>"
-        "</body>"
-        "</html>";
-
-    ewk_view_html_string_load(webView(), colorPickerHTML, 0, 0);
-    waitUntilLoadFinished();
-
-    // 1. Click input element to show color picker.
-    mouseClick(30, 20);
-
-    bool handled = false;
-    evas_object_smart_callback_add(webView(), "input,type,color,request", onColorPickerDone, &handled);
-    while (!handled)
-        ecore_main_loop_iterate();
-
-    // 6. Click input element to show color picker again.
-    mouseClick(30, 20);
-
-    handled = false;
-    while (!handled)
-        ecore_main_loop_iterate();
-
-    // 8. Click button to remove input element durlng color picker is shown.
-    api->input_picker_color_dismiss = hideColorPickerByRemovingElement;
-    mouseClick(80, 20);
-
-    handled = false;
-    while (!handled)
-        ecore_main_loop_iterate();
-    evas_object_smart_callback_del(webView(), "input,type,color,request", onColorPickerDone);
-}
-#endif // ENABLE(INPUT_TYPE_COLOR)
-
 TEST_F(EWK2UnitTestBase, ewk_view_context_get)
 {
     Ewk_Context* context = ewk_view_context_get(webView());

Modified: trunk/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp (132616 => 132617)


--- trunk/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp	2012-10-26 11:26:28 UTC (rev 132616)
+++ trunk/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp	2012-10-26 11:32:25 UTC (rev 132617)
@@ -72,7 +72,7 @@
 {
     PageUIClientEfl* pageUIClient = toPageUIClientEfl(clientInfo);
     WebCore::Color color = WebCore::Color(WebKit::toWTFString(initialColor));
-    pageUIClient->m_viewImpl->requestColorPicker(color.red(), color.green(), color.blue(), color.alpha(), listener);
+    pageUIClient->m_viewImpl->requestColorPicker(listener, color);
 }
 
 void PageUIClientEfl::hideColorPicker(WKPageRef, const void* clientInfo)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to