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_PREFERENCE)
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();
1374 #if ENABLE(TIZEN_PREFERENCE)
1375 if (priv && priv->pageClient->page()) {
1376 priv->pageClient->page()->pageGroup()->preferences()->setViewWidth(width);
1377 priv->pageClient->page()->pageGroup()->preferences()->setViewHeight(height);
1380 #endif // #if OS(TIZEN)
1382 smartData->changed.size = true;
1383 _ewk_view_smart_changed(smartData);
1386 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
1388 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1390 smartData->changed.position = true;
1391 _ewk_view_smart_changed(smartData);
1394 IntSize ewk_view_size_get(const Evas_Object* ewkView)
1397 evas_object_geometry_get(ewkView, 0, 0, &width, &height);
1398 return IntSize(width, height);
1401 #if USE(ACCELERATED_COMPOSITING)
1402 static bool ewk_view_create_gl_surface(const Evas_Object* ewkView, const IntSize& viewSize)
1404 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1405 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1407 Evas_GL_Config evasGlConfig = {
1409 EVAS_GL_DEPTH_BIT_8,
1410 EVAS_GL_STENCIL_NONE,
1411 EVAS_GL_OPTIONS_NONE,
1412 EVAS_GL_MULTISAMPLE_NONE
1415 ASSERT(!priv->evasGlSurface);
1416 priv->evasGlSurface = evas_gl_surface_create(priv->evasGl, &evasGlConfig, viewSize.width(), viewSize.height());
1417 if (!priv->evasGlSurface)
1420 Evas_Native_Surface nativeSurface;
1421 evas_gl_native_surface_get(priv->evasGl, priv->evasGlSurface, &nativeSurface);
1422 evas_object_image_native_surface_set(smartData->image, &nativeSurface);
1427 bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView)
1429 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1430 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1432 EINA_SAFETY_ON_TRUE_RETURN_VAL(!!priv->evasGl, false);
1434 Evas* evas = evas_object_evas_get(ewkView);
1435 priv->evasGl = evas_gl_new(evas);
1439 priv->evasGlContext = evas_gl_context_create(priv->evasGl, 0);
1440 if (!priv->evasGlContext) {
1441 evas_gl_free(priv->evasGl);
1446 if (!ewk_view_create_gl_surface(ewkView, ewk_view_size_get(ewkView))) {
1447 evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
1448 priv->evasGlContext = 0;
1450 evas_gl_free(priv->evasGl);
1458 bool ewk_view_accelerated_compositing_mode_exit(const Evas_Object* ewkView)
1460 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1461 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1463 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->evasGl, false);
1465 if (priv->evasGlSurface) {
1466 evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
1467 priv->evasGlSurface = 0;
1470 if (priv->evasGlContext) {
1471 evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
1472 priv->evasGlContext = 0;
1475 evas_gl_free(priv->evasGl);
1482 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
1484 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1485 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1486 Evas_Coord x, y, width, height;
1488 smartData->changed.any = false;
1490 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
1492 if (smartData->changed.size) {
1494 if (priv->pageClient->page()->drawingArea())
1495 priv->pageClient->page()->drawingArea()->setSize(IntSize(width, height), IntSize());
1497 #if USE(ACCELERATED_COMPOSITING)
1498 if (!priv->evasGlSurface)
1500 evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
1501 priv->evasGlSurface = 0;
1502 ewk_view_create_gl_surface(ewkView, IntSize(width, height));
1503 ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
1505 #endif // #if !OS(TIZEN)
1507 smartData->view.w = width;
1508 smartData->view.h = height;
1509 smartData->changed.size = false;
1512 if (priv->pageClient) {
1513 if (DrawingAreaProxy* drawingArea = priv->pageClient->page()->drawingArea()) {
1514 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1515 if (priv->pageClient->page()->isViewVisible())
1516 drawingArea->setSize(IntSize(width, height), IntSize());
1518 drawingArea->setSize(IntSize(width, height), IntSize());
1520 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1521 priv->pageClient->updateViewportSize(IntSize(width, height));
1522 if (ewk_view_is_opengl_backend(ewkView))
1523 priv->pageClient->displayViewport();
1526 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1527 priv->pageClient->frameRectChanged();
1530 #endif // #if OS(TIZEN)
1533 if (smartData->changed.position) {
1534 evas_object_move(smartData->image, x, y);
1535 smartData->view.x = x;
1536 smartData->view.y = y;
1537 smartData->changed.position = false;
1539 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1540 priv->pageClient->frameRectChanged();
1542 #if ENABLE(TIZEN_SCREEN_READER)
1543 priv->pageClient->page()->recalcScreenReaderFocusRect();
1545 #endif // #if OS(TIZEN)
1548 if (priv->popupPicker)
1549 ewk_popup_picker_resize(priv->popupPicker);
1550 #endif // #if OS(TIZEN)
1553 static void _ewk_view_smart_show(Evas_Object* ewkView)
1555 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1556 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1558 if (evas_object_clipees_get(smartData->base.clipper))
1559 evas_object_show(smartData->base.clipper);
1560 evas_object_show(smartData->image);
1563 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1565 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1567 evas_object_hide(smartData->base.clipper);
1568 evas_object_hide(smartData->image);
1569 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1570 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1571 if (priv->pageClient->isTextSelectionMode())
1572 priv->pageClient->setIsTextSelectionMode(false);
1576 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1578 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1579 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1583 else if (alpha > 255)
1586 #define CHECK_COLOR(color, alpha) \
1589 else if (color > alpha) \
1591 CHECK_COLOR(red, alpha);
1592 CHECK_COLOR(green, alpha);
1593 CHECK_COLOR(blue, alpha);
1596 evas_object_image_alpha_set(smartData->image, alpha < 255);
1597 priv->pageClient->page()->setDrawsBackground(red || green || blue);
1598 priv->pageClient->page()->setDrawsTransparentBackground(alpha < 255);
1599 priv->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1602 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1606 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1608 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1610 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1611 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1612 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1616 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1617 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1619 evas_object_smart_clipped_smart_set(&api->sc);
1621 // Set Evas_Smart_Class functions.
1622 api->sc.add = _ewk_view_smart_add;
1623 api->sc.del = _ewk_view_smart_del;
1624 api->sc.move = _ewk_view_smart_move;
1625 api->sc.resize = _ewk_view_smart_resize;
1626 api->sc.show = _ewk_view_smart_show;
1627 api->sc.hide = _ewk_view_smart_hide;
1628 api->sc.color_set = _ewk_view_smart_color_set;
1629 api->sc.calculate = _ewk_view_smart_calculate;
1630 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1632 // Set Ewk_View_Smart_Class functions.
1633 api->focus_in = _ewk_view_smart_focus_in;
1634 api->focus_out = _ewk_view_smart_focus_out;
1635 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1636 api->mouse_down = _ewk_view_smart_mouse_down;
1637 api->mouse_up = _ewk_view_smart_mouse_up;
1638 api->mouse_move = _ewk_view_smart_mouse_move;
1639 api->key_down = _ewk_view_smart_key_down;
1640 api->key_up = _ewk_view_smart_key_up;
1642 api->gesture_start = _ewk_view_smart_gesture_start;
1643 api->gesture_end = _ewk_view_smart_gesture_end;
1644 api->gesture_move = _ewk_view_smart_gesture_move;
1646 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1647 api->popup_menu_show = _ewk_view_popup_menu_show;
1648 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1649 api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1651 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1652 api->popup_menu_update = _ewk_view_popup_menu_update;
1654 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1655 api->text_selection_down = _ewk_view_text_selection_down;
1656 api->text_selection_move = _ewk_view_text_selection_move;
1657 api->text_selection_up = _ewk_view_text_selection_up;
1659 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1660 api->input_picker_show = _ewk_view_input_picker_show;
1662 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1663 api->data_list_show = _ewk_view_data_list_show;
1664 api->data_list_hide = _ewk_view_data_list_hide;
1666 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1667 api->orientation_lock = _ewk_orientation_lock;
1668 api->orientation_unlock = _ewk_orientation_unlock;
1670 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1671 api->input_picker_color_request = _ewk_input_picker_color_request;
1672 api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1674 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1675 api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1676 api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1677 api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1678 api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1680 #if ENABLE(TIZEN_SCREEN_READER)
1681 api->screen_reader_command_execute = _ewk_view_screen_reader_command_execute;
1683 #endif //#if OS(TIZEN)
1688 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1690 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1691 static Evas_Smart* smart = 0;
1693 if (EINA_UNLIKELY(!smart)) {
1694 ewk_view_smart_class_set(&api);
1695 smart = evas_smart_class_new(&api.sc);
1701 static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKPageGroupRef pageGroupRef)
1703 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1704 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
1705 EINA_SAFETY_ON_NULL_RETURN(context);
1707 if (priv->pageClient)
1710 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1711 if (ewk_view_is_opengl_backend(ewkView)) {
1712 priv->pageClient = PageClientEvasGL::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1713 priv->pageClient->page()->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1716 priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1717 priv->pageClient->page()->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1718 priv->pageClient->page()->pageGroup()->preferences()->setWebGLEnabled(false);
1719 priv->pageClient->page()->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1722 priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1724 // FixMe: Comment should be removed when pageClient is removed.
1725 //priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageProxy.get())))));
1726 priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageClient->page())))));
1729 priv->context = context;
1731 ewkViewContextMenuClientAttachClient(ewkView);
1732 ewkViewFindClientAttatchClient(ewkView);
1733 ewkViewTizenClientAttachClient(ewkView);
1734 ewkViewUIClientAttatchClient(ewkView);
1736 #if ENABLE(TIZEN_GEOLOCATION)
1737 ewkViewGeolocationProviderAttachProvider(ewkView, ewk_context_WKContext_get(context));
1740 #if ENABLE(TIZEN_NOTIFICATIONS)
1741 ewkViewNotificationProviderAttachProvider(ewkView, ewk_context_WKContext_get(context));
1744 #if ENABLE(TIZEN_ICON_DATABASE)
1745 ewk_view_icondatabase_client_attach(ewkView, ewk_context_WKContext_get(context));
1748 ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1749 ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1750 ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1751 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1752 ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1754 ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1755 #else // #if OS(TIZEN)
1756 priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageClient->page()->backForwardList()));
1758 #if USE(COORDINATED_GRAPHICS)
1759 priv->viewportHandler = EflViewportHandler::create(priv->pageClient.get());
1761 #endif // #if OS(TIZEN)
1763 WKPageRef wkPage = toAPI(priv->pageClient->page());
1764 ewk_view_form_client_attach(wkPage, ewkView);
1765 ewk_view_loader_client_attach(wkPage, ewkView);
1766 ewk_view_policy_client_attach(wkPage, ewkView);
1767 ewk_view_resource_load_client_attach(wkPage, ewkView);
1769 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1770 ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1773 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1774 if (!ewk_context_x_window_get(context))
1775 ewk_context_x_window_set(context, elm_win_xwindow_get(ewkView));
1779 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1781 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1782 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1784 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1785 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1786 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1791 Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1795 EWK_VIEW_SD_GET(ewkView, smartData);
1797 evas_object_del(ewkView);
1801 EWK_VIEW_PRIV_GET(smartData, priv);
1803 evas_object_del(ewkView);
1812 * Constructs a ewk_view Evas_Object with WKType parameters.
1814 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1816 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1817 EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1819 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1823 _ewk_view_initialize(ewkView, ewk_context_new_from_WKContext(contextRef), pageGroupRef);
1828 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1830 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1831 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1832 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1834 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1838 #if ENABLE(TIZEN_ICON_DATABASE)
1839 //set default iconDatabasePath
1840 WKContextRef contextRef = ewk_context_WKContext_get(context);
1841 toImpl(contextRef)->setIconDatabasePath(toImpl(contextRef)->iconDatabasePath());
1844 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1845 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1846 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1847 _ewk_view_initialize(ewkView, context, toAPI(priv->pageGroup.get()));
1849 _ewk_view_initialize(ewkView, context, 0);
1855 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1857 return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1860 Evas_Object* ewk_view_add(Evas* canvas)
1862 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1867 * The uri of view was changed by the frame loader.
1869 * Emits signal: "uri,changed" with pointer to new uri string.
1871 void ewk_view_uri_update(Evas_Object* ewkView)
1873 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1874 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1876 String activeURL = priv->pageClient->page()->activeURL();
1877 if (activeURL.isEmpty())
1880 if (!eina_stringshare_replace(&priv->uri, activeURL.utf8().data()))
1883 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1884 evas_object_smart_callback_call(ewkView, "url,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1887 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* uri)
1889 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1890 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1891 EINA_SAFETY_ON_NULL_RETURN_VAL(uri, false);
1893 priv->pageClient->page()->loadURL(String::fromUTF8(uri));
1894 ewk_view_uri_update(ewkView);
1899 const char* ewk_view_url_get(const Evas_Object* ewkView)
1901 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1902 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1907 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1909 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1910 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1912 priv->pageClient->page()->reload(/*reloadFromOrigin*/ false);
1913 ewk_view_uri_update(ewkView);
1918 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1920 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1921 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1923 priv->pageClient->page()->reload(/*reloadFromOrigin*/ true);
1924 ewk_view_uri_update(ewkView);
1929 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1931 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1932 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1934 priv->pageClient->page()->stopLoading();
1939 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1941 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1942 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1944 return priv->settings.get();
1949 * Load was initiated for a resource in the view.
1951 * Emits signal: "resource,request,new" with pointer to resource request.
1953 void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request)
1955 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1956 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1958 Ewk_Web_Resource_Request resourceRequest = {resource, request, 0};
1960 // Keep the resource internally to reuse it later.
1961 ewk_web_resource_ref(resource);
1962 priv->loadingResourcesMap.add(resourceIdentifier, resource);
1964 evas_object_smart_callback_call(ewkView, "resource,request,new", &resourceRequest);
1969 * Received a response to a resource load request in the view.
1971 * Emits signal: "resource,request,response" with pointer to resource response.
1973 void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response)
1975 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1976 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1978 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
1981 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
1982 Ewk_Web_Resource_Load_Response resourceLoadResponse = {resource, response};
1983 evas_object_smart_callback_call(ewkView, "resource,request,response", &resourceLoadResponse);
1988 * Failed loading a resource in the view.
1990 * Emits signal: "resource,request,finished" with pointer to the resource load error.
1992 void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Error* error)
1994 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1995 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1997 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2000 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
2001 Ewk_Web_Resource_Load_Error resourceLoadError = {resource, error};
2002 evas_object_smart_callback_call(ewkView, "resource,request,failed", &resourceLoadError);
2007 * Finished loading a resource in the view.
2009 * Emits signal: "resource,request,finished" with pointer to the resource.
2011 void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIdentifier)
2013 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2014 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2016 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2019 Ewk_Web_Resource* resource = priv->loadingResourcesMap.take(resourceIdentifier);
2020 evas_object_smart_callback_call(ewkView, "resource,request,finished", resource);
2022 ewk_web_resource_unref(resource);
2027 * Request was sent for a resource in the view.
2029 * Emits signal: "resource,request,sent" with pointer to resource request and possible redirect response.
2031 void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse)
2033 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2034 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2036 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2039 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
2040 Ewk_Web_Resource_Request resourceRequest = {resource, request, redirectResponse};
2042 evas_object_smart_callback_call(ewkView, "resource,request,sent", &resourceRequest);
2045 const char* ewk_view_title_get(const Evas_Object* ewkView)
2047 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2048 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2050 CString title = priv->pageClient->page()->pageTitle().utf8();
2051 eina_stringshare_replace(&priv->title, title.data());
2058 * Reports that the requested text was found.
2060 * Emits signal: "text,found" with the number of matches.
2062 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
2064 evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
2069 * The view title was changed by the frame loader.
2071 * Emits signal: "title,changed" with pointer to new title string.
2073 void ewk_view_title_changed(Evas_Object* ewkView, const char* title)
2075 evas_object_smart_callback_call(ewkView, "title,changed", const_cast<char*>(title));
2078 double ewk_view_load_progress_get(const Evas_Object* ewkView)
2080 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2081 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2083 return priv->pageClient->page()->estimatedProgress();
2086 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
2088 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2089 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2095 scaleFactor = priv->pageClient->adjustScaleWithViewport(scaleFactor);
2097 IntPoint scrollPosition = priv->pageClient->scrollPosition();
2098 double scaleDifference = scaleFactor / priv->pageClient->scaleFactor();
2099 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
2100 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
2102 priv->pageClient->page()->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
2104 priv->pageClient->page()->scalePage(scaleFactor, IntPoint(x, y));
2109 double ewk_view_scale_get(const Evas_Object* ewkView)
2111 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
2112 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1);
2115 return priv->pageClient->page()->scaleFactor();
2117 return priv->pageClient->page()->pageScaleFactor();
2121 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
2123 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2124 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2126 priv->pageClient->page()->setCustomDeviceScaleFactor(ratio);
2131 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
2133 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2134 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2136 return priv->pageClient->page()->deviceScaleFactor();
2139 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
2140 void ewk_view_load_progress_started(Evas_Object* ewkView)
2142 evas_object_smart_callback_call(ewkView, "load,progress,started", 0);
2148 * Reports load progress changed.
2150 * Emits signal: "load,progress" with pointer to a double from 0.0 to 1.0.
2152 void ewk_view_load_progress_changed(Evas_Object* ewkView, double progress)
2154 evas_object_smart_callback_call(ewkView, "load,progress", &progress);
2157 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
2158 void ewk_view_load_progress_finished(Evas_Object* ewkView)
2160 evas_object_smart_callback_call(ewkView, "load,progress,finished", 0);
2164 #if ENABLE(WEB_INTENTS)
2167 * The view received a new intent request.
2169 * Emits signal: "intent,request,new" with pointer to a Ewk_Intent.
2171 void ewk_view_intent_request_new(Evas_Object* ewkView, const Ewk_Intent* ewkIntent)
2173 evas_object_smart_callback_call(ewkView, "intent,request,new", const_cast<Ewk_Intent*>(ewkIntent));
2177 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
2179 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2180 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2182 if (!eina_stringshare_replace(&priv->theme, path))
2185 priv->pageClient->page()->setThemePath(path);
2188 const char* ewk_view_theme_get(const Evas_Object* ewkView)
2190 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2191 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2196 void ewk_view_cursor_set(Evas_Object* ewkView, const Cursor& cursor)
2198 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2199 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2201 const char* group = cursor.platformCursor();
2202 if (!group || group == priv->cursorGroup)
2205 priv->cursorGroup = group;
2207 if (priv->cursorObject)
2208 evas_object_del(priv->cursorObject);
2209 priv->cursorObject = edje_object_add(smartData->base.evas);
2211 Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
2212 if (!priv->theme || !edje_object_file_set(priv->cursorObject, priv->theme, group)) {
2213 evas_object_del(priv->cursorObject);
2214 priv->cursorObject = 0;
2216 ecore_evas_object_cursor_set(ecoreEvas, 0, 0, 0, 0);
2218 if (priv->isUsingEcoreX)
2219 WebCore::applyFallbackCursor(ecoreEvas, group);
2224 Evas_Coord width, height;
2225 edje_object_size_min_get(priv->cursorObject, &width, &height);
2226 if (width <= 0 || height <= 0)
2227 edje_object_size_min_calc(priv->cursorObject, &width, &height);
2228 if (width <= 0 || height <= 0) {
2229 width = defaultCursorSize;
2230 height = defaultCursorSize;
2232 evas_object_resize(priv->cursorObject, width, height);
2236 data = edje_object_data_get(priv->cursorObject, "hot.x");
2238 hotspotX = atoi(data);
2241 data = edje_object_data_get(priv->cursorObject, "hot.y");
2243 hotspotY = atoi(data);
2245 ecore_evas_object_cursor_set(ecoreEvas, priv->cursorObject, EVAS_LAYER_MAX, hotspotX, hotspotY);
2248 void ewk_view_display(Evas_Object* ewkView, const IntRect& rect)
2250 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2251 if (!smartData->image)
2254 evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height());
2259 * A download for that view was cancelled.
2261 * Emits signal: "download,cancelled" with pointer to a Ewk_Download_Job.
2263 void ewk_view_download_job_cancelled(Evas_Object* ewkView, Ewk_Download_Job* download)
2265 evas_object_smart_callback_call(ewkView, "download,cancelled", download);
2270 * A new download has been requested for that view.
2272 * Emits signal: "download,request" with pointer to a Ewk_Download_Job.
2274 void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job* download)
2276 evas_object_smart_callback_call(ewkView, "download,request", download);
2281 * A download for that view has failed.
2283 * Emits signal: "download,failed" with pointer to a Ewk_Download_Job_Error.
2285 void ewk_view_download_job_failed(Evas_Object* ewkView, Ewk_Download_Job* download, Ewk_Web_Error* error)
2287 Ewk_Download_Job_Error downloadError = { download, error };
2288 evas_object_smart_callback_call(ewkView, "download,failed", &downloadError);
2293 * A download for that view finished successfully.
2295 * Emits signal: "download,finished" with pointer to a Ewk_Download_Job.
2297 void ewk_view_download_job_finished(Evas_Object* ewkView, Ewk_Download_Job* download)
2299 evas_object_smart_callback_call(ewkView, "download,finished", download);
2302 Eina_Bool ewk_view_back(Evas_Object* ewkView)
2304 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2305 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2307 WebPageProxy* page = priv->pageClient->page();
2308 if (page->canGoBack()) {
2316 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
2318 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2319 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2321 WebPageProxy* page = priv->pageClient->page();
2322 if (page->canGoForward()) {
2330 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
2332 #if ENABLE(WEB_INTENTS)
2333 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2334 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2335 EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
2337 WebPageProxy* page = priv->pageClient->page();
2338 page->deliverIntentToFrame(page->mainFrame(), toImpl(ewk_intent_WKIntentDataRef_get(intent)));
2346 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
2348 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2349 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2351 return priv->pageClient->page()->canGoBack();
2354 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
2356 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2357 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2359 return priv->pageClient->page()->canGoForward();
2362 void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size)
2364 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2365 if (!imageData || !smartData->image)
2368 evas_object_resize(smartData->image, size.width(), size.height());
2369 evas_object_image_size_set(smartData->image, size.width(), size.height());
2370 evas_object_image_data_copy_set(smartData->image, imageData);
2375 * Reports that a form request is about to be submitted.
2377 * Emits signal: "form,submission,request" with pointer to Ewk_Form_Submission_Request.
2379 void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submission_Request* request)
2381 evas_object_smart_callback_call(ewkView, "form,submission,request", request);
2384 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2385 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
2387 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2388 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2390 if (!ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
2393 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(ewkView);
2394 if (!imfContext || ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
2397 if (value.isEmpty()) {
2398 if(smartData->api->formdata_candidate_is_showing(smartData))
2399 smartData->api->formdata_candidate_hide(smartData);
2403 Vector<String> popupCandidates;
2404 ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
2405 std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
2407 Eina_List* candidateList = 0;
2408 for (size_t i = 0; i < popupCandidates.size(); ++i) {
2409 if (popupCandidates[i].startsWith(value, false))
2410 candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
2413 if (!eina_list_count(candidateList)) {
2414 if(smartData->api->formdata_candidate_is_showing(smartData))
2415 smartData->api->formdata_candidate_hide(smartData);
2419 smartData->api->formdata_candidate_update_data(smartData, candidateList);
2421 if (!smartData->api->formdata_candidate_is_showing(smartData))
2422 smartData->api->formdata_candidate_hide(smartData);
2424 IntRect inputFieldRect = priv->pageClient->focusedNodeRect();
2425 smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
2428 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm)
2430 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2431 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2432 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
2433 && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
2435 ewk_context_form_data_add(ewk_view_context_get(ewkView), priv->uri, formData, isPasswordForm);
2438 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
2440 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2441 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2443 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
2446 Vector<std::pair<String, String> > passwordFormData;
2447 ewk_context_form_password_data_get(ewk_view_context_get(ewkView), priv->uri, passwordFormData);
2449 if (!passwordFormData.size())
2452 String passwordFormAutofill = "try { function passwordFormAutofill() { var inputFields;";
2453 for (size_t i = 0; i < passwordFormData.size(); i++) {
2454 passwordFormAutofill += String::format(" inputFields = document.getElementsByName(\"%s\");"
2455 " for (var i = 0; i < inputFields.length; i++)"
2456 " if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\"))"
2457 " inputFields[i].value = \"%s\";",
2458 passwordFormData[i].first.utf8().data(), passwordFormData[i].second.utf8().data());
2460 passwordFormAutofill += "} passwordFormAutofill(); } catch(e) { }";
2461 ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
2464 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
2466 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2467 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2468 ewk_context_form_candidate_data_get(ewk_view_context_get(ewkView), name, candidates);
2474 * Reports load failed with error information.
2476 * Emits signal: "load,error" with pointer to Ewk_Web_Error.
2478 void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error)
2480 evas_object_smart_callback_call(ewkView, "load,error", const_cast<Ewk_Web_Error*>(error));
2485 * Reports load finished.
2487 * Emits signal: "load,finished".
2489 void ewk_view_load_finished(Evas_Object* ewkView)
2491 ewk_view_uri_update(ewkView);
2492 evas_object_smart_callback_call(ewkView, "load,finished", 0);
2494 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2495 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2497 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
2498 priv->pageClient->page()->setLoadingFinished(true);
2501 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2502 ewk_view_form_password_data_fill(ewkView);
2505 if (!priv->suspendRequested)
2508 priv->suspendRequested = false;
2510 if (!priv->suspendedPainting) {
2511 priv->pageClient->page()->suspendPainting();
2512 priv->suspendedPainting = true;
2514 if (!priv->suspendedResources) {
2515 priv->pageClient->page()->suspendJavaScriptAndResource();
2516 priv->suspendedResources = true;
2522 * Reports view provisional load failed with error information.
2524 * Emits signal: "load,provisional,failed" with pointer to Ewk_Web_Error.
2526 void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Web_Error* error)
2528 evas_object_smart_callback_call(ewkView, "load,provisional,failed", const_cast<Ewk_Web_Error*>(error));
2533 * Reports view received redirect for provisional load.
2535 * Emits signal: "load,provisional,redirect".
2537 void ewk_view_load_provisional_redirect(Evas_Object* ewkView)
2539 ewk_view_uri_update(ewkView);
2540 evas_object_smart_callback_call(ewkView, "load,provisional,redirect", 0);
2545 * Reports view provisional load started.
2547 * Emits signal: "load,provisional,started".
2549 void ewk_view_load_provisional_started(Evas_Object* ewkView)
2552 evas_object_smart_callback_call(ewkView, "load,started", 0);
2555 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2556 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2558 #if ENABLE(TIZEN_DRAG_SUPPORT)
2559 if (priv->pageClient->isDragMode())
2560 priv->pageClient->setDragMode(false);
2563 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
2564 priv->pageClient->page()->setLoadingFinished(false);
2567 // The main frame started provisional load, we should clear
2568 // the loadingResources HashMap to start clean.
2569 _ewk_view_priv_loading_resources_clear(priv->loadingResourcesMap);
2571 ewk_view_uri_update(ewkView);
2572 evas_object_smart_callback_call(ewkView, "load,provisional,started", 0);
2577 * Reports that a navigation policy decision should be taken.
2579 * Emits signal: "policy,decision,navigation".
2581 void ewk_view_navigation_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision)
2583 evas_object_smart_callback_call(ewkView, "policy,decision,navigation", decision);
2588 * Reports that a new window policy decision should be taken.
2590 * Emits signal: "policy,decision,new,window".
2592 void ewk_view_new_window_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision)
2594 evas_object_smart_callback_call(ewkView, "policy,decision,new,window", decision);
2597 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
2599 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2600 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2601 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
2603 if (unreachableUrl && *unreachableUrl)
2604 priv->pageClient->page()->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
2606 priv->pageClient->page()->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
2607 ewk_view_uri_update(ewkView);
2612 #if ENABLE(WEB_INTENTS_TAG)
2615 * The view received a new intent service registration.
2617 * Emits signal: "intent,service,register" with pointer to a Ewk_Intent_Service.
2619 void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Service* ewkIntentService)
2621 evas_object_smart_callback_call(ewkView, "intent,service,register", const_cast<Ewk_Intent_Service*>(ewkIntentService));
2623 #endif // ENABLE(WEB_INTENTS_TAG)
2625 WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView)
2627 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2628 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2630 return priv->pageClient->page();
2633 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
2635 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2636 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2638 String customEncoding = priv->pageClient->page()->customTextEncodingName();
2639 if (customEncoding.isEmpty())
2642 eina_stringshare_replace(&priv->customEncoding, customEncoding.utf8().data());
2644 return priv->customEncoding;
2647 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
2649 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2650 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2652 if (eina_stringshare_replace(&priv->customEncoding, encoding))
2653 priv->pageClient->page()->setCustomTextEncodingName(encoding ? String::fromUTF8(encoding) : String());
2659 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
2661 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2662 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2663 return priv->context;
2666 // FIXME: It should be removed.
2667 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
2669 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2670 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2672 return toAPI(priv->pageClient->page());
2675 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
2677 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2678 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2680 enabled = !!enabled;
2681 if (priv->areMouseEventsEnabled == enabled)
2684 priv->areMouseEventsEnabled = enabled;
2686 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down, smartData);
2687 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up, smartData);
2688 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move, smartData);
2690 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
2691 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
2692 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
2698 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
2700 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2701 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2703 return priv->areMouseEventsEnabled;
2706 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
2708 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2709 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2711 return priv->javascriptPopup->alert(alertText);
2714 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
2716 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2717 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2719 return priv->javascriptPopup->confirm(message);
2722 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
2724 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2725 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2727 return priv->javascriptPopup->prompt(message, defaultValue);
2730 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
2731 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, void* userData)
2733 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2734 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2736 return priv->javascriptPopup->beforeUnloadConfirmPanel(message);
2740 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)
2742 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2743 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2745 return priv->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, priv);
2748 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
2749 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)
2751 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2753 if (priv->popupPicker)
2754 ewk_popup_picker_del(priv->popupPicker);
2756 #if ENABLE(TIZEN_MULTIPLE_SELECT)
2757 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
2759 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
2765 #if ENABLE(TIZEN_MULTIPLE_SELECT)
2766 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)
2768 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2770 if (priv->popupPicker)
2771 ewk_popup_picker_del(priv->popupPicker);
2773 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
2779 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
2781 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2783 if (!priv->popupPicker)
2786 ewk_popup_picker_del(priv->popupPicker);
2787 priv->popupPicker = 0;
2792 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)
2794 // FIXME: The rect should be updated if it was changed
2796 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2798 if (!priv->popupPicker)
2801 ewk_popup_picker_update(smartData->self, priv->popupPicker, items, selectedIndex);
2807 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
2808 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
2810 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2812 priv->inputPicker->show(inputType, inputValue);
2817 #if ENABLE(TIZEN_DATALIST_ELEMENT)
2818 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
2820 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2822 priv->inputPicker->showDataList(inputType, optionList);
2826 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
2828 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2830 priv->inputPicker->hideDataList(inputType);
2835 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
2836 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
2838 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2840 priv->inputPicker->showColorPicker(r, g, b, a);
2844 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
2846 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2848 priv->inputPicker->hideColorPicker();
2853 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
2855 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2856 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2858 return priv->pageClient.get();
2861 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
2863 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
2864 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1);
2866 return WKPageGetTextZoomFactor(toAPI(priv->pageClient->page()));
2869 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
2871 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2872 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2874 WKPageSetTextZoomFactor(toAPI(priv->pageClient->page()), textZoomFactor);
2878 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
2879 FocusRing* ewkViewGetFocusRing(Evas_Object* ewkView)
2881 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2882 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2884 return priv->focusRing.get();
2888 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
2890 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2891 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2893 return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(priv->pageClient->page())));
2896 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
2898 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2899 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2901 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(priv->pageClient->page())));
2904 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
2906 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2907 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2909 if (!priv->javascriptGlobalContext)
2910 priv->javascriptGlobalContext = JSGlobalContextCreate(0);
2911 return priv->javascriptGlobalContext;
2914 void ewkViewLoadCommitted(Evas_Object* ewkView)
2916 #if ENABLE(TIZEN_GESTURE)
2917 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2918 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2919 priv->gestureClient->reset();
2921 #if ENABLE(TIZEN_ISF_PORT)
2922 ewk_view_imf_context_hide(ewkView);
2924 ewk_view_uri_update(ewkView);
2925 evas_object_smart_callback_call(ewkView, "load,committed", 0);
2928 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
2930 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2931 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2933 Ewk_Error* ewkError = ewkErrorCreate(error);
2934 ewkErrorLoadErrorPage(ewkError, toAPI(priv->pageClient->page()));
2935 evas_object_smart_callback_call(ewkView, "load,error", ewkError);
2936 ewkErrorDelete(ewkError);
2939 void ewkViewSetTitleAndURL(Evas_Object* ewkView, const char* title, const char* url)
2941 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2942 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2944 if (title && eina_stringshare_replace(&priv->title, title))
2945 evas_object_smart_callback_call(ewkView, "title,changed", static_cast<void*>(const_cast<char*>(priv->title)));
2946 if (url && eina_stringshare_replace(&priv->uri, url))
2947 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
2950 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
2952 #if ENABLE(TIZEN_GESTURE)
2953 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2954 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2955 priv->gestureClient->reset();
2957 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
2960 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
2962 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2963 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2965 if (priv->authChallenge)
2966 ewkAuthChallengeDelete(priv->authChallenge);
2967 priv->authChallenge = authChallenge;
2969 evas_object_smart_callback_call(ewkView, "authentication,challenge", priv->authChallenge);
2972 void ewk_view_process_crashed(Evas_Object* ewkView)
2974 bool handled = false;
2975 evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
2981 #if ENABLE(TIZEN_SQL_DATABASE)
2982 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)
2984 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, currentQuota);
2985 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, currentQuota);
2987 TIZEN_LOGI("database,quota,exceeded");
2988 uint64_t defaultQuota = ewkContextGetDatabaseQuota(priv->context);
2989 if (defaultQuota >= expectedUsage + currentQuota)
2990 return defaultQuota;
2992 if (priv->exceededDatabaseQuota)
2993 ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
2994 priv->exceededDatabaseQuota = ewkContextCreateExceededQuota(origin, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
2995 evas_object_smart_callback_call(ewkView, "database,quota,exceeded", priv->exceededDatabaseQuota);
2997 return ewkContextGetNewQuotaForExceededQuota(priv->context, priv->exceededDatabaseQuota);
3001 #if ENABLE(TIZEN_NOTIFICATIONS)
3002 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
3004 TIZEN_LOGI("notification,cancel");
3005 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
3008 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
3010 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3011 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3013 TIZEN_LOGI("notification,permission,request");
3014 priv->notificationPermissionRequests = eina_list_append(priv->notificationPermissionRequests, notificationPermissionRequest);
3015 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
3018 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
3020 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3021 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3023 TIZEN_LOGI("notification,show");
3024 Eina_List* listIterator=0;
3026 const char* replaceID = ewkNotificationGetReplaceID(notification);
3027 if(strlen(replaceID)) {
3028 EINA_LIST_FOREACH(priv->notifications, listIterator, data) {
3029 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
3030 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
3031 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
3035 priv->notifications = eina_list_append(priv->notifications, notification);
3036 evas_object_smart_callback_call(ewkView, "notification,show", notification);
3039 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
3041 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3042 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3044 priv->notificationPermissionRequests = eina_list_remove(priv->notificationPermissionRequests, ewkNotificationPermissionRequest);
3048 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
3049 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
3051 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3053 TIZEN_LOGI("protocolhandler,registration,requested");
3054 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
3055 evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
3056 ewkCustomHandlersDeleteData(customHandlersData);
3060 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
3061 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
3063 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
3065 TIZEN_LOGI("protocolhandler,isregistered");
3066 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
3067 evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
3069 Ewk_Custom_Handlers_State result;
3070 result = ewkGetCustomHandlersDataResult(customHandlersData);
3071 ewkCustomHandlersDeleteData(customHandlersData);
3076 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
3078 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3080 TIZEN_LOGI("protocolhandler,unregistration,requested");
3081 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
3082 evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
3083 ewkCustomHandlersDeleteData(customHandlersData);
3087 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
3088 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
3090 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3092 TIZEN_LOGI("contenthandler,registration,requested");
3093 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
3094 evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
3095 ewkCustomHandlersDeleteData(customHandlersData);
3098 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
3100 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
3102 TIZEN_LOGI("contenthandler,isregistered");
3103 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
3104 evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
3106 Ewk_Custom_Handlers_State result;
3107 result = ewkGetCustomHandlersDataResult(customHandlersData);
3108 ewkCustomHandlersDeleteData(customHandlersData);
3113 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
3115 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3117 TIZEN_LOGI("contenthandler,unregistration,requested");
3118 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
3119 evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
3120 ewkCustomHandlersDeleteData(customHandlersData);
3124 #if ENABLE(TIZEN_SEARCH_PROVIDER)
3125 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
3127 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3129 TIZEN_LOGI("searchProvider,add");
3130 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
3131 evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
3132 ewkSearchProviderDeleteData(searchProviderData);
3135 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
3137 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3139 TIZEN_LOGI("searchProvider,installed");
3140 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
3141 evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
3142 unsigned long result;
3143 result = ewkGetSearchProviderResult(searchProviderData);
3144 ewkSearchProviderDeleteData(searchProviderData);
3149 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3150 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
3152 bool standalone = true;
3153 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
3158 #if ENABLE(TIZEN_MEDIA_STREAM)
3159 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
3161 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3162 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3164 priv->userMediaPermissionRequests = eina_list_append(priv->userMediaPermissionRequests, userMediaPermission);
3165 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
3168 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
3170 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3171 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3173 priv->userMediaPermissionRequests = eina_list_remove(priv->userMediaPermissionRequests, permission);
3178 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
3179 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
3181 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
3182 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
3183 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
3184 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
3185 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
3186 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
3188 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
3192 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
3193 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
3195 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3196 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3197 if (priv->certificatePolicyDecision)
3198 ewkCertificatePolicyDecisionDelete(priv->certificatePolicyDecision);
3199 priv->certificatePolicyDecision = certificatePolicyDecision;
3201 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
3205 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
3207 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
3210 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
3212 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
3215 void ewkViewClosePage(Evas_Object* ewkView)
3217 evas_object_smart_callback_call(ewkView, "close,window", 0);
3220 #if ENABLE(TIZEN_GEOLOCATION)
3221 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
3223 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3224 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3226 TIZEN_LOGI("geolocation,permission,request");
3227 priv->geolocationPermissionRequests = eina_list_append(priv->geolocationPermissionRequests, geolocationPermissionRequest);
3228 evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
3231 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
3233 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3234 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3236 priv->geolocationPermissionRequests = eina_list_remove(priv->geolocationPermissionRequests, geolocationPermissionRequest);
3239 void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
3241 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3242 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3244 priv->geolocation = geolocation;
3247 Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
3249 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3250 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3252 return priv->geolocation;
3255 bool ewkViewIsValidLocationService(Evas_Object* ewkView)
3257 TIZEN_LOGI("geolocation,valid");
3260 evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
3265 WKPageRef ewkViewCreateNewPage(Evas_Object* ewkView)
3267 Evas_Object* createdEwkView = 0;
3269 evas_object_smart_callback_call(ewkView, "create,window", &createdEwkView);
3271 if (!createdEwkView)
3274 return static_cast<WKPageRef>(WKRetain(toAPI(ewk_view_page_get(createdEwkView))));
3277 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
3279 evas_object_smart_callback_call(ewkView, "form,submit", formData);
3282 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3284 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3285 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3286 if (priv->policyDecision)
3287 ewkPolicyDecisionDelete(priv->policyDecision);
3288 priv->policyDecision = policyDecision;
3290 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", priv->policyDecision);
3293 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3295 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3296 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3297 if (priv->policyDecision)
3298 ewkPolicyDecisionDelete(priv->policyDecision);
3299 priv->policyDecision = policyDecision;
3301 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", priv->policyDecision);
3304 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3306 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3307 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3308 if (priv->policyDecision)
3309 ewkPolicyDecisionDelete(priv->policyDecision);
3310 priv->policyDecision = policyDecision;
3312 evas_object_smart_callback_call(ewkView, "policy,response,decide", priv->policyDecision);
3315 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
3317 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3318 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3320 IntPoint scrollPosition = priv->pageClient->scrollPosition();
3321 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3322 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3323 contentsSize.scale(priv->pageClient->scaleFactor());
3326 // some website's contents size is smaller than view size,
3327 // so we have to adjust contents size to view size for that case.
3328 if (contentsSize.width() < smartData->view.w)
3329 contentsSize.setWidth(smartData->view.w);
3330 if (contentsSize.height() < smartData->view.h)
3331 contentsSize.setHeight(smartData->view.h);
3333 // Call "scroll,down" if webview can be scrolled down.
3334 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
3335 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
3336 // Call "scroll,up" if webview can be scrolled up.
3337 else if (deltaY < 0 && scrollPosition.y() > 0)
3338 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
3340 // Call "scroll,right" if webview can be scrolled down.
3341 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
3342 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
3343 // Call "scroll,left" if webview can be scrolled up.
3344 else if (deltaX < 0 && scrollPosition.x() > 0)
3345 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
3348 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
3350 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3351 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3353 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3354 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3355 contentsSize.scale(priv->pageClient->scaleFactor());
3358 int maxScrollY = contentsSize.height() - smartData->view.h;
3359 if (!priv->isVerticalEdge) {
3360 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
3361 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
3362 priv->isVerticalEdge = true;
3363 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
3364 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
3365 priv->isVerticalEdge = true;
3368 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
3369 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
3370 priv->isVerticalEdge = false;
3373 int maxScrollX = contentsSize.width() - smartData->view.w;
3374 if (!priv->isHorizontalEdge) {
3375 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
3376 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
3377 priv->isHorizontalEdge = true;
3378 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
3379 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
3380 priv->isHorizontalEdge = true;
3383 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
3384 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
3385 priv->isHorizontalEdge = false;
3389 void ewkViewClearEdges(Evas_Object* ewkView)
3391 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3392 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3394 priv->isVerticalEdge = false;
3395 priv->isHorizontalEdge = false;
3398 void ewk_view_top_of_contents_go(Evas_Object* ewkView)
3400 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3401 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3403 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3404 priv->pageClient->setVisibleContentRect(IntRect(IntPoint(), ewk_view_size_get(ewkView)), priv->pageClient->scaleFactor());
3406 priv->pageClient->page()->scrollMainFrameTo(IntPoint());
3410 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
3412 EWK_VIEW_SD_GET(ewkView, smartData);
3413 if (!smartData || !smartData->priv) {
3421 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
3423 *minimumScale = constraints.minimumScale;
3425 *maximumScale = constraints.maximumScale;
3428 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard)
3430 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3431 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3433 double scaleFactor = priv->pageClient->scaleFactor();
3434 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3436 double newScaleFactor = scaleFactor;
3437 // Readable zoom value is dependent on device DPI
3438 if (scaleFactor < priv->pageClient->page()->deviceScaleFactor()
3439 && priv->pageClient->viewportConstraints().userScalable)
3440 newScaleFactor = priv->pageClient->page()->deviceScaleFactor();
3442 // Readable zoom value should be inside of viewport scale range
3443 newScaleFactor = priv->pageClient->adjustScaleWithViewport(newScaleFactor);
3445 // scale contents' size with new scale factor
3446 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3447 contentsSize.scale(newScaleFactor);
3449 contentsSize.scale(newScaleFactor / scaleFactor);
3452 #if ENABLE(TIZEN_ISF_PORT)
3453 Ecore_X_Window rootWin = ecore_x_window_root_first_get();
3454 ecore_x_event_mask_set(rootWin, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
3455 Ecore_X_Atom xAtom = ecore_x_atom_get("X External Keyboard Exist");
3456 unsigned int connectedKeyboardNum = 0;
3457 bool isExternalKeyboardConnected = false;
3459 // get connected keyboard number
3460 if (ecore_x_window_prop_card32_get(rootWin, xAtom, &connectedKeyboardNum, 1)
3461 && connectedKeyboardNum)
3462 isExternalKeyboardConnected = true;
3464 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
3465 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
3466 // input field zoom should not work with below conditions
3467 // 1. view is not focused
3468 // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
3469 // 3. imfContext is null(if adjustForExternalKeyboard is false)
3470 // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
3471 if ((!(static_cast<PageClient*>(priv->pageClient.get()))->isViewFocused()
3472 || (adjustForExternalKeyboard && !isExternalKeyboardConnected)
3473 || (!adjustForExternalKeyboard && !priv->imfContext)
3474 || (!adjustForExternalKeyboard && ecore_imf_context_input_panel_state_get(priv->imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE))
3475 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
3476 && !(priv->pageClient->isClipboardWindowOpened())
3482 IntSize visibleSize(smartData->view.w, smartData->view.h);
3483 // caret position can be outside of visible rect.
3484 // we need to consider it.
3485 IntRect selectionRect = priv->pageClient->page()->getSelectionRect(true);
3486 IntRect focusedNodeRect = priv->pageClient->focusedNodeRect();
3487 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3488 selectionRect.scale(newScaleFactor);
3489 focusedNodeRect.scale(newScaleFactor);
3491 selectionRect.scale(newScaleFactor / scaleFactor);
3492 focusedNodeRect.scale(newScaleFactor / scaleFactor);
3494 if (selectionRect.isEmpty())
3498 IntPoint scrollPosition(selectionRect.x() - visibleSize.width() / 3, selectionRect.y() - visibleSize.height() / 3);
3499 // If both input field's position x and selection rect can be displayed together,
3500 // adjust scroll position to input field's position x.
3501 if (!focusedNodeRect.isEmpty()
3502 && selectionRect.x() - focusedNodeRect.x() < visibleSize.width() * 4 / 5)
3503 scrollPosition.setX(focusedNodeRect.x());
3505 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3506 priv->pageClient->setVisibleContentRect(IntRect(scrollPosition, ewk_view_size_get(ewkView)), newScaleFactor);
3508 if (newScaleFactor != scaleFactor)
3509 priv->pageClient->page()->scalePage(newScaleFactor, scrollPosition);
3511 priv->pageClient->page()->scrollMainFrameTo(scrollPosition);
3513 evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
3517 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
3518 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
3519 static Eina_Bool _ewk_view_composite(void* data)
3521 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
3522 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
3524 if (!evas_object_visible_get(smartData->image))
3525 return ECORE_CALLBACK_CANCEL;
3528 evas_object_image_size_get(smartData->image, &ow, &oh);
3529 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
3531 RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_ARGB32, ow, oh, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, ow)));
3532 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
3534 cairo_save(context.get());
3535 cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
3536 cairo_rectangle(context.get(), 0, 0, ow, oh);
3537 cairo_fill(context.get());
3538 cairo_restore(context.get());
3540 priv->pageClient->drawContents(context.get());
3542 evas_object_image_data_set(smartData->image, pixels);
3543 evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
3545 ewkViewFrameRendered(smartData->self);
3547 priv->compositionAnimator = 0;
3549 return ECORE_CALLBACK_CANCEL;
3553 void ewk_view_mark_for_sync(Evas_Object* ewkView)
3555 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3556 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
3558 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
3559 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3561 if (!ewk_view_is_opengl_backend(ewkView)) {
3562 if (!priv->compositionAnimator)
3563 priv->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
3568 evas_object_image_pixels_dirty_set(smartData->image, true);
3571 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
3573 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
3574 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3575 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3576 priv->pageClient->drawContents();
3579 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
3581 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3582 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3584 if (!smartData->image)
3587 evas_object_image_native_surface_set(smartData->image, nativeSurface);
3588 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
3594 void _ewk_view_suspend_painting(Evas_Object* ewkView)
3596 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3597 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3599 if (!priv->suspendedPainting) {
3600 priv->pageClient->page()->suspendPainting();
3601 priv->suspendedPainting = true;
3605 void _ewk_view_resume_painting(Evas_Object* ewkView)
3607 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3608 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3610 if (priv->suspendedPainting) {
3611 priv->pageClient->page()->resumePainting();
3612 priv->suspendedPainting = false;
3616 void ewk_view_suspend(Evas_Object* ewkView)
3618 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3619 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3621 if (priv->pageClient->page()->estimatedProgress() < 1.0) {
3622 priv->suspendRequested = true;
3625 priv->suspendRequested = false;
3627 _ewk_view_suspend_painting(ewkView);
3629 // FIXME Workaround for suspend/resume while javascript popup is displayed.
3630 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
3631 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
3633 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
3634 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
3635 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
3636 // will be suspended again.
3637 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
3638 // the ActiveDOMObject.
3639 if (!priv->suspendedResources && !priv->isWaitingForJavaScriptPopupReply) {
3640 priv->pageClient->page()->suspendJavaScriptAndResource();
3641 priv->suspendedResources = true;
3644 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
3645 priv->pageClient->page()->suspendPlugin();
3649 void ewk_view_resume(Evas_Object* ewkView)
3651 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3652 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3654 if (priv->suspendRequested) {
3655 priv->suspendRequested = false;
3659 _ewk_view_resume_painting(ewkView);
3661 // FIXME Workaround for suspend/resume while javascript popup is displayed.
3662 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
3663 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
3665 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
3666 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
3667 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
3668 // will be suspended again.
3669 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
3670 // the ActiveDOMObject.
3671 if (priv->suspendedResources && !priv->isWaitingForJavaScriptPopupReply) {
3672 priv->pageClient->page()->resumeJavaScriptAndResource();
3673 priv->suspendedResources = false;
3676 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
3677 priv->pageClient->page()->resumePlugin();
3681 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
3683 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3684 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3685 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
3687 ResourceRequest request(String::fromUTF8(url));
3690 case EWK_HTTP_METHOD_GET:
3691 request.setHTTPMethod("GET");
3693 case EWK_HTTP_METHOD_HEAD:
3694 request.setHTTPMethod("HEAD");
3696 case EWK_HTTP_METHOD_POST:
3697 request.setHTTPMethod("POST");
3699 case EWK_HTTP_METHOD_PUT:
3700 request.setHTTPMethod("PUT");
3702 case EWK_HTTP_METHOD_DELETE:
3703 request.setHTTPMethod("DELETE");
3710 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
3712 while (eina_iterator_next(it, &data)) {
3713 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
3714 const char* name = static_cast<const char*>(t->key);
3715 const char* value = static_cast<const char*>(t->data);
3716 request.addHTTPHeaderField(name, value);
3718 eina_iterator_free(it);
3722 request.setHTTPBody(FormData::create(body));
3724 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
3725 WKPageLoadURLRequest(toAPI(priv->pageClient->page()), urlRequest.get());
3730 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
3732 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3733 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3735 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
3736 WKPageLoadPlainTextString(toAPI(priv->pageClient->page()), plainTextRef.get());
3741 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
3743 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3744 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3745 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
3747 if (contentsSize == 0)
3750 String mimeTypeString;
3752 mimeTypeString = String::fromUTF8(mimeType);
3754 mimeTypeString = String::fromUTF8("text/html");
3756 String encodingString;
3758 encodingString = String::fromUTF8(encoding);
3760 encodingString = String::fromUTF8("UTF-8");
3762 String baseUriString;
3764 baseUriString = String::fromUTF8(baseUri);
3766 baseUriString = String::fromUTF8("about:blank");
3768 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
3769 priv->pageClient->page()->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
3774 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
3776 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3777 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3779 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
3780 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
3782 WKPageLoadHTMLString(toAPI(priv->pageClient->page()), htmlString.get(), baseURL.get());
3787 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
3789 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3790 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3792 TIZEN_LOGI("initialState (%d)", initialState);
3793 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
3794 WKPageSetPageVisibility(toAPI(priv->pageClient->page()), static_cast<WKPageVisibilityState
3795 >(pageVisibilityState), initialState);
3803 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
3805 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
3807 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3808 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3810 eina_stringshare_replace(&priv->userAgent, userAgent);
3812 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
3813 WKPageSetCustomUserAgent(toAPI(priv->pageClient->page()), userAgentString.get());
3818 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
3820 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3821 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3823 if (!priv->userAgent) {
3824 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(priv->pageClient->page())));
3826 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
3827 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3828 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
3829 eina_stringshare_replace(&priv->userAgent, buffer.get());
3832 return priv->userAgent;
3834 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
3836 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3837 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3838 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3840 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
3841 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
3843 WKPageAddCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get(), customHeaderValue.get());
3846 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3851 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
3853 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3854 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3855 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3857 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
3859 WKPageRemoveCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get());
3862 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3867 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
3869 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3870 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3871 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3873 WKPageClearCustomHeaders(toAPI(priv->pageClient->page()));
3876 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3881 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
3882 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
3884 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3885 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3887 priv->pageClient->setIsVisible(enable);
3892 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
3894 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
3896 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3897 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3900 rect.origin.x = viewArea.x;
3901 rect.origin.y = viewArea.y;
3902 rect.size.width = viewArea.w;
3903 rect.size.height = viewArea.h;
3905 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(priv->pageClient->page()), rect, scaleFactor));
3906 if (!snapshot.get())
3909 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
3911 Evas_Object* screenshotImage = evas_object_image_add(canvas);
3912 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
3913 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
3914 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
3915 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
3917 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
3919 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)));
3920 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
3922 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
3923 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
3924 cairo_fill(cairo.get());
3926 evas_object_image_smooth_scale_set(screenshotImage, true);
3927 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
3928 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
3929 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
3930 evas_object_image_data_set(screenshotImage, pixels);
3932 return screenshotImage;
3935 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
3937 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
3938 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
3939 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, 0);
3941 return priv->pageClient->page()->startInspectorServer(port);
3943 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
3948 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
3950 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
3951 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
3952 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
3954 return priv->pageClient->page()->stopInspectorServer();
3956 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
3961 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
3963 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3964 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3966 WKPageScrollBy(toAPI(priv->pageClient->page()), toAPI(IntSize(deltaX, deltaY)));
3969 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
3975 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3976 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3978 IntPoint scrollPosition = priv->pageClient->scrollPosition();
3980 *x = scrollPosition.x();
3982 *y = scrollPosition.y();
3987 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
3989 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3990 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3992 priv->pageClient->page()->scrollMainFrameTo(IntPoint(x, y));
3996 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
4002 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4003 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4005 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4006 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
4007 contentsSize.scale(priv->pageClient->scaleFactor());
4010 if (width && contentsSize.width() > smartData->view.w)
4011 *width = contentsSize.width() - smartData->view.w;
4012 if (height && contentsSize.height() > smartData->view.h)
4013 *height = contentsSize.height() - smartData->view.h;
4017 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
4019 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4020 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4021 if (!priv->alertContext || !priv->alertContext->javascriptAlertCallback)
4023 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->alertContext->ewkView == ewkView, false);
4025 priv->isWaitingForJavaScriptPopupReply = true;
4026 int length = WKStringGetMaximumUTF8CStringSize(alertText);
4027 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
4028 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
4029 return priv->alertContext->javascriptAlertCallback(priv->alertContext->ewkView, alertTextBuffer.get(), priv->alertContext->userData) == EINA_TRUE;
4032 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
4034 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4035 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4036 if (!priv->confirmContext || !priv->confirmContext->javascriptConfirmCallback)
4038 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->confirmContext->ewkView == ewkView, false);
4040 priv->isWaitingForJavaScriptPopupReply = true;
4041 int length = WKStringGetMaximumUTF8CStringSize(message);
4042 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4043 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4044 return priv->confirmContext->javascriptConfirmCallback(priv->confirmContext->ewkView, messageBuffer.get(), priv->confirmContext->userData) == EINA_TRUE;
4047 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
4049 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4050 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4051 if (!priv->promptContext || !priv->promptContext->javascriptPromptCallback)
4053 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->promptContext->ewkView == ewkView, false);
4055 priv->isWaitingForJavaScriptPopupReply = true;
4056 int length = WKStringGetMaximumUTF8CStringSize(message);
4057 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4058 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4059 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
4060 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
4061 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
4062 return priv->promptContext->javascriptPromptCallback(priv->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), priv->promptContext->userData) == EINA_TRUE;
4065 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
4066 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
4068 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4069 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4070 if (!priv->beforeUnloadConfirmPanelContext || !priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
4072 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
4074 priv->isWaitingForJavaScriptPopupReply = true;
4075 int length = WKStringGetMaximumUTF8CStringSize(message);
4076 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4077 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4078 bool result = priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(priv->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), priv->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
4083 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
4085 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4086 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4087 if (!priv->openpanelContext || !priv->openpanelContext->openPanelCallback)
4090 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->openpanelContext->ewkView == ewkView, false);
4092 priv->openPanelListener = listener;
4094 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
4095 Eina_List* acceptedMimeTypes = 0;
4096 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
4097 size_t len = WKArrayGetSize(array.get());
4098 for (size_t i = 0; i < len; i++) {
4099 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
4100 if (WKGetTypeID(item) != WKStringGetTypeID())
4102 WKStringRef mime = static_cast<WKStringRef>(item);
4103 int length = WKStringGetMaximumUTF8CStringSize(mime);
4104 char* buffer = new char[length];
4105 WKStringGetUTF8CString(mime, buffer, length);
4106 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
4108 const char* capture = 0;
4109 #if ENABLE(MEDIA_CAPTURE)
4110 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
4111 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
4113 bool result = priv->openpanelContext->openPanelCallback(priv->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
4114 if (!acceptedMimeTypes)
4119 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
4120 delete[] (char*)data;
4121 eina_list_free(acceptedMimeTypes);
4125 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
4127 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4128 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4130 if (!priv->alertContext)
4131 priv->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4132 priv->alertContext->javascriptAlertCallback = callback;
4133 priv->alertContext->ewkView = ewkView;
4134 priv->alertContext->userData = userData;
4137 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
4139 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4140 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4142 WKPageReplyJavaScriptAlert(toAPI(ewk_view_page_get(ewkView)));
4143 priv->isWaitingForJavaScriptPopupReply = false;
4146 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
4148 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4149 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4151 if (!priv->confirmContext)
4152 priv->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4153 priv->confirmContext->javascriptConfirmCallback = callback;
4154 priv->confirmContext->ewkView = ewkView;
4155 priv->confirmContext->userData = userData;
4158 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
4160 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4161 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4163 WKPageReplyJavaScriptConfirm(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
4164 priv->isWaitingForJavaScriptPopupReply = false;
4167 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
4169 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4170 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4172 if (!priv->promptContext)
4173 priv->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4174 priv->promptContext->javascriptPromptCallback = callback;
4175 priv->promptContext->ewkView = ewkView;
4176 priv->promptContext->userData = userData;
4179 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
4181 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4182 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4184 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
4185 WKPageReplyJavaScriptPrompt(toAPI(ewk_view_page_get(ewkView)), result ? resultString.get() : 0);
4186 priv->isWaitingForJavaScriptPopupReply = false;
4189 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
4190 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
4192 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4193 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4195 if (!priv->beforeUnloadConfirmPanelContext)
4196 priv->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4197 priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
4198 priv->beforeUnloadConfirmPanelContext->ewkView = ewkView;
4199 priv->beforeUnloadConfirmPanelContext->userData = userData;
4202 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
4204 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4205 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4207 WKPageReplyBeforeUnloadConfirmPanel(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
4208 priv->isWaitingForJavaScriptPopupReply = false;
4212 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
4214 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4215 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4217 if (!priv->openpanelContext)
4218 priv->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4220 priv->openpanelContext->openPanelCallback = callback;
4221 priv->openpanelContext->ewkView = ewkView;
4222 priv->openpanelContext->userData = userData;
4225 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
4227 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4228 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4230 if (!priv->openPanelListener)
4233 unsigned int size = eina_list_count(fileUrls);
4234 if ((result == EINA_FALSE) || (size == 0)) {
4235 WKOpenPanelResultListenerCancel(priv->openPanelListener);
4236 priv->openPanelListener = 0;
4240 WKTypeRef* items = new WKTypeRef[size];
4244 KURL base(KURL(), "file://");
4245 EINA_LIST_FOREACH(fileUrls, list, data) {
4246 KURL url(base, static_cast<char*>(data));
4247 items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
4249 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
4250 WKOpenPanelResultListenerChooseFiles(priv->openPanelListener, filesArray.get());
4251 priv->openPanelListener = 0;
4253 eina_list_free(fileUrls);
4256 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4257 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
4259 EINA_SAFETY_ON_NULL_RETURN(capable);
4260 EINA_SAFETY_ON_NULL_RETURN(context);
4262 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4264 ASSERT(webAppContext->webAppCapableCallback);
4267 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
4269 webAppContext->webAppCapableCallback(0, webAppContext->userData);
4271 delete webAppContext;
4274 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
4276 EINA_SAFETY_ON_NULL_RETURN(iconURL);
4277 EINA_SAFETY_ON_NULL_RETURN(context);
4279 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4281 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
4282 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4284 ASSERT(webAppContext->webAppIconURLCallback);
4287 eina_stringshare_replace(&priv->webAppIconURL, toImpl(iconURL)->string().utf8().data());
4288 webAppContext->webAppIconURLCallback(priv->webAppIconURL, webAppContext->userData);
4290 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
4292 delete webAppContext;
4296 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
4298 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4299 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4300 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4301 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4303 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4304 context->webAppCapableCallback = callback;
4305 context->ewkView = ewkView;
4306 context->userData = userData;
4308 WKPageGetWebAppCapable(toAPI(priv->pageClient->page()), context, didGetWebAppCapable);
4316 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
4318 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4319 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4320 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4321 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4323 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4324 context->webAppIconURLCallback = callback;
4325 context->ewkView = ewkView;
4326 context->userData = userData;
4328 WKPageGetWebAppIconURL(toAPI(priv->pageClient->page()), context, didGetWebAppIconURL);
4336 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
4338 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4339 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4340 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
4342 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
4343 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
4344 WKPageExecuteCommandWithArgument(toAPI(priv->pageClient->page()), commandString.get(), valueString.get());
4349 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4351 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4352 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4353 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4355 // FixMe: Comment should be removed when pageClient is removed.
4356 //priv->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4357 priv->pageClient->page()->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4362 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4364 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4365 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4367 // FixMe: Comment should be removed when pageClient is removed.
4368 //priv->pageProxy->hideFindUI();
4369 priv->pageClient->page()->hideFindUI();
4374 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
4381 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4382 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4384 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4387 *width = contentsSize.width();
4389 *height = contentsSize.height();
4394 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
4396 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
4397 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4398 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4399 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
4401 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4402 WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
4410 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, int width, int height, const char* fileName)
4412 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
4413 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4414 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4415 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
4417 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4418 WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
4426 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
4428 EINA_SAFETY_ON_NULL_RETURN(context);
4429 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4431 if (!callbackContext->scriptExecuteCallback) {
4432 delete callbackContext;
4436 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
4439 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
4440 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
4441 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
4442 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
4443 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
4444 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
4446 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
4448 delete callbackContext;
4451 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
4453 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4454 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4455 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
4456 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient, false);
4458 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4459 context->scriptExecuteCallback = callback;
4460 context->ewkView = ewkView;
4461 context->userData = user_data;
4462 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
4463 WKPageRunJavaScriptInMainFrame(toAPI(priv->pageClient->page()), scriptString.get(), context, runJavaScriptCallback);
4468 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
4469 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
4471 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
4474 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
4476 storageContext->webStorageQuotaCallback(0, storageContext->userData);
4478 delete storageContext;
4482 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
4484 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
4485 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
4486 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
4487 TIZEN_LOGI("resultCallback (%p)", resultCallback);
4489 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4490 context->webStorageQuotaCallback = resultCallback;
4491 context->userData = userData;
4493 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
4494 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
4502 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
4504 #if ENABLE(TIZEN_WEB_STORAGE)
4505 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
4507 TIZEN_LOGI("quota (%d)", quota);
4508 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
4509 WKPageSetWebStorageQuota(pageRef, quota);
4517 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
4519 EINA_SAFETY_ON_NULL_RETURN(context);
4520 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4522 ASSERT(callbackContext->plainTextGetCallback);
4525 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
4526 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
4527 WKStringGetUTF8CString(plain_text, buffer.get(), length);
4529 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
4531 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
4533 delete callbackContext;
4536 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
4538 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4539 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4540 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4541 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient, false);
4543 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4544 context->plainTextGetCallback = callback;
4545 context->ewkView = ewkView;
4546 context->userData = user_data;
4547 WKPageGetContentsAsString(toAPI(priv->pageClient->page()), context, getContentsAsStringCallback);
4552 #if ENABLE(TIZEN_SUPPORT_MHTML)
4555 * Callback function used for ewk_view_mhtml_data_get().
4557 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4559 EINA_SAFETY_ON_NULL_RETURN(context);
4560 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4562 ASSERT(callbackContext->mhtmlDataGetCallback);
4564 callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
4566 delete callbackContext;
4569 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
4571 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4572 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4573 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4575 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4576 context->mhtmlDataGetCallback = callback;
4577 context->ewkView = ewkView;
4578 context->userData = user_data;
4580 WKPageGetContentsAsMHTMLData(toAPI(priv->pageClient->page()), false, context, getContentsAsMHTMLCallback);
4584 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
4586 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
4588 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
4589 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4590 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4591 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, 0);
4593 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
4594 WebHitTestResult::Data hitTestResultData = priv->pageClient->page()->hitTestResultAtPoint(pointForHitTest, hitTestMode);
4595 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
4603 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
4605 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
4606 WebPageProxy* page = ewk_view_page_get(ewkView);
4607 EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
4609 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
4612 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
4614 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4615 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4617 WKPageRecordingSurfaceSetEnable(toAPI(priv->pageClient->page()), enable);
4622 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
4624 #if ENABLE(TIZEN_NOTIFICATIONS)
4625 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4626 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4627 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->context, false);
4629 TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
4630 if (!eina_list_count(ewkNotifications))
4633 Eina_List* listIterator = 0;
4635 Vector<WKTypeRef> ids;
4636 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
4637 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
4638 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
4640 priv->notifications = eina_list_remove(priv->notifications, notification);
4643 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
4644 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(ewk_context_WKContext_get(priv->context));
4645 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
4646 ewkNotificationDeleteNotificationList(ewkNotifications);
4654 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
4656 Eina_List* popupItems = 0;
4657 size_t size = items.size();
4658 for (size_t i = 0; i < size; ++i) {
4659 Ewk_Popup_Menu_Item* item = ewk_popup_menu_item_new(items[i].m_type,
4660 items[i].m_text.utf8().data(),
4661 items[i].m_textDirection,
4662 items[i].m_hasTextDirectionOverride,
4663 items[i].m_toolTip.utf8().data(),
4664 items[i].m_accessibilityText.utf8().data(),
4665 items[i].m_isEnabled,
4666 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4667 items[i].m_isSelected,
4669 items[i].m_isLabel);
4670 popupItems = eina_list_append(popupItems, item);
4672 TIZEN_LOGI("size : %d", size);
4676 static void releasePopupMenuList(Eina_List* popupMenuItems)
4678 if (!popupMenuItems)
4682 EINA_LIST_FREE(popupMenuItems, item)
4683 ewk_popup_menu_item_free(static_cast<Ewk_Popup_Menu_Item*>(item));
4686 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4687 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)
4689 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)
4692 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4693 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4694 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4695 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4699 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4700 if (!smartData->api->popup_menu_show && !smartData->api->multiple_popup_menu_show)
4702 if (!smartData->api->popup_menu_show)
4706 if (priv->popupMenuProxy)
4707 ewk_view_popup_menu_close(ewkView);
4708 priv->popupMenuProxy = popupMenu;
4710 priv->popupMenuItems = createPopupMenuList(items);
4712 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4713 if ((!multiple && smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems, selectedIndex)) ||
4714 (multiple && smartData->api->multiple_popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems))) {
4716 if (smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems, selectedIndex)) {
4718 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
4719 /* maps.google.com generate mouse event in touch down without preventDefault.
4720 * So, popup menu is opend in touch down event and closed via fake mouse down
4721 * which generated by endTap.
4722 * In order to fix select of maps.google.com (based on touch behavior),
4723 * We should disable touch events when select popup is open.
4726 #if ENABLE(TIZEN_GESTURE)
4727 priv->gestureClient->reset();
4729 ewk_view_touch_events_enabled_set(ewkView, false);
4734 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
4736 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4737 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4738 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4739 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4741 if (!priv->popupMenuProxy)
4744 priv->popupMenuProxy = 0;
4746 if (smartData->api->popup_menu_hide)
4747 smartData->api->popup_menu_hide(smartData);
4748 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
4749 ewk_view_touch_events_enabled_set(ewkView, true);
4752 releasePopupMenuList(priv->popupMenuItems);
4753 priv->popupMenuItems = 0;
4758 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
4760 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4761 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4762 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4763 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4765 if (!priv->popupMenuProxy)
4768 if (!smartData->api->popup_menu_update)
4771 releasePopupMenuList(priv->popupMenuItems);
4772 priv->popupMenuItems = createPopupMenuList(items);
4774 // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
4775 smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), priv->popupMenuItems, selectedIndex);
4778 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
4780 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4781 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4782 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
4783 TIZEN_LOGI("proxy : %p / index : %d", priv->popupMenuProxy, selectedIndex);
4785 if (!priv->popupMenuItems)
4788 if (selectedIndex >= eina_list_count(priv->popupMenuItems))
4791 priv->popupMenuProxy->valueChanged(selectedIndex);
4796 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4797 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
4799 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4800 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4801 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
4803 Vector<int> selectedIndex;
4805 if (!priv->popupMenuItems)
4810 itr = eina_inarray_iterator_new(changeList);
4811 EINA_ITERATOR_FOREACH(itr, data)
4813 int* pData = static_cast<int*>(data);
4814 selectedIndex.append(*pData);
4816 eina_iterator_free(itr);
4818 priv->popupMenuProxy->multipleValueChanged(selectedIndex);
4823 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
4825 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
4826 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4827 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4828 TIZEN_LOGI("orientation : %d", orientation);
4830 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
4833 if (priv->orientation == orientation)
4836 priv->orientation = orientation;
4838 priv->pageClient->page()->sendOrientationChangeEvent(orientation);
4842 void ewkViewFrameRendered(Evas_Object* ewkView)
4844 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
4847 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4848 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
4850 return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
4853 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
4855 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4856 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4857 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
4859 IntRect leftSelectionRect;
4860 IntRect rightSelectionRect;
4861 if (!priv->pageClient->page()->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
4874 AffineTransform contentToScreen = impl->transformToScene();
4875 leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
4876 rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
4878 leftRect->x = leftSelectionRect.x();
4879 leftRect->y = leftSelectionRect.y();
4880 leftRect->w = leftSelectionRect.width();
4881 leftRect->h = leftSelectionRect.height();
4883 rightRect->x = rightSelectionRect.x();
4884 rightRect->y = rightSelectionRect.y();
4885 rightRect->w = rightSelectionRect.width();
4886 rightRect->h = rightSelectionRect.height();
4891 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
4893 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4894 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4896 const CString selectedString = priv->pageClient->page()->getSelectionText().utf8();
4897 eina_stringshare_replace(&priv->selectedText, selectedString.data());
4899 return priv->selectedText;
4902 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
4904 return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
4907 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
4909 return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
4911 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4913 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4914 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
4916 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4917 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4918 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
4920 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
4924 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
4925 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
4927 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4928 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4929 IntPoint drawingPosition = (IntPoint)(priv->pageClient->visibleContentRect().location() - priv->pageClient->scrollPosition());
4931 *x = drawingPosition.x();
4933 *y = drawingPosition.y();
4935 *w = priv->pageClient->visibleContentRect().width();
4937 *h = priv->pageClient->visibleContentRect().height();
4941 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
4943 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4944 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4945 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4947 priv->pageClient->page()->setFocusedInputElementValue(String::fromUTF8(value));
4948 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4951 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
4953 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4954 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4955 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4957 eina_stringshare_replace(&priv->inputValue, priv->pageClient->page()->getFocusedInputElementValue().utf8().data());
4958 return priv->inputValue;
4961 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4964 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4965 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
4967 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4968 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4969 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4970 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
4973 ewkViewDataListHideRequest(ewkView, inputType);
4975 for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
4977 priv->dataList = eina_list_append(priv->dataList, eina_stringshare_add(value.utf8().data()));
4980 smartData->api->data_list_show(smartData, inputType, priv->dataList);
4983 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
4985 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4986 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4987 EINA_SAFETY_ON_NULL_RETURN(priv->dataList);
4988 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4989 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
4991 if (priv->dataList) {
4992 _ewk_view_data_list_del(priv->dataList);
4996 smartData->api->data_list_hide(smartData, inputType);
5000 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
5002 #if ENABLE(TIZEN_DATALIST_ELEMENT)
5003 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5004 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5006 if (priv->dataList) {
5007 _ewk_view_data_list_del(priv->dataList);
5011 ewk_view_focused_input_element_value_set(ewkView, value);
5015 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
5017 #if ENABLE(TIZEN_GESTURE)
5018 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
5019 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
5020 return priv->holdHorizontalPanning;
5026 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
5028 #if ENABLE(TIZEN_GESTURE)
5029 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5030 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5031 priv->holdHorizontalPanning = hold;
5035 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
5037 #if ENABLE(TIZEN_GESTURE)
5038 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
5039 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
5040 return priv->holdVerticalPanning;
5046 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
5048 #if ENABLE(TIZEN_GESTURE)
5049 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5050 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5051 priv->holdVerticalPanning = hold;
5055 void ewk_view_use_smart_selection_set(Evas_Object* ewkView, Eina_Bool use)
5057 #if ENABLE(TIZEN_GESTURE)
5058 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5059 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5060 priv->useSmartSelection = use;
5064 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
5066 #if ENABLE(TIZEN_GESTURE)
5067 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5068 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5070 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5071 if (priv->focusRing && wasHandled)
5072 priv->focusRing->hide();
5073 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5075 if (priv->areMouseEventsEnabled)
5078 // We have to check TouchStart, TouchMove and TouchEnd with handled.
5079 // The Pan and Flick will be enabled if Touch Start was not handled,
5080 // and Touch Move was not handled or did not occur.
5081 // Tap will be enabled if Touch Start and End was not handled
5082 // and Touch Move did not occur.
5083 // The gestures are disabled as a default.
5084 // o: handled, x: not handled
5085 // ------------------------------------------------------------
5086 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
5087 // ------------------------------------------------------------
5088 // o | o or x | o or x || disable | disable
5089 // x | o | o or x || disable | disable
5090 // x | x | o or x || disable | enable
5091 // x |not occured | x || enable | enable
5092 // ------------------------------------------------------------
5093 if (type == WebEvent::TouchStart) {
5094 priv->gestureClient->setGestureEnabled(!wasHandled);
5095 priv->wasHandledTouchStart = wasHandled;
5097 // Initialize wasHandledTouchMove to true and notify that to the application
5098 // to prevent applications scrolling at the beginning of touch.
5099 priv->wasHandledTouchMove = true;
5100 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&priv->wasHandledTouchMove));
5101 } else if (type == WebEvent::TouchMove) {
5102 priv->gestureClient->setMovingEnabled(!wasHandled);
5104 // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
5105 if (priv->wasHandledTouchStart)
5108 // Notify the result of touchmove to applications when handled value is changed
5109 // in order to make applications to choose whether scrolling its scrollable objects or not.
5110 if (priv->wasHandledTouchMove != wasHandled)
5111 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
5112 priv->wasHandledTouchMove = wasHandled;
5113 } else if (type == WebEvent::TouchEnd && !priv->exceedTouchMoveThreshold && !wasHandled) {
5114 priv->gestureClient->setMovingEnabled(!wasHandled);
5115 priv->gestureClient->setTapEnabled(!wasHandled);
5120 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
5121 void ewkViewDidGetTextStyleStateForSelection(Evas_Object* ewkView, int underlineState, int italicState, int boldState, const IntPoint& startPoint, const IntPoint& endPoint)
5123 Ewk_Text_Style* textStyle = ewkTextStyleCreate(underlineState, italicState, boldState, startPoint, endPoint);
5124 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
5125 ewkTextStyleDelete(textStyle);
5129 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
5130 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
5132 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5133 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
5135 TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
5136 if (!smartData->api->orientation_lock) {
5141 return smartData->api->orientation_lock(smartData, willLockOrientation);
5144 void ewk_view_orientation_unlock(Evas_Object* ewkView)
5146 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5147 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
5149 TIZEN_LOGI("ewkView (%p)", ewkView);
5150 if (!smartData->api->orientation_unlock) {
5155 smartData->api->orientation_unlock(smartData);
5159 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
5161 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
5162 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5163 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5164 TIZEN_LOGI("callbacks: %p / data: %p", func, data);
5166 priv->orientationLock.callback = func;
5167 priv->orientationLock.data = data;
5171 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
5172 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
5174 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
5175 TIZEN_LOGI("locked orientations : %d", orientations);
5177 if (priv->orientationLock.callback)
5178 return priv->orientationLock.callback(sd->self, true, orientations, priv->orientationLock.data);
5183 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
5185 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
5186 TIZEN_LOGI("unlock is requested");
5188 if (priv->orientationLock.callback)
5189 priv->orientationLock.callback(sd->self, false, 0, priv->orientationLock.data);
5193 void ewk_view_fullscreen_enter(Evas_Object* ewkView)
5195 TIZEN_LOGI("fullscreen,enterfullscreen");
5196 ewk_view_main_frame_scrollbar_visible_set(ewkView, false);
5197 evas_object_smart_callback_call(ewkView, "fullscreen,enterfullscreen", 0);
5200 void ewk_view_fullscreen_exit(Evas_Object* ewkView)
5202 TIZEN_LOGI("fullscreen,exitfullscreen");
5203 ewk_view_main_frame_scrollbar_visible_set(ewkView, true);
5204 evas_object_smart_callback_call(ewkView, "fullscreen,exitfullscreen", 0);
5207 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
5208 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
5210 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5212 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
5213 const char *engine = ecore_evas_engine_name_get(ee);
5214 if (engine && !strcmp(engine, "opengl_x11"))
5220 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
5222 #if ENABLE(TIZEN_GESTURE)
5223 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5224 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5226 priv->gestureClient->setZoomableArea(target, area);
5230 #if ENABLE(TIZEN_ISF_PORT)
5231 static void imfInputPanelStateEventCb(void* data, Ecore_IMF_Context* ctx, int state)
5233 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5234 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5236 if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
5237 evas_object_smart_callback_call(smartData->self, "editorclient,ime,closed", 0);
5238 LOG(ISF, "[SIGNAL] editorclient,ime,closed\n");
5239 } else if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
5240 evas_object_smart_callback_call(smartData->self, "editorclient,ime,opened", 0);
5241 LOG(ISF, "[SIGNAL] editorclient,ime,opened\n");
5245 static void imfInputPanelGeometryEventCb(void* data, Ecore_IMF_Context* ctx, int value)
5247 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5248 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5250 Eina_Rectangle rect;
5251 ecore_imf_context_input_panel_geometry_get(priv->imfContext, &rect.x, &rect.y, &rect.w, &rect.h);
5252 evas_object_smart_callback_call(smartData->self, "inputmethod,changed", &rect);
5253 LOG(ISF, "%s : [SIGNAL] inputmethod,changed (%d,%d,%d,%d)\n", __func__, rect.x, rect.y, rect.w, rect.h);
5256 static void imfCandidatePanelStateEventCb(void* data, Ecore_IMF_Context* ctx, int state)
5258 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5259 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5261 if (state == ECORE_IMF_CANDIDATE_PANEL_SHOW)
5262 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,opened", 0);
5264 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,closed", 0);
5267 static void imfCandidatePanelGeometryEventCb(void* data, Ecore_IMF_Context* ctx, int value)
5269 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5270 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5272 Eina_Rectangle rect;
5273 ecore_imf_context_candidate_panel_geometry_get(priv->imfContext, &rect.x, &rect.y, &rect.w, &rect.h);
5274 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,changed", &rect);
5277 static Eina_Bool imfRetrieveSurroundingCb(void* data, Ecore_IMF_Context* context, char** text, int* offset)
5279 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5280 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5282 if (!priv->pageClient->page()->focusedFrame() || (!text && !offset))
5285 String surroundingText;
5287 priv->pageClient->page()->getSurroundingTextAndCursorOffset(surroundingText, cursorOffset);
5290 CString utf8Text(surroundingText.utf8());
5291 size_t length = utf8Text.length();
5293 *text = static_cast<char*>(malloc((length + 1) * sizeof(char)));
5298 strncpy(*text, utf8Text.data(), length);
5299 (*text)[length] = 0;
5303 *offset = cursorOffset;
5308 static void imfPreeditChangedCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5310 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5311 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5313 priv->pageClient->imContextPreeditChanged(context);
5316 static void imfEventCommittedCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5318 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5319 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5321 priv->pageClient->imContextCommitted(context, static_cast<char*>(eventInfo));
5324 static void imfContextDeleteSurroundingCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5326 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5327 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5329 Ecore_IMF_Event_Delete_Surrounding* event = static_cast<Ecore_IMF_Event_Delete_Surrounding*>(eventInfo);
5333 priv->pageClient->page()->deleteSurroundingText(event->offset, event->n_chars);
5336 Ecore_IMF_Context* ewk_view_imf_context_get(Evas_Object* ewkView)
5338 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5339 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5341 return priv->imfContext;
5344 Ecore_IMF_Context* ewk_view_imf_context_set(Evas_Object* ewkView, Ecore_IMF_Input_Panel_Layout layout)
5346 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5347 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5349 Ecore_IMF_Context* imfContext;
5350 Eina_List* iterator;
5353 EINA_LIST_FOREACH(priv->imfContextList, iterator, data) {
5354 imfContext = static_cast<Ecore_IMF_Context*>(data);
5355 if (ecore_imf_context_input_panel_layout_get(imfContext) == layout) {
5356 priv->imfContext = imfContext;
5361 imfContext = ecore_imf_context_add(ecore_imf_context_default_id_get());
5365 ecore_imf_context_input_panel_enabled_set(imfContext, false);
5366 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, imfInputPanelStateEventCb, smartData);
5367 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, imfInputPanelGeometryEventCb, smartData);
5368 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, imfCandidatePanelStateEventCb, smartData);
5369 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, imfCandidatePanelGeometryEventCb, smartData);
5370 ecore_imf_context_retrieve_surrounding_callback_set(imfContext, imfRetrieveSurroundingCb, smartData); // Support for Auto Capitalization
5371 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, imfPreeditChangedCb, smartData);
5372 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_COMMIT, imfEventCommittedCb, smartData);
5373 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, imfContextDeleteSurroundingCb, smartData); //Support for Automatic Full Stop
5374 ecore_imf_context_input_panel_layout_set(imfContext, layout);
5376 priv->imfContextList = eina_list_append(priv->imfContextList, imfContext);
5377 priv->imfContext = imfContext;
5382 void ewk_view_imf_context_reset(Evas_Object* ewkView)
5384 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5385 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5387 if (!priv->imfContext)
5390 ecore_imf_context_reset(priv->imfContext);
5392 if (ecore_imf_context_input_panel_state_get(priv->imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
5393 priv->imfContext = 0;
5396 void ewk_view_imf_context_hide(Evas_Object* ewkView)
5398 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5399 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5401 if (!priv->imfContext)
5404 if (ecore_imf_context_input_panel_state_get(priv->imfContext) != ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
5405 ecore_imf_context_reset(priv->imfContext);
5406 ecore_imf_context_input_panel_hide(priv->imfContext);
5407 ecore_imf_context_focus_out(priv->imfContext);
5410 priv->imfContext = 0;
5413 static void _ewk_view_imf_context_destroy(Ewk_View_Private_Data* priv)
5415 if (!priv->imfContextList)
5419 EINA_LIST_FREE(priv->imfContextList, item) {
5420 Ecore_IMF_Context* imfContext = static_cast<Ecore_IMF_Context*>(item);
5424 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, imfInputPanelStateEventCb);
5425 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, imfInputPanelGeometryEventCb);
5426 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, imfCandidatePanelStateEventCb);
5427 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, imfCandidatePanelGeometryEventCb);
5428 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, imfPreeditChangedCb);
5429 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_COMMIT, imfEventCommittedCb);
5430 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, imfContextDeleteSurroundingCb);
5431 ecore_imf_context_del(imfContext);
5434 priv->imfContextList = 0;
5435 priv->imfContext = 0;
5438 void ewk_view_imf_context_destroy(Evas_Object* ewkView)
5440 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5441 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5443 _ewk_view_imf_context_destroy(priv);
5447 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
5448 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
5450 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5451 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5453 WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(priv->pageClient->page())));
5457 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
5458 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
5460 evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
5464 #if ENABLE(TIZEN_ICON_DATABASE)
5465 void ewkViewIconReceived(Evas_Object* ewkView)
5469 evas_object_smart_callback_call(ewkView, "icon,received", 0);
5473 #endif // #if OS(TIZEN)
5475 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
5476 #if ENABLE(INPUT_TYPE_COLOR)
5479 * Reqeusts to show external color picker.
5481 void ewk_view_color_picker_request(Evas_Object* ewkView, int r, int g, int b, int a, WKColorPickerResultListenerRef listener)
5483 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5484 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5485 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_request);
5487 priv->colorPickerResultListener = listener;
5489 smartData->api->input_picker_color_request(smartData, r, g, b, a);
5494 * Reqeusts to hide external color picker.
5496 void ewk_view_color_picker_dismiss(Evas_Object* ewkView)
5498 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5499 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5500 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_dismiss);
5502 priv->colorPickerResultListener = 0;
5504 smartData->api->input_picker_color_dismiss(smartData);
5508 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
5510 #if ENABLE(INPUT_TYPE_COLOR)
5511 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5512 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5513 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->colorPickerResultListener, false);
5515 WebCore::Color color = WebCore::Color(r, g, b, a);
5516 WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(color.serialized().utf8().data()));
5517 WKColorPickerResultListenerSetColor(priv->colorPickerResultListener, colorString.get());
5518 priv->colorPickerResultListener = 0;
5525 #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
5527 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
5529 #if ENABLE(TOUCH_EVENTS)
5530 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
5531 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5532 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5533 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
5535 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
5536 if (priv->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
5537 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5538 IntPoint handlePoint(point->x, point->y);
5540 if (type == EWK_TOUCH_START)
5541 priv->pageClient->textSelectonHandleDown(handlePoint);
5542 else if (type == EWK_TOUCH_MOVE)
5543 priv->pageClient->textSelectonHandleMove(handlePoint);
5545 priv->pageClient->textSelectonHandleUp();
5549 #if ENABLE(TIZEN_GESTURE)
5550 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
5551 // We don't want to process touch event when context menu is shown.
5552 if (priv->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
5555 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
5556 if (priv->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
5560 if (type == EWK_TOUCH_START) {
5561 if (eina_list_count(points) == 1) {
5562 priv->gestureClient->reset();
5563 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5564 priv->touchDownPoint.x = point->x;
5565 priv->touchDownPoint.y = point->y;
5566 priv->exceedTouchMoveThreshold = false;
5568 } else if (type == EWK_TOUCH_MOVE && !priv->exceedTouchMoveThreshold) {
5569 if (eina_list_count(points) == 1) {
5570 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
5571 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5572 int diffX = priv->touchDownPoint.x - point->x;
5573 int diffY = priv->touchDownPoint.y - point->y;
5574 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
5575 priv->exceedTouchMoveThreshold = true;
5579 priv->exceedTouchMoveThreshold = true;
5582 #endif // #if ENABLE(TIZEN_GESTURE)
5584 // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
5585 //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
5586 priv->pageClient->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
5594 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
5596 #if ENABLE(TOUCH_EVENTS)
5597 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5598 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5600 enabled = !!enabled;
5601 if (priv->areTouchEventsEnabled == enabled)
5604 priv->areTouchEventsEnabled = enabled;
5606 // FIXME: We have to connect touch callbacks with mouse and multi events
5607 // because the Evas creates mouse events for first touch and multi events
5608 // for second and third touches. Below codes should be fixed when the Evas
5609 // supports the touch events.
5610 // See https://bugs.webkit.org/show_bug.cgi?id=97785 for details.
5611 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down, smartData);
5612 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up, smartData);
5613 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move, smartData);
5614 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down, smartData);
5615 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up, smartData);
5616 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move, smartData);
5618 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down);
5619 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up);
5620 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move);
5621 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down);
5622 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up);
5623 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move);
5632 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
5634 #if ENABLE(TOUCH_EVENTS)
5635 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5636 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5638 return priv->areTouchEventsEnabled;
5644 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
5646 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
5647 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5648 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5650 priv->mainFrameScrollbarVisibility = visible;
5651 priv->pageClient->updateVisibility();
5659 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
5661 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
5662 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5663 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5665 return priv->mainFrameScrollbarVisibility;
5671 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
5673 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
5674 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5675 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5676 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
5678 String title = ewk_view_title_get(ewkView);
5679 String url = ewk_view_url_get(ewkView);
5680 String directoryPath(path);
5681 priv->pageClient->startOfflinePageSave(directoryPath, url, title);
5685 UNUSED_PARAM(ewkView);
5693 * Callback function used for ewk_view_page_contents_get().
5695 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
5697 EINA_SAFETY_ON_NULL_RETURN(context);
5699 RefPtr<WebData> webData = toImpl(wkData);
5700 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
5701 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
5706 * Callback function used for ewk_view_page_contents_get().
5708 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
5710 EINA_SAFETY_ON_NULL_RETURN(context);
5712 RefPtr<WebString> webString = toImpl(wkString);
5713 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
5714 contentsContext->callback(contentsContext->type, webString->string().utf8().data());
5717 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
5719 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
5720 EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
5721 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5722 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5724 switch (context->type) {
5725 case EWK_PAGE_CONTENTS_TYPE_MHTML:
5726 priv->pageClient->page()->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
5729 case EWK_PAGE_CONTENTS_TYPE_STRING:
5730 priv->pageClient->page()->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
5734 ASSERT_NOT_REACHED();
5741 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
5743 #if ENABLE(TIZEN_GESTURE)
5744 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5745 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5747 return priv->gestureClient->scrollToWithAnimation(x, y);
5749 UNUSED_PARAM(ewkView);
5756 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5757 void ewkViewFocusRingHide(Evas_Object* ewkView)
5759 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5760 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5762 if (priv->focusRing)
5763 priv->focusRing->hide();
5767 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
5769 #if ENABLE(TIZEN_CSP)
5770 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
5771 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
5773 TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
5774 priv->pageClient->page()->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));