/webkit-efl/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
C++ | 4031 lines | 3232 code | 725 blank | 74 comment | 318 complexity | eb18014803718e55f908732091bf7cc8 MD5 | raw file
Possible License(s): GPL-3.0, AGPL-3.0, GPL-2.0, MPL-2.0, JSON, WTFPL, CC-BY-SA-4.0, CC-BY-3.0, BSD-3-Clause, LGPL-2.0, MPL-2.0-no-copyleft-exception, AGPL-1.0, 0BSD, Zlib, Unlicense, BSD-2-Clause, Apache-2.0, LGPL-3.0, ISC, MIT, CC-BY-SA-3.0, CC0-1.0, LGPL-2.1
- /*
- 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_view.h"
- #include "NativeWebKeyboardEvent.h"
- #include "NativeWebMouseEvent.h"
- #include "NativeWebWheelEvent.h"
- #include "PageClientImpl.h"
- #include "WKAPICast.h"
- #include "WKRetainPtr.h"
- #include "WKURL.h"
- #include "ewk_context.h"
- #include "ewk_context_private.h"
- #include "ewk_view_private.h"
- #include <wtf/text/CString.h>
- #if OS(TIZEN)
- #include "DrawingAreaProxyImpl.h"
- #include "JavaScriptPopup.h"
- #include "OpenPanel.h"
- #include "WKArray.h"
- #include "WKData.h"
- #include "WKDownload.h"
- #include "WKError.h"
- #include "WKGeolocationPermissionRequest.h"
- #include "WKImageCairo.h"
- #include "WKOpenPanelParameters.h"
- #include "WKOpenPanelResultListener.h"
- #include "WKPage.h"
- #include "WKPageGroup.h"
- #include "WKPageTizen.h"
- #include "WKPreferences.h"
- #include "WKSerializedScriptValue.h"
- #include "WKString.h"
- #include "WKURLRequest.h"
- #include "ewk_auth_challenge_private.h"
- #include "ewk_context_menu_private.h"
- #include "ewk_error.h"
- #include "ewk_error_private.h"
- #include "ewk_history_private.h"
- #include "ewk_setting_private.h"
- #include "ewk_view_context_menu_client.h"
- #include "ewk_view_find_client.h"
- #include "ewk_view_form_client.h"
- #include "ewk_view_loader_client.h"
- #include "ewk_view_policy_client.h"
- #include "ewk_view_tizen_client.h"
- #include "ewk_view_ui_client.h"
- #include <Ecore.h>
- #include <Ecore_Evas.h>
- #include <Elementary.h>
- #include <JavaScriptCore/JSRetainPtr.h>
- #include <WebCore/NotImplemented.h>
- #include <cairo.h>
- #if ENABLE(TIZEN_ICON_DATABASE)
- #include "WKContextPrivate.h"
- #include "WebContext.h"
- #endif
- #if ENABLE(TIZEN_ERROR_PAGE)
- #include "WebErrorPageEfl.h"
- #endif
- #if ENABLE(TIZEN_GEOLOCATION)
- #include "ewk_security_origin.h"
- #include "ewk_view_geolocation_provider.h"
- #endif
- #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- #include "InputPicker.h"
- #endif
- #if ENABLE(TIZEN_GESTURE)
- #include "GestureRecognizer.h"
- #include "GestureClient.h"
- #endif
- #if ENABLE(TOUCH_EVENTS)
- #include "NativeWebTouchEvent.h"
- #include "WebEvent.h"
- #endif
- #if ENABLE(TIZEN_ISF_PORT)
- #include <Ecore_IMF.h>
- #endif
- #if ENABLE(TIZEN_NOTIFICATION)
- #include "WKArray.h"
- #include "WKNotificationManager.h"
- #include "WKNumber.h"
- #include "ewk_view_notification_provider.h"
- #endif
- #if ENABLE(TIZEN_WEBKIT2_POPUP)
- #include "WebPopupItem.h"
- #include "WebPopupMenuProxyEfl.h"
- #endif
- #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
- #include "ewk_popup_picker.h"
- #endif
- #if ENABLE(TIZEN_MEDIA_STREAM)
- #include "WKUserMediaPermissionRequest.h"
- #endif
- #if ENABLE(TIZEN_PREFERENCE)
- #include "WebPageGroup.h"
- #include "WebPreferences.h"
- #endif
- #if ENABLE(TIZEN_WEBKIT_PASTEBOARD)
- #include "ewk_util.h"
- #endif
- #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
- #include "ewk_hit_test_private.h"
- #endif
- #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
- #include <Ecore_Evas.h>
- #include <WebCore/Cursor.h>
- #include <WebCore/EflScreenUtilities.h>
- #endif
- #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
- #include "FocusRing.h"
- #endif
- #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
- #include "WebColorChooserProxyEfl.h"
- #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
- #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
- #include "ewk_text_style.h"
- #endif
- #endif // #if OS(TIZEN)
- using namespace WebKit;
- using namespace WebCore;
- static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
- typedef struct _Ewk_View_Callback_Context Ewk_View_Callback_Context;
- struct _Ewk_View_Private_Data {
- OwnPtr<PageClientImpl> pageClient;
- const char* uri;
- #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
- const char* cursorGroup;
- #ifdef HAVE_ECORE_X
- bool isUsingEcoreX;
- #endif
- #endif
- #if OS(TIZEN)
- bool areMouseEventsEnabled;
- #if ENABLE(TIZEN_ORIENTATION_EVENTS)
- int orientation;
- #endif
- struct {
- int count;
- int position;
- } formNavigation;
- JSGlobalContextRef javascriptGlobalContext;
- const char* title;
- const char* userAgent;
- const char* theme;
- const char* encoding;
- #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
- const char* webAppIconURL;
- #endif
- OwnPtr<Ewk_View_Callback_Context> alertContext;
- OwnPtr<Ewk_View_Callback_Context> confirmContext;
- OwnPtr<Ewk_View_Callback_Context> promptContext;
- OwnPtr<Ewk_View_Callback_Context> openpanelContext;
- OwnPtr<JavaScriptPopup> javascriptPopup;
- OwnPtr<OpenPanel> openPanel;
- #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- OwnPtr<InputPicker> inputPicker;
- const char* inputValue;
- #endif
- Ewk_Auth_Challenge* authChallenge;
- Ewk_Policy_Decision* policyDecision;
- WKOpenPanelResultListenerRef openPanelListener;
- #if ENABLE(TIZEN_MEDIA_STREAM)
- Ewk_User_Media_Permission* userMediaPermission;
- #endif
- struct {
- Ewk_View_String_Find_Callback callback;
- void* userData;
- } findClientInfo;
- Ewk_Setting* setting;
- Ewk_Context* context;
- #if ENABLE(TIZEN_GEOLOCATION)
- Ewk_Geolocation* geolocation;
- Ewk_Geolocation_Permission_Data* geolocationPermission;
- #endif
- #if ENABLE(TIZEN_NOTIFICATION)
- Eina_List* notifications;
- Ewk_Notification_Permission_Request* notificationPermissionRequest;
- #endif
- #if ENABLE(TIZEN_SQL_DATABASE)
- Ewk_Context_Exceeded_Quota* exceededDatabaseQuota;
- #endif
- #if ENABLE(TIZEN_WEBKIT2_POPUP)
- WebPopupMenuProxyEfl* popupMenuProxy;
- Eina_List* popupMenuItems;
- #endif
- #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
- Ewk_Popup_Picker* popupPicker;
- #endif
- bool isVerticalEdge;
- bool isHorizontalEdge;
- #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
- OwnPtr<FocusRing> focusRing;
- #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
- #if ENABLE(TIZEN_GESTURE)
- OwnPtr<GestureRecognizer> gestureRecognizer;
- OwnPtr<GestureClient> gestureClient;
- #if ENABLE(TOUCH_EVENTS)
- Ecore_Animator* touchAnimator;
- Evas_Coord_Point touchDownPoint;
- bool exceedTouchMoveThreshold;
- #endif // #if ENABLE(TOUCH_EVENTS)
- bool holdHorizontalPanning;
- bool holdVerticalPanning;
- #endif // #if ENABLE(TIZEN_GESTURE)
- #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
- const char* selectedText;
- #endif
- #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
- WebColorChooserProxyEfl* colorChooser;
- #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
- #if ENABLE(TIZEN_DATALIST_ELEMENT)
- Eina_List* dataList;
- #endif
- #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
- struct {
- Ewk_Orientation_Lock_Cb callback;
- void* data;
- } orientationLock;
- #endif
- #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
- RefPtr<WebPageGroup> pageGroup;
- #endif
- #endif // #if OS(TIZEN)
- };
- #if OS(TIZEN)
- #if ENABLE(TIZEN_MM_PLAYER)
- struct _Ewk_View_Html5_Video_Data {
- WKStringRef url;
- WKStringRef cookie;
- };
- #endif // #if ENABLE(TIZEN_MM_PLAYER)
- struct _Ewk_View_Callback_Context {
- union {
- Ewk_View_Rss_Items_Get_Callback rssItemsGetCallback;
- Ewk_Web_App_Capable_Get_Callback webAppCapableCallback;
- Ewk_Web_App_Icon_URL_Get_Callback webAppIconURLCallback;
- #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
- Ewk_Web_Storage_Quota_Get_Callback webStorageQuotaCallback;
- #endif
- Ewk_View_Script_Execute_Callback scriptExecuteCallback;
- Ewk_View_Plain_Text_Get_Callback plainTextGetCallback;
- #if OS(TIZEN)
- Ewk_View_JavaScript_Alert_Callback javascriptAlertCallback;
- Ewk_View_JavaScript_Confirm_Callback javascriptConfirmCallback;
- Ewk_View_JavaScript_Prompt_Callback javascriptPromptCallback;
- Ewk_View_Open_Panel_Callback openPanelCallback;
- #endif // #if OS(TIZEN)
- };
- Evas_Object* ewkView;
- void* userData;
- };
- #define READABLE_SCALE_FACTOR 1.0
- #endif // #if OS(TIZEN)
- #define EWK_VIEW_TYPE_CHECK(ewkView, result) \
- bool result = true; \
- do { \
- const char* _tmp_otype = evas_object_type_get(ewkView); \
- const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
- if (EINA_UNLIKELY(!_tmp_s)) { \
- EINA_LOG_CRIT \
- ("%p (%s) is not a smart object!", \
- ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
- result = false; \
- } \
- const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
- if (EINA_UNLIKELY(!_tmp_sc)) { \
- EINA_LOG_CRIT \
- ("%p (%s) is not a smart object!", \
- ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
- result = false; \
- } \
- else if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \
- EINA_LOG_CRIT \
- ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
- ewkView, _tmp_otype ? _tmp_otype : "(null)", \
- EWK_VIEW_TYPE_STR, _tmp_sc->data); \
- result = false; \
- } \
- } while (0)
- #define EWK_VIEW_SD_GET(ewkView, smartData) \
- EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \
- Ewk_View_Smart_Data* smartData = 0; \
- if (_tmp_result) \
- smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView);
- #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \
- EWK_VIEW_SD_GET(ewkView, smartData); \
- if (!smartData) { \
- EINA_LOG_CRIT("no smart data for object %p (%s)", \
- ewkView, evas_object_type_get(ewkView)); \
- return __VA_ARGS__; \
- }
- #define EWK_VIEW_PRIV_GET(smartData, priv) \
- Ewk_View_Private_Data* priv = smartData->priv
- #define EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, ...) \
- if (!smartData) { \
- EINA_LOG_CRIT("smart data is null"); \
- return __VA_ARGS__; \
- } \
- EWK_VIEW_PRIV_GET(smartData, priv); \
- if (!priv) { \
- EINA_LOG_CRIT("no private data for object %p (%s)", \
- smartData->self, evas_object_type_get(smartData->self)); \
- return __VA_ARGS__; \
- }
- #if OS(TIZEN)
- #define DECLARE_EVENT_FUNC(func) \
- static void func(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
- DECLARE_EVENT_FUNC(_ewk_view_on_touch_down);
- DECLARE_EVENT_FUNC(_ewk_view_on_touch_move);
- DECLARE_EVENT_FUNC(_ewk_view_on_touch_up);
- #undef DECLARE_EVENT_FUNC
- static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object*, const char* alertText, void* userData);
- static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object*, const char* message, void* userData);
- static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object*, const char* message, const char* defaultValue, void* userData);
- static Eina_Bool _ewk_view_default_open_panel(Evas_Object*, Eina_Bool allow_multiple_files, Eina_List *accepted_mime_types, const char* capture, void* userData);
- #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
- Eina_Bool _ewk_view_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items, int selectedIndex);
- Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data*);
- #endif
- #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
- Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations);
- void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd);
- #endif
- #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data*, Ewk_Input_Type, const char* inputValue);
- #endif
- #if ENABLE(TIZEN_DATALIST_ELEMENT)
- static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data*, Ewk_Input_Type, Eina_List*);
- static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data*, Ewk_Input_Type);
- #endif
- #endif // #if OS(TIZEN)
- static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
- {
- if (smartData->changed.any)
- return;
- smartData->changed.any = true;
- evas_object_smart_changed(smartData->self);
- }
- // Default Event Handling.
- static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- #if OS(TIZEN)
- priv->pageClient->setViewFocused(true);
- #endif // #if OS(TIZEN)
- priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
- return true;
- }
- static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- #if ENABLE(TIZEN_ISF_PORT)
- // Keypad should be hidden rapidly when moving focus on elementary
- // because Ecore-ime doesn't support it.
- Ecore_IMF_Context* context = priv->pageClient->getIMFContext();
- if (context && priv->pageClient->getInputMethodState()) {
- LOG(ISF, "%s\n - keypad status : hide\n", __func__);
- ecore_imf_context_input_panel_hide(context);
- ecore_imf_context_focus_out(context);
- }
- #endif
- #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
- if (priv->pageClient->isTextSelectionMode())
- priv->pageClient->setIsTextSelectionMode(false);
- #endif
- #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
- if (priv->pageClient->isContextMenuVisible())
- priv->pageClient->page()->hideContextMenu();
- #endif
- #if OS(TIZEN)
- priv->pageClient->setViewFocused(false);
- #endif // #if OS(TIZEN)
- priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
- return true;
- }
- static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- Evas_Point position = {smartData->view.x, smartData->view.y};
- priv->pageClient->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, &position));
- return true;
- }
- #if OS(TIZEN) && ENABLE(TOUCH_EVENTS)
- void ewkViewHandleTouchEvent(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
- {
- Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(ewkView));
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
- Eina_List* points = 0;
- int count = evas_touch_point_list_count(smartData->base.evas);
- Ewk_Touch_Point* point;
- for (int i = 0; i < count; ++i) {
- point = static_cast<Ewk_Touch_Point*>(calloc(1, sizeof(Ewk_Touch_Point)));
- point->id = evas_touch_point_list_nth_id_get(smartData->base.evas, i);
- evas_touch_point_list_nth_xy_get(smartData->base.evas, i, &point->x, &point->y);
- point->state = evas_touch_point_list_nth_state_get(smartData->base.evas, i);
- points = eina_list_append(points, point);
- }
- ewk_view_feed_touch_event(ewkView, type, points, evas_key_modifier_get(smartData->base.evas));
- void* data;
- EINA_LIST_FREE(points, data)
- free(data);
- }
- static Eina_Bool _ewk_view_touch_animator(void *data)
- {
- Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- if (!priv->exceedTouchMoveThreshold && evas_touch_point_list_count(smartData->base.evas)) {
- Evas_Coord x, y;
- evas_touch_point_list_nth_xy_get(smartData->base.evas, 0, &x, &y);
- unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
- int diffX = priv->touchDownPoint.x - x;
- int diffY = priv->touchDownPoint.y - y;
- if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
- priv->exceedTouchMoveThreshold = true;
- }
- if (priv->exceedTouchMoveThreshold)
- ewkViewHandleTouchEvent(smartData->self, EWK_TOUCH_MOVE);
- return ECORE_CALLBACK_RENEW;
- }
- #endif // #if OS(TIZEN) && ENABLE(TOUCH_EVENTS)
- static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- Evas_Point position = {smartData->view.x, smartData->view.y};
- priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, &position));
- return true;
- }
- static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- Evas_Point position = {smartData->view.x, smartData->view.y};
- priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, &position));
- return true;
- }
- static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- Evas_Point position = {smartData->view.x, smartData->view.y};
- priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, &position));
- return true;
- }
- static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- #if ENABLE(TIZEN_ISF_PORT)
- Ecore_IMF_Event IMFEvent;
- ecore_imf_evas_event_key_down_wrap(const_cast<Evas_Event_Key_Down*>(downEvent), &IMFEvent.key_down);
- bool filtered = ecore_imf_context_filter_event(priv->pageClient->getIMFContext(), ECORE_IMF_EVENT_KEY_DOWN, &IMFEvent);
- priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, filtered));
- #else
- priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent));
- #endif // #if ENABLE(TIZEN_ISF_PORT)
- return true;
- }
- static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
- return true;
- }
- #if OS(TIZEN)
- #if ENABLE(TOUCH_EVENTS)
- static Eina_Bool _ewk_view_smart_multi_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Multi_Down* downEvent)
- {
- EINA_SAFETY_ON_NULL_RETURN_VAL(smartData, false);
- _ewk_view_on_touch_down(0, smartData->base.evas, smartData->self, 0);
- return true;
- }
- static Eina_Bool _ewk_view_smart_multi_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Multi_Up* upEvent)
- {
- EINA_SAFETY_ON_NULL_RETURN_VAL(smartData, false);
- _ewk_view_on_touch_up(0, smartData->base.evas, smartData->self, 0);
- return true;
- }
- static Eina_Bool _ewk_view_smart_multi_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Multi_Move* moveEvent)
- {
- EINA_SAFETY_ON_NULL_RETURN_VAL(smartData, false);
- _ewk_view_on_touch_move(0, smartData->base.evas, smartData->self, 0);
- return true;
- }
- #endif // #if ENABLE(TOUCH_EVENTS)
- static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- switch (event->type) {
- case EWK_GESTURE_TAP:
- priv->gestureClient->startTap(IntPoint(event->position.x, event->position.y));
- break;
- case EWK_GESTURE_LONG_PRESS:
- priv->gestureClient->startLongPress(IntPoint(event->position.x, event->position.y));
- break;
- case EWK_GESTURE_PAN:
- priv->gestureClient->startPan(IntPoint(event->position.x, event->position.y));
- break;
- case EWK_GESTURE_FLICK:
- priv->gestureClient->startFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
- break;
- case EWK_GESTURE_PINCH: {
- PageClientImpl* pageClient = ewkViewGetPageClient(smartData->self);
- if (pageClient->viewportConstraints().userScalable)
- priv->gestureClient->startPinch(IntPoint(event->position.x, event->position.y), event->scale);
- break;
- }
- default:
- ASSERT_NOT_REACHED();
- break;
- }
- return true;
- }
- static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- switch (event->type) {
- case EWK_GESTURE_TAP:
- if (event->count == 1)
- priv->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
- else if (event->count == 2)
- priv->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
- break;
- case EWK_GESTURE_LONG_PRESS:
- priv->gestureClient->endLongPress(IntPoint(event->position.x, event->position.y));
- break;
- case EWK_GESTURE_PAN:
- priv->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
- break;
- case EWK_GESTURE_FLICK:
- priv->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
- break;
- case EWK_GESTURE_PINCH:
- priv->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
- break;
- default:
- ASSERT_NOT_REACHED();
- break;
- }
- return true;
- }
- static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- switch (event->type) {
- case EWK_GESTURE_PAN:
- priv->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
- break;
- case EWK_GESTURE_TAP:
- case EWK_GESTURE_LONG_PRESS:
- case EWK_GESTURE_FLICK:
- break;
- case EWK_GESTURE_PINCH: {
- PageClientImpl* pageClient = ewkViewGetPageClient(smartData->self);
- if (pageClient->viewportConstraints().userScalable)
- priv->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
- break;
- }
- default:
- ASSERT_NOT_REACHED();
- break;
- }
- return true;
- }
- static void _ewk_view_clients_attach(Ewk_View_Smart_Data* smartData)
- {
- EINA_SAFETY_ON_NULL_RETURN(smartData);
- ewkViewContextMenuClientAttachClient(smartData->self);
- ewkViewFindClientAttatchClient(smartData->self);
- ewkViewFormClientAttachClient(smartData->self);
- ewkViewLoaderClientAttachClient(smartData->self);
- ewkViewPolicyClientAttatchClient(smartData->self);
- ewkViewTizenClientAttachClient(smartData->self);
- ewkViewUIClientAttatchClient(smartData->self);
- }
- static void _ewk_view_providers_attach(Ewk_View_Smart_Data* smartData, WKContextRef contextRef)
- {
- EINA_SAFETY_ON_NULL_RETURN(smartData);
- EINA_SAFETY_ON_NULL_RETURN(contextRef);
- #if ENABLE(TIZEN_GEOLOCATION)
- ewkViewGeolocationProviderAttachProvider(smartData->self, contextRef);
- #endif
- #if ENABLE(TIZEN_NOTIFICATION)
- ewkViewNotificationProviderAttachProvider(smartData->self, contextRef);
- #endif
- }
- static void _ewk_view_default_callbacks_set(Ewk_View_Smart_Data* smartData)
- {
- EINA_SAFETY_ON_NULL_RETURN(smartData);
- ewk_view_javascript_alert_callback_set(smartData->self, _ewk_view_default_javascript_alert, 0);
- ewk_view_javascript_confirm_callback_set(smartData->self, _ewk_view_default_javascript_confirm, 0);
- ewk_view_javascript_prompt_callback_set(smartData->self, _ewk_view_default_javascript_prompt, 0);
- ewk_view_open_panel_callback_set(smartData->self, _ewk_view_default_open_panel, 0);
- }
- static void _ewk_view_page_initialize(Ewk_View_Smart_Data* smartData, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
- {
- EINA_SAFETY_ON_NULL_RETURN(smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- priv->pageClient = PageClientImpl::create(toImpl(contextRef), toImpl(pageGroupRef), smartData->self);
- priv->setting = ewkSettingCreate(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageClient->page()))));
- #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
- ewk_view_theme_set(smartData->self, DEFAULT_THEME_PATH"/default.edj");
- #endif
- _ewk_view_clients_attach(smartData);
- _ewk_view_providers_attach(smartData, contextRef);
- _ewk_view_default_callbacks_set(smartData);
- }
- static Eina_Bool _ewk_view_initialize(Ewk_View_Smart_Data* smartData, Ewk_Context* context)
- {
- EINA_SAFETY_ON_NULL_RETURN_VAL(smartData, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- priv->context = context;
- #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
- _ewk_view_page_initialize(smartData, ewk_context_WKContext_get(context), toAPI(priv->pageGroup.get()));
- #else
- _ewk_view_page_initialize(smartData, ewk_context_WKContext_get(context), 0);
- #endif
- return true;
- }
- #endif //#if OS(TIZEN)
- // Event Handling.
- static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
- {
- Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
- smartData->api->focus_in(smartData);
- }
- static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
- {
- Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
- smartData->api->focus_out(smartData);
- }
- static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
- {
- Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
- Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
- smartData->api->mouse_wheel(smartData, wheelEvent);
- }
- static void _ewk_view_on_mouse_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
- {
- Evas_Event_Mouse_Down* downEvent = static_cast<Evas_Event_Mouse_Down*>(eventInfo);
- Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_down);
- smartData->api->mouse_down(smartData, downEvent);
- }
- static void _ewk_view_on_mouse_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
- {
- Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
- Evas_Event_Mouse_Up* upEvent = static_cast<Evas_Event_Mouse_Up*>(eventInfo);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_up);
- smartData->api->mouse_up(smartData, upEvent);
- }
- static void _ewk_view_on_mouse_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
- {
- Evas_Event_Mouse_Move* moveEvent = static_cast<Evas_Event_Mouse_Move*>(eventInfo);
- Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_move);
- smartData->api->mouse_move(smartData, moveEvent);
- }
- static void _ewk_view_on_key_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
- {
- Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
- Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
- smartData->api->key_down(smartData, downEvent);
- }
- static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
- {
- Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
- Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
- smartData->api->key_up(smartData, upEvent);
- }
- #if OS(TIZEN)
- static void _ewk_view_mouse_events_connect(Ewk_View_Smart_Data* smartData)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
- EINA_SAFETY_ON_FALSE_RETURN(priv->areMouseEventsEnabled);
- #define CONNECT(s, c) evas_object_event_callback_add(smartData->self, s, c, smartData)
- CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
- CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
- CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
- #undef CONNECT
- }
- static void _ewk_view_mouse_events_disconnect(Ewk_View_Smart_Data* smartData)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
- EINA_SAFETY_ON_TRUE_RETURN(priv->areMouseEventsEnabled);
- #define DISCONNECT(s, c) evas_object_event_callback_del(smartData->self, s, c)
- DISCONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
- DISCONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
- DISCONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
- #undef DISCONNECT
- }
- #if ENABLE(TOUCH_EVENTS)
- static void _ewk_view_on_touch_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- // Start touchAnimator if current number of touch is one.
- if (evas_touch_point_list_count(smartData->base.evas) == 1) {
- priv->gestureRecognizer->initializeGesture();
- if (priv->touchAnimator)
- ecore_animator_del(priv->touchAnimator);
- priv->touchAnimator = ecore_animator_add(_ewk_view_touch_animator, smartData);
- #if OS(TIZEN)
- evas_touch_point_list_nth_xy_get(canvas, 0, &priv->touchDownPoint.x, &priv->touchDownPoint.y);
- priv->exceedTouchMoveThreshold = false;
- #endif // #if OS(TIZEN)
- }
- ewkViewHandleTouchEvent(ewkView, EWK_TOUCH_START);
- }
- static void _ewk_view_on_touch_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- // Stop touchAnimator if current number of touch is one.
- if (evas_touch_point_list_count(smartData->base.evas) == 1 && priv->touchAnimator) {
- ecore_animator_del(priv->touchAnimator);
- priv->touchAnimator = 0;
- }
- ewkViewHandleTouchEvent(ewkView, EWK_TOUCH_END);
- }
- static void _ewk_view_on_touch_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
- {
- notImplemented();
- }
- #endif
- #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
- Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- IntPoint point(x, y);
- priv->pageClient->textSelectionDown(point, true);
- return true;
- }
- Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- IntPoint point(x, y);
- priv->pageClient->textSelectionMove(point, true);
- return true;
- }
- Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- IntPoint point(x, y);
- priv->pageClient->textSelectionUp(point);
- return true;
- }
- #endif
- #if ENABLE(TIZEN_DATALIST_ELEMENT)
- static void _ewk_view_data_list_del(Eina_List* dataList)
- {
- EINA_SAFETY_ON_NULL_RETURN(dataList);
- void* item;
- EINA_LIST_FREE(dataList, item)
- eina_stringshare_del(static_cast<char*>(item));
- }
- #endif
- #endif // #if OS(TIZEN)
- static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
- #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
- static uint64_t generatePageGroupIdentifierID()
- {
- static uint64_t uniquePageGroupIdentifierID = 1;
- return uniquePageGroupIdentifierID++;
- }
- #endif
- static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
- {
- Ewk_View_Private_Data* priv =
- static_cast<Ewk_View_Private_Data*>(calloc(1, sizeof(Ewk_View_Private_Data)));
- if (!priv) {
- EINA_LOG_CRIT("could not allocate Ewk_View_Private_Data");
- return 0;
- }
- #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
- #ifdef HAV_ECORE_X
- priv->isUsingEcoreX = WebCore::isUsingEcoreX(smartData->base.evas);
- #endif
- #endif
- #if OS(TIZEN)
- priv->areMouseEventsEnabled = false;
- priv->javascriptPopup = adoptPtr<JavaScriptPopup>(new JavaScriptPopup(smartData->self));
- priv->openPanel = adoptPtr<OpenPanel>(new OpenPanel(smartData->self));
- #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- priv->inputPicker = adoptPtr<InputPicker>(new InputPicker(smartData->self));
- #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
- priv->focusRing = FocusRing::create(smartData->self);
- #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
- #if ENABLE(TIZEN_GESTURE)
- priv->gestureRecognizer = GestureRecognizer::create(smartData->self);
- priv->gestureClient = GestureClient::create(smartData->self);
- #endif // #if ENABLE(TIZEN_GESTURE)
- #if ENABLE(TIZEN_DATALIST_ELEMENT)
- priv->dataList = 0;
- #endif
- #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
- String pageGroupIdentifierID = String::number(generatePageGroupIdentifierID());
- String pageGroupIdentifier = String::format("PageGroup%s", pageGroupIdentifierID.utf8().data());
- WKRetainPtr<WKStringRef> pageGroupIdentifierRef(AdoptWK, WKStringCreateWithUTF8CString(pageGroupIdentifier.utf8().data()));
- priv->pageGroup = WebPageGroup::create(toWTFString(pageGroupIdentifierRef.get()));
- #endif
- #endif // #if OS(TIZEN)
- return priv;
- }
- static void _ewk_view_priv_del(Ewk_View_Private_Data* priv)
- {
- if (!priv)
- return;
- priv->pageClient = nullptr;
- #if OS(TIZEN)
- if (priv->javascriptGlobalContext)
- JSGlobalContextRelease(priv->javascriptGlobalContext);
- eina_stringshare_del(priv->uri);
- eina_stringshare_del(priv->title);
- eina_stringshare_del(priv->userAgent);
- eina_stringshare_del(priv->encoding);
- #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
- eina_stringshare_del(priv->webAppIconURL);
- #endif
- if (priv->authChallenge)
- ewkAuthChallengeDelete(priv->authChallenge);
- if (priv->policyDecision)
- ewkPolicyDecisionDelete(priv->policyDecision);
- #if ENABLE(TIZEN_MEDIA_STREAM)
- if (priv->userMediaPermission)
- ewkUserMediaPermissionDelete(priv->userMediaPermission);
- #endif
- ewkSettingDelete(priv->setting);
- priv->openPanelListener = 0;
- priv->openPanel = nullptr;
- priv->javascriptPopup = nullptr;
- priv->alertContext = nullptr;
- priv->confirmContext = nullptr;
- priv->promptContext = nullptr;
- priv->openpanelContext = nullptr;
- #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- priv->inputPicker = nullptr;
- eina_stringshare_del(priv->inputValue);
- #endif
- #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
- priv->pageGroup = nullptr;
- #endif
- #endif
- #if ENABLE(TIZEN_DATALIST_ELEMENT)
- if (priv->dataList) {
- _ewk_view_data_list_del(priv->dataList);
- priv->dataList = 0;
- }
- #endif
- #if ENABLE(TIZEN_GEOLOCATION)
- if (priv->geolocation)
- ewkGeolocationDeleteGeolocation(priv->geolocation);
- if (priv->geolocationPermission)
- ewkGeolocationDeletePermission(priv->geolocationPermission);
- #endif
- #if ENABLE(TIZEN_NOTIFICATION)
- if (priv->notifications)
- ewkNotificationDeleteNotificationList(priv->notifications);
- if (priv->notificationPermissionRequest)
- ewkNotificationDeletePermissionRequest(priv->notificationPermissionRequest);
- #endif
- #if ENABLE(TIZEN_SQL_DATABASE)
- if (priv->exceededDatabaseQuota)
- ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
- #endif
- #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
- priv->focusRing = nullptr;
- #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
- #if ENABLE(TIZEN_GESTURE)
- priv->gestureRecognizer = nullptr;
- priv->gestureClient = nullptr;
- #if ENABLE(TOUCH_EVENTS)
- if (priv->touchAnimator)
- ecore_animator_del(priv->touchAnimator);
- #endif // #if ENABLE(TOUCH_EVENTS)
- #endif // #if ENABLE(TIZEN_GESTURE)
- #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
- eina_stringshare_del(priv->selectedText);
- #endif
- free(priv);
- }
- static void _ewk_view_smart_add(Evas_Object* ewkView)
- {
- const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
- const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
- const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
- EWK_VIEW_SD_GET(ewkView, smartData);
- if (!smartData) {
- smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
- if (!smartData) {
- EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
- return;
- }
- evas_object_smart_data_set(ewkView, smartData);
- }
- smartData->self = ewkView;
- #if !ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
- smartData->priv = _ewk_view_priv_new(smartData);
- #endif
- smartData->api = api;
- #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
- g_parentSmartClass.add(ewkView);
- smartData->priv = _ewk_view_priv_new(smartData);
- #endif
- if (!smartData->priv) {
- EINA_LOG_CRIT("could not allocate _Ewk_View_Private_Data");
- evas_object_smart_data_set(ewkView, 0);
- free(smartData);
- return;
- }
- #if !ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
- g_parentSmartClass.add(ewkView);
- #endif
- #if OS(TIZEN)
- // create bg_rect
- smartData->bg_rect = evas_object_rectangle_add(smartData->base.evas);
- evas_object_color_set(smartData->bg_rect, 255, 255, 255, 255);
- evas_object_show(smartData->bg_rect);
- evas_object_smart_member_add(smartData->bg_rect, ewkView);
- #endif // #if OS(TIZEN)
- // Create evas_object_image to draw web contents.
- smartData->image = evas_object_image_add(smartData->base.evas);
- #if OS(TIZEN)
- #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
- Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
- const char *engine = ecore_evas_engine_name_get(ee);
- if (engine && !strcmp(engine, "opengl_x11"))
- evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
- #endif
- #endif // #if OS(TIZEN)
- evas_object_image_alpha_set(smartData->image, false);
- evas_object_image_filled_set(smartData->image, true);
- evas_object_smart_member_add(smartData->image, ewkView);
- evas_object_show(smartData->image);
- #if OS(TIZEN)
- evas_object_pass_events_set(smartData->image, true);
- // create events_rect
- smartData->events_rect = evas_object_rectangle_add(smartData->base.evas);
- evas_object_color_set(smartData->events_rect, 0, 0, 0, 0);
- evas_object_smart_member_add(smartData->events_rect, ewkView);
- evas_object_show(smartData->events_rect);
- if (smartData->priv->areMouseEventsEnabled)
- _ewk_view_mouse_events_connect(smartData);
- #endif // #if OS(TIZEN)
- #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
- CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
- CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
- CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
- #if !OS(TIZEN)
- CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
- CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
- CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
- #endif
- CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
- CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
- #if OS(TIZEN) && ENABLE(TOUCH_EVENTS)
- // FIXME: We have to connect touch callbacks with Mouse and Multi event
- // because the Evas sends the Touch event using them.
- // It should be fixed when the Evas supports the Touch event.
- CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down);
- CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up);
- CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move);
- CONNECT(EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down);
- CONNECT(EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up);
- CONNECT(EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move);
- #endif // #if OS(TIZEN) && ENABLE(TOUCH_EVENTS)
- #undef CONNECT
- }
- static void _ewk_view_smart_del(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET(ewkView, smartData);
- if (smartData && smartData->priv)
- _ewk_view_priv_del(smartData->priv);
- g_parentSmartClass.del(ewkView);
- }
- static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- evas_object_resize(smartData->image, width, height);
- evas_object_image_size_set(smartData->image, width, height);
- evas_object_image_fill_set(smartData->image, 0, 0, width, height);
- #if OS(TIZEN)
- evas_object_resize(smartData->events_rect, width, height);
- EWK_VIEW_PRIV_GET(smartData, priv);
- #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
- evas_object_image_native_surface_set(smartData->image, 0);
- if (priv)
- priv->pageClient->displayViewport();
- #endif
- #if ENABLE(TIZEN_PREFERENCE)
- if (priv && priv->pageClient->page()) {
- priv->pageClient->page()->pageGroup()->preferences()->setViewWidth(width);
- priv->pageClient->page()->pageGroup()->preferences()->setViewHeight(height);
- }
- #endif
- #endif // #if OS(TIZEN)
- smartData->changed.size = true;
- _ewk_view_smart_changed(smartData);
- }
- static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- smartData->changed.position = true;
- _ewk_view_smart_changed(smartData);
- }
- static void _ewk_view_smart_calculate(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- Evas_Coord x, y, width, height;
- smartData->changed.any = false;
- evas_object_geometry_get(ewkView, &x, &y, &width, &height);
- if (smartData->changed.size) {
- smartData->view.w = width;
- smartData->view.h = height;
- smartData->changed.size = false;
- #if OS(TIZEN)
- if (priv->pageClient) {
- if (DrawingAreaProxy* drawingArea = priv->pageClient->page()->drawingArea()) {
- #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
- if (priv->pageClient->page()->isViewVisible())
- drawingArea->setSize(IntSize(width, height), IntSize());
- #else
- drawingArea->setSize(IntSize(width, height), IntSize());
- #endif
- #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
- priv->pageClient->updateViewportSize(IntSize(width, height));
- priv->pageClient->displayViewport();
- #endif
- }
- #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
- priv->pageClient->frameRectChanged();
- #endif
- }
- evas_object_resize(smartData->bg_rect, width, height);
- #endif // #if OS(TIZEN)
- }
- if (smartData->changed.position) {
- evas_object_move(smartData->image, x, y);
- #if OS(TIZEN)
- evas_object_move(smartData->events_rect, x, y);
- evas_object_move(smartData->bg_rect, x, y);
- #endif // #if OS(TIZEN)
- smartData->view.x = x;
- smartData->view.y = y;
- smartData->changed.position = false;
- #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
- priv->pageClient->frameRectChanged();
- #endif
- }
- if (priv->popupPicker)
- ewk_popup_picker_resize(priv->popupPicker);
- }
- static void _ewk_view_smart_show(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (evas_object_clipees_get(smartData->base.clipper))
- evas_object_show(smartData->base.clipper);
- evas_object_show(smartData->image);
- }
- static void _ewk_view_smart_hide(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- evas_object_hide(smartData->base.clipper);
- evas_object_hide(smartData->image);
- }
- static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (alpha < 0)
- alpha = 0;
- else if (alpha > 255)
- alpha = 255;
- #define CHECK_COLOR(color, alpha) \
- if (color < 0) \
- color = 0; \
- else if (color > alpha) \
- color = alpha;
- CHECK_COLOR(red, alpha);
- CHECK_COLOR(green, alpha);
- CHECK_COLOR(blue, alpha);
- #undef CHECK_COLOR
- #if OS(TIZEN)
- evas_object_color_set(smartData->bg_rect, red, green, blue, alpha);
- #endif
- evas_object_image_alpha_set(smartData->image, alpha < 255);
- priv->pageClient->page()->setDrawsBackground(red || green || blue);
- priv->pageClient->page()->setDrawsTransparentBackground(alpha < 255);
- g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
- }
- #if OS(TIZEN)
- Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
- #else
- Eina_Bool ewk_view_smart_class_init(Ewk_View_Smart_Class* api)
- #endif
- {
- EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
- if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
- EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
- api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
- return false;
- }
- if (EINA_UNLIKELY(!g_parentSmartClass.add))
- evas_object_smart_clipped_smart_set(&g_parentSmartClass);
- evas_object_smart_clipped_smart_set(&api->sc);
- // Set Evas_Smart_Class functions.
- api->sc.add = _ewk_view_smart_add;
- api->sc.del = _ewk_view_smart_del;
- api->sc.move = _ewk_view_smart_move;
- api->sc.resize = _ewk_view_smart_resize;
- api->sc.show = _ewk_view_smart_show;
- api->sc.hide = _ewk_view_smart_hide;
- api->sc.color_set = _ewk_view_smart_color_set;
- api->sc.calculate = _ewk_view_smart_calculate;
- api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
- // Set Ewk_View_Smart_Class functions.
- api->focus_in = _ewk_view_smart_focus_in;
- api->focus_out = _ewk_view_smart_focus_out;
- api->mouse_wheel = _ewk_view_smart_mouse_wheel;
- api->mouse_down = _ewk_view_smart_mouse_down;
- api->mouse_up = _ewk_view_smart_mouse_up;
- api->mouse_move = _ewk_view_smart_mouse_move;
- api->key_down = _ewk_view_smart_key_down;
- api->key_up = _ewk_view_smart_key_up;
- #if OS(TIZEN)
- api->initialize = _ewk_view_initialize;
- #if ENABLE(TOUCH_EVENTS)
- api->multi_down = _ewk_view_smart_multi_down;
- api->multi_up = _ewk_view_smart_multi_up;
- api->multi_move = _ewk_view_smart_multi_move;
- #endif // #if ENABLE(TOUCH_EVENTS)
- api->gesture_start = _ewk_view_smart_gesture_start;
- api->gesture_end = _ewk_view_smart_gesture_end;
- api->gesture_move = _ewk_view_smart_gesture_move;
- #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
- api->popup_menu_show = _ewk_view_popup_menu_show;
- api->popup_menu_hide = _ewk_view_popup_menu_hide;
- #endif
- #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
- api->text_selection_down = _ewk_view_text_selection_down;
- api->text_selection_move = _ewk_view_text_selection_move;
- api->text_selection_up = _ewk_view_text_selection_up;
- #endif
- #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- api->input_picker_show = _ewk_view_input_picker_show;
- #endif
- #if ENABLE(TIZEN_DATALIST_ELEMENT)
- api->data_list_show = _ewk_view_data_list_show;
- api->data_list_hide = _ewk_view_data_list_hide;
- #endif
- #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
- api->orientation_lock = _ewk_orientation_lock;
- api->orientation_unlock = _ewk_orientation_unlock;
- #endif
- #endif //#if OS(TIZEN)
- return true;
- }
- static inline Evas_Smart* _ewk_view_smart_class_new(void)
- {
- static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION(ewkViewLegacyName);
- static Evas_Smart* smart = 0;
- if (EINA_UNLIKELY(!smart)) {
- #if OS(TIZEN)
- ewk_view_smart_class_set(&api);
- #else
- ewk_view_smart_class_init(&api);
- #endif
- smart = evas_smart_class_new(&api.sc);
- }
- return smart;
- }
- #if OS(TIZEN)
- static Evas_Object* _ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
- #else
- Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
- #endif
- {
- Evas_Object* ewkView = evas_object_smart_add(canvas, _ewk_view_smart_class_new());
- if (!ewkView)
- return 0;
- EWK_VIEW_SD_GET(ewkView, smartData);
- if (!smartData) {
- evas_object_del(ewkView);
- return 0;
- }
- EWK_VIEW_PRIV_GET(smartData, priv);
- if (!priv) {
- evas_object_del(ewkView);
- return 0;
- }
- #if !OS(TIZEN)
- priv->pageClient = PageClientImpl::create(toImpl(contextRef), toImpl(pageGroupRef), ewkView);
- #endif
- return ewkView;
- }
- #if OS(TIZEN)
- /**
- * @internal
- * Constructs a ewk_view Evas_Object with WKType parameters.
- */
- Evas_Object* ewk_view_add_with_WKType(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
- {
- Evas_Object* ewkView = _ewk_view_base_add(canvas, contextRef, pageGroupRef);
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ewkView);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, ewkView);
- priv->context = ewk_context_new_with_WKContext(contextRef);
- _ewk_view_page_initialize(smartData, contextRef, pageGroupRef);
- return ewkView;
- }
- #endif // #if OS(TIZEN)
- Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
- {
- #if OS(TIZEN)
- EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
- EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
- #if ENABLE(TIZEN_ICON_DATABASE)
- //set default iconDatabasePath
- String platformDefaultPath = toImpl(ewk_context_WKContext_get(context))->iconDatabasePath();
- WKContextSetIconDatabasePath(ewk_context_WKContext_get(context), WKStringCreateWithUTF8CString(platformDefaultPath.utf8().data()));
- #endif
- Evas_Object* ewkView = _ewk_view_base_add(canvas, ewk_context_WKContext_get(context), 0);
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ewkView);
- EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, ewkView);
- EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->initialize, ewkView);
- smartData->api->initialize(smartData, context);
- return ewkView;
- #else
- return ewk_view_base_add(canvas, ewk_context_WKContext_get(context), 0);
- #endif
- }
- Evas_Object* ewk_view_add(Evas* canvas)
- {
- return ewk_view_add_with_context(canvas, ewk_context_default_get());
- }
- Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- return priv->context;
- }
- Eina_Bool ewk_view_uri_set(Evas_Object* ewkView, const char* uri)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- WKRetainPtr<WKURLRef> url(AdoptWK, WKURLCreateWithUTF8CString(uri));
- WKPageLoadURL(toAPI(priv->pageClient->page()), url.get());
- eina_stringshare_replace(&priv->uri, uri);
- return true;
- }
- const char* ewk_view_uri_get(const Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- return priv->uri;
- }
- Eina_Bool ewk_view_reload(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- WKPageReload(toAPI(priv->pageClient->page()));
- return true;
- }
- Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- WKPageReloadFromOrigin(toAPI(priv->pageClient->page()));
- return true;
- }
- Eina_Bool ewk_view_stop(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- WKPageStopLoading(toAPI(priv->pageClient->page()));
- return true;
- }
- Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- priv->pageClient->page()->setCustomDeviceScaleFactor(ratio);
- return true;
- }
- float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1);
- return priv->pageClient->page()->deviceScaleFactor();
- }
- void ewk_view_display(Evas_Object* ewkView, const IntRect& rect)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- if (!smartData->image)
- return;
- evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height());
- }
- Eina_Bool ewk_view_back(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- WKPageRef pageRef = toAPI(priv->pageClient->page());
- if (WKPageCanGoBack(pageRef)) {
- WKPageGoBack(pageRef);
- return true;
- }
- return false;
- }
- Eina_Bool ewk_view_forward(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- WKPageRef pageRef = toAPI(priv->pageClient->page());
- if (WKPageCanGoForward(pageRef)) {
- WKPageGoForward(pageRef);
- return true;
- }
- return false;
- }
- Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- return WKPageCanGoBack(toAPI(priv->pageClient->page()));
- }
- Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- return WKPageCanGoForward(toAPI(priv->pageClient->page()));
- }
- void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- if (!imageData || !smartData->image)
- return;
- evas_object_resize(smartData->image, size.width(), size.height());
- evas_object_image_size_set(smartData->image, size.width(), size.height());
- evas_object_image_data_copy_set(smartData->image, imageData);
- }
- WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- return priv->pageClient->page();
- }
- #if OS(TIZEN)
- // FIXME: It should be removed.
- WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- return toAPI(priv->pageClient->page());
- }
- Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- enabled = !!enabled;
- if (priv->areMouseEventsEnabled == enabled)
- return true;
- priv->areMouseEventsEnabled = enabled;
- if (enabled)
- _ewk_view_mouse_events_connect(smartData);
- else
- _ewk_view_mouse_events_disconnect(smartData);
- return true;
- }
- Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- return priv->areMouseEventsEnabled;
- }
- Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, Eina_List* points, const Evas_Modifier* modifiers)
- {
- #if ENABLE(TOUCH_EVENTS)
- EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- #if ENABLE(TIZEN_GESTURE)
- #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
- // We don't want to process touch event when context menu is shown.
- if (priv->pageClient->isContextMenuVisible()) {
- priv->gestureRecognizer->setEnableGesture(true);
- priv->gestureRecognizer->setEnableMoving(true);
- return true;
- }
- #endif
- #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
- if (priv->pageClient->isTextSelectionMode()) {
- priv->gestureRecognizer->setEnableGesture(true);
- priv->gestureRecognizer->setEnableMoving(true);
- priv->gestureRecognizer->setEnableTap(true);
- return true;
- }
- #endif
- #endif // #if ENABLE(TIZEN_GESTURE)
- #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
- const Eina_List* list;
- void* item;
- EINA_LIST_FOREACH(points, list, item) {
- Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(item);
- float revertScale = 1 / priv->pageClient->scaleFactor();
- IntPoint scrollPosition = priv->pageClient->scrollPosition();
- point->x = (scrollPosition.x() + (point->x - smartData->view.x)) * revertScale + smartData->view.x;
- point->y = (scrollPosition.y() + (point->y - smartData->view.y)) * revertScale + smartData->view.y;
- }
- #endif
- Evas_Point position = {smartData->view.x, smartData->view.y};
- priv->pageClient->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, position, smartData->base.evas, ecore_time_get()));
- return true;
- #else
- return false;
- #endif
- }
- static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- return priv->javascriptPopup->alert(alertText);
- }
- static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- return priv->javascriptPopup->confirm(message);
- }
- static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- return priv->javascriptPopup->prompt(message, defaultValue);
- }
- static Eina_Bool _ewk_view_default_open_panel(Evas_Object* ewkView, Eina_Bool allow_multiple_files, Eina_List *accepted_mime_types, const char* capture, void* userData)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- return priv->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, priv);
- }
- #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
- Eina_Bool _ewk_view_popup_menu_show(Ewk_View_Smart_Data* smartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* items, int selectedIndex)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- if (priv->popupPicker)
- ewk_popup_picker_del(priv->popupPicker);
- priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
- return true;
- }
- Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- if (!priv->popupPicker)
- return false;
- ewk_popup_picker_del(priv->popupPicker);
- priv->popupPicker = 0;
- return true;
- }
- #endif
- #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- priv->inputPicker->show(inputType, inputValue);
- return true;
- }
- #endif
- #if ENABLE(TIZEN_DATALIST_ELEMENT)
- static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- priv->inputPicker->showDataList(inputType, optionList);
- return true;
- }
- static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- priv->inputPicker->hideDataList(inputType);
- return true;
- }
- #endif
- PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- return priv->pageClient.get();
- }
- double ewk_view_text_zoom_get(const Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1);
- return WKPageGetTextZoomFactor(toAPI(priv->pageClient->page()));
- }
- Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- WKPageSetTextZoomFactor(toAPI(priv->pageClient->page()), textZoomFactor);
- return true;
- }
- #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
- void ewkViewShowFocusRing(Evas_Object* ewkView, const IntPoint& position)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (!priv->focusRing)
- return;
- priv->focusRing->requestToShow(position);
- }
- void ewkViewHideFocusRing(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (!priv->focusRing)
- return;
- priv->focusRing->hide();
- }
- #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
- Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(priv->pageClient->page())));
- }
- Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(priv->pageClient->page())));
- }
- Ewk_Setting* ewk_view_setting_get(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- return priv->setting;
- }
- #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
- void ewk_view_cursor_set(Evas_Object* ewkView, const Cursor& cursor)
- {
- #ifdef HAVE_ECORE_X
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (!priv->isUsingEcoreX)
- return;
- const char* group = cursor.platformCursor();
- if (!group || group == priv->cursorGroup)
- return;
- priv->cursorGroup = group;
- Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
- WebCore::applyFallbackCursor(ecoreEvas, group);
- #endif
- }
- #endif
- JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- if (!priv->javascriptGlobalContext)
- priv->javascriptGlobalContext = JSGlobalContextCreate(0);
- return priv->javascriptGlobalContext;
- }
- static void setURI(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKPageCopyActiveURL(toAPI(priv->pageClient->page())));
- if (!wkURL)
- return;
- CString activeURI = toImpl(wkURL.get())->string().utf8();
- if (priv->uri && (activeURI == CString(priv->uri)))
- return;
- eina_stringshare_replace(&priv->uri, activeURI.data());
- evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
- }
- void ewkViewLoadStarted(Evas_Object* ewkView)
- {
- setURI(ewkView);
- evas_object_smart_callback_call(ewkView, "load,started", 0);
- }
- void ewkViewLoadCommitted(Evas_Object* ewkView)
- {
- setURI(ewkView);
- evas_object_smart_callback_call(ewkView, "load,committed", 0);
- }
- void ewkViewLoadFinished(Evas_Object* ewkView)
- {
- setURI(ewkView);
- evas_object_smart_callback_call(ewkView, "load,finished", 0);
- }
- void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- Ewk_Error* ewkError = ewkErrorCreate(error);
- ewkErrorLoadErrorPage(ewkError, toAPI(priv->pageClient->page()));
- evas_object_smart_callback_call(ewkView, "load,error", ewkError);
- ewkErrorDelete(ewkError);
- }
- void ewkViewSetTitleAndURL(Evas_Object* ewkView, const char* title, const char* url)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (title && eina_stringshare_replace(&priv->title, title))
- evas_object_smart_callback_call(ewkView, "title,changed", static_cast<void*>(const_cast<char*>(priv->title)));
- if (url && eina_stringshare_replace(&priv->uri, url))
- evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
- }
- void ewkViewSetTitle(Evas_Object* ewkView, const char* title)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (!title || !eina_stringshare_replace(&priv->title, title))
- return;
- evas_object_smart_callback_call(ewkView, "title,changed", static_cast<void*>(const_cast<char*>(priv->title)));
- }
- void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
- {
- evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
- }
- void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (priv->authChallenge)
- ewkAuthChallengeDelete(priv->authChallenge);
- priv->authChallenge = authChallenge;
- evas_object_smart_callback_call(ewkView, "authentication,challenge", priv->authChallenge);
- }
- void ewkViewLoadProgressChanged(Evas_Object* ewkView, double progress)
- {
- evas_object_smart_callback_call(ewkView, "load,progress", &progress);
- }
- void ewk_view_process_crashed(Evas_Object* ewkView)
- {
- bool handled = false;
- evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
- if (!handled)
- exit(0);
- }
- #if ENABLE(TIZEN_SQL_DATABASE)
- unsigned long long ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, currentQuota);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, currentQuota);
- if (priv->exceededDatabaseQuota)
- ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
- priv->exceededDatabaseQuota = ewkContextCreateExceededQuota(origin, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
- evas_object_smart_callback_call(ewkView, "database,quota,exceeded", priv->exceededDatabaseQuota);
- return ewkContextGetNewQuotaForExceededQuota(priv->context, priv->exceededDatabaseQuota);
- }
- #endif
- #if ENABLE(TIZEN_NOTIFICATION)
- void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
- {
- evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
- }
- void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if(priv->notificationPermissionRequest)
- ewkNotificationDeletePermissionRequest(priv->notificationPermissionRequest);
- priv->notificationPermissionRequest = notificationPermissionRequest;
- evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
- }
- void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- Eina_List* listIterator=0;
- void* data=0;
- const char* replaceID = ewkNotificationGetReplaceID(notification);
- if(strlen(replaceID)) {
- EINA_LIST_FOREACH(priv->notifications, listIterator, data) {
- Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
- if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
- ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
- }
- }
- priv->notifications = eina_list_append(priv->notifications, notification);
- evas_object_smart_callback_call(ewkView, "notification,show", notification);
- }
- #endif
- #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
- void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
- {
- EINA_SAFETY_ON_NULL_RETURN(ewkView);
- Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
- evas_object_smart_callback_call(ewkView, "protocolhandlers,register", static_cast<void*>(customHandlersData));
- ewkCustomHandlersDeleteData(customHandlersData);
- }
- #endif
- #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
- void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
- {
- EINA_SAFETY_ON_NULL_RETURN(ewkView);
- Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
- evas_object_smart_callback_call(ewkView, "contenthandlers,register", static_cast<void*>(customHandlersData));
- ewkCustomHandlersDeleteData(customHandlersData);
- }
- #endif
- #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
- bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
- {
- bool standalone = true;
- evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
- return standalone;
- }
- #endif
- #if ENABLE(TIZEN_MM_PLAYER)
- void ewkViewProcessHTML5Video(Evas_Object* ewkView, WKStringRef url, WKStringRef cookie)
- {
- Ewk_View_Html5_Video_Data videoData;
- videoData.url = url;
- videoData.cookie = cookie;
- evas_object_smart_callback_call(ewkView, "request,html5video", &videoData);
- }
- #endif
- #if ENABLE(TIZEN_MEDIA_STREAM)
- void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission* userMediaPermission)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (priv->userMediaPermission)
- ewkUserMediaPermissionDelete(priv->userMediaPermission);
- priv->userMediaPermission = userMediaPermission;
- evas_object_smart_callback_call(ewkView, "usermedia,permission,request", priv->userMediaPermission);
- }
- #endif
- #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
- void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
- {
- int requestLength = WKStringGetMaximumUTF8CStringSize(request);
- OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
- int messageLength = WKStringGetMaximumUTF8CStringSize(message);
- OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
- WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
- WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
- evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
- }
- #endif
- #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
- void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
- {
- evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
- }
- #endif
- void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
- {
- evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
- }
- void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
- {
- evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
- }
- void ewkViewClosePage(Evas_Object* ewkView)
- {
- evas_object_smart_callback_call(ewkView, "close,window", 0);
- }
- #if ENABLE(TIZEN_GEOLOCATION)
- void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Data* permissionData)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (priv->geolocationPermission)
- ewkGeolocationDeletePermission(priv->geolocationPermission);
- priv->geolocationPermission = permissionData;
- evas_object_smart_callback_call(ewkView, "request,geolocation,permission", priv->geolocationPermission);
- }
- void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- priv->geolocation = geolocation;
- }
- Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- return priv->geolocation;
- }
- bool ewkViewIsValidLocationService(Evas_Object* ewkView)
- {
- bool valid = false;
- evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
- return valid;
- }
- #endif
- WKPageRef ewkViewCreateNewPage(Evas_Object* ewkView)
- {
- Evas_Object* createdEwkView = 0;
- evas_object_smart_callback_call(ewkView, "create,window", &createdEwkView);
- if (!createdEwkView)
- return 0;
- return static_cast<WKPageRef>(WKRetain(toAPI(ewk_view_page_get(createdEwkView))));
- }
- void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
- {
- evas_object_smart_callback_call(ewkView, "form,submit", formData);
- }
- void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
- EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
- if (priv->policyDecision)
- ewkPolicyDecisionDelete(priv->policyDecision);
- priv->policyDecision = policyDecision;
- evas_object_smart_callback_call(ewkView, "policy,navigation,decide", priv->policyDecision);
- }
- void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
- EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
- if (priv->policyDecision)
- ewkPolicyDecisionDelete(priv->policyDecision);
- priv->policyDecision = policyDecision;
- evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", priv->policyDecision);
- }
- void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
- EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
- if (priv->policyDecision)
- ewkPolicyDecisionDelete(priv->policyDecision);
- priv->policyDecision = policyDecision;
- evas_object_smart_callback_call(ewkView, "policy,response,decide", priv->policyDecision);
- }
- void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- IntPoint scrollPosition = priv->pageClient->scrollPosition();
- IntSize contentsSize = priv->pageClient->page()->contentsSize();
- #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
- contentsSize.scale(priv->pageClient->scaleFactor());
- #endif
- // some website's contents size is smaller than view size,
- // so we have to adjust contents size to view size for that case.
- if (contentsSize.width() < smartData->view.w)
- contentsSize.setWidth(smartData->view.w);
- if (contentsSize.height() < smartData->view.h)
- contentsSize.setHeight(smartData->view.h);
- // Call "scroll,down" if webview can be scrolled down.
- if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
- evas_object_smart_callback_call(ewkView, "scroll,down", 0);
- // Call "scroll,up" if webview can be scrolled up.
- else if (deltaY < 0 && scrollPosition.y() > 0)
- evas_object_smart_callback_call(ewkView, "scroll,up", 0);
- // Call "scroll,right" if webview can be scrolled down.
- if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
- evas_object_smart_callback_call(ewkView, "scroll,right", 0);
- // Call "scroll,left" if webview can be scrolled up.
- else if (deltaX < 0 && scrollPosition.x() > 0)
- evas_object_smart_callback_call(ewkView, "scroll,left", 0);
- }
- void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- IntSize contentsSize = priv->pageClient->page()->contentsSize();
- #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
- contentsSize.scale(priv->pageClient->scaleFactor());
- #endif
- int maxScrollY = contentsSize.height() - smartData->view.h;
- if (!priv->isVerticalEdge) {
- if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
- evas_object_smart_callback_call(ewkView, "edge,top", NULL);
- priv->isVerticalEdge = true;
- } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
- evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
- priv->isVerticalEdge = true;
- }
- } else {
- if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
- || (scrollPosition.y() == maxScrollY && deltaY < 0)))
- priv->isVerticalEdge = false;
- }
- int maxScrollX = contentsSize.width() - smartData->view.w;
- if (!priv->isHorizontalEdge) {
- if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
- evas_object_smart_callback_call(ewkView, "edge,left", NULL);
- priv->isHorizontalEdge = true;
- } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
- evas_object_smart_callback_call(ewkView, "edge,right", NULL);
- priv->isHorizontalEdge = true;
- }
- } else {
- if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
- || (scrollPosition.x() == maxScrollX && deltaX < 0)))
- priv->isHorizontalEdge = false;
- }
- }
- void ewkViewClearEdges(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- priv->isVerticalEdge = false;
- priv->isHorizontalEdge = false;
- }
- void ewk_view_top_of_contents_go(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
- priv->pageClient->setVisibleContentRect(IntPoint(), priv->pageClient->scaleFactor(), FloatPoint());
- priv->pageClient->displayViewport();
- #else
- priv->pageClient->page()->scrollMainFrameTo(IntPoint());
- #endif
- }
- Eina_Bool ewk_view_enable_specified_plugin_set(Evas_Object* ewkView, Eina_Bool enable, const char* mimeType)
- {
- #if ENABLE(TIZEN_ON_OFF_SPECIFIED_PLUGINS)
- if (!mimeType)
- return false;
- PluginDatabase* pluginDatabase = PluginDatabase::installedPlugins(true);
- if (!pluginDatabase)
- return false;
- // Find pluginPackage.
- String key = String(mimeType).lower();
- Vector<PluginPackage*, 2> pluginChoices;
- const Vector<WebCore::PluginPackage *> plugins = pluginDatabase->plugins();
- for (unsigned int i = 0; i < plugins.size(); i++) {
- PluginPackage* plugin = plugins[i];
- if (plugin->mimeToDescriptions().contains(key))
- pluginChoices.append(plugin);
- }
- // Set enable/disable to choiced pluginPackage.
- if (!pluginChoices.isEmpty()) {
- qsort(pluginChoices.data(), pluginChoices.size(), sizeof(PluginPackage*), PluginDatabase::preferredPluginCompare);
- pluginChoices[0].setEnabled(enable);
- return true;
- }
- return false;
- #else
- return false;
- #endif
- }
- double ewk_view_scale_get(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1);
- return priv->pageClient->page()->scaleFactor();
- }
- Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, Evas_Coord centerX, Evas_Coord centerY)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- scaleFactor = priv->pageClient->adjustScaleWithViewport(scaleFactor);
- IntPoint scrollPosition = priv->pageClient->scrollPosition();
- double scaleDifference = scaleFactor / priv->pageClient->scaleFactor();
- int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
- int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
- priv->pageClient->page()->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
- return true;
- }
- void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
- {
- EWK_VIEW_SD_GET(ewkView, smartData);
- if (!smartData || !smartData->priv) {
- if (minimumScale)
- *minimumScale = -1;
- if (maximumScale)
- *maximumScale = -1;
- return;
- }
- PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
- if (minimumScale)
- *minimumScale = constraints.minimumScale;
- if (maximumScale)
- *maximumScale = constraints.maximumScale;
- }
- static void inputPickerClosed(void* data, Evas_Object*, void*)
- {
- Evas_Object* ewkView = static_cast<Evas_Object*>(data);
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
- EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
- ecore_imf_context_input_panel_hide(priv->pageClient->getIMFContext());
- ecore_imf_context_focus_out(priv->pageClient->getIMFContext());
- }
- Evas_Object* ewk_view_image_get(Evas_Object* o)
- {
- EWK_VIEW_SD_GET_OR_RETURN(o, sd, 0);
- return sd->image;
- }
- void ewk_view_form_navigation_move(Evas_Object* ewkView, int newPosition)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- priv->pageClient->page()->moveFocus(newPosition);
- priv->formNavigation.position = newPosition;
- }
- bool ewk_view_focused_node_adjust(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- double scaleFactor = priv->pageClient->scaleFactor();
- IntSize contentsSize = priv->pageClient->page()->contentsSize();
- IntSize visibleSize(0, 0);
- IntPoint scrollPosition(0, 0);
- IntRect caretRect(0, 0, 0, 0);
- double newScaleFactor = scaleFactor;
- // Readable zoom value is dependent on device DPI
- if (scaleFactor < priv->pageClient->page()->pageGroup()->preferences()->devicePixelRatio()
- && priv->pageClient->viewportConstraints().userScalable)
- newScaleFactor = ((float)priv->pageClient->page()->pageGroup()->preferences()->devicePixelRatio()) / 160;
- // Readable zoom value should be inside of viewport scale range
- newScaleFactor = priv->pageClient->adjustScaleWithViewport(newScaleFactor);
- // scale contents' size with new scale factor
- #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
- contentsSize.scale(newScaleFactor);
- #else
- contentsSize.scale(newScaleFactor / scaleFactor);
- #endif
- Ecore_IMF_Context* imfContext = priv->pageClient->getIMFContext();
- // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
- // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
- if (!(static_cast<PageClient*>(priv->pageClient.get()))->isViewFocused()
- || !imfContext
- || ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
- return false;
- visibleSize = IntSize(smartData->view.w, smartData->view.h);
- // caret position can be outside of visible rect.
- // we need to consider it.
- priv->pageClient->page()->getCaretPosition(caretRect);
- #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
- caretRect.scale(newScaleFactor);
- #else
- caretRect.scale(newScaleFactor / scaleFactor);
- #endif
- if (caretRect.isEmpty())
- return false;
- // set paddings
- scrollPosition.setX(caretRect.x() - 20);
- scrollPosition.setY(caretRect.y() - visibleSize.height() / 2);
- // Restrict visible content rect inside of contents boundary
- if (scrollPosition.x() < 0)
- scrollPosition.setX(0);
- if (scrollPosition.y() < 0)
- scrollPosition.setY(0);
- if (scrollPosition.x() + visibleSize.width() > contentsSize.width())
- scrollPosition.setX(contentsSize.width() - visibleSize.width());
- if (scrollPosition.y() + visibleSize.height() > contentsSize.height())
- scrollPosition.setY(contentsSize.height() - visibleSize.height());
- #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
- priv->pageClient->setVisibleContentRect(scrollPosition, newScaleFactor, FloatPoint());
- if (newScaleFactor == scaleFactor)
- priv->pageClient->displayViewport();
- #else
- if (newScaleFactor != scaleFactor)
- priv->pageClient->page()->scalePage(newScaleFactor, scrollPosition);
- else
- priv->pageClient->page()->scrollMainFrameTo(scrollPosition);
- #endif
- evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
- return true;
- }
- #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
- void ewk_view_mark_for_sync(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EINA_SAFETY_ON_NULL_RETURN(smartData->image);
- evas_object_image_pixels_dirty_set(smartData->image, true);
- }
- static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
- {
- Evas_Object* ewkView = static_cast<Evas_Object*>(data);
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- priv->pageClient->drawContents();
- }
- bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- if (!smartData->image)
- return false;
- evas_object_image_native_surface_set(smartData->image, nativeSurface);
- evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
- return true;
- }
- #endif
- #if ENABLE(TIZEN_WEBKIT_PASTEBOARD)
- void ewk_view_write_data_to_clipboard_with_type(Evas_Object* ewkView, const String& data, Pasteboard::PasteboardDataType type)
- {
- EINA_SAFETY_ON_NULL_RETURN(ewkView);
- switch (type) {
- case Pasteboard::PlainText:
- elm_cnp_selection_set(elm_object_parent_widget_get(ewkView), ELM_SEL_TYPE_CLIPBOARD,
- ELM_SEL_FORMAT_TEXT, data.utf8().data(), data.length());
- break;
- case Pasteboard::Markup:
- elm_cnp_selection_set(elm_object_parent_widget_get(ewkView), ELM_SEL_TYPE_CLIPBOARD,
- ELM_SEL_FORMAT_HTML, data.utf8().data(), data.length());
- break;
- case Pasteboard::ImageURI:
- // FIXME: We pass data.length() + 1 because of a bug in elementary which adds some random characters
- // to copied image path. '+1' should be removed when the bug will be fixed on elementary side.
- elm_cnp_selection_set(elm_object_parent_widget_get(ewkView), ELM_SEL_TYPE_CLIPBOARD,
- ELM_SEL_FORMAT_IMAGE, data.utf8().data(), data.length() + 1);
- break;
- default:
- break;
- }
- }
- static Eina_Bool pasteCallback(void* data, Evas_Object* object, Elm_Selection_Data* selectionData)
- {
- WebPageProxy* webPageProxy = static_cast<WebPageProxy*>(data);
- if (!selectionData || selectionData->len <= 0) {
- webPageProxy->sendPasteMessageWithData(String(""), WebCore::Pasteboard::PlainText);
- } else {
- String data = String::fromUTF8(static_cast<const char*>(selectionData->data));
- if (selectionData->format == ELM_SEL_FORMAT_TEXT)
- webPageProxy->sendPasteMessageWithData(data, WebCore::Pasteboard::PlainText);
- else if (selectionData->format == ELM_SEL_FORMAT_HTML)
- webPageProxy->sendPasteMessageWithData(data, WebCore::Pasteboard::Markup);
- else if (selectionData->format == ELM_SEL_FORMAT_IMAGE)
- webPageProxy->sendPasteMessageWithData(data, WebCore::Pasteboard::ImageURI);
- }
- return true;
- }
- void ewk_view_paste_with_clipboard(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (!ewk_util_number_of_clipboard_items_get(ewkView)) {
- priv->pageClient->page()->sendPasteMessageWithData(String(""), WebCore::Pasteboard::PlainText);
- return;
- }
- Eina_Bool result = elm_cnp_selection_get(elm_object_parent_widget_get(ewkView), ELM_SEL_TYPE_CLIPBOARD,
- static_cast<Elm_Sel_Format>(ELM_SEL_FORMAT_TEXT | ELM_SEL_FORMAT_HTML | ELM_SEL_FORMAT_IMAGE),
- pasteCallback, priv->pageClient->page());
- if (!result)
- priv->pageClient->page()->sendPasteMessageWithData(String(""), WebCore::Pasteboard::PlainText);
- }
- #endif // ENABLE(TIZEN_WEBKIT_PASTEBOARD)
- void ewk_view_suspend(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- priv->pageClient->suspendIfNeeded();
- }
- void ewk_view_resume(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- priv->pageClient->resumeIfNeeded();
- }
- Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
- ResourceRequest request(url);
- switch (method) {
- case EWK_HTTP_METHOD_GET:
- request.setHTTPMethod("GET");
- break;
- case EWK_HTTP_METHOD_HEAD:
- request.setHTTPMethod("HEAD");
- break;
- case EWK_HTTP_METHOD_POST:
- request.setHTTPMethod("POST");
- break;
- case EWK_HTTP_METHOD_PUT:
- request.setHTTPMethod("PUT");
- break;
- case EWK_HTTP_METHOD_DELETE:
- request.setHTTPMethod("DELETE");
- break;
- default:
- return false;
- }
- if (headers) {
- Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
- void* data;
- while (eina_iterator_next(it, &data)) {
- Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
- const char* name = static_cast<const char*>(t->key);
- const char* value = static_cast<const char*>(t->data);
- request.addHTTPHeaderField(name, value);
- }
- eina_iterator_free(it);
- }
- if (body)
- request.setHTTPBody(FormData::create(body));
- WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
- WKPageLoadURLRequest(toAPI(priv->pageClient->page()), urlRequest.get());
- return true;
- }
- Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
- WKPageLoadPlainTextString(toAPI(priv->pageClient->page()), plainTextRef.get());
- return true;
- }
- Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
- if (contentsSize == 0)
- return false;
- String mimeTypeString;
- if (mimeType)
- mimeTypeString = String::fromUTF8(mimeType);
- else
- mimeTypeString = String::fromUTF8("text/html");
- String encodingString;
- if (encoding)
- encodingString = String::fromUTF8(encoding);
- else
- encodingString = String::fromUTF8("UTF-8");
- String baseUriString;
- if (baseUri)
- baseUriString = String::fromUTF8(baseUri);
- else
- baseUriString = String::fromUTF8("about:blank");
- WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
- priv->pageClient->page()->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
- return true;
- }
- const char* ewk_view_title_get(const Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- return priv->title;
- }
- double ewk_view_load_progress_get(const Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1);
- return WKPageGetEstimatedProgress(toAPI(priv->pageClient->page()));
- }
- Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
- WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
- WKPageLoadHTMLString(toAPI(priv->pageClient->page()), htmlString.get(), baseURL.get());
- return true;
- }
- Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
- WKPageSetPageVisibility(toAPI(priv->pageClient->page()), static_cast<WKPageVisibilityState
- >(pageVisibilityState), initialState);
- return true;
- #else
- return false;
- #endif
- }
- Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
- {
- EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- eina_stringshare_replace(&priv->userAgent, userAgent);
- WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
- WKPageSetCustomUserAgent(toAPI(priv->pageClient->page()), userAgentString.get());
- return true;
- }
- const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- if (!priv->userAgent) {
- WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(priv->pageClient->page())));
- int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
- OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
- WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
- eina_stringshare_replace(&priv->userAgent, buffer.get());
- }
- return priv->userAgent;
- }
- Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
- {
- #if ENABLE(TIZEN_CUSTOM_HEADERS)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
- WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
- WKPageAddCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get(), customHeaderValue.get());
- return true;
- #else
- ERR("TIZEN_CUSTOM_HEADERS not enabled!");
- return false;
- #endif
- }
- const char* ewk_view_video_data_url_get(const Ewk_View_Html5_Video_Data* videoData)
- {
- #if ENABLE(TIZEN_MM_PLAYER)
- if (!videoData || !videoData->url)
- return "";
- return toImpl(videoData->url)->string().utf8().data();
- #else
- return "";
- #endif
- }
- const char* ewk_view_video_data_cookie_get(const Ewk_View_Html5_Video_Data* videoData)
- {
- #if ENABLE(TIZEN_MM_PLAYER)
- if (!videoData || videoData->cookie)
- return "";
- return toImpl(videoData->cookie)->string().utf8().data();
- #else
- return "";
- #endif
- }
- #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
- Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- priv->pageClient->setIsVisible(enable);
- return true;
- }
- #endif
- Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
- {
- EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- WKRect rect;
- rect.origin.x = viewArea.x;
- rect.origin.y = viewArea.y;
- rect.size.width = viewArea.w;
- rect.size.height = viewArea.h;
- WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(priv->pageClient->page()), rect, scaleFactor));
- if (!snapshot.get())
- return 0;
- RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
- Evas_Object* screenshotImage = evas_object_image_add(canvas);
- int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
- int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
- evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
- evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
- uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
- RefPtr<cairo_surface_t> imageSurface = adoptRef(cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_RGB24, surfaceWidth, surfaceHeight, cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, surfaceWidth)));
- RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
- cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
- cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
- cairo_fill(cairo.get());
- evas_object_image_smooth_scale_set(screenshotImage, true);
- evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
- evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
- evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
- evas_object_image_data_set(screenshotImage, pixels);
- return screenshotImage;
- }
- unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
- {
- #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, 0);
- return priv->pageClient->page()->startInspectorServer(port);
- #else
- LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
- return 0;
- #endif
- }
- Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
- {
- #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
- return priv->pageClient->page()->stopInspectorServer();
- #else
- LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
- return false;
- #endif
- }
- void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- WKPageScrollBy(toAPI(priv->pageClient->page()), toAPI(IntSize(deltaX, deltaY)));
- }
- Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
- {
- if (x)
- *x = 0;
- if (y)
- *y = 0;
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- IntPoint scrollPosition = priv->pageClient->scrollPosition();
- if (x)
- *x = scrollPosition.x();
- if (y)
- *y = scrollPosition.y();
- return true;
- }
- Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- priv->pageClient->page()->scrollMainFrameTo(IntPoint(x, y));
- return true;
- }
- Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
- {
- if (width)
- *width = 0;
- if (height)
- *height = 0;
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- IntSize contentsSize = priv->pageClient->page()->contentsSize();
- #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
- contentsSize.scale(priv->pageClient->scaleFactor());
- #endif
- if (width && contentsSize.width() > smartData->view.w)
- *width = contentsSize.width() - smartData->view.w;
- if (height && contentsSize.height() > smartData->view.h)
- *height = contentsSize.height() - smartData->view.h;
- return true;
- }
- bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- if (!priv->alertContext || !priv->alertContext->javascriptAlertCallback)
- return false;
- EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->alertContext->ewkView == ewkView, false);
- int length = WKStringGetMaximumUTF8CStringSize(alertText);
- OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
- WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
- return priv->alertContext->javascriptAlertCallback(priv->alertContext->ewkView, alertTextBuffer.get(), priv->alertContext->userData) == EINA_TRUE;
- }
- bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- if (!priv->confirmContext || !priv->confirmContext->javascriptConfirmCallback)
- return false;
- EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->confirmContext->ewkView == ewkView, false);
- int length = WKStringGetMaximumUTF8CStringSize(message);
- OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
- WKStringGetUTF8CString(message, messageBuffer.get(), length);
- return priv->confirmContext->javascriptConfirmCallback(priv->confirmContext->ewkView, messageBuffer.get(), priv->confirmContext->userData) == EINA_TRUE;
- }
- bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- if (!priv->promptContext || !priv->promptContext->javascriptPromptCallback)
- return false;
- EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->promptContext->ewkView == ewkView, false);
- int length = WKStringGetMaximumUTF8CStringSize(message);
- OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
- WKStringGetUTF8CString(message, messageBuffer.get(), length);
- length = WKStringGetMaximumUTF8CStringSize(defaultValue);
- OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
- WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
- return priv->promptContext->javascriptPromptCallback(priv->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), priv->promptContext->userData) == EINA_TRUE;
- }
- bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- if (!priv->openpanelContext || !priv->openpanelContext->openPanelCallback)
- return false;
- EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->openpanelContext->ewkView == ewkView, false);
- priv->openPanelListener = listener;
- Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
- Eina_List* acceptedMimeTypes = 0;
- WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
- size_t len = WKArrayGetSize(array.get());
- for (size_t i = 0; i < len; i++) {
- WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
- if (WKGetTypeID(item) != WKStringGetTypeID())
- continue;
- WKStringRef mime = static_cast<WKStringRef>(item);
- int length = WKStringGetMaximumUTF8CStringSize(mime);
- char* buffer = new char[length];
- WKStringGetUTF8CString(mime, buffer, length);
- acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
- }
- const char* capture = 0;
- #if ENABLE(MEDIA_CAPTURE)
- WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
- capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
- #endif
- bool result = priv->openpanelContext->openPanelCallback(priv->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
- if (!acceptedMimeTypes)
- return result;
- Eina_List* list;
- void* data = 0;
- EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
- delete[] (char*)data;
- eina_list_free(acceptedMimeTypes);
- return result;
- }
- void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (!priv->alertContext)
- priv->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
- priv->alertContext->javascriptAlertCallback = callback;
- priv->alertContext->ewkView = ewkView;
- priv->alertContext->userData = userData;
- }
- void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- WKPageReplyJavaScriptAlert(toAPI(ewk_view_page_get(ewkView)));
- }
- void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (!priv->confirmContext)
- priv->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
- priv->confirmContext->javascriptConfirmCallback = callback;
- priv->confirmContext->ewkView = ewkView;
- priv->confirmContext->userData = userData;
- }
- void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- WKPageReplyJavaScriptConfirm(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
- }
- void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (!priv->promptContext)
- priv->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
- priv->promptContext->javascriptPromptCallback = callback;
- priv->promptContext->ewkView = ewkView;
- priv->promptContext->userData = userData;
- }
- void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
- WKPageReplyJavaScriptPrompt(toAPI(ewk_view_page_get(ewkView)), result ? resultString.get() : 0);
- }
- void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (!priv->openpanelContext)
- priv->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
- priv->openpanelContext->openPanelCallback = callback;
- priv->openpanelContext->ewkView = ewkView;
- priv->openpanelContext->userData = userData;
- }
- void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (!priv->openPanelListener)
- return;
- unsigned int size = eina_list_count(fileUrls);
- if ((result == EINA_FALSE) || (size == 0)) {
- WKOpenPanelResultListenerCancel(priv->openPanelListener);
- priv->openPanelListener = 0;
- return;
- }
- WKTypeRef* items = new WKTypeRef[size];
- Eina_List* list;
- void* data;
- unsigned int i = 0;
- EINA_LIST_FOREACH(fileUrls, list, data)
- items[i++] = WKURLCreateWithUTF8CString((char*)data);
- WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
- WKOpenPanelResultListenerChooseFiles(priv->openPanelListener, filesArray.get());
- priv->openPanelListener = 0;
- delete [] items;
- eina_list_free(fileUrls);
- }
- static void getRssItemsCallback(const Eina_List* rss_items, WKErrorRef, void* context)
- {
- EINA_SAFETY_ON_NULL_RETURN(context);
- Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
- ASSERT(callbackContext->rssItemsGetCallback);
- callbackContext->rssItemsGetCallback(callbackContext->ewkView, rss_items, callbackContext->userData);
- delete callbackContext;
- }
- Eina_Bool ewk_view_rss_items_get(Evas_Object* ewkView, Ewk_View_Rss_Items_Get_Callback callback, void* user_data)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
- Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
- context->rssItemsGetCallback = callback;
- context->ewkView = ewkView;
- context->userData = user_data;
- WKPageGetRssItems(toAPI(priv->pageClient->page()), context, getRssItemsCallback);
- return true;
- }
- #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
- static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
- {
- EINA_SAFETY_ON_NULL_RETURN(capable);
- EINA_SAFETY_ON_NULL_RETURN(context);
- Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
- ASSERT(webAppContext->webAppCapableCallback);
- if (capable)
- webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
- else
- webAppContext->webAppCapableCallback(0, webAppContext->userData);
- delete webAppContext;
- }
- static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
- {
- EINA_SAFETY_ON_NULL_RETURN(iconURL);
- EINA_SAFETY_ON_NULL_RETURN(context);
- Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
- EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- ASSERT(webAppContext->webAppIconURLCallback);
- if (iconURL) {
- eina_stringshare_replace(&priv->webAppIconURL, toImpl(iconURL)->string().utf8().data());
- webAppContext->webAppIconURLCallback(priv->webAppIconURL, webAppContext->userData);
- } else
- webAppContext->webAppIconURLCallback(0, webAppContext->userData);
- delete webAppContext;
- }
- #endif
- Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
- {
- #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
- EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
- context->webAppCapableCallback = callback;
- context->ewkView = ewkView;
- context->userData = userData;
- WKPageGetWebAppCapable(toAPI(priv->pageClient->page()), context, didGetWebAppCapable);
- return true;
- #else
- return false;
- #endif
- }
- Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
- {
- #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
- EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
- context->webAppIconURLCallback = callback;
- context->ewkView = ewkView;
- context->userData = userData;
- WKPageGetWebAppIconURL(toAPI(priv->pageClient->page()), context, didGetWebAppIconURL);
- return true;
- #else
- return 0;
- #endif
- }
- Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
- WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
- WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
- WKPageExecuteCommandWithArgument(toAPI(priv->pageClient->page()), commandString.get(), valueString.get());
- return true;
- }
- Eina_Bool ewk_view_string_find(Evas_Object* ewkView, const char* string, EwkFindOptions options, unsigned maxMatchCount, Ewk_View_String_Find_Callback callback, void* userData)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(string, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
- priv->findClientInfo.callback = callback;
- priv->findClientInfo.userData = userData;
- WKRetainPtr<WKStringRef> findString(AdoptWK, WKStringCreateWithUTF8CString(string));
- WKPageFindString(toAPI(priv->pageClient->page()), findString.get(), options, maxMatchCount);
- return true;
- }
- Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
- {
- if (width)
- *width = 0;
- if (height)
- *height = 0;
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- IntSize contentsSize = priv->pageClient->page()->contentsSize();
- if (width)
- *width = contentsSize.width();
- if (height)
- *height = contentsSize.height();
- return true;
- }
- Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, const char* fileName)
- {
- #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
- IntSize contentsSize = priv->pageClient->page()->contentsSize();
- WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
- return true;
- #else
- return false;
- #endif
- }
- static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
- {
- EINA_SAFETY_ON_NULL_RETURN(context);
- Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
- if (!callbackContext->scriptExecuteCallback) {
- delete callbackContext;
- return;
- }
- JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
- if (scriptValue) {
- JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
- JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
- size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
- OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
- JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
- callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
- } else
- callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
- delete callbackContext;
- }
- Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
- Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
- context->scriptExecuteCallback = callback;
- context->ewkView = ewkView;
- context->userData = user_data;
- WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
- WKPageRunJavaScriptInMainFrame(toAPI(priv->pageClient->page()), scriptString.get(), context, runJavaScriptCallback);
- return true;
- }
- void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
- {
- #if ENABLE(TIZEN_WEBKIT2_THEME_SET)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (!eina_stringshare_replace(&priv->theme, path))
- return;
- priv->pageClient->page()->setThemePath(path);
- #endif
- }
- const char* ewk_view_theme_get(const Evas_Object* ewkView)
- {
- #if ENABLE(TIZEN_WEBKIT2_THEME_SET)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- return priv->theme;
- #else
- return 0;
- #endif
- }
- void ewkViewDidFindString(Evas_Object* ewkView, WKStringRef string, unsigned maxMatchCount)
- {
- EINA_SAFETY_ON_NULL_RETURN(string);
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- int length = WKStringGetMaximumUTF8CStringSize(string);
- OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
- WKStringGetUTF8CString(string, buffer.get(), length);
- if (priv->findClientInfo.callback)
- priv->findClientInfo.callback(ewkView, buffer.get(), maxMatchCount, priv->findClientInfo.userData);
- }
- #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
- static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
- {
- Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
- if (quota)
- storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
- else
- storageContext->webStorageQuotaCallback(0, storageContext->userData);
- delete storageContext;
- }
- #endif
- Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
- {
- #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
- EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
- Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
- context->webStorageQuotaCallback = resultCallback;
- context->userData = userData;
- WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
- WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
- return true;
- #else
- return false;
- #endif
- }
- Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
- {
- #if ENABLE(TIZEN_WEB_STORAGE)
- EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
- WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
- WKPageSetWebStorageQuota(pageRef, quota);
- return true;
- #else
- return false;
- #endif
- }
- static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
- {
- EINA_SAFETY_ON_NULL_RETURN(context);
- Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
- ASSERT(callbackContext->plainTextGetCallback);
- if (plain_text) {
- size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
- OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
- WKStringGetUTF8CString(plain_text, buffer.get(), length);
- callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
- } else
- callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
- delete callbackContext;
- }
- Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
- Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
- context->plainTextGetCallback = callback;
- context->ewkView = ewkView;
- context->userData = user_data;
- WKPageGetContentsAsString(toAPI(priv->pageClient->page()), context, getContentsAsStringCallback);
- return true;
- }
- Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
- {
- #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- int viewPositionX;
- int viewPositionY;
- evas_object_geometry_get(ewkView, &viewPositionX, &viewPositionY, 0, 0);
- IntPoint pointForHitTest(x, y);
- #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
- float revertScale = 1 / priv->pageClient->scaleFactor();
- IntPoint scrollPosition = priv->pageClient->scrollPosition();
- pointForHitTest.setX((scrollPosition.x() + (x - viewPositionX)) * revertScale);
- pointForHitTest.setY((scrollPosition.y() + (y - viewPositionY)) * revertScale);
- #else
- pointForHitTest.setX(x - viewPositionX);
- pointForHitTest.setY(y - viewPositionY);
- #endif
- WebHitTestResult::Data hitTestResultData = priv->pageClient->page()->hitTestResultAtPoint(pointForHitTest, hitTestMode);
- Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
- return hitTest;
- #else
- return 0;
- #endif
- }
- Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
- {
- EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
- return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(ewk_view_page_get(ewkView))));
- }
- Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- WKPageRecordingSurfaceSetEnable(toAPI(priv->pageClient->page()), enable);
- return true;
- }
- Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
- {
- #if ENABLE(TIZEN_NOTIFICATION)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(priv->context, false);
- if (!eina_list_count(ewkNotifications))
- return false;
- Eina_List* listIterator = 0;
- void* data = 0;
- Vector<WKTypeRef> ids;
- EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
- Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
- WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
- ids.append(idRef);
- priv->notifications = eina_list_remove(priv->notifications, notification);
- }
- WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
- WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(ewk_context_WKContext_get(priv->context));
- WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
- ewkNotificationDeleteNotificationList(ewkNotifications);
- return true;
- #else
- return false;
- #endif
- }
- #if ENABLE(TIZEN_WEBKIT2_POPUP)
- void ewk_view_popup_menu_request(Evas_Object* ewkView, WebPopupMenuProxyEfl* popupMenu, const IntRect& rect, TextDirection textDirection, double pageScaleFactor, const Vector<WebPopupItem>& items, int32_t selectedIndex)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api->popup_menu_show);
- ASSERT(popupMenenu);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (priv->popupMenuProxy)
- ewk_view_popup_menu_close(ewkView);
- priv->popupMenuProxy = popupMenu;
- Eina_List* popupItems = 0;
- for (size_t i = 0; i < items.size(); ++i) {
- Ewk_Popup_Menu_Item* item = new Ewk_Popup_Menu_Item;
- if (items[i].m_type == WebPopupItem::Separator) {
- item->type = EWK_POPUP_MENU_SEPARATOR;
- item->text = 0;
- } else {
- item->type = EWK_POPUP_MENU_ITEM;
- item->text = eina_stringshare_add(items[i].m_text.utf8().data());
- }
- popupItems = eina_list_append(popupItems, item);
- }
- priv->popupMenuItems = popupItems;
- smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, popupItems, selectedIndex);
- }
- Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
- if (smartData->api->popup_menu_hide)
- smartData->api->popup_menu_hide(smartData);
- void* itemv;
- EINA_LIST_FREE(priv->popupMenuItems, itemv) {
- Ewk_Popup_Menu_Item* item = static_cast<Ewk_Popup_Menu_Item*>(itemv);
- eina_stringshare_del(item->text);
- delete item;
- }
- priv->popupMenuProxy = 0;
- }
- Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
- if (selectedIndex > eina_list_count(priv->popupMenuItems))
- return false;
- priv->popupMenuProxy->valueChanged(selectedIndex);
- return true;
- }
- #endif
- void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
- {
- #if ENABLE(TIZEN_ORIENTATION_EVENTS)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
- return;
- if (priv->orientation == orientation)
- return;
- priv->orientation = orientation;
- priv->pageClient->page()->sendOrientationChangeEvent(orientation);
- #endif
- }
- void ewkViewFrameRendered(Evas_Object* ewkView)
- {
- evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
- }
- const char* ewk_view_encoding_custom_get(const Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- WKRetainPtr<WKStringRef> encodingString(AdoptWK, WKPageCopyCustomTextEncodingName(toAPI(priv->pageClient->page())));
- eina_stringshare_replace(&priv->encoding, toImpl(encodingString.get())->string().utf8().data());
- return priv->encoding;
- }
- void ewk_view_encoding_custom_set(Evas_Object* ewkView, const char* encoding)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- WKRetainPtr<WKStringRef> encodingString(AdoptWK, WKStringCreateWithUTF8CString(encoding));
- WKPageSetCustomTextEncodingName(toAPI(priv->pageClient->page()), encodingString.get());
- }
- #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
- Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- priv->pageClient->setIsTextSelectionEnable(enable);
- return true;
- }
- Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient->page()->focusedFrame(), false);
- IntRect leftSelectionRect;
- IntRect rightSelectionRect;
- if (!priv->pageClient->page()->focusedFrame()->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
- leftRect->x = 0;
- leftRect->y = 0;
- leftRect->w = 0;
- leftRect->h = 0;
- rightRect->x = 0;
- rightRect->y = 0;
- rightRect->w = 0;
- rightRect->h = 0;
- return false;
- }
- int viewPositionX;
- int viewPositionY;
- evas_object_geometry_get(ewkView, &viewPositionX, &viewPositionY, 0, 0);
- #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
- float scaleFactor = priv->pageClient->scaleFactor();
- IntPoint scrollPosition = priv->pageClient->scrollPosition();
- leftSelectionRect.scale(scaleFactor);
- leftSelectionRect.move(-scrollPosition.x(), -scrollPosition.y());
- #endif
- leftSelectionRect.move(viewPositionX, viewPositionY);
- #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
- rightSelectionRect.scale(scaleFactor);
- rightSelectionRect.move(-scrollPosition.x(), -scrollPosition.y());
- #endif
- rightSelectionRect.move(viewPositionX, viewPositionY);
- leftRect->x = leftSelectionRect.x();
- leftRect->y = leftSelectionRect.y();
- leftRect->w = leftSelectionRect.width();
- leftRect->h = leftSelectionRect.height();
- rightRect->x = rightSelectionRect.x();
- rightRect->y = rightSelectionRect.y();
- rightRect->w = rightSelectionRect.width();
- rightRect->h = rightSelectionRect.height();
- return true;;
- }
- const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient->page()->focusedFrame(), 0);
- const CString selectedString = priv->pageClient->page()->focusedFrame()->getSelectionText().utf8();
- eina_stringshare_replace(&priv->selectedText, selectedString.data());
- return priv->selectedText;
- }
- #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
- #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
- smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
- }
- #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
- void ewkViewColorChooserRequest(Evas_Object* ewkView, WebColorChooserProxyEfl* colorChooser, const String& inputValue)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- priv->colorChooser = colorChooser;
- ewkViewInputPickerRequest(ewkView, EWK_INPUT_TYPE_COLOR, inputValue);
- }
- #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
- #endif
- void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
- {
- #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- priv->pageClient->page()->setFocusedInputElementValue(String(value));
- #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- }
- const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
- {
- #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
- eina_stringshare_replace(&priv->inputValue, priv->pageClient->page()->getFocusedInputElementValue().utf8().data());
- return priv->inputValue;
- #else
- return 0;
- #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
- }
- void ewk_view_color_chooser_color_set(Evas_Object* ewkView, const char* color)
- {
- #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (priv->colorChooser)
- priv->colorChooser->setSelectedColor(Color(color));
- #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
- }
- void ewk_view_color_chooser_close(Evas_Object* ewkView)
- {
- #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (priv->colorChooser)
- priv->colorChooser->endChooser();
- priv->colorChooser = 0;
- #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
- }
- #if ENABLE(TIZEN_DATALIST_ELEMENT)
- void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
- if (priv->dataList)
- ewkViewDataListHideRequest(ewkView, inputType);
- for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
- String value = *it;
- priv->dataList = eina_list_append(priv->dataList, eina_stringshare_add(value.utf8().data()));
- }
- smartData->api->data_list_show(smartData, inputType, priv->dataList);
- }
- void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- EINA_SAFETY_ON_NULL_RETURN(priv->dataList);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
- if (priv->dataList) {
- _ewk_view_data_list_del(priv->dataList);
- priv->dataList = 0;
- }
- smartData->api->data_list_hide(smartData, inputType);
- }
- #endif
- void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
- {
- #if ENABLE(TIZEN_DATALIST_ELEMENT)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- if (priv->dataList) {
- _ewk_view_data_list_del(priv->dataList);
- priv->dataList = 0;
- }
- ewk_view_focused_input_element_value_set(ewkView, value);
- #endif
- }
- Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
- {
- #if ENABLE(TIZEN_GESTURE)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- return priv->holdHorizontalPanning;
- #else
- return false;
- #endif
- }
- void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
- {
- #if ENABLE(TIZEN_GESTURE)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
- priv->holdHorizontalPanning = hold;
- #endif
- }
- Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
- {
- #if ENABLE(TIZEN_GESTURE)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
- return priv->holdVerticalPanning;
- #else
- return false;
- #endif
- }
- void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
- {
- #if ENABLE(TIZEN_GESTURE)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
- priv->holdVerticalPanning = hold;
- #endif
- }
- void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
- {
- #if ENABLE(TIZEN_GESTURE)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
- #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
- if (wasHandled)
- ewkViewHideFocusRing(ewkView);
- #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
- if (priv->areMouseEventsEnabled)
- return;
- // We have to check TouchStart, TouchMove and TouchEnd with handled.
- // The Pan and Flick will be enabled if Touch Start was not handled,
- // and Touch Move was not handled or did not occur.
- // Tap will be enabled if Touch Start and End was not handled
- // and Touch Move did not occur.
- // The gestures are disabled as a default.
- // o: handled, x: not handled
- // ------------------------------------------------------------
- // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
- // ------------------------------------------------------------
- // o | o or x | o or x || disable | disable
- // x | o | o or x || disable | disable
- // x | x | o or x || disable | enable
- // x |not occured | x || enable | enable
- // ------------------------------------------------------------
- if (type == WebEvent::TouchStart)
- priv->gestureRecognizer->setEnableGesture(!wasHandled);
- else if (type == WebEvent::TouchMove)
- priv->gestureRecognizer->setEnableMoving(!wasHandled);
- else if (type == WebEvent::TouchEnd && !priv->exceedTouchMoveThreshold && !wasHandled) {
- priv->gestureRecognizer->setEnableMoving(!wasHandled);
- priv->gestureRecognizer->setEnableTap(!wasHandled);
- }
- #endif
- }
- #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
- void ewkViewDidGetTextStyleStateForSelection(Evas_Object* ewkView, int underlineState, int italicState, int boldState)
- {
- Ewk_Text_Style* textStyle = ewkTextStyleCreate(underlineState, italicState, boldState);
- evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
- ewkTextStyleDelete(textStyle);
- }
- #endif
- #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
- bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
- EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
- if (!smartData->api->orientation_lock)
- return false;
- return smartData->api->orientation_lock(smartData, willLockOrientation);
- }
- void ewk_view_orientation_unlock(Evas_Object* ewkView)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EINA_SAFETY_ON_NULL_RETURN(smartData->api);
- if (!smartData->api->orientation_unlock)
- return;
- smartData->api->orientation_unlock(smartData);
- }
- #endif
- void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
- {
- #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- priv->orientationLock.callback = func;
- priv->orientationLock.data = data;
- #endif
- }
- #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
- Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
- if (priv->orientationLock.callback) {
- return priv->orientationLock.callback(sd->self, true, orientations, priv->orientationLock.data);
- }
- return false;
- }
- void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
- {
- EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
- priv->orientationLock.callback(sd->self, false, 0, priv->orientationLock.data);
- }
- #endif
- void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
- {
- EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
- EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
- priv->gestureClient->setZoomableArea(target, area);
- }
- #endif // #if OS(TIZEN)