Changeset 129121 in webkit
- Timestamp:
- Sep 20, 2012 5:09:08 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r129116 r129121 1 2012-09-20 KwangYong Choi <ky0.choi@samsung.com> 2 3 [EFL][WK2] Implemented color picker API 4 https://bugs.webkit.org/show_bug.cgi?id=91832 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Add support for color picker API for EFL port in WebKit2. 9 10 The external application can implement input picker by overriding 11 smart class function. 12 13 * UIProcess/API/efl/ewk_view.cpp: 14 (_Ewk_View_Private_Data): 15 (_Ewk_View_Private_Data::_Ewk_View_Private_Data): 16 (ewk_view_color_picker_request): 17 (ewk_view_color_picker_dismiss): 18 (ewk_view_color_picker_color_set): 19 * UIProcess/API/efl/ewk_view.h: 20 * UIProcess/API/efl/ewk_view_private.h: 21 * UIProcess/API/efl/ewk_view_ui_client.cpp: 22 (showColorPicker): 23 (hideColorPicker): 24 (ewk_view_ui_client_attach): 25 * UIProcess/API/efl/tests/test_ewk2_view.cpp: 26 (onColorPickerDone): 27 (setColorPickerColor): 28 (showColorPicker): 29 (hideColorPicker): 30 (TEST_F): 31 1 32 2012-09-20 Balazs Kelemen <kbalazs@webkit.org> 2 33 -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
r129101 r129121 27 27 #include "PageClientImpl.h" 28 28 #include "WKAPICast.h" 29 #include "WKColorPickerResultListener.h" 29 30 #include "WKEinaSharedString.h" 30 31 #include "WKFindOptions.h" … … 99 100 OwnPtr<Ewk_Settings> settings; 100 101 bool areMouseEventsEnabled; 102 WKColorPickerResultListenerRef colorPickerResultListener; 101 103 102 104 WebPopupMenuProxyEfl* popupMenuProxy; … … 117 119 , backForwardList(0) 118 120 , areMouseEventsEnabled(false) 121 , colorPickerResultListener(0) 119 122 , popupMenuProxy(0) 120 123 , popupMenuItems(0) … … 1698 1701 return WKEinaSharedString::adopt(smartData->api->run_javascript_prompt(smartData, message, defaultValue)); 1699 1702 } 1703 1704 #if ENABLE(INPUT_TYPE_COLOR) 1705 /** 1706 * @internal 1707 * Reqeusts to show external color picker. 1708 */ 1709 void ewk_view_color_picker_request(Evas_Object* ewkView, int r, int g, int b, int a, WKColorPickerResultListenerRef listener) 1710 { 1711 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); 1712 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); 1713 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_request); 1714 1715 priv->colorPickerResultListener = listener; 1716 1717 smartData->api->input_picker_color_request(smartData, r, g, b, a); 1718 } 1719 1720 /** 1721 * @internal 1722 * Reqeusts to hide external color picker. 1723 */ 1724 void ewk_view_color_picker_dismiss(Evas_Object* ewkView) 1725 { 1726 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); 1727 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); 1728 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_dismiss); 1729 1730 priv->colorPickerResultListener = 0; 1731 1732 smartData->api->input_picker_color_dismiss(smartData); 1733 } 1734 #endif 1735 1736 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a) 1737 { 1738 #if ENABLE(INPUT_TYPE_COLOR) 1739 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); 1740 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); 1741 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->colorPickerResultListener, false); 1742 1743 WebCore::Color color = WebCore::Color(r, g, b, a); 1744 const WKStringRef colorString = WKStringCreateWithUTF8CString(color.serialized().utf8().data()); 1745 WKColorPickerResultListenerSetColor(priv->colorPickerResultListener, colorString); 1746 priv->colorPickerResultListener = 0; 1747 1748 return true; 1749 #else 1750 return false; 1751 #endif 1752 } -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h
r128967 r129121 122 122 Eina_Bool (*run_javascript_confirm)(Ewk_View_Smart_Data *sd, const char *message); 123 123 const char *(*run_javascript_prompt)(Ewk_View_Smart_Data *sd, const char *message, const char *default_value); /**< return string should be stringshared. */ 124 125 // color picker: 126 // - Shows and hides color picker. 127 Eina_Bool (*input_picker_color_request)(Ewk_View_Smart_Data *sd, int r, int g, int b, int a); 128 Eina_Bool (*input_picker_color_dismiss)(Ewk_View_Smart_Data *sd); 124 129 }; 125 130 … … 128 133 * in the @a Ewk_View_Smart_Class structure. 129 134 */ 130 #define EWK_VIEW_SMART_CLASS_VERSION 4UL135 #define EWK_VIEW_SMART_CLASS_VERSION 5UL 131 136 132 137 /** … … 140 145 * @see EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION 141 146 */ 142 #define EWK_VIEW_SMART_CLASS_INIT(smart_class_init) {smart_class_init, EWK_VIEW_SMART_CLASS_VERSION, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }147 #define EWK_VIEW_SMART_CLASS_INIT(smart_class_init) {smart_class_init, EWK_VIEW_SMART_CLASS_VERSION, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 143 148 144 149 /** … … 662 667 EAPI Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object *o); 663 668 669 /* 670 * Sets the user chosen color. To be used when implementing a color picker. 671 * 672 * The function should only be called when a color has been requested by the document. 673 * If called when this is not the case or when the input picker has been dismissed, this 674 * function will fail and return EINA_FALSE. 675 * 676 * @param o view object contains color picker 677 * @param r red channel value to be set 678 * @param g green channel value to be set 679 * @param b blue channel value to be set 680 * @param a alpha channel value to be set 681 * 682 * @return @c EINA_TRUE on success @c EINA_FALSE otherwise 683 */ 684 EAPI Eina_Bool ewk_view_color_picker_color_set(Evas_Object *o, int r, int g, int b, int a); 685 664 686 #ifdef __cplusplus 665 687 } -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h
r129099 r129121 110 110 WKEinaSharedString ewk_view_run_javascript_prompt(Evas_Object* ewkView, const WKEinaSharedString& message, const WKEinaSharedString& defaultValue); 111 111 112 #if ENABLE(INPUT_TYPE_COLOR) 113 void ewk_view_color_picker_request(Evas_Object* ewkView, int r, int g, int b, int a, WKColorPickerResultListenerRef listener); 114 void ewk_view_color_picker_dismiss(Evas_Object* ewkView); 115 #endif 116 112 117 #endif // ewk_view_private_h -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp
r128967 r129121 61 61 } 62 62 63 #if ENABLE(INPUT_TYPE_COLOR) 64 static void showColorPicker(WKPageRef, WKStringRef initialColor, WKColorPickerResultListenerRef listener, const void* clientInfo) 65 { 66 WebCore::Color color = WebCore::Color(WebKit::toWTFString(initialColor)); 67 ewk_view_color_picker_request(toEwkView(clientInfo), color.red(), color.green(), color.blue(), color.alpha(), listener); 68 } 69 70 static void hideColorPicker(WKPageRef, const void* clientInfo) 71 { 72 ewk_view_color_picker_dismiss(toEwkView(clientInfo)); 73 } 74 #endif 75 63 76 void ewk_view_ui_client_attach(WKPageRef pageRef, Evas_Object* ewkView) 64 77 { … … 72 85 uiClient.runJavaScriptConfirm = runJavaScriptConfirm; 73 86 uiClient.runJavaScriptPrompt = runJavaScriptPrompt; 87 88 #if ENABLE(INPUT_TYPE_COLOR) 89 uiClient.showColorPicker = showColorPicker; 90 uiClient.hideColorPicker = hideColorPicker; 91 #endif 92 74 93 WKPageSetPageUIClient(pageRef, &uiClient); 75 94 } -
trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp
r129111 r129121 625 625 EXPECT_EQ(promptCallbackData.called, false); 626 626 } 627 628 #if ENABLE(INPUT_TYPE_COLOR) 629 static const int initialRed = 0x12; 630 static const int initialGreen = 0x34; 631 static const int initialBlue = 0x56; 632 static const int initialAlpha = 0xff; 633 static const int changedRed = 0x98; 634 static const int changedGreen = 0x76; 635 static const int changedBlue = 0x54; 636 static const int changedAlpha = 0xff; 637 638 static bool isColorPickerShown = false; 639 640 static void onColorPickerDone(void* userData, Evas_Object*, void*) 641 { 642 bool* handled = static_cast<bool*>(userData); 643 644 *handled = true; 645 } 646 647 static unsigned char setColorPickerColor(void* data) 648 { 649 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data); 650 651 // 3. Change color to changed color. 652 EXPECT_TRUE(ewk_view_color_picker_color_set(smartData->self, changedRed, changedGreen, changedBlue, changedAlpha)); 653 654 evas_object_smart_callback_call(smartData->self, "input,type,color,request", 0); 655 656 return 0; 657 } 658 659 static Eina_Bool showColorPicker(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a) 660 { 661 static bool isFirstRun = true; 662 663 isColorPickerShown = true; 664 665 if (isFirstRun) { 666 // 1. Check initial value from html file. 667 EXPECT_EQ(r, initialRed); 668 EXPECT_EQ(g, initialGreen); 669 EXPECT_EQ(b, initialBlue); 670 EXPECT_EQ(a, initialAlpha); 671 672 isFirstRun = false; 673 } else { 674 // 4. Input values should be same as changed color. 675 EXPECT_EQ(r, changedRed); 676 EXPECT_EQ(g, changedGreen); 677 EXPECT_EQ(b, changedBlue); 678 EXPECT_EQ(a, changedAlpha); 679 } 680 681 // 2. Return after making a color picker. 682 ecore_timer_add(0.0, setColorPickerColor, smartData); 683 return true; 684 } 685 686 static Eina_Bool hideColorPicker(Ewk_View_Smart_Data*) 687 { 688 // Test color picker is shown. 689 EXPECT_TRUE(isColorPickerShown); 690 isColorPickerShown = false; 691 } 692 693 TEST_F(EWK2UnitTestBase, ewk_view_color_picker_color_set) 694 { 695 Ewk_View_Smart_Class* api = ewkViewClass(); 696 api->input_picker_color_request = showColorPicker; 697 api->input_picker_color_dismiss = hideColorPicker; 698 699 loadUrlSync("data:text/html,<input type='color' value='#123456'>"); 700 701 // Click input element. 702 mouseClick(30, 20); 703 704 bool handled = false; 705 evas_object_smart_callback_add(webView(), "input,type,color,request", onColorPickerDone, &handled); 706 while (!handled) 707 ecore_main_loop_iterate(); 708 709 // Click input element again. 710 mouseClick(30, 20); 711 712 handled = false; 713 while (!handled) 714 ecore_main_loop_iterate(); 715 evas_object_smart_callback_del(webView(), "input,type,color,request", onColorPickerDone); 716 } 717 #endif // ENABLE(INPUT_TYPE_COLOR)
Note: See TracChangeset
for help on using the changeset viewer.