2 Copyright (C) 2011 Samsung Electronics
3 Copyright (C) 2012 Intel Corporation. All rights reserved.
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
24 #include "EwkViewImpl.h"
25 #include "LayerTreeCoordinatorProxy.h"
26 #include "NativeWebKeyboardEvent.h"
27 #include "NativeWebMouseEvent.h"
28 #include "NativeWebWheelEvent.h"
29 #include "PageClientImpl.h"
30 #include "WKAPICast.h"
31 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
32 #include "WKColorPickerResultListener.h"
34 #include "WKRetainPtr.h"
38 #include "WebPageGroup.h"
39 #include "WebPopupItem.h"
40 #include "WebPopupMenuProxyEfl.h"
41 #include "ewk_context.h"
42 #include "ewk_context_private.h"
43 #include "ewk_intent_private.h"
44 #include "ewk_settings_private.h"
45 #include "ewk_view_form_client_private.h"
46 #include "ewk_view_loader_client_private.h"
47 #include "ewk_view_policy_client_private.h"
48 #include "ewk_view_private.h"
49 #include "ewk_view_resource_load_client_private.h"
50 #include "ewk_web_resource.h"
51 #include <Ecore_Evas.h>
54 #include <WebCore/Cursor.h>
55 #include <WebCore/EflScreenUtilities.h>
56 #include <WebKit2/WKPageGroup.h>
57 #include <wtf/text/CString.h>
59 #if USE(ACCELERATED_COMPOSITING)
63 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
65 #define Cursor WebCore::Cursor
69 #include "DrawingAreaProxyImpl.h"
70 #include "JavaScriptPopup.h"
71 #include "OpenPanel.h"
74 #include "WKDownload.h"
76 #include "WKGeolocationPermissionRequest.h"
77 #include "WKImageCairo.h"
78 #include "WKOpenPanelParameters.h"
79 #include "WKOpenPanelResultListener.h"
81 #include "WKPageGroup.h"
83 #include "WKPageTizen.h"
84 #include "WKPreferences.h"
85 #include "WKSerializedScriptValue.h"
87 #include "WKURLRequest.h"
88 #include "ewk_auth_challenge_private.h"
89 #include "ewk_context_menu_private.h"
90 #include "ewk_error.h"
91 #include "ewk_error_private.h"
92 #include "ewk_history_private.h"
93 #include "ewk_popup_menu_item.h"
94 #include "ewk_popup_menu_item_private.h"
95 #include "ewk_view_context_menu_client.h"
96 #include "ewk_view_find_client.h"
97 #include "ewk_view_icondatabase_client.h"
98 #include "ewk_view_tizen_client.h"
99 #include "ewk_view_ui_client.h"
101 #include <Ecore_Evas.h>
102 #include <Elementary.h>
103 #include <JavaScriptCore/JSRetainPtr.h>
104 #include <WebCore/NotImplemented.h>
107 #if ENABLE(TIZEN_ICON_DATABASE)
108 #include "WKContextPrivate.h"
109 #include "WebContext.h"
112 #if ENABLE(TIZEN_GEOLOCATION)
113 #include "ewk_geolocation_private.h"
114 #include "ewk_security_origin.h"
115 #include "ewk_view_geolocation_provider.h"
118 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
119 #include "InputPicker.h"
122 #if ENABLE(TIZEN_GESTURE)
123 #include "GestureRecognizer.h"
124 #include "GestureClient.h"
127 #if ENABLE(TOUCH_EVENTS)
128 #include "NativeWebTouchEvent.h"
129 #include "WebEvent.h"
132 #if ENABLE(TIZEN_ISF_PORT)
133 #include <Ecore_IMF.h>
136 #if ENABLE(TIZEN_NOTIFICATIONS)
138 #include "WKNotificationManager.h"
139 #include "WKNumber.h"
140 #include "ewk_notification_private.h"
141 #include "ewk_view_notification_provider.h"
144 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
145 #include "ewk_popup_picker.h"
148 #if ENABLE(TIZEN_MEDIA_STREAM)
149 #include "WKUserMediaPermissionRequest.h"
150 #include "ewk_user_media_private.h"
153 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
154 #include "WebPageGroup.h"
155 #include "WebPreferences.h"
158 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
159 #include "ewk_hit_test_private.h"
162 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
163 #include "FocusRing.h"
166 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
167 #include "ewk_text_style.h"
170 #if ENABLE(TIZEN_SCREEN_READER)
171 #include "ScreenReaderProxy.h"
174 #if ENABLE(TIZEN_CSP)
175 #include <WebCore/ContentSecurityPolicy.h>
178 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
179 #include "WKDictionary.h"
180 #include "ewk_web_application_icon_data_private.h"
183 #endif // #if OS(TIZEN)
185 using namespace WebKit;
186 using namespace WebCore;
188 static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
191 typedef struct _Ewk_View_Callback_Context Ewk_View_Callback_Context;
192 #endif // #if OS(TIZEN)
194 static const int defaultCursorSize = 16;
196 typedef HashMap<uint64_t, Ewk_Web_Resource*> LoadingResourcesMap;
197 static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap);
199 struct _Ewk_View_Private_Data {
200 OwnPtr<PageClientImpl> pageClient;
205 const char* customEncoding;
206 const char* cursorGroup;
207 Evas_Object* cursorObject;
208 LoadingResourcesMap loadingResourcesMap;
209 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
210 WKColorPickerResultListenerRef colorPickerResultListener;
212 #if ENABLE(TOUCH_EVENTS)
213 bool areTouchEventsEnabled;
215 OwnPtr<Ewk_Settings> settings;
221 #if USE(ACCELERATED_COMPOSITING)
223 Evas_GL_Context* evasGlContext;
224 Evas_GL_Surface* evasGlSurface;
228 bool areMouseEventsEnabled;
229 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
233 JSGlobalContextRef javascriptGlobalContext;
235 const char* userAgent;
236 const char* encoding;
237 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
238 const char* webAppIconURL;
239 Eina_List* webAppIconURLs;
242 OwnPtr<Ewk_View_Callback_Context> alertContext;
243 OwnPtr<Ewk_View_Callback_Context> confirmContext;
244 OwnPtr<Ewk_View_Callback_Context> promptContext;
245 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
246 OwnPtr<Ewk_View_Callback_Context> beforeUnloadConfirmPanelContext;
248 OwnPtr<Ewk_View_Callback_Context> openpanelContext;
249 OwnPtr<JavaScriptPopup> javascriptPopup;
250 bool isWaitingForJavaScriptPopupReply;
251 OwnPtr<OpenPanel> openPanel;
252 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
253 OwnPtr<InputPicker> inputPicker;
254 const char* inputValue;
257 Ewk_Auth_Challenge* authChallenge;
258 Ewk_Policy_Decision* policyDecision;
259 WKOpenPanelResultListenerRef openPanelListener;
261 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
262 Ewk_Certificate_Policy_Decision* certificatePolicyDecision;
265 #if ENABLE(TIZEN_MEDIA_STREAM)
266 Eina_List* userMediaPermissionRequests;
269 Ewk_Context* context;
271 #if ENABLE(TIZEN_GEOLOCATION)
272 Ewk_Geolocation* geolocation;
273 Eina_List* geolocationPermissionRequests;
276 #if ENABLE(TIZEN_ISF_PORT)
277 Eina_List* imfContextList;
278 Ecore_IMF_Context* imfContext;
281 bool suspendRequested;
282 bool suspendedPainting;
283 bool suspendedResources;
285 #if ENABLE(TIZEN_NOTIFICATIONS)
286 Eina_List* notifications;
287 Eina_List* notificationPermissionRequests;
289 #if ENABLE(TIZEN_SQL_DATABASE)
290 Ewk_Context_Exceeded_Quota* exceededDatabaseQuota;
292 WebPopupMenuProxyEfl* popupMenuProxy;
293 Eina_List* popupMenuItems;
294 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
295 Ewk_Popup_Picker* popupPicker;
299 bool isHorizontalEdge;
300 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
301 OwnPtr<FocusRing> focusRing;
302 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
304 #if ENABLE(TIZEN_GESTURE)
305 OwnPtr<GestureRecognizer> gestureRecognizer;
306 OwnPtr<GestureClient> gestureClient;
307 #if ENABLE(TOUCH_EVENTS)
308 Evas_Coord_Point touchDownPoint;
309 bool exceedTouchMoveThreshold;
310 bool wasHandledTouchStart;
311 bool wasHandledTouchMove;
312 #endif // #if ENABLE(TOUCH_EVENTS)
313 bool holdHorizontalPanning;
314 bool holdVerticalPanning;
315 #endif // #if ENABLE(TIZEN_GESTURE)
316 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
317 bool mainFrameScrollbarVisibility;
320 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
321 Ecore_Animator* compositionAnimator;
324 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
325 const char* selectedText;
327 #if ENABLE(TIZEN_DATALIST_ELEMENT)
330 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
332 Ewk_Orientation_Lock_Cb callback;
336 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
337 RefPtr<WebPageGroup> pageGroup;
340 #if ENABLE(TIZEN_APPLICATION_CACHE)
341 OwnPtr<Ewk_View_Callback_Context> applicationCachePermissionContext;
342 Ewk_Security_Origin* applicationCachePermissionOrigin;
343 bool isWaitingForApplicationCachePermission;
345 #endif // #if OS(TIZEN)
347 _Ewk_View_Private_Data()
354 #if ENABLE(TIZEN_INPUT_COLOR_TYPE) // wait for upstream
355 , colorPickerResultListener(0)
357 #if ENABLE(TOUCH_EVENTS)
358 , areTouchEventsEnabled(false)
361 , isUsingEcoreX(false)
363 #if USE(ACCELERATED_COMPOSITING)
370 ~_Ewk_View_Private_Data()
372 eina_stringshare_del(uri);
373 eina_stringshare_del(title);
374 eina_stringshare_del(theme);
375 eina_stringshare_del(customEncoding);
376 _ewk_view_priv_loading_resources_clear(loadingResourcesMap);
379 evas_object_del(cursorObject);
381 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
382 if (compositionAnimator) {
383 ecore_animator_del(compositionAnimator);
384 compositionAnimator = 0;
392 struct _Ewk_View_Callback_Context {
394 Ewk_Web_App_Capable_Get_Callback webAppCapableCallback;
395 Ewk_Web_App_Icon_URL_Get_Callback webAppIconURLCallback;
396 Ewk_Web_App_Icon_URLs_Get_Callback webAppIconURLsCallback;
397 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
398 Ewk_Web_Storage_Quota_Get_Callback webStorageQuotaCallback;
400 Ewk_View_Script_Execute_Callback scriptExecuteCallback;
401 Ewk_View_Plain_Text_Get_Callback plainTextGetCallback;
402 #if ENABLE(TIZEN_SUPPORT_MHTML)
403 Ewk_View_MHTML_Data_Get_Callback mhtmlDataGetCallback;
405 Ewk_View_JavaScript_Alert_Callback javascriptAlertCallback;
406 Ewk_View_JavaScript_Confirm_Callback javascriptConfirmCallback;
407 Ewk_View_JavaScript_Prompt_Callback javascriptPromptCallback;
408 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
409 Ewk_View_Before_Unload_Confirm_Panel_Callback beforeUnloadConfirmPanelCallback;
411 Ewk_View_Open_Panel_Callback openPanelCallback;
412 #if ENABLE(TIZEN_APPLICATION_CACHE)
413 Ewk_View_Applicacion_Cache_Permission_Callback applicationCachePermissionCallback;
417 Evas_Object* ewkView;
420 #endif // #if OS(TIZEN)
422 #define EWK_VIEW_TYPE_CHECK(ewkView, result) \
423 bool result = true; \
425 const char* _tmp_otype = evas_object_type_get(ewkView); \
426 const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
427 if (EINA_UNLIKELY(!_tmp_s)) { \
429 ("%p (%s) is not a smart object!", \
430 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
434 const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
435 if (EINA_UNLIKELY(!_tmp_sc)) { \
437 ("%p (%s) is not a smart object!", \
438 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
442 else if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \
444 ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
445 ewkView, _tmp_otype ? _tmp_otype : "(null)", \
446 EWK_VIEW_TYPE_STR, _tmp_sc->data); \
451 #define EWK_VIEW_SD_GET(ewkView, smartData) \
452 EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \
453 Ewk_View_Smart_Data* smartData = 0; \
455 smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView);
457 #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \
458 EWK_VIEW_SD_GET(ewkView, smartData); \
460 EINA_LOG_CRIT("no smart data for object %p (%s)", \
461 ewkView, evas_object_type_get(ewkView)); \
462 return __VA_ARGS__; \
465 #define EWK_VIEW_PRIV_GET(smartData, priv) \
466 Ewk_View_Private_Data* priv = smartData->priv
468 #define EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, ...) \
470 EINA_LOG_CRIT("smart data is null"); \
471 return __VA_ARGS__; \
473 EWK_VIEW_PRIV_GET(smartData, priv); \
475 EINA_LOG_CRIT("no private data for object %p (%s)", \
476 smartData->self, evas_object_type_get(smartData->self)); \
477 return __VA_ARGS__; \
480 #define EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, ...) \
482 EINA_LOG_CRIT("smart data is null"); \
483 return __VA_ARGS__; \
485 EwkViewImpl* impl = smartData->ewkViewImpl; \
488 EINA_LOG_CRIT("no private data for object %p (%s)", \
489 smartData->self, evas_object_type_get(smartData->self)); \
490 return __VA_ARGS__; \
494 #define EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, ...) \
495 EwkViewImpl* impl = 0; \
497 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, __VA_ARGS__); \
498 impl = smartData->ewkViewImpl; \
500 EINA_LOG_CRIT("no private data for object %p (%s)", \
501 smartData->self, evas_object_type_get(smartData->self)); \
502 return __VA_ARGS__; \
507 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object*, const char* alertText, void* userData);
508 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object*, const char* message, void* userData);
509 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object*, const char* message, const char* defaultValue, void* userData);
510 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
511 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object*, const char* message, void* userData);
513 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);
515 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
516 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);
517 #if ENABLE(TIZEN_MULTIPLE_SELECT)
518 Eina_Bool _ewk_view_multiple_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items);
520 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data*);
521 Eina_Bool _ewk_view_popup_menu_update(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, Eina_List*, int);
523 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
524 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations);
525 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd);
528 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
529 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data*, Ewk_Input_Type, const char* inputValue);
532 #if ENABLE(TIZEN_DATALIST_ELEMENT)
533 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data*, Ewk_Input_Type, Eina_List*);
534 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data*, Ewk_Input_Type);
537 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
538 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data*, int, int, int, int);
539 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data*);
542 #if ENABLE(TIZEN_ISF_PORT)
543 static void _ewk_view_imf_context_destroy(Ewk_View_Private_Data*);
546 #endif // #if OS(TIZEN)
548 static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
550 if (smartData->changed.any)
552 smartData->changed.any = true;
553 evas_object_smart_changed(smartData->self);
556 // Default Event Handling.
557 static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
559 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
563 priv->pageClient->setViewFocused(true);
564 #endif // #if OS(TIZEN)
565 priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
566 #if ENABLE(TIZEN_ISF_PORT)
567 if (priv->imfContext) {
568 ecore_imf_context_focus_in(priv->imfContext);
569 ecore_imf_context_input_panel_show(priv->imfContext);
575 static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
577 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
581 #if ENABLE(TIZEN_ISF_PORT)
582 // Keypad should be hidden rapidly when moving focus on elementary
583 // because Ecore-ime doesn't support it.
584 if (priv->imfContext) {
585 ecore_imf_context_input_panel_hide(priv->imfContext);
586 ecore_imf_context_focus_out(priv->imfContext);
590 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
591 if (priv->pageClient->isTextSelectionMode())
592 priv->pageClient->setIsTextSelectionMode(false);
595 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
596 if (priv->pageClient->isContextMenuVisible())
597 priv->pageClient->page()->hideContextMenu();
600 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
601 priv->pageClient->clearClipboardSelectionHandler();
604 #if ENABLE(TIZEN_DRAG_SUPPORT)
605 if (priv->pageClient->isDragMode())
606 priv->pageClient->setDragMode(false);
609 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
610 if (smartData->api->formdata_candidate_is_showing(smartData))
611 smartData->api->formdata_candidate_hide(smartData);
614 priv->pageClient->setViewFocused(false);
615 #endif // #if OS(TIZEN)
616 priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
620 static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
622 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
623 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
625 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
626 //impl->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
627 priv->pageClient->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
631 static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
633 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
634 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
636 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
637 //impl->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
638 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
642 static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
644 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
645 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
647 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
648 //impl->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
649 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
653 static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
655 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
656 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
658 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
659 //impl->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
660 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
664 static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
666 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
668 #if ENABLE(TIZEN_ISF_PORT)
669 Ecore_IMF_Event IMFEvent;
670 ecore_imf_evas_event_key_down_wrap(const_cast<Evas_Event_Key_Down*>(downEvent), &IMFEvent.key_down);
671 bool filtered = ecore_imf_context_filter_event(priv->imfContext, ECORE_IMF_EVENT_KEY_DOWN, &IMFEvent);
673 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, filtered));
675 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent));
676 #endif // #if ENABLE(TIZEN_ISF_PORT)
680 static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
682 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
684 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
689 static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
691 #if ENABLE(TIZEN_GESTURE)
692 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
693 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
695 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
696 if (priv->pageClient->isTextSelectionMode() && priv->pageClient->isTextSelectionHandleDowned())
700 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
701 if (priv->focusRing) {
702 if (event->type == EWK_GESTURE_TAP && event->count == 1) {
703 priv->focusRing->requestToShow(IntPoint(event->position.x, event->position.y));
704 } else if (event->type == EWK_GESTURE_PAN) {
705 if (priv->exceedTouchMoveThreshold)
706 priv->focusRing->hide();
708 if (event->type != EWK_GESTURE_LONG_PRESS) {
709 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
710 if (!priv->pageClient->isContextMenuVisible())
712 priv->focusRing->hide();
718 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
719 if (smartData->api->formdata_candidate_is_showing(smartData))
720 smartData->api->formdata_candidate_hide(smartData);
723 switch (event->type) {
724 case EWK_GESTURE_TAP:
725 priv->gestureClient->startTap(IntPoint(event->position.x, event->position.y));
727 case EWK_GESTURE_LONG_PRESS: {
728 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
729 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
730 if (ewk_settings_text_selection_enabled_get(priv->settings.get()))
731 priv->pageClient->setIsTextSelectionMode(false);
733 IntPoint scenePoint(event->position.x, event->position.y);
734 IntPoint contentsPoint = impl->transformFromScene().mapPoint(scenePoint);
735 WebHitTestResult::Data hitTestResultData = priv->pageClient->page()->hitTestResultAtPoint(contentsPoint);
736 #if ENABLE(TIZEN_DRAG_SUPPORT)
737 // 1. Check to start dragging.
738 if (hitTestResultData.isDragSupport) {
739 priv->pageClient->setDragPoint(scenePoint);
740 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
742 priv->focusRing->show(IntRect(), true);
744 priv->gestureClient->showContextMenu(scenePoint);
748 // 2. Check to show context menu.
749 if (!hitTestResultData.absoluteImageURL.isEmpty()
750 || !hitTestResultData.absoluteLinkURL.isEmpty()
751 || !hitTestResultData.absoluteMediaURL.isEmpty()) {
752 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
754 priv->focusRing->show(IntRect(), true);
756 priv->gestureClient->showContextMenu(scenePoint);
759 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
760 // 3. Check for text selection.
761 if (ewk_settings_text_selection_enabled_get(priv->settings.get())) {
762 // Process gesture_end(EWK_GESTURE_TAP) to activate the editing if node under point is editable.
763 if (hitTestResultData.context & WebHitTestResult::HitTestResultContextEditable) {
764 if (smartData->api && smartData->api->gesture_end) {
765 Ewk_Event_Gesture tapEvent = {EWK_GESTURE_TAP, event->position, {0, 0}, 0, 1, ecore_time_get() * 1000};
766 smartData->api->gesture_end(smartData, &tapEvent);
770 if (priv->pageClient->textSelectionDown(scenePoint)) {
771 priv->gestureClient->setGestureEnabled(false);
772 ewkViewHandleTouchEvent(smartData->self, EWK_TOUCH_CANCEL);
777 #endif // #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
779 case EWK_GESTURE_PAN:
780 priv->gestureClient->startPan(IntPoint(event->position.x, event->position.y));
782 case EWK_GESTURE_FLICK:
783 priv->gestureClient->startFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
785 case EWK_GESTURE_PINCH:
786 if (priv->pageClient->viewportConstraints().userScalable)
787 priv->gestureClient->startPinch(IntPoint(event->position.x, event->position.y), event->scale);
790 ASSERT_NOT_REACHED();
797 #endif // #if ENABLE(TIZEN_GESTURE)
800 static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
802 #if ENABLE(TIZEN_GESTURE)
803 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
805 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
806 if (priv->pageClient->isTextSelectionMode() && priv->pageClient->isTextSelectionHandleDowned())
810 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
811 if (priv->focusRing) {
812 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
813 if (!priv->pageClient->isContextMenuVisible())
815 priv->focusRing->hide();
819 switch (event->type) {
820 case EWK_GESTURE_TAP:
821 if (event->count == 1) {
822 #if ENABLE(TIZEN_DRAG_SUPPORT)
823 if (priv->pageClient->isDragMode())
824 priv->pageClient->setDragMode(false);
826 priv->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
827 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
828 if (priv->pageClient->isTextSelectionMode())
829 priv->pageClient->setIsTextSelectionMode(false);
831 #if ENABLE(TIZEN_ISF_PORT)
832 evas_object_focus_set(smartData->self, true);
834 } else if (event->count == 2)
835 priv->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
837 case EWK_GESTURE_LONG_PRESS:
838 #if ENABLE(TIZEN_DRAG_SUPPORT)
839 if (priv->pageClient->isDragMode())
840 priv->pageClient->setDragMode(false);
842 // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
843 priv->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
845 case EWK_GESTURE_PAN:
846 priv->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
848 case EWK_GESTURE_FLICK:
849 priv->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
851 case EWK_GESTURE_PINCH:
852 priv->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
855 ASSERT_NOT_REACHED();
862 #endif // #if ENABLE(TIZEN_GESTURE)
865 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
867 #if ENABLE(TIZEN_GESTURE)
868 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
870 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
871 if (priv->pageClient->isTextSelectionMode() && priv->pageClient->isTextSelectionHandleDowned())
875 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
876 if (priv->focusRing && !(event->type == EWK_GESTURE_PAN && !priv->exceedTouchMoveThreshold))
877 priv->focusRing->hide();
880 switch (event->type) {
881 case EWK_GESTURE_PAN:
882 priv->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
884 case EWK_GESTURE_TAP:
885 case EWK_GESTURE_LONG_PRESS:
886 case EWK_GESTURE_FLICK:
888 case EWK_GESTURE_PINCH:
889 if (priv->pageClient->viewportConstraints().userScalable)
890 priv->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
893 ASSERT_NOT_REACHED();
900 #endif // #if ENABLE(TIZEN_GESTURE)
902 #endif //#if OS(TIZEN)
905 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
907 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
908 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
909 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
910 smartData->api->focus_in(smartData);
913 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
915 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
916 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
917 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
918 smartData->api->focus_out(smartData);
921 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
923 Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
924 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
925 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
926 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
927 smartData->api->mouse_wheel(smartData, wheelEvent);
930 static void _ewk_view_on_mouse_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
932 Evas_Event_Mouse_Down* downEvent = static_cast<Evas_Event_Mouse_Down*>(eventInfo);
933 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
934 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
935 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_down);
936 smartData->api->mouse_down(smartData, downEvent);
939 static void _ewk_view_on_mouse_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
941 Evas_Event_Mouse_Up* upEvent = static_cast<Evas_Event_Mouse_Up*>(eventInfo);
942 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
943 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
944 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_up);
945 smartData->api->mouse_up(smartData, upEvent);
948 static void _ewk_view_on_mouse_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
950 Evas_Event_Mouse_Move* moveEvent = static_cast<Evas_Event_Mouse_Move*>(eventInfo);
951 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
952 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
953 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_move);
954 smartData->api->mouse_move(smartData, moveEvent);
957 static void _ewk_view_on_key_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
959 Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
960 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
961 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
962 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
963 smartData->api->key_down(smartData, downEvent);
966 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
968 Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
969 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
970 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
971 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
972 smartData->api->key_up(smartData, upEvent);
975 #if ENABLE(TOUCH_EVENTS)
976 static inline void _ewk_view_feed_touch_event_using_touch_point_list_of_evas(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
978 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
980 unsigned count = evas_touch_point_list_count(smartData->base.evas);
984 Eina_List* points = 0;
985 for (unsigned i = 0; i < count; ++i) {
986 Ewk_Touch_Point* point = new Ewk_Touch_Point;
987 point->id = evas_touch_point_list_nth_id_get(smartData->base.evas, i);
988 evas_touch_point_list_nth_xy_get(smartData->base.evas, i, &point->x, &point->y);
989 point->state = evas_touch_point_list_nth_state_get(smartData->base.evas, i);
990 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_GESTURE)
991 if (type == EWK_TOUCH_CANCEL)
992 point->state = EVAS_TOUCH_POINT_CANCEL;
994 points = eina_list_append(points, point);
997 ewk_view_feed_touch_event(ewkView, type, points, evas_key_modifier_get(smartData->base.evas));
1000 EINA_LIST_FREE(points, data)
1001 delete static_cast<Ewk_Touch_Point*>(data);
1004 static void _ewk_view_on_touch_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
1006 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_START);
1009 static void _ewk_view_on_touch_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
1011 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_END);
1014 static void _ewk_view_on_touch_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
1016 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_MOVE);
1020 void ewkViewHandleTouchEvent(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
1022 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, type);
1028 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1029 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
1031 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1033 return priv->pageClient->textSelectionDown(IntPoint(x, y), true);
1036 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
1038 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1040 IntPoint point(x, y);
1041 priv->pageClient->textSelectionMove(point, true);
1046 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
1048 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1050 IntPoint point(x, y);
1051 priv->pageClient->textSelectionUp(point, true);
1057 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1058 static void _ewk_view_data_list_del(Eina_List* dataList)
1060 EINA_SAFETY_ON_NULL_RETURN(dataList);
1063 EINA_LIST_FREE(dataList, item)
1064 eina_stringshare_del(static_cast<char*>(item));
1068 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1069 Eina_Bool _ewk_view_smart_formdata_candidate_show(Ewk_View_Smart_Data* smartData, int x, int y, int w, int h)
1071 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1073 priv->pageClient->showFormDataCandidate(IntRect(x, y, w, h));
1078 Eina_Bool _ewk_view_smart_formdata_candidate_hide(Ewk_View_Smart_Data* smartData)
1080 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1082 priv->pageClient->hideFormDataCandidate();
1087 Eina_Bool _ewk_view_smart_formdata_candidate_update_data(Ewk_View_Smart_Data* smartData, Eina_List* dataList)
1089 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1091 Vector<String> formData;
1094 EINA_LIST_FOREACH(dataList, list, data)
1095 formData.append(String::fromUTF8(static_cast<char*>(data)));
1097 priv->pageClient->updateFormDataCandidate(formData);
1102 Eina_Bool _ewk_view_smart_formdata_candidate_is_showing(Ewk_View_Smart_Data* smartData)
1104 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1106 return priv->pageClient->isShowingFormDataCandidate();
1110 #if ENABLE(TIZEN_SCREEN_READER)
1111 Eina_Bool _ewk_view_screen_reader_command_execute(Ewk_View_Smart_Data* smartData, unsigned int command, int data1, int data2)
1113 return ScreenReaderProxy::screenReader().executeCommand(smartData->self, command, data1, data2);
1116 #endif // #if OS(TIZEN)
1118 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
1120 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1121 static uint64_t generatePageGroupIdentifierID()
1123 static uint64_t uniquePageGroupIdentifierID = 1;
1124 return uniquePageGroupIdentifierID++;
1128 static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
1130 Ewk_View_Private_Data* priv = new Ewk_View_Private_Data;
1131 memset(priv, 0, sizeof(Ewk_View_Private_Data)); // FIXME : below code should be considered to move to constructor.
1133 priv->areMouseEventsEnabled = false;
1135 priv->javascriptPopup = adoptPtr<JavaScriptPopup>(new JavaScriptPopup(smartData->self));
1136 priv->openPanel = adoptPtr<OpenPanel>(new OpenPanel(smartData->self));
1138 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1139 priv->inputPicker = adoptPtr<InputPicker>(new InputPicker(smartData->self));
1140 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1142 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1143 priv->focusRing = FocusRing::create(smartData->self);
1144 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1146 #if ENABLE(TIZEN_GESTURE)
1147 priv->gestureRecognizer = GestureRecognizer::create(smartData->self);
1148 priv->gestureClient = GestureClient::create(smartData->ewkViewImpl);
1149 #endif // #if ENABLE(TIZEN_GESTURE)
1150 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1151 const char* hideScrollbar = getenv("TIZEN_WEBKIT2_TILED_SCROLLBAR_HIDE");
1152 if (hideScrollbar && atoi(hideScrollbar) == 1)
1153 priv->mainFrameScrollbarVisibility = false;
1155 priv->mainFrameScrollbarVisibility = true;
1158 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1162 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1163 String pageGroupIdentifierID = String::number(generatePageGroupIdentifierID());
1164 String pageGroupIdentifier = String::format("PageGroup%s", pageGroupIdentifierID.utf8().data());
1166 WKRetainPtr<WKStringRef> pageGroupIdentifierRef(AdoptWK, WKStringCreateWithUTF8CString(pageGroupIdentifier.utf8().data()));
1167 priv->pageGroup = WebPageGroup::create(toWTFString(pageGroupIdentifierRef.get()));
1170 priv->suspendRequested = false;
1171 priv->suspendedPainting = false;
1172 priv->suspendedResources = false;
1173 #endif // #if OS(TIZEN)
1176 priv->isUsingEcoreX = WebCore::isUsingEcoreX(smartData->base.evas);
1182 static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap)
1184 // Clear the loadingResources HashMap.
1185 LoadingResourcesMap::iterator it = loadingResourcesMap.begin();
1186 LoadingResourcesMap::iterator end = loadingResourcesMap.end();
1187 for ( ; it != end; ++it)
1188 ewk_web_resource_unref(it->second);
1190 loadingResourcesMap.clear();
1193 static void _ewk_view_priv_del(Ewk_View_Private_Data* priv)
1199 if (priv->javascriptGlobalContext)
1200 JSGlobalContextRelease(priv->javascriptGlobalContext);
1202 eina_stringshare_del(priv->userAgent);
1203 eina_stringshare_del(priv->encoding);
1204 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1205 eina_stringshare_del(priv->webAppIconURL);
1206 if (priv->webAppIconURLs) {
1208 EINA_LIST_FREE(priv->webAppIconURLs, data)
1209 ewkWebAppIconDataDelete(static_cast<Ewk_Web_App_Icon_Data*>(data));
1213 if (priv->authChallenge)
1214 ewkAuthChallengeDelete(priv->authChallenge);
1215 if (priv->policyDecision)
1216 ewkPolicyDecisionDelete(priv->policyDecision);
1218 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1219 if (priv->certificatePolicyDecision)
1220 ewkCertificatePolicyDecisionDelete(priv->certificatePolicyDecision);
1223 #if ENABLE(TIZEN_MEDIA_STREAM)
1224 if (priv->userMediaPermissionRequests)
1225 ewkUserMediaDeletePermissionRequestList(priv->userMediaPermissionRequests);
1228 priv->openPanelListener = 0;
1229 priv->openPanel = nullptr;
1230 priv->javascriptPopup = nullptr;
1231 priv->alertContext = nullptr;
1232 priv->confirmContext = nullptr;
1233 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1234 priv->beforeUnloadConfirmPanelContext = nullptr;
1236 priv->promptContext = nullptr;
1237 priv->isWaitingForJavaScriptPopupReply = false;
1238 priv->openpanelContext = nullptr;
1239 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1240 priv->inputPicker = nullptr;
1241 eina_stringshare_del(priv->inputValue);
1244 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1245 if (priv->dataList) {
1246 _ewk_view_data_list_del(priv->dataList);
1251 #if ENABLE(TIZEN_GEOLOCATION)
1252 if (priv->geolocation)
1253 ewkGeolocationDeleteGeolocation(priv->geolocation);
1254 if (priv->geolocationPermissionRequests)
1255 ewkGeolocationDeletePermissionRequestList(priv->geolocationPermissionRequests);
1258 #if ENABLE(TIZEN_NOTIFICATIONS)
1259 if (priv->notifications)
1260 ewkNotificationDeleteNotificationList(priv->notifications);
1261 if (priv->notificationPermissionRequests)
1262 ewkNotificationDeletePermissionRequestList(priv->notificationPermissionRequests);
1264 #if ENABLE(TIZEN_SQL_DATABASE)
1265 if (priv->exceededDatabaseQuota)
1266 ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
1268 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1269 priv->focusRing = nullptr;
1270 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1271 #if ENABLE(TIZEN_GESTURE)
1272 priv->gestureRecognizer = nullptr;
1273 priv->gestureClient = nullptr;
1274 #endif // #if ENABLE(TIZEN_GESTURE)
1276 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1277 eina_stringshare_del(priv->selectedText);
1279 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1280 priv->pageGroup = nullptr;
1283 #if ENABLE(TIZEN_ISF_PORT)
1284 _ewk_view_imf_context_destroy(priv);
1287 #if ENABLE(TIZEN_APPLICATION_CACHE)
1288 if (priv->applicationCachePermissionOrigin)
1289 deleteSecurityOrigin(priv->applicationCachePermissionOrigin);
1290 priv->isWaitingForApplicationCachePermission = false;
1291 priv->applicationCachePermissionContext = nullptr;
1293 #endif // #if OS(TIZEN)
1298 static void _ewk_view_smart_add(Evas_Object* ewkView)
1300 const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
1301 const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
1302 const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
1303 EWK_VIEW_SD_GET(ewkView, smartData);
1306 smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
1308 EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
1311 evas_object_smart_data_set(ewkView, smartData);
1314 smartData->self = ewkView;
1315 smartData->api = api;
1317 g_parentSmartClass.add(ewkView);
1319 // FIXME: Ewk_View_Private_Data was replaced with EwkViewImpl in the webkit opensource.
1320 // So, we have both Ewk_View_Private_Data and EwkViewImpl now,
1321 // but Ewk_View_Private_Data should be removed later.
1322 smartData->ewkViewImpl = new EwkViewImpl(ewkView);
1323 smartData->priv = _ewk_view_priv_new(smartData);
1325 // Create evas_object_image to draw web contents.
1326 smartData->image = evas_object_image_add(smartData->base.evas);
1327 evas_object_image_alpha_set(smartData->image, false);
1328 evas_object_image_filled_set(smartData->image, true);
1329 evas_object_smart_member_add(smartData->image, ewkView);
1332 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1333 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
1334 const char *engine = ecore_evas_engine_name_get(ee);
1335 if (engine && !strcmp(engine, "opengl_x11"))
1336 evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
1338 ewk_view_mouse_events_enabled_set(ewkView, false);
1339 ewk_view_touch_events_enabled_set(ewkView, true);
1341 // FIXME: This code should be removed if side effect occur.
1342 // WebView does not have focus after url loading.
1343 // If focus is set as true to webview,
1344 // elementary steal webview's focus during mouse up event
1345 // So, added code that events are not propagated to smart parent according to guide from EFL
1346 evas_object_propagate_events_set(ewkView, false);
1348 #if ENABLE(TIZEN_SCREEN_READER)
1349 ScreenReaderProxy::screenReader().addView(ewkView);
1351 #endif // #if OS(TIZEN)
1353 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
1354 CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
1355 CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
1356 CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
1358 CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
1359 CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
1360 CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
1362 CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
1363 CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
1367 static void _ewk_view_smart_del(Evas_Object* ewkView)
1369 EWK_VIEW_SD_GET(ewkView, smartData);
1370 #if ENABLE(TIZEN_SCREEN_READER)
1371 ScreenReaderProxy::screenReader().removeView(ewkView);
1373 if (smartData && smartData->priv) {
1374 _ewk_view_priv_del(smartData->priv);
1375 smartData->priv = 0;
1378 // FIXME: Ewk_View_Private_Data was replaced with EwkViewImpl in the webkit opensource.
1379 // If then, ewkViewImpl will be changed to priv.
1381 delete smartData->ewkViewImpl;
1383 g_parentSmartClass.del(ewkView);
1386 static Eina_Bool _ewk_view_composite(void* data);
1388 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
1390 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1392 evas_object_resize(smartData->image, width, height);
1393 evas_object_image_size_set(smartData->image, width, height);
1394 evas_object_image_fill_set(smartData->image, 0, 0, width, height);
1396 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1397 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1398 evas_object_image_native_surface_set(smartData->image, 0);
1400 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1401 if (!ewk_view_is_opengl_backend(ewkView))
1402 _ewk_view_composite(smartData);
1403 else // OpenGL backend
1405 priv->pageClient->displayViewport();
1407 #endif // #if OS(TIZEN)
1409 smartData->changed.size = true;
1410 _ewk_view_smart_changed(smartData);
1413 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
1415 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1417 smartData->changed.position = true;
1418 _ewk_view_smart_changed(smartData);
1421 IntSize ewk_view_size_get(const Evas_Object* ewkView)
1424 evas_object_geometry_get(ewkView, 0, 0, &width, &height);
1425 return IntSize(width, height);
1428 #if USE(ACCELERATED_COMPOSITING)
1429 static bool ewk_view_create_gl_surface(const Evas_Object* ewkView, const IntSize& viewSize)
1431 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1432 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1434 Evas_GL_Config evasGlConfig = {
1436 EVAS_GL_DEPTH_BIT_8,
1437 EVAS_GL_STENCIL_NONE,
1438 EVAS_GL_OPTIONS_NONE,
1439 EVAS_GL_MULTISAMPLE_NONE
1442 ASSERT(!priv->evasGlSurface);
1443 priv->evasGlSurface = evas_gl_surface_create(priv->evasGl, &evasGlConfig, viewSize.width(), viewSize.height());
1444 if (!priv->evasGlSurface)
1447 Evas_Native_Surface nativeSurface;
1448 evas_gl_native_surface_get(priv->evasGl, priv->evasGlSurface, &nativeSurface);
1449 evas_object_image_native_surface_set(smartData->image, &nativeSurface);
1454 bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView)
1456 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1457 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1459 EINA_SAFETY_ON_TRUE_RETURN_VAL(!!priv->evasGl, false);
1461 Evas* evas = evas_object_evas_get(ewkView);
1462 priv->evasGl = evas_gl_new(evas);
1466 priv->evasGlContext = evas_gl_context_create(priv->evasGl, 0);
1467 if (!priv->evasGlContext) {
1468 evas_gl_free(priv->evasGl);
1473 if (!ewk_view_create_gl_surface(ewkView, ewk_view_size_get(ewkView))) {
1474 evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
1475 priv->evasGlContext = 0;
1477 evas_gl_free(priv->evasGl);
1485 bool ewk_view_accelerated_compositing_mode_exit(const Evas_Object* ewkView)
1487 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1488 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1490 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->evasGl, false);
1492 if (priv->evasGlSurface) {
1493 evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
1494 priv->evasGlSurface = 0;
1497 if (priv->evasGlContext) {
1498 evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
1499 priv->evasGlContext = 0;
1502 evas_gl_free(priv->evasGl);
1509 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
1511 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1512 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1513 Evas_Coord x, y, width, height;
1515 smartData->changed.any = false;
1517 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
1519 if (smartData->changed.size) {
1521 if (priv->pageClient->page()->drawingArea())
1522 priv->pageClient->page()->drawingArea()->setSize(IntSize(width, height), IntSize());
1524 #if USE(ACCELERATED_COMPOSITING)
1525 if (!priv->evasGlSurface)
1527 evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
1528 priv->evasGlSurface = 0;
1529 ewk_view_create_gl_surface(ewkView, IntSize(width, height));
1530 ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
1532 #endif // #if !OS(TIZEN)
1534 smartData->view.w = width;
1535 smartData->view.h = height;
1536 smartData->changed.size = false;
1539 if (priv->pageClient) {
1540 if (DrawingAreaProxy* drawingArea = priv->pageClient->page()->drawingArea()) {
1541 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1542 if (priv->pageClient->page()->isViewVisible())
1543 drawingArea->setSize(IntSize(width, height), IntSize());
1545 drawingArea->setSize(IntSize(width, height), IntSize());
1547 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1548 priv->pageClient->updateViewportSize(IntSize(width, height));
1549 if (ewk_view_is_opengl_backend(ewkView))
1550 priv->pageClient->displayViewport();
1553 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1554 priv->pageClient->frameRectChanged();
1557 #endif // #if OS(TIZEN)
1560 if (smartData->changed.position) {
1561 evas_object_move(smartData->image, x, y);
1562 smartData->view.x = x;
1563 smartData->view.y = y;
1564 smartData->changed.position = false;
1566 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1567 priv->pageClient->frameRectChanged();
1569 #if ENABLE(TIZEN_SCREEN_READER)
1570 priv->pageClient->page()->recalcScreenReaderFocusRect();
1572 #endif // #if OS(TIZEN)
1575 if (priv->popupPicker)
1576 ewk_popup_picker_resize(priv->popupPicker);
1577 #endif // #if OS(TIZEN)
1580 static void _ewk_view_smart_show(Evas_Object* ewkView)
1582 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1583 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1585 if (evas_object_clipees_get(smartData->base.clipper))
1586 evas_object_show(smartData->base.clipper);
1587 evas_object_show(smartData->image);
1590 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1592 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1594 evas_object_hide(smartData->base.clipper);
1595 evas_object_hide(smartData->image);
1596 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1597 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1598 if (priv->pageClient->isTextSelectionMode())
1599 priv->pageClient->setIsTextSelectionMode(false);
1603 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1605 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1606 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1610 else if (alpha > 255)
1613 #define CHECK_COLOR(color, alpha) \
1616 else if (color > alpha) \
1618 CHECK_COLOR(red, alpha);
1619 CHECK_COLOR(green, alpha);
1620 CHECK_COLOR(blue, alpha);
1623 evas_object_image_alpha_set(smartData->image, alpha < 255);
1624 priv->pageClient->page()->setDrawsBackground(red || green || blue);
1625 priv->pageClient->page()->setDrawsTransparentBackground(alpha < 255);
1626 priv->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1629 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1633 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1635 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1637 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1638 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1639 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1643 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1644 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1646 evas_object_smart_clipped_smart_set(&api->sc);
1648 // Set Evas_Smart_Class functions.
1649 api->sc.add = _ewk_view_smart_add;
1650 api->sc.del = _ewk_view_smart_del;
1651 api->sc.move = _ewk_view_smart_move;
1652 api->sc.resize = _ewk_view_smart_resize;
1653 api->sc.show = _ewk_view_smart_show;
1654 api->sc.hide = _ewk_view_smart_hide;
1655 api->sc.color_set = _ewk_view_smart_color_set;
1656 api->sc.calculate = _ewk_view_smart_calculate;
1657 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1659 // Set Ewk_View_Smart_Class functions.
1660 api->focus_in = _ewk_view_smart_focus_in;
1661 api->focus_out = _ewk_view_smart_focus_out;
1662 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1663 api->mouse_down = _ewk_view_smart_mouse_down;
1664 api->mouse_up = _ewk_view_smart_mouse_up;
1665 api->mouse_move = _ewk_view_smart_mouse_move;
1666 api->key_down = _ewk_view_smart_key_down;
1667 api->key_up = _ewk_view_smart_key_up;
1669 api->gesture_start = _ewk_view_smart_gesture_start;
1670 api->gesture_end = _ewk_view_smart_gesture_end;
1671 api->gesture_move = _ewk_view_smart_gesture_move;
1673 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1674 api->popup_menu_show = _ewk_view_popup_menu_show;
1675 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1676 api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1678 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1679 api->popup_menu_update = _ewk_view_popup_menu_update;
1681 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1682 api->text_selection_down = _ewk_view_text_selection_down;
1683 api->text_selection_move = _ewk_view_text_selection_move;
1684 api->text_selection_up = _ewk_view_text_selection_up;
1686 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1687 api->input_picker_show = _ewk_view_input_picker_show;
1689 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1690 api->data_list_show = _ewk_view_data_list_show;
1691 api->data_list_hide = _ewk_view_data_list_hide;
1693 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1694 api->orientation_lock = _ewk_orientation_lock;
1695 api->orientation_unlock = _ewk_orientation_unlock;
1697 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1698 api->input_picker_color_request = _ewk_input_picker_color_request;
1699 api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1701 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1702 api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1703 api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1704 api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1705 api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1707 #if ENABLE(TIZEN_SCREEN_READER)
1708 api->screen_reader_command_execute = _ewk_view_screen_reader_command_execute;
1710 #endif //#if OS(TIZEN)
1715 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1717 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1718 static Evas_Smart* smart = 0;
1720 if (EINA_UNLIKELY(!smart)) {
1721 ewk_view_smart_class_set(&api);
1722 smart = evas_smart_class_new(&api.sc);
1728 static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKPageGroupRef pageGroupRef)
1730 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1731 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
1732 EINA_SAFETY_ON_NULL_RETURN(context);
1734 if (priv->pageClient)
1737 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1738 if (ewk_view_is_opengl_backend(ewkView)) {
1739 priv->pageClient = PageClientEvasGL::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1740 priv->pageClient->page()->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1743 priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1744 priv->pageClient->page()->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1745 priv->pageClient->page()->pageGroup()->preferences()->setWebGLEnabled(false);
1746 priv->pageClient->page()->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1749 priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1751 // FixMe: Comment should be removed when pageClient is removed.
1752 //priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageProxy.get())))));
1753 priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageClient->page())))));
1756 priv->context = context;
1758 ewkViewContextMenuClientAttachClient(ewkView);
1759 ewkViewFindClientAttatchClient(ewkView);
1760 ewkViewTizenClientAttachClient(ewkView);
1761 ewkViewUIClientAttatchClient(ewkView);
1763 #if ENABLE(TIZEN_GEOLOCATION)
1764 ewkViewGeolocationProviderAttachProvider(ewkView, ewk_context_WKContext_get(context));
1767 #if ENABLE(TIZEN_NOTIFICATIONS)
1768 ewkViewNotificationProviderAttachProvider(ewkView, ewk_context_WKContext_get(context));
1771 #if ENABLE(TIZEN_ICON_DATABASE)
1772 ewk_view_icondatabase_client_attach(ewkView, ewk_context_WKContext_get(context));
1775 ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1776 ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1777 ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1778 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1779 ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1781 ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1782 #else // #if OS(TIZEN)
1783 priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageClient->page()->backForwardList()));
1785 #if USE(COORDINATED_GRAPHICS)
1786 priv->viewportHandler = EflViewportHandler::create(priv->pageClient.get());
1788 #endif // #if OS(TIZEN)
1790 WKPageRef wkPage = toAPI(priv->pageClient->page());
1791 ewk_view_form_client_attach(wkPage, ewkView);
1792 ewk_view_loader_client_attach(wkPage, ewkView);
1793 ewk_view_policy_client_attach(wkPage, ewkView);
1794 ewk_view_resource_load_client_attach(wkPage, ewkView);
1796 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1797 ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1800 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1801 if (!ewk_context_x_window_get(context))
1802 ewk_context_x_window_set(context, elm_win_xwindow_get(ewkView));
1806 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1808 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1809 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1811 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1812 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1813 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1818 Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1822 EWK_VIEW_SD_GET(ewkView, smartData);
1824 evas_object_del(ewkView);
1828 EWK_VIEW_PRIV_GET(smartData, priv);
1830 evas_object_del(ewkView);
1839 * Constructs a ewk_view Evas_Object with WKType parameters.
1841 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1843 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1844 EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1846 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1850 _ewk_view_initialize(ewkView, ewk_context_new_from_WKContext(contextRef), pageGroupRef);
1855 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1857 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1858 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1859 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1861 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1865 #if ENABLE(TIZEN_ICON_DATABASE)
1866 //set default iconDatabasePath
1867 WKContextRef contextRef = ewk_context_WKContext_get(context);
1868 toImpl(contextRef)->setIconDatabasePath(toImpl(contextRef)->iconDatabasePath());
1871 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1872 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1873 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1874 _ewk_view_initialize(ewkView, context, toAPI(priv->pageGroup.get()));
1876 _ewk_view_initialize(ewkView, context, 0);
1882 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1884 return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1887 Evas_Object* ewk_view_add(Evas* canvas)
1889 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1894 * The uri of view was changed by the frame loader.
1896 * Emits signal: "uri,changed" with pointer to new uri string.
1898 void ewk_view_uri_update(Evas_Object* ewkView)
1900 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1901 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1903 String activeURL = priv->pageClient->page()->activeURL();
1904 if (activeURL.isEmpty())
1907 if (!eina_stringshare_replace(&priv->uri, activeURL.utf8().data()))
1910 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1911 evas_object_smart_callback_call(ewkView, "url,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1914 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* uri)
1916 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1917 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1918 EINA_SAFETY_ON_NULL_RETURN_VAL(uri, false);
1920 priv->pageClient->page()->loadURL(String::fromUTF8(uri));
1921 ewk_view_uri_update(ewkView);
1926 const char* ewk_view_url_get(const Evas_Object* ewkView)
1928 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1929 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1934 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1936 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1937 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1939 priv->pageClient->page()->reload(/*reloadFromOrigin*/ false);
1940 ewk_view_uri_update(ewkView);
1945 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1947 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1948 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1950 priv->pageClient->page()->reload(/*reloadFromOrigin*/ true);
1951 ewk_view_uri_update(ewkView);
1956 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1958 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1959 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1961 priv->pageClient->page()->stopLoading();
1966 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1968 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1969 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1971 return priv->settings.get();
1976 * Load was initiated for a resource in the view.
1978 * Emits signal: "resource,request,new" with pointer to resource request.
1980 void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request)
1982 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1983 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1985 Ewk_Web_Resource_Request resourceRequest = {resource, request, 0};
1987 // Keep the resource internally to reuse it later.
1988 ewk_web_resource_ref(resource);
1989 priv->loadingResourcesMap.add(resourceIdentifier, resource);
1991 evas_object_smart_callback_call(ewkView, "resource,request,new", &resourceRequest);
1996 * Received a response to a resource load request in the view.
1998 * Emits signal: "resource,request,response" with pointer to resource response.
2000 void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response)
2002 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2003 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2005 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2008 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
2009 Ewk_Web_Resource_Load_Response resourceLoadResponse = {resource, response};
2010 evas_object_smart_callback_call(ewkView, "resource,request,response", &resourceLoadResponse);
2015 * Failed loading a resource in the view.
2017 * Emits signal: "resource,request,finished" with pointer to the resource load error.
2019 void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Error* error)
2021 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2022 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2024 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2027 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
2028 Ewk_Web_Resource_Load_Error resourceLoadError = {resource, error};
2029 evas_object_smart_callback_call(ewkView, "resource,request,failed", &resourceLoadError);
2034 * Finished loading a resource in the view.
2036 * Emits signal: "resource,request,finished" with pointer to the resource.
2038 void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIdentifier)
2040 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2041 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2043 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2046 Ewk_Web_Resource* resource = priv->loadingResourcesMap.take(resourceIdentifier);
2047 evas_object_smart_callback_call(ewkView, "resource,request,finished", resource);
2049 ewk_web_resource_unref(resource);
2054 * Request was sent for a resource in the view.
2056 * Emits signal: "resource,request,sent" with pointer to resource request and possible redirect response.
2058 void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse)
2060 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2061 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2063 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2066 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
2067 Ewk_Web_Resource_Request resourceRequest = {resource, request, redirectResponse};
2069 evas_object_smart_callback_call(ewkView, "resource,request,sent", &resourceRequest);
2072 const char* ewk_view_title_get(const Evas_Object* ewkView)
2074 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2075 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2077 CString title = priv->pageClient->page()->pageTitle().utf8();
2078 eina_stringshare_replace(&priv->title, title.data());
2085 * Reports that the requested text was found.
2087 * Emits signal: "text,found" with the number of matches.
2089 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
2091 evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
2096 * The view title was changed by the frame loader.
2098 * Emits signal: "title,changed" with pointer to new title string.
2100 void ewk_view_title_changed(Evas_Object* ewkView, const char* title)
2102 evas_object_smart_callback_call(ewkView, "title,changed", const_cast<char*>(title));
2105 double ewk_view_load_progress_get(const Evas_Object* ewkView)
2107 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2108 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2110 return priv->pageClient->page()->estimatedProgress();
2113 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
2115 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2116 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2122 scaleFactor = priv->pageClient->adjustScaleWithViewport(scaleFactor);
2124 IntPoint scrollPosition = priv->pageClient->scrollPosition();
2125 double scaleDifference = scaleFactor / priv->pageClient->scaleFactor();
2126 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
2127 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
2129 priv->pageClient->page()->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
2131 priv->pageClient->page()->scalePage(scaleFactor, IntPoint(x, y));
2136 double ewk_view_scale_get(const Evas_Object* ewkView)
2138 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
2139 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1);
2142 return priv->pageClient->page()->scaleFactor();
2144 return priv->pageClient->page()->pageScaleFactor();
2148 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
2150 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2151 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2153 priv->pageClient->page()->setCustomDeviceScaleFactor(ratio);
2158 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
2160 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2161 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2163 return priv->pageClient->page()->deviceScaleFactor();
2166 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
2167 void ewk_view_load_progress_started(Evas_Object* ewkView)
2169 evas_object_smart_callback_call(ewkView, "load,progress,started", 0);
2175 * Reports load progress changed.
2177 * Emits signal: "load,progress" with pointer to a double from 0.0 to 1.0.
2179 void ewk_view_load_progress_changed(Evas_Object* ewkView, double progress)
2181 evas_object_smart_callback_call(ewkView, "load,progress", &progress);
2184 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
2185 void ewk_view_load_progress_finished(Evas_Object* ewkView)
2187 evas_object_smart_callback_call(ewkView, "load,progress,finished", 0);
2191 #if ENABLE(WEB_INTENTS)
2194 * The view received a new intent request.
2196 * Emits signal: "intent,request,new" with pointer to a Ewk_Intent.
2198 void ewk_view_intent_request_new(Evas_Object* ewkView, const Ewk_Intent* ewkIntent)
2200 evas_object_smart_callback_call(ewkView, "intent,request,new", const_cast<Ewk_Intent*>(ewkIntent));
2204 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
2206 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2207 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2209 if (!eina_stringshare_replace(&priv->theme, path))
2212 priv->pageClient->page()->setThemePath(path);
2215 const char* ewk_view_theme_get(const Evas_Object* ewkView)
2217 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2218 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2223 void ewk_view_cursor_set(Evas_Object* ewkView, const Cursor& cursor)
2225 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2226 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2228 const char* group = cursor.platformCursor();
2229 if (!group || group == priv->cursorGroup)
2232 priv->cursorGroup = group;
2234 if (priv->cursorObject)
2235 evas_object_del(priv->cursorObject);
2236 priv->cursorObject = edje_object_add(smartData->base.evas);
2238 Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
2239 if (!priv->theme || !edje_object_file_set(priv->cursorObject, priv->theme, group)) {
2240 evas_object_del(priv->cursorObject);
2241 priv->cursorObject = 0;
2243 ecore_evas_object_cursor_set(ecoreEvas, 0, 0, 0, 0);
2245 if (priv->isUsingEcoreX)
2246 WebCore::applyFallbackCursor(ecoreEvas, group);
2251 Evas_Coord width, height;
2252 edje_object_size_min_get(priv->cursorObject, &width, &height);
2253 if (width <= 0 || height <= 0)
2254 edje_object_size_min_calc(priv->cursorObject, &width, &height);
2255 if (width <= 0 || height <= 0) {
2256 width = defaultCursorSize;
2257 height = defaultCursorSize;
2259 evas_object_resize(priv->cursorObject, width, height);
2263 data = edje_object_data_get(priv->cursorObject, "hot.x");
2265 hotspotX = atoi(data);
2268 data = edje_object_data_get(priv->cursorObject, "hot.y");
2270 hotspotY = atoi(data);
2272 ecore_evas_object_cursor_set(ecoreEvas, priv->cursorObject, EVAS_LAYER_MAX, hotspotX, hotspotY);
2275 void ewk_view_display(Evas_Object* ewkView, const IntRect& rect)
2277 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2278 if (!smartData->image)
2281 evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height());
2286 * A download for that view was cancelled.
2288 * Emits signal: "download,cancelled" with pointer to a Ewk_Download_Job.
2290 void ewk_view_download_job_cancelled(Evas_Object* ewkView, Ewk_Download_Job* download)
2292 evas_object_smart_callback_call(ewkView, "download,cancelled", download);
2297 * A new download has been requested for that view.
2299 * Emits signal: "download,request" with pointer to a Ewk_Download_Job.
2301 void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job* download)
2303 evas_object_smart_callback_call(ewkView, "download,request", download);
2308 * A download for that view has failed.
2310 * Emits signal: "download,failed" with pointer to a Ewk_Download_Job_Error.
2312 void ewk_view_download_job_failed(Evas_Object* ewkView, Ewk_Download_Job* download, Ewk_Web_Error* error)
2314 Ewk_Download_Job_Error downloadError = { download, error };
2315 evas_object_smart_callback_call(ewkView, "download,failed", &downloadError);
2320 * A download for that view finished successfully.
2322 * Emits signal: "download,finished" with pointer to a Ewk_Download_Job.
2324 void ewk_view_download_job_finished(Evas_Object* ewkView, Ewk_Download_Job* download)
2326 evas_object_smart_callback_call(ewkView, "download,finished", download);
2329 Eina_Bool ewk_view_back(Evas_Object* ewkView)
2331 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2332 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2334 WebPageProxy* page = priv->pageClient->page();
2335 if (page->canGoBack()) {
2343 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
2345 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2346 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2348 WebPageProxy* page = priv->pageClient->page();
2349 if (page->canGoForward()) {
2357 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
2359 #if ENABLE(WEB_INTENTS)
2360 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2361 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2362 EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
2364 WebPageProxy* page = priv->pageClient->page();
2365 page->deliverIntentToFrame(page->mainFrame(), toImpl(ewk_intent_WKIntentDataRef_get(intent)));
2373 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
2375 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2376 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2378 return priv->pageClient->page()->canGoBack();
2381 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
2383 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2384 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2386 return priv->pageClient->page()->canGoForward();
2389 void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size)
2391 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2392 if (!imageData || !smartData->image)
2395 evas_object_resize(smartData->image, size.width(), size.height());
2396 evas_object_image_size_set(smartData->image, size.width(), size.height());
2397 evas_object_image_data_copy_set(smartData->image, imageData);
2402 * Reports that a form request is about to be submitted.
2404 * Emits signal: "form,submission,request" with pointer to Ewk_Form_Submission_Request.
2406 void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submission_Request* request)
2408 evas_object_smart_callback_call(ewkView, "form,submission,request", request);
2411 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2412 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
2414 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2415 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2417 if (!ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
2420 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(ewkView);
2421 if (!imfContext || ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
2424 if (value.isEmpty()) {
2425 if(smartData->api->formdata_candidate_is_showing(smartData))
2426 smartData->api->formdata_candidate_hide(smartData);
2430 Vector<String> popupCandidates;
2431 ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
2432 std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
2434 Eina_List* candidateList = 0;
2435 for (size_t i = 0; i < popupCandidates.size(); ++i) {
2436 if (popupCandidates[i].startsWith(value, false))
2437 candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
2440 if (!eina_list_count(candidateList)) {
2441 if(smartData->api->formdata_candidate_is_showing(smartData))
2442 smartData->api->formdata_candidate_hide(smartData);
2446 smartData->api->formdata_candidate_update_data(smartData, candidateList);
2448 if (!smartData->api->formdata_candidate_is_showing(smartData))
2449 smartData->api->formdata_candidate_hide(smartData);
2451 IntRect inputFieldRect = priv->pageClient->focusedNodeRect();
2452 smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
2455 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm)
2457 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2458 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2459 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
2460 && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
2462 ewk_context_form_data_add(ewk_view_context_get(ewkView), priv->uri, formData, isPasswordForm);
2465 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
2467 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2468 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2470 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
2473 Vector<std::pair<String, String> > passwordFormData;
2474 ewk_context_form_password_data_get(ewk_view_context_get(ewkView), priv->uri, passwordFormData);
2476 if (!passwordFormData.size())
2479 String passwordFormAutofill = "try { function passwordFormAutofill() { var inputFields;";
2480 for (size_t i = 0; i < passwordFormData.size(); i++) {
2481 passwordFormAutofill += String::format(" inputFields = document.getElementsByName(\"%s\");"
2482 " for (var i = 0; i < inputFields.length; i++)"
2483 " if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\"))"
2484 " inputFields[i].value = \"%s\";",
2485 passwordFormData[i].first.utf8().data(), passwordFormData[i].second.utf8().data());
2487 passwordFormAutofill += "} passwordFormAutofill(); } catch(e) { }";
2488 ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
2491 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
2493 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2494 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2495 ewk_context_form_candidate_data_get(ewk_view_context_get(ewkView), name, candidates);
2501 * Reports load failed with error information.
2503 * Emits signal: "load,error" with pointer to Ewk_Web_Error.
2505 void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error)
2507 evas_object_smart_callback_call(ewkView, "load,error", const_cast<Ewk_Web_Error*>(error));
2512 * Reports load finished.
2514 * Emits signal: "load,finished".
2516 void ewk_view_load_finished(Evas_Object* ewkView)
2518 ewk_view_uri_update(ewkView);
2519 evas_object_smart_callback_call(ewkView, "load,finished", 0);
2521 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2522 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2524 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
2525 priv->pageClient->page()->setLoadingFinished(true);
2528 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2529 ewk_view_form_password_data_fill(ewkView);
2532 if (!priv->suspendRequested)
2535 priv->suspendRequested = false;
2537 if (!priv->suspendedPainting) {
2538 priv->pageClient->page()->suspendPainting();
2539 priv->suspendedPainting = true;
2541 if (!priv->suspendedResources) {
2542 priv->pageClient->page()->suspendJavaScriptAndResource();
2543 priv->suspendedResources = true;
2549 * Reports view provisional load failed with error information.
2551 * Emits signal: "load,provisional,failed" with pointer to Ewk_Web_Error.
2553 void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Web_Error* error)
2555 evas_object_smart_callback_call(ewkView, "load,provisional,failed", const_cast<Ewk_Web_Error*>(error));
2560 * Reports view received redirect for provisional load.
2562 * Emits signal: "load,provisional,redirect".
2564 void ewk_view_load_provisional_redirect(Evas_Object* ewkView)
2566 ewk_view_uri_update(ewkView);
2567 evas_object_smart_callback_call(ewkView, "load,provisional,redirect", 0);
2572 * Reports view provisional load started.
2574 * Emits signal: "load,provisional,started".
2576 void ewk_view_load_provisional_started(Evas_Object* ewkView)
2579 evas_object_smart_callback_call(ewkView, "load,started", 0);
2582 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2583 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2585 #if ENABLE(TIZEN_DRAG_SUPPORT)
2586 if (priv->pageClient->isDragMode())
2587 priv->pageClient->setDragMode(false);
2590 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
2591 priv->pageClient->page()->setLoadingFinished(false);
2594 // The main frame started provisional load, we should clear
2595 // the loadingResources HashMap to start clean.
2596 _ewk_view_priv_loading_resources_clear(priv->loadingResourcesMap);
2598 ewk_view_uri_update(ewkView);
2599 evas_object_smart_callback_call(ewkView, "load,provisional,started", 0);
2604 * Reports that a navigation policy decision should be taken.
2606 * Emits signal: "policy,decision,navigation".
2608 void ewk_view_navigation_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision)
2610 evas_object_smart_callback_call(ewkView, "policy,decision,navigation", decision);
2615 * Reports that a new window policy decision should be taken.
2617 * Emits signal: "policy,decision,new,window".
2619 void ewk_view_new_window_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision)
2621 evas_object_smart_callback_call(ewkView, "policy,decision,new,window", decision);
2624 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
2626 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2627 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2628 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
2630 if (unreachableUrl && *unreachableUrl)
2631 priv->pageClient->page()->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
2633 priv->pageClient->page()->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
2634 ewk_view_uri_update(ewkView);
2639 #if ENABLE(WEB_INTENTS_TAG)
2642 * The view received a new intent service registration.
2644 * Emits signal: "intent,service,register" with pointer to a Ewk_Intent_Service.
2646 void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Service* ewkIntentService)
2648 evas_object_smart_callback_call(ewkView, "intent,service,register", const_cast<Ewk_Intent_Service*>(ewkIntentService));
2650 #endif // ENABLE(WEB_INTENTS_TAG)
2652 WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView)
2654 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2655 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2657 return priv->pageClient->page();
2660 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
2662 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2663 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2665 String customEncoding = priv->pageClient->page()->customTextEncodingName();
2666 if (customEncoding.isEmpty())
2669 eina_stringshare_replace(&priv->customEncoding, customEncoding.utf8().data());
2671 return priv->customEncoding;
2674 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
2676 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2677 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2679 if (eina_stringshare_replace(&priv->customEncoding, encoding))
2680 priv->pageClient->page()->setCustomTextEncodingName(encoding ? String::fromUTF8(encoding) : String());
2686 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
2688 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2689 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2690 return priv->context;
2693 // FIXME: It should be removed.
2694 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
2696 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2697 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2699 return toAPI(priv->pageClient->page());
2702 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
2704 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2705 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2707 enabled = !!enabled;
2708 if (priv->areMouseEventsEnabled == enabled)
2711 priv->areMouseEventsEnabled = enabled;
2713 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down, smartData);
2714 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up, smartData);
2715 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move, smartData);
2717 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
2718 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
2719 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
2725 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
2727 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2728 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2730 return priv->areMouseEventsEnabled;
2733 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
2735 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2736 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2738 return priv->javascriptPopup->alert(alertText);
2741 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
2743 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2744 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2746 return priv->javascriptPopup->confirm(message);
2749 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
2751 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2752 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2754 return priv->javascriptPopup->prompt(message, defaultValue);
2757 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
2758 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, void* userData)
2760 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2761 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2763 return priv->javascriptPopup->beforeUnloadConfirmPanel(message);
2767 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)
2769 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2770 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2772 return priv->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, priv);
2775 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
2776 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)
2778 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2780 if (priv->popupPicker)
2781 ewk_popup_picker_del(priv->popupPicker);
2783 #if ENABLE(TIZEN_MULTIPLE_SELECT)
2784 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
2786 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
2792 #if ENABLE(TIZEN_MULTIPLE_SELECT)
2793 Eina_Bool _ewk_view_multiple_popup_menu_show(Ewk_View_Smart_Data* smartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* items)
2795 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2797 if (priv->popupPicker)
2798 ewk_popup_picker_del(priv->popupPicker);
2800 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
2806 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
2808 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2810 if (!priv->popupPicker)
2813 ewk_popup_picker_del(priv->popupPicker);
2814 priv->popupPicker = 0;
2819 Eina_Bool _ewk_view_popup_menu_update(Ewk_View_Smart_Data* smartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, Eina_List* items, int selectedIndex)
2821 // FIXME: The rect should be updated if it was changed
2823 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2825 if (!priv->popupPicker)
2828 ewk_popup_picker_update(smartData->self, priv->popupPicker, items, selectedIndex);
2834 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
2835 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
2837 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2839 priv->inputPicker->show(inputType, inputValue);
2844 #if ENABLE(TIZEN_DATALIST_ELEMENT)
2845 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
2847 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2849 priv->inputPicker->showDataList(inputType, optionList);
2853 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
2855 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2857 priv->inputPicker->hideDataList(inputType);
2862 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
2863 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
2865 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2867 priv->inputPicker->showColorPicker(r, g, b, a);
2871 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
2873 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2875 priv->inputPicker->hideColorPicker();
2880 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
2882 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2883 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2885 return priv->pageClient.get();
2888 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
2890 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
2891 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1);
2893 return WKPageGetTextZoomFactor(toAPI(priv->pageClient->page()));
2896 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
2898 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2899 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2901 WKPageSetTextZoomFactor(toAPI(priv->pageClient->page()), textZoomFactor);
2905 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
2906 FocusRing* ewkViewGetFocusRing(Evas_Object* ewkView)
2908 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2909 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2911 return priv->focusRing.get();
2915 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
2917 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2918 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2920 return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(priv->pageClient->page())));
2923 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
2925 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2926 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2928 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(priv->pageClient->page())));
2931 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
2933 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2934 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2936 if (!priv->javascriptGlobalContext)
2937 priv->javascriptGlobalContext = JSGlobalContextCreate(0);
2938 return priv->javascriptGlobalContext;
2941 void ewkViewLoadCommitted(Evas_Object* ewkView)
2943 #if ENABLE(TIZEN_GESTURE)
2944 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2945 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2946 priv->gestureClient->reset();
2948 #if ENABLE(TIZEN_ISF_PORT)
2949 ewk_view_imf_context_hide(ewkView);
2951 ewk_view_uri_update(ewkView);
2952 evas_object_smart_callback_call(ewkView, "load,committed", 0);
2955 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
2957 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2958 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2960 Ewk_Error* ewkError = ewkErrorCreate(error);
2961 ewkErrorLoadErrorPage(ewkError, toAPI(priv->pageClient->page()));
2962 evas_object_smart_callback_call(ewkView, "load,error", ewkError);
2963 ewkErrorDelete(ewkError);
2966 void ewkViewSetTitleAndURL(Evas_Object* ewkView, const char* title, const char* url)
2968 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2969 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2971 if (title && eina_stringshare_replace(&priv->title, title))
2972 evas_object_smart_callback_call(ewkView, "title,changed", static_cast<void*>(const_cast<char*>(priv->title)));
2973 if (url && eina_stringshare_replace(&priv->uri, url))
2974 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
2977 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
2979 #if ENABLE(TIZEN_GESTURE)
2980 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2981 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2982 priv->gestureClient->reset();
2984 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
2987 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
2989 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2990 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2992 if (priv->authChallenge)
2993 ewkAuthChallengeDelete(priv->authChallenge);
2994 priv->authChallenge = authChallenge;
2996 evas_object_smart_callback_call(ewkView, "authentication,challenge", priv->authChallenge);
2999 void ewk_view_process_crashed(Evas_Object* ewkView)
3001 bool handled = false;
3002 evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
3008 #if ENABLE(TIZEN_SQL_DATABASE)
3009 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)
3011 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, currentQuota);
3012 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, currentQuota);
3014 TIZEN_LOGI("database,quota,exceeded");
3015 uint64_t defaultQuota = ewkContextGetDatabaseQuota(priv->context);
3016 if (defaultQuota >= expectedUsage + currentQuota)
3017 return defaultQuota;
3019 if (priv->exceededDatabaseQuota)
3020 ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
3021 priv->exceededDatabaseQuota = ewkContextCreateExceededQuota(origin, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
3022 evas_object_smart_callback_call(ewkView, "database,quota,exceeded", priv->exceededDatabaseQuota);
3024 return ewkContextGetNewQuotaForExceededQuota(priv->context, priv->exceededDatabaseQuota);
3028 #if ENABLE(TIZEN_NOTIFICATIONS)
3029 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
3031 TIZEN_LOGI("notification,cancel");
3032 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
3035 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
3037 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3038 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3040 TIZEN_LOGI("notification,permission,request");
3041 priv->notificationPermissionRequests = eina_list_append(priv->notificationPermissionRequests, notificationPermissionRequest);
3042 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
3045 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
3047 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3048 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3050 TIZEN_LOGI("notification,show");
3051 Eina_List* listIterator=0;
3053 const char* replaceID = ewkNotificationGetReplaceID(notification);
3054 if(strlen(replaceID)) {
3055 EINA_LIST_FOREACH(priv->notifications, listIterator, data) {
3056 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
3057 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
3058 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
3062 priv->notifications = eina_list_append(priv->notifications, notification);
3063 evas_object_smart_callback_call(ewkView, "notification,show", notification);
3066 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
3068 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3069 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3071 priv->notificationPermissionRequests = eina_list_remove(priv->notificationPermissionRequests, ewkNotificationPermissionRequest);
3075 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
3076 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
3078 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3080 TIZEN_LOGI("protocolhandler,registration,requested");
3081 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
3082 evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
3083 ewkCustomHandlersDeleteData(customHandlersData);
3087 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
3088 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
3090 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
3092 TIZEN_LOGI("protocolhandler,isregistered");
3093 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
3094 evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
3096 Ewk_Custom_Handlers_State result;
3097 result = ewkGetCustomHandlersDataResult(customHandlersData);
3098 ewkCustomHandlersDeleteData(customHandlersData);
3103 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
3105 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3107 TIZEN_LOGI("protocolhandler,unregistration,requested");
3108 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
3109 evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
3110 ewkCustomHandlersDeleteData(customHandlersData);
3114 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
3115 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
3117 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3119 TIZEN_LOGI("contenthandler,registration,requested");
3120 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
3121 evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
3122 ewkCustomHandlersDeleteData(customHandlersData);
3125 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
3127 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
3129 TIZEN_LOGI("contenthandler,isregistered");
3130 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
3131 evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
3133 Ewk_Custom_Handlers_State result;
3134 result = ewkGetCustomHandlersDataResult(customHandlersData);
3135 ewkCustomHandlersDeleteData(customHandlersData);
3140 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
3142 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3144 TIZEN_LOGI("contenthandler,unregistration,requested");
3145 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
3146 evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
3147 ewkCustomHandlersDeleteData(customHandlersData);
3151 #if ENABLE(TIZEN_SEARCH_PROVIDER)
3152 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
3154 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3156 TIZEN_LOGI("searchProvider,add");
3157 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
3158 evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
3159 ewkSearchProviderDeleteData(searchProviderData);
3162 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
3164 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3166 TIZEN_LOGI("searchProvider,installed");
3167 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
3168 evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
3169 unsigned long result;
3170 result = ewkGetSearchProviderResult(searchProviderData);
3171 ewkSearchProviderDeleteData(searchProviderData);
3176 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3177 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
3179 TIZEN_LOGI("webapp,metatag,standalone");
3180 bool standalone = true;
3181 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
3186 #if ENABLE(TIZEN_MEDIA_STREAM)
3187 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
3189 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3190 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3192 priv->userMediaPermissionRequests = eina_list_append(priv->userMediaPermissionRequests, userMediaPermission);
3193 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
3196 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
3198 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3199 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3201 priv->userMediaPermissionRequests = eina_list_remove(priv->userMediaPermissionRequests, permission);
3206 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
3207 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
3209 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
3210 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
3211 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
3212 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
3213 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
3214 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
3216 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
3220 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
3221 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
3223 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3224 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3225 if (priv->certificatePolicyDecision)
3226 ewkCertificatePolicyDecisionDelete(priv->certificatePolicyDecision);
3227 priv->certificatePolicyDecision = certificatePolicyDecision;
3229 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
3233 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
3235 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
3238 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
3240 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
3243 void ewkViewClosePage(Evas_Object* ewkView)
3245 evas_object_smart_callback_call(ewkView, "close,window", 0);
3248 #if ENABLE(TIZEN_GEOLOCATION)
3249 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
3251 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3252 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3254 TIZEN_LOGI("geolocation,permission,request");
3255 priv->geolocationPermissionRequests = eina_list_append(priv->geolocationPermissionRequests, geolocationPermissionRequest);
3256 evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
3259 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
3261 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3262 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3264 priv->geolocationPermissionRequests = eina_list_remove(priv->geolocationPermissionRequests, geolocationPermissionRequest);
3267 void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
3269 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3270 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3272 priv->geolocation = geolocation;
3275 Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
3277 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3278 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3280 return priv->geolocation;
3283 bool ewkViewIsValidLocationService(Evas_Object* ewkView)
3285 TIZEN_LOGI("geolocation,valid");
3288 evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
3293 WKPageRef ewkViewCreateNewPage(Evas_Object* ewkView)
3295 Evas_Object* createdEwkView = 0;
3297 evas_object_smart_callback_call(ewkView, "create,window", &createdEwkView);
3299 if (!createdEwkView)
3302 return static_cast<WKPageRef>(WKRetain(toAPI(ewk_view_page_get(createdEwkView))));
3305 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
3307 evas_object_smart_callback_call(ewkView, "form,submit", formData);
3310 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3312 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3313 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3314 if (priv->policyDecision)
3315 ewkPolicyDecisionDelete(priv->policyDecision);
3316 priv->policyDecision = policyDecision;
3318 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", priv->policyDecision);
3321 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3323 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3324 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3325 if (priv->policyDecision)
3326 ewkPolicyDecisionDelete(priv->policyDecision);
3327 priv->policyDecision = policyDecision;
3329 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", priv->policyDecision);
3332 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3334 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3335 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3336 if (priv->policyDecision)
3337 ewkPolicyDecisionDelete(priv->policyDecision);
3338 priv->policyDecision = policyDecision;
3340 evas_object_smart_callback_call(ewkView, "policy,response,decide", priv->policyDecision);
3343 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
3345 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3346 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3348 IntPoint scrollPosition = priv->pageClient->scrollPosition();
3349 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3350 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3351 contentsSize.scale(priv->pageClient->scaleFactor());
3354 // some website's contents size is smaller than view size,
3355 // so we have to adjust contents size to view size for that case.
3356 if (contentsSize.width() < smartData->view.w)
3357 contentsSize.setWidth(smartData->view.w);
3358 if (contentsSize.height() < smartData->view.h)
3359 contentsSize.setHeight(smartData->view.h);
3361 // Call "scroll,down" if webview can be scrolled down.
3362 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
3363 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
3364 // Call "scroll,up" if webview can be scrolled up.
3365 else if (deltaY < 0 && scrollPosition.y() > 0)
3366 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
3368 // Call "scroll,right" if webview can be scrolled down.
3369 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
3370 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
3371 // Call "scroll,left" if webview can be scrolled up.
3372 else if (deltaX < 0 && scrollPosition.x() > 0)
3373 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
3376 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
3378 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3379 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3381 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3382 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3383 contentsSize.scale(priv->pageClient->scaleFactor());
3386 int maxScrollY = contentsSize.height() - smartData->view.h;
3387 if (!priv->isVerticalEdge) {
3388 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
3389 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
3390 priv->isVerticalEdge = true;
3391 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
3392 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
3393 priv->isVerticalEdge = true;
3396 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
3397 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
3398 priv->isVerticalEdge = false;
3401 int maxScrollX = contentsSize.width() - smartData->view.w;
3402 if (!priv->isHorizontalEdge) {
3403 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
3404 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
3405 priv->isHorizontalEdge = true;
3406 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
3407 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
3408 priv->isHorizontalEdge = true;
3411 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
3412 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
3413 priv->isHorizontalEdge = false;
3417 void ewkViewClearEdges(Evas_Object* ewkView)
3419 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3420 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3422 priv->isVerticalEdge = false;
3423 priv->isHorizontalEdge = false;
3426 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
3428 EWK_VIEW_SD_GET(ewkView, smartData);
3429 if (!smartData || !smartData->priv) {
3437 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
3439 *minimumScale = constraints.minimumScale;
3441 *maximumScale = constraints.maximumScale;
3444 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard)
3446 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3447 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3449 double scaleFactor = priv->pageClient->scaleFactor();
3450 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3452 double newScaleFactor = scaleFactor;
3453 // Readable zoom value is dependent on device DPI
3454 if (scaleFactor < priv->pageClient->page()->deviceScaleFactor()
3455 && priv->pageClient->viewportConstraints().userScalable)
3456 newScaleFactor = priv->pageClient->page()->deviceScaleFactor();
3458 // Readable zoom value should be inside of viewport scale range
3459 newScaleFactor = priv->pageClient->adjustScaleWithViewport(newScaleFactor);
3461 // scale contents' size with new scale factor
3462 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3463 contentsSize.scale(newScaleFactor);
3465 contentsSize.scale(newScaleFactor / scaleFactor);
3468 #if ENABLE(TIZEN_ISF_PORT)
3469 Ecore_X_Window rootWin = ecore_x_window_root_first_get();
3470 ecore_x_event_mask_set(rootWin, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
3471 Ecore_X_Atom xAtom = ecore_x_atom_get("X External Keyboard Exist");
3472 unsigned int connectedKeyboardNum = 0;
3473 bool isExternalKeyboardConnected = false;
3475 // get connected keyboard number
3476 if (ecore_x_window_prop_card32_get(rootWin, xAtom, &connectedKeyboardNum, 1)
3477 && connectedKeyboardNum)
3478 isExternalKeyboardConnected = true;
3480 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
3481 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
3482 // input field zoom should not work with below conditions
3483 // 1. view is not focused
3484 // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
3485 // 3. imfContext is null(if adjustForExternalKeyboard is false)
3486 // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
3487 if ((!(static_cast<PageClient*>(priv->pageClient.get()))->isViewFocused()
3488 || (adjustForExternalKeyboard && !isExternalKeyboardConnected)
3489 || (!adjustForExternalKeyboard && !priv->imfContext)
3490 || (!adjustForExternalKeyboard && ecore_imf_context_input_panel_state_get(priv->imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE))
3491 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
3492 && !(priv->pageClient->isClipboardWindowOpened())
3498 IntSize visibleSize(smartData->view.w, smartData->view.h);
3499 // caret position can be outside of visible rect.
3500 // we need to consider it.
3501 IntRect selectionRect = priv->pageClient->page()->getSelectionRect(true);
3502 IntRect focusedNodeRect = priv->pageClient->focusedNodeRect();
3503 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3504 selectionRect.scale(newScaleFactor);
3505 focusedNodeRect.scale(newScaleFactor);
3507 selectionRect.scale(newScaleFactor / scaleFactor);
3508 focusedNodeRect.scale(newScaleFactor / scaleFactor);
3510 if (selectionRect.isEmpty())
3514 IntPoint scrollPosition(selectionRect.x() - visibleSize.width() / 3, selectionRect.y() - visibleSize.height() / 3);
3515 // If both input field's position x and selection rect can be displayed together,
3516 // adjust scroll position to input field's position x.
3517 if (!focusedNodeRect.isEmpty()
3518 && selectionRect.x() - focusedNodeRect.x() < visibleSize.width() * 4 / 5)
3519 scrollPosition.setX(focusedNodeRect.x());
3521 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3522 priv->pageClient->setVisibleContentRect(IntRect(scrollPosition, ewk_view_size_get(ewkView)), newScaleFactor);
3524 if (newScaleFactor != scaleFactor)
3525 priv->pageClient->page()->scalePage(newScaleFactor, scrollPosition);
3527 priv->pageClient->page()->scrollMainFrameTo(scrollPosition);
3529 evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
3533 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
3534 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
3535 static Eina_Bool _ewk_view_composite(void* data)
3537 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
3538 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
3540 if (!evas_object_visible_get(smartData->image))
3541 return ECORE_CALLBACK_CANCEL;
3544 evas_object_image_size_get(smartData->image, &ow, &oh);
3545 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
3547 RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_ARGB32, ow, oh, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, ow)));
3548 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
3550 cairo_save(context.get());
3551 cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
3552 cairo_rectangle(context.get(), 0, 0, ow, oh);
3553 cairo_fill(context.get());
3554 cairo_restore(context.get());
3556 priv->pageClient->drawContents(context.get());
3558 evas_object_image_data_set(smartData->image, pixels);
3559 evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
3561 ewkViewFrameRendered(smartData->self);
3563 priv->compositionAnimator = 0;
3565 return ECORE_CALLBACK_CANCEL;
3569 void ewk_view_mark_for_sync(Evas_Object* ewkView)
3571 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3572 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
3574 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
3575 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3577 if (!ewk_view_is_opengl_backend(ewkView)) {
3578 if (!priv->compositionAnimator)
3579 priv->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
3584 evas_object_image_pixels_dirty_set(smartData->image, true);
3587 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
3589 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
3590 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3591 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3592 priv->pageClient->drawContents();
3595 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
3597 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3598 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3600 if (!smartData->image)
3603 evas_object_image_native_surface_set(smartData->image, nativeSurface);
3604 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
3610 void _ewk_view_suspend_painting(Evas_Object* ewkView)
3612 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3613 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3615 if (!priv->suspendedPainting) {
3616 priv->pageClient->page()->suspendPainting();
3617 priv->suspendedPainting = true;
3621 void _ewk_view_resume_painting(Evas_Object* ewkView)
3623 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3624 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3626 if (priv->suspendedPainting) {
3627 priv->pageClient->page()->resumePainting();
3628 priv->suspendedPainting = false;
3632 void ewk_view_suspend(Evas_Object* ewkView)
3634 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3635 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3637 if (priv->pageClient->page()->estimatedProgress() < 1.0) {
3638 priv->suspendRequested = true;
3641 priv->suspendRequested = false;
3643 _ewk_view_suspend_painting(ewkView);
3645 // FIXME Workaround for suspend/resume while javascript popup is displayed.
3646 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
3647 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
3649 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
3650 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
3651 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
3652 // will be suspended again.
3653 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
3654 // the ActiveDOMObject.
3655 if (!priv->suspendedResources && (!priv->isWaitingForJavaScriptPopupReply || !priv->isWaitingForApplicationCachePermission)) {
3656 priv->pageClient->page()->suspendJavaScriptAndResource();
3657 priv->suspendedResources = true;
3660 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
3661 priv->pageClient->page()->suspendPlugin();
3665 void ewk_view_resume(Evas_Object* ewkView)
3667 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3668 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3670 if (priv->suspendRequested) {
3671 priv->suspendRequested = false;
3675 _ewk_view_resume_painting(ewkView);
3677 // FIXME Workaround for suspend/resume while javascript popup is displayed.
3678 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
3679 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
3681 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
3682 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
3683 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
3684 // will be suspended again.
3685 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
3686 // the ActiveDOMObject.
3687 if (priv->suspendedResources && (!priv->isWaitingForJavaScriptPopupReply || !priv->isWaitingForApplicationCachePermission)) {
3688 priv->pageClient->page()->resumeJavaScriptAndResource();
3689 priv->suspendedResources = false;
3692 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
3693 priv->pageClient->page()->resumePlugin();
3697 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
3699 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3700 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3701 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
3703 ResourceRequest request(String::fromUTF8(url));
3706 case EWK_HTTP_METHOD_GET:
3707 request.setHTTPMethod("GET");
3709 case EWK_HTTP_METHOD_HEAD:
3710 request.setHTTPMethod("HEAD");
3712 case EWK_HTTP_METHOD_POST:
3713 request.setHTTPMethod("POST");
3715 case EWK_HTTP_METHOD_PUT:
3716 request.setHTTPMethod("PUT");
3718 case EWK_HTTP_METHOD_DELETE:
3719 request.setHTTPMethod("DELETE");
3726 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
3728 while (eina_iterator_next(it, &data)) {
3729 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
3730 const char* name = static_cast<const char*>(t->key);
3731 const char* value = static_cast<const char*>(t->data);
3732 request.addHTTPHeaderField(name, value);
3734 eina_iterator_free(it);
3738 request.setHTTPBody(FormData::create(body));
3740 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
3741 WKPageLoadURLRequest(toAPI(priv->pageClient->page()), urlRequest.get());
3746 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
3748 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3749 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3751 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
3752 WKPageLoadPlainTextString(toAPI(priv->pageClient->page()), plainTextRef.get());
3757 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
3759 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3760 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3761 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
3763 if (contentsSize == 0)
3766 String mimeTypeString;
3768 mimeTypeString = String::fromUTF8(mimeType);
3770 mimeTypeString = String::fromUTF8("text/html");
3772 String encodingString;
3774 encodingString = String::fromUTF8(encoding);
3776 encodingString = String::fromUTF8("UTF-8");
3778 String baseUriString;
3780 baseUriString = String::fromUTF8(baseUri);
3782 baseUriString = String::fromUTF8("about:blank");
3784 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
3785 priv->pageClient->page()->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
3790 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
3792 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3793 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3795 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
3796 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
3798 WKPageLoadHTMLString(toAPI(priv->pageClient->page()), htmlString.get(), baseURL.get());
3803 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
3805 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3806 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3808 TIZEN_LOGI("initialState (%d)", initialState);
3809 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
3810 WKPageSetPageVisibility(toAPI(priv->pageClient->page()), static_cast<WKPageVisibilityState
3811 >(pageVisibilityState), initialState);
3819 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
3821 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
3823 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3824 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3826 eina_stringshare_replace(&priv->userAgent, userAgent);
3828 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
3829 WKPageSetCustomUserAgent(toAPI(priv->pageClient->page()), userAgentString.get());
3834 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
3836 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3837 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3839 if (!priv->userAgent) {
3840 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(priv->pageClient->page())));
3842 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
3843 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3844 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
3845 eina_stringshare_replace(&priv->userAgent, buffer.get());
3848 return priv->userAgent;
3850 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
3852 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3853 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3854 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3856 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
3857 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
3859 WKPageAddCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get(), customHeaderValue.get());
3862 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3867 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
3869 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3870 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3871 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3873 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
3875 WKPageRemoveCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get());
3878 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3883 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
3885 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3886 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3887 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3889 WKPageClearCustomHeaders(toAPI(priv->pageClient->page()));
3892 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3897 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
3898 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
3900 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3901 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3903 #if ENABLE(TIZEN_DRAG_SUPPORT)
3904 if (priv->pageClient->isDragMode())
3905 priv->pageClient->setDragMode(false);
3908 priv->pageClient->setIsVisible(enable);
3913 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
3915 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
3917 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3918 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3921 rect.origin.x = viewArea.x;
3922 rect.origin.y = viewArea.y;
3923 rect.size.width = viewArea.w;
3924 rect.size.height = viewArea.h;
3926 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(priv->pageClient->page()), rect, scaleFactor));
3927 if (!snapshot.get())
3930 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
3932 Evas_Object* screenshotImage = evas_object_image_add(canvas);
3933 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
3934 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
3935 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
3936 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
3938 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
3940 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)));
3941 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
3943 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
3944 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
3945 cairo_fill(cairo.get());
3947 evas_object_image_smooth_scale_set(screenshotImage, true);
3948 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
3949 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
3950 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
3951 evas_object_image_data_set(screenshotImage, pixels);
3953 return screenshotImage;
3956 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
3958 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
3959 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
3960 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, 0);
3962 return priv->pageClient->page()->startInspectorServer(port);
3964 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
3969 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
3971 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
3972 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
3973 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
3975 return priv->pageClient->page()->stopInspectorServer();
3977 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
3982 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
3984 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3985 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3987 WKPageScrollBy(toAPI(priv->pageClient->page()), toAPI(IntSize(deltaX, deltaY)));
3990 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
3996 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3997 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3999 IntPoint scrollPosition = priv->pageClient->scrollPosition();
4001 *x = scrollPosition.x();
4003 *y = scrollPosition.y();
4008 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
4010 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4011 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4013 priv->pageClient->page()->scrollMainFrameTo(IntPoint(x, y));
4017 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
4023 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4024 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4026 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4027 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
4028 contentsSize.scale(priv->pageClient->scaleFactor());
4031 if (width && contentsSize.width() > smartData->view.w)
4032 *width = contentsSize.width() - smartData->view.w;
4033 if (height && contentsSize.height() > smartData->view.h)
4034 *height = contentsSize.height() - smartData->view.h;
4038 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
4040 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4041 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4042 if (!priv->alertContext || !priv->alertContext->javascriptAlertCallback)
4044 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->alertContext->ewkView == ewkView, false);
4046 priv->isWaitingForJavaScriptPopupReply = true;
4047 int length = WKStringGetMaximumUTF8CStringSize(alertText);
4048 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
4049 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
4050 return priv->alertContext->javascriptAlertCallback(priv->alertContext->ewkView, alertTextBuffer.get(), priv->alertContext->userData) == EINA_TRUE;
4053 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
4055 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4056 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4057 if (!priv->confirmContext || !priv->confirmContext->javascriptConfirmCallback)
4059 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->confirmContext->ewkView == ewkView, false);
4061 priv->isWaitingForJavaScriptPopupReply = true;
4062 int length = WKStringGetMaximumUTF8CStringSize(message);
4063 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4064 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4065 return priv->confirmContext->javascriptConfirmCallback(priv->confirmContext->ewkView, messageBuffer.get(), priv->confirmContext->userData) == EINA_TRUE;
4068 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
4070 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4071 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4072 if (!priv->promptContext || !priv->promptContext->javascriptPromptCallback)
4074 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->promptContext->ewkView == ewkView, false);
4076 priv->isWaitingForJavaScriptPopupReply = true;
4077 int length = WKStringGetMaximumUTF8CStringSize(message);
4078 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4079 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4080 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
4081 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
4082 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
4083 return priv->promptContext->javascriptPromptCallback(priv->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), priv->promptContext->userData) == EINA_TRUE;
4086 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
4087 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
4089 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4090 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4091 if (!priv->beforeUnloadConfirmPanelContext || !priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
4093 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
4095 priv->isWaitingForJavaScriptPopupReply = true;
4096 int length = WKStringGetMaximumUTF8CStringSize(message);
4097 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4098 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4099 bool result = priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(priv->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), priv->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
4104 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
4106 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4107 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4108 if (!priv->openpanelContext || !priv->openpanelContext->openPanelCallback)
4111 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->openpanelContext->ewkView == ewkView, false);
4113 priv->openPanelListener = listener;
4115 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
4116 Eina_List* acceptedMimeTypes = 0;
4117 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
4118 size_t len = WKArrayGetSize(array.get());
4119 for (size_t i = 0; i < len; i++) {
4120 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
4121 if (WKGetTypeID(item) != WKStringGetTypeID())
4123 WKStringRef mime = static_cast<WKStringRef>(item);
4124 int length = WKStringGetMaximumUTF8CStringSize(mime);
4125 char* buffer = new char[length];
4126 WKStringGetUTF8CString(mime, buffer, length);
4127 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
4129 const char* capture = 0;
4130 #if ENABLE(MEDIA_CAPTURE)
4131 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
4132 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
4134 bool result = priv->openpanelContext->openPanelCallback(priv->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
4135 if (!acceptedMimeTypes)
4140 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
4141 delete[] (char*)data;
4142 eina_list_free(acceptedMimeTypes);
4146 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
4148 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4149 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4151 if (!priv->alertContext)
4152 priv->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4153 priv->alertContext->javascriptAlertCallback = callback;
4154 priv->alertContext->ewkView = ewkView;
4155 priv->alertContext->userData = userData;
4158 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
4160 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4161 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4163 WKPageReplyJavaScriptAlert(toAPI(ewk_view_page_get(ewkView)));
4164 priv->isWaitingForJavaScriptPopupReply = false;
4167 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
4169 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4170 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4172 if (!priv->confirmContext)
4173 priv->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4174 priv->confirmContext->javascriptConfirmCallback = callback;
4175 priv->confirmContext->ewkView = ewkView;
4176 priv->confirmContext->userData = userData;
4179 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
4181 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4182 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4184 WKPageReplyJavaScriptConfirm(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
4185 priv->isWaitingForJavaScriptPopupReply = false;
4188 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
4190 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4191 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4193 if (!priv->promptContext)
4194 priv->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4195 priv->promptContext->javascriptPromptCallback = callback;
4196 priv->promptContext->ewkView = ewkView;
4197 priv->promptContext->userData = userData;
4200 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
4202 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4203 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4205 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
4206 WKPageReplyJavaScriptPrompt(toAPI(ewk_view_page_get(ewkView)), result ? resultString.get() : 0);
4207 priv->isWaitingForJavaScriptPopupReply = false;
4210 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
4211 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
4213 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4214 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4216 if (!priv->beforeUnloadConfirmPanelContext)
4217 priv->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4218 priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
4219 priv->beforeUnloadConfirmPanelContext->ewkView = ewkView;
4220 priv->beforeUnloadConfirmPanelContext->userData = userData;
4223 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
4225 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4226 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4228 WKPageReplyBeforeUnloadConfirmPanel(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
4229 priv->isWaitingForJavaScriptPopupReply = false;
4233 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
4235 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4236 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4238 if (!priv->openpanelContext)
4239 priv->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4241 priv->openpanelContext->openPanelCallback = callback;
4242 priv->openpanelContext->ewkView = ewkView;
4243 priv->openpanelContext->userData = userData;
4246 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
4248 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4249 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4251 if (!priv->openPanelListener)
4254 unsigned int size = eina_list_count(fileUrls);
4255 if ((result == EINA_FALSE) || (size == 0)) {
4256 WKOpenPanelResultListenerCancel(priv->openPanelListener);
4257 priv->openPanelListener = 0;
4261 WKTypeRef* items = new WKTypeRef[size];
4265 KURL base(KURL(), "file://");
4266 EINA_LIST_FOREACH(fileUrls, list, data) {
4267 KURL url(base, static_cast<char*>(data));
4268 items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
4270 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
4271 WKOpenPanelResultListenerChooseFiles(priv->openPanelListener, filesArray.get());
4272 priv->openPanelListener = 0;
4274 eina_list_free(fileUrls);
4277 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4278 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
4280 EINA_SAFETY_ON_NULL_RETURN(capable);
4281 EINA_SAFETY_ON_NULL_RETURN(context);
4283 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4285 ASSERT(webAppContext->webAppCapableCallback);
4287 TIZEN_LOGI("webAppCapableCallback exist. capable(%b)", capable);
4289 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
4291 webAppContext->webAppCapableCallback(0, webAppContext->userData);
4293 delete webAppContext;
4296 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
4298 EINA_SAFETY_ON_NULL_RETURN(iconURL);
4299 EINA_SAFETY_ON_NULL_RETURN(context);
4301 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4303 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
4304 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4306 ASSERT(webAppContext->webAppIconURLCallback);
4309 eina_stringshare_replace(&priv->webAppIconURL, toImpl(iconURL)->string().utf8().data());
4310 webAppContext->webAppIconURLCallback(priv->webAppIconURL, webAppContext->userData);
4312 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
4314 delete webAppContext;
4317 static void didGetWebAppIconURLs(WKDictionaryRef iconURLs, WKErrorRef, void* context)
4319 EINA_SAFETY_ON_NULL_RETURN(iconURLs);
4320 EINA_SAFETY_ON_NULL_RETURN(context);
4322 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4324 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
4325 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4327 ASSERT(webAppContext->webAppIconURLsCallback);
4329 if (priv->webAppIconURLs) {
4331 EINA_LIST_FREE(priv->webAppIconURLs, data)
4332 ewkWebAppIconDataDelete(static_cast<Ewk_Web_App_Icon_Data*>(data));
4335 WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(iconURLs));
4336 size_t iconURLCount = WKArrayGetSize(wkKeys.get());
4337 for (size_t i = 0; i < iconURLCount; i++) {
4338 WKStringRef urlRef = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
4339 WKStringRef sizeRef = static_cast<WKStringRef>(WKDictionaryGetItemForKey(iconURLs, urlRef));
4340 priv->webAppIconURLs = eina_list_append(priv->webAppIconURLs, ewkWebAppIconDataCreate(sizeRef, urlRef));
4342 TIZEN_LOGI("webAppIconURLsCallback exist. found %d icon urls", iconURLCount);
4344 webAppContext->webAppIconURLsCallback(priv->webAppIconURLs, webAppContext->userData);
4345 delete webAppContext;
4349 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
4351 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4352 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4353 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4354 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4356 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
4357 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4358 context->webAppCapableCallback = callback;
4359 context->ewkView = ewkView;
4360 context->userData = userData;
4362 WKPageGetWebAppCapable(toAPI(priv->pageClient->page()), context, didGetWebAppCapable);
4370 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
4372 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4373 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4374 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4375 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4377 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4378 context->webAppIconURLCallback = callback;
4379 context->ewkView = ewkView;
4380 context->userData = userData;
4382 WKPageGetWebAppIconURL(toAPI(priv->pageClient->page()), context, didGetWebAppIconURL);
4390 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
4392 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4393 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4394 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4395 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4397 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
4398 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4399 context->webAppIconURLsCallback = callback;
4400 context->ewkView = ewkView;
4401 context->userData = userData;
4403 WKPageGetWebAppIconURLs(toAPI(priv->pageClient->page()), context, didGetWebAppIconURLs);
4407 UNUSED_PARAM(ewkView);
4408 UNUSED_PARAM(callback);
4409 UNUSED_PARAM(userData);
4414 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
4416 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4417 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4418 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
4420 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
4421 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
4422 WKPageExecuteCommandWithArgument(toAPI(priv->pageClient->page()), commandString.get(), valueString.get());
4427 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4429 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4430 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4431 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4433 // FixMe: Comment should be removed when pageClient is removed.
4434 //priv->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4435 priv->pageClient->page()->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4440 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4442 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4443 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4445 // FixMe: Comment should be removed when pageClient is removed.
4446 //priv->pageProxy->hideFindUI();
4447 priv->pageClient->page()->hideFindUI();
4452 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
4459 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4460 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4462 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4465 *width = contentsSize.width();
4467 *height = contentsSize.height();
4472 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
4474 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
4475 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4476 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4477 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
4479 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4480 WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
4488 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, int width, int height, const char* fileName)
4490 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
4491 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4492 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4493 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
4495 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4496 WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
4504 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
4506 EINA_SAFETY_ON_NULL_RETURN(context);
4507 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4509 if (!callbackContext->scriptExecuteCallback) {
4510 delete callbackContext;
4514 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
4517 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
4518 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
4519 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
4520 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
4521 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
4522 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
4524 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
4526 delete callbackContext;
4529 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
4531 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4532 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4533 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
4534 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient, false);
4536 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4537 context->scriptExecuteCallback = callback;
4538 context->ewkView = ewkView;
4539 context->userData = user_data;
4540 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
4541 WKPageRunJavaScriptInMainFrame(toAPI(priv->pageClient->page()), scriptString.get(), context, runJavaScriptCallback);
4546 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
4547 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
4549 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
4552 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
4554 storageContext->webStorageQuotaCallback(0, storageContext->userData);
4556 delete storageContext;
4560 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
4562 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
4563 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
4564 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
4565 TIZEN_LOGI("resultCallback (%p)", resultCallback);
4567 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4568 context->webStorageQuotaCallback = resultCallback;
4569 context->userData = userData;
4571 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
4572 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
4580 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
4582 #if ENABLE(TIZEN_WEB_STORAGE)
4583 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
4585 TIZEN_LOGI("quota (%d)", quota);
4586 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
4587 WKPageSetWebStorageQuota(pageRef, quota);
4595 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
4597 EINA_SAFETY_ON_NULL_RETURN(context);
4598 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4600 ASSERT(callbackContext->plainTextGetCallback);
4603 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
4604 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
4605 WKStringGetUTF8CString(plain_text, buffer.get(), length);
4607 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
4609 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
4611 delete callbackContext;
4614 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
4616 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4617 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4618 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4619 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient, false);
4621 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4622 context->plainTextGetCallback = callback;
4623 context->ewkView = ewkView;
4624 context->userData = user_data;
4625 WKPageGetContentsAsString(toAPI(priv->pageClient->page()), context, getContentsAsStringCallback);
4630 #if ENABLE(TIZEN_SUPPORT_MHTML)
4633 * Callback function used for ewk_view_mhtml_data_get().
4635 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4637 EINA_SAFETY_ON_NULL_RETURN(context);
4638 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4640 ASSERT(callbackContext->mhtmlDataGetCallback);
4642 callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
4644 delete callbackContext;
4647 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
4649 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4650 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4651 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4653 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4654 context->mhtmlDataGetCallback = callback;
4655 context->ewkView = ewkView;
4656 context->userData = user_data;
4658 WKPageGetContentsAsMHTMLData(toAPI(priv->pageClient->page()), false, context, getContentsAsMHTMLCallback);
4662 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
4664 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
4666 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
4667 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4668 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4669 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, 0);
4671 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
4672 WebHitTestResult::Data hitTestResultData = priv->pageClient->page()->hitTestResultAtPoint(pointForHitTest, hitTestMode);
4673 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
4681 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
4683 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
4684 WebPageProxy* page = ewk_view_page_get(ewkView);
4685 EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
4687 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
4690 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
4692 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4693 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4695 WKPageRecordingSurfaceSetEnable(toAPI(priv->pageClient->page()), enable);
4700 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
4702 #if ENABLE(TIZEN_NOTIFICATIONS)
4703 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4704 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4705 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->context, false);
4707 TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
4708 if (!eina_list_count(ewkNotifications))
4711 Eina_List* listIterator = 0;
4713 Vector<WKTypeRef> ids;
4714 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
4715 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
4716 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
4718 priv->notifications = eina_list_remove(priv->notifications, notification);
4721 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
4722 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(ewk_context_WKContext_get(priv->context));
4723 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
4724 ewkNotificationDeleteNotificationList(ewkNotifications);
4732 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
4734 Eina_List* popupItems = 0;
4735 size_t size = items.size();
4736 for (size_t i = 0; i < size; ++i) {
4737 Ewk_Popup_Menu_Item* item = ewk_popup_menu_item_new(items[i].m_type,
4738 items[i].m_text.utf8().data(),
4739 items[i].m_textDirection,
4740 items[i].m_hasTextDirectionOverride,
4741 items[i].m_toolTip.utf8().data(),
4742 items[i].m_accessibilityText.utf8().data(),
4743 items[i].m_isEnabled,
4744 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4745 items[i].m_isSelected,
4747 items[i].m_isLabel);
4748 popupItems = eina_list_append(popupItems, item);
4750 TIZEN_LOGI("size : %d", size);
4754 static void releasePopupMenuList(Eina_List* popupMenuItems)
4756 if (!popupMenuItems)
4760 EINA_LIST_FREE(popupMenuItems, item)
4761 ewk_popup_menu_item_free(static_cast<Ewk_Popup_Menu_Item*>(item));
4764 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4765 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, bool multiple)
4767 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)
4770 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4771 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4772 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4773 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4777 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4778 if (!smartData->api->popup_menu_show && !smartData->api->multiple_popup_menu_show)
4780 if (!smartData->api->popup_menu_show)
4784 if (priv->popupMenuProxy)
4785 ewk_view_popup_menu_close(ewkView);
4786 priv->popupMenuProxy = popupMenu;
4788 priv->popupMenuItems = createPopupMenuList(items);
4790 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4791 if ((!multiple && smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems, selectedIndex)) ||
4792 (multiple && smartData->api->multiple_popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems))) {
4794 if (smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems, selectedIndex)) {
4796 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
4797 /* maps.google.com generate mouse event in touch down without preventDefault.
4798 * So, popup menu is opend in touch down event and closed via fake mouse down
4799 * which generated by endTap.
4800 * In order to fix select of maps.google.com (based on touch behavior),
4801 * We should disable touch events when select popup is open.
4804 #if ENABLE(TIZEN_GESTURE)
4805 priv->gestureClient->reset();
4807 ewk_view_touch_events_enabled_set(ewkView, false);
4812 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
4814 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4815 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4816 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4817 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4819 if (!priv->popupMenuProxy)
4822 priv->popupMenuProxy = 0;
4824 if (smartData->api->popup_menu_hide)
4825 smartData->api->popup_menu_hide(smartData);
4826 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
4827 ewk_view_touch_events_enabled_set(ewkView, true);
4830 releasePopupMenuList(priv->popupMenuItems);
4831 priv->popupMenuItems = 0;
4836 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
4838 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4839 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4840 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4841 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4843 if (!priv->popupMenuProxy)
4846 if (!smartData->api->popup_menu_update)
4849 releasePopupMenuList(priv->popupMenuItems);
4850 priv->popupMenuItems = createPopupMenuList(items);
4852 // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
4853 smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), priv->popupMenuItems, selectedIndex);
4856 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
4858 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4859 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4860 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
4861 TIZEN_LOGI("proxy : %p / index : %d", priv->popupMenuProxy, selectedIndex);
4863 if (!priv->popupMenuItems)
4866 if (selectedIndex >= eina_list_count(priv->popupMenuItems))
4869 priv->popupMenuProxy->valueChanged(selectedIndex);
4874 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4875 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
4877 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4878 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4879 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
4881 Vector<int> selectedIndex;
4883 if (!priv->popupMenuItems)
4888 itr = eina_inarray_iterator_new(changeList);
4889 EINA_ITERATOR_FOREACH(itr, data)
4891 int* pData = static_cast<int*>(data);
4892 selectedIndex.append(*pData);
4894 eina_iterator_free(itr);
4896 priv->popupMenuProxy->multipleValueChanged(selectedIndex);
4901 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
4903 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
4904 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4905 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4906 TIZEN_LOGI("orientation : %d", orientation);
4908 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
4911 if (priv->orientation == orientation)
4914 priv->orientation = orientation;
4916 priv->pageClient->page()->sendOrientationChangeEvent(orientation);
4920 void ewkViewFrameRendered(Evas_Object* ewkView)
4922 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
4925 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4926 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
4928 return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
4931 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
4933 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4934 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4935 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
4937 IntRect leftSelectionRect;
4938 IntRect rightSelectionRect;
4939 if (!priv->pageClient->page()->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
4952 AffineTransform contentToScreen = impl->transformToScene();
4953 leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
4954 rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
4956 leftRect->x = leftSelectionRect.x();
4957 leftRect->y = leftSelectionRect.y();
4958 leftRect->w = leftSelectionRect.width();
4959 leftRect->h = leftSelectionRect.height();
4961 rightRect->x = rightSelectionRect.x();
4962 rightRect->y = rightSelectionRect.y();
4963 rightRect->w = rightSelectionRect.width();
4964 rightRect->h = rightSelectionRect.height();
4969 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
4971 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4972 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4974 const CString selectedString = priv->pageClient->page()->getSelectionText().utf8();
4975 eina_stringshare_replace(&priv->selectedText, selectedString.data());
4977 return priv->selectedText;
4980 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
4982 return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
4985 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
4987 return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
4989 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4991 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4992 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
4994 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4995 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4996 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
4998 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
5002 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
5003 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
5005 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5006 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5007 IntPoint drawingPosition = (IntPoint)(priv->pageClient->visibleContentRect().location() - priv->pageClient->scrollPosition());
5009 *x = drawingPosition.x();
5011 *y = drawingPosition.y();
5013 *w = priv->pageClient->visibleContentRect().width();
5015 *h = priv->pageClient->visibleContentRect().height();
5019 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
5021 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
5022 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5023 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5025 priv->pageClient->page()->setFocusedInputElementValue(String::fromUTF8(value));
5026 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
5029 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
5031 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
5032 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5033 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5035 eina_stringshare_replace(&priv->inputValue, priv->pageClient->page()->getFocusedInputElementValue().utf8().data());
5036 return priv->inputValue;
5039 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
5042 #if ENABLE(TIZEN_DATALIST_ELEMENT)
5043 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
5045 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5046 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5047 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
5048 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
5051 ewkViewDataListHideRequest(ewkView, inputType);
5053 for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
5055 priv->dataList = eina_list_append(priv->dataList, eina_stringshare_add(value.utf8().data()));
5058 smartData->api->data_list_show(smartData, inputType, priv->dataList);
5061 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
5063 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5064 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5065 EINA_SAFETY_ON_NULL_RETURN(priv->dataList);
5066 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
5067 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
5069 if (priv->dataList) {
5070 _ewk_view_data_list_del(priv->dataList);
5074 smartData->api->data_list_hide(smartData, inputType);
5078 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
5080 #if ENABLE(TIZEN_DATALIST_ELEMENT)
5081 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5082 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5084 if (priv->dataList) {
5085 _ewk_view_data_list_del(priv->dataList);
5089 ewk_view_focused_input_element_value_set(ewkView, value);
5093 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
5095 #if ENABLE(TIZEN_GESTURE)
5096 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
5097 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
5098 return priv->holdHorizontalPanning;
5104 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
5106 #if ENABLE(TIZEN_GESTURE)
5107 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5108 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5109 priv->holdHorizontalPanning = hold;
5113 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
5115 #if ENABLE(TIZEN_GESTURE)
5116 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
5117 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
5118 return priv->holdVerticalPanning;
5124 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
5126 #if ENABLE(TIZEN_GESTURE)
5127 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5128 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5129 priv->holdVerticalPanning = hold;
5133 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
5135 #if ENABLE(TIZEN_GESTURE)
5136 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5137 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5139 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5140 if (priv->focusRing && wasHandled)
5141 priv->focusRing->hide();
5142 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5144 if (priv->areMouseEventsEnabled)
5147 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
5148 if (wasHandled && priv->pageClient->isTextSelectionMode()) {
5149 if (type == WebEvent::TouchStart)
5150 priv->pageClient->updateTextSelectionHandlesAndContextMenu(false);
5151 else if (type == WebEvent::TouchMove)
5152 priv->pageClient->updateTextSelectionHandlesAndContextMenu(false);
5153 else if (type == WebEvent::TouchEnd)
5154 priv->pageClient->requestToShowTextSelectionHandlesAndContextMenu();
5158 // We have to check TouchStart, TouchMove and TouchEnd with handled.
5159 // The Pan and Flick will be enabled if Touch Start was not handled,
5160 // and Touch Move was not handled or did not occur.
5161 // Tap will be enabled if Touch Start and End was not handled
5162 // and Touch Move did not occur.
5163 // The gestures are disabled as a default.
5164 // o: handled, x: not handled
5165 // ------------------------------------------------------------
5166 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
5167 // ------------------------------------------------------------
5168 // o | o or x | o or x || disable | disable
5169 // x | o | o or x || disable | disable
5170 // x | x | o or x || disable | enable
5171 // x |not occured | x || enable | enable
5172 // ------------------------------------------------------------
5173 if (type == WebEvent::TouchStart) {
5174 priv->gestureClient->setGestureEnabled(!wasHandled);
5175 priv->wasHandledTouchStart = wasHandled;
5177 // Initialize wasHandledTouchMove to true and notify that to the application
5178 // to prevent applications scrolling at the beginning of touch.
5179 priv->wasHandledTouchMove = true;
5180 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&priv->wasHandledTouchMove));
5181 } else if (type == WebEvent::TouchMove) {
5182 priv->gestureClient->setMovingEnabled(!wasHandled);
5184 // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
5185 if (priv->wasHandledTouchStart)
5188 // Notify the result of touchmove to applications when handled value is changed
5189 // in order to make applications to choose whether scrolling its scrollable objects or not.
5190 if (priv->wasHandledTouchMove != wasHandled)
5191 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
5192 priv->wasHandledTouchMove = wasHandled;
5193 } else if (type == WebEvent::TouchEnd && !priv->exceedTouchMoveThreshold && !wasHandled) {
5194 priv->gestureClient->setMovingEnabled(!wasHandled);
5195 priv->gestureClient->setTapEnabled(!wasHandled);
5200 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
5201 void ewkViewDidGetTextStyleStateForSelection(Evas_Object* ewkView, int underlineState, int italicState, int boldState, const IntPoint& startPoint, const IntPoint& endPoint)
5203 Ewk_Text_Style* textStyle = ewkTextStyleCreate(underlineState, italicState, boldState, startPoint, endPoint);
5204 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
5205 ewkTextStyleDelete(textStyle);
5209 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
5210 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
5212 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5213 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
5215 TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
5216 if (!smartData->api->orientation_lock) {
5221 return smartData->api->orientation_lock(smartData, willLockOrientation);
5224 void ewk_view_orientation_unlock(Evas_Object* ewkView)
5226 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5227 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
5229 TIZEN_LOGI("ewkView (%p)", ewkView);
5230 if (!smartData->api->orientation_unlock) {
5235 smartData->api->orientation_unlock(smartData);
5239 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
5241 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
5242 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5243 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5244 TIZEN_LOGI("callbacks: %p / data: %p", func, data);
5246 priv->orientationLock.callback = func;
5247 priv->orientationLock.data = data;
5251 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
5252 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
5254 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
5255 TIZEN_LOGI("locked orientations : %d", orientations);
5257 if (priv->orientationLock.callback)
5258 return priv->orientationLock.callback(sd->self, true, orientations, priv->orientationLock.data);
5263 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
5265 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
5266 TIZEN_LOGI("unlock is requested");
5268 if (priv->orientationLock.callback)
5269 priv->orientationLock.callback(sd->self, false, 0, priv->orientationLock.data);
5273 void ewk_view_fullscreen_enter(Evas_Object* ewkView)
5275 TIZEN_LOGI("fullscreen,enterfullscreen");
5276 ewk_view_main_frame_scrollbar_visible_set(ewkView, false);
5277 evas_object_smart_callback_call(ewkView, "fullscreen,enterfullscreen", 0);
5280 void ewk_view_fullscreen_exit(Evas_Object* ewkView)
5282 TIZEN_LOGI("fullscreen,exitfullscreen");
5283 ewk_view_main_frame_scrollbar_visible_set(ewkView, true);
5284 evas_object_smart_callback_call(ewkView, "fullscreen,exitfullscreen", 0);
5287 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
5288 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
5290 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5292 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
5293 const char *engine = ecore_evas_engine_name_get(ee);
5294 if (engine && !strcmp(engine, "opengl_x11"))
5300 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
5302 #if ENABLE(TIZEN_GESTURE)
5303 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5304 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5306 priv->gestureClient->setZoomableArea(target, area);
5310 #if ENABLE(TIZEN_ISF_PORT)
5311 static void imfInputPanelStateEventCb(void* data, Ecore_IMF_Context* ctx, int state)
5313 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5314 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5316 if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
5317 evas_object_smart_callback_call(smartData->self, "editorclient,ime,closed", 0);
5318 LOG(ISF, "[SIGNAL] editorclient,ime,closed\n");
5319 } else if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
5320 evas_object_smart_callback_call(smartData->self, "editorclient,ime,opened", 0);
5321 LOG(ISF, "[SIGNAL] editorclient,ime,opened\n");
5325 static void imfInputPanelGeometryEventCb(void* data, Ecore_IMF_Context* ctx, int value)
5327 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5328 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5330 Eina_Rectangle rect;
5331 ecore_imf_context_input_panel_geometry_get(priv->imfContext, &rect.x, &rect.y, &rect.w, &rect.h);
5332 evas_object_smart_callback_call(smartData->self, "inputmethod,changed", &rect);
5333 LOG(ISF, "%s : [SIGNAL] inputmethod,changed (%d,%d,%d,%d)\n", __func__, rect.x, rect.y, rect.w, rect.h);
5336 static void imfCandidatePanelStateEventCb(void* data, Ecore_IMF_Context* ctx, int state)
5338 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5339 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5341 if (state == ECORE_IMF_CANDIDATE_PANEL_SHOW)
5342 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,opened", 0);
5344 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,closed", 0);
5347 static void imfCandidatePanelGeometryEventCb(void* data, Ecore_IMF_Context* ctx, int value)
5349 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5350 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5352 Eina_Rectangle rect;
5353 ecore_imf_context_candidate_panel_geometry_get(priv->imfContext, &rect.x, &rect.y, &rect.w, &rect.h);
5354 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,changed", &rect);
5357 static Eina_Bool imfRetrieveSurroundingCb(void* data, Ecore_IMF_Context* context, char** text, int* offset)
5359 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5360 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5362 if (!priv->pageClient->page()->focusedFrame() || (!text && !offset))
5365 String surroundingText;
5367 priv->pageClient->page()->getSurroundingTextAndCursorOffset(surroundingText, cursorOffset);
5370 CString utf8Text(surroundingText.utf8());
5371 size_t length = utf8Text.length();
5373 *text = static_cast<char*>(malloc((length + 1) * sizeof(char)));
5378 strncpy(*text, utf8Text.data(), length);
5379 (*text)[length] = 0;
5383 *offset = cursorOffset;
5388 static void imfPreeditChangedCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5390 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5391 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5393 priv->pageClient->imContextPreeditChanged(context);
5396 static void imfEventCommittedCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5398 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5399 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5401 priv->pageClient->imContextCommitted(context, static_cast<char*>(eventInfo));
5404 static void imfContextDeleteSurroundingCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5406 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5407 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5409 Ecore_IMF_Event_Delete_Surrounding* event = static_cast<Ecore_IMF_Event_Delete_Surrounding*>(eventInfo);
5413 priv->pageClient->page()->deleteSurroundingText(event->offset, event->n_chars);
5416 Ecore_IMF_Context* ewk_view_imf_context_get(Evas_Object* ewkView)
5418 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5419 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5421 return priv->imfContext;
5424 Ecore_IMF_Context* ewk_view_imf_context_set(Evas_Object* ewkView, Ecore_IMF_Input_Panel_Layout layout)
5426 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5427 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5429 Ecore_IMF_Context* imfContext;
5430 Eina_List* iterator;
5433 EINA_LIST_FOREACH(priv->imfContextList, iterator, data) {
5434 imfContext = static_cast<Ecore_IMF_Context*>(data);
5435 if (ecore_imf_context_input_panel_layout_get(imfContext) == layout) {
5436 priv->imfContext = imfContext;
5441 imfContext = ecore_imf_context_add(ecore_imf_context_default_id_get());
5445 ecore_imf_context_input_panel_enabled_set(imfContext, false);
5446 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, imfInputPanelStateEventCb, smartData);
5447 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, imfInputPanelGeometryEventCb, smartData);
5448 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, imfCandidatePanelStateEventCb, smartData);
5449 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, imfCandidatePanelGeometryEventCb, smartData);
5450 ecore_imf_context_retrieve_surrounding_callback_set(imfContext, imfRetrieveSurroundingCb, smartData); // Support for Auto Capitalization
5451 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, imfPreeditChangedCb, smartData);
5452 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_COMMIT, imfEventCommittedCb, smartData);
5453 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, imfContextDeleteSurroundingCb, smartData); //Support for Automatic Full Stop
5454 ecore_imf_context_input_panel_layout_set(imfContext, layout);
5456 priv->imfContextList = eina_list_append(priv->imfContextList, imfContext);
5457 priv->imfContext = imfContext;
5462 void ewk_view_imf_context_reset(Evas_Object* ewkView)
5464 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5465 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5467 if (!priv->imfContext)
5470 ecore_imf_context_reset(priv->imfContext);
5472 if (ecore_imf_context_input_panel_state_get(priv->imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
5473 priv->imfContext = 0;
5476 void ewk_view_imf_context_hide(Evas_Object* ewkView)
5478 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5479 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5481 if (!priv->imfContext)
5484 if (ecore_imf_context_input_panel_state_get(priv->imfContext) != ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
5485 ecore_imf_context_reset(priv->imfContext);
5486 ecore_imf_context_input_panel_hide(priv->imfContext);
5487 ecore_imf_context_focus_out(priv->imfContext);
5490 priv->imfContext = 0;
5493 static void _ewk_view_imf_context_destroy(Ewk_View_Private_Data* priv)
5495 if (!priv->imfContextList)
5499 EINA_LIST_FREE(priv->imfContextList, item) {
5500 Ecore_IMF_Context* imfContext = static_cast<Ecore_IMF_Context*>(item);
5504 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, imfInputPanelStateEventCb);
5505 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, imfInputPanelGeometryEventCb);
5506 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, imfCandidatePanelStateEventCb);
5507 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, imfCandidatePanelGeometryEventCb);
5508 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, imfPreeditChangedCb);
5509 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_COMMIT, imfEventCommittedCb);
5510 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, imfContextDeleteSurroundingCb);
5511 ecore_imf_context_del(imfContext);
5514 priv->imfContextList = 0;
5515 priv->imfContext = 0;
5518 void ewk_view_imf_context_destroy(Evas_Object* ewkView)
5520 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5521 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5523 _ewk_view_imf_context_destroy(priv);
5527 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
5528 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
5530 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5531 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5533 WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(priv->pageClient->page())));
5537 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
5538 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
5540 evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
5544 #if ENABLE(TIZEN_ICON_DATABASE)
5545 void ewkViewIconReceived(Evas_Object* ewkView)
5549 evas_object_smart_callback_call(ewkView, "icon,received", 0);
5553 #endif // #if OS(TIZEN)
5555 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
5556 #if ENABLE(INPUT_TYPE_COLOR)
5559 * Reqeusts to show external color picker.
5561 void ewk_view_color_picker_request(Evas_Object* ewkView, int r, int g, int b, int a, WKColorPickerResultListenerRef listener)
5563 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5564 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5565 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_request);
5567 priv->colorPickerResultListener = listener;
5569 smartData->api->input_picker_color_request(smartData, r, g, b, a);
5574 * Reqeusts to hide external color picker.
5576 void ewk_view_color_picker_dismiss(Evas_Object* ewkView)
5578 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5579 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5580 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_dismiss);
5582 priv->colorPickerResultListener = 0;
5584 smartData->api->input_picker_color_dismiss(smartData);
5588 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
5590 #if ENABLE(INPUT_TYPE_COLOR)
5591 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5592 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5593 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->colorPickerResultListener, false);
5595 WebCore::Color color = WebCore::Color(r, g, b, a);
5596 WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(color.serialized().utf8().data()));
5597 WKColorPickerResultListenerSetColor(priv->colorPickerResultListener, colorString.get());
5598 priv->colorPickerResultListener = 0;
5605 #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
5607 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
5609 #if ENABLE(TOUCH_EVENTS)
5610 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
5611 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5612 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5613 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
5615 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
5616 if (priv->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
5617 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5618 IntPoint handlePoint(point->x, point->y);
5620 if (type == EWK_TOUCH_START)
5621 priv->pageClient->textSelectonHandleDown(handlePoint);
5622 else if (type == EWK_TOUCH_MOVE)
5623 priv->pageClient->textSelectonHandleMove(handlePoint);
5625 priv->pageClient->textSelectonHandleUp();
5629 #if ENABLE(TIZEN_GESTURE)
5630 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
5631 // We don't want to process touch event when context menu is shown.
5632 if (priv->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
5635 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
5636 if (priv->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
5640 if (type == EWK_TOUCH_START) {
5641 if (eina_list_count(points) == 1) {
5642 priv->gestureClient->reset();
5643 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5644 priv->touchDownPoint.x = point->x;
5645 priv->touchDownPoint.y = point->y;
5646 priv->exceedTouchMoveThreshold = false;
5648 } else if (type == EWK_TOUCH_MOVE && !priv->exceedTouchMoveThreshold) {
5649 if (eina_list_count(points) == 1) {
5650 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
5651 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5652 int diffX = priv->touchDownPoint.x - point->x;
5653 int diffY = priv->touchDownPoint.y - point->y;
5654 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
5655 priv->exceedTouchMoveThreshold = true;
5659 priv->exceedTouchMoveThreshold = true;
5662 #endif // #if ENABLE(TIZEN_GESTURE)
5664 // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
5665 //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
5666 priv->pageClient->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
5674 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
5676 #if ENABLE(TOUCH_EVENTS)
5677 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5678 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5680 enabled = !!enabled;
5681 if (priv->areTouchEventsEnabled == enabled)
5684 priv->areTouchEventsEnabled = enabled;
5686 // FIXME: We have to connect touch callbacks with mouse and multi events
5687 // because the Evas creates mouse events for first touch and multi events
5688 // for second and third touches. Below codes should be fixed when the Evas
5689 // supports the touch events.
5690 // See https://bugs.webkit.org/show_bug.cgi?id=97785 for details.
5691 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down, smartData);
5692 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up, smartData);
5693 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move, smartData);
5694 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down, smartData);
5695 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up, smartData);
5696 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move, smartData);
5698 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down);
5699 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up);
5700 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move);
5701 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down);
5702 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up);
5703 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move);
5712 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
5714 #if ENABLE(TOUCH_EVENTS)
5715 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5716 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5718 return priv->areTouchEventsEnabled;
5724 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
5726 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
5727 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5728 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5730 priv->mainFrameScrollbarVisibility = visible;
5731 priv->pageClient->updateVisibility();
5739 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
5741 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
5742 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5743 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5745 return priv->mainFrameScrollbarVisibility;
5751 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
5753 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
5754 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5755 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5756 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
5758 String title = ewk_view_title_get(ewkView);
5759 String url = ewk_view_url_get(ewkView);
5760 String directoryPath(path);
5761 priv->pageClient->startOfflinePageSave(directoryPath, url, title);
5765 UNUSED_PARAM(ewkView);
5773 * Callback function used for ewk_view_page_contents_get().
5775 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
5777 EINA_SAFETY_ON_NULL_RETURN(context);
5779 RefPtr<WebData> webData = toImpl(wkData);
5780 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
5781 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
5786 * Callback function used for ewk_view_page_contents_get().
5788 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
5790 EINA_SAFETY_ON_NULL_RETURN(context);
5792 RefPtr<WebString> webString = toImpl(wkString);
5793 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
5794 contentsContext->callback(contentsContext->type, webString->string().utf8().data());
5797 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
5799 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
5800 EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
5801 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5802 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5804 switch (context->type) {
5805 case EWK_PAGE_CONTENTS_TYPE_MHTML:
5806 priv->pageClient->page()->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
5809 case EWK_PAGE_CONTENTS_TYPE_STRING:
5810 priv->pageClient->page()->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
5814 ASSERT_NOT_REACHED();
5821 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
5823 #if ENABLE(TIZEN_GESTURE)
5824 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5825 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5827 return priv->gestureClient->scrollToWithAnimation(x, y);
5829 UNUSED_PARAM(ewkView);
5836 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5837 void ewkViewFocusRingHide(Evas_Object* ewkView)
5839 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5840 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5842 if (priv->focusRing)
5843 priv->focusRing->hide();
5847 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
5849 #if ENABLE(TIZEN_CSP)
5850 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
5851 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
5853 TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
5854 priv->pageClient->page()->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));
5858 #if ENABLE(TIZEN_APPLICATION_CACHE)
5859 Eina_Bool ewkViewRequestApplicationCachePermission(Evas_Object* ewkView, WKSecurityOriginRef origin)
5861 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5862 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5864 if (!priv->applicationCachePermissionContext || !priv->applicationCachePermissionContext->applicationCachePermissionCallback)
5867 priv->isWaitingForApplicationCachePermission = true;
5868 if (priv->applicationCachePermissionOrigin)
5869 deleteSecurityOrigin(priv->applicationCachePermissionOrigin);
5870 priv->applicationCachePermissionOrigin = createSecurityOrigin(origin);
5872 return priv->applicationCachePermissionContext->applicationCachePermissionCallback(ewkView, priv->applicationCachePermissionOrigin, priv->applicationCachePermissionContext->userData) == EINA_TRUE;
5876 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
5878 #if ENABLE(TIZEN_APPLICATION_CACHE)
5879 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5880 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5882 if (!priv->applicationCachePermissionContext)
5883 priv->applicationCachePermissionContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
5884 priv->applicationCachePermissionContext->applicationCachePermissionCallback = callback;
5885 priv->applicationCachePermissionContext->userData = userData;
5887 UNUSED_PARAM(ewkView);
5888 UNUSED_PARAM(callback);
5889 UNUSED_PARAM(userData);
5893 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
5895 #if ENABLE(TIZEN_APPLICATION_CACHE)
5896 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5897 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5899 TIZEN_LOGI("allow %d", allow);
5900 WKPageReplyApplicationCachePermission(toAPI(ewk_view_page_get(ewkView)), allow);
5901 if (priv->applicationCachePermissionOrigin)
5902 deleteSecurityOrigin(priv->applicationCachePermissionOrigin);
5903 priv->applicationCachePermissionOrigin = 0;
5904 priv->isWaitingForApplicationCachePermission = false;
5906 UNUSED_PARAM(ewkView);
5907 UNUSED_PARAM(allow);