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 #endif // #if OS(TIZEN)
180 using namespace WebKit;
181 using namespace WebCore;
183 static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
186 typedef struct _Ewk_View_Callback_Context Ewk_View_Callback_Context;
187 #endif // #if OS(TIZEN)
189 static const int defaultCursorSize = 16;
191 typedef HashMap<uint64_t, Ewk_Web_Resource*> LoadingResourcesMap;
192 static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap);
194 struct _Ewk_View_Private_Data {
195 OwnPtr<PageClientImpl> pageClient;
200 const char* customEncoding;
201 const char* cursorGroup;
202 Evas_Object* cursorObject;
203 LoadingResourcesMap loadingResourcesMap;
204 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
205 WKColorPickerResultListenerRef colorPickerResultListener;
207 #if ENABLE(TOUCH_EVENTS)
208 bool areTouchEventsEnabled;
210 OwnPtr<Ewk_Settings> settings;
216 #if USE(ACCELERATED_COMPOSITING)
218 Evas_GL_Context* evasGlContext;
219 Evas_GL_Surface* evasGlSurface;
223 bool areMouseEventsEnabled;
224 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
228 JSGlobalContextRef javascriptGlobalContext;
230 const char* userAgent;
231 const char* encoding;
232 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
233 const char* webAppIconURL;
236 OwnPtr<Ewk_View_Callback_Context> alertContext;
237 OwnPtr<Ewk_View_Callback_Context> confirmContext;
238 OwnPtr<Ewk_View_Callback_Context> promptContext;
239 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
240 OwnPtr<Ewk_View_Callback_Context> beforeUnloadConfirmPanelContext;
242 OwnPtr<Ewk_View_Callback_Context> openpanelContext;
243 OwnPtr<JavaScriptPopup> javascriptPopup;
244 bool isWaitingForJavaScriptPopupReply;
245 OwnPtr<OpenPanel> openPanel;
246 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
247 OwnPtr<InputPicker> inputPicker;
248 const char* inputValue;
251 Ewk_Auth_Challenge* authChallenge;
252 Ewk_Policy_Decision* policyDecision;
253 WKOpenPanelResultListenerRef openPanelListener;
255 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
256 Ewk_Certificate_Policy_Decision* certificatePolicyDecision;
259 #if ENABLE(TIZEN_MEDIA_STREAM)
260 Eina_List* userMediaPermissionRequests;
263 Ewk_Context* context;
265 #if ENABLE(TIZEN_GEOLOCATION)
266 Ewk_Geolocation* geolocation;
267 Eina_List* geolocationPermissionRequests;
270 #if ENABLE(TIZEN_ISF_PORT)
271 Eina_List* imfContextList;
272 Ecore_IMF_Context* imfContext;
275 bool suspendRequested;
276 bool suspendedPainting;
277 bool suspendedResources;
279 #if ENABLE(TIZEN_NOTIFICATIONS)
280 Eina_List* notifications;
281 Eina_List* notificationPermissionRequests;
283 #if ENABLE(TIZEN_SQL_DATABASE)
284 Ewk_Context_Exceeded_Quota* exceededDatabaseQuota;
286 WebPopupMenuProxyEfl* popupMenuProxy;
287 Eina_List* popupMenuItems;
288 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
289 Ewk_Popup_Picker* popupPicker;
293 bool isHorizontalEdge;
294 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
295 OwnPtr<FocusRing> focusRing;
296 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
298 #if ENABLE(TIZEN_GESTURE)
299 OwnPtr<GestureRecognizer> gestureRecognizer;
300 OwnPtr<GestureClient> gestureClient;
301 #if ENABLE(TOUCH_EVENTS)
302 Evas_Coord_Point touchDownPoint;
303 bool exceedTouchMoveThreshold;
304 bool wasHandledTouchStart;
305 bool wasHandledTouchMove;
306 #endif // #if ENABLE(TOUCH_EVENTS)
307 bool holdHorizontalPanning;
308 bool holdVerticalPanning;
309 bool useSmartSelection;
310 #endif // #if ENABLE(TIZEN_GESTURE)
311 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
312 bool mainFrameScrollbarVisibility;
315 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
316 Ecore_Animator* compositionAnimator;
319 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
320 const char* selectedText;
322 #if ENABLE(TIZEN_DATALIST_ELEMENT)
325 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
327 Ewk_Orientation_Lock_Cb callback;
331 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
332 RefPtr<WebPageGroup> pageGroup;
334 #endif // #if OS(TIZEN)
336 _Ewk_View_Private_Data()
343 #if ENABLE(TIZEN_INPUT_COLOR_TYPE) // wait for upstream
344 , colorPickerResultListener(0)
346 #if ENABLE(TOUCH_EVENTS)
347 , areTouchEventsEnabled(false)
350 , isUsingEcoreX(false)
352 #if USE(ACCELERATED_COMPOSITING)
359 ~_Ewk_View_Private_Data()
361 eina_stringshare_del(uri);
362 eina_stringshare_del(title);
363 eina_stringshare_del(theme);
364 eina_stringshare_del(customEncoding);
365 _ewk_view_priv_loading_resources_clear(loadingResourcesMap);
368 evas_object_del(cursorObject);
370 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
371 if (compositionAnimator) {
372 ecore_animator_del(compositionAnimator);
373 compositionAnimator = 0;
381 struct _Ewk_View_Callback_Context {
383 Ewk_Web_App_Capable_Get_Callback webAppCapableCallback;
384 Ewk_Web_App_Icon_URL_Get_Callback webAppIconURLCallback;
385 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
386 Ewk_Web_Storage_Quota_Get_Callback webStorageQuotaCallback;
388 Ewk_View_Script_Execute_Callback scriptExecuteCallback;
389 Ewk_View_Plain_Text_Get_Callback plainTextGetCallback;
390 #if ENABLE(TIZEN_SUPPORT_MHTML)
391 Ewk_View_MHTML_Data_Get_Callback mhtmlDataGetCallback;
393 Ewk_View_JavaScript_Alert_Callback javascriptAlertCallback;
394 Ewk_View_JavaScript_Confirm_Callback javascriptConfirmCallback;
395 Ewk_View_JavaScript_Prompt_Callback javascriptPromptCallback;
396 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
397 Ewk_View_Before_Unload_Confirm_Panel_Callback beforeUnloadConfirmPanelCallback;
399 Ewk_View_Open_Panel_Callback openPanelCallback;
402 Evas_Object* ewkView;
405 #endif // #if OS(TIZEN)
407 #define EWK_VIEW_TYPE_CHECK(ewkView, result) \
408 bool result = true; \
410 const char* _tmp_otype = evas_object_type_get(ewkView); \
411 const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
412 if (EINA_UNLIKELY(!_tmp_s)) { \
414 ("%p (%s) is not a smart object!", \
415 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
419 const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
420 if (EINA_UNLIKELY(!_tmp_sc)) { \
422 ("%p (%s) is not a smart object!", \
423 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
427 else if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \
429 ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
430 ewkView, _tmp_otype ? _tmp_otype : "(null)", \
431 EWK_VIEW_TYPE_STR, _tmp_sc->data); \
436 #define EWK_VIEW_SD_GET(ewkView, smartData) \
437 EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \
438 Ewk_View_Smart_Data* smartData = 0; \
440 smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView);
442 #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \
443 EWK_VIEW_SD_GET(ewkView, smartData); \
445 EINA_LOG_CRIT("no smart data for object %p (%s)", \
446 ewkView, evas_object_type_get(ewkView)); \
447 return __VA_ARGS__; \
450 #define EWK_VIEW_PRIV_GET(smartData, priv) \
451 Ewk_View_Private_Data* priv = smartData->priv
453 #define EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, ...) \
455 EINA_LOG_CRIT("smart data is null"); \
456 return __VA_ARGS__; \
458 EWK_VIEW_PRIV_GET(smartData, priv); \
460 EINA_LOG_CRIT("no private data for object %p (%s)", \
461 smartData->self, evas_object_type_get(smartData->self)); \
462 return __VA_ARGS__; \
465 #define EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, ...) \
467 EINA_LOG_CRIT("smart data is null"); \
468 return __VA_ARGS__; \
470 EwkViewImpl* impl = smartData->ewkViewImpl; \
473 EINA_LOG_CRIT("no private data for object %p (%s)", \
474 smartData->self, evas_object_type_get(smartData->self)); \
475 return __VA_ARGS__; \
479 #define EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, ...) \
480 EwkViewImpl* impl = 0; \
482 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, __VA_ARGS__); \
483 impl = smartData->ewkViewImpl; \
485 EINA_LOG_CRIT("no private data for object %p (%s)", \
486 smartData->self, evas_object_type_get(smartData->self)); \
487 return __VA_ARGS__; \
492 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object*, const char* alertText, void* userData);
493 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object*, const char* message, void* userData);
494 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object*, const char* message, const char* defaultValue, void* userData);
495 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
496 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object*, const char* message, void* userData);
498 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);
500 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
501 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);
502 #if ENABLE(TIZEN_MULTIPLE_SELECT)
503 Eina_Bool _ewk_view_multiple_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items);
505 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data*);
506 Eina_Bool _ewk_view_popup_menu_update(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, Eina_List*, int);
508 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
509 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations);
510 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd);
513 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
514 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data*, Ewk_Input_Type, const char* inputValue);
517 #if ENABLE(TIZEN_DATALIST_ELEMENT)
518 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data*, Ewk_Input_Type, Eina_List*);
519 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data*, Ewk_Input_Type);
522 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
523 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data*, int, int, int, int);
524 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data*);
527 #if ENABLE(TIZEN_ISF_PORT)
528 static void _ewk_view_imf_context_destroy(Ewk_View_Private_Data*);
531 #endif // #if OS(TIZEN)
533 static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
535 if (smartData->changed.any)
537 smartData->changed.any = true;
538 evas_object_smart_changed(smartData->self);
541 // Default Event Handling.
542 static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
544 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
548 priv->pageClient->setViewFocused(true);
549 #endif // #if OS(TIZEN)
550 priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
551 #if ENABLE(TIZEN_ISF_PORT)
552 if (priv->imfContext) {
553 ecore_imf_context_focus_in(priv->imfContext);
554 ecore_imf_context_input_panel_show(priv->imfContext);
560 static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
562 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
566 #if ENABLE(TIZEN_ISF_PORT)
567 // Keypad should be hidden rapidly when moving focus on elementary
568 // because Ecore-ime doesn't support it.
569 if (priv->imfContext) {
570 ecore_imf_context_input_panel_hide(priv->imfContext);
571 ecore_imf_context_focus_out(priv->imfContext);
575 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
576 if (priv->pageClient->isTextSelectionMode())
577 priv->pageClient->setIsTextSelectionMode(false);
580 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
581 if (priv->pageClient->isContextMenuVisible())
582 priv->pageClient->page()->hideContextMenu();
585 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
586 priv->pageClient->clearClipboardSelectionHandler();
589 #if ENABLE(TIZEN_DRAG_SUPPORT)
590 if (priv->pageClient->isDragMode())
591 priv->pageClient->setDragMode(false);
594 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
595 if (smartData->api->formdata_candidate_is_showing(smartData))
596 smartData->api->formdata_candidate_hide(smartData);
599 priv->pageClient->setViewFocused(false);
600 #endif // #if OS(TIZEN)
601 priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
605 static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
607 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
608 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
610 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
611 //impl->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
612 priv->pageClient->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
616 static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
618 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
619 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
621 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
622 //impl->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
623 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
627 static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
629 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
630 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
632 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
633 //impl->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
634 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
638 static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
640 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
641 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
643 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
644 //impl->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
645 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
649 static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
651 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
653 #if ENABLE(TIZEN_ISF_PORT)
654 Ecore_IMF_Event IMFEvent;
655 ecore_imf_evas_event_key_down_wrap(const_cast<Evas_Event_Key_Down*>(downEvent), &IMFEvent.key_down);
656 bool filtered = ecore_imf_context_filter_event(priv->imfContext, ECORE_IMF_EVENT_KEY_DOWN, &IMFEvent);
658 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, filtered));
660 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent));
661 #endif // #if ENABLE(TIZEN_ISF_PORT)
665 static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
667 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
669 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
674 static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
676 #if ENABLE(TIZEN_GESTURE)
677 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
678 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
680 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
681 if (priv->pageClient->isTextSelectionMode() && priv->pageClient->isTextSelectionHandleDowned())
685 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
686 if (priv->focusRing) {
687 if (event->type == EWK_GESTURE_TAP && event->count == 1) {
688 priv->focusRing->requestToShow(IntPoint(event->position.x, event->position.y));
689 } else if (event->type == EWK_GESTURE_PAN) {
690 if (priv->exceedTouchMoveThreshold)
691 priv->focusRing->hide();
693 if (!event->type == EWK_GESTURE_LONG_PRESS) {
694 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
695 if (!priv->pageClient->isContextMenuVisible())
697 priv->focusRing->hide();
703 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
704 if (smartData->api->formdata_candidate_is_showing(smartData))
705 smartData->api->formdata_candidate_hide(smartData);
708 switch (event->type) {
709 case EWK_GESTURE_TAP:
710 priv->gestureClient->startTap(IntPoint(event->position.x, event->position.y));
712 case EWK_GESTURE_LONG_PRESS: {
713 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
714 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
715 if (ewk_settings_text_selection_enabled_get(priv->settings.get()))
716 priv->pageClient->setIsTextSelectionMode(false);
718 IntPoint scenePoint(event->position.x, event->position.y);
719 IntPoint contentsPoint = impl->transformFromScene().mapPoint(scenePoint);
720 WebHitTestResult::Data hitTestResultData = priv->pageClient->page()->hitTestResultAtPoint(contentsPoint);
721 #if ENABLE(TIZEN_DRAG_SUPPORT)
722 // 1. Check to start dragging.
723 if (hitTestResultData.isDragSupport) {
724 priv->pageClient->setDragPoint(scenePoint);
725 priv->gestureClient->showContextMenu(scenePoint);
729 // 2. Check to show context menu.
730 if (!hitTestResultData.absoluteImageURL.isEmpty()
731 || !hitTestResultData.absoluteLinkURL.isEmpty()
732 || !hitTestResultData.absoluteMediaURL.isEmpty()) {
733 priv->gestureClient->showContextMenu(scenePoint);
736 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
737 // 3. Check for text selection.
738 if (ewk_settings_text_selection_enabled_get(priv->settings.get())) {
739 // Process gesture_end(EWK_GESTURE_TAP) to activate the editing if node under point is editable.
740 if (hitTestResultData.context & WebHitTestResult::HitTestResultContextEditable) {
741 if (smartData->api && smartData->api->gesture_end) {
742 Ewk_Event_Gesture tapEvent = {EWK_GESTURE_TAP, event->position, {0, 0}, 0, 1, ecore_time_get() * 1000};
743 smartData->api->gesture_end(smartData, &tapEvent);
747 if (priv->pageClient->textSelectionDown(scenePoint)) {
748 priv->gestureClient->setGestureEnabled(false);
749 ewkViewHandleTouchEvent(smartData->self, EWK_TOUCH_CANCEL);
754 #endif // #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
756 case EWK_GESTURE_PAN:
757 priv->gestureClient->startPan(IntPoint(event->position.x, event->position.y));
759 case EWK_GESTURE_FLICK:
760 priv->gestureClient->startFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
762 case EWK_GESTURE_PINCH:
763 if (priv->pageClient->viewportConstraints().userScalable)
764 priv->gestureClient->startPinch(IntPoint(event->position.x, event->position.y), event->scale);
767 ASSERT_NOT_REACHED();
774 #endif // #if ENABLE(TIZEN_GESTURE)
777 static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
779 #if ENABLE(TIZEN_GESTURE)
780 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
782 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
783 if (priv->pageClient->isTextSelectionMode() && priv->pageClient->isTextSelectionHandleDowned())
787 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
788 if (priv->focusRing) {
789 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
790 if (!priv->pageClient->isContextMenuVisible())
792 priv->focusRing->hide();
796 switch (event->type) {
797 case EWK_GESTURE_TAP:
798 if (event->count == 1) {
799 #if ENABLE(TIZEN_DRAG_SUPPORT)
800 if (priv->pageClient->isDragMode())
801 priv->pageClient->setDragMode(false);
803 priv->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
804 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
805 if (priv->pageClient->isTextSelectionMode())
806 priv->pageClient->setIsTextSelectionMode(false);
808 #if ENABLE(TIZEN_ISF_PORT)
809 evas_object_focus_set(smartData->self, true);
811 } else if (event->count == 2 && priv->useSmartSelection)
812 priv->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
814 case EWK_GESTURE_LONG_PRESS:
815 #if ENABLE(TIZEN_DRAG_SUPPORT)
816 if (priv->pageClient->isDragMode())
817 priv->pageClient->setDragMode(false);
819 // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
820 priv->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
822 case EWK_GESTURE_PAN:
823 priv->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
825 case EWK_GESTURE_FLICK:
826 priv->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
828 case EWK_GESTURE_PINCH:
829 priv->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
832 ASSERT_NOT_REACHED();
839 #endif // #if ENABLE(TIZEN_GESTURE)
842 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
844 #if ENABLE(TIZEN_GESTURE)
845 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
847 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
848 if (priv->pageClient->isTextSelectionMode() && priv->pageClient->isTextSelectionHandleDowned())
852 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
853 if (priv->focusRing && !(event->type == EWK_GESTURE_PAN && !priv->exceedTouchMoveThreshold))
854 priv->focusRing->hide();
857 switch (event->type) {
858 case EWK_GESTURE_PAN:
859 priv->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
861 case EWK_GESTURE_TAP:
862 case EWK_GESTURE_LONG_PRESS:
863 case EWK_GESTURE_FLICK:
865 case EWK_GESTURE_PINCH:
866 if (priv->pageClient->viewportConstraints().userScalable)
867 priv->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
870 ASSERT_NOT_REACHED();
877 #endif // #if ENABLE(TIZEN_GESTURE)
879 #endif //#if OS(TIZEN)
882 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
884 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
885 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
886 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
887 smartData->api->focus_in(smartData);
890 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
892 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
893 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
894 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
895 smartData->api->focus_out(smartData);
898 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
900 Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
901 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
902 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
903 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
904 smartData->api->mouse_wheel(smartData, wheelEvent);
907 static void _ewk_view_on_mouse_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
909 Evas_Event_Mouse_Down* downEvent = static_cast<Evas_Event_Mouse_Down*>(eventInfo);
910 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
911 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
912 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_down);
913 smartData->api->mouse_down(smartData, downEvent);
916 static void _ewk_view_on_mouse_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
918 Evas_Event_Mouse_Up* upEvent = static_cast<Evas_Event_Mouse_Up*>(eventInfo);
919 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
920 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
921 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_up);
922 smartData->api->mouse_up(smartData, upEvent);
925 static void _ewk_view_on_mouse_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
927 Evas_Event_Mouse_Move* moveEvent = static_cast<Evas_Event_Mouse_Move*>(eventInfo);
928 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
929 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
930 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_move);
931 smartData->api->mouse_move(smartData, moveEvent);
934 static void _ewk_view_on_key_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
936 Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
937 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
938 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
939 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
940 smartData->api->key_down(smartData, downEvent);
943 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
945 Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
946 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
947 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
948 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
949 smartData->api->key_up(smartData, upEvent);
952 #if ENABLE(TOUCH_EVENTS)
953 static inline void _ewk_view_feed_touch_event_using_touch_point_list_of_evas(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
955 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
957 unsigned count = evas_touch_point_list_count(smartData->base.evas);
961 Eina_List* points = 0;
962 for (unsigned i = 0; i < count; ++i) {
963 Ewk_Touch_Point* point = new Ewk_Touch_Point;
964 point->id = evas_touch_point_list_nth_id_get(smartData->base.evas, i);
965 evas_touch_point_list_nth_xy_get(smartData->base.evas, i, &point->x, &point->y);
966 point->state = evas_touch_point_list_nth_state_get(smartData->base.evas, i);
967 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_GESTURE)
968 if (type == EWK_TOUCH_CANCEL)
969 point->state = EVAS_TOUCH_POINT_CANCEL;
971 points = eina_list_append(points, point);
974 ewk_view_feed_touch_event(ewkView, type, points, evas_key_modifier_get(smartData->base.evas));
977 EINA_LIST_FREE(points, data)
978 delete static_cast<Ewk_Touch_Point*>(data);
981 static void _ewk_view_on_touch_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
983 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_START);
986 static void _ewk_view_on_touch_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
988 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_END);
991 static void _ewk_view_on_touch_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
993 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_MOVE);
997 void ewkViewHandleTouchEvent(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
999 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, type);
1005 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1006 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
1008 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1010 return priv->pageClient->textSelectionDown(IntPoint(x, y), true);
1013 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
1015 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1017 IntPoint point(x, y);
1018 priv->pageClient->textSelectionMove(point, true);
1023 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
1025 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1027 IntPoint point(x, y);
1028 priv->pageClient->textSelectionUp(point, true);
1034 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1035 static void _ewk_view_data_list_del(Eina_List* dataList)
1037 EINA_SAFETY_ON_NULL_RETURN(dataList);
1040 EINA_LIST_FREE(dataList, item)
1041 eina_stringshare_del(static_cast<char*>(item));
1045 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1046 Eina_Bool _ewk_view_smart_formdata_candidate_show(Ewk_View_Smart_Data* smartData, int x, int y, int w, int h)
1048 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1050 priv->pageClient->showFormDataCandidate(IntRect(x, y, w, h));
1055 Eina_Bool _ewk_view_smart_formdata_candidate_hide(Ewk_View_Smart_Data* smartData)
1057 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1059 priv->pageClient->hideFormDataCandidate();
1064 Eina_Bool _ewk_view_smart_formdata_candidate_update_data(Ewk_View_Smart_Data* smartData, Eina_List* dataList)
1066 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1068 Vector<String> formData;
1071 EINA_LIST_FOREACH(dataList, list, data)
1072 formData.append(String::fromUTF8(static_cast<char*>(data)));
1074 priv->pageClient->updateFormDataCandidate(formData);
1079 Eina_Bool _ewk_view_smart_formdata_candidate_is_showing(Ewk_View_Smart_Data* smartData)
1081 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1083 return priv->pageClient->isShowingFormDataCandidate();
1087 #if ENABLE(TIZEN_SCREEN_READER)
1088 Eina_Bool _ewk_view_screen_reader_command_execute(Ewk_View_Smart_Data* smartData, unsigned int command, int data1, int data2)
1090 return ScreenReaderProxy::screenReader().executeCommand(smartData->self, command, data1, data2);
1093 #endif // #if OS(TIZEN)
1095 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
1097 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1098 static uint64_t generatePageGroupIdentifierID()
1100 static uint64_t uniquePageGroupIdentifierID = 1;
1101 return uniquePageGroupIdentifierID++;
1105 static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
1107 Ewk_View_Private_Data* priv = new Ewk_View_Private_Data;
1108 memset(priv, 0, sizeof(Ewk_View_Private_Data)); // FIXME : below code should be considered to move to constructor.
1110 priv->areMouseEventsEnabled = false;
1112 priv->javascriptPopup = adoptPtr<JavaScriptPopup>(new JavaScriptPopup(smartData->self));
1113 priv->openPanel = adoptPtr<OpenPanel>(new OpenPanel(smartData->self));
1115 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1116 priv->inputPicker = adoptPtr<InputPicker>(new InputPicker(smartData->self));
1117 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1119 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1120 priv->focusRing = FocusRing::create(smartData->self);
1121 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1123 #if ENABLE(TIZEN_GESTURE)
1124 priv->gestureRecognizer = GestureRecognizer::create(smartData->self);
1125 priv->gestureClient = GestureClient::create(smartData->ewkViewImpl);
1126 priv->useSmartSelection = true;
1127 #endif // #if ENABLE(TIZEN_GESTURE)
1128 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1129 const char* hideScrollbar = getenv("TIZEN_WEBKIT2_TILED_SCROLLBAR_HIDE");
1130 if (hideScrollbar && atoi(hideScrollbar) == 1)
1131 priv->mainFrameScrollbarVisibility = false;
1133 priv->mainFrameScrollbarVisibility = true;
1136 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1140 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1141 String pageGroupIdentifierID = String::number(generatePageGroupIdentifierID());
1142 String pageGroupIdentifier = String::format("PageGroup%s", pageGroupIdentifierID.utf8().data());
1144 WKRetainPtr<WKStringRef> pageGroupIdentifierRef(AdoptWK, WKStringCreateWithUTF8CString(pageGroupIdentifier.utf8().data()));
1145 priv->pageGroup = WebPageGroup::create(toWTFString(pageGroupIdentifierRef.get()));
1148 priv->suspendRequested = false;
1149 priv->suspendedPainting = false;
1150 priv->suspendedResources = false;
1151 #endif // #if OS(TIZEN)
1154 priv->isUsingEcoreX = WebCore::isUsingEcoreX(smartData->base.evas);
1160 static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap)
1162 // Clear the loadingResources HashMap.
1163 LoadingResourcesMap::iterator it = loadingResourcesMap.begin();
1164 LoadingResourcesMap::iterator end = loadingResourcesMap.end();
1165 for ( ; it != end; ++it)
1166 ewk_web_resource_unref(it->second);
1168 loadingResourcesMap.clear();
1171 static void _ewk_view_priv_del(Ewk_View_Private_Data* priv)
1177 if (priv->javascriptGlobalContext)
1178 JSGlobalContextRelease(priv->javascriptGlobalContext);
1180 eina_stringshare_del(priv->userAgent);
1181 eina_stringshare_del(priv->encoding);
1182 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1183 eina_stringshare_del(priv->webAppIconURL);
1186 if (priv->authChallenge)
1187 ewkAuthChallengeDelete(priv->authChallenge);
1188 if (priv->policyDecision)
1189 ewkPolicyDecisionDelete(priv->policyDecision);
1191 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1192 if (priv->certificatePolicyDecision)
1193 ewkCertificatePolicyDecisionDelete(priv->certificatePolicyDecision);
1196 #if ENABLE(TIZEN_MEDIA_STREAM)
1197 if (priv->userMediaPermissionRequests)
1198 ewkUserMediaDeletePermissionRequestList(priv->userMediaPermissionRequests);
1201 priv->openPanelListener = 0;
1202 priv->openPanel = nullptr;
1203 priv->javascriptPopup = nullptr;
1204 priv->alertContext = nullptr;
1205 priv->confirmContext = nullptr;
1206 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1207 priv->beforeUnloadConfirmPanelContext = nullptr;
1209 priv->promptContext = nullptr;
1210 priv->isWaitingForJavaScriptPopupReply = false;
1211 priv->openpanelContext = nullptr;
1212 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1213 priv->inputPicker = nullptr;
1214 eina_stringshare_del(priv->inputValue);
1217 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1218 if (priv->dataList) {
1219 _ewk_view_data_list_del(priv->dataList);
1224 #if ENABLE(TIZEN_GEOLOCATION)
1225 if (priv->geolocation)
1226 ewkGeolocationDeleteGeolocation(priv->geolocation);
1227 if (priv->geolocationPermissionRequests)
1228 ewkGeolocationDeletePermissionRequestList(priv->geolocationPermissionRequests);
1231 #if ENABLE(TIZEN_NOTIFICATIONS)
1232 if (priv->notifications)
1233 ewkNotificationDeleteNotificationList(priv->notifications);
1234 if (priv->notificationPermissionRequests)
1235 ewkNotificationDeletePermissionRequestList(priv->notificationPermissionRequests);
1237 #if ENABLE(TIZEN_SQL_DATABASE)
1238 if (priv->exceededDatabaseQuota)
1239 ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
1241 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1242 priv->focusRing = nullptr;
1243 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1244 #if ENABLE(TIZEN_GESTURE)
1245 priv->gestureRecognizer = nullptr;
1246 priv->gestureClient = nullptr;
1247 #endif // #if ENABLE(TIZEN_GESTURE)
1249 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1250 eina_stringshare_del(priv->selectedText);
1252 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1253 priv->pageGroup = nullptr;
1256 #if ENABLE(TIZEN_ISF_PORT)
1257 _ewk_view_imf_context_destroy(priv);
1259 #endif // #if OS(TIZEN)
1264 static void _ewk_view_smart_add(Evas_Object* ewkView)
1266 const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
1267 const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
1268 const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
1269 EWK_VIEW_SD_GET(ewkView, smartData);
1272 smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
1274 EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
1277 evas_object_smart_data_set(ewkView, smartData);
1280 smartData->self = ewkView;
1281 smartData->api = api;
1283 g_parentSmartClass.add(ewkView);
1285 // FIXME: Ewk_View_Private_Data was replaced with EwkViewImpl in the webkit opensource.
1286 // So, we have both Ewk_View_Private_Data and EwkViewImpl now,
1287 // but Ewk_View_Private_Data should be removed later.
1288 smartData->ewkViewImpl = new EwkViewImpl(ewkView);
1289 smartData->priv = _ewk_view_priv_new(smartData);
1291 // Create evas_object_image to draw web contents.
1292 smartData->image = evas_object_image_add(smartData->base.evas);
1293 evas_object_image_alpha_set(smartData->image, false);
1294 evas_object_image_filled_set(smartData->image, true);
1295 evas_object_smart_member_add(smartData->image, ewkView);
1298 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1299 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
1300 const char *engine = ecore_evas_engine_name_get(ee);
1301 if (engine && !strcmp(engine, "opengl_x11"))
1302 evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
1304 ewk_view_mouse_events_enabled_set(ewkView, false);
1305 ewk_view_touch_events_enabled_set(ewkView, true);
1307 // FIXME: This code should be removed if side effect occur.
1308 // WebView does not have focus after url loading.
1309 // If focus is set as true to webview,
1310 // elementary steal webview's focus during mouse up event
1311 // So, added code that events are not propagated to smart parent according to guide from EFL
1312 evas_object_propagate_events_set(ewkView, false);
1314 #if ENABLE(TIZEN_SCREEN_READER)
1315 ScreenReaderProxy::screenReader().addView(ewkView);
1317 #endif // #if OS(TIZEN)
1319 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
1320 CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
1321 CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
1322 CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
1324 CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
1325 CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
1326 CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
1328 CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
1329 CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
1333 static void _ewk_view_smart_del(Evas_Object* ewkView)
1335 EWK_VIEW_SD_GET(ewkView, smartData);
1336 #if ENABLE(TIZEN_SCREEN_READER)
1337 ScreenReaderProxy::screenReader().removeView(ewkView);
1339 if (smartData && smartData->priv) {
1340 _ewk_view_priv_del(smartData->priv);
1341 smartData->priv = 0;
1344 // FIXME: Ewk_View_Private_Data was replaced with EwkViewImpl in the webkit opensource.
1345 // If then, ewkViewImpl will be changed to priv.
1347 delete smartData->ewkViewImpl;
1349 g_parentSmartClass.del(ewkView);
1352 static Eina_Bool _ewk_view_composite(void* data);
1354 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
1356 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1358 evas_object_resize(smartData->image, width, height);
1359 evas_object_image_size_set(smartData->image, width, height);
1360 evas_object_image_fill_set(smartData->image, 0, 0, width, height);
1362 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1363 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1364 evas_object_image_native_surface_set(smartData->image, 0);
1366 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1367 if (!ewk_view_is_opengl_backend(ewkView))
1368 _ewk_view_composite(smartData);
1369 else // OpenGL backend
1371 priv->pageClient->displayViewport();
1373 #endif // #if OS(TIZEN)
1375 smartData->changed.size = true;
1376 _ewk_view_smart_changed(smartData);
1379 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
1381 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1383 smartData->changed.position = true;
1384 _ewk_view_smart_changed(smartData);
1387 IntSize ewk_view_size_get(const Evas_Object* ewkView)
1390 evas_object_geometry_get(ewkView, 0, 0, &width, &height);
1391 return IntSize(width, height);
1394 #if USE(ACCELERATED_COMPOSITING)
1395 static bool ewk_view_create_gl_surface(const Evas_Object* ewkView, const IntSize& viewSize)
1397 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1398 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1400 Evas_GL_Config evasGlConfig = {
1402 EVAS_GL_DEPTH_BIT_8,
1403 EVAS_GL_STENCIL_NONE,
1404 EVAS_GL_OPTIONS_NONE,
1405 EVAS_GL_MULTISAMPLE_NONE
1408 ASSERT(!priv->evasGlSurface);
1409 priv->evasGlSurface = evas_gl_surface_create(priv->evasGl, &evasGlConfig, viewSize.width(), viewSize.height());
1410 if (!priv->evasGlSurface)
1413 Evas_Native_Surface nativeSurface;
1414 evas_gl_native_surface_get(priv->evasGl, priv->evasGlSurface, &nativeSurface);
1415 evas_object_image_native_surface_set(smartData->image, &nativeSurface);
1420 bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView)
1422 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1423 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1425 EINA_SAFETY_ON_TRUE_RETURN_VAL(!!priv->evasGl, false);
1427 Evas* evas = evas_object_evas_get(ewkView);
1428 priv->evasGl = evas_gl_new(evas);
1432 priv->evasGlContext = evas_gl_context_create(priv->evasGl, 0);
1433 if (!priv->evasGlContext) {
1434 evas_gl_free(priv->evasGl);
1439 if (!ewk_view_create_gl_surface(ewkView, ewk_view_size_get(ewkView))) {
1440 evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
1441 priv->evasGlContext = 0;
1443 evas_gl_free(priv->evasGl);
1451 bool ewk_view_accelerated_compositing_mode_exit(const Evas_Object* ewkView)
1453 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1454 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1456 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->evasGl, false);
1458 if (priv->evasGlSurface) {
1459 evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
1460 priv->evasGlSurface = 0;
1463 if (priv->evasGlContext) {
1464 evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
1465 priv->evasGlContext = 0;
1468 evas_gl_free(priv->evasGl);
1475 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
1477 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1478 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1479 Evas_Coord x, y, width, height;
1481 smartData->changed.any = false;
1483 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
1485 if (smartData->changed.size) {
1487 if (priv->pageClient->page()->drawingArea())
1488 priv->pageClient->page()->drawingArea()->setSize(IntSize(width, height), IntSize());
1490 #if USE(ACCELERATED_COMPOSITING)
1491 if (!priv->evasGlSurface)
1493 evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
1494 priv->evasGlSurface = 0;
1495 ewk_view_create_gl_surface(ewkView, IntSize(width, height));
1496 ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
1498 #endif // #if !OS(TIZEN)
1500 smartData->view.w = width;
1501 smartData->view.h = height;
1502 smartData->changed.size = false;
1505 if (priv->pageClient) {
1506 if (DrawingAreaProxy* drawingArea = priv->pageClient->page()->drawingArea()) {
1507 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1508 if (priv->pageClient->page()->isViewVisible())
1509 drawingArea->setSize(IntSize(width, height), IntSize());
1511 drawingArea->setSize(IntSize(width, height), IntSize());
1513 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1514 priv->pageClient->updateViewportSize(IntSize(width, height));
1515 if (ewk_view_is_opengl_backend(ewkView))
1516 priv->pageClient->displayViewport();
1519 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1520 priv->pageClient->frameRectChanged();
1523 #endif // #if OS(TIZEN)
1526 if (smartData->changed.position) {
1527 evas_object_move(smartData->image, x, y);
1528 smartData->view.x = x;
1529 smartData->view.y = y;
1530 smartData->changed.position = false;
1532 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1533 priv->pageClient->frameRectChanged();
1535 #if ENABLE(TIZEN_SCREEN_READER)
1536 priv->pageClient->page()->recalcScreenReaderFocusRect();
1538 #endif // #if OS(TIZEN)
1541 if (priv->popupPicker)
1542 ewk_popup_picker_resize(priv->popupPicker);
1543 #endif // #if OS(TIZEN)
1546 static void _ewk_view_smart_show(Evas_Object* ewkView)
1548 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1549 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1551 if (evas_object_clipees_get(smartData->base.clipper))
1552 evas_object_show(smartData->base.clipper);
1553 evas_object_show(smartData->image);
1556 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1558 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1560 evas_object_hide(smartData->base.clipper);
1561 evas_object_hide(smartData->image);
1562 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1563 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1564 if (priv->pageClient->isTextSelectionMode())
1565 priv->pageClient->setIsTextSelectionMode(false);
1569 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1571 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1572 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1576 else if (alpha > 255)
1579 #define CHECK_COLOR(color, alpha) \
1582 else if (color > alpha) \
1584 CHECK_COLOR(red, alpha);
1585 CHECK_COLOR(green, alpha);
1586 CHECK_COLOR(blue, alpha);
1589 evas_object_image_alpha_set(smartData->image, alpha < 255);
1590 priv->pageClient->page()->setDrawsBackground(red || green || blue);
1591 priv->pageClient->page()->setDrawsTransparentBackground(alpha < 255);
1592 priv->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1595 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1599 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1601 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1603 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1604 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1605 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1609 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1610 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1612 evas_object_smart_clipped_smart_set(&api->sc);
1614 // Set Evas_Smart_Class functions.
1615 api->sc.add = _ewk_view_smart_add;
1616 api->sc.del = _ewk_view_smart_del;
1617 api->sc.move = _ewk_view_smart_move;
1618 api->sc.resize = _ewk_view_smart_resize;
1619 api->sc.show = _ewk_view_smart_show;
1620 api->sc.hide = _ewk_view_smart_hide;
1621 api->sc.color_set = _ewk_view_smart_color_set;
1622 api->sc.calculate = _ewk_view_smart_calculate;
1623 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1625 // Set Ewk_View_Smart_Class functions.
1626 api->focus_in = _ewk_view_smart_focus_in;
1627 api->focus_out = _ewk_view_smart_focus_out;
1628 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1629 api->mouse_down = _ewk_view_smart_mouse_down;
1630 api->mouse_up = _ewk_view_smart_mouse_up;
1631 api->mouse_move = _ewk_view_smart_mouse_move;
1632 api->key_down = _ewk_view_smart_key_down;
1633 api->key_up = _ewk_view_smart_key_up;
1635 api->gesture_start = _ewk_view_smart_gesture_start;
1636 api->gesture_end = _ewk_view_smart_gesture_end;
1637 api->gesture_move = _ewk_view_smart_gesture_move;
1639 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1640 api->popup_menu_show = _ewk_view_popup_menu_show;
1641 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1642 api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1644 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1645 api->popup_menu_update = _ewk_view_popup_menu_update;
1647 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1648 api->text_selection_down = _ewk_view_text_selection_down;
1649 api->text_selection_move = _ewk_view_text_selection_move;
1650 api->text_selection_up = _ewk_view_text_selection_up;
1652 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1653 api->input_picker_show = _ewk_view_input_picker_show;
1655 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1656 api->data_list_show = _ewk_view_data_list_show;
1657 api->data_list_hide = _ewk_view_data_list_hide;
1659 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1660 api->orientation_lock = _ewk_orientation_lock;
1661 api->orientation_unlock = _ewk_orientation_unlock;
1663 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1664 api->input_picker_color_request = _ewk_input_picker_color_request;
1665 api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1667 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1668 api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1669 api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1670 api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1671 api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1673 #if ENABLE(TIZEN_SCREEN_READER)
1674 api->screen_reader_command_execute = _ewk_view_screen_reader_command_execute;
1676 #endif //#if OS(TIZEN)
1681 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1683 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1684 static Evas_Smart* smart = 0;
1686 if (EINA_UNLIKELY(!smart)) {
1687 ewk_view_smart_class_set(&api);
1688 smart = evas_smart_class_new(&api.sc);
1694 static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKPageGroupRef pageGroupRef)
1696 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1697 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
1698 EINA_SAFETY_ON_NULL_RETURN(context);
1700 if (priv->pageClient)
1703 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1704 if (ewk_view_is_opengl_backend(ewkView)) {
1705 priv->pageClient = PageClientEvasGL::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1706 priv->pageClient->page()->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1709 priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1710 priv->pageClient->page()->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1711 priv->pageClient->page()->pageGroup()->preferences()->setWebGLEnabled(false);
1712 priv->pageClient->page()->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1715 priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1717 // FixMe: Comment should be removed when pageClient is removed.
1718 //priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageProxy.get())))));
1719 priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageClient->page())))));
1722 priv->context = context;
1724 ewkViewContextMenuClientAttachClient(ewkView);
1725 ewkViewFindClientAttatchClient(ewkView);
1726 ewkViewTizenClientAttachClient(ewkView);
1727 ewkViewUIClientAttatchClient(ewkView);
1729 #if ENABLE(TIZEN_GEOLOCATION)
1730 ewkViewGeolocationProviderAttachProvider(ewkView, ewk_context_WKContext_get(context));
1733 #if ENABLE(TIZEN_NOTIFICATIONS)
1734 ewkViewNotificationProviderAttachProvider(ewkView, ewk_context_WKContext_get(context));
1737 #if ENABLE(TIZEN_ICON_DATABASE)
1738 ewk_view_icondatabase_client_attach(ewkView, ewk_context_WKContext_get(context));
1741 ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1742 ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1743 ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1744 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1745 ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1747 ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1748 #else // #if OS(TIZEN)
1749 priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageClient->page()->backForwardList()));
1751 #if USE(COORDINATED_GRAPHICS)
1752 priv->viewportHandler = EflViewportHandler::create(priv->pageClient.get());
1754 #endif // #if OS(TIZEN)
1756 WKPageRef wkPage = toAPI(priv->pageClient->page());
1757 ewk_view_form_client_attach(wkPage, ewkView);
1758 ewk_view_loader_client_attach(wkPage, ewkView);
1759 ewk_view_policy_client_attach(wkPage, ewkView);
1760 ewk_view_resource_load_client_attach(wkPage, ewkView);
1762 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1763 ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1766 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1767 if (!ewk_context_x_window_get(context))
1768 ewk_context_x_window_set(context, elm_win_xwindow_get(ewkView));
1772 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1774 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1775 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1777 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1778 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1779 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1784 Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1788 EWK_VIEW_SD_GET(ewkView, smartData);
1790 evas_object_del(ewkView);
1794 EWK_VIEW_PRIV_GET(smartData, priv);
1796 evas_object_del(ewkView);
1805 * Constructs a ewk_view Evas_Object with WKType parameters.
1807 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1809 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1810 EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1812 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1816 _ewk_view_initialize(ewkView, ewk_context_new_from_WKContext(contextRef), pageGroupRef);
1821 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1823 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1824 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1825 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1827 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1831 #if ENABLE(TIZEN_ICON_DATABASE)
1832 //set default iconDatabasePath
1833 WKContextRef contextRef = ewk_context_WKContext_get(context);
1834 toImpl(contextRef)->setIconDatabasePath(toImpl(contextRef)->iconDatabasePath());
1837 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1838 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1839 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1840 _ewk_view_initialize(ewkView, context, toAPI(priv->pageGroup.get()));
1842 _ewk_view_initialize(ewkView, context, 0);
1848 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1850 return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1853 Evas_Object* ewk_view_add(Evas* canvas)
1855 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1860 * The uri of view was changed by the frame loader.
1862 * Emits signal: "uri,changed" with pointer to new uri string.
1864 void ewk_view_uri_update(Evas_Object* ewkView)
1866 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1867 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1869 String activeURL = priv->pageClient->page()->activeURL();
1870 if (activeURL.isEmpty())
1873 if (!eina_stringshare_replace(&priv->uri, activeURL.utf8().data()))
1876 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1877 evas_object_smart_callback_call(ewkView, "url,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1880 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* uri)
1882 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1883 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1884 EINA_SAFETY_ON_NULL_RETURN_VAL(uri, false);
1886 priv->pageClient->page()->loadURL(String::fromUTF8(uri));
1887 ewk_view_uri_update(ewkView);
1892 const char* ewk_view_url_get(const Evas_Object* ewkView)
1894 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1895 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1900 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1902 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1903 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1905 priv->pageClient->page()->reload(/*reloadFromOrigin*/ false);
1906 ewk_view_uri_update(ewkView);
1911 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1913 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1914 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1916 priv->pageClient->page()->reload(/*reloadFromOrigin*/ true);
1917 ewk_view_uri_update(ewkView);
1922 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1924 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1925 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1927 priv->pageClient->page()->stopLoading();
1932 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1934 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1935 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1937 return priv->settings.get();
1942 * Load was initiated for a resource in the view.
1944 * Emits signal: "resource,request,new" with pointer to resource request.
1946 void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request)
1948 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1949 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1951 Ewk_Web_Resource_Request resourceRequest = {resource, request, 0};
1953 // Keep the resource internally to reuse it later.
1954 ewk_web_resource_ref(resource);
1955 priv->loadingResourcesMap.add(resourceIdentifier, resource);
1957 evas_object_smart_callback_call(ewkView, "resource,request,new", &resourceRequest);
1962 * Received a response to a resource load request in the view.
1964 * Emits signal: "resource,request,response" with pointer to resource response.
1966 void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response)
1968 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1969 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1971 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
1974 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
1975 Ewk_Web_Resource_Load_Response resourceLoadResponse = {resource, response};
1976 evas_object_smart_callback_call(ewkView, "resource,request,response", &resourceLoadResponse);
1981 * Failed loading a resource in the view.
1983 * Emits signal: "resource,request,finished" with pointer to the resource load error.
1985 void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Error* error)
1987 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1988 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1990 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
1993 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
1994 Ewk_Web_Resource_Load_Error resourceLoadError = {resource, error};
1995 evas_object_smart_callback_call(ewkView, "resource,request,failed", &resourceLoadError);
2000 * Finished loading a resource in the view.
2002 * Emits signal: "resource,request,finished" with pointer to the resource.
2004 void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIdentifier)
2006 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2007 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2009 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2012 Ewk_Web_Resource* resource = priv->loadingResourcesMap.take(resourceIdentifier);
2013 evas_object_smart_callback_call(ewkView, "resource,request,finished", resource);
2015 ewk_web_resource_unref(resource);
2020 * Request was sent for a resource in the view.
2022 * Emits signal: "resource,request,sent" with pointer to resource request and possible redirect response.
2024 void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse)
2026 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2027 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2029 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2032 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
2033 Ewk_Web_Resource_Request resourceRequest = {resource, request, redirectResponse};
2035 evas_object_smart_callback_call(ewkView, "resource,request,sent", &resourceRequest);
2038 const char* ewk_view_title_get(const Evas_Object* ewkView)
2040 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2041 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2043 CString title = priv->pageClient->page()->pageTitle().utf8();
2044 eina_stringshare_replace(&priv->title, title.data());
2051 * Reports that the requested text was found.
2053 * Emits signal: "text,found" with the number of matches.
2055 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
2057 evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
2062 * The view title was changed by the frame loader.
2064 * Emits signal: "title,changed" with pointer to new title string.
2066 void ewk_view_title_changed(Evas_Object* ewkView, const char* title)
2068 evas_object_smart_callback_call(ewkView, "title,changed", const_cast<char*>(title));
2071 double ewk_view_load_progress_get(const Evas_Object* ewkView)
2073 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2074 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2076 return priv->pageClient->page()->estimatedProgress();
2079 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
2081 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2082 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2088 scaleFactor = priv->pageClient->adjustScaleWithViewport(scaleFactor);
2090 IntPoint scrollPosition = priv->pageClient->scrollPosition();
2091 double scaleDifference = scaleFactor / priv->pageClient->scaleFactor();
2092 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
2093 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
2095 priv->pageClient->page()->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
2097 priv->pageClient->page()->scalePage(scaleFactor, IntPoint(x, y));
2102 double ewk_view_scale_get(const Evas_Object* ewkView)
2104 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
2105 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1);
2108 return priv->pageClient->page()->scaleFactor();
2110 return priv->pageClient->page()->pageScaleFactor();
2114 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
2116 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2117 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2119 priv->pageClient->page()->setCustomDeviceScaleFactor(ratio);
2124 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
2126 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2127 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2129 return priv->pageClient->page()->deviceScaleFactor();
2132 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
2133 void ewk_view_load_progress_started(Evas_Object* ewkView)
2135 evas_object_smart_callback_call(ewkView, "load,progress,started", 0);
2141 * Reports load progress changed.
2143 * Emits signal: "load,progress" with pointer to a double from 0.0 to 1.0.
2145 void ewk_view_load_progress_changed(Evas_Object* ewkView, double progress)
2147 evas_object_smart_callback_call(ewkView, "load,progress", &progress);
2150 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
2151 void ewk_view_load_progress_finished(Evas_Object* ewkView)
2153 evas_object_smart_callback_call(ewkView, "load,progress,finished", 0);
2157 #if ENABLE(WEB_INTENTS)
2160 * The view received a new intent request.
2162 * Emits signal: "intent,request,new" with pointer to a Ewk_Intent.
2164 void ewk_view_intent_request_new(Evas_Object* ewkView, const Ewk_Intent* ewkIntent)
2166 evas_object_smart_callback_call(ewkView, "intent,request,new", const_cast<Ewk_Intent*>(ewkIntent));
2170 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
2172 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2173 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2175 if (!eina_stringshare_replace(&priv->theme, path))
2178 priv->pageClient->page()->setThemePath(path);
2181 const char* ewk_view_theme_get(const Evas_Object* ewkView)
2183 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2184 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2189 void ewk_view_cursor_set(Evas_Object* ewkView, const Cursor& cursor)
2191 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2192 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2194 const char* group = cursor.platformCursor();
2195 if (!group || group == priv->cursorGroup)
2198 priv->cursorGroup = group;
2200 if (priv->cursorObject)
2201 evas_object_del(priv->cursorObject);
2202 priv->cursorObject = edje_object_add(smartData->base.evas);
2204 Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
2205 if (!priv->theme || !edje_object_file_set(priv->cursorObject, priv->theme, group)) {
2206 evas_object_del(priv->cursorObject);
2207 priv->cursorObject = 0;
2209 ecore_evas_object_cursor_set(ecoreEvas, 0, 0, 0, 0);
2211 if (priv->isUsingEcoreX)
2212 WebCore::applyFallbackCursor(ecoreEvas, group);
2217 Evas_Coord width, height;
2218 edje_object_size_min_get(priv->cursorObject, &width, &height);
2219 if (width <= 0 || height <= 0)
2220 edje_object_size_min_calc(priv->cursorObject, &width, &height);
2221 if (width <= 0 || height <= 0) {
2222 width = defaultCursorSize;
2223 height = defaultCursorSize;
2225 evas_object_resize(priv->cursorObject, width, height);
2229 data = edje_object_data_get(priv->cursorObject, "hot.x");
2231 hotspotX = atoi(data);
2234 data = edje_object_data_get(priv->cursorObject, "hot.y");
2236 hotspotY = atoi(data);
2238 ecore_evas_object_cursor_set(ecoreEvas, priv->cursorObject, EVAS_LAYER_MAX, hotspotX, hotspotY);
2241 void ewk_view_display(Evas_Object* ewkView, const IntRect& rect)
2243 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2244 if (!smartData->image)
2247 evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height());
2252 * A download for that view was cancelled.
2254 * Emits signal: "download,cancelled" with pointer to a Ewk_Download_Job.
2256 void ewk_view_download_job_cancelled(Evas_Object* ewkView, Ewk_Download_Job* download)
2258 evas_object_smart_callback_call(ewkView, "download,cancelled", download);
2263 * A new download has been requested for that view.
2265 * Emits signal: "download,request" with pointer to a Ewk_Download_Job.
2267 void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job* download)
2269 evas_object_smart_callback_call(ewkView, "download,request", download);
2274 * A download for that view has failed.
2276 * Emits signal: "download,failed" with pointer to a Ewk_Download_Job_Error.
2278 void ewk_view_download_job_failed(Evas_Object* ewkView, Ewk_Download_Job* download, Ewk_Web_Error* error)
2280 Ewk_Download_Job_Error downloadError = { download, error };
2281 evas_object_smart_callback_call(ewkView, "download,failed", &downloadError);
2286 * A download for that view finished successfully.
2288 * Emits signal: "download,finished" with pointer to a Ewk_Download_Job.
2290 void ewk_view_download_job_finished(Evas_Object* ewkView, Ewk_Download_Job* download)
2292 evas_object_smart_callback_call(ewkView, "download,finished", download);
2295 Eina_Bool ewk_view_back(Evas_Object* ewkView)
2297 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2298 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2300 WebPageProxy* page = priv->pageClient->page();
2301 if (page->canGoBack()) {
2309 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
2311 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2312 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2314 WebPageProxy* page = priv->pageClient->page();
2315 if (page->canGoForward()) {
2323 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
2325 #if ENABLE(WEB_INTENTS)
2326 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2327 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2328 EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
2330 WebPageProxy* page = priv->pageClient->page();
2331 page->deliverIntentToFrame(page->mainFrame(), toImpl(ewk_intent_WKIntentDataRef_get(intent)));
2339 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
2341 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2342 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2344 return priv->pageClient->page()->canGoBack();
2347 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
2349 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2350 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2352 return priv->pageClient->page()->canGoForward();
2355 void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size)
2357 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2358 if (!imageData || !smartData->image)
2361 evas_object_resize(smartData->image, size.width(), size.height());
2362 evas_object_image_size_set(smartData->image, size.width(), size.height());
2363 evas_object_image_data_copy_set(smartData->image, imageData);
2368 * Reports that a form request is about to be submitted.
2370 * Emits signal: "form,submission,request" with pointer to Ewk_Form_Submission_Request.
2372 void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submission_Request* request)
2374 evas_object_smart_callback_call(ewkView, "form,submission,request", request);
2377 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2378 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
2380 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2381 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2383 if (!ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
2386 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(ewkView);
2387 if (!imfContext || ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
2390 if (value.isEmpty()) {
2391 if(smartData->api->formdata_candidate_is_showing(smartData))
2392 smartData->api->formdata_candidate_hide(smartData);
2396 Vector<String> popupCandidates;
2397 ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
2398 std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
2400 Eina_List* candidateList = 0;
2401 for (size_t i = 0; i < popupCandidates.size(); ++i) {
2402 if (popupCandidates[i].startsWith(value, false))
2403 candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
2406 if (!eina_list_count(candidateList)) {
2407 if(smartData->api->formdata_candidate_is_showing(smartData))
2408 smartData->api->formdata_candidate_hide(smartData);
2412 smartData->api->formdata_candidate_update_data(smartData, candidateList);
2414 if (!smartData->api->formdata_candidate_is_showing(smartData))
2415 smartData->api->formdata_candidate_hide(smartData);
2417 IntRect inputFieldRect = priv->pageClient->focusedNodeRect();
2418 smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
2421 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm)
2423 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2424 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2425 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
2426 && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
2428 ewk_context_form_data_add(ewk_view_context_get(ewkView), priv->uri, formData, isPasswordForm);
2431 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
2433 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2434 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2436 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
2439 Vector<std::pair<String, String> > passwordFormData;
2440 ewk_context_form_password_data_get(ewk_view_context_get(ewkView), priv->uri, passwordFormData);
2442 if (!passwordFormData.size())
2445 String passwordFormAutofill = "try { function passwordFormAutofill() { var inputFields;";
2446 for (size_t i = 0; i < passwordFormData.size(); i++) {
2447 passwordFormAutofill += String::format(" inputFields = document.getElementsByName(\"%s\");"
2448 " for (var i = 0; i < inputFields.length; i++)"
2449 " if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\"))"
2450 " inputFields[i].value = \"%s\";",
2451 passwordFormData[i].first.utf8().data(), passwordFormData[i].second.utf8().data());
2453 passwordFormAutofill += "} passwordFormAutofill(); } catch(e) { }";
2454 ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
2457 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
2459 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2460 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2461 ewk_context_form_candidate_data_get(ewk_view_context_get(ewkView), name, candidates);
2467 * Reports load failed with error information.
2469 * Emits signal: "load,error" with pointer to Ewk_Web_Error.
2471 void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error)
2473 evas_object_smart_callback_call(ewkView, "load,error", const_cast<Ewk_Web_Error*>(error));
2478 * Reports load finished.
2480 * Emits signal: "load,finished".
2482 void ewk_view_load_finished(Evas_Object* ewkView)
2484 ewk_view_uri_update(ewkView);
2485 evas_object_smart_callback_call(ewkView, "load,finished", 0);
2487 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2488 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2490 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
2491 priv->pageClient->page()->setLoadingFinished(true);
2494 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2495 ewk_view_form_password_data_fill(ewkView);
2498 if (!priv->suspendRequested)
2501 priv->suspendRequested = false;
2503 if (!priv->suspendedPainting) {
2504 priv->pageClient->page()->suspendPainting();
2505 priv->suspendedPainting = true;
2507 if (!priv->suspendedResources) {
2508 priv->pageClient->page()->suspendJavaScriptAndResource();
2509 priv->suspendedResources = true;
2515 * Reports view provisional load failed with error information.
2517 * Emits signal: "load,provisional,failed" with pointer to Ewk_Web_Error.
2519 void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Web_Error* error)
2521 evas_object_smart_callback_call(ewkView, "load,provisional,failed", const_cast<Ewk_Web_Error*>(error));
2526 * Reports view received redirect for provisional load.
2528 * Emits signal: "load,provisional,redirect".
2530 void ewk_view_load_provisional_redirect(Evas_Object* ewkView)
2532 ewk_view_uri_update(ewkView);
2533 evas_object_smart_callback_call(ewkView, "load,provisional,redirect", 0);
2538 * Reports view provisional load started.
2540 * Emits signal: "load,provisional,started".
2542 void ewk_view_load_provisional_started(Evas_Object* ewkView)
2545 evas_object_smart_callback_call(ewkView, "load,started", 0);
2548 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2549 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2551 #if ENABLE(TIZEN_DRAG_SUPPORT)
2552 if (priv->pageClient->isDragMode())
2553 priv->pageClient->setDragMode(false);
2556 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
2557 priv->pageClient->page()->setLoadingFinished(false);
2560 // The main frame started provisional load, we should clear
2561 // the loadingResources HashMap to start clean.
2562 _ewk_view_priv_loading_resources_clear(priv->loadingResourcesMap);
2564 ewk_view_uri_update(ewkView);
2565 evas_object_smart_callback_call(ewkView, "load,provisional,started", 0);
2570 * Reports that a navigation policy decision should be taken.
2572 * Emits signal: "policy,decision,navigation".
2574 void ewk_view_navigation_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision)
2576 evas_object_smart_callback_call(ewkView, "policy,decision,navigation", decision);
2581 * Reports that a new window policy decision should be taken.
2583 * Emits signal: "policy,decision,new,window".
2585 void ewk_view_new_window_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision)
2587 evas_object_smart_callback_call(ewkView, "policy,decision,new,window", decision);
2590 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
2592 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2593 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2594 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
2596 if (unreachableUrl && *unreachableUrl)
2597 priv->pageClient->page()->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
2599 priv->pageClient->page()->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
2600 ewk_view_uri_update(ewkView);
2605 #if ENABLE(WEB_INTENTS_TAG)
2608 * The view received a new intent service registration.
2610 * Emits signal: "intent,service,register" with pointer to a Ewk_Intent_Service.
2612 void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Service* ewkIntentService)
2614 evas_object_smart_callback_call(ewkView, "intent,service,register", const_cast<Ewk_Intent_Service*>(ewkIntentService));
2616 #endif // ENABLE(WEB_INTENTS_TAG)
2618 WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView)
2620 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2621 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2623 return priv->pageClient->page();
2626 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
2628 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2629 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2631 String customEncoding = priv->pageClient->page()->customTextEncodingName();
2632 if (customEncoding.isEmpty())
2635 eina_stringshare_replace(&priv->customEncoding, customEncoding.utf8().data());
2637 return priv->customEncoding;
2640 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
2642 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2643 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2645 if (eina_stringshare_replace(&priv->customEncoding, encoding))
2646 priv->pageClient->page()->setCustomTextEncodingName(encoding ? String::fromUTF8(encoding) : String());
2652 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
2654 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2655 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2656 return priv->context;
2659 // FIXME: It should be removed.
2660 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
2662 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2663 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2665 return toAPI(priv->pageClient->page());
2668 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
2670 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2671 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2673 enabled = !!enabled;
2674 if (priv->areMouseEventsEnabled == enabled)
2677 priv->areMouseEventsEnabled = enabled;
2679 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down, smartData);
2680 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up, smartData);
2681 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move, smartData);
2683 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
2684 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
2685 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
2691 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
2693 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2694 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2696 return priv->areMouseEventsEnabled;
2699 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
2701 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2702 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2704 return priv->javascriptPopup->alert(alertText);
2707 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
2709 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2710 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2712 return priv->javascriptPopup->confirm(message);
2715 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
2717 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2718 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2720 return priv->javascriptPopup->prompt(message, defaultValue);
2723 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
2724 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, void* userData)
2726 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2727 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2729 return priv->javascriptPopup->beforeUnloadConfirmPanel(message);
2733 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)
2735 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2736 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2738 return priv->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, priv);
2741 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
2742 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)
2744 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2746 if (priv->popupPicker)
2747 ewk_popup_picker_del(priv->popupPicker);
2749 #if ENABLE(TIZEN_MULTIPLE_SELECT)
2750 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
2752 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
2758 #if ENABLE(TIZEN_MULTIPLE_SELECT)
2759 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)
2761 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2763 if (priv->popupPicker)
2764 ewk_popup_picker_del(priv->popupPicker);
2766 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
2772 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
2774 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2776 if (!priv->popupPicker)
2779 ewk_popup_picker_del(priv->popupPicker);
2780 priv->popupPicker = 0;
2785 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)
2787 // FIXME: The rect should be updated if it was changed
2789 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2791 if (!priv->popupPicker)
2794 ewk_popup_picker_update(smartData->self, priv->popupPicker, items, selectedIndex);
2800 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
2801 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
2803 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2805 priv->inputPicker->show(inputType, inputValue);
2810 #if ENABLE(TIZEN_DATALIST_ELEMENT)
2811 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
2813 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2815 priv->inputPicker->showDataList(inputType, optionList);
2819 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
2821 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2823 priv->inputPicker->hideDataList(inputType);
2828 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
2829 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
2831 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2833 priv->inputPicker->showColorPicker(r, g, b, a);
2837 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
2839 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2841 priv->inputPicker->hideColorPicker();
2846 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
2848 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2849 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2851 return priv->pageClient.get();
2854 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
2856 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
2857 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1);
2859 return WKPageGetTextZoomFactor(toAPI(priv->pageClient->page()));
2862 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
2864 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2865 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2867 WKPageSetTextZoomFactor(toAPI(priv->pageClient->page()), textZoomFactor);
2871 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
2872 FocusRing* ewkViewGetFocusRing(Evas_Object* ewkView)
2874 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2875 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2877 return priv->focusRing.get();
2881 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
2883 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2884 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2886 return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(priv->pageClient->page())));
2889 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
2891 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2892 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2894 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(priv->pageClient->page())));
2897 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
2899 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2900 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2902 if (!priv->javascriptGlobalContext)
2903 priv->javascriptGlobalContext = JSGlobalContextCreate(0);
2904 return priv->javascriptGlobalContext;
2907 void ewkViewLoadCommitted(Evas_Object* ewkView)
2909 #if ENABLE(TIZEN_GESTURE)
2910 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2911 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2912 priv->gestureClient->reset();
2914 #if ENABLE(TIZEN_ISF_PORT)
2915 ewk_view_imf_context_hide(ewkView);
2917 ewk_view_uri_update(ewkView);
2918 evas_object_smart_callback_call(ewkView, "load,committed", 0);
2921 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
2923 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2924 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2926 Ewk_Error* ewkError = ewkErrorCreate(error);
2927 ewkErrorLoadErrorPage(ewkError, toAPI(priv->pageClient->page()));
2928 evas_object_smart_callback_call(ewkView, "load,error", ewkError);
2929 ewkErrorDelete(ewkError);
2932 void ewkViewSetTitleAndURL(Evas_Object* ewkView, const char* title, const char* url)
2934 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2935 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2937 if (title && eina_stringshare_replace(&priv->title, title))
2938 evas_object_smart_callback_call(ewkView, "title,changed", static_cast<void*>(const_cast<char*>(priv->title)));
2939 if (url && eina_stringshare_replace(&priv->uri, url))
2940 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
2943 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
2945 #if ENABLE(TIZEN_GESTURE)
2946 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2947 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2948 priv->gestureClient->reset();
2950 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
2953 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
2955 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2956 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2958 if (priv->authChallenge)
2959 ewkAuthChallengeDelete(priv->authChallenge);
2960 priv->authChallenge = authChallenge;
2962 evas_object_smart_callback_call(ewkView, "authentication,challenge", priv->authChallenge);
2965 void ewk_view_process_crashed(Evas_Object* ewkView)
2967 bool handled = false;
2968 evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
2974 #if ENABLE(TIZEN_SQL_DATABASE)
2975 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)
2977 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, currentQuota);
2978 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, currentQuota);
2980 TIZEN_LOGI("database,quota,exceeded");
2981 uint64_t defaultQuota = ewkContextGetDatabaseQuota(priv->context);
2982 if (defaultQuota >= expectedUsage + currentQuota)
2983 return defaultQuota;
2985 if (priv->exceededDatabaseQuota)
2986 ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
2987 priv->exceededDatabaseQuota = ewkContextCreateExceededQuota(origin, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
2988 evas_object_smart_callback_call(ewkView, "database,quota,exceeded", priv->exceededDatabaseQuota);
2990 return ewkContextGetNewQuotaForExceededQuota(priv->context, priv->exceededDatabaseQuota);
2994 #if ENABLE(TIZEN_NOTIFICATIONS)
2995 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
2997 TIZEN_LOGI("notification,cancel");
2998 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
3001 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
3003 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3004 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3006 TIZEN_LOGI("notification,permission,request");
3007 priv->notificationPermissionRequests = eina_list_append(priv->notificationPermissionRequests, notificationPermissionRequest);
3008 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
3011 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
3013 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3014 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3016 TIZEN_LOGI("notification,show");
3017 Eina_List* listIterator=0;
3019 const char* replaceID = ewkNotificationGetReplaceID(notification);
3020 if(strlen(replaceID)) {
3021 EINA_LIST_FOREACH(priv->notifications, listIterator, data) {
3022 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
3023 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
3024 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
3028 priv->notifications = eina_list_append(priv->notifications, notification);
3029 evas_object_smart_callback_call(ewkView, "notification,show", notification);
3032 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
3034 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3035 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3037 priv->notificationPermissionRequests = eina_list_remove(priv->notificationPermissionRequests, ewkNotificationPermissionRequest);
3041 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
3042 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
3044 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3046 TIZEN_LOGI("protocolhandler,registration,requested");
3047 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
3048 evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
3049 ewkCustomHandlersDeleteData(customHandlersData);
3053 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
3054 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
3056 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
3058 TIZEN_LOGI("protocolhandler,isregistered");
3059 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
3060 evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
3062 Ewk_Custom_Handlers_State result;
3063 result = ewkGetCustomHandlersDataResult(customHandlersData);
3064 ewkCustomHandlersDeleteData(customHandlersData);
3069 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
3071 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3073 TIZEN_LOGI("protocolhandler,unregistration,requested");
3074 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
3075 evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
3076 ewkCustomHandlersDeleteData(customHandlersData);
3080 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
3081 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
3083 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3085 TIZEN_LOGI("contenthandler,registration,requested");
3086 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
3087 evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
3088 ewkCustomHandlersDeleteData(customHandlersData);
3091 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
3093 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
3095 TIZEN_LOGI("contenthandler,isregistered");
3096 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
3097 evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
3099 Ewk_Custom_Handlers_State result;
3100 result = ewkGetCustomHandlersDataResult(customHandlersData);
3101 ewkCustomHandlersDeleteData(customHandlersData);
3106 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
3108 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3110 TIZEN_LOGI("contenthandler,unregistration,requested");
3111 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
3112 evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
3113 ewkCustomHandlersDeleteData(customHandlersData);
3117 #if ENABLE(TIZEN_SEARCH_PROVIDER)
3118 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
3120 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3122 TIZEN_LOGI("searchProvider,add");
3123 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
3124 evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
3125 ewkSearchProviderDeleteData(searchProviderData);
3128 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
3130 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3132 TIZEN_LOGI("searchProvider,installed");
3133 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
3134 evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
3135 unsigned long result;
3136 result = ewkGetSearchProviderResult(searchProviderData);
3137 ewkSearchProviderDeleteData(searchProviderData);
3142 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3143 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
3145 bool standalone = true;
3146 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
3151 #if ENABLE(TIZEN_MEDIA_STREAM)
3152 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
3154 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3155 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3157 priv->userMediaPermissionRequests = eina_list_append(priv->userMediaPermissionRequests, userMediaPermission);
3158 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
3161 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
3163 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3164 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3166 priv->userMediaPermissionRequests = eina_list_remove(priv->userMediaPermissionRequests, permission);
3171 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
3172 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
3174 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
3175 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
3176 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
3177 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
3178 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
3179 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
3181 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
3185 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
3186 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
3188 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3189 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3190 if (priv->certificatePolicyDecision)
3191 ewkCertificatePolicyDecisionDelete(priv->certificatePolicyDecision);
3192 priv->certificatePolicyDecision = certificatePolicyDecision;
3194 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
3198 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
3200 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
3203 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
3205 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
3208 void ewkViewClosePage(Evas_Object* ewkView)
3210 evas_object_smart_callback_call(ewkView, "close,window", 0);
3213 #if ENABLE(TIZEN_GEOLOCATION)
3214 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
3216 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3217 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3219 TIZEN_LOGI("geolocation,permission,request");
3220 priv->geolocationPermissionRequests = eina_list_append(priv->geolocationPermissionRequests, geolocationPermissionRequest);
3221 evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
3224 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
3226 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3227 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3229 priv->geolocationPermissionRequests = eina_list_remove(priv->geolocationPermissionRequests, geolocationPermissionRequest);
3232 void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
3234 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3235 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3237 priv->geolocation = geolocation;
3240 Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
3242 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3243 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3245 return priv->geolocation;
3248 bool ewkViewIsValidLocationService(Evas_Object* ewkView)
3250 TIZEN_LOGI("geolocation,valid");
3253 evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
3258 WKPageRef ewkViewCreateNewPage(Evas_Object* ewkView)
3260 Evas_Object* createdEwkView = 0;
3262 evas_object_smart_callback_call(ewkView, "create,window", &createdEwkView);
3264 if (!createdEwkView)
3267 return static_cast<WKPageRef>(WKRetain(toAPI(ewk_view_page_get(createdEwkView))));
3270 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
3272 evas_object_smart_callback_call(ewkView, "form,submit", formData);
3275 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3277 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3278 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3279 if (priv->policyDecision)
3280 ewkPolicyDecisionDelete(priv->policyDecision);
3281 priv->policyDecision = policyDecision;
3283 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", priv->policyDecision);
3286 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3288 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3289 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3290 if (priv->policyDecision)
3291 ewkPolicyDecisionDelete(priv->policyDecision);
3292 priv->policyDecision = policyDecision;
3294 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", priv->policyDecision);
3297 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3299 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3300 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3301 if (priv->policyDecision)
3302 ewkPolicyDecisionDelete(priv->policyDecision);
3303 priv->policyDecision = policyDecision;
3305 evas_object_smart_callback_call(ewkView, "policy,response,decide", priv->policyDecision);
3308 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
3310 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3311 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3313 IntPoint scrollPosition = priv->pageClient->scrollPosition();
3314 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3315 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3316 contentsSize.scale(priv->pageClient->scaleFactor());
3319 // some website's contents size is smaller than view size,
3320 // so we have to adjust contents size to view size for that case.
3321 if (contentsSize.width() < smartData->view.w)
3322 contentsSize.setWidth(smartData->view.w);
3323 if (contentsSize.height() < smartData->view.h)
3324 contentsSize.setHeight(smartData->view.h);
3326 // Call "scroll,down" if webview can be scrolled down.
3327 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
3328 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
3329 // Call "scroll,up" if webview can be scrolled up.
3330 else if (deltaY < 0 && scrollPosition.y() > 0)
3331 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
3333 // Call "scroll,right" if webview can be scrolled down.
3334 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
3335 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
3336 // Call "scroll,left" if webview can be scrolled up.
3337 else if (deltaX < 0 && scrollPosition.x() > 0)
3338 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
3341 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
3343 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3344 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3346 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3347 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3348 contentsSize.scale(priv->pageClient->scaleFactor());
3351 int maxScrollY = contentsSize.height() - smartData->view.h;
3352 if (!priv->isVerticalEdge) {
3353 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
3354 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
3355 priv->isVerticalEdge = true;
3356 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
3357 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
3358 priv->isVerticalEdge = true;
3361 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
3362 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
3363 priv->isVerticalEdge = false;
3366 int maxScrollX = contentsSize.width() - smartData->view.w;
3367 if (!priv->isHorizontalEdge) {
3368 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
3369 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
3370 priv->isHorizontalEdge = true;
3371 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
3372 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
3373 priv->isHorizontalEdge = true;
3376 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
3377 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
3378 priv->isHorizontalEdge = false;
3382 void ewkViewClearEdges(Evas_Object* ewkView)
3384 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3385 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3387 priv->isVerticalEdge = false;
3388 priv->isHorizontalEdge = false;
3391 void ewk_view_top_of_contents_go(Evas_Object* ewkView)
3393 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3394 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3396 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3397 priv->pageClient->setVisibleContentRect(IntRect(IntPoint(), ewk_view_size_get(ewkView)), priv->pageClient->scaleFactor());
3399 priv->pageClient->page()->scrollMainFrameTo(IntPoint());
3403 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
3405 EWK_VIEW_SD_GET(ewkView, smartData);
3406 if (!smartData || !smartData->priv) {
3414 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
3416 *minimumScale = constraints.minimumScale;
3418 *maximumScale = constraints.maximumScale;
3421 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard)
3423 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3424 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3426 double scaleFactor = priv->pageClient->scaleFactor();
3427 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3429 double newScaleFactor = scaleFactor;
3430 // Readable zoom value is dependent on device DPI
3431 if (scaleFactor < priv->pageClient->page()->deviceScaleFactor()
3432 && priv->pageClient->viewportConstraints().userScalable)
3433 newScaleFactor = priv->pageClient->page()->deviceScaleFactor();
3435 // Readable zoom value should be inside of viewport scale range
3436 newScaleFactor = priv->pageClient->adjustScaleWithViewport(newScaleFactor);
3438 // scale contents' size with new scale factor
3439 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3440 contentsSize.scale(newScaleFactor);
3442 contentsSize.scale(newScaleFactor / scaleFactor);
3445 #if ENABLE(TIZEN_ISF_PORT)
3446 Ecore_X_Window rootWin = ecore_x_window_root_first_get();
3447 ecore_x_event_mask_set(rootWin, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
3448 Ecore_X_Atom xAtom = ecore_x_atom_get("X External Keyboard Exist");
3449 unsigned int connectedKeyboardNum = 0;
3450 bool isExternalKeyboardConnected = false;
3452 // get connected keyboard number
3453 if (ecore_x_window_prop_card32_get(rootWin, xAtom, &connectedKeyboardNum, 1)
3454 && connectedKeyboardNum)
3455 isExternalKeyboardConnected = true;
3457 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
3458 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
3459 // input field zoom should not work with below conditions
3460 // 1. view is not focused
3461 // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
3462 // 3. imfContext is null(if adjustForExternalKeyboard is false)
3463 // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
3464 if ((!(static_cast<PageClient*>(priv->pageClient.get()))->isViewFocused()
3465 || (adjustForExternalKeyboard && !isExternalKeyboardConnected)
3466 || (!adjustForExternalKeyboard && !priv->imfContext)
3467 || (!adjustForExternalKeyboard && ecore_imf_context_input_panel_state_get(priv->imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE))
3468 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
3469 && !(priv->pageClient->isClipboardWindowOpened())
3475 IntSize visibleSize(smartData->view.w, smartData->view.h);
3476 // caret position can be outside of visible rect.
3477 // we need to consider it.
3478 IntRect selectionRect = priv->pageClient->page()->getSelectionRect(true);
3479 IntRect focusedNodeRect = priv->pageClient->focusedNodeRect();
3480 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3481 selectionRect.scale(newScaleFactor);
3482 focusedNodeRect.scale(newScaleFactor);
3484 selectionRect.scale(newScaleFactor / scaleFactor);
3485 focusedNodeRect.scale(newScaleFactor / scaleFactor);
3487 if (selectionRect.isEmpty())
3491 IntPoint scrollPosition(selectionRect.x() - visibleSize.width() / 3, selectionRect.y() - visibleSize.height() / 3);
3492 // If both input field's position x and selection rect can be displayed together,
3493 // adjust scroll position to input field's position x.
3494 if (!focusedNodeRect.isEmpty()
3495 && selectionRect.x() - focusedNodeRect.x() < visibleSize.width() * 4 / 5)
3496 scrollPosition.setX(focusedNodeRect.x());
3498 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3499 priv->pageClient->setVisibleContentRect(IntRect(scrollPosition, ewk_view_size_get(ewkView)), newScaleFactor);
3501 if (newScaleFactor != scaleFactor)
3502 priv->pageClient->page()->scalePage(newScaleFactor, scrollPosition);
3504 priv->pageClient->page()->scrollMainFrameTo(scrollPosition);
3506 evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
3510 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
3511 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
3512 static Eina_Bool _ewk_view_composite(void* data)
3514 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
3515 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
3517 if (!evas_object_visible_get(smartData->image))
3518 return ECORE_CALLBACK_CANCEL;
3521 evas_object_image_size_get(smartData->image, &ow, &oh);
3522 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
3524 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)));
3525 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
3527 cairo_save(context.get());
3528 cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
3529 cairo_rectangle(context.get(), 0, 0, ow, oh);
3530 cairo_fill(context.get());
3531 cairo_restore(context.get());
3533 priv->pageClient->drawContents(context.get());
3535 evas_object_image_data_set(smartData->image, pixels);
3536 evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
3538 ewkViewFrameRendered(smartData->self);
3540 priv->compositionAnimator = 0;
3542 return ECORE_CALLBACK_CANCEL;
3546 void ewk_view_mark_for_sync(Evas_Object* ewkView)
3548 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3549 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
3551 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
3552 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3554 if (!ewk_view_is_opengl_backend(ewkView)) {
3555 if (!priv->compositionAnimator)
3556 priv->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
3561 evas_object_image_pixels_dirty_set(smartData->image, true);
3564 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
3566 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
3567 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3568 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3569 priv->pageClient->drawContents();
3572 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
3574 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3575 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3577 if (!smartData->image)
3580 evas_object_image_native_surface_set(smartData->image, nativeSurface);
3581 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
3587 void _ewk_view_suspend_painting(Evas_Object* ewkView)
3589 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3590 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3592 if (!priv->suspendedPainting) {
3593 priv->pageClient->page()->suspendPainting();
3594 priv->suspendedPainting = true;
3598 void _ewk_view_resume_painting(Evas_Object* ewkView)
3600 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3601 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3603 if (priv->suspendedPainting) {
3604 priv->pageClient->page()->resumePainting();
3605 priv->suspendedPainting = false;
3609 void ewk_view_suspend(Evas_Object* ewkView)
3611 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3612 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3614 if (priv->pageClient->page()->estimatedProgress() < 1.0) {
3615 priv->suspendRequested = true;
3618 priv->suspendRequested = false;
3620 _ewk_view_suspend_painting(ewkView);
3622 // FIXME Workaround for suspend/resume while javascript popup is displayed.
3623 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
3624 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
3626 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
3627 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
3628 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
3629 // will be suspended again.
3630 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
3631 // the ActiveDOMObject.
3632 if (!priv->suspendedResources && !priv->isWaitingForJavaScriptPopupReply) {
3633 priv->pageClient->page()->suspendJavaScriptAndResource();
3634 priv->suspendedResources = true;
3637 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
3638 priv->pageClient->page()->suspendPlugin();
3642 void ewk_view_resume(Evas_Object* ewkView)
3644 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3645 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3647 if (priv->suspendRequested) {
3648 priv->suspendRequested = false;
3652 _ewk_view_resume_painting(ewkView);
3654 // FIXME Workaround for suspend/resume while javascript popup is displayed.
3655 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
3656 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
3658 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
3659 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
3660 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
3661 // will be suspended again.
3662 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
3663 // the ActiveDOMObject.
3664 if (priv->suspendedResources && !priv->isWaitingForJavaScriptPopupReply) {
3665 priv->pageClient->page()->resumeJavaScriptAndResource();
3666 priv->suspendedResources = false;
3669 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
3670 priv->pageClient->page()->resumePlugin();
3674 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
3676 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3677 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3678 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
3680 ResourceRequest request(String::fromUTF8(url));
3683 case EWK_HTTP_METHOD_GET:
3684 request.setHTTPMethod("GET");
3686 case EWK_HTTP_METHOD_HEAD:
3687 request.setHTTPMethod("HEAD");
3689 case EWK_HTTP_METHOD_POST:
3690 request.setHTTPMethod("POST");
3692 case EWK_HTTP_METHOD_PUT:
3693 request.setHTTPMethod("PUT");
3695 case EWK_HTTP_METHOD_DELETE:
3696 request.setHTTPMethod("DELETE");
3703 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
3705 while (eina_iterator_next(it, &data)) {
3706 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
3707 const char* name = static_cast<const char*>(t->key);
3708 const char* value = static_cast<const char*>(t->data);
3709 request.addHTTPHeaderField(name, value);
3711 eina_iterator_free(it);
3715 request.setHTTPBody(FormData::create(body));
3717 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
3718 WKPageLoadURLRequest(toAPI(priv->pageClient->page()), urlRequest.get());
3723 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
3725 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3726 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3728 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
3729 WKPageLoadPlainTextString(toAPI(priv->pageClient->page()), plainTextRef.get());
3734 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
3736 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3737 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3738 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
3740 if (contentsSize == 0)
3743 String mimeTypeString;
3745 mimeTypeString = String::fromUTF8(mimeType);
3747 mimeTypeString = String::fromUTF8("text/html");
3749 String encodingString;
3751 encodingString = String::fromUTF8(encoding);
3753 encodingString = String::fromUTF8("UTF-8");
3755 String baseUriString;
3757 baseUriString = String::fromUTF8(baseUri);
3759 baseUriString = String::fromUTF8("about:blank");
3761 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
3762 priv->pageClient->page()->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
3767 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
3769 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3770 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3772 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
3773 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
3775 WKPageLoadHTMLString(toAPI(priv->pageClient->page()), htmlString.get(), baseURL.get());
3780 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
3782 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3783 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3785 TIZEN_LOGI("initialState (%d)", initialState);
3786 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
3787 WKPageSetPageVisibility(toAPI(priv->pageClient->page()), static_cast<WKPageVisibilityState
3788 >(pageVisibilityState), initialState);
3796 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
3798 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
3800 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3801 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3803 eina_stringshare_replace(&priv->userAgent, userAgent);
3805 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
3806 WKPageSetCustomUserAgent(toAPI(priv->pageClient->page()), userAgentString.get());
3811 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
3813 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3814 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3816 if (!priv->userAgent) {
3817 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(priv->pageClient->page())));
3819 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
3820 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3821 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
3822 eina_stringshare_replace(&priv->userAgent, buffer.get());
3825 return priv->userAgent;
3827 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
3829 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3830 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3831 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3833 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
3834 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
3836 WKPageAddCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get(), customHeaderValue.get());
3839 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3844 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
3846 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3847 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3848 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3850 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
3852 WKPageRemoveCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get());
3855 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3860 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
3862 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3863 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3864 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3866 WKPageClearCustomHeaders(toAPI(priv->pageClient->page()));
3869 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3874 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
3875 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
3877 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3878 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3880 priv->pageClient->setIsVisible(enable);
3885 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
3887 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
3889 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3890 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3893 rect.origin.x = viewArea.x;
3894 rect.origin.y = viewArea.y;
3895 rect.size.width = viewArea.w;
3896 rect.size.height = viewArea.h;
3898 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(priv->pageClient->page()), rect, scaleFactor));
3899 if (!snapshot.get())
3902 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
3904 Evas_Object* screenshotImage = evas_object_image_add(canvas);
3905 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
3906 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
3907 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
3908 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
3910 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
3912 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)));
3913 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
3915 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
3916 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
3917 cairo_fill(cairo.get());
3919 evas_object_image_smooth_scale_set(screenshotImage, true);
3920 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
3921 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
3922 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
3923 evas_object_image_data_set(screenshotImage, pixels);
3925 return screenshotImage;
3928 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
3930 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
3931 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
3932 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, 0);
3934 return priv->pageClient->page()->startInspectorServer(port);
3936 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
3941 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
3943 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
3944 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
3945 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
3947 return priv->pageClient->page()->stopInspectorServer();
3949 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
3954 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
3956 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3957 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3959 WKPageScrollBy(toAPI(priv->pageClient->page()), toAPI(IntSize(deltaX, deltaY)));
3962 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
3968 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3969 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3971 IntPoint scrollPosition = priv->pageClient->scrollPosition();
3973 *x = scrollPosition.x();
3975 *y = scrollPosition.y();
3980 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
3982 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3983 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3985 priv->pageClient->page()->scrollMainFrameTo(IntPoint(x, y));
3989 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
3995 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3996 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3998 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3999 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
4000 contentsSize.scale(priv->pageClient->scaleFactor());
4003 if (width && contentsSize.width() > smartData->view.w)
4004 *width = contentsSize.width() - smartData->view.w;
4005 if (height && contentsSize.height() > smartData->view.h)
4006 *height = contentsSize.height() - smartData->view.h;
4010 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
4012 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4013 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4014 if (!priv->alertContext || !priv->alertContext->javascriptAlertCallback)
4016 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->alertContext->ewkView == ewkView, false);
4018 priv->isWaitingForJavaScriptPopupReply = true;
4019 int length = WKStringGetMaximumUTF8CStringSize(alertText);
4020 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
4021 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
4022 return priv->alertContext->javascriptAlertCallback(priv->alertContext->ewkView, alertTextBuffer.get(), priv->alertContext->userData) == EINA_TRUE;
4025 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
4027 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4028 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4029 if (!priv->confirmContext || !priv->confirmContext->javascriptConfirmCallback)
4031 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->confirmContext->ewkView == ewkView, false);
4033 priv->isWaitingForJavaScriptPopupReply = true;
4034 int length = WKStringGetMaximumUTF8CStringSize(message);
4035 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4036 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4037 return priv->confirmContext->javascriptConfirmCallback(priv->confirmContext->ewkView, messageBuffer.get(), priv->confirmContext->userData) == EINA_TRUE;
4040 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
4042 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4043 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4044 if (!priv->promptContext || !priv->promptContext->javascriptPromptCallback)
4046 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->promptContext->ewkView == ewkView, false);
4048 priv->isWaitingForJavaScriptPopupReply = true;
4049 int length = WKStringGetMaximumUTF8CStringSize(message);
4050 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4051 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4052 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
4053 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
4054 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
4055 return priv->promptContext->javascriptPromptCallback(priv->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), priv->promptContext->userData) == EINA_TRUE;
4058 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
4059 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
4061 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4062 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4063 if (!priv->beforeUnloadConfirmPanelContext || !priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
4065 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
4067 priv->isWaitingForJavaScriptPopupReply = true;
4068 int length = WKStringGetMaximumUTF8CStringSize(message);
4069 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4070 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4071 bool result = priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(priv->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), priv->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
4076 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
4078 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4079 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4080 if (!priv->openpanelContext || !priv->openpanelContext->openPanelCallback)
4083 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->openpanelContext->ewkView == ewkView, false);
4085 priv->openPanelListener = listener;
4087 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
4088 Eina_List* acceptedMimeTypes = 0;
4089 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
4090 size_t len = WKArrayGetSize(array.get());
4091 for (size_t i = 0; i < len; i++) {
4092 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
4093 if (WKGetTypeID(item) != WKStringGetTypeID())
4095 WKStringRef mime = static_cast<WKStringRef>(item);
4096 int length = WKStringGetMaximumUTF8CStringSize(mime);
4097 char* buffer = new char[length];
4098 WKStringGetUTF8CString(mime, buffer, length);
4099 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
4101 const char* capture = 0;
4102 #if ENABLE(MEDIA_CAPTURE)
4103 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
4104 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
4106 bool result = priv->openpanelContext->openPanelCallback(priv->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
4107 if (!acceptedMimeTypes)
4112 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
4113 delete[] (char*)data;
4114 eina_list_free(acceptedMimeTypes);
4118 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
4120 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4121 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4123 if (!priv->alertContext)
4124 priv->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4125 priv->alertContext->javascriptAlertCallback = callback;
4126 priv->alertContext->ewkView = ewkView;
4127 priv->alertContext->userData = userData;
4130 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
4132 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4133 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4135 WKPageReplyJavaScriptAlert(toAPI(ewk_view_page_get(ewkView)));
4136 priv->isWaitingForJavaScriptPopupReply = false;
4139 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
4141 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4142 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4144 if (!priv->confirmContext)
4145 priv->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4146 priv->confirmContext->javascriptConfirmCallback = callback;
4147 priv->confirmContext->ewkView = ewkView;
4148 priv->confirmContext->userData = userData;
4151 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
4153 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4154 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4156 WKPageReplyJavaScriptConfirm(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
4157 priv->isWaitingForJavaScriptPopupReply = false;
4160 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
4162 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4163 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4165 if (!priv->promptContext)
4166 priv->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4167 priv->promptContext->javascriptPromptCallback = callback;
4168 priv->promptContext->ewkView = ewkView;
4169 priv->promptContext->userData = userData;
4172 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
4174 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4175 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4177 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
4178 WKPageReplyJavaScriptPrompt(toAPI(ewk_view_page_get(ewkView)), result ? resultString.get() : 0);
4179 priv->isWaitingForJavaScriptPopupReply = false;
4182 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
4183 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
4185 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4186 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4188 if (!priv->beforeUnloadConfirmPanelContext)
4189 priv->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4190 priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
4191 priv->beforeUnloadConfirmPanelContext->ewkView = ewkView;
4192 priv->beforeUnloadConfirmPanelContext->userData = userData;
4195 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
4197 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4198 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4200 WKPageReplyBeforeUnloadConfirmPanel(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
4201 priv->isWaitingForJavaScriptPopupReply = false;
4205 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
4207 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4208 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4210 if (!priv->openpanelContext)
4211 priv->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4213 priv->openpanelContext->openPanelCallback = callback;
4214 priv->openpanelContext->ewkView = ewkView;
4215 priv->openpanelContext->userData = userData;
4218 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
4220 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4221 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4223 if (!priv->openPanelListener)
4226 unsigned int size = eina_list_count(fileUrls);
4227 if ((result == EINA_FALSE) || (size == 0)) {
4228 WKOpenPanelResultListenerCancel(priv->openPanelListener);
4229 priv->openPanelListener = 0;
4233 WKTypeRef* items = new WKTypeRef[size];
4237 KURL base(KURL(), "file://");
4238 EINA_LIST_FOREACH(fileUrls, list, data) {
4239 KURL url(base, static_cast<char*>(data));
4240 items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
4242 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
4243 WKOpenPanelResultListenerChooseFiles(priv->openPanelListener, filesArray.get());
4244 priv->openPanelListener = 0;
4246 eina_list_free(fileUrls);
4249 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4250 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
4252 EINA_SAFETY_ON_NULL_RETURN(capable);
4253 EINA_SAFETY_ON_NULL_RETURN(context);
4255 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4257 ASSERT(webAppContext->webAppCapableCallback);
4260 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
4262 webAppContext->webAppCapableCallback(0, webAppContext->userData);
4264 delete webAppContext;
4267 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
4269 EINA_SAFETY_ON_NULL_RETURN(iconURL);
4270 EINA_SAFETY_ON_NULL_RETURN(context);
4272 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4274 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
4275 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4277 ASSERT(webAppContext->webAppIconURLCallback);
4280 eina_stringshare_replace(&priv->webAppIconURL, toImpl(iconURL)->string().utf8().data());
4281 webAppContext->webAppIconURLCallback(priv->webAppIconURL, webAppContext->userData);
4283 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
4285 delete webAppContext;
4289 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
4291 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4292 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4293 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4294 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4296 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4297 context->webAppCapableCallback = callback;
4298 context->ewkView = ewkView;
4299 context->userData = userData;
4301 WKPageGetWebAppCapable(toAPI(priv->pageClient->page()), context, didGetWebAppCapable);
4309 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
4311 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4312 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4313 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4314 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4316 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4317 context->webAppIconURLCallback = callback;
4318 context->ewkView = ewkView;
4319 context->userData = userData;
4321 WKPageGetWebAppIconURL(toAPI(priv->pageClient->page()), context, didGetWebAppIconURL);
4329 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
4331 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4332 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4333 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
4335 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
4336 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
4337 WKPageExecuteCommandWithArgument(toAPI(priv->pageClient->page()), commandString.get(), valueString.get());
4342 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4344 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4345 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4346 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4348 // FixMe: Comment should be removed when pageClient is removed.
4349 //priv->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4350 priv->pageClient->page()->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4355 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4357 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4358 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4360 // FixMe: Comment should be removed when pageClient is removed.
4361 //priv->pageProxy->hideFindUI();
4362 priv->pageClient->page()->hideFindUI();
4367 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
4374 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4375 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4377 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4380 *width = contentsSize.width();
4382 *height = contentsSize.height();
4387 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
4389 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
4390 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4391 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4392 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
4394 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4395 WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
4403 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, int width, int height, const char* fileName)
4405 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
4406 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4407 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4408 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
4410 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4411 WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
4419 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
4421 EINA_SAFETY_ON_NULL_RETURN(context);
4422 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4424 if (!callbackContext->scriptExecuteCallback) {
4425 delete callbackContext;
4429 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
4432 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
4433 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
4434 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
4435 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
4436 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
4437 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
4439 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
4441 delete callbackContext;
4444 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
4446 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4447 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4448 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
4449 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient, false);
4451 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4452 context->scriptExecuteCallback = callback;
4453 context->ewkView = ewkView;
4454 context->userData = user_data;
4455 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
4456 WKPageRunJavaScriptInMainFrame(toAPI(priv->pageClient->page()), scriptString.get(), context, runJavaScriptCallback);
4461 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
4462 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
4464 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
4467 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
4469 storageContext->webStorageQuotaCallback(0, storageContext->userData);
4471 delete storageContext;
4475 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
4477 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
4478 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
4479 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
4480 TIZEN_LOGI("resultCallback (%p)", resultCallback);
4482 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4483 context->webStorageQuotaCallback = resultCallback;
4484 context->userData = userData;
4486 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
4487 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
4495 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
4497 #if ENABLE(TIZEN_WEB_STORAGE)
4498 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
4500 TIZEN_LOGI("quota (%d)", quota);
4501 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
4502 WKPageSetWebStorageQuota(pageRef, quota);
4510 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
4512 EINA_SAFETY_ON_NULL_RETURN(context);
4513 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4515 ASSERT(callbackContext->plainTextGetCallback);
4518 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
4519 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
4520 WKStringGetUTF8CString(plain_text, buffer.get(), length);
4522 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
4524 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
4526 delete callbackContext;
4529 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
4531 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4532 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4533 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4534 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient, false);
4536 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4537 context->plainTextGetCallback = callback;
4538 context->ewkView = ewkView;
4539 context->userData = user_data;
4540 WKPageGetContentsAsString(toAPI(priv->pageClient->page()), context, getContentsAsStringCallback);
4545 #if ENABLE(TIZEN_SUPPORT_MHTML)
4548 * Callback function used for ewk_view_mhtml_data_get().
4550 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4552 EINA_SAFETY_ON_NULL_RETURN(context);
4553 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4555 ASSERT(callbackContext->mhtmlDataGetCallback);
4557 callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
4559 delete callbackContext;
4562 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
4564 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4565 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4566 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4568 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4569 context->mhtmlDataGetCallback = callback;
4570 context->ewkView = ewkView;
4571 context->userData = user_data;
4573 WKPageGetContentsAsMHTMLData(toAPI(priv->pageClient->page()), false, context, getContentsAsMHTMLCallback);
4577 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
4579 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
4581 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
4582 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4583 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4584 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, 0);
4586 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
4587 WebHitTestResult::Data hitTestResultData = priv->pageClient->page()->hitTestResultAtPoint(pointForHitTest, hitTestMode);
4588 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
4596 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
4598 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
4599 WebPageProxy* page = ewk_view_page_get(ewkView);
4600 EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
4602 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
4605 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
4607 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4608 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4610 WKPageRecordingSurfaceSetEnable(toAPI(priv->pageClient->page()), enable);
4615 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
4617 #if ENABLE(TIZEN_NOTIFICATIONS)
4618 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4619 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4620 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->context, false);
4622 TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
4623 if (!eina_list_count(ewkNotifications))
4626 Eina_List* listIterator = 0;
4628 Vector<WKTypeRef> ids;
4629 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
4630 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
4631 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
4633 priv->notifications = eina_list_remove(priv->notifications, notification);
4636 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
4637 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(ewk_context_WKContext_get(priv->context));
4638 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
4639 ewkNotificationDeleteNotificationList(ewkNotifications);
4647 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
4649 Eina_List* popupItems = 0;
4650 size_t size = items.size();
4651 for (size_t i = 0; i < size; ++i) {
4652 Ewk_Popup_Menu_Item* item = ewk_popup_menu_item_new(items[i].m_type,
4653 items[i].m_text.utf8().data(),
4654 items[i].m_textDirection,
4655 items[i].m_hasTextDirectionOverride,
4656 items[i].m_toolTip.utf8().data(),
4657 items[i].m_accessibilityText.utf8().data(),
4658 items[i].m_isEnabled,
4659 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4660 items[i].m_isSelected,
4662 items[i].m_isLabel);
4663 popupItems = eina_list_append(popupItems, item);
4665 TIZEN_LOGI("size : %d", size);
4669 static void releasePopupMenuList(Eina_List* popupMenuItems)
4671 if (!popupMenuItems)
4675 EINA_LIST_FREE(popupMenuItems, item)
4676 ewk_popup_menu_item_free(static_cast<Ewk_Popup_Menu_Item*>(item));
4679 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4680 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)
4682 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)
4685 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4686 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4687 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4688 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4692 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4693 if (!smartData->api->popup_menu_show && !smartData->api->multiple_popup_menu_show)
4695 if (!smartData->api->popup_menu_show)
4699 if (priv->popupMenuProxy)
4700 ewk_view_popup_menu_close(ewkView);
4701 priv->popupMenuProxy = popupMenu;
4703 priv->popupMenuItems = createPopupMenuList(items);
4705 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4706 if ((!multiple && smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems, selectedIndex)) ||
4707 (multiple && smartData->api->multiple_popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems))) {
4709 if (smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems, selectedIndex)) {
4711 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
4712 /* maps.google.com generate mouse event in touch down without preventDefault.
4713 * So, popup menu is opend in touch down event and closed via fake mouse down
4714 * which generated by endTap.
4715 * In order to fix select of maps.google.com (based on touch behavior),
4716 * We should disable touch events when select popup is open.
4719 #if ENABLE(TIZEN_GESTURE)
4720 priv->gestureClient->reset();
4722 ewk_view_touch_events_enabled_set(ewkView, false);
4727 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
4729 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4730 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4731 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4732 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4734 if (!priv->popupMenuProxy)
4737 priv->popupMenuProxy = 0;
4739 if (smartData->api->popup_menu_hide)
4740 smartData->api->popup_menu_hide(smartData);
4741 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
4742 ewk_view_touch_events_enabled_set(ewkView, true);
4745 releasePopupMenuList(priv->popupMenuItems);
4746 priv->popupMenuItems = 0;
4751 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
4753 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4754 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4755 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4756 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4758 if (!priv->popupMenuProxy)
4761 if (!smartData->api->popup_menu_update)
4764 releasePopupMenuList(priv->popupMenuItems);
4765 priv->popupMenuItems = createPopupMenuList(items);
4767 // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
4768 smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), priv->popupMenuItems, selectedIndex);
4771 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
4773 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4774 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4775 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
4776 TIZEN_LOGI("proxy : %p / index : %d", priv->popupMenuProxy, selectedIndex);
4778 if (!priv->popupMenuItems)
4781 if (selectedIndex >= eina_list_count(priv->popupMenuItems))
4784 priv->popupMenuProxy->valueChanged(selectedIndex);
4789 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4790 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
4792 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4793 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4794 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
4796 Vector<int> selectedIndex;
4798 if (!priv->popupMenuItems)
4803 itr = eina_inarray_iterator_new(changeList);
4804 EINA_ITERATOR_FOREACH(itr, data)
4806 int* pData = static_cast<int*>(data);
4807 selectedIndex.append(*pData);
4809 eina_iterator_free(itr);
4811 priv->popupMenuProxy->multipleValueChanged(selectedIndex);
4816 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
4818 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
4819 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4820 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4821 TIZEN_LOGI("orientation : %d", orientation);
4823 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
4826 if (priv->orientation == orientation)
4829 priv->orientation = orientation;
4831 priv->pageClient->page()->sendOrientationChangeEvent(orientation);
4835 void ewkViewFrameRendered(Evas_Object* ewkView)
4837 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
4840 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4841 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
4843 return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
4846 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
4848 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4849 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4850 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
4852 IntRect leftSelectionRect;
4853 IntRect rightSelectionRect;
4854 if (!priv->pageClient->page()->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
4867 AffineTransform contentToScreen = impl->transformToScene();
4868 leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
4869 rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
4871 leftRect->x = leftSelectionRect.x();
4872 leftRect->y = leftSelectionRect.y();
4873 leftRect->w = leftSelectionRect.width();
4874 leftRect->h = leftSelectionRect.height();
4876 rightRect->x = rightSelectionRect.x();
4877 rightRect->y = rightSelectionRect.y();
4878 rightRect->w = rightSelectionRect.width();
4879 rightRect->h = rightSelectionRect.height();
4884 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
4886 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4887 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4889 const CString selectedString = priv->pageClient->page()->getSelectionText().utf8();
4890 eina_stringshare_replace(&priv->selectedText, selectedString.data());
4892 return priv->selectedText;
4895 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
4897 return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
4900 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
4902 return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
4904 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4906 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4907 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
4909 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4910 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4911 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
4913 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
4917 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
4918 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
4920 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4921 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4922 IntPoint drawingPosition = (IntPoint)(priv->pageClient->visibleContentRect().location() - priv->pageClient->scrollPosition());
4924 *x = drawingPosition.x();
4926 *y = drawingPosition.y();
4928 *w = priv->pageClient->visibleContentRect().width();
4930 *h = priv->pageClient->visibleContentRect().height();
4934 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
4936 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4937 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4938 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4940 priv->pageClient->page()->setFocusedInputElementValue(String::fromUTF8(value));
4941 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4944 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
4946 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4947 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4948 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4950 eina_stringshare_replace(&priv->inputValue, priv->pageClient->page()->getFocusedInputElementValue().utf8().data());
4951 return priv->inputValue;
4954 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4957 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4958 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
4960 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4961 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4962 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4963 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
4966 ewkViewDataListHideRequest(ewkView, inputType);
4968 for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
4970 priv->dataList = eina_list_append(priv->dataList, eina_stringshare_add(value.utf8().data()));
4973 smartData->api->data_list_show(smartData, inputType, priv->dataList);
4976 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
4978 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4979 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4980 EINA_SAFETY_ON_NULL_RETURN(priv->dataList);
4981 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4982 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
4984 if (priv->dataList) {
4985 _ewk_view_data_list_del(priv->dataList);
4989 smartData->api->data_list_hide(smartData, inputType);
4993 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
4995 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4996 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4997 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4999 if (priv->dataList) {
5000 _ewk_view_data_list_del(priv->dataList);
5004 ewk_view_focused_input_element_value_set(ewkView, value);
5008 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
5010 #if ENABLE(TIZEN_GESTURE)
5011 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
5012 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
5013 return priv->holdHorizontalPanning;
5019 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
5021 #if ENABLE(TIZEN_GESTURE)
5022 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5023 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5024 priv->holdHorizontalPanning = hold;
5028 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
5030 #if ENABLE(TIZEN_GESTURE)
5031 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
5032 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
5033 return priv->holdVerticalPanning;
5039 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
5041 #if ENABLE(TIZEN_GESTURE)
5042 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5043 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5044 priv->holdVerticalPanning = hold;
5048 void ewk_view_use_smart_selection_set(Evas_Object* ewkView, Eina_Bool use)
5050 #if ENABLE(TIZEN_GESTURE)
5051 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5052 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5053 priv->useSmartSelection = use;
5057 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
5059 #if ENABLE(TIZEN_GESTURE)
5060 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5061 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5063 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5064 if (priv->focusRing && wasHandled)
5065 priv->focusRing->hide();
5066 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5068 if (priv->areMouseEventsEnabled)
5071 // We have to check TouchStart, TouchMove and TouchEnd with handled.
5072 // The Pan and Flick will be enabled if Touch Start was not handled,
5073 // and Touch Move was not handled or did not occur.
5074 // Tap will be enabled if Touch Start and End was not handled
5075 // and Touch Move did not occur.
5076 // The gestures are disabled as a default.
5077 // o: handled, x: not handled
5078 // ------------------------------------------------------------
5079 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
5080 // ------------------------------------------------------------
5081 // o | o or x | o or x || disable | disable
5082 // x | o | o or x || disable | disable
5083 // x | x | o or x || disable | enable
5084 // x |not occured | x || enable | enable
5085 // ------------------------------------------------------------
5086 if (type == WebEvent::TouchStart) {
5087 priv->gestureClient->setGestureEnabled(!wasHandled);
5088 priv->wasHandledTouchStart = wasHandled;
5090 // Initialize wasHandledTouchMove to true and notify that to the application
5091 // to prevent applications scrolling at the beginning of touch.
5092 priv->wasHandledTouchMove = true;
5093 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&priv->wasHandledTouchMove));
5094 } else if (type == WebEvent::TouchMove) {
5095 priv->gestureClient->setMovingEnabled(!wasHandled);
5097 // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
5098 if (priv->wasHandledTouchStart)
5101 // Notify the result of touchmove to applications when handled value is changed
5102 // in order to make applications to choose whether scrolling its scrollable objects or not.
5103 if (priv->wasHandledTouchMove != wasHandled)
5104 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
5105 priv->wasHandledTouchMove = wasHandled;
5106 } else if (type == WebEvent::TouchEnd && !priv->exceedTouchMoveThreshold && !wasHandled) {
5107 priv->gestureClient->setMovingEnabled(!wasHandled);
5108 priv->gestureClient->setTapEnabled(!wasHandled);
5113 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
5114 void ewkViewDidGetTextStyleStateForSelection(Evas_Object* ewkView, int underlineState, int italicState, int boldState, const IntPoint& startPoint, const IntPoint& endPoint)
5116 Ewk_Text_Style* textStyle = ewkTextStyleCreate(underlineState, italicState, boldState, startPoint, endPoint);
5117 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
5118 ewkTextStyleDelete(textStyle);
5122 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
5123 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
5125 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5126 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
5128 TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
5129 if (!smartData->api->orientation_lock) {
5134 return smartData->api->orientation_lock(smartData, willLockOrientation);
5137 void ewk_view_orientation_unlock(Evas_Object* ewkView)
5139 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5140 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
5142 TIZEN_LOGI("ewkView (%p)", ewkView);
5143 if (!smartData->api->orientation_unlock) {
5148 smartData->api->orientation_unlock(smartData);
5152 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
5154 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
5155 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5156 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5157 TIZEN_LOGI("callbacks: %p / data: %p", func, data);
5159 priv->orientationLock.callback = func;
5160 priv->orientationLock.data = data;
5164 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
5165 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
5167 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
5168 TIZEN_LOGI("locked orientations : %d", orientations);
5170 if (priv->orientationLock.callback)
5171 return priv->orientationLock.callback(sd->self, true, orientations, priv->orientationLock.data);
5176 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
5178 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
5179 TIZEN_LOGI("unlock is requested");
5181 if (priv->orientationLock.callback)
5182 priv->orientationLock.callback(sd->self, false, 0, priv->orientationLock.data);
5186 void ewk_view_fullscreen_enter(Evas_Object* ewkView)
5188 TIZEN_LOGI("fullscreen,enterfullscreen");
5189 ewk_view_main_frame_scrollbar_visible_set(ewkView, false);
5190 evas_object_smart_callback_call(ewkView, "fullscreen,enterfullscreen", 0);
5193 void ewk_view_fullscreen_exit(Evas_Object* ewkView)
5195 TIZEN_LOGI("fullscreen,exitfullscreen");
5196 ewk_view_main_frame_scrollbar_visible_set(ewkView, true);
5197 evas_object_smart_callback_call(ewkView, "fullscreen,exitfullscreen", 0);
5200 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
5201 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
5203 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5205 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
5206 const char *engine = ecore_evas_engine_name_get(ee);
5207 if (engine && !strcmp(engine, "opengl_x11"))
5213 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
5215 #if ENABLE(TIZEN_GESTURE)
5216 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5217 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5219 priv->gestureClient->setZoomableArea(target, area);
5223 #if ENABLE(TIZEN_ISF_PORT)
5224 static void imfInputPanelStateEventCb(void* data, Ecore_IMF_Context* ctx, int state)
5226 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5227 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5229 if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
5230 evas_object_smart_callback_call(smartData->self, "editorclient,ime,closed", 0);
5231 LOG(ISF, "[SIGNAL] editorclient,ime,closed\n");
5232 } else if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
5233 evas_object_smart_callback_call(smartData->self, "editorclient,ime,opened", 0);
5234 LOG(ISF, "[SIGNAL] editorclient,ime,opened\n");
5238 static void imfInputPanelGeometryEventCb(void* data, Ecore_IMF_Context* ctx, int value)
5240 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5241 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5243 Eina_Rectangle rect;
5244 ecore_imf_context_input_panel_geometry_get(priv->imfContext, &rect.x, &rect.y, &rect.w, &rect.h);
5245 evas_object_smart_callback_call(smartData->self, "inputmethod,changed", &rect);
5246 LOG(ISF, "%s : [SIGNAL] inputmethod,changed (%d,%d,%d,%d)\n", __func__, rect.x, rect.y, rect.w, rect.h);
5249 static void imfCandidatePanelStateEventCb(void* data, Ecore_IMF_Context* ctx, int state)
5251 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5252 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5254 if (state == ECORE_IMF_CANDIDATE_PANEL_SHOW)
5255 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,opened", 0);
5257 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,closed", 0);
5260 static void imfCandidatePanelGeometryEventCb(void* data, Ecore_IMF_Context* ctx, int value)
5262 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5263 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5265 Eina_Rectangle rect;
5266 ecore_imf_context_candidate_panel_geometry_get(priv->imfContext, &rect.x, &rect.y, &rect.w, &rect.h);
5267 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,changed", &rect);
5270 static Eina_Bool imfRetrieveSurroundingCb(void* data, Ecore_IMF_Context* context, char** text, int* offset)
5272 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5273 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5275 if (!priv->pageClient->page()->focusedFrame() || (!text && !offset))
5278 String surroundingText;
5280 priv->pageClient->page()->getSurroundingTextAndCursorOffset(surroundingText, cursorOffset);
5283 CString utf8Text(surroundingText.utf8());
5284 size_t length = utf8Text.length();
5286 *text = static_cast<char*>(malloc((length + 1) * sizeof(char)));
5291 strncpy(*text, utf8Text.data(), length);
5292 (*text)[length] = 0;
5296 *offset = cursorOffset;
5301 static void imfPreeditChangedCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5303 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5304 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5306 priv->pageClient->imContextPreeditChanged(context);
5309 static void imfEventCommittedCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5311 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5312 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5314 priv->pageClient->imContextCommitted(context, static_cast<char*>(eventInfo));
5317 static void imfContextDeleteSurroundingCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5319 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5320 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5322 Ecore_IMF_Event_Delete_Surrounding* event = static_cast<Ecore_IMF_Event_Delete_Surrounding*>(eventInfo);
5326 priv->pageClient->page()->deleteSurroundingText(event->offset, event->n_chars);
5329 Ecore_IMF_Context* ewk_view_imf_context_get(Evas_Object* ewkView)
5331 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5332 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5334 return priv->imfContext;
5337 Ecore_IMF_Context* ewk_view_imf_context_set(Evas_Object* ewkView, Ecore_IMF_Input_Panel_Layout layout)
5339 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5340 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5342 Ecore_IMF_Context* imfContext;
5343 Eina_List* iterator;
5346 EINA_LIST_FOREACH(priv->imfContextList, iterator, data) {
5347 imfContext = static_cast<Ecore_IMF_Context*>(data);
5348 if (ecore_imf_context_input_panel_layout_get(imfContext) == layout) {
5349 priv->imfContext = imfContext;
5354 imfContext = ecore_imf_context_add(ecore_imf_context_default_id_get());
5358 ecore_imf_context_input_panel_enabled_set(imfContext, false);
5359 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, imfInputPanelStateEventCb, smartData);
5360 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, imfInputPanelGeometryEventCb, smartData);
5361 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, imfCandidatePanelStateEventCb, smartData);
5362 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, imfCandidatePanelGeometryEventCb, smartData);
5363 ecore_imf_context_retrieve_surrounding_callback_set(imfContext, imfRetrieveSurroundingCb, smartData); // Support for Auto Capitalization
5364 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, imfPreeditChangedCb, smartData);
5365 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_COMMIT, imfEventCommittedCb, smartData);
5366 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, imfContextDeleteSurroundingCb, smartData); //Support for Automatic Full Stop
5367 ecore_imf_context_input_panel_layout_set(imfContext, layout);
5369 priv->imfContextList = eina_list_append(priv->imfContextList, imfContext);
5370 priv->imfContext = imfContext;
5375 void ewk_view_imf_context_reset(Evas_Object* ewkView)
5377 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5378 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5380 if (!priv->imfContext)
5383 ecore_imf_context_reset(priv->imfContext);
5385 if (ecore_imf_context_input_panel_state_get(priv->imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
5386 priv->imfContext = 0;
5389 void ewk_view_imf_context_hide(Evas_Object* ewkView)
5391 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5392 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5394 if (!priv->imfContext)
5397 if (ecore_imf_context_input_panel_state_get(priv->imfContext) != ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
5398 ecore_imf_context_reset(priv->imfContext);
5399 ecore_imf_context_input_panel_hide(priv->imfContext);
5400 ecore_imf_context_focus_out(priv->imfContext);
5403 priv->imfContext = 0;
5406 static void _ewk_view_imf_context_destroy(Ewk_View_Private_Data* priv)
5408 if (!priv->imfContextList)
5412 EINA_LIST_FREE(priv->imfContextList, item) {
5413 Ecore_IMF_Context* imfContext = static_cast<Ecore_IMF_Context*>(item);
5417 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, imfInputPanelStateEventCb);
5418 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, imfInputPanelGeometryEventCb);
5419 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, imfCandidatePanelStateEventCb);
5420 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, imfCandidatePanelGeometryEventCb);
5421 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, imfPreeditChangedCb);
5422 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_COMMIT, imfEventCommittedCb);
5423 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, imfContextDeleteSurroundingCb);
5424 ecore_imf_context_del(imfContext);
5427 priv->imfContextList = 0;
5428 priv->imfContext = 0;
5431 void ewk_view_imf_context_destroy(Evas_Object* ewkView)
5433 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5434 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5436 _ewk_view_imf_context_destroy(priv);
5440 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
5441 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
5443 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5444 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5446 WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(priv->pageClient->page())));
5450 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
5451 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
5453 evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
5457 #if ENABLE(TIZEN_ICON_DATABASE)
5458 void ewkViewIconReceived(Evas_Object* ewkView)
5462 evas_object_smart_callback_call(ewkView, "icon,received", 0);
5466 #endif // #if OS(TIZEN)
5468 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
5469 #if ENABLE(INPUT_TYPE_COLOR)
5472 * Reqeusts to show external color picker.
5474 void ewk_view_color_picker_request(Evas_Object* ewkView, int r, int g, int b, int a, WKColorPickerResultListenerRef listener)
5476 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5477 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5478 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_request);
5480 priv->colorPickerResultListener = listener;
5482 smartData->api->input_picker_color_request(smartData, r, g, b, a);
5487 * Reqeusts to hide external color picker.
5489 void ewk_view_color_picker_dismiss(Evas_Object* ewkView)
5491 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5492 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5493 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_dismiss);
5495 priv->colorPickerResultListener = 0;
5497 smartData->api->input_picker_color_dismiss(smartData);
5501 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
5503 #if ENABLE(INPUT_TYPE_COLOR)
5504 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5505 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5506 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->colorPickerResultListener, false);
5508 WebCore::Color color = WebCore::Color(r, g, b, a);
5509 WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(color.serialized().utf8().data()));
5510 WKColorPickerResultListenerSetColor(priv->colorPickerResultListener, colorString.get());
5511 priv->colorPickerResultListener = 0;
5518 #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
5520 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
5522 #if ENABLE(TOUCH_EVENTS)
5523 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
5524 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5525 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5526 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
5528 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
5529 if (priv->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
5530 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5531 IntPoint handlePoint(point->x, point->y);
5533 if (type == EWK_TOUCH_START)
5534 priv->pageClient->textSelectonHandleDown(handlePoint);
5535 else if (type == EWK_TOUCH_MOVE)
5536 priv->pageClient->textSelectonHandleMove(handlePoint);
5538 priv->pageClient->textSelectonHandleUp();
5542 #if ENABLE(TIZEN_GESTURE)
5543 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
5544 // We don't want to process touch event when context menu is shown.
5545 if (priv->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
5548 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
5549 if (priv->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
5553 if (type == EWK_TOUCH_START) {
5554 if (eina_list_count(points) == 1) {
5555 priv->gestureClient->reset();
5556 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5557 priv->touchDownPoint.x = point->x;
5558 priv->touchDownPoint.y = point->y;
5559 priv->exceedTouchMoveThreshold = false;
5561 } else if (type == EWK_TOUCH_MOVE && !priv->exceedTouchMoveThreshold) {
5562 if (eina_list_count(points) == 1) {
5563 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
5564 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5565 int diffX = priv->touchDownPoint.x - point->x;
5566 int diffY = priv->touchDownPoint.y - point->y;
5567 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
5568 priv->exceedTouchMoveThreshold = true;
5572 priv->exceedTouchMoveThreshold = true;
5575 #endif // #if ENABLE(TIZEN_GESTURE)
5577 // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
5578 //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
5579 priv->pageClient->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
5587 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
5589 #if ENABLE(TOUCH_EVENTS)
5590 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5591 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5593 enabled = !!enabled;
5594 if (priv->areTouchEventsEnabled == enabled)
5597 priv->areTouchEventsEnabled = enabled;
5599 // FIXME: We have to connect touch callbacks with mouse and multi events
5600 // because the Evas creates mouse events for first touch and multi events
5601 // for second and third touches. Below codes should be fixed when the Evas
5602 // supports the touch events.
5603 // See https://bugs.webkit.org/show_bug.cgi?id=97785 for details.
5604 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down, smartData);
5605 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up, smartData);
5606 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move, smartData);
5607 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down, smartData);
5608 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up, smartData);
5609 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move, smartData);
5611 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down);
5612 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up);
5613 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move);
5614 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down);
5615 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up);
5616 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move);
5625 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
5627 #if ENABLE(TOUCH_EVENTS)
5628 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5629 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5631 return priv->areTouchEventsEnabled;
5637 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
5639 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
5640 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5641 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5643 priv->mainFrameScrollbarVisibility = visible;
5644 priv->pageClient->updateVisibility();
5652 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
5654 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
5655 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5656 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5658 return priv->mainFrameScrollbarVisibility;
5664 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
5666 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
5667 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5668 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5669 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
5671 String title = ewk_view_title_get(ewkView);
5672 String url = ewk_view_url_get(ewkView);
5673 String directoryPath(path);
5674 priv->pageClient->startOfflinePageSave(directoryPath, url, title);
5678 UNUSED_PARAM(ewkView);
5686 * Callback function used for ewk_view_page_contents_get().
5688 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
5690 EINA_SAFETY_ON_NULL_RETURN(context);
5692 RefPtr<WebData> webData = toImpl(wkData);
5693 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
5694 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
5699 * Callback function used for ewk_view_page_contents_get().
5701 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
5703 EINA_SAFETY_ON_NULL_RETURN(context);
5705 RefPtr<WebString> webString = toImpl(wkString);
5706 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
5707 contentsContext->callback(contentsContext->type, webString->string().utf8().data());
5710 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
5712 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
5713 EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
5714 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5715 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5717 switch (context->type) {
5718 case EWK_PAGE_CONTENTS_TYPE_MHTML:
5719 priv->pageClient->page()->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
5722 case EWK_PAGE_CONTENTS_TYPE_STRING:
5723 priv->pageClient->page()->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
5727 ASSERT_NOT_REACHED();
5734 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
5736 #if ENABLE(TIZEN_GESTURE)
5737 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5738 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5740 return priv->gestureClient->scrollToWithAnimation(x, y);
5742 UNUSED_PARAM(ewkView);
5749 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5750 void ewkViewFocusRingHide(Evas_Object* ewkView)
5752 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5753 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5755 if (priv->focusRing)
5756 priv->focusRing->hide();
5760 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
5762 #if ENABLE(TIZEN_CSP)
5763 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
5764 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
5766 TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
5767 priv->pageClient->page()->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));