/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
Large files files are truncated, but you can click here to view the full file
- /*
- 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(…
Large files files are truncated, but you can click here to view the full file