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;
339 #endif // #if OS(TIZEN)
341 _Ewk_View_Private_Data()
348 #if ENABLE(TIZEN_INPUT_COLOR_TYPE) // wait for upstream
349 , colorPickerResultListener(0)
351 #if ENABLE(TOUCH_EVENTS)
352 , areTouchEventsEnabled(false)
355 , isUsingEcoreX(false)
357 #if USE(ACCELERATED_COMPOSITING)
364 ~_Ewk_View_Private_Data()
366 eina_stringshare_del(uri);
367 eina_stringshare_del(title);
368 eina_stringshare_del(theme);
369 eina_stringshare_del(customEncoding);
370 _ewk_view_priv_loading_resources_clear(loadingResourcesMap);
373 evas_object_del(cursorObject);
375 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
376 if (compositionAnimator) {
377 ecore_animator_del(compositionAnimator);
378 compositionAnimator = 0;
386 struct _Ewk_View_Callback_Context {
388 Ewk_Web_App_Capable_Get_Callback webAppCapableCallback;
389 Ewk_Web_App_Icon_URL_Get_Callback webAppIconURLCallback;
390 Ewk_Web_App_Icon_URLs_Get_Callback webAppIconURLsCallback;
391 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
392 Ewk_Web_Storage_Quota_Get_Callback webStorageQuotaCallback;
394 Ewk_View_Script_Execute_Callback scriptExecuteCallback;
395 Ewk_View_Plain_Text_Get_Callback plainTextGetCallback;
396 #if ENABLE(TIZEN_SUPPORT_MHTML)
397 Ewk_View_MHTML_Data_Get_Callback mhtmlDataGetCallback;
399 Ewk_View_JavaScript_Alert_Callback javascriptAlertCallback;
400 Ewk_View_JavaScript_Confirm_Callback javascriptConfirmCallback;
401 Ewk_View_JavaScript_Prompt_Callback javascriptPromptCallback;
402 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
403 Ewk_View_Before_Unload_Confirm_Panel_Callback beforeUnloadConfirmPanelCallback;
405 Ewk_View_Open_Panel_Callback openPanelCallback;
408 Evas_Object* ewkView;
411 #endif // #if OS(TIZEN)
413 #define EWK_VIEW_TYPE_CHECK(ewkView, result) \
414 bool result = true; \
416 const char* _tmp_otype = evas_object_type_get(ewkView); \
417 const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
418 if (EINA_UNLIKELY(!_tmp_s)) { \
420 ("%p (%s) is not a smart object!", \
421 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
425 const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
426 if (EINA_UNLIKELY(!_tmp_sc)) { \
428 ("%p (%s) is not a smart object!", \
429 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
433 else if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \
435 ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
436 ewkView, _tmp_otype ? _tmp_otype : "(null)", \
437 EWK_VIEW_TYPE_STR, _tmp_sc->data); \
442 #define EWK_VIEW_SD_GET(ewkView, smartData) \
443 EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \
444 Ewk_View_Smart_Data* smartData = 0; \
446 smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView);
448 #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \
449 EWK_VIEW_SD_GET(ewkView, smartData); \
451 EINA_LOG_CRIT("no smart data for object %p (%s)", \
452 ewkView, evas_object_type_get(ewkView)); \
453 return __VA_ARGS__; \
456 #define EWK_VIEW_PRIV_GET(smartData, priv) \
457 Ewk_View_Private_Data* priv = smartData->priv
459 #define EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, ...) \
461 EINA_LOG_CRIT("smart data is null"); \
462 return __VA_ARGS__; \
464 EWK_VIEW_PRIV_GET(smartData, priv); \
466 EINA_LOG_CRIT("no private data for object %p (%s)", \
467 smartData->self, evas_object_type_get(smartData->self)); \
468 return __VA_ARGS__; \
471 #define EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, ...) \
473 EINA_LOG_CRIT("smart data is null"); \
474 return __VA_ARGS__; \
476 EwkViewImpl* impl = smartData->ewkViewImpl; \
479 EINA_LOG_CRIT("no private data for object %p (%s)", \
480 smartData->self, evas_object_type_get(smartData->self)); \
481 return __VA_ARGS__; \
485 #define EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, ...) \
486 EwkViewImpl* impl = 0; \
488 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, __VA_ARGS__); \
489 impl = smartData->ewkViewImpl; \
491 EINA_LOG_CRIT("no private data for object %p (%s)", \
492 smartData->self, evas_object_type_get(smartData->self)); \
493 return __VA_ARGS__; \
498 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object*, const char* alertText, void* userData);
499 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object*, const char* message, void* userData);
500 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object*, const char* message, const char* defaultValue, void* userData);
501 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
502 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object*, const char* message, void* userData);
504 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);
506 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
507 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);
508 #if ENABLE(TIZEN_MULTIPLE_SELECT)
509 Eina_Bool _ewk_view_multiple_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items);
511 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data*);
512 Eina_Bool _ewk_view_popup_menu_update(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, Eina_List*, int);
514 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
515 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations);
516 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd);
519 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
520 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data*, Ewk_Input_Type, const char* inputValue);
523 #if ENABLE(TIZEN_DATALIST_ELEMENT)
524 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data*, Ewk_Input_Type, Eina_List*);
525 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data*, Ewk_Input_Type);
528 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
529 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data*, int, int, int, int);
530 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data*);
533 #if ENABLE(TIZEN_ISF_PORT)
534 static void _ewk_view_imf_context_destroy(Ewk_View_Private_Data*);
537 #endif // #if OS(TIZEN)
539 static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
541 if (smartData->changed.any)
543 smartData->changed.any = true;
544 evas_object_smart_changed(smartData->self);
547 // Default Event Handling.
548 static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
550 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
554 priv->pageClient->setViewFocused(true);
555 #endif // #if OS(TIZEN)
556 priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
557 #if ENABLE(TIZEN_ISF_PORT)
558 if (priv->imfContext) {
559 ecore_imf_context_focus_in(priv->imfContext);
560 ecore_imf_context_input_panel_show(priv->imfContext);
566 static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
568 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
572 #if ENABLE(TIZEN_ISF_PORT)
573 // Keypad should be hidden rapidly when moving focus on elementary
574 // because Ecore-ime doesn't support it.
575 if (priv->imfContext) {
576 ecore_imf_context_input_panel_hide(priv->imfContext);
577 ecore_imf_context_focus_out(priv->imfContext);
581 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
582 if (priv->pageClient->isTextSelectionMode())
583 priv->pageClient->setIsTextSelectionMode(false);
586 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
587 if (priv->pageClient->isContextMenuVisible())
588 priv->pageClient->page()->hideContextMenu();
591 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
592 priv->pageClient->clearClipboardSelectionHandler();
595 #if ENABLE(TIZEN_DRAG_SUPPORT)
596 if (priv->pageClient->isDragMode())
597 priv->pageClient->setDragMode(false);
600 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
601 if (smartData->api->formdata_candidate_is_showing(smartData))
602 smartData->api->formdata_candidate_hide(smartData);
605 priv->pageClient->setViewFocused(false);
606 #endif // #if OS(TIZEN)
607 priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
611 static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
613 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
614 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
616 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
617 //impl->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
618 priv->pageClient->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
622 static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
624 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
625 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
627 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
628 //impl->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
629 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
633 static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
635 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
636 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
638 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
639 //impl->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
640 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
644 static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
646 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
647 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
649 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
650 //impl->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
651 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
655 static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
657 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
659 #if ENABLE(TIZEN_ISF_PORT)
660 Ecore_IMF_Event IMFEvent;
661 ecore_imf_evas_event_key_down_wrap(const_cast<Evas_Event_Key_Down*>(downEvent), &IMFEvent.key_down);
662 bool filtered = ecore_imf_context_filter_event(priv->imfContext, ECORE_IMF_EVENT_KEY_DOWN, &IMFEvent);
664 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, filtered));
666 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent));
667 #endif // #if ENABLE(TIZEN_ISF_PORT)
671 static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
673 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
675 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
680 static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
682 #if ENABLE(TIZEN_GESTURE)
683 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
684 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
686 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
687 if (priv->pageClient->isTextSelectionMode() && priv->pageClient->isTextSelectionHandleDowned())
691 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
692 if (priv->focusRing) {
693 if (event->type == EWK_GESTURE_TAP && event->count == 1) {
694 priv->focusRing->requestToShow(IntPoint(event->position.x, event->position.y));
695 } else if (event->type == EWK_GESTURE_PAN) {
696 if (priv->exceedTouchMoveThreshold)
697 priv->focusRing->hide();
699 if (event->type != EWK_GESTURE_LONG_PRESS) {
700 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
701 if (!priv->pageClient->isContextMenuVisible())
703 priv->focusRing->hide();
709 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
710 if (smartData->api->formdata_candidate_is_showing(smartData))
711 smartData->api->formdata_candidate_hide(smartData);
714 switch (event->type) {
715 case EWK_GESTURE_TAP:
716 priv->gestureClient->startTap(IntPoint(event->position.x, event->position.y));
718 case EWK_GESTURE_LONG_PRESS: {
719 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
720 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
721 if (ewk_settings_text_selection_enabled_get(priv->settings.get()))
722 priv->pageClient->setIsTextSelectionMode(false);
724 IntPoint scenePoint(event->position.x, event->position.y);
725 IntPoint contentsPoint = impl->transformFromScene().mapPoint(scenePoint);
726 WebHitTestResult::Data hitTestResultData = priv->pageClient->page()->hitTestResultAtPoint(contentsPoint);
727 #if ENABLE(TIZEN_DRAG_SUPPORT)
728 // 1. Check to start dragging.
729 if (hitTestResultData.isDragSupport) {
730 priv->pageClient->setDragPoint(scenePoint);
731 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
733 priv->focusRing->show(IntRect(), true);
735 priv->gestureClient->showContextMenu(scenePoint);
739 // 2. Check to show context menu.
740 if (!hitTestResultData.absoluteImageURL.isEmpty()
741 || !hitTestResultData.absoluteLinkURL.isEmpty()
742 || !hitTestResultData.absoluteMediaURL.isEmpty()) {
743 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
745 priv->focusRing->show(IntRect(), true);
747 priv->gestureClient->showContextMenu(scenePoint);
750 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
751 // 3. Check for text selection.
752 if (ewk_settings_text_selection_enabled_get(priv->settings.get())) {
753 // Process gesture_end(EWK_GESTURE_TAP) to activate the editing if node under point is editable.
754 if (hitTestResultData.context & WebHitTestResult::HitTestResultContextEditable) {
755 if (smartData->api && smartData->api->gesture_end) {
756 Ewk_Event_Gesture tapEvent = {EWK_GESTURE_TAP, event->position, {0, 0}, 0, 1, ecore_time_get() * 1000};
757 smartData->api->gesture_end(smartData, &tapEvent);
761 if (priv->pageClient->textSelectionDown(scenePoint)) {
762 priv->gestureClient->setGestureEnabled(false);
763 ewkViewHandleTouchEvent(smartData->self, EWK_TOUCH_CANCEL);
768 #endif // #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
770 case EWK_GESTURE_PAN:
771 priv->gestureClient->startPan(IntPoint(event->position.x, event->position.y));
773 case EWK_GESTURE_FLICK:
774 priv->gestureClient->startFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
776 case EWK_GESTURE_PINCH:
777 if (priv->pageClient->viewportConstraints().userScalable)
778 priv->gestureClient->startPinch(IntPoint(event->position.x, event->position.y), event->scale);
781 ASSERT_NOT_REACHED();
788 #endif // #if ENABLE(TIZEN_GESTURE)
791 static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
793 #if ENABLE(TIZEN_GESTURE)
794 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
796 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
797 if (priv->pageClient->isTextSelectionMode() && priv->pageClient->isTextSelectionHandleDowned())
801 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
802 if (priv->focusRing) {
803 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
804 if (!priv->pageClient->isContextMenuVisible())
806 priv->focusRing->hide();
810 switch (event->type) {
811 case EWK_GESTURE_TAP:
812 if (event->count == 1) {
813 #if ENABLE(TIZEN_DRAG_SUPPORT)
814 if (priv->pageClient->isDragMode())
815 priv->pageClient->setDragMode(false);
817 priv->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
818 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
819 if (priv->pageClient->isTextSelectionMode())
820 priv->pageClient->setIsTextSelectionMode(false);
822 #if ENABLE(TIZEN_ISF_PORT)
823 evas_object_focus_set(smartData->self, true);
825 } else if (event->count == 2)
826 priv->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
828 case EWK_GESTURE_LONG_PRESS:
829 #if ENABLE(TIZEN_DRAG_SUPPORT)
830 if (priv->pageClient->isDragMode())
831 priv->pageClient->setDragMode(false);
833 // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
834 priv->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
836 case EWK_GESTURE_PAN:
837 priv->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
839 case EWK_GESTURE_FLICK:
840 priv->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
842 case EWK_GESTURE_PINCH:
843 priv->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
846 ASSERT_NOT_REACHED();
853 #endif // #if ENABLE(TIZEN_GESTURE)
856 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
858 #if ENABLE(TIZEN_GESTURE)
859 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
861 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
862 if (priv->pageClient->isTextSelectionMode() && priv->pageClient->isTextSelectionHandleDowned())
866 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
867 if (priv->focusRing && !(event->type == EWK_GESTURE_PAN && !priv->exceedTouchMoveThreshold))
868 priv->focusRing->hide();
871 switch (event->type) {
872 case EWK_GESTURE_PAN:
873 priv->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
875 case EWK_GESTURE_TAP:
876 case EWK_GESTURE_LONG_PRESS:
877 case EWK_GESTURE_FLICK:
879 case EWK_GESTURE_PINCH:
880 if (priv->pageClient->viewportConstraints().userScalable)
881 priv->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
884 ASSERT_NOT_REACHED();
891 #endif // #if ENABLE(TIZEN_GESTURE)
893 #endif //#if OS(TIZEN)
896 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
898 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
899 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
900 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
901 smartData->api->focus_in(smartData);
904 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
906 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
907 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
908 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
909 smartData->api->focus_out(smartData);
912 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
914 Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(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->mouse_wheel);
918 smartData->api->mouse_wheel(smartData, wheelEvent);
921 static void _ewk_view_on_mouse_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
923 Evas_Event_Mouse_Down* downEvent = static_cast<Evas_Event_Mouse_Down*>(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_down);
927 smartData->api->mouse_down(smartData, downEvent);
930 static void _ewk_view_on_mouse_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
932 Evas_Event_Mouse_Up* upEvent = static_cast<Evas_Event_Mouse_Up*>(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_up);
936 smartData->api->mouse_up(smartData, upEvent);
939 static void _ewk_view_on_mouse_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
941 Evas_Event_Mouse_Move* moveEvent = static_cast<Evas_Event_Mouse_Move*>(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_move);
945 smartData->api->mouse_move(smartData, moveEvent);
948 static void _ewk_view_on_key_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
950 Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(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->key_down);
954 smartData->api->key_down(smartData, downEvent);
957 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
959 Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(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_up);
963 smartData->api->key_up(smartData, upEvent);
966 #if ENABLE(TOUCH_EVENTS)
967 static inline void _ewk_view_feed_touch_event_using_touch_point_list_of_evas(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
969 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
971 unsigned count = evas_touch_point_list_count(smartData->base.evas);
975 Eina_List* points = 0;
976 for (unsigned i = 0; i < count; ++i) {
977 Ewk_Touch_Point* point = new Ewk_Touch_Point;
978 point->id = evas_touch_point_list_nth_id_get(smartData->base.evas, i);
979 evas_touch_point_list_nth_xy_get(smartData->base.evas, i, &point->x, &point->y);
980 point->state = evas_touch_point_list_nth_state_get(smartData->base.evas, i);
981 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_GESTURE)
982 if (type == EWK_TOUCH_CANCEL)
983 point->state = EVAS_TOUCH_POINT_CANCEL;
985 points = eina_list_append(points, point);
988 ewk_view_feed_touch_event(ewkView, type, points, evas_key_modifier_get(smartData->base.evas));
991 EINA_LIST_FREE(points, data)
992 delete static_cast<Ewk_Touch_Point*>(data);
995 static void _ewk_view_on_touch_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
997 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_START);
1000 static void _ewk_view_on_touch_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
1002 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_END);
1005 static void _ewk_view_on_touch_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
1007 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_MOVE);
1011 void ewkViewHandleTouchEvent(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
1013 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, type);
1019 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1020 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
1022 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1024 return priv->pageClient->textSelectionDown(IntPoint(x, y), true);
1027 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
1029 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1031 IntPoint point(x, y);
1032 priv->pageClient->textSelectionMove(point, true);
1037 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
1039 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1041 IntPoint point(x, y);
1042 priv->pageClient->textSelectionUp(point, true);
1048 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1049 static void _ewk_view_data_list_del(Eina_List* dataList)
1051 EINA_SAFETY_ON_NULL_RETURN(dataList);
1054 EINA_LIST_FREE(dataList, item)
1055 eina_stringshare_del(static_cast<char*>(item));
1059 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1060 Eina_Bool _ewk_view_smart_formdata_candidate_show(Ewk_View_Smart_Data* smartData, int x, int y, int w, int h)
1062 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1064 priv->pageClient->showFormDataCandidate(IntRect(x, y, w, h));
1069 Eina_Bool _ewk_view_smart_formdata_candidate_hide(Ewk_View_Smart_Data* smartData)
1071 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1073 priv->pageClient->hideFormDataCandidate();
1078 Eina_Bool _ewk_view_smart_formdata_candidate_update_data(Ewk_View_Smart_Data* smartData, Eina_List* dataList)
1080 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1082 Vector<String> formData;
1085 EINA_LIST_FOREACH(dataList, list, data)
1086 formData.append(String::fromUTF8(static_cast<char*>(data)));
1088 priv->pageClient->updateFormDataCandidate(formData);
1093 Eina_Bool _ewk_view_smart_formdata_candidate_is_showing(Ewk_View_Smart_Data* smartData)
1095 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1097 return priv->pageClient->isShowingFormDataCandidate();
1101 #if ENABLE(TIZEN_SCREEN_READER)
1102 Eina_Bool _ewk_view_screen_reader_command_execute(Ewk_View_Smart_Data* smartData, unsigned int command, int data1, int data2)
1104 return ScreenReaderProxy::screenReader().executeCommand(smartData->self, command, data1, data2);
1107 #endif // #if OS(TIZEN)
1109 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
1111 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1112 static uint64_t generatePageGroupIdentifierID()
1114 static uint64_t uniquePageGroupIdentifierID = 1;
1115 return uniquePageGroupIdentifierID++;
1119 static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
1121 Ewk_View_Private_Data* priv = new Ewk_View_Private_Data;
1122 memset(priv, 0, sizeof(Ewk_View_Private_Data)); // FIXME : below code should be considered to move to constructor.
1124 priv->areMouseEventsEnabled = false;
1126 priv->javascriptPopup = adoptPtr<JavaScriptPopup>(new JavaScriptPopup(smartData->self));
1127 priv->openPanel = adoptPtr<OpenPanel>(new OpenPanel(smartData->self));
1129 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1130 priv->inputPicker = adoptPtr<InputPicker>(new InputPicker(smartData->self));
1131 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1133 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1134 priv->focusRing = FocusRing::create(smartData->self);
1135 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1137 #if ENABLE(TIZEN_GESTURE)
1138 priv->gestureRecognizer = GestureRecognizer::create(smartData->self);
1139 priv->gestureClient = GestureClient::create(smartData->ewkViewImpl);
1140 #endif // #if ENABLE(TIZEN_GESTURE)
1141 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1142 const char* hideScrollbar = getenv("TIZEN_WEBKIT2_TILED_SCROLLBAR_HIDE");
1143 if (hideScrollbar && atoi(hideScrollbar) == 1)
1144 priv->mainFrameScrollbarVisibility = false;
1146 priv->mainFrameScrollbarVisibility = true;
1149 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1153 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1154 String pageGroupIdentifierID = String::number(generatePageGroupIdentifierID());
1155 String pageGroupIdentifier = String::format("PageGroup%s", pageGroupIdentifierID.utf8().data());
1157 WKRetainPtr<WKStringRef> pageGroupIdentifierRef(AdoptWK, WKStringCreateWithUTF8CString(pageGroupIdentifier.utf8().data()));
1158 priv->pageGroup = WebPageGroup::create(toWTFString(pageGroupIdentifierRef.get()));
1161 priv->suspendRequested = false;
1162 priv->suspendedPainting = false;
1163 priv->suspendedResources = false;
1164 #endif // #if OS(TIZEN)
1167 priv->isUsingEcoreX = WebCore::isUsingEcoreX(smartData->base.evas);
1173 static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap)
1175 // Clear the loadingResources HashMap.
1176 LoadingResourcesMap::iterator it = loadingResourcesMap.begin();
1177 LoadingResourcesMap::iterator end = loadingResourcesMap.end();
1178 for ( ; it != end; ++it)
1179 ewk_web_resource_unref(it->second);
1181 loadingResourcesMap.clear();
1184 static void _ewk_view_priv_del(Ewk_View_Private_Data* priv)
1190 if (priv->javascriptGlobalContext)
1191 JSGlobalContextRelease(priv->javascriptGlobalContext);
1193 eina_stringshare_del(priv->userAgent);
1194 eina_stringshare_del(priv->encoding);
1195 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1196 eina_stringshare_del(priv->webAppIconURL);
1197 if (priv->webAppIconURLs) {
1199 EINA_LIST_FREE(priv->webAppIconURLs, data)
1200 ewkWebAppIconDataDelete(static_cast<Ewk_Web_App_Icon_Data*>(data));
1204 if (priv->authChallenge)
1205 ewkAuthChallengeDelete(priv->authChallenge);
1206 if (priv->policyDecision)
1207 ewkPolicyDecisionDelete(priv->policyDecision);
1209 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1210 if (priv->certificatePolicyDecision)
1211 ewkCertificatePolicyDecisionDelete(priv->certificatePolicyDecision);
1214 #if ENABLE(TIZEN_MEDIA_STREAM)
1215 if (priv->userMediaPermissionRequests)
1216 ewkUserMediaDeletePermissionRequestList(priv->userMediaPermissionRequests);
1219 priv->openPanelListener = 0;
1220 priv->openPanel = nullptr;
1221 priv->javascriptPopup = nullptr;
1222 priv->alertContext = nullptr;
1223 priv->confirmContext = nullptr;
1224 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1225 priv->beforeUnloadConfirmPanelContext = nullptr;
1227 priv->promptContext = nullptr;
1228 priv->isWaitingForJavaScriptPopupReply = false;
1229 priv->openpanelContext = nullptr;
1230 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1231 priv->inputPicker = nullptr;
1232 eina_stringshare_del(priv->inputValue);
1235 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1236 if (priv->dataList) {
1237 _ewk_view_data_list_del(priv->dataList);
1242 #if ENABLE(TIZEN_GEOLOCATION)
1243 if (priv->geolocation)
1244 ewkGeolocationDeleteGeolocation(priv->geolocation);
1245 if (priv->geolocationPermissionRequests)
1246 ewkGeolocationDeletePermissionRequestList(priv->geolocationPermissionRequests);
1249 #if ENABLE(TIZEN_NOTIFICATIONS)
1250 if (priv->notifications)
1251 ewkNotificationDeleteNotificationList(priv->notifications);
1252 if (priv->notificationPermissionRequests)
1253 ewkNotificationDeletePermissionRequestList(priv->notificationPermissionRequests);
1255 #if ENABLE(TIZEN_SQL_DATABASE)
1256 if (priv->exceededDatabaseQuota)
1257 ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
1259 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1260 priv->focusRing = nullptr;
1261 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1262 #if ENABLE(TIZEN_GESTURE)
1263 priv->gestureRecognizer = nullptr;
1264 priv->gestureClient = nullptr;
1265 #endif // #if ENABLE(TIZEN_GESTURE)
1267 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1268 eina_stringshare_del(priv->selectedText);
1270 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1271 priv->pageGroup = nullptr;
1274 #if ENABLE(TIZEN_ISF_PORT)
1275 _ewk_view_imf_context_destroy(priv);
1277 #endif // #if OS(TIZEN)
1282 static void _ewk_view_smart_add(Evas_Object* ewkView)
1284 const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
1285 const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
1286 const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
1287 EWK_VIEW_SD_GET(ewkView, smartData);
1290 smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
1292 EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
1295 evas_object_smart_data_set(ewkView, smartData);
1298 smartData->self = ewkView;
1299 smartData->api = api;
1301 g_parentSmartClass.add(ewkView);
1303 // FIXME: Ewk_View_Private_Data was replaced with EwkViewImpl in the webkit opensource.
1304 // So, we have both Ewk_View_Private_Data and EwkViewImpl now,
1305 // but Ewk_View_Private_Data should be removed later.
1306 smartData->ewkViewImpl = new EwkViewImpl(ewkView);
1307 smartData->priv = _ewk_view_priv_new(smartData);
1309 // Create evas_object_image to draw web contents.
1310 smartData->image = evas_object_image_add(smartData->base.evas);
1311 evas_object_image_alpha_set(smartData->image, false);
1312 evas_object_image_filled_set(smartData->image, true);
1313 evas_object_smart_member_add(smartData->image, ewkView);
1316 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1317 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
1318 const char *engine = ecore_evas_engine_name_get(ee);
1319 if (engine && !strcmp(engine, "opengl_x11"))
1320 evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
1322 ewk_view_mouse_events_enabled_set(ewkView, false);
1323 ewk_view_touch_events_enabled_set(ewkView, true);
1325 // FIXME: This code should be removed if side effect occur.
1326 // WebView does not have focus after url loading.
1327 // If focus is set as true to webview,
1328 // elementary steal webview's focus during mouse up event
1329 // So, added code that events are not propagated to smart parent according to guide from EFL
1330 evas_object_propagate_events_set(ewkView, false);
1332 #if ENABLE(TIZEN_SCREEN_READER)
1333 ScreenReaderProxy::screenReader().addView(ewkView);
1335 #endif // #if OS(TIZEN)
1337 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
1338 CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
1339 CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
1340 CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
1342 CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
1343 CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
1344 CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
1346 CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
1347 CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
1351 static void _ewk_view_smart_del(Evas_Object* ewkView)
1353 EWK_VIEW_SD_GET(ewkView, smartData);
1354 #if ENABLE(TIZEN_SCREEN_READER)
1355 ScreenReaderProxy::screenReader().removeView(ewkView);
1357 if (smartData && smartData->priv) {
1358 _ewk_view_priv_del(smartData->priv);
1359 smartData->priv = 0;
1362 // FIXME: Ewk_View_Private_Data was replaced with EwkViewImpl in the webkit opensource.
1363 // If then, ewkViewImpl will be changed to priv.
1365 delete smartData->ewkViewImpl;
1367 g_parentSmartClass.del(ewkView);
1370 static Eina_Bool _ewk_view_composite(void* data);
1372 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
1374 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1376 evas_object_resize(smartData->image, width, height);
1377 evas_object_image_size_set(smartData->image, width, height);
1378 evas_object_image_fill_set(smartData->image, 0, 0, width, height);
1380 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1381 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1382 evas_object_image_native_surface_set(smartData->image, 0);
1384 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1385 if (!ewk_view_is_opengl_backend(ewkView))
1386 _ewk_view_composite(smartData);
1387 else // OpenGL backend
1389 priv->pageClient->displayViewport();
1391 #endif // #if OS(TIZEN)
1393 smartData->changed.size = true;
1394 _ewk_view_smart_changed(smartData);
1397 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
1399 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1401 smartData->changed.position = true;
1402 _ewk_view_smart_changed(smartData);
1405 IntSize ewk_view_size_get(const Evas_Object* ewkView)
1408 evas_object_geometry_get(ewkView, 0, 0, &width, &height);
1409 return IntSize(width, height);
1412 #if USE(ACCELERATED_COMPOSITING)
1413 static bool ewk_view_create_gl_surface(const Evas_Object* ewkView, const IntSize& viewSize)
1415 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1416 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1418 Evas_GL_Config evasGlConfig = {
1420 EVAS_GL_DEPTH_BIT_8,
1421 EVAS_GL_STENCIL_NONE,
1422 EVAS_GL_OPTIONS_NONE,
1423 EVAS_GL_MULTISAMPLE_NONE
1426 ASSERT(!priv->evasGlSurface);
1427 priv->evasGlSurface = evas_gl_surface_create(priv->evasGl, &evasGlConfig, viewSize.width(), viewSize.height());
1428 if (!priv->evasGlSurface)
1431 Evas_Native_Surface nativeSurface;
1432 evas_gl_native_surface_get(priv->evasGl, priv->evasGlSurface, &nativeSurface);
1433 evas_object_image_native_surface_set(smartData->image, &nativeSurface);
1438 bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView)
1440 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1441 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1443 EINA_SAFETY_ON_TRUE_RETURN_VAL(!!priv->evasGl, false);
1445 Evas* evas = evas_object_evas_get(ewkView);
1446 priv->evasGl = evas_gl_new(evas);
1450 priv->evasGlContext = evas_gl_context_create(priv->evasGl, 0);
1451 if (!priv->evasGlContext) {
1452 evas_gl_free(priv->evasGl);
1457 if (!ewk_view_create_gl_surface(ewkView, ewk_view_size_get(ewkView))) {
1458 evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
1459 priv->evasGlContext = 0;
1461 evas_gl_free(priv->evasGl);
1469 bool ewk_view_accelerated_compositing_mode_exit(const Evas_Object* ewkView)
1471 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1472 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1474 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->evasGl, false);
1476 if (priv->evasGlSurface) {
1477 evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
1478 priv->evasGlSurface = 0;
1481 if (priv->evasGlContext) {
1482 evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
1483 priv->evasGlContext = 0;
1486 evas_gl_free(priv->evasGl);
1493 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
1495 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1496 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1497 Evas_Coord x, y, width, height;
1499 smartData->changed.any = false;
1501 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
1503 if (smartData->changed.size) {
1505 if (priv->pageClient->page()->drawingArea())
1506 priv->pageClient->page()->drawingArea()->setSize(IntSize(width, height), IntSize());
1508 #if USE(ACCELERATED_COMPOSITING)
1509 if (!priv->evasGlSurface)
1511 evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
1512 priv->evasGlSurface = 0;
1513 ewk_view_create_gl_surface(ewkView, IntSize(width, height));
1514 ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
1516 #endif // #if !OS(TIZEN)
1518 smartData->view.w = width;
1519 smartData->view.h = height;
1520 smartData->changed.size = false;
1523 if (priv->pageClient) {
1524 if (DrawingAreaProxy* drawingArea = priv->pageClient->page()->drawingArea()) {
1525 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1526 if (priv->pageClient->page()->isViewVisible())
1527 drawingArea->setSize(IntSize(width, height), IntSize());
1529 drawingArea->setSize(IntSize(width, height), IntSize());
1531 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1532 priv->pageClient->updateViewportSize(IntSize(width, height));
1533 if (ewk_view_is_opengl_backend(ewkView))
1534 priv->pageClient->displayViewport();
1537 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1538 priv->pageClient->frameRectChanged();
1541 #endif // #if OS(TIZEN)
1544 if (smartData->changed.position) {
1545 evas_object_move(smartData->image, x, y);
1546 smartData->view.x = x;
1547 smartData->view.y = y;
1548 smartData->changed.position = false;
1550 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1551 priv->pageClient->frameRectChanged();
1553 #if ENABLE(TIZEN_SCREEN_READER)
1554 priv->pageClient->page()->recalcScreenReaderFocusRect();
1556 #endif // #if OS(TIZEN)
1559 if (priv->popupPicker)
1560 ewk_popup_picker_resize(priv->popupPicker);
1561 #endif // #if OS(TIZEN)
1564 static void _ewk_view_smart_show(Evas_Object* ewkView)
1566 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1567 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1569 if (evas_object_clipees_get(smartData->base.clipper))
1570 evas_object_show(smartData->base.clipper);
1571 evas_object_show(smartData->image);
1574 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1576 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1578 evas_object_hide(smartData->base.clipper);
1579 evas_object_hide(smartData->image);
1580 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1581 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1582 if (priv->pageClient->isTextSelectionMode())
1583 priv->pageClient->setIsTextSelectionMode(false);
1587 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1589 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1590 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1594 else if (alpha > 255)
1597 #define CHECK_COLOR(color, alpha) \
1600 else if (color > alpha) \
1602 CHECK_COLOR(red, alpha);
1603 CHECK_COLOR(green, alpha);
1604 CHECK_COLOR(blue, alpha);
1607 evas_object_image_alpha_set(smartData->image, alpha < 255);
1608 priv->pageClient->page()->setDrawsBackground(red || green || blue);
1609 priv->pageClient->page()->setDrawsTransparentBackground(alpha < 255);
1610 priv->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1613 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1617 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1619 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1621 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1622 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1623 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1627 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1628 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1630 evas_object_smart_clipped_smart_set(&api->sc);
1632 // Set Evas_Smart_Class functions.
1633 api->sc.add = _ewk_view_smart_add;
1634 api->sc.del = _ewk_view_smart_del;
1635 api->sc.move = _ewk_view_smart_move;
1636 api->sc.resize = _ewk_view_smart_resize;
1637 api->sc.show = _ewk_view_smart_show;
1638 api->sc.hide = _ewk_view_smart_hide;
1639 api->sc.color_set = _ewk_view_smart_color_set;
1640 api->sc.calculate = _ewk_view_smart_calculate;
1641 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1643 // Set Ewk_View_Smart_Class functions.
1644 api->focus_in = _ewk_view_smart_focus_in;
1645 api->focus_out = _ewk_view_smart_focus_out;
1646 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1647 api->mouse_down = _ewk_view_smart_mouse_down;
1648 api->mouse_up = _ewk_view_smart_mouse_up;
1649 api->mouse_move = _ewk_view_smart_mouse_move;
1650 api->key_down = _ewk_view_smart_key_down;
1651 api->key_up = _ewk_view_smart_key_up;
1653 api->gesture_start = _ewk_view_smart_gesture_start;
1654 api->gesture_end = _ewk_view_smart_gesture_end;
1655 api->gesture_move = _ewk_view_smart_gesture_move;
1657 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1658 api->popup_menu_show = _ewk_view_popup_menu_show;
1659 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1660 api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1662 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1663 api->popup_menu_update = _ewk_view_popup_menu_update;
1665 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1666 api->text_selection_down = _ewk_view_text_selection_down;
1667 api->text_selection_move = _ewk_view_text_selection_move;
1668 api->text_selection_up = _ewk_view_text_selection_up;
1670 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1671 api->input_picker_show = _ewk_view_input_picker_show;
1673 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1674 api->data_list_show = _ewk_view_data_list_show;
1675 api->data_list_hide = _ewk_view_data_list_hide;
1677 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1678 api->orientation_lock = _ewk_orientation_lock;
1679 api->orientation_unlock = _ewk_orientation_unlock;
1681 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1682 api->input_picker_color_request = _ewk_input_picker_color_request;
1683 api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1685 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1686 api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1687 api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1688 api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1689 api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1691 #if ENABLE(TIZEN_SCREEN_READER)
1692 api->screen_reader_command_execute = _ewk_view_screen_reader_command_execute;
1694 #endif //#if OS(TIZEN)
1699 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1701 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1702 static Evas_Smart* smart = 0;
1704 if (EINA_UNLIKELY(!smart)) {
1705 ewk_view_smart_class_set(&api);
1706 smart = evas_smart_class_new(&api.sc);
1712 static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKPageGroupRef pageGroupRef)
1714 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1715 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
1716 EINA_SAFETY_ON_NULL_RETURN(context);
1718 if (priv->pageClient)
1721 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1722 if (ewk_view_is_opengl_backend(ewkView)) {
1723 priv->pageClient = PageClientEvasGL::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1724 priv->pageClient->page()->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1727 priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1728 priv->pageClient->page()->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1729 priv->pageClient->page()->pageGroup()->preferences()->setWebGLEnabled(false);
1730 priv->pageClient->page()->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1733 priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1735 // FixMe: Comment should be removed when pageClient is removed.
1736 //priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageProxy.get())))));
1737 priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageClient->page())))));
1740 priv->context = context;
1742 ewkViewContextMenuClientAttachClient(ewkView);
1743 ewkViewFindClientAttatchClient(ewkView);
1744 ewkViewTizenClientAttachClient(ewkView);
1745 ewkViewUIClientAttatchClient(ewkView);
1747 #if ENABLE(TIZEN_GEOLOCATION)
1748 ewkViewGeolocationProviderAttachProvider(ewkView, ewk_context_WKContext_get(context));
1751 #if ENABLE(TIZEN_NOTIFICATIONS)
1752 ewkViewNotificationProviderAttachProvider(ewkView, ewk_context_WKContext_get(context));
1755 #if ENABLE(TIZEN_ICON_DATABASE)
1756 ewk_view_icondatabase_client_attach(ewkView, ewk_context_WKContext_get(context));
1759 ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1760 ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1761 ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1762 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1763 ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1765 ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1766 #else // #if OS(TIZEN)
1767 priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageClient->page()->backForwardList()));
1769 #if USE(COORDINATED_GRAPHICS)
1770 priv->viewportHandler = EflViewportHandler::create(priv->pageClient.get());
1772 #endif // #if OS(TIZEN)
1774 WKPageRef wkPage = toAPI(priv->pageClient->page());
1775 ewk_view_form_client_attach(wkPage, ewkView);
1776 ewk_view_loader_client_attach(wkPage, ewkView);
1777 ewk_view_policy_client_attach(wkPage, ewkView);
1778 ewk_view_resource_load_client_attach(wkPage, ewkView);
1780 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1781 ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1784 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1785 if (!ewk_context_x_window_get(context))
1786 ewk_context_x_window_set(context, elm_win_xwindow_get(ewkView));
1790 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1792 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1793 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1795 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1796 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1797 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1802 Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1806 EWK_VIEW_SD_GET(ewkView, smartData);
1808 evas_object_del(ewkView);
1812 EWK_VIEW_PRIV_GET(smartData, priv);
1814 evas_object_del(ewkView);
1823 * Constructs a ewk_view Evas_Object with WKType parameters.
1825 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1827 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1828 EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1830 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1834 _ewk_view_initialize(ewkView, ewk_context_new_from_WKContext(contextRef), pageGroupRef);
1839 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1841 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1842 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1843 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1845 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1849 #if ENABLE(TIZEN_ICON_DATABASE)
1850 //set default iconDatabasePath
1851 WKContextRef contextRef = ewk_context_WKContext_get(context);
1852 toImpl(contextRef)->setIconDatabasePath(toImpl(contextRef)->iconDatabasePath());
1855 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1856 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1857 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1858 _ewk_view_initialize(ewkView, context, toAPI(priv->pageGroup.get()));
1860 _ewk_view_initialize(ewkView, context, 0);
1866 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1868 return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1871 Evas_Object* ewk_view_add(Evas* canvas)
1873 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1878 * The uri of view was changed by the frame loader.
1880 * Emits signal: "uri,changed" with pointer to new uri string.
1882 void ewk_view_uri_update(Evas_Object* ewkView)
1884 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1885 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1887 String activeURL = priv->pageClient->page()->activeURL();
1888 if (activeURL.isEmpty())
1891 if (!eina_stringshare_replace(&priv->uri, activeURL.utf8().data()))
1894 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1895 evas_object_smart_callback_call(ewkView, "url,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1898 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* uri)
1900 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1901 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1902 EINA_SAFETY_ON_NULL_RETURN_VAL(uri, false);
1904 priv->pageClient->page()->loadURL(String::fromUTF8(uri));
1905 ewk_view_uri_update(ewkView);
1910 const char* ewk_view_url_get(const Evas_Object* ewkView)
1912 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1913 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1918 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1920 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1921 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1923 priv->pageClient->page()->reload(/*reloadFromOrigin*/ false);
1924 ewk_view_uri_update(ewkView);
1929 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1931 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1932 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1934 priv->pageClient->page()->reload(/*reloadFromOrigin*/ true);
1935 ewk_view_uri_update(ewkView);
1940 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1942 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1943 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1945 priv->pageClient->page()->stopLoading();
1950 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1952 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1953 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1955 return priv->settings.get();
1960 * Load was initiated for a resource in the view.
1962 * Emits signal: "resource,request,new" with pointer to resource request.
1964 void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request)
1966 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1967 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1969 Ewk_Web_Resource_Request resourceRequest = {resource, request, 0};
1971 // Keep the resource internally to reuse it later.
1972 ewk_web_resource_ref(resource);
1973 priv->loadingResourcesMap.add(resourceIdentifier, resource);
1975 evas_object_smart_callback_call(ewkView, "resource,request,new", &resourceRequest);
1980 * Received a response to a resource load request in the view.
1982 * Emits signal: "resource,request,response" with pointer to resource response.
1984 void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response)
1986 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1987 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1989 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
1992 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
1993 Ewk_Web_Resource_Load_Response resourceLoadResponse = {resource, response};
1994 evas_object_smart_callback_call(ewkView, "resource,request,response", &resourceLoadResponse);
1999 * Failed loading a resource in the view.
2001 * Emits signal: "resource,request,finished" with pointer to the resource load error.
2003 void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Error* error)
2005 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2006 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2008 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2011 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
2012 Ewk_Web_Resource_Load_Error resourceLoadError = {resource, error};
2013 evas_object_smart_callback_call(ewkView, "resource,request,failed", &resourceLoadError);
2018 * Finished loading a resource in the view.
2020 * Emits signal: "resource,request,finished" with pointer to the resource.
2022 void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIdentifier)
2024 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2025 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2027 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2030 Ewk_Web_Resource* resource = priv->loadingResourcesMap.take(resourceIdentifier);
2031 evas_object_smart_callback_call(ewkView, "resource,request,finished", resource);
2033 ewk_web_resource_unref(resource);
2038 * Request was sent for a resource in the view.
2040 * Emits signal: "resource,request,sent" with pointer to resource request and possible redirect response.
2042 void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse)
2044 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2045 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2047 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2050 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
2051 Ewk_Web_Resource_Request resourceRequest = {resource, request, redirectResponse};
2053 evas_object_smart_callback_call(ewkView, "resource,request,sent", &resourceRequest);
2056 const char* ewk_view_title_get(const Evas_Object* ewkView)
2058 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2059 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2061 CString title = priv->pageClient->page()->pageTitle().utf8();
2062 eina_stringshare_replace(&priv->title, title.data());
2069 * Reports that the requested text was found.
2071 * Emits signal: "text,found" with the number of matches.
2073 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
2075 evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
2080 * The view title was changed by the frame loader.
2082 * Emits signal: "title,changed" with pointer to new title string.
2084 void ewk_view_title_changed(Evas_Object* ewkView, const char* title)
2086 evas_object_smart_callback_call(ewkView, "title,changed", const_cast<char*>(title));
2089 double ewk_view_load_progress_get(const Evas_Object* ewkView)
2091 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2092 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2094 return priv->pageClient->page()->estimatedProgress();
2097 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
2099 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2100 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2106 scaleFactor = priv->pageClient->adjustScaleWithViewport(scaleFactor);
2108 IntPoint scrollPosition = priv->pageClient->scrollPosition();
2109 double scaleDifference = scaleFactor / priv->pageClient->scaleFactor();
2110 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
2111 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
2113 priv->pageClient->page()->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
2115 priv->pageClient->page()->scalePage(scaleFactor, IntPoint(x, y));
2120 double ewk_view_scale_get(const Evas_Object* ewkView)
2122 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
2123 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1);
2126 return priv->pageClient->page()->scaleFactor();
2128 return priv->pageClient->page()->pageScaleFactor();
2132 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
2134 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2135 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2137 priv->pageClient->page()->setCustomDeviceScaleFactor(ratio);
2142 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
2144 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2145 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2147 return priv->pageClient->page()->deviceScaleFactor();
2150 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
2151 void ewk_view_load_progress_started(Evas_Object* ewkView)
2153 evas_object_smart_callback_call(ewkView, "load,progress,started", 0);
2159 * Reports load progress changed.
2161 * Emits signal: "load,progress" with pointer to a double from 0.0 to 1.0.
2163 void ewk_view_load_progress_changed(Evas_Object* ewkView, double progress)
2165 evas_object_smart_callback_call(ewkView, "load,progress", &progress);
2168 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
2169 void ewk_view_load_progress_finished(Evas_Object* ewkView)
2171 evas_object_smart_callback_call(ewkView, "load,progress,finished", 0);
2175 #if ENABLE(WEB_INTENTS)
2178 * The view received a new intent request.
2180 * Emits signal: "intent,request,new" with pointer to a Ewk_Intent.
2182 void ewk_view_intent_request_new(Evas_Object* ewkView, const Ewk_Intent* ewkIntent)
2184 evas_object_smart_callback_call(ewkView, "intent,request,new", const_cast<Ewk_Intent*>(ewkIntent));
2188 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
2190 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2191 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2193 if (!eina_stringshare_replace(&priv->theme, path))
2196 priv->pageClient->page()->setThemePath(path);
2199 const char* ewk_view_theme_get(const Evas_Object* ewkView)
2201 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2202 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2207 void ewk_view_cursor_set(Evas_Object* ewkView, const Cursor& cursor)
2209 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2210 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2212 const char* group = cursor.platformCursor();
2213 if (!group || group == priv->cursorGroup)
2216 priv->cursorGroup = group;
2218 if (priv->cursorObject)
2219 evas_object_del(priv->cursorObject);
2220 priv->cursorObject = edje_object_add(smartData->base.evas);
2222 Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
2223 if (!priv->theme || !edje_object_file_set(priv->cursorObject, priv->theme, group)) {
2224 evas_object_del(priv->cursorObject);
2225 priv->cursorObject = 0;
2227 ecore_evas_object_cursor_set(ecoreEvas, 0, 0, 0, 0);
2229 if (priv->isUsingEcoreX)
2230 WebCore::applyFallbackCursor(ecoreEvas, group);
2235 Evas_Coord width, height;
2236 edje_object_size_min_get(priv->cursorObject, &width, &height);
2237 if (width <= 0 || height <= 0)
2238 edje_object_size_min_calc(priv->cursorObject, &width, &height);
2239 if (width <= 0 || height <= 0) {
2240 width = defaultCursorSize;
2241 height = defaultCursorSize;
2243 evas_object_resize(priv->cursorObject, width, height);
2247 data = edje_object_data_get(priv->cursorObject, "hot.x");
2249 hotspotX = atoi(data);
2252 data = edje_object_data_get(priv->cursorObject, "hot.y");
2254 hotspotY = atoi(data);
2256 ecore_evas_object_cursor_set(ecoreEvas, priv->cursorObject, EVAS_LAYER_MAX, hotspotX, hotspotY);
2259 void ewk_view_display(Evas_Object* ewkView, const IntRect& rect)
2261 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2262 if (!smartData->image)
2265 evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height());
2270 * A download for that view was cancelled.
2272 * Emits signal: "download,cancelled" with pointer to a Ewk_Download_Job.
2274 void ewk_view_download_job_cancelled(Evas_Object* ewkView, Ewk_Download_Job* download)
2276 evas_object_smart_callback_call(ewkView, "download,cancelled", download);
2281 * A new download has been requested for that view.
2283 * Emits signal: "download,request" with pointer to a Ewk_Download_Job.
2285 void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job* download)
2287 evas_object_smart_callback_call(ewkView, "download,request", download);
2292 * A download for that view has failed.
2294 * Emits signal: "download,failed" with pointer to a Ewk_Download_Job_Error.
2296 void ewk_view_download_job_failed(Evas_Object* ewkView, Ewk_Download_Job* download, Ewk_Web_Error* error)
2298 Ewk_Download_Job_Error downloadError = { download, error };
2299 evas_object_smart_callback_call(ewkView, "download,failed", &downloadError);
2304 * A download for that view finished successfully.
2306 * Emits signal: "download,finished" with pointer to a Ewk_Download_Job.
2308 void ewk_view_download_job_finished(Evas_Object* ewkView, Ewk_Download_Job* download)
2310 evas_object_smart_callback_call(ewkView, "download,finished", download);
2313 Eina_Bool ewk_view_back(Evas_Object* ewkView)
2315 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2316 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2318 WebPageProxy* page = priv->pageClient->page();
2319 if (page->canGoBack()) {
2327 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
2329 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2330 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2332 WebPageProxy* page = priv->pageClient->page();
2333 if (page->canGoForward()) {
2341 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
2343 #if ENABLE(WEB_INTENTS)
2344 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2345 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2346 EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
2348 WebPageProxy* page = priv->pageClient->page();
2349 page->deliverIntentToFrame(page->mainFrame(), toImpl(ewk_intent_WKIntentDataRef_get(intent)));
2357 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
2359 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2360 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2362 return priv->pageClient->page()->canGoBack();
2365 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
2367 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2368 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2370 return priv->pageClient->page()->canGoForward();
2373 void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size)
2375 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2376 if (!imageData || !smartData->image)
2379 evas_object_resize(smartData->image, size.width(), size.height());
2380 evas_object_image_size_set(smartData->image, size.width(), size.height());
2381 evas_object_image_data_copy_set(smartData->image, imageData);
2386 * Reports that a form request is about to be submitted.
2388 * Emits signal: "form,submission,request" with pointer to Ewk_Form_Submission_Request.
2390 void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submission_Request* request)
2392 evas_object_smart_callback_call(ewkView, "form,submission,request", request);
2395 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2396 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
2398 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2399 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2401 if (!ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
2404 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(ewkView);
2405 if (!imfContext || ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
2408 if (value.isEmpty()) {
2409 if(smartData->api->formdata_candidate_is_showing(smartData))
2410 smartData->api->formdata_candidate_hide(smartData);
2414 Vector<String> popupCandidates;
2415 ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
2416 std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
2418 Eina_List* candidateList = 0;
2419 for (size_t i = 0; i < popupCandidates.size(); ++i) {
2420 if (popupCandidates[i].startsWith(value, false))
2421 candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
2424 if (!eina_list_count(candidateList)) {
2425 if(smartData->api->formdata_candidate_is_showing(smartData))
2426 smartData->api->formdata_candidate_hide(smartData);
2430 smartData->api->formdata_candidate_update_data(smartData, candidateList);
2432 if (!smartData->api->formdata_candidate_is_showing(smartData))
2433 smartData->api->formdata_candidate_hide(smartData);
2435 IntRect inputFieldRect = priv->pageClient->focusedNodeRect();
2436 smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
2439 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm)
2441 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2442 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2443 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
2444 && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
2446 ewk_context_form_data_add(ewk_view_context_get(ewkView), priv->uri, formData, isPasswordForm);
2449 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
2451 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2452 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2454 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
2457 Vector<std::pair<String, String> > passwordFormData;
2458 ewk_context_form_password_data_get(ewk_view_context_get(ewkView), priv->uri, passwordFormData);
2460 if (!passwordFormData.size())
2463 String passwordFormAutofill = "try { function passwordFormAutofill() { var inputFields;";
2464 for (size_t i = 0; i < passwordFormData.size(); i++) {
2465 passwordFormAutofill += String::format(" inputFields = document.getElementsByName(\"%s\");"
2466 " for (var i = 0; i < inputFields.length; i++)"
2467 " if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\"))"
2468 " inputFields[i].value = \"%s\";",
2469 passwordFormData[i].first.utf8().data(), passwordFormData[i].second.utf8().data());
2471 passwordFormAutofill += "} passwordFormAutofill(); } catch(e) { }";
2472 ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
2475 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
2477 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2478 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2479 ewk_context_form_candidate_data_get(ewk_view_context_get(ewkView), name, candidates);
2485 * Reports load failed with error information.
2487 * Emits signal: "load,error" with pointer to Ewk_Web_Error.
2489 void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error)
2491 evas_object_smart_callback_call(ewkView, "load,error", const_cast<Ewk_Web_Error*>(error));
2496 * Reports load finished.
2498 * Emits signal: "load,finished".
2500 void ewk_view_load_finished(Evas_Object* ewkView)
2502 ewk_view_uri_update(ewkView);
2503 evas_object_smart_callback_call(ewkView, "load,finished", 0);
2505 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2506 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2508 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
2509 priv->pageClient->page()->setLoadingFinished(true);
2512 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2513 ewk_view_form_password_data_fill(ewkView);
2516 if (!priv->suspendRequested)
2519 priv->suspendRequested = false;
2521 if (!priv->suspendedPainting) {
2522 priv->pageClient->page()->suspendPainting();
2523 priv->suspendedPainting = true;
2525 if (!priv->suspendedResources) {
2526 priv->pageClient->page()->suspendJavaScriptAndResource();
2527 priv->suspendedResources = true;
2533 * Reports view provisional load failed with error information.
2535 * Emits signal: "load,provisional,failed" with pointer to Ewk_Web_Error.
2537 void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Web_Error* error)
2539 evas_object_smart_callback_call(ewkView, "load,provisional,failed", const_cast<Ewk_Web_Error*>(error));
2544 * Reports view received redirect for provisional load.
2546 * Emits signal: "load,provisional,redirect".
2548 void ewk_view_load_provisional_redirect(Evas_Object* ewkView)
2550 ewk_view_uri_update(ewkView);
2551 evas_object_smart_callback_call(ewkView, "load,provisional,redirect", 0);
2556 * Reports view provisional load started.
2558 * Emits signal: "load,provisional,started".
2560 void ewk_view_load_provisional_started(Evas_Object* ewkView)
2563 evas_object_smart_callback_call(ewkView, "load,started", 0);
2566 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2567 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2569 #if ENABLE(TIZEN_DRAG_SUPPORT)
2570 if (priv->pageClient->isDragMode())
2571 priv->pageClient->setDragMode(false);
2574 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
2575 priv->pageClient->page()->setLoadingFinished(false);
2578 // The main frame started provisional load, we should clear
2579 // the loadingResources HashMap to start clean.
2580 _ewk_view_priv_loading_resources_clear(priv->loadingResourcesMap);
2582 ewk_view_uri_update(ewkView);
2583 evas_object_smart_callback_call(ewkView, "load,provisional,started", 0);
2588 * Reports that a navigation policy decision should be taken.
2590 * Emits signal: "policy,decision,navigation".
2592 void ewk_view_navigation_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision)
2594 evas_object_smart_callback_call(ewkView, "policy,decision,navigation", decision);
2599 * Reports that a new window policy decision should be taken.
2601 * Emits signal: "policy,decision,new,window".
2603 void ewk_view_new_window_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision)
2605 evas_object_smart_callback_call(ewkView, "policy,decision,new,window", decision);
2608 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
2610 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2611 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2612 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
2614 if (unreachableUrl && *unreachableUrl)
2615 priv->pageClient->page()->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
2617 priv->pageClient->page()->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
2618 ewk_view_uri_update(ewkView);
2623 #if ENABLE(WEB_INTENTS_TAG)
2626 * The view received a new intent service registration.
2628 * Emits signal: "intent,service,register" with pointer to a Ewk_Intent_Service.
2630 void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Service* ewkIntentService)
2632 evas_object_smart_callback_call(ewkView, "intent,service,register", const_cast<Ewk_Intent_Service*>(ewkIntentService));
2634 #endif // ENABLE(WEB_INTENTS_TAG)
2636 WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView)
2638 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2639 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2641 return priv->pageClient->page();
2644 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
2646 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2647 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2649 String customEncoding = priv->pageClient->page()->customTextEncodingName();
2650 if (customEncoding.isEmpty())
2653 eina_stringshare_replace(&priv->customEncoding, customEncoding.utf8().data());
2655 return priv->customEncoding;
2658 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
2660 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2661 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2663 if (eina_stringshare_replace(&priv->customEncoding, encoding))
2664 priv->pageClient->page()->setCustomTextEncodingName(encoding ? String::fromUTF8(encoding) : String());
2670 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
2672 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2673 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2674 return priv->context;
2677 // FIXME: It should be removed.
2678 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
2680 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2681 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2683 return toAPI(priv->pageClient->page());
2686 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
2688 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2689 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2691 enabled = !!enabled;
2692 if (priv->areMouseEventsEnabled == enabled)
2695 priv->areMouseEventsEnabled = enabled;
2697 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down, smartData);
2698 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up, smartData);
2699 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move, smartData);
2701 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
2702 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
2703 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
2709 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
2711 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2712 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2714 return priv->areMouseEventsEnabled;
2717 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
2719 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2720 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2722 return priv->javascriptPopup->alert(alertText);
2725 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
2727 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2728 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2730 return priv->javascriptPopup->confirm(message);
2733 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, 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->prompt(message, defaultValue);
2741 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
2742 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, void* userData)
2744 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2745 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2747 return priv->javascriptPopup->beforeUnloadConfirmPanel(message);
2751 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)
2753 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2754 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2756 return priv->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, priv);
2759 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
2760 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)
2762 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2764 if (priv->popupPicker)
2765 ewk_popup_picker_del(priv->popupPicker);
2767 #if ENABLE(TIZEN_MULTIPLE_SELECT)
2768 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
2770 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
2776 #if ENABLE(TIZEN_MULTIPLE_SELECT)
2777 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)
2779 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2781 if (priv->popupPicker)
2782 ewk_popup_picker_del(priv->popupPicker);
2784 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
2790 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
2792 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2794 if (!priv->popupPicker)
2797 ewk_popup_picker_del(priv->popupPicker);
2798 priv->popupPicker = 0;
2803 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)
2805 // FIXME: The rect should be updated if it was changed
2807 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2809 if (!priv->popupPicker)
2812 ewk_popup_picker_update(smartData->self, priv->popupPicker, items, selectedIndex);
2818 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
2819 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
2821 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2823 priv->inputPicker->show(inputType, inputValue);
2828 #if ENABLE(TIZEN_DATALIST_ELEMENT)
2829 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
2831 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2833 priv->inputPicker->showDataList(inputType, optionList);
2837 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
2839 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2841 priv->inputPicker->hideDataList(inputType);
2846 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
2847 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
2849 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2851 priv->inputPicker->showColorPicker(r, g, b, a);
2855 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
2857 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2859 priv->inputPicker->hideColorPicker();
2864 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
2866 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2867 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2869 return priv->pageClient.get();
2872 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
2874 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
2875 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1);
2877 return WKPageGetTextZoomFactor(toAPI(priv->pageClient->page()));
2880 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
2882 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2883 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2885 WKPageSetTextZoomFactor(toAPI(priv->pageClient->page()), textZoomFactor);
2889 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
2890 FocusRing* ewkViewGetFocusRing(Evas_Object* ewkView)
2892 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2893 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2895 return priv->focusRing.get();
2899 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
2901 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2902 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2904 return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(priv->pageClient->page())));
2907 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
2909 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2910 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2912 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(priv->pageClient->page())));
2915 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
2917 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2918 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2920 if (!priv->javascriptGlobalContext)
2921 priv->javascriptGlobalContext = JSGlobalContextCreate(0);
2922 return priv->javascriptGlobalContext;
2925 void ewkViewLoadCommitted(Evas_Object* ewkView)
2927 #if ENABLE(TIZEN_GESTURE)
2928 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2929 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2930 priv->gestureClient->reset();
2932 #if ENABLE(TIZEN_ISF_PORT)
2933 ewk_view_imf_context_hide(ewkView);
2935 ewk_view_uri_update(ewkView);
2936 evas_object_smart_callback_call(ewkView, "load,committed", 0);
2939 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
2941 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2942 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2944 Ewk_Error* ewkError = ewkErrorCreate(error);
2945 ewkErrorLoadErrorPage(ewkError, toAPI(priv->pageClient->page()));
2946 evas_object_smart_callback_call(ewkView, "load,error", ewkError);
2947 ewkErrorDelete(ewkError);
2950 void ewkViewSetTitleAndURL(Evas_Object* ewkView, const char* title, const char* url)
2952 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2953 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2955 if (title && eina_stringshare_replace(&priv->title, title))
2956 evas_object_smart_callback_call(ewkView, "title,changed", static_cast<void*>(const_cast<char*>(priv->title)));
2957 if (url && eina_stringshare_replace(&priv->uri, url))
2958 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
2961 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
2963 #if ENABLE(TIZEN_GESTURE)
2964 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2965 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2966 priv->gestureClient->reset();
2968 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
2971 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
2973 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2974 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2976 if (priv->authChallenge)
2977 ewkAuthChallengeDelete(priv->authChallenge);
2978 priv->authChallenge = authChallenge;
2980 evas_object_smart_callback_call(ewkView, "authentication,challenge", priv->authChallenge);
2983 void ewk_view_process_crashed(Evas_Object* ewkView)
2985 bool handled = false;
2986 evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
2992 #if ENABLE(TIZEN_SQL_DATABASE)
2993 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)
2995 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, currentQuota);
2996 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, currentQuota);
2998 TIZEN_LOGI("database,quota,exceeded");
2999 uint64_t defaultQuota = ewkContextGetDatabaseQuota(priv->context);
3000 if (defaultQuota >= expectedUsage + currentQuota)
3001 return defaultQuota;
3003 if (priv->exceededDatabaseQuota)
3004 ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
3005 priv->exceededDatabaseQuota = ewkContextCreateExceededQuota(origin, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
3006 evas_object_smart_callback_call(ewkView, "database,quota,exceeded", priv->exceededDatabaseQuota);
3008 return ewkContextGetNewQuotaForExceededQuota(priv->context, priv->exceededDatabaseQuota);
3012 #if ENABLE(TIZEN_NOTIFICATIONS)
3013 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
3015 TIZEN_LOGI("notification,cancel");
3016 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
3019 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
3021 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3022 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3024 TIZEN_LOGI("notification,permission,request");
3025 priv->notificationPermissionRequests = eina_list_append(priv->notificationPermissionRequests, notificationPermissionRequest);
3026 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
3029 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
3031 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3032 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3034 TIZEN_LOGI("notification,show");
3035 Eina_List* listIterator=0;
3037 const char* replaceID = ewkNotificationGetReplaceID(notification);
3038 if(strlen(replaceID)) {
3039 EINA_LIST_FOREACH(priv->notifications, listIterator, data) {
3040 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
3041 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
3042 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
3046 priv->notifications = eina_list_append(priv->notifications, notification);
3047 evas_object_smart_callback_call(ewkView, "notification,show", notification);
3050 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
3052 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3053 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3055 priv->notificationPermissionRequests = eina_list_remove(priv->notificationPermissionRequests, ewkNotificationPermissionRequest);
3059 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
3060 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
3062 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3064 TIZEN_LOGI("protocolhandler,registration,requested");
3065 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
3066 evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
3067 ewkCustomHandlersDeleteData(customHandlersData);
3071 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
3072 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
3074 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
3076 TIZEN_LOGI("protocolhandler,isregistered");
3077 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
3078 evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
3080 Ewk_Custom_Handlers_State result;
3081 result = ewkGetCustomHandlersDataResult(customHandlersData);
3082 ewkCustomHandlersDeleteData(customHandlersData);
3087 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
3089 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3091 TIZEN_LOGI("protocolhandler,unregistration,requested");
3092 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
3093 evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
3094 ewkCustomHandlersDeleteData(customHandlersData);
3098 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
3099 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
3101 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3103 TIZEN_LOGI("contenthandler,registration,requested");
3104 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
3105 evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
3106 ewkCustomHandlersDeleteData(customHandlersData);
3109 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
3111 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
3113 TIZEN_LOGI("contenthandler,isregistered");
3114 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
3115 evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
3117 Ewk_Custom_Handlers_State result;
3118 result = ewkGetCustomHandlersDataResult(customHandlersData);
3119 ewkCustomHandlersDeleteData(customHandlersData);
3124 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
3126 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3128 TIZEN_LOGI("contenthandler,unregistration,requested");
3129 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
3130 evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
3131 ewkCustomHandlersDeleteData(customHandlersData);
3135 #if ENABLE(TIZEN_SEARCH_PROVIDER)
3136 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
3138 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3140 TIZEN_LOGI("searchProvider,add");
3141 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
3142 evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
3143 ewkSearchProviderDeleteData(searchProviderData);
3146 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
3148 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3150 TIZEN_LOGI("searchProvider,installed");
3151 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
3152 evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
3153 unsigned long result;
3154 result = ewkGetSearchProviderResult(searchProviderData);
3155 ewkSearchProviderDeleteData(searchProviderData);
3160 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3161 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
3163 TIZEN_LOGI("webapp,metatag,standalone");
3164 bool standalone = true;
3165 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
3170 #if ENABLE(TIZEN_MEDIA_STREAM)
3171 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
3173 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3174 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3176 priv->userMediaPermissionRequests = eina_list_append(priv->userMediaPermissionRequests, userMediaPermission);
3177 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
3180 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
3182 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3183 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3185 priv->userMediaPermissionRequests = eina_list_remove(priv->userMediaPermissionRequests, permission);
3190 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
3191 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
3193 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
3194 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
3195 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
3196 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
3197 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
3198 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
3200 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
3204 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
3205 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
3207 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3208 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3209 if (priv->certificatePolicyDecision)
3210 ewkCertificatePolicyDecisionDelete(priv->certificatePolicyDecision);
3211 priv->certificatePolicyDecision = certificatePolicyDecision;
3213 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
3217 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
3219 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
3222 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
3224 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
3227 void ewkViewClosePage(Evas_Object* ewkView)
3229 evas_object_smart_callback_call(ewkView, "close,window", 0);
3232 #if ENABLE(TIZEN_GEOLOCATION)
3233 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
3235 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3236 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3238 TIZEN_LOGI("geolocation,permission,request");
3239 priv->geolocationPermissionRequests = eina_list_append(priv->geolocationPermissionRequests, geolocationPermissionRequest);
3240 evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
3243 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
3245 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3246 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3248 priv->geolocationPermissionRequests = eina_list_remove(priv->geolocationPermissionRequests, geolocationPermissionRequest);
3251 void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
3253 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3254 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3256 priv->geolocation = geolocation;
3259 Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
3261 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3262 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3264 return priv->geolocation;
3267 bool ewkViewIsValidLocationService(Evas_Object* ewkView)
3269 TIZEN_LOGI("geolocation,valid");
3272 evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
3277 WKPageRef ewkViewCreateNewPage(Evas_Object* ewkView)
3279 Evas_Object* createdEwkView = 0;
3281 evas_object_smart_callback_call(ewkView, "create,window", &createdEwkView);
3283 if (!createdEwkView)
3286 return static_cast<WKPageRef>(WKRetain(toAPI(ewk_view_page_get(createdEwkView))));
3289 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
3291 evas_object_smart_callback_call(ewkView, "form,submit", formData);
3294 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3296 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3297 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3298 if (priv->policyDecision)
3299 ewkPolicyDecisionDelete(priv->policyDecision);
3300 priv->policyDecision = policyDecision;
3302 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", priv->policyDecision);
3305 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3307 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3308 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3309 if (priv->policyDecision)
3310 ewkPolicyDecisionDelete(priv->policyDecision);
3311 priv->policyDecision = policyDecision;
3313 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", priv->policyDecision);
3316 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3318 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3319 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3320 if (priv->policyDecision)
3321 ewkPolicyDecisionDelete(priv->policyDecision);
3322 priv->policyDecision = policyDecision;
3324 evas_object_smart_callback_call(ewkView, "policy,response,decide", priv->policyDecision);
3327 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
3329 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3330 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3332 IntPoint scrollPosition = priv->pageClient->scrollPosition();
3333 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3334 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3335 contentsSize.scale(priv->pageClient->scaleFactor());
3338 // some website's contents size is smaller than view size,
3339 // so we have to adjust contents size to view size for that case.
3340 if (contentsSize.width() < smartData->view.w)
3341 contentsSize.setWidth(smartData->view.w);
3342 if (contentsSize.height() < smartData->view.h)
3343 contentsSize.setHeight(smartData->view.h);
3345 // Call "scroll,down" if webview can be scrolled down.
3346 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
3347 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
3348 // Call "scroll,up" if webview can be scrolled up.
3349 else if (deltaY < 0 && scrollPosition.y() > 0)
3350 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
3352 // Call "scroll,right" if webview can be scrolled down.
3353 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
3354 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
3355 // Call "scroll,left" if webview can be scrolled up.
3356 else if (deltaX < 0 && scrollPosition.x() > 0)
3357 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
3360 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
3362 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3363 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3365 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3366 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3367 contentsSize.scale(priv->pageClient->scaleFactor());
3370 int maxScrollY = contentsSize.height() - smartData->view.h;
3371 if (!priv->isVerticalEdge) {
3372 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
3373 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
3374 priv->isVerticalEdge = true;
3375 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
3376 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
3377 priv->isVerticalEdge = true;
3380 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
3381 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
3382 priv->isVerticalEdge = false;
3385 int maxScrollX = contentsSize.width() - smartData->view.w;
3386 if (!priv->isHorizontalEdge) {
3387 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
3388 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
3389 priv->isHorizontalEdge = true;
3390 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
3391 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
3392 priv->isHorizontalEdge = true;
3395 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
3396 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
3397 priv->isHorizontalEdge = false;
3401 void ewkViewClearEdges(Evas_Object* ewkView)
3403 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3404 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3406 priv->isVerticalEdge = false;
3407 priv->isHorizontalEdge = false;
3410 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
3412 EWK_VIEW_SD_GET(ewkView, smartData);
3413 if (!smartData || !smartData->priv) {
3421 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
3423 *minimumScale = constraints.minimumScale;
3425 *maximumScale = constraints.maximumScale;
3428 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard)
3430 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3431 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3433 double scaleFactor = priv->pageClient->scaleFactor();
3434 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3436 double newScaleFactor = scaleFactor;
3437 // Readable zoom value is dependent on device DPI
3438 if (scaleFactor < priv->pageClient->page()->deviceScaleFactor()
3439 && priv->pageClient->viewportConstraints().userScalable)
3440 newScaleFactor = priv->pageClient->page()->deviceScaleFactor();
3442 // Readable zoom value should be inside of viewport scale range
3443 newScaleFactor = priv->pageClient->adjustScaleWithViewport(newScaleFactor);
3445 // scale contents' size with new scale factor
3446 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3447 contentsSize.scale(newScaleFactor);
3449 contentsSize.scale(newScaleFactor / scaleFactor);
3452 #if ENABLE(TIZEN_ISF_PORT)
3453 Ecore_X_Window rootWin = ecore_x_window_root_first_get();
3454 ecore_x_event_mask_set(rootWin, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
3455 Ecore_X_Atom xAtom = ecore_x_atom_get("X External Keyboard Exist");
3456 unsigned int connectedKeyboardNum = 0;
3457 bool isExternalKeyboardConnected = false;
3459 // get connected keyboard number
3460 if (ecore_x_window_prop_card32_get(rootWin, xAtom, &connectedKeyboardNum, 1)
3461 && connectedKeyboardNum)
3462 isExternalKeyboardConnected = true;
3464 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
3465 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
3466 // input field zoom should not work with below conditions
3467 // 1. view is not focused
3468 // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
3469 // 3. imfContext is null(if adjustForExternalKeyboard is false)
3470 // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
3471 if ((!(static_cast<PageClient*>(priv->pageClient.get()))->isViewFocused()
3472 || (adjustForExternalKeyboard && !isExternalKeyboardConnected)
3473 || (!adjustForExternalKeyboard && !priv->imfContext)
3474 || (!adjustForExternalKeyboard && ecore_imf_context_input_panel_state_get(priv->imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE))
3475 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
3476 && !(priv->pageClient->isClipboardWindowOpened())
3482 IntSize visibleSize(smartData->view.w, smartData->view.h);
3483 // caret position can be outside of visible rect.
3484 // we need to consider it.
3485 IntRect selectionRect = priv->pageClient->page()->getSelectionRect(true);
3486 IntRect focusedNodeRect = priv->pageClient->focusedNodeRect();
3487 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3488 selectionRect.scale(newScaleFactor);
3489 focusedNodeRect.scale(newScaleFactor);
3491 selectionRect.scale(newScaleFactor / scaleFactor);
3492 focusedNodeRect.scale(newScaleFactor / scaleFactor);
3494 if (selectionRect.isEmpty())
3498 IntPoint scrollPosition(selectionRect.x() - visibleSize.width() / 3, selectionRect.y() - visibleSize.height() / 3);
3499 // If both input field's position x and selection rect can be displayed together,
3500 // adjust scroll position to input field's position x.
3501 if (!focusedNodeRect.isEmpty()
3502 && selectionRect.x() - focusedNodeRect.x() < visibleSize.width() * 4 / 5)
3503 scrollPosition.setX(focusedNodeRect.x());
3505 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3506 priv->pageClient->setVisibleContentRect(IntRect(scrollPosition, ewk_view_size_get(ewkView)), newScaleFactor);
3508 if (newScaleFactor != scaleFactor)
3509 priv->pageClient->page()->scalePage(newScaleFactor, scrollPosition);
3511 priv->pageClient->page()->scrollMainFrameTo(scrollPosition);
3513 evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
3517 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
3518 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
3519 static Eina_Bool _ewk_view_composite(void* data)
3521 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
3522 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
3524 if (!evas_object_visible_get(smartData->image))
3525 return ECORE_CALLBACK_CANCEL;
3528 evas_object_image_size_get(smartData->image, &ow, &oh);
3529 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
3531 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)));
3532 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
3534 cairo_save(context.get());
3535 cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
3536 cairo_rectangle(context.get(), 0, 0, ow, oh);
3537 cairo_fill(context.get());
3538 cairo_restore(context.get());
3540 priv->pageClient->drawContents(context.get());
3542 evas_object_image_data_set(smartData->image, pixels);
3543 evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
3545 ewkViewFrameRendered(smartData->self);
3547 priv->compositionAnimator = 0;
3549 return ECORE_CALLBACK_CANCEL;
3553 void ewk_view_mark_for_sync(Evas_Object* ewkView)
3555 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3556 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
3558 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
3559 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3561 if (!ewk_view_is_opengl_backend(ewkView)) {
3562 if (!priv->compositionAnimator)
3563 priv->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
3568 evas_object_image_pixels_dirty_set(smartData->image, true);
3571 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
3573 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
3574 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3575 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3576 priv->pageClient->drawContents();
3579 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
3581 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3582 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3584 if (!smartData->image)
3587 evas_object_image_native_surface_set(smartData->image, nativeSurface);
3588 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
3594 void _ewk_view_suspend_painting(Evas_Object* ewkView)
3596 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3597 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3599 if (!priv->suspendedPainting) {
3600 priv->pageClient->page()->suspendPainting();
3601 priv->suspendedPainting = true;
3605 void _ewk_view_resume_painting(Evas_Object* ewkView)
3607 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3608 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3610 if (priv->suspendedPainting) {
3611 priv->pageClient->page()->resumePainting();
3612 priv->suspendedPainting = false;
3616 void ewk_view_suspend(Evas_Object* ewkView)
3618 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3619 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3621 if (priv->pageClient->page()->estimatedProgress() < 1.0) {
3622 priv->suspendRequested = true;
3625 priv->suspendRequested = false;
3627 _ewk_view_suspend_painting(ewkView);
3629 // FIXME Workaround for suspend/resume while javascript popup is displayed.
3630 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
3631 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
3633 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
3634 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
3635 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
3636 // will be suspended again.
3637 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
3638 // the ActiveDOMObject.
3639 if (!priv->suspendedResources && !priv->isWaitingForJavaScriptPopupReply) {
3640 priv->pageClient->page()->suspendJavaScriptAndResource();
3641 priv->suspendedResources = true;
3644 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
3645 priv->pageClient->page()->suspendPlugin();
3649 void ewk_view_resume(Evas_Object* ewkView)
3651 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3652 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3654 if (priv->suspendRequested) {
3655 priv->suspendRequested = false;
3659 _ewk_view_resume_painting(ewkView);
3661 // FIXME Workaround for suspend/resume while javascript popup is displayed.
3662 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
3663 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
3665 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
3666 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
3667 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
3668 // will be suspended again.
3669 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
3670 // the ActiveDOMObject.
3671 if (priv->suspendedResources && !priv->isWaitingForJavaScriptPopupReply) {
3672 priv->pageClient->page()->resumeJavaScriptAndResource();
3673 priv->suspendedResources = false;
3676 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
3677 priv->pageClient->page()->resumePlugin();
3681 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
3683 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3684 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3685 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
3687 ResourceRequest request(String::fromUTF8(url));
3690 case EWK_HTTP_METHOD_GET:
3691 request.setHTTPMethod("GET");
3693 case EWK_HTTP_METHOD_HEAD:
3694 request.setHTTPMethod("HEAD");
3696 case EWK_HTTP_METHOD_POST:
3697 request.setHTTPMethod("POST");
3699 case EWK_HTTP_METHOD_PUT:
3700 request.setHTTPMethod("PUT");
3702 case EWK_HTTP_METHOD_DELETE:
3703 request.setHTTPMethod("DELETE");
3710 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
3712 while (eina_iterator_next(it, &data)) {
3713 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
3714 const char* name = static_cast<const char*>(t->key);
3715 const char* value = static_cast<const char*>(t->data);
3716 request.addHTTPHeaderField(name, value);
3718 eina_iterator_free(it);
3722 request.setHTTPBody(FormData::create(body));
3724 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
3725 WKPageLoadURLRequest(toAPI(priv->pageClient->page()), urlRequest.get());
3730 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
3732 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3733 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3735 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
3736 WKPageLoadPlainTextString(toAPI(priv->pageClient->page()), plainTextRef.get());
3741 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
3743 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3744 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3745 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
3747 if (contentsSize == 0)
3750 String mimeTypeString;
3752 mimeTypeString = String::fromUTF8(mimeType);
3754 mimeTypeString = String::fromUTF8("text/html");
3756 String encodingString;
3758 encodingString = String::fromUTF8(encoding);
3760 encodingString = String::fromUTF8("UTF-8");
3762 String baseUriString;
3764 baseUriString = String::fromUTF8(baseUri);
3766 baseUriString = String::fromUTF8("about:blank");
3768 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
3769 priv->pageClient->page()->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
3774 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
3776 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3777 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3779 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
3780 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
3782 WKPageLoadHTMLString(toAPI(priv->pageClient->page()), htmlString.get(), baseURL.get());
3787 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
3789 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3790 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3792 TIZEN_LOGI("initialState (%d)", initialState);
3793 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
3794 WKPageSetPageVisibility(toAPI(priv->pageClient->page()), static_cast<WKPageVisibilityState
3795 >(pageVisibilityState), initialState);
3803 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
3805 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
3807 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3808 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3810 eina_stringshare_replace(&priv->userAgent, userAgent);
3812 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
3813 WKPageSetCustomUserAgent(toAPI(priv->pageClient->page()), userAgentString.get());
3818 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
3820 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3821 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3823 if (!priv->userAgent) {
3824 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(priv->pageClient->page())));
3826 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
3827 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3828 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
3829 eina_stringshare_replace(&priv->userAgent, buffer.get());
3832 return priv->userAgent;
3834 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
3836 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3837 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3838 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3840 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
3841 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
3843 WKPageAddCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get(), customHeaderValue.get());
3846 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3851 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
3853 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3854 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3855 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3857 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
3859 WKPageRemoveCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get());
3862 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3867 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
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 WKPageClearCustomHeaders(toAPI(priv->pageClient->page()));
3876 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3881 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
3882 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
3884 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3885 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3887 #if ENABLE(TIZEN_DRAG_SUPPORT)
3888 if (priv->pageClient->isDragMode())
3889 priv->pageClient->setDragMode(false);
3892 priv->pageClient->setIsVisible(enable);
3897 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
3899 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
3901 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3902 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3905 rect.origin.x = viewArea.x;
3906 rect.origin.y = viewArea.y;
3907 rect.size.width = viewArea.w;
3908 rect.size.height = viewArea.h;
3910 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(priv->pageClient->page()), rect, scaleFactor));
3911 if (!snapshot.get())
3914 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
3916 Evas_Object* screenshotImage = evas_object_image_add(canvas);
3917 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
3918 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
3919 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
3920 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
3922 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
3924 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)));
3925 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
3927 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
3928 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
3929 cairo_fill(cairo.get());
3931 evas_object_image_smooth_scale_set(screenshotImage, true);
3932 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
3933 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
3934 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
3935 evas_object_image_data_set(screenshotImage, pixels);
3937 return screenshotImage;
3940 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
3942 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
3943 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
3944 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, 0);
3946 return priv->pageClient->page()->startInspectorServer(port);
3948 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
3953 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
3955 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
3956 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
3957 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
3959 return priv->pageClient->page()->stopInspectorServer();
3961 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
3966 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
3968 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3969 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3971 WKPageScrollBy(toAPI(priv->pageClient->page()), toAPI(IntSize(deltaX, deltaY)));
3974 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
3980 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3981 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3983 IntPoint scrollPosition = priv->pageClient->scrollPosition();
3985 *x = scrollPosition.x();
3987 *y = scrollPosition.y();
3992 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
3994 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3995 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3997 priv->pageClient->page()->scrollMainFrameTo(IntPoint(x, y));
4001 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
4007 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4008 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4010 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4011 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
4012 contentsSize.scale(priv->pageClient->scaleFactor());
4015 if (width && contentsSize.width() > smartData->view.w)
4016 *width = contentsSize.width() - smartData->view.w;
4017 if (height && contentsSize.height() > smartData->view.h)
4018 *height = contentsSize.height() - smartData->view.h;
4022 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
4024 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4025 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4026 if (!priv->alertContext || !priv->alertContext->javascriptAlertCallback)
4028 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->alertContext->ewkView == ewkView, false);
4030 priv->isWaitingForJavaScriptPopupReply = true;
4031 int length = WKStringGetMaximumUTF8CStringSize(alertText);
4032 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
4033 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
4034 return priv->alertContext->javascriptAlertCallback(priv->alertContext->ewkView, alertTextBuffer.get(), priv->alertContext->userData) == EINA_TRUE;
4037 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
4039 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4040 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4041 if (!priv->confirmContext || !priv->confirmContext->javascriptConfirmCallback)
4043 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->confirmContext->ewkView == ewkView, false);
4045 priv->isWaitingForJavaScriptPopupReply = true;
4046 int length = WKStringGetMaximumUTF8CStringSize(message);
4047 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4048 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4049 return priv->confirmContext->javascriptConfirmCallback(priv->confirmContext->ewkView, messageBuffer.get(), priv->confirmContext->userData) == EINA_TRUE;
4052 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
4054 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4055 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4056 if (!priv->promptContext || !priv->promptContext->javascriptPromptCallback)
4058 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->promptContext->ewkView == ewkView, false);
4060 priv->isWaitingForJavaScriptPopupReply = true;
4061 int length = WKStringGetMaximumUTF8CStringSize(message);
4062 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4063 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4064 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
4065 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
4066 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
4067 return priv->promptContext->javascriptPromptCallback(priv->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), priv->promptContext->userData) == EINA_TRUE;
4070 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
4071 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
4073 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4074 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4075 if (!priv->beforeUnloadConfirmPanelContext || !priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
4077 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
4079 priv->isWaitingForJavaScriptPopupReply = true;
4080 int length = WKStringGetMaximumUTF8CStringSize(message);
4081 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4082 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4083 bool result = priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(priv->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), priv->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
4088 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
4090 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4091 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4092 if (!priv->openpanelContext || !priv->openpanelContext->openPanelCallback)
4095 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->openpanelContext->ewkView == ewkView, false);
4097 priv->openPanelListener = listener;
4099 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
4100 Eina_List* acceptedMimeTypes = 0;
4101 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
4102 size_t len = WKArrayGetSize(array.get());
4103 for (size_t i = 0; i < len; i++) {
4104 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
4105 if (WKGetTypeID(item) != WKStringGetTypeID())
4107 WKStringRef mime = static_cast<WKStringRef>(item);
4108 int length = WKStringGetMaximumUTF8CStringSize(mime);
4109 char* buffer = new char[length];
4110 WKStringGetUTF8CString(mime, buffer, length);
4111 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
4113 const char* capture = 0;
4114 #if ENABLE(MEDIA_CAPTURE)
4115 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
4116 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
4118 bool result = priv->openpanelContext->openPanelCallback(priv->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
4119 if (!acceptedMimeTypes)
4124 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
4125 delete[] (char*)data;
4126 eina_list_free(acceptedMimeTypes);
4130 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
4132 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4133 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4135 if (!priv->alertContext)
4136 priv->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4137 priv->alertContext->javascriptAlertCallback = callback;
4138 priv->alertContext->ewkView = ewkView;
4139 priv->alertContext->userData = userData;
4142 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
4144 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4145 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4147 WKPageReplyJavaScriptAlert(toAPI(ewk_view_page_get(ewkView)));
4148 priv->isWaitingForJavaScriptPopupReply = false;
4151 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
4153 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4154 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4156 if (!priv->confirmContext)
4157 priv->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4158 priv->confirmContext->javascriptConfirmCallback = callback;
4159 priv->confirmContext->ewkView = ewkView;
4160 priv->confirmContext->userData = userData;
4163 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
4165 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4166 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4168 WKPageReplyJavaScriptConfirm(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
4169 priv->isWaitingForJavaScriptPopupReply = false;
4172 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
4174 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4175 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4177 if (!priv->promptContext)
4178 priv->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4179 priv->promptContext->javascriptPromptCallback = callback;
4180 priv->promptContext->ewkView = ewkView;
4181 priv->promptContext->userData = userData;
4184 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
4186 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4187 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4189 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
4190 WKPageReplyJavaScriptPrompt(toAPI(ewk_view_page_get(ewkView)), result ? resultString.get() : 0);
4191 priv->isWaitingForJavaScriptPopupReply = false;
4194 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
4195 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
4197 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4198 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4200 if (!priv->beforeUnloadConfirmPanelContext)
4201 priv->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4202 priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
4203 priv->beforeUnloadConfirmPanelContext->ewkView = ewkView;
4204 priv->beforeUnloadConfirmPanelContext->userData = userData;
4207 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
4209 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4210 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4212 WKPageReplyBeforeUnloadConfirmPanel(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
4213 priv->isWaitingForJavaScriptPopupReply = false;
4217 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
4219 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4220 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4222 if (!priv->openpanelContext)
4223 priv->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4225 priv->openpanelContext->openPanelCallback = callback;
4226 priv->openpanelContext->ewkView = ewkView;
4227 priv->openpanelContext->userData = userData;
4230 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
4232 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4233 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4235 if (!priv->openPanelListener)
4238 unsigned int size = eina_list_count(fileUrls);
4239 if ((result == EINA_FALSE) || (size == 0)) {
4240 WKOpenPanelResultListenerCancel(priv->openPanelListener);
4241 priv->openPanelListener = 0;
4245 WKTypeRef* items = new WKTypeRef[size];
4249 KURL base(KURL(), "file://");
4250 EINA_LIST_FOREACH(fileUrls, list, data) {
4251 KURL url(base, static_cast<char*>(data));
4252 items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
4254 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
4255 WKOpenPanelResultListenerChooseFiles(priv->openPanelListener, filesArray.get());
4256 priv->openPanelListener = 0;
4258 eina_list_free(fileUrls);
4261 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4262 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
4264 EINA_SAFETY_ON_NULL_RETURN(capable);
4265 EINA_SAFETY_ON_NULL_RETURN(context);
4267 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4269 ASSERT(webAppContext->webAppCapableCallback);
4271 TIZEN_LOGI("webAppCapableCallback exist. capable(%b)", capable);
4273 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
4275 webAppContext->webAppCapableCallback(0, webAppContext->userData);
4277 delete webAppContext;
4280 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
4282 EINA_SAFETY_ON_NULL_RETURN(iconURL);
4283 EINA_SAFETY_ON_NULL_RETURN(context);
4285 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4287 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
4288 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4290 ASSERT(webAppContext->webAppIconURLCallback);
4293 eina_stringshare_replace(&priv->webAppIconURL, toImpl(iconURL)->string().utf8().data());
4294 webAppContext->webAppIconURLCallback(priv->webAppIconURL, webAppContext->userData);
4296 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
4298 delete webAppContext;
4301 static void didGetWebAppIconURLs(WKDictionaryRef iconURLs, WKErrorRef, void* context)
4303 EINA_SAFETY_ON_NULL_RETURN(iconURLs);
4304 EINA_SAFETY_ON_NULL_RETURN(context);
4306 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4308 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
4309 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4311 ASSERT(webAppContext->webAppIconURLsCallback);
4313 if (priv->webAppIconURLs) {
4315 EINA_LIST_FREE(priv->webAppIconURLs, data)
4316 ewkWebAppIconDataDelete(static_cast<Ewk_Web_App_Icon_Data*>(data));
4319 WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(iconURLs));
4320 size_t iconURLCount = WKArrayGetSize(wkKeys.get());
4321 for (size_t i = 0; i < iconURLCount; i++) {
4322 WKStringRef urlRef = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
4323 WKStringRef sizeRef = static_cast<WKStringRef>(WKDictionaryGetItemForKey(iconURLs, urlRef));
4324 priv->webAppIconURLs = eina_list_append(priv->webAppIconURLs, ewkWebAppIconDataCreate(sizeRef, urlRef));
4326 TIZEN_LOGI("webAppIconURLsCallback exist. found %d icon urls", iconURLCount);
4328 webAppContext->webAppIconURLsCallback(priv->webAppIconURLs, webAppContext->userData);
4329 delete webAppContext;
4333 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
4335 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4336 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4337 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4338 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4340 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
4341 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4342 context->webAppCapableCallback = callback;
4343 context->ewkView = ewkView;
4344 context->userData = userData;
4346 WKPageGetWebAppCapable(toAPI(priv->pageClient->page()), context, didGetWebAppCapable);
4354 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
4356 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4357 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4358 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4359 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4361 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4362 context->webAppIconURLCallback = callback;
4363 context->ewkView = ewkView;
4364 context->userData = userData;
4366 WKPageGetWebAppIconURL(toAPI(priv->pageClient->page()), context, didGetWebAppIconURL);
4374 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
4376 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4377 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4378 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4379 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4381 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
4382 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4383 context->webAppIconURLsCallback = callback;
4384 context->ewkView = ewkView;
4385 context->userData = userData;
4387 WKPageGetWebAppIconURLs(toAPI(priv->pageClient->page()), context, didGetWebAppIconURLs);
4391 UNUSED_PARAM(ewkView);
4392 UNUSED_PARAM(callback);
4393 UNUSED_PARAM(userData);
4398 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
4400 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4401 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4402 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
4404 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
4405 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
4406 WKPageExecuteCommandWithArgument(toAPI(priv->pageClient->page()), commandString.get(), valueString.get());
4411 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4413 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4414 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4415 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4417 // FixMe: Comment should be removed when pageClient is removed.
4418 //priv->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4419 priv->pageClient->page()->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4424 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4426 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4427 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4429 // FixMe: Comment should be removed when pageClient is removed.
4430 //priv->pageProxy->hideFindUI();
4431 priv->pageClient->page()->hideFindUI();
4436 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
4443 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4444 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4446 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4449 *width = contentsSize.width();
4451 *height = contentsSize.height();
4456 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
4458 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
4459 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4460 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4461 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
4463 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4464 WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
4472 Eina_Bool ewk_view_contents_pdf_get(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 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
4490 EINA_SAFETY_ON_NULL_RETURN(context);
4491 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4493 if (!callbackContext->scriptExecuteCallback) {
4494 delete callbackContext;
4498 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
4501 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
4502 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
4503 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
4504 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
4505 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
4506 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
4508 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
4510 delete callbackContext;
4513 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
4515 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4516 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4517 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
4518 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient, false);
4520 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4521 context->scriptExecuteCallback = callback;
4522 context->ewkView = ewkView;
4523 context->userData = user_data;
4524 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
4525 WKPageRunJavaScriptInMainFrame(toAPI(priv->pageClient->page()), scriptString.get(), context, runJavaScriptCallback);
4530 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
4531 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
4533 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
4536 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
4538 storageContext->webStorageQuotaCallback(0, storageContext->userData);
4540 delete storageContext;
4544 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
4546 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
4547 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
4548 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
4549 TIZEN_LOGI("resultCallback (%p)", resultCallback);
4551 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4552 context->webStorageQuotaCallback = resultCallback;
4553 context->userData = userData;
4555 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
4556 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
4564 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
4566 #if ENABLE(TIZEN_WEB_STORAGE)
4567 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
4569 TIZEN_LOGI("quota (%d)", quota);
4570 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
4571 WKPageSetWebStorageQuota(pageRef, quota);
4579 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
4581 EINA_SAFETY_ON_NULL_RETURN(context);
4582 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4584 ASSERT(callbackContext->plainTextGetCallback);
4587 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
4588 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
4589 WKStringGetUTF8CString(plain_text, buffer.get(), length);
4591 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
4593 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
4595 delete callbackContext;
4598 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
4600 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4601 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4602 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4603 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient, false);
4605 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4606 context->plainTextGetCallback = callback;
4607 context->ewkView = ewkView;
4608 context->userData = user_data;
4609 WKPageGetContentsAsString(toAPI(priv->pageClient->page()), context, getContentsAsStringCallback);
4614 #if ENABLE(TIZEN_SUPPORT_MHTML)
4617 * Callback function used for ewk_view_mhtml_data_get().
4619 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4621 EINA_SAFETY_ON_NULL_RETURN(context);
4622 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4624 ASSERT(callbackContext->mhtmlDataGetCallback);
4626 callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
4628 delete callbackContext;
4631 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
4633 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4634 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4635 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4637 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4638 context->mhtmlDataGetCallback = callback;
4639 context->ewkView = ewkView;
4640 context->userData = user_data;
4642 WKPageGetContentsAsMHTMLData(toAPI(priv->pageClient->page()), false, context, getContentsAsMHTMLCallback);
4646 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
4648 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
4650 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
4651 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4652 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4653 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, 0);
4655 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
4656 WebHitTestResult::Data hitTestResultData = priv->pageClient->page()->hitTestResultAtPoint(pointForHitTest, hitTestMode);
4657 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
4665 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
4667 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
4668 WebPageProxy* page = ewk_view_page_get(ewkView);
4669 EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
4671 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
4674 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
4676 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4677 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4679 WKPageRecordingSurfaceSetEnable(toAPI(priv->pageClient->page()), enable);
4684 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
4686 #if ENABLE(TIZEN_NOTIFICATIONS)
4687 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4688 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4689 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->context, false);
4691 TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
4692 if (!eina_list_count(ewkNotifications))
4695 Eina_List* listIterator = 0;
4697 Vector<WKTypeRef> ids;
4698 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
4699 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
4700 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
4702 priv->notifications = eina_list_remove(priv->notifications, notification);
4705 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
4706 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(ewk_context_WKContext_get(priv->context));
4707 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
4708 ewkNotificationDeleteNotificationList(ewkNotifications);
4716 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
4718 Eina_List* popupItems = 0;
4719 size_t size = items.size();
4720 for (size_t i = 0; i < size; ++i) {
4721 Ewk_Popup_Menu_Item* item = ewk_popup_menu_item_new(items[i].m_type,
4722 items[i].m_text.utf8().data(),
4723 items[i].m_textDirection,
4724 items[i].m_hasTextDirectionOverride,
4725 items[i].m_toolTip.utf8().data(),
4726 items[i].m_accessibilityText.utf8().data(),
4727 items[i].m_isEnabled,
4728 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4729 items[i].m_isSelected,
4731 items[i].m_isLabel);
4732 popupItems = eina_list_append(popupItems, item);
4734 TIZEN_LOGI("size : %d", size);
4738 static void releasePopupMenuList(Eina_List* popupMenuItems)
4740 if (!popupMenuItems)
4744 EINA_LIST_FREE(popupMenuItems, item)
4745 ewk_popup_menu_item_free(static_cast<Ewk_Popup_Menu_Item*>(item));
4748 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4749 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)
4751 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)
4754 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4755 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4756 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4757 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4761 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4762 if (!smartData->api->popup_menu_show && !smartData->api->multiple_popup_menu_show)
4764 if (!smartData->api->popup_menu_show)
4768 if (priv->popupMenuProxy)
4769 ewk_view_popup_menu_close(ewkView);
4770 priv->popupMenuProxy = popupMenu;
4772 priv->popupMenuItems = createPopupMenuList(items);
4774 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4775 if ((!multiple && smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems, selectedIndex)) ||
4776 (multiple && smartData->api->multiple_popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems))) {
4778 if (smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems, selectedIndex)) {
4780 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
4781 /* maps.google.com generate mouse event in touch down without preventDefault.
4782 * So, popup menu is opend in touch down event and closed via fake mouse down
4783 * which generated by endTap.
4784 * In order to fix select of maps.google.com (based on touch behavior),
4785 * We should disable touch events when select popup is open.
4788 #if ENABLE(TIZEN_GESTURE)
4789 priv->gestureClient->reset();
4791 ewk_view_touch_events_enabled_set(ewkView, false);
4796 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
4798 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4799 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4800 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4801 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4803 if (!priv->popupMenuProxy)
4806 priv->popupMenuProxy = 0;
4808 if (smartData->api->popup_menu_hide)
4809 smartData->api->popup_menu_hide(smartData);
4810 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
4811 ewk_view_touch_events_enabled_set(ewkView, true);
4814 releasePopupMenuList(priv->popupMenuItems);
4815 priv->popupMenuItems = 0;
4820 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
4822 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4823 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4824 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4825 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4827 if (!priv->popupMenuProxy)
4830 if (!smartData->api->popup_menu_update)
4833 releasePopupMenuList(priv->popupMenuItems);
4834 priv->popupMenuItems = createPopupMenuList(items);
4836 // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
4837 smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), priv->popupMenuItems, selectedIndex);
4840 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
4842 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4843 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4844 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
4845 TIZEN_LOGI("proxy : %p / index : %d", priv->popupMenuProxy, selectedIndex);
4847 if (!priv->popupMenuItems)
4850 if (selectedIndex >= eina_list_count(priv->popupMenuItems))
4853 priv->popupMenuProxy->valueChanged(selectedIndex);
4858 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4859 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
4861 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4862 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4863 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
4865 Vector<int> selectedIndex;
4867 if (!priv->popupMenuItems)
4872 itr = eina_inarray_iterator_new(changeList);
4873 EINA_ITERATOR_FOREACH(itr, data)
4875 int* pData = static_cast<int*>(data);
4876 selectedIndex.append(*pData);
4878 eina_iterator_free(itr);
4880 priv->popupMenuProxy->multipleValueChanged(selectedIndex);
4885 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
4887 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
4888 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4889 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4890 TIZEN_LOGI("orientation : %d", orientation);
4892 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
4895 if (priv->orientation == orientation)
4898 priv->orientation = orientation;
4900 priv->pageClient->page()->sendOrientationChangeEvent(orientation);
4904 void ewkViewFrameRendered(Evas_Object* ewkView)
4906 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
4909 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4910 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
4912 return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
4915 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
4917 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4918 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4919 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
4921 IntRect leftSelectionRect;
4922 IntRect rightSelectionRect;
4923 if (!priv->pageClient->page()->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
4936 AffineTransform contentToScreen = impl->transformToScene();
4937 leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
4938 rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
4940 leftRect->x = leftSelectionRect.x();
4941 leftRect->y = leftSelectionRect.y();
4942 leftRect->w = leftSelectionRect.width();
4943 leftRect->h = leftSelectionRect.height();
4945 rightRect->x = rightSelectionRect.x();
4946 rightRect->y = rightSelectionRect.y();
4947 rightRect->w = rightSelectionRect.width();
4948 rightRect->h = rightSelectionRect.height();
4953 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
4955 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4956 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4958 const CString selectedString = priv->pageClient->page()->getSelectionText().utf8();
4959 eina_stringshare_replace(&priv->selectedText, selectedString.data());
4961 return priv->selectedText;
4964 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
4966 return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
4969 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
4971 return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
4973 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4975 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4976 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
4978 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4979 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4980 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
4982 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
4986 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
4987 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
4989 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4990 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4991 IntPoint drawingPosition = (IntPoint)(priv->pageClient->visibleContentRect().location() - priv->pageClient->scrollPosition());
4993 *x = drawingPosition.x();
4995 *y = drawingPosition.y();
4997 *w = priv->pageClient->visibleContentRect().width();
4999 *h = priv->pageClient->visibleContentRect().height();
5003 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
5005 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
5006 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5007 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5009 priv->pageClient->page()->setFocusedInputElementValue(String::fromUTF8(value));
5010 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
5013 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
5015 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
5016 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5017 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5019 eina_stringshare_replace(&priv->inputValue, priv->pageClient->page()->getFocusedInputElementValue().utf8().data());
5020 return priv->inputValue;
5023 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
5026 #if ENABLE(TIZEN_DATALIST_ELEMENT)
5027 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
5029 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5030 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5031 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
5032 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
5035 ewkViewDataListHideRequest(ewkView, inputType);
5037 for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
5039 priv->dataList = eina_list_append(priv->dataList, eina_stringshare_add(value.utf8().data()));
5042 smartData->api->data_list_show(smartData, inputType, priv->dataList);
5045 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
5047 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5048 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5049 EINA_SAFETY_ON_NULL_RETURN(priv->dataList);
5050 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
5051 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
5053 if (priv->dataList) {
5054 _ewk_view_data_list_del(priv->dataList);
5058 smartData->api->data_list_hide(smartData, inputType);
5062 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
5064 #if ENABLE(TIZEN_DATALIST_ELEMENT)
5065 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5066 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5068 if (priv->dataList) {
5069 _ewk_view_data_list_del(priv->dataList);
5073 ewk_view_focused_input_element_value_set(ewkView, value);
5077 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
5079 #if ENABLE(TIZEN_GESTURE)
5080 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
5081 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
5082 return priv->holdHorizontalPanning;
5088 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
5090 #if ENABLE(TIZEN_GESTURE)
5091 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5092 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5093 priv->holdHorizontalPanning = hold;
5097 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
5099 #if ENABLE(TIZEN_GESTURE)
5100 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
5101 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
5102 return priv->holdVerticalPanning;
5108 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
5110 #if ENABLE(TIZEN_GESTURE)
5111 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5112 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5113 priv->holdVerticalPanning = hold;
5117 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
5119 #if ENABLE(TIZEN_GESTURE)
5120 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5121 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5123 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5124 if (priv->focusRing && wasHandled)
5125 priv->focusRing->hide();
5126 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5128 if (priv->areMouseEventsEnabled)
5131 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
5132 if (wasHandled && priv->pageClient->isTextSelectionMode()) {
5133 if (type == WebEvent::TouchStart)
5134 priv->pageClient->updateTextSelectionHandlesAndContextMenu(false);
5135 else if (type == WebEvent::TouchMove)
5136 priv->pageClient->updateTextSelectionHandlesAndContextMenu(false);
5137 else if (type == WebEvent::TouchEnd)
5138 priv->pageClient->requestToShowTextSelectionHandlesAndContextMenu();
5142 // We have to check TouchStart, TouchMove and TouchEnd with handled.
5143 // The Pan and Flick will be enabled if Touch Start was not handled,
5144 // and Touch Move was not handled or did not occur.
5145 // Tap will be enabled if Touch Start and End was not handled
5146 // and Touch Move did not occur.
5147 // The gestures are disabled as a default.
5148 // o: handled, x: not handled
5149 // ------------------------------------------------------------
5150 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
5151 // ------------------------------------------------------------
5152 // o | o or x | o or x || disable | disable
5153 // x | o | o or x || disable | disable
5154 // x | x | o or x || disable | enable
5155 // x |not occured | x || enable | enable
5156 // ------------------------------------------------------------
5157 if (type == WebEvent::TouchStart) {
5158 priv->gestureClient->setGestureEnabled(!wasHandled);
5159 priv->wasHandledTouchStart = wasHandled;
5161 // Initialize wasHandledTouchMove to true and notify that to the application
5162 // to prevent applications scrolling at the beginning of touch.
5163 priv->wasHandledTouchMove = true;
5164 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&priv->wasHandledTouchMove));
5165 } else if (type == WebEvent::TouchMove) {
5166 priv->gestureClient->setMovingEnabled(!wasHandled);
5168 // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
5169 if (priv->wasHandledTouchStart)
5172 // Notify the result of touchmove to applications when handled value is changed
5173 // in order to make applications to choose whether scrolling its scrollable objects or not.
5174 if (priv->wasHandledTouchMove != wasHandled)
5175 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
5176 priv->wasHandledTouchMove = wasHandled;
5177 } else if (type == WebEvent::TouchEnd && !priv->exceedTouchMoveThreshold && !wasHandled) {
5178 priv->gestureClient->setMovingEnabled(!wasHandled);
5179 priv->gestureClient->setTapEnabled(!wasHandled);
5184 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
5185 void ewkViewDidGetTextStyleStateForSelection(Evas_Object* ewkView, int underlineState, int italicState, int boldState, const IntPoint& startPoint, const IntPoint& endPoint)
5187 Ewk_Text_Style* textStyle = ewkTextStyleCreate(underlineState, italicState, boldState, startPoint, endPoint);
5188 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
5189 ewkTextStyleDelete(textStyle);
5193 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
5194 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
5196 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5197 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
5199 TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
5200 if (!smartData->api->orientation_lock) {
5205 return smartData->api->orientation_lock(smartData, willLockOrientation);
5208 void ewk_view_orientation_unlock(Evas_Object* ewkView)
5210 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5211 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
5213 TIZEN_LOGI("ewkView (%p)", ewkView);
5214 if (!smartData->api->orientation_unlock) {
5219 smartData->api->orientation_unlock(smartData);
5223 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
5225 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
5226 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5227 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5228 TIZEN_LOGI("callbacks: %p / data: %p", func, data);
5230 priv->orientationLock.callback = func;
5231 priv->orientationLock.data = data;
5235 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
5236 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
5238 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
5239 TIZEN_LOGI("locked orientations : %d", orientations);
5241 if (priv->orientationLock.callback)
5242 return priv->orientationLock.callback(sd->self, true, orientations, priv->orientationLock.data);
5247 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
5249 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
5250 TIZEN_LOGI("unlock is requested");
5252 if (priv->orientationLock.callback)
5253 priv->orientationLock.callback(sd->self, false, 0, priv->orientationLock.data);
5257 void ewk_view_fullscreen_enter(Evas_Object* ewkView)
5259 TIZEN_LOGI("fullscreen,enterfullscreen");
5260 ewk_view_main_frame_scrollbar_visible_set(ewkView, false);
5261 evas_object_smart_callback_call(ewkView, "fullscreen,enterfullscreen", 0);
5264 void ewk_view_fullscreen_exit(Evas_Object* ewkView)
5266 TIZEN_LOGI("fullscreen,exitfullscreen");
5267 ewk_view_main_frame_scrollbar_visible_set(ewkView, true);
5268 evas_object_smart_callback_call(ewkView, "fullscreen,exitfullscreen", 0);
5271 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
5272 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
5274 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5276 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
5277 const char *engine = ecore_evas_engine_name_get(ee);
5278 if (engine && !strcmp(engine, "opengl_x11"))
5284 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
5286 #if ENABLE(TIZEN_GESTURE)
5287 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5288 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5290 priv->gestureClient->setZoomableArea(target, area);
5294 #if ENABLE(TIZEN_ISF_PORT)
5295 static void imfInputPanelStateEventCb(void* data, Ecore_IMF_Context* ctx, int state)
5297 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5298 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5300 if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
5301 evas_object_smart_callback_call(smartData->self, "editorclient,ime,closed", 0);
5302 LOG(ISF, "[SIGNAL] editorclient,ime,closed\n");
5303 } else if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
5304 evas_object_smart_callback_call(smartData->self, "editorclient,ime,opened", 0);
5305 LOG(ISF, "[SIGNAL] editorclient,ime,opened\n");
5309 static void imfInputPanelGeometryEventCb(void* data, Ecore_IMF_Context* ctx, int value)
5311 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5312 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5314 Eina_Rectangle rect;
5315 ecore_imf_context_input_panel_geometry_get(priv->imfContext, &rect.x, &rect.y, &rect.w, &rect.h);
5316 evas_object_smart_callback_call(smartData->self, "inputmethod,changed", &rect);
5317 LOG(ISF, "%s : [SIGNAL] inputmethod,changed (%d,%d,%d,%d)\n", __func__, rect.x, rect.y, rect.w, rect.h);
5320 static void imfCandidatePanelStateEventCb(void* data, Ecore_IMF_Context* ctx, int state)
5322 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5323 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5325 if (state == ECORE_IMF_CANDIDATE_PANEL_SHOW)
5326 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,opened", 0);
5328 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,closed", 0);
5331 static void imfCandidatePanelGeometryEventCb(void* data, Ecore_IMF_Context* ctx, int value)
5333 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5334 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5336 Eina_Rectangle rect;
5337 ecore_imf_context_candidate_panel_geometry_get(priv->imfContext, &rect.x, &rect.y, &rect.w, &rect.h);
5338 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,changed", &rect);
5341 static Eina_Bool imfRetrieveSurroundingCb(void* data, Ecore_IMF_Context* context, char** text, int* offset)
5343 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5344 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5346 if (!priv->pageClient->page()->focusedFrame() || (!text && !offset))
5349 String surroundingText;
5351 priv->pageClient->page()->getSurroundingTextAndCursorOffset(surroundingText, cursorOffset);
5354 CString utf8Text(surroundingText.utf8());
5355 size_t length = utf8Text.length();
5357 *text = static_cast<char*>(malloc((length + 1) * sizeof(char)));
5362 strncpy(*text, utf8Text.data(), length);
5363 (*text)[length] = 0;
5367 *offset = cursorOffset;
5372 static void imfPreeditChangedCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5374 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5375 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5377 priv->pageClient->imContextPreeditChanged(context);
5380 static void imfEventCommittedCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5382 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5383 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5385 priv->pageClient->imContextCommitted(context, static_cast<char*>(eventInfo));
5388 static void imfContextDeleteSurroundingCb(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 Ecore_IMF_Event_Delete_Surrounding* event = static_cast<Ecore_IMF_Event_Delete_Surrounding*>(eventInfo);
5397 priv->pageClient->page()->deleteSurroundingText(event->offset, event->n_chars);
5400 Ecore_IMF_Context* ewk_view_imf_context_get(Evas_Object* ewkView)
5402 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5403 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5405 return priv->imfContext;
5408 Ecore_IMF_Context* ewk_view_imf_context_set(Evas_Object* ewkView, Ecore_IMF_Input_Panel_Layout layout)
5410 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5411 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5413 Ecore_IMF_Context* imfContext;
5414 Eina_List* iterator;
5417 EINA_LIST_FOREACH(priv->imfContextList, iterator, data) {
5418 imfContext = static_cast<Ecore_IMF_Context*>(data);
5419 if (ecore_imf_context_input_panel_layout_get(imfContext) == layout) {
5420 priv->imfContext = imfContext;
5425 imfContext = ecore_imf_context_add(ecore_imf_context_default_id_get());
5429 ecore_imf_context_input_panel_enabled_set(imfContext, false);
5430 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, imfInputPanelStateEventCb, smartData);
5431 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, imfInputPanelGeometryEventCb, smartData);
5432 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, imfCandidatePanelStateEventCb, smartData);
5433 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, imfCandidatePanelGeometryEventCb, smartData);
5434 ecore_imf_context_retrieve_surrounding_callback_set(imfContext, imfRetrieveSurroundingCb, smartData); // Support for Auto Capitalization
5435 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, imfPreeditChangedCb, smartData);
5436 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_COMMIT, imfEventCommittedCb, smartData);
5437 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, imfContextDeleteSurroundingCb, smartData); //Support for Automatic Full Stop
5438 ecore_imf_context_input_panel_layout_set(imfContext, layout);
5440 priv->imfContextList = eina_list_append(priv->imfContextList, imfContext);
5441 priv->imfContext = imfContext;
5446 void ewk_view_imf_context_reset(Evas_Object* ewkView)
5448 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5449 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5451 if (!priv->imfContext)
5454 ecore_imf_context_reset(priv->imfContext);
5456 if (ecore_imf_context_input_panel_state_get(priv->imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
5457 priv->imfContext = 0;
5460 void ewk_view_imf_context_hide(Evas_Object* ewkView)
5462 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5463 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5465 if (!priv->imfContext)
5468 if (ecore_imf_context_input_panel_state_get(priv->imfContext) != ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
5469 ecore_imf_context_reset(priv->imfContext);
5470 ecore_imf_context_input_panel_hide(priv->imfContext);
5471 ecore_imf_context_focus_out(priv->imfContext);
5474 priv->imfContext = 0;
5477 static void _ewk_view_imf_context_destroy(Ewk_View_Private_Data* priv)
5479 if (!priv->imfContextList)
5483 EINA_LIST_FREE(priv->imfContextList, item) {
5484 Ecore_IMF_Context* imfContext = static_cast<Ecore_IMF_Context*>(item);
5488 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, imfInputPanelStateEventCb);
5489 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, imfInputPanelGeometryEventCb);
5490 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, imfCandidatePanelStateEventCb);
5491 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, imfCandidatePanelGeometryEventCb);
5492 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, imfPreeditChangedCb);
5493 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_COMMIT, imfEventCommittedCb);
5494 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, imfContextDeleteSurroundingCb);
5495 ecore_imf_context_del(imfContext);
5498 priv->imfContextList = 0;
5499 priv->imfContext = 0;
5502 void ewk_view_imf_context_destroy(Evas_Object* ewkView)
5504 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5505 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5507 _ewk_view_imf_context_destroy(priv);
5511 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
5512 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
5514 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5515 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5517 WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(priv->pageClient->page())));
5521 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
5522 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
5524 evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
5528 #if ENABLE(TIZEN_ICON_DATABASE)
5529 void ewkViewIconReceived(Evas_Object* ewkView)
5533 evas_object_smart_callback_call(ewkView, "icon,received", 0);
5537 #endif // #if OS(TIZEN)
5539 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
5540 #if ENABLE(INPUT_TYPE_COLOR)
5543 * Reqeusts to show external color picker.
5545 void ewk_view_color_picker_request(Evas_Object* ewkView, int r, int g, int b, int a, WKColorPickerResultListenerRef listener)
5547 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5548 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5549 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_request);
5551 priv->colorPickerResultListener = listener;
5553 smartData->api->input_picker_color_request(smartData, r, g, b, a);
5558 * Reqeusts to hide external color picker.
5560 void ewk_view_color_picker_dismiss(Evas_Object* ewkView)
5562 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5563 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5564 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_dismiss);
5566 priv->colorPickerResultListener = 0;
5568 smartData->api->input_picker_color_dismiss(smartData);
5572 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
5574 #if ENABLE(INPUT_TYPE_COLOR)
5575 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5576 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5577 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->colorPickerResultListener, false);
5579 WebCore::Color color = WebCore::Color(r, g, b, a);
5580 WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(color.serialized().utf8().data()));
5581 WKColorPickerResultListenerSetColor(priv->colorPickerResultListener, colorString.get());
5582 priv->colorPickerResultListener = 0;
5589 #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
5591 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
5593 #if ENABLE(TOUCH_EVENTS)
5594 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
5595 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5596 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5597 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
5599 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
5600 if (priv->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
5601 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5602 IntPoint handlePoint(point->x, point->y);
5604 if (type == EWK_TOUCH_START)
5605 priv->pageClient->textSelectonHandleDown(handlePoint);
5606 else if (type == EWK_TOUCH_MOVE)
5607 priv->pageClient->textSelectonHandleMove(handlePoint);
5609 priv->pageClient->textSelectonHandleUp();
5613 #if ENABLE(TIZEN_GESTURE)
5614 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
5615 // We don't want to process touch event when context menu is shown.
5616 if (priv->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
5619 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
5620 if (priv->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
5624 if (type == EWK_TOUCH_START) {
5625 if (eina_list_count(points) == 1) {
5626 priv->gestureClient->reset();
5627 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5628 priv->touchDownPoint.x = point->x;
5629 priv->touchDownPoint.y = point->y;
5630 priv->exceedTouchMoveThreshold = false;
5632 } else if (type == EWK_TOUCH_MOVE && !priv->exceedTouchMoveThreshold) {
5633 if (eina_list_count(points) == 1) {
5634 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
5635 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5636 int diffX = priv->touchDownPoint.x - point->x;
5637 int diffY = priv->touchDownPoint.y - point->y;
5638 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
5639 priv->exceedTouchMoveThreshold = true;
5643 priv->exceedTouchMoveThreshold = true;
5646 #endif // #if ENABLE(TIZEN_GESTURE)
5648 // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
5649 //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
5650 priv->pageClient->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
5658 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
5660 #if ENABLE(TOUCH_EVENTS)
5661 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5662 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5664 enabled = !!enabled;
5665 if (priv->areTouchEventsEnabled == enabled)
5668 priv->areTouchEventsEnabled = enabled;
5670 // FIXME: We have to connect touch callbacks with mouse and multi events
5671 // because the Evas creates mouse events for first touch and multi events
5672 // for second and third touches. Below codes should be fixed when the Evas
5673 // supports the touch events.
5674 // See https://bugs.webkit.org/show_bug.cgi?id=97785 for details.
5675 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down, smartData);
5676 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up, smartData);
5677 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move, smartData);
5678 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down, smartData);
5679 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up, smartData);
5680 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move, smartData);
5682 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down);
5683 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up);
5684 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move);
5685 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down);
5686 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up);
5687 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move);
5696 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
5698 #if ENABLE(TOUCH_EVENTS)
5699 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5700 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5702 return priv->areTouchEventsEnabled;
5708 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
5710 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
5711 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5712 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5714 priv->mainFrameScrollbarVisibility = visible;
5715 priv->pageClient->updateVisibility();
5723 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
5725 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
5726 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5727 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5729 return priv->mainFrameScrollbarVisibility;
5735 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
5737 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
5738 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5739 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5740 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
5742 String title = ewk_view_title_get(ewkView);
5743 String url = ewk_view_url_get(ewkView);
5744 String directoryPath(path);
5745 priv->pageClient->startOfflinePageSave(directoryPath, url, title);
5749 UNUSED_PARAM(ewkView);
5757 * Callback function used for ewk_view_page_contents_get().
5759 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
5761 EINA_SAFETY_ON_NULL_RETURN(context);
5763 RefPtr<WebData> webData = toImpl(wkData);
5764 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
5765 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
5770 * Callback function used for ewk_view_page_contents_get().
5772 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
5774 EINA_SAFETY_ON_NULL_RETURN(context);
5776 RefPtr<WebString> webString = toImpl(wkString);
5777 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
5778 contentsContext->callback(contentsContext->type, webString->string().utf8().data());
5781 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
5783 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
5784 EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
5785 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5786 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5788 switch (context->type) {
5789 case EWK_PAGE_CONTENTS_TYPE_MHTML:
5790 priv->pageClient->page()->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
5793 case EWK_PAGE_CONTENTS_TYPE_STRING:
5794 priv->pageClient->page()->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
5798 ASSERT_NOT_REACHED();
5805 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
5807 #if ENABLE(TIZEN_GESTURE)
5808 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5809 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5811 return priv->gestureClient->scrollToWithAnimation(x, y);
5813 UNUSED_PARAM(ewkView);
5820 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5821 void ewkViewFocusRingHide(Evas_Object* ewkView)
5823 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5824 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5826 if (priv->focusRing)
5827 priv->focusRing->hide();
5831 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
5833 #if ENABLE(TIZEN_CSP)
5834 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
5835 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
5837 TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
5838 priv->pageClient->page()->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));