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 #if ENABLE(TIZEN_ISF_PORT)
804 if (!evas_object_focus_get(smartData->self))
805 priv->imfContext = 0;
807 priv->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
808 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
809 if (priv->pageClient->isTextSelectionMode())
810 priv->pageClient->setIsTextSelectionMode(false);
812 #if ENABLE(TIZEN_ISF_PORT)
813 evas_object_focus_set(smartData->self, true);
815 } else if (event->count == 2 && priv->useSmartSelection)
816 priv->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
818 case EWK_GESTURE_LONG_PRESS:
819 #if ENABLE(TIZEN_DRAG_SUPPORT)
820 if (priv->pageClient->isDragMode())
821 priv->pageClient->setDragMode(false);
823 // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
824 priv->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
826 case EWK_GESTURE_PAN:
827 priv->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
829 case EWK_GESTURE_FLICK:
830 priv->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
832 case EWK_GESTURE_PINCH:
833 priv->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
836 ASSERT_NOT_REACHED();
843 #endif // #if ENABLE(TIZEN_GESTURE)
846 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
848 #if ENABLE(TIZEN_GESTURE)
849 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
851 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
852 if (priv->pageClient->isTextSelectionMode() && priv->pageClient->isTextSelectionHandleDowned())
856 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
857 if (priv->focusRing && !(event->type == EWK_GESTURE_PAN && !priv->exceedTouchMoveThreshold))
858 priv->focusRing->hide();
861 switch (event->type) {
862 case EWK_GESTURE_PAN:
863 priv->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
865 case EWK_GESTURE_TAP:
866 case EWK_GESTURE_LONG_PRESS:
867 case EWK_GESTURE_FLICK:
869 case EWK_GESTURE_PINCH:
870 if (priv->pageClient->viewportConstraints().userScalable)
871 priv->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
874 ASSERT_NOT_REACHED();
881 #endif // #if ENABLE(TIZEN_GESTURE)
883 #endif //#if OS(TIZEN)
886 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
888 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
889 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
890 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
891 smartData->api->focus_in(smartData);
894 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
896 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
897 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
898 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
899 smartData->api->focus_out(smartData);
902 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
904 Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
905 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
906 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
907 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
908 smartData->api->mouse_wheel(smartData, wheelEvent);
911 static void _ewk_view_on_mouse_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
913 Evas_Event_Mouse_Down* downEvent = static_cast<Evas_Event_Mouse_Down*>(eventInfo);
914 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
915 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
916 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_down);
917 smartData->api->mouse_down(smartData, downEvent);
920 static void _ewk_view_on_mouse_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
922 Evas_Event_Mouse_Up* upEvent = static_cast<Evas_Event_Mouse_Up*>(eventInfo);
923 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
924 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
925 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_up);
926 smartData->api->mouse_up(smartData, upEvent);
929 static void _ewk_view_on_mouse_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
931 Evas_Event_Mouse_Move* moveEvent = static_cast<Evas_Event_Mouse_Move*>(eventInfo);
932 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
933 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
934 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_move);
935 smartData->api->mouse_move(smartData, moveEvent);
938 static void _ewk_view_on_key_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
940 Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
941 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
942 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
943 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
944 smartData->api->key_down(smartData, downEvent);
947 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
949 Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
950 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
951 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
952 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
953 smartData->api->key_up(smartData, upEvent);
956 #if ENABLE(TOUCH_EVENTS)
957 static inline void _ewk_view_feed_touch_event_using_touch_point_list_of_evas(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
959 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
961 unsigned count = evas_touch_point_list_count(smartData->base.evas);
965 Eina_List* points = 0;
966 for (unsigned i = 0; i < count; ++i) {
967 Ewk_Touch_Point* point = new Ewk_Touch_Point;
968 point->id = evas_touch_point_list_nth_id_get(smartData->base.evas, i);
969 evas_touch_point_list_nth_xy_get(smartData->base.evas, i, &point->x, &point->y);
970 point->state = evas_touch_point_list_nth_state_get(smartData->base.evas, i);
971 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_GESTURE)
972 if (type == EWK_TOUCH_CANCEL)
973 point->state = EVAS_TOUCH_POINT_CANCEL;
975 points = eina_list_append(points, point);
978 ewk_view_feed_touch_event(ewkView, type, points, evas_key_modifier_get(smartData->base.evas));
981 EINA_LIST_FREE(points, data)
982 delete static_cast<Ewk_Touch_Point*>(data);
985 static void _ewk_view_on_touch_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
987 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_START);
990 static void _ewk_view_on_touch_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
992 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_END);
995 static void _ewk_view_on_touch_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
997 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_MOVE);
1001 void ewkViewHandleTouchEvent(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
1003 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, type);
1009 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1010 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
1012 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1014 return priv->pageClient->textSelectionDown(IntPoint(x, y), true);
1017 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
1019 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1021 IntPoint point(x, y);
1022 priv->pageClient->textSelectionMove(point, true);
1027 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
1029 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1031 IntPoint point(x, y);
1032 priv->pageClient->textSelectionUp(point, true);
1038 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1039 static void _ewk_view_data_list_del(Eina_List* dataList)
1041 EINA_SAFETY_ON_NULL_RETURN(dataList);
1044 EINA_LIST_FREE(dataList, item)
1045 eina_stringshare_del(static_cast<char*>(item));
1049 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1050 Eina_Bool _ewk_view_smart_formdata_candidate_show(Ewk_View_Smart_Data* smartData, int x, int y, int w, int h)
1052 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1054 priv->pageClient->showFormDataCandidate(IntRect(x, y, w, h));
1059 Eina_Bool _ewk_view_smart_formdata_candidate_hide(Ewk_View_Smart_Data* smartData)
1061 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1063 priv->pageClient->hideFormDataCandidate();
1068 Eina_Bool _ewk_view_smart_formdata_candidate_update_data(Ewk_View_Smart_Data* smartData, Eina_List* dataList)
1070 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1072 Vector<String> formData;
1075 EINA_LIST_FOREACH(dataList, list, data)
1076 formData.append(String::fromUTF8(static_cast<char*>(data)));
1078 priv->pageClient->updateFormDataCandidate(formData);
1083 Eina_Bool _ewk_view_smart_formdata_candidate_is_showing(Ewk_View_Smart_Data* smartData)
1085 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1087 return priv->pageClient->isShowingFormDataCandidate();
1091 #if ENABLE(TIZEN_SCREEN_READER)
1092 Eina_Bool _ewk_view_screen_reader_command_execute(Ewk_View_Smart_Data* smartData, unsigned int command, int data1, int data2)
1094 return ScreenReaderProxy::screenReader().executeCommand(smartData->self, command, data1, data2);
1097 #endif // #if OS(TIZEN)
1099 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
1101 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1102 static uint64_t generatePageGroupIdentifierID()
1104 static uint64_t uniquePageGroupIdentifierID = 1;
1105 return uniquePageGroupIdentifierID++;
1109 static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
1111 Ewk_View_Private_Data* priv = new Ewk_View_Private_Data;
1112 memset(priv, 0, sizeof(Ewk_View_Private_Data)); // FIXME : below code should be considered to move to constructor.
1114 priv->areMouseEventsEnabled = false;
1116 priv->javascriptPopup = adoptPtr<JavaScriptPopup>(new JavaScriptPopup(smartData->self));
1117 priv->openPanel = adoptPtr<OpenPanel>(new OpenPanel(smartData->self));
1119 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1120 priv->inputPicker = adoptPtr<InputPicker>(new InputPicker(smartData->self));
1121 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1123 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1124 priv->focusRing = FocusRing::create(smartData->self);
1125 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1127 #if ENABLE(TIZEN_GESTURE)
1128 priv->gestureRecognizer = GestureRecognizer::create(smartData->self);
1129 priv->gestureClient = GestureClient::create(smartData->ewkViewImpl);
1130 priv->useSmartSelection = true;
1131 #endif // #if ENABLE(TIZEN_GESTURE)
1132 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1133 const char* hideScrollbar = getenv("TIZEN_WEBKIT2_TILED_SCROLLBAR_HIDE");
1134 if (hideScrollbar && atoi(hideScrollbar) == 1)
1135 priv->mainFrameScrollbarVisibility = false;
1137 priv->mainFrameScrollbarVisibility = true;
1140 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1144 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1145 String pageGroupIdentifierID = String::number(generatePageGroupIdentifierID());
1146 String pageGroupIdentifier = String::format("PageGroup%s", pageGroupIdentifierID.utf8().data());
1148 WKRetainPtr<WKStringRef> pageGroupIdentifierRef(AdoptWK, WKStringCreateWithUTF8CString(pageGroupIdentifier.utf8().data()));
1149 priv->pageGroup = WebPageGroup::create(toWTFString(pageGroupIdentifierRef.get()));
1152 priv->suspendRequested = false;
1153 priv->suspendedPainting = false;
1154 priv->suspendedResources = false;
1155 #endif // #if OS(TIZEN)
1158 priv->isUsingEcoreX = WebCore::isUsingEcoreX(smartData->base.evas);
1164 static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap)
1166 // Clear the loadingResources HashMap.
1167 LoadingResourcesMap::iterator it = loadingResourcesMap.begin();
1168 LoadingResourcesMap::iterator end = loadingResourcesMap.end();
1169 for ( ; it != end; ++it)
1170 ewk_web_resource_unref(it->second);
1172 loadingResourcesMap.clear();
1175 static void _ewk_view_priv_del(Ewk_View_Private_Data* priv)
1181 if (priv->javascriptGlobalContext)
1182 JSGlobalContextRelease(priv->javascriptGlobalContext);
1184 eina_stringshare_del(priv->userAgent);
1185 eina_stringshare_del(priv->encoding);
1186 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1187 eina_stringshare_del(priv->webAppIconURL);
1190 if (priv->authChallenge)
1191 ewkAuthChallengeDelete(priv->authChallenge);
1192 if (priv->policyDecision)
1193 ewkPolicyDecisionDelete(priv->policyDecision);
1195 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1196 if (priv->certificatePolicyDecision)
1197 ewkCertificatePolicyDecisionDelete(priv->certificatePolicyDecision);
1200 #if ENABLE(TIZEN_MEDIA_STREAM)
1201 if (priv->userMediaPermissionRequests)
1202 ewkUserMediaDeletePermissionRequestList(priv->userMediaPermissionRequests);
1205 priv->openPanelListener = 0;
1206 priv->openPanel = nullptr;
1207 priv->javascriptPopup = nullptr;
1208 priv->alertContext = nullptr;
1209 priv->confirmContext = nullptr;
1210 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1211 priv->beforeUnloadConfirmPanelContext = nullptr;
1213 priv->promptContext = nullptr;
1214 priv->isWaitingForJavaScriptPopupReply = false;
1215 priv->openpanelContext = nullptr;
1216 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1217 priv->inputPicker = nullptr;
1218 eina_stringshare_del(priv->inputValue);
1221 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1222 if (priv->dataList) {
1223 _ewk_view_data_list_del(priv->dataList);
1228 #if ENABLE(TIZEN_GEOLOCATION)
1229 if (priv->geolocation)
1230 ewkGeolocationDeleteGeolocation(priv->geolocation);
1231 if (priv->geolocationPermissionRequests)
1232 ewkGeolocationDeletePermissionRequestList(priv->geolocationPermissionRequests);
1235 #if ENABLE(TIZEN_NOTIFICATIONS)
1236 if (priv->notifications)
1237 ewkNotificationDeleteNotificationList(priv->notifications);
1238 if (priv->notificationPermissionRequests)
1239 ewkNotificationDeletePermissionRequestList(priv->notificationPermissionRequests);
1241 #if ENABLE(TIZEN_SQL_DATABASE)
1242 if (priv->exceededDatabaseQuota)
1243 ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
1245 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1246 priv->focusRing = nullptr;
1247 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1248 #if ENABLE(TIZEN_GESTURE)
1249 priv->gestureRecognizer = nullptr;
1250 priv->gestureClient = nullptr;
1251 #endif // #if ENABLE(TIZEN_GESTURE)
1253 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1254 eina_stringshare_del(priv->selectedText);
1256 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1257 priv->pageGroup = nullptr;
1260 #if ENABLE(TIZEN_ISF_PORT)
1261 _ewk_view_imf_context_destroy(priv);
1263 #endif // #if OS(TIZEN)
1268 static void _ewk_view_smart_add(Evas_Object* ewkView)
1270 const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
1271 const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
1272 const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
1273 EWK_VIEW_SD_GET(ewkView, smartData);
1276 smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
1278 EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
1281 evas_object_smart_data_set(ewkView, smartData);
1284 smartData->self = ewkView;
1285 smartData->api = api;
1287 g_parentSmartClass.add(ewkView);
1289 // FIXME: Ewk_View_Private_Data was replaced with EwkViewImpl in the webkit opensource.
1290 // So, we have both Ewk_View_Private_Data and EwkViewImpl now,
1291 // but Ewk_View_Private_Data should be removed later.
1292 smartData->ewkViewImpl = new EwkViewImpl(ewkView);
1293 smartData->priv = _ewk_view_priv_new(smartData);
1295 // Create evas_object_image to draw web contents.
1296 smartData->image = evas_object_image_add(smartData->base.evas);
1297 evas_object_image_alpha_set(smartData->image, false);
1298 evas_object_image_filled_set(smartData->image, true);
1299 evas_object_smart_member_add(smartData->image, ewkView);
1302 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1303 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
1304 const char *engine = ecore_evas_engine_name_get(ee);
1305 if (engine && !strcmp(engine, "opengl_x11"))
1306 evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
1308 ewk_view_mouse_events_enabled_set(ewkView, false);
1309 ewk_view_touch_events_enabled_set(ewkView, true);
1311 // FIXME: This code should be removed if side effect occur.
1312 // WebView does not have focus after url loading.
1313 // If focus is set as true to webview,
1314 // elementary steal webview's focus during mouse up event
1315 // So, added code that events are not propagated to smart parent according to guide from EFL
1316 evas_object_propagate_events_set(ewkView, false);
1318 #if ENABLE(TIZEN_SCREEN_READER)
1319 ScreenReaderProxy::screenReader().addView(ewkView);
1321 #endif // #if OS(TIZEN)
1323 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
1324 CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
1325 CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
1326 CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
1328 CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
1329 CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
1330 CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
1332 CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
1333 CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
1337 static void _ewk_view_smart_del(Evas_Object* ewkView)
1339 EWK_VIEW_SD_GET(ewkView, smartData);
1340 #if ENABLE(TIZEN_SCREEN_READER)
1341 ScreenReaderProxy::screenReader().removeView(ewkView);
1343 if (smartData && smartData->priv) {
1344 _ewk_view_priv_del(smartData->priv);
1345 smartData->priv = 0;
1348 // FIXME: Ewk_View_Private_Data was replaced with EwkViewImpl in the webkit opensource.
1349 // If then, ewkViewImpl will be changed to priv.
1351 delete smartData->ewkViewImpl;
1353 g_parentSmartClass.del(ewkView);
1356 static Eina_Bool _ewk_view_composite(void* data);
1358 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
1360 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1362 evas_object_resize(smartData->image, width, height);
1363 evas_object_image_size_set(smartData->image, width, height);
1364 evas_object_image_fill_set(smartData->image, 0, 0, width, height);
1366 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1367 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1368 evas_object_image_native_surface_set(smartData->image, 0);
1370 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1371 if (!ewk_view_is_opengl_backend(ewkView))
1372 _ewk_view_composite(smartData);
1373 else // OpenGL backend
1375 priv->pageClient->displayViewport();
1378 #if ENABLE(TIZEN_PREFERENCE)
1379 if (priv && priv->pageClient->page()) {
1380 priv->pageClient->page()->pageGroup()->preferences()->setViewWidth(width);
1381 priv->pageClient->page()->pageGroup()->preferences()->setViewHeight(height);
1384 #endif // #if OS(TIZEN)
1386 smartData->changed.size = true;
1387 _ewk_view_smart_changed(smartData);
1390 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
1392 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1394 smartData->changed.position = true;
1395 _ewk_view_smart_changed(smartData);
1398 IntSize ewk_view_size_get(const Evas_Object* ewkView)
1401 evas_object_geometry_get(ewkView, 0, 0, &width, &height);
1402 return IntSize(width, height);
1405 #if USE(ACCELERATED_COMPOSITING)
1406 static bool ewk_view_create_gl_surface(const Evas_Object* ewkView, const IntSize& viewSize)
1408 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1409 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1411 Evas_GL_Config evasGlConfig = {
1413 EVAS_GL_DEPTH_BIT_8,
1414 EVAS_GL_STENCIL_NONE,
1415 EVAS_GL_OPTIONS_NONE,
1416 EVAS_GL_MULTISAMPLE_NONE
1419 ASSERT(!priv->evasGlSurface);
1420 priv->evasGlSurface = evas_gl_surface_create(priv->evasGl, &evasGlConfig, viewSize.width(), viewSize.height());
1421 if (!priv->evasGlSurface)
1424 Evas_Native_Surface nativeSurface;
1425 evas_gl_native_surface_get(priv->evasGl, priv->evasGlSurface, &nativeSurface);
1426 evas_object_image_native_surface_set(smartData->image, &nativeSurface);
1431 bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView)
1433 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1434 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1436 EINA_SAFETY_ON_TRUE_RETURN_VAL(!!priv->evasGl, false);
1438 Evas* evas = evas_object_evas_get(ewkView);
1439 priv->evasGl = evas_gl_new(evas);
1443 priv->evasGlContext = evas_gl_context_create(priv->evasGl, 0);
1444 if (!priv->evasGlContext) {
1445 evas_gl_free(priv->evasGl);
1450 if (!ewk_view_create_gl_surface(ewkView, ewk_view_size_get(ewkView))) {
1451 evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
1452 priv->evasGlContext = 0;
1454 evas_gl_free(priv->evasGl);
1462 bool ewk_view_accelerated_compositing_mode_exit(const Evas_Object* ewkView)
1464 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1465 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1467 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->evasGl, false);
1469 if (priv->evasGlSurface) {
1470 evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
1471 priv->evasGlSurface = 0;
1474 if (priv->evasGlContext) {
1475 evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
1476 priv->evasGlContext = 0;
1479 evas_gl_free(priv->evasGl);
1486 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
1488 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1489 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1490 Evas_Coord x, y, width, height;
1492 smartData->changed.any = false;
1494 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
1496 if (smartData->changed.size) {
1498 if (priv->pageClient->page()->drawingArea())
1499 priv->pageClient->page()->drawingArea()->setSize(IntSize(width, height), IntSize());
1501 #if USE(ACCELERATED_COMPOSITING)
1502 if (!priv->evasGlSurface)
1504 evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
1505 priv->evasGlSurface = 0;
1506 ewk_view_create_gl_surface(ewkView, IntSize(width, height));
1507 ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
1509 #endif // #if !OS(TIZEN)
1511 smartData->view.w = width;
1512 smartData->view.h = height;
1513 smartData->changed.size = false;
1516 if (priv->pageClient) {
1517 if (DrawingAreaProxy* drawingArea = priv->pageClient->page()->drawingArea()) {
1518 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1519 if (priv->pageClient->page()->isViewVisible())
1520 drawingArea->setSize(IntSize(width, height), IntSize());
1522 drawingArea->setSize(IntSize(width, height), IntSize());
1524 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1525 priv->pageClient->updateViewportSize(IntSize(width, height));
1526 if (ewk_view_is_opengl_backend(ewkView))
1527 priv->pageClient->displayViewport();
1530 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1531 priv->pageClient->frameRectChanged();
1534 #endif // #if OS(TIZEN)
1537 if (smartData->changed.position) {
1538 evas_object_move(smartData->image, x, y);
1539 smartData->view.x = x;
1540 smartData->view.y = y;
1541 smartData->changed.position = false;
1543 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1544 priv->pageClient->frameRectChanged();
1546 #if ENABLE(TIZEN_SCREEN_READER)
1547 priv->pageClient->page()->recalcScreenReaderFocusRect();
1549 #endif // #if OS(TIZEN)
1552 if (priv->popupPicker)
1553 ewk_popup_picker_resize(priv->popupPicker);
1554 #endif // #if OS(TIZEN)
1557 static void _ewk_view_smart_show(Evas_Object* ewkView)
1559 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1560 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1562 if (evas_object_clipees_get(smartData->base.clipper))
1563 evas_object_show(smartData->base.clipper);
1564 evas_object_show(smartData->image);
1567 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1569 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1571 evas_object_hide(smartData->base.clipper);
1572 evas_object_hide(smartData->image);
1573 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1574 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1575 if (priv->pageClient->isTextSelectionMode())
1576 priv->pageClient->setIsTextSelectionMode(false);
1580 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1582 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1583 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1587 else if (alpha > 255)
1590 #define CHECK_COLOR(color, alpha) \
1593 else if (color > alpha) \
1595 CHECK_COLOR(red, alpha);
1596 CHECK_COLOR(green, alpha);
1597 CHECK_COLOR(blue, alpha);
1600 evas_object_image_alpha_set(smartData->image, alpha < 255);
1601 priv->pageClient->page()->setDrawsBackground(red || green || blue);
1602 priv->pageClient->page()->setDrawsTransparentBackground(alpha < 255);
1603 priv->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1606 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1610 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1612 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1614 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1615 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1616 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1620 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1621 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1623 evas_object_smart_clipped_smart_set(&api->sc);
1625 // Set Evas_Smart_Class functions.
1626 api->sc.add = _ewk_view_smart_add;
1627 api->sc.del = _ewk_view_smart_del;
1628 api->sc.move = _ewk_view_smart_move;
1629 api->sc.resize = _ewk_view_smart_resize;
1630 api->sc.show = _ewk_view_smart_show;
1631 api->sc.hide = _ewk_view_smart_hide;
1632 api->sc.color_set = _ewk_view_smart_color_set;
1633 api->sc.calculate = _ewk_view_smart_calculate;
1634 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1636 // Set Ewk_View_Smart_Class functions.
1637 api->focus_in = _ewk_view_smart_focus_in;
1638 api->focus_out = _ewk_view_smart_focus_out;
1639 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1640 api->mouse_down = _ewk_view_smart_mouse_down;
1641 api->mouse_up = _ewk_view_smart_mouse_up;
1642 api->mouse_move = _ewk_view_smart_mouse_move;
1643 api->key_down = _ewk_view_smart_key_down;
1644 api->key_up = _ewk_view_smart_key_up;
1646 api->gesture_start = _ewk_view_smart_gesture_start;
1647 api->gesture_end = _ewk_view_smart_gesture_end;
1648 api->gesture_move = _ewk_view_smart_gesture_move;
1650 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1651 api->popup_menu_show = _ewk_view_popup_menu_show;
1652 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1653 api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1655 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1656 api->popup_menu_update = _ewk_view_popup_menu_update;
1658 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1659 api->text_selection_down = _ewk_view_text_selection_down;
1660 api->text_selection_move = _ewk_view_text_selection_move;
1661 api->text_selection_up = _ewk_view_text_selection_up;
1663 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1664 api->input_picker_show = _ewk_view_input_picker_show;
1666 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1667 api->data_list_show = _ewk_view_data_list_show;
1668 api->data_list_hide = _ewk_view_data_list_hide;
1670 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1671 api->orientation_lock = _ewk_orientation_lock;
1672 api->orientation_unlock = _ewk_orientation_unlock;
1674 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1675 api->input_picker_color_request = _ewk_input_picker_color_request;
1676 api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1678 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1679 api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1680 api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1681 api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1682 api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1684 #if ENABLE(TIZEN_SCREEN_READER)
1685 api->screen_reader_command_execute = _ewk_view_screen_reader_command_execute;
1687 #endif //#if OS(TIZEN)
1692 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1694 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1695 static Evas_Smart* smart = 0;
1697 if (EINA_UNLIKELY(!smart)) {
1698 ewk_view_smart_class_set(&api);
1699 smart = evas_smart_class_new(&api.sc);
1705 static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKPageGroupRef pageGroupRef)
1707 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1708 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
1709 EINA_SAFETY_ON_NULL_RETURN(context);
1711 if (priv->pageClient)
1714 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1715 if (ewk_view_is_opengl_backend(ewkView)) {
1716 priv->pageClient = PageClientEvasGL::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1717 priv->pageClient->page()->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1720 priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1721 priv->pageClient->page()->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1722 priv->pageClient->page()->pageGroup()->preferences()->setWebGLEnabled(false);
1723 priv->pageClient->page()->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1726 priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1728 // FixMe: Comment should be removed when pageClient is removed.
1729 //priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageProxy.get())))));
1730 priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageClient->page())))));
1733 priv->context = context;
1735 ewkViewContextMenuClientAttachClient(ewkView);
1736 ewkViewFindClientAttatchClient(ewkView);
1737 ewkViewTizenClientAttachClient(ewkView);
1738 ewkViewUIClientAttatchClient(ewkView);
1740 #if ENABLE(TIZEN_GEOLOCATION)
1741 ewkViewGeolocationProviderAttachProvider(ewkView, ewk_context_WKContext_get(context));
1744 #if ENABLE(TIZEN_NOTIFICATIONS)
1745 ewkViewNotificationProviderAttachProvider(ewkView, ewk_context_WKContext_get(context));
1748 #if ENABLE(TIZEN_ICON_DATABASE)
1749 ewk_view_icondatabase_client_attach(ewkView, ewk_context_WKContext_get(context));
1752 ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1753 ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1754 ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1755 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1756 ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1758 ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1759 #else // #if OS(TIZEN)
1760 priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageClient->page()->backForwardList()));
1762 #if USE(COORDINATED_GRAPHICS)
1763 priv->viewportHandler = EflViewportHandler::create(priv->pageClient.get());
1765 #endif // #if OS(TIZEN)
1767 WKPageRef wkPage = toAPI(priv->pageClient->page());
1768 ewk_view_form_client_attach(wkPage, ewkView);
1769 ewk_view_loader_client_attach(wkPage, ewkView);
1770 ewk_view_policy_client_attach(wkPage, ewkView);
1771 ewk_view_resource_load_client_attach(wkPage, ewkView);
1773 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1774 ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1777 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1778 if (!ewk_context_x_window_get(context))
1779 ewk_context_x_window_set(context, elm_win_xwindow_get(ewkView));
1783 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1785 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1786 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1788 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1789 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1790 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1795 Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1799 EWK_VIEW_SD_GET(ewkView, smartData);
1801 evas_object_del(ewkView);
1805 EWK_VIEW_PRIV_GET(smartData, priv);
1807 evas_object_del(ewkView);
1816 * Constructs a ewk_view Evas_Object with WKType parameters.
1818 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1820 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1821 EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1823 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1827 _ewk_view_initialize(ewkView, ewk_context_new_from_WKContext(contextRef), pageGroupRef);
1832 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1834 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1835 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1836 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1838 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1842 #if ENABLE(TIZEN_ICON_DATABASE)
1843 //set default iconDatabasePath
1844 WKContextRef contextRef = ewk_context_WKContext_get(context);
1845 toImpl(contextRef)->setIconDatabasePath(toImpl(contextRef)->iconDatabasePath());
1848 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1849 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1850 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1851 _ewk_view_initialize(ewkView, context, toAPI(priv->pageGroup.get()));
1853 _ewk_view_initialize(ewkView, context, 0);
1859 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1861 return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1864 Evas_Object* ewk_view_add(Evas* canvas)
1866 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1871 * The uri of view was changed by the frame loader.
1873 * Emits signal: "uri,changed" with pointer to new uri string.
1875 void ewk_view_uri_update(Evas_Object* ewkView)
1877 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1878 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1880 String activeURL = priv->pageClient->page()->activeURL();
1881 if (activeURL.isEmpty())
1884 if (!eina_stringshare_replace(&priv->uri, activeURL.utf8().data()))
1887 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1888 evas_object_smart_callback_call(ewkView, "url,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1891 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* uri)
1893 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1894 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1895 EINA_SAFETY_ON_NULL_RETURN_VAL(uri, false);
1897 priv->pageClient->page()->loadURL(String::fromUTF8(uri));
1898 ewk_view_uri_update(ewkView);
1903 const char* ewk_view_url_get(const Evas_Object* ewkView)
1905 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1906 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1911 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1913 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1914 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1916 priv->pageClient->page()->reload(/*reloadFromOrigin*/ false);
1917 ewk_view_uri_update(ewkView);
1922 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1924 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1925 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1927 priv->pageClient->page()->reload(/*reloadFromOrigin*/ true);
1928 ewk_view_uri_update(ewkView);
1933 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1935 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1936 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1938 priv->pageClient->page()->stopLoading();
1943 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1945 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1946 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1948 return priv->settings.get();
1953 * Load was initiated for a resource in the view.
1955 * Emits signal: "resource,request,new" with pointer to resource request.
1957 void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request)
1959 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1960 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1962 Ewk_Web_Resource_Request resourceRequest = {resource, request, 0};
1964 // Keep the resource internally to reuse it later.
1965 ewk_web_resource_ref(resource);
1966 priv->loadingResourcesMap.add(resourceIdentifier, resource);
1968 evas_object_smart_callback_call(ewkView, "resource,request,new", &resourceRequest);
1973 * Received a response to a resource load request in the view.
1975 * Emits signal: "resource,request,response" with pointer to resource response.
1977 void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response)
1979 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1980 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1982 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
1985 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
1986 Ewk_Web_Resource_Load_Response resourceLoadResponse = {resource, response};
1987 evas_object_smart_callback_call(ewkView, "resource,request,response", &resourceLoadResponse);
1992 * Failed loading a resource in the view.
1994 * Emits signal: "resource,request,finished" with pointer to the resource load error.
1996 void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Error* error)
1998 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1999 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2001 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2004 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
2005 Ewk_Web_Resource_Load_Error resourceLoadError = {resource, error};
2006 evas_object_smart_callback_call(ewkView, "resource,request,failed", &resourceLoadError);
2011 * Finished loading a resource in the view.
2013 * Emits signal: "resource,request,finished" with pointer to the resource.
2015 void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIdentifier)
2017 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2018 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2020 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2023 Ewk_Web_Resource* resource = priv->loadingResourcesMap.take(resourceIdentifier);
2024 evas_object_smart_callback_call(ewkView, "resource,request,finished", resource);
2026 ewk_web_resource_unref(resource);
2031 * Request was sent for a resource in the view.
2033 * Emits signal: "resource,request,sent" with pointer to resource request and possible redirect response.
2035 void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse)
2037 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2038 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2040 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2043 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
2044 Ewk_Web_Resource_Request resourceRequest = {resource, request, redirectResponse};
2046 evas_object_smart_callback_call(ewkView, "resource,request,sent", &resourceRequest);
2049 const char* ewk_view_title_get(const Evas_Object* ewkView)
2051 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2052 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2054 CString title = priv->pageClient->page()->pageTitle().utf8();
2055 eina_stringshare_replace(&priv->title, title.data());
2062 * Reports that the requested text was found.
2064 * Emits signal: "text,found" with the number of matches.
2066 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
2068 evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
2073 * The view title was changed by the frame loader.
2075 * Emits signal: "title,changed" with pointer to new title string.
2077 void ewk_view_title_changed(Evas_Object* ewkView, const char* title)
2079 evas_object_smart_callback_call(ewkView, "title,changed", const_cast<char*>(title));
2082 double ewk_view_load_progress_get(const Evas_Object* ewkView)
2084 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2085 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2087 return priv->pageClient->page()->estimatedProgress();
2090 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
2092 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2093 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2099 scaleFactor = priv->pageClient->adjustScaleWithViewport(scaleFactor);
2101 IntPoint scrollPosition = priv->pageClient->scrollPosition();
2102 double scaleDifference = scaleFactor / priv->pageClient->scaleFactor();
2103 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
2104 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
2106 priv->pageClient->page()->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
2108 priv->pageClient->page()->scalePage(scaleFactor, IntPoint(x, y));
2113 double ewk_view_scale_get(const Evas_Object* ewkView)
2115 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
2116 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1);
2119 return priv->pageClient->page()->scaleFactor();
2121 return priv->pageClient->page()->pageScaleFactor();
2125 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
2127 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2128 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2130 priv->pageClient->page()->setCustomDeviceScaleFactor(ratio);
2135 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
2137 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2138 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2140 return priv->pageClient->page()->deviceScaleFactor();
2143 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
2144 void ewk_view_load_progress_started(Evas_Object* ewkView)
2146 evas_object_smart_callback_call(ewkView, "load,progress,started", 0);
2152 * Reports load progress changed.
2154 * Emits signal: "load,progress" with pointer to a double from 0.0 to 1.0.
2156 void ewk_view_load_progress_changed(Evas_Object* ewkView, double progress)
2158 evas_object_smart_callback_call(ewkView, "load,progress", &progress);
2161 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
2162 void ewk_view_load_progress_finished(Evas_Object* ewkView)
2164 evas_object_smart_callback_call(ewkView, "load,progress,finished", 0);
2168 #if ENABLE(WEB_INTENTS)
2171 * The view received a new intent request.
2173 * Emits signal: "intent,request,new" with pointer to a Ewk_Intent.
2175 void ewk_view_intent_request_new(Evas_Object* ewkView, const Ewk_Intent* ewkIntent)
2177 evas_object_smart_callback_call(ewkView, "intent,request,new", const_cast<Ewk_Intent*>(ewkIntent));
2181 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
2183 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2184 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2186 if (!eina_stringshare_replace(&priv->theme, path))
2189 priv->pageClient->page()->setThemePath(path);
2192 const char* ewk_view_theme_get(const Evas_Object* ewkView)
2194 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2195 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2200 void ewk_view_cursor_set(Evas_Object* ewkView, const Cursor& cursor)
2202 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2203 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2205 const char* group = cursor.platformCursor();
2206 if (!group || group == priv->cursorGroup)
2209 priv->cursorGroup = group;
2211 if (priv->cursorObject)
2212 evas_object_del(priv->cursorObject);
2213 priv->cursorObject = edje_object_add(smartData->base.evas);
2215 Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
2216 if (!priv->theme || !edje_object_file_set(priv->cursorObject, priv->theme, group)) {
2217 evas_object_del(priv->cursorObject);
2218 priv->cursorObject = 0;
2220 ecore_evas_object_cursor_set(ecoreEvas, 0, 0, 0, 0);
2222 if (priv->isUsingEcoreX)
2223 WebCore::applyFallbackCursor(ecoreEvas, group);
2228 Evas_Coord width, height;
2229 edje_object_size_min_get(priv->cursorObject, &width, &height);
2230 if (width <= 0 || height <= 0)
2231 edje_object_size_min_calc(priv->cursorObject, &width, &height);
2232 if (width <= 0 || height <= 0) {
2233 width = defaultCursorSize;
2234 height = defaultCursorSize;
2236 evas_object_resize(priv->cursorObject, width, height);
2240 data = edje_object_data_get(priv->cursorObject, "hot.x");
2242 hotspotX = atoi(data);
2245 data = edje_object_data_get(priv->cursorObject, "hot.y");
2247 hotspotY = atoi(data);
2249 ecore_evas_object_cursor_set(ecoreEvas, priv->cursorObject, EVAS_LAYER_MAX, hotspotX, hotspotY);
2252 void ewk_view_display(Evas_Object* ewkView, const IntRect& rect)
2254 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2255 if (!smartData->image)
2258 evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height());
2263 * A download for that view was cancelled.
2265 * Emits signal: "download,cancelled" with pointer to a Ewk_Download_Job.
2267 void ewk_view_download_job_cancelled(Evas_Object* ewkView, Ewk_Download_Job* download)
2269 evas_object_smart_callback_call(ewkView, "download,cancelled", download);
2274 * A new download has been requested for that view.
2276 * Emits signal: "download,request" with pointer to a Ewk_Download_Job.
2278 void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job* download)
2280 evas_object_smart_callback_call(ewkView, "download,request", download);
2285 * A download for that view has failed.
2287 * Emits signal: "download,failed" with pointer to a Ewk_Download_Job_Error.
2289 void ewk_view_download_job_failed(Evas_Object* ewkView, Ewk_Download_Job* download, Ewk_Web_Error* error)
2291 Ewk_Download_Job_Error downloadError = { download, error };
2292 evas_object_smart_callback_call(ewkView, "download,failed", &downloadError);
2297 * A download for that view finished successfully.
2299 * Emits signal: "download,finished" with pointer to a Ewk_Download_Job.
2301 void ewk_view_download_job_finished(Evas_Object* ewkView, Ewk_Download_Job* download)
2303 evas_object_smart_callback_call(ewkView, "download,finished", download);
2306 Eina_Bool ewk_view_back(Evas_Object* ewkView)
2308 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2309 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2311 WebPageProxy* page = priv->pageClient->page();
2312 if (page->canGoBack()) {
2320 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
2322 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2323 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2325 WebPageProxy* page = priv->pageClient->page();
2326 if (page->canGoForward()) {
2334 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
2336 #if ENABLE(WEB_INTENTS)
2337 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2338 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2339 EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
2341 WebPageProxy* page = priv->pageClient->page();
2342 page->deliverIntentToFrame(page->mainFrame(), toImpl(ewk_intent_WKIntentDataRef_get(intent)));
2350 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
2352 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2353 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2355 return priv->pageClient->page()->canGoBack();
2358 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
2360 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2361 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2363 return priv->pageClient->page()->canGoForward();
2366 void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size)
2368 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2369 if (!imageData || !smartData->image)
2372 evas_object_resize(smartData->image, size.width(), size.height());
2373 evas_object_image_size_set(smartData->image, size.width(), size.height());
2374 evas_object_image_data_copy_set(smartData->image, imageData);
2379 * Reports that a form request is about to be submitted.
2381 * Emits signal: "form,submission,request" with pointer to Ewk_Form_Submission_Request.
2383 void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submission_Request* request)
2385 evas_object_smart_callback_call(ewkView, "form,submission,request", request);
2388 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2389 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
2391 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2392 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2394 if (!ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
2397 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(ewkView);
2398 if (!imfContext || ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
2401 if (value.isEmpty()) {
2402 if(smartData->api->formdata_candidate_is_showing(smartData))
2403 smartData->api->formdata_candidate_hide(smartData);
2407 Vector<String> popupCandidates;
2408 ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
2409 std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
2411 Eina_List* candidateList = 0;
2412 for (size_t i = 0; i < popupCandidates.size(); ++i) {
2413 if (popupCandidates[i].startsWith(value, false))
2414 candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
2417 if (!eina_list_count(candidateList)) {
2418 if(smartData->api->formdata_candidate_is_showing(smartData))
2419 smartData->api->formdata_candidate_hide(smartData);
2423 smartData->api->formdata_candidate_update_data(smartData, candidateList);
2425 if (!smartData->api->formdata_candidate_is_showing(smartData))
2426 smartData->api->formdata_candidate_hide(smartData);
2428 IntRect inputFieldRect = priv->pageClient->focusedNodeRect();
2429 smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
2432 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm)
2434 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2435 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2436 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
2437 && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
2439 ewk_context_form_data_add(ewk_view_context_get(ewkView), priv->uri, formData, isPasswordForm);
2442 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
2444 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2445 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2447 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
2450 Vector<std::pair<String, String> > passwordFormData;
2451 ewk_context_form_password_data_get(ewk_view_context_get(ewkView), priv->uri, passwordFormData);
2453 if (!passwordFormData.size())
2456 String passwordFormAutofill = "try { function passwordFormAutofill() { var inputFields;";
2457 for (size_t i = 0; i < passwordFormData.size(); i++) {
2458 passwordFormAutofill += String::format(" inputFields = document.getElementsByName(\"%s\");"
2459 " for (var i = 0; i < inputFields.length; i++)"
2460 " if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\"))"
2461 " inputFields[i].value = \"%s\";",
2462 passwordFormData[i].first.utf8().data(), passwordFormData[i].second.utf8().data());
2464 passwordFormAutofill += "} passwordFormAutofill(); } catch(e) { }";
2465 ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
2468 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
2470 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2471 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2472 ewk_context_form_candidate_data_get(ewk_view_context_get(ewkView), name, candidates);
2478 * Reports load failed with error information.
2480 * Emits signal: "load,error" with pointer to Ewk_Web_Error.
2482 void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error)
2484 evas_object_smart_callback_call(ewkView, "load,error", const_cast<Ewk_Web_Error*>(error));
2489 * Reports load finished.
2491 * Emits signal: "load,finished".
2493 void ewk_view_load_finished(Evas_Object* ewkView)
2495 ewk_view_uri_update(ewkView);
2496 evas_object_smart_callback_call(ewkView, "load,finished", 0);
2498 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2499 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2501 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
2502 priv->pageClient->page()->setLoadingFinished(true);
2505 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2506 ewk_view_form_password_data_fill(ewkView);
2509 if (!priv->suspendRequested)
2512 priv->suspendRequested = false;
2514 if (!priv->suspendedPainting) {
2515 priv->pageClient->page()->suspendPainting();
2516 priv->suspendedPainting = true;
2518 if (!priv->suspendedResources) {
2519 priv->pageClient->page()->suspendJavaScriptAndResource();
2520 priv->suspendedResources = true;
2526 * Reports view provisional load failed with error information.
2528 * Emits signal: "load,provisional,failed" with pointer to Ewk_Web_Error.
2530 void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Web_Error* error)
2532 evas_object_smart_callback_call(ewkView, "load,provisional,failed", const_cast<Ewk_Web_Error*>(error));
2537 * Reports view received redirect for provisional load.
2539 * Emits signal: "load,provisional,redirect".
2541 void ewk_view_load_provisional_redirect(Evas_Object* ewkView)
2543 ewk_view_uri_update(ewkView);
2544 evas_object_smart_callback_call(ewkView, "load,provisional,redirect", 0);
2549 * Reports view provisional load started.
2551 * Emits signal: "load,provisional,started".
2553 void ewk_view_load_provisional_started(Evas_Object* ewkView)
2556 evas_object_smart_callback_call(ewkView, "load,started", 0);
2559 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2560 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2562 #if ENABLE(TIZEN_DRAG_SUPPORT)
2563 if (priv->pageClient->isDragMode())
2564 priv->pageClient->setDragMode(false);
2567 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
2568 priv->pageClient->page()->setLoadingFinished(false);
2571 // The main frame started provisional load, we should clear
2572 // the loadingResources HashMap to start clean.
2573 _ewk_view_priv_loading_resources_clear(priv->loadingResourcesMap);
2575 ewk_view_uri_update(ewkView);
2576 evas_object_smart_callback_call(ewkView, "load,provisional,started", 0);
2581 * Reports that a navigation policy decision should be taken.
2583 * Emits signal: "policy,decision,navigation".
2585 void ewk_view_navigation_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision)
2587 evas_object_smart_callback_call(ewkView, "policy,decision,navigation", decision);
2592 * Reports that a new window policy decision should be taken.
2594 * Emits signal: "policy,decision,new,window".
2596 void ewk_view_new_window_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision)
2598 evas_object_smart_callback_call(ewkView, "policy,decision,new,window", decision);
2601 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
2603 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2604 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2605 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
2607 if (unreachableUrl && *unreachableUrl)
2608 priv->pageClient->page()->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
2610 priv->pageClient->page()->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
2611 ewk_view_uri_update(ewkView);
2616 #if ENABLE(WEB_INTENTS_TAG)
2619 * The view received a new intent service registration.
2621 * Emits signal: "intent,service,register" with pointer to a Ewk_Intent_Service.
2623 void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Service* ewkIntentService)
2625 evas_object_smart_callback_call(ewkView, "intent,service,register", const_cast<Ewk_Intent_Service*>(ewkIntentService));
2627 #endif // ENABLE(WEB_INTENTS_TAG)
2629 WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView)
2631 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2632 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2634 return priv->pageClient->page();
2637 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
2639 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2640 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2642 String customEncoding = priv->pageClient->page()->customTextEncodingName();
2643 if (customEncoding.isEmpty())
2646 eina_stringshare_replace(&priv->customEncoding, customEncoding.utf8().data());
2648 return priv->customEncoding;
2651 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
2653 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2654 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2656 if (eina_stringshare_replace(&priv->customEncoding, encoding))
2657 priv->pageClient->page()->setCustomTextEncodingName(encoding ? String::fromUTF8(encoding) : String());
2663 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
2665 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2666 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2667 return priv->context;
2670 // FIXME: It should be removed.
2671 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
2673 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2674 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2676 return toAPI(priv->pageClient->page());
2679 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
2681 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2682 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2684 enabled = !!enabled;
2685 if (priv->areMouseEventsEnabled == enabled)
2688 priv->areMouseEventsEnabled = enabled;
2690 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down, smartData);
2691 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up, smartData);
2692 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move, smartData);
2694 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
2695 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
2696 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
2702 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
2704 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2705 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2707 return priv->areMouseEventsEnabled;
2710 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
2712 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2713 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2715 return priv->javascriptPopup->alert(alertText);
2718 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
2720 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2721 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2723 return priv->javascriptPopup->confirm(message);
2726 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
2728 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2729 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2731 return priv->javascriptPopup->prompt(message, defaultValue);
2734 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
2735 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, void* userData)
2737 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2738 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2740 return priv->javascriptPopup->beforeUnloadConfirmPanel(message);
2744 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)
2746 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2747 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2749 return priv->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, priv);
2752 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
2753 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)
2755 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2757 if (priv->popupPicker)
2758 ewk_popup_picker_del(priv->popupPicker);
2760 #if ENABLE(TIZEN_MULTIPLE_SELECT)
2761 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
2763 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
2769 #if ENABLE(TIZEN_MULTIPLE_SELECT)
2770 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)
2772 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2774 if (priv->popupPicker)
2775 ewk_popup_picker_del(priv->popupPicker);
2777 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
2783 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
2785 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2787 if (!priv->popupPicker)
2790 ewk_popup_picker_del(priv->popupPicker);
2791 priv->popupPicker = 0;
2796 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)
2798 // FIXME: The rect should be updated if it was changed
2800 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2802 if (!priv->popupPicker)
2805 ewk_popup_picker_update(smartData->self, priv->popupPicker, items, selectedIndex);
2811 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
2812 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
2814 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2816 priv->inputPicker->show(inputType, inputValue);
2821 #if ENABLE(TIZEN_DATALIST_ELEMENT)
2822 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
2824 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2826 priv->inputPicker->showDataList(inputType, optionList);
2830 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
2832 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2834 priv->inputPicker->hideDataList(inputType);
2839 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
2840 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
2842 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2844 priv->inputPicker->showColorPicker(r, g, b, a);
2848 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
2850 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2852 priv->inputPicker->hideColorPicker();
2857 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
2859 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2860 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2862 return priv->pageClient.get();
2865 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
2867 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
2868 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1);
2870 return WKPageGetTextZoomFactor(toAPI(priv->pageClient->page()));
2873 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
2875 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2876 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2878 WKPageSetTextZoomFactor(toAPI(priv->pageClient->page()), textZoomFactor);
2882 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
2883 FocusRing* ewkViewGetFocusRing(Evas_Object* ewkView)
2885 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2886 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2888 return priv->focusRing.get();
2892 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
2894 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2895 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2897 return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(priv->pageClient->page())));
2900 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
2902 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2903 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2905 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(priv->pageClient->page())));
2908 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
2910 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2911 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2913 if (!priv->javascriptGlobalContext)
2914 priv->javascriptGlobalContext = JSGlobalContextCreate(0);
2915 return priv->javascriptGlobalContext;
2918 void ewkViewLoadCommitted(Evas_Object* ewkView)
2920 #if ENABLE(TIZEN_GESTURE)
2921 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2922 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2923 priv->gestureClient->reset();
2925 #if ENABLE(TIZEN_ISF_PORT)
2926 ewk_view_imf_context_hide(ewkView);
2928 ewk_view_uri_update(ewkView);
2929 evas_object_smart_callback_call(ewkView, "load,committed", 0);
2932 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
2934 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2935 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2937 Ewk_Error* ewkError = ewkErrorCreate(error);
2938 ewkErrorLoadErrorPage(ewkError, toAPI(priv->pageClient->page()));
2939 evas_object_smart_callback_call(ewkView, "load,error", ewkError);
2940 ewkErrorDelete(ewkError);
2943 void ewkViewSetTitleAndURL(Evas_Object* ewkView, const char* title, const char* url)
2945 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2946 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2948 if (title && eina_stringshare_replace(&priv->title, title))
2949 evas_object_smart_callback_call(ewkView, "title,changed", static_cast<void*>(const_cast<char*>(priv->title)));
2950 if (url && eina_stringshare_replace(&priv->uri, url))
2951 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
2954 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
2956 #if ENABLE(TIZEN_GESTURE)
2957 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2958 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2959 priv->gestureClient->reset();
2961 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
2964 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
2966 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2967 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2969 if (priv->authChallenge)
2970 ewkAuthChallengeDelete(priv->authChallenge);
2971 priv->authChallenge = authChallenge;
2973 evas_object_smart_callback_call(ewkView, "authentication,challenge", priv->authChallenge);
2976 void ewk_view_process_crashed(Evas_Object* ewkView)
2978 bool handled = false;
2979 evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
2985 #if ENABLE(TIZEN_SQL_DATABASE)
2986 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)
2988 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, currentQuota);
2989 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, currentQuota);
2991 TIZEN_LOGI("database,quota,exceeded");
2992 uint64_t defaultQuota = ewkContextGetDatabaseQuota(priv->context);
2993 if (defaultQuota >= expectedUsage + currentQuota)
2994 return defaultQuota;
2996 if (priv->exceededDatabaseQuota)
2997 ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
2998 priv->exceededDatabaseQuota = ewkContextCreateExceededQuota(origin, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
2999 evas_object_smart_callback_call(ewkView, "database,quota,exceeded", priv->exceededDatabaseQuota);
3001 return ewkContextGetNewQuotaForExceededQuota(priv->context, priv->exceededDatabaseQuota);
3005 #if ENABLE(TIZEN_NOTIFICATIONS)
3006 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
3008 TIZEN_LOGI("notification,cancel");
3009 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
3012 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
3014 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3015 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3017 TIZEN_LOGI("notification,permission,request");
3018 priv->notificationPermissionRequests = eina_list_append(priv->notificationPermissionRequests, notificationPermissionRequest);
3019 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
3022 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
3024 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3025 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3027 TIZEN_LOGI("notification,show");
3028 Eina_List* listIterator=0;
3030 const char* replaceID = ewkNotificationGetReplaceID(notification);
3031 if(strlen(replaceID)) {
3032 EINA_LIST_FOREACH(priv->notifications, listIterator, data) {
3033 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
3034 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
3035 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
3039 priv->notifications = eina_list_append(priv->notifications, notification);
3040 evas_object_smart_callback_call(ewkView, "notification,show", notification);
3043 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
3045 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3046 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3048 priv->notificationPermissionRequests = eina_list_remove(priv->notificationPermissionRequests, ewkNotificationPermissionRequest);
3052 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
3053 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
3055 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3057 TIZEN_LOGI("protocolhandler,registration,requested");
3058 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
3059 evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
3060 ewkCustomHandlersDeleteData(customHandlersData);
3064 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
3065 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
3067 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
3069 TIZEN_LOGI("protocolhandler,isregistered");
3070 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
3071 evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
3073 Ewk_Custom_Handlers_State result;
3074 result = ewkGetCustomHandlersDataResult(customHandlersData);
3075 ewkCustomHandlersDeleteData(customHandlersData);
3080 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
3082 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3084 TIZEN_LOGI("protocolhandler,unregistration,requested");
3085 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
3086 evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
3087 ewkCustomHandlersDeleteData(customHandlersData);
3091 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
3092 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
3094 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3096 TIZEN_LOGI("contenthandler,registration,requested");
3097 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
3098 evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
3099 ewkCustomHandlersDeleteData(customHandlersData);
3102 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
3104 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
3106 TIZEN_LOGI("contenthandler,isregistered");
3107 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
3108 evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
3110 Ewk_Custom_Handlers_State result;
3111 result = ewkGetCustomHandlersDataResult(customHandlersData);
3112 ewkCustomHandlersDeleteData(customHandlersData);
3117 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
3119 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3121 TIZEN_LOGI("contenthandler,unregistration,requested");
3122 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
3123 evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
3124 ewkCustomHandlersDeleteData(customHandlersData);
3128 #if ENABLE(TIZEN_SEARCH_PROVIDER)
3129 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
3131 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3133 TIZEN_LOGI("searchProvider,add");
3134 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
3135 evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
3136 ewkSearchProviderDeleteData(searchProviderData);
3139 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
3141 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3143 TIZEN_LOGI("searchProvider,installed");
3144 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
3145 evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
3146 unsigned long result;
3147 result = ewkGetSearchProviderResult(searchProviderData);
3148 ewkSearchProviderDeleteData(searchProviderData);
3153 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3154 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
3156 bool standalone = true;
3157 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
3162 #if ENABLE(TIZEN_MEDIA_STREAM)
3163 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
3165 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3166 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3168 priv->userMediaPermissionRequests = eina_list_append(priv->userMediaPermissionRequests, userMediaPermission);
3169 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
3172 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
3174 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3175 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3177 priv->userMediaPermissionRequests = eina_list_remove(priv->userMediaPermissionRequests, permission);
3182 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
3183 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
3185 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
3186 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
3187 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
3188 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
3189 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
3190 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
3192 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
3196 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
3197 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
3199 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3200 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3201 if (priv->certificatePolicyDecision)
3202 ewkCertificatePolicyDecisionDelete(priv->certificatePolicyDecision);
3203 priv->certificatePolicyDecision = certificatePolicyDecision;
3205 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
3209 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
3211 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
3214 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
3216 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
3219 void ewkViewClosePage(Evas_Object* ewkView)
3221 evas_object_smart_callback_call(ewkView, "close,window", 0);
3224 #if ENABLE(TIZEN_GEOLOCATION)
3225 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
3227 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3228 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3230 TIZEN_LOGI("geolocation,permission,request");
3231 priv->geolocationPermissionRequests = eina_list_append(priv->geolocationPermissionRequests, geolocationPermissionRequest);
3232 evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
3235 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
3237 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3238 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3240 priv->geolocationPermissionRequests = eina_list_remove(priv->geolocationPermissionRequests, geolocationPermissionRequest);
3243 void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
3245 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3246 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3248 priv->geolocation = geolocation;
3251 Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
3253 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3254 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3256 return priv->geolocation;
3259 bool ewkViewIsValidLocationService(Evas_Object* ewkView)
3261 TIZEN_LOGI("geolocation,valid");
3264 evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
3269 WKPageRef ewkViewCreateNewPage(Evas_Object* ewkView)
3271 Evas_Object* createdEwkView = 0;
3273 evas_object_smart_callback_call(ewkView, "create,window", &createdEwkView);
3275 if (!createdEwkView)
3278 return static_cast<WKPageRef>(WKRetain(toAPI(ewk_view_page_get(createdEwkView))));
3281 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
3283 evas_object_smart_callback_call(ewkView, "form,submit", formData);
3286 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3288 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3289 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3290 if (priv->policyDecision)
3291 ewkPolicyDecisionDelete(priv->policyDecision);
3292 priv->policyDecision = policyDecision;
3294 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", priv->policyDecision);
3297 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3299 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3300 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3301 if (priv->policyDecision)
3302 ewkPolicyDecisionDelete(priv->policyDecision);
3303 priv->policyDecision = policyDecision;
3305 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", priv->policyDecision);
3308 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3310 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3311 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3312 if (priv->policyDecision)
3313 ewkPolicyDecisionDelete(priv->policyDecision);
3314 priv->policyDecision = policyDecision;
3316 evas_object_smart_callback_call(ewkView, "policy,response,decide", priv->policyDecision);
3319 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
3321 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3322 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3324 IntPoint scrollPosition = priv->pageClient->scrollPosition();
3325 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3326 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3327 contentsSize.scale(priv->pageClient->scaleFactor());
3330 // some website's contents size is smaller than view size,
3331 // so we have to adjust contents size to view size for that case.
3332 if (contentsSize.width() < smartData->view.w)
3333 contentsSize.setWidth(smartData->view.w);
3334 if (contentsSize.height() < smartData->view.h)
3335 contentsSize.setHeight(smartData->view.h);
3337 // Call "scroll,down" if webview can be scrolled down.
3338 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
3339 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
3340 // Call "scroll,up" if webview can be scrolled up.
3341 else if (deltaY < 0 && scrollPosition.y() > 0)
3342 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
3344 // Call "scroll,right" if webview can be scrolled down.
3345 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
3346 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
3347 // Call "scroll,left" if webview can be scrolled up.
3348 else if (deltaX < 0 && scrollPosition.x() > 0)
3349 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
3352 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
3354 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3355 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3357 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3358 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3359 contentsSize.scale(priv->pageClient->scaleFactor());
3362 int maxScrollY = contentsSize.height() - smartData->view.h;
3363 if (!priv->isVerticalEdge) {
3364 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
3365 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
3366 priv->isVerticalEdge = true;
3367 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
3368 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
3369 priv->isVerticalEdge = true;
3372 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
3373 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
3374 priv->isVerticalEdge = false;
3377 int maxScrollX = contentsSize.width() - smartData->view.w;
3378 if (!priv->isHorizontalEdge) {
3379 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
3380 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
3381 priv->isHorizontalEdge = true;
3382 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
3383 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
3384 priv->isHorizontalEdge = true;
3387 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
3388 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
3389 priv->isHorizontalEdge = false;
3393 void ewkViewClearEdges(Evas_Object* ewkView)
3395 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3396 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3398 priv->isVerticalEdge = false;
3399 priv->isHorizontalEdge = false;
3402 void ewk_view_top_of_contents_go(Evas_Object* ewkView)
3404 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3405 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3407 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3408 priv->pageClient->setVisibleContentRect(IntRect(IntPoint(), ewk_view_size_get(ewkView)), priv->pageClient->scaleFactor());
3410 priv->pageClient->page()->scrollMainFrameTo(IntPoint());
3414 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
3416 EWK_VIEW_SD_GET(ewkView, smartData);
3417 if (!smartData || !smartData->priv) {
3425 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
3427 *minimumScale = constraints.minimumScale;
3429 *maximumScale = constraints.maximumScale;
3432 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard)
3434 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3435 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3437 double scaleFactor = priv->pageClient->scaleFactor();
3438 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3440 double newScaleFactor = scaleFactor;
3441 // Readable zoom value is dependent on device DPI
3442 if (scaleFactor < priv->pageClient->page()->deviceScaleFactor()
3443 && priv->pageClient->viewportConstraints().userScalable)
3444 newScaleFactor = priv->pageClient->page()->deviceScaleFactor();
3446 // Readable zoom value should be inside of viewport scale range
3447 newScaleFactor = priv->pageClient->adjustScaleWithViewport(newScaleFactor);
3449 // scale contents' size with new scale factor
3450 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3451 contentsSize.scale(newScaleFactor);
3453 contentsSize.scale(newScaleFactor / scaleFactor);
3456 #if ENABLE(TIZEN_ISF_PORT)
3457 Ecore_X_Window rootWin = ecore_x_window_root_first_get();
3458 ecore_x_event_mask_set(rootWin, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
3459 Ecore_X_Atom xAtom = ecore_x_atom_get("X External Keyboard Exist");
3460 unsigned int connectedKeyboardNum = 0;
3461 bool isExternalKeyboardConnected = false;
3463 // get connected keyboard number
3464 if (ecore_x_window_prop_card32_get(rootWin, xAtom, &connectedKeyboardNum, 1)
3465 && connectedKeyboardNum)
3466 isExternalKeyboardConnected = true;
3468 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
3469 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
3470 // input field zoom should not work with below conditions
3471 // 1. view is not focused
3472 // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
3473 // 3. imfContext is null(if adjustForExternalKeyboard is false)
3474 // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
3475 if ((!(static_cast<PageClient*>(priv->pageClient.get()))->isViewFocused()
3476 || (adjustForExternalKeyboard && !isExternalKeyboardConnected)
3477 || (!adjustForExternalKeyboard && !priv->imfContext)
3478 || (!adjustForExternalKeyboard && ecore_imf_context_input_panel_state_get(priv->imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE))
3479 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
3480 && !(priv->pageClient->isClipboardWindowOpened())
3486 IntSize visibleSize(smartData->view.w, smartData->view.h);
3487 // caret position can be outside of visible rect.
3488 // we need to consider it.
3489 IntRect selectionRect = priv->pageClient->page()->getSelectionRect(true);
3490 IntRect focusedNodeRect = priv->pageClient->focusedNodeRect();
3491 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3492 selectionRect.scale(newScaleFactor);
3493 focusedNodeRect.scale(newScaleFactor);
3495 selectionRect.scale(newScaleFactor / scaleFactor);
3496 focusedNodeRect.scale(newScaleFactor / scaleFactor);
3498 if (selectionRect.isEmpty())
3502 IntPoint scrollPosition(selectionRect.x() - visibleSize.width() / 3, selectionRect.y() - visibleSize.height() / 3);
3503 // If both input field's position x and selection rect can be displayed together,
3504 // adjust scroll position to input field's position x.
3505 if (!focusedNodeRect.isEmpty()
3506 && selectionRect.x() - focusedNodeRect.x() < visibleSize.width() * 4 / 5)
3507 scrollPosition.setX(focusedNodeRect.x());
3509 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3510 priv->pageClient->setVisibleContentRect(IntRect(scrollPosition, ewk_view_size_get(ewkView)), newScaleFactor);
3512 if (newScaleFactor != scaleFactor)
3513 priv->pageClient->page()->scalePage(newScaleFactor, scrollPosition);
3515 priv->pageClient->page()->scrollMainFrameTo(scrollPosition);
3517 evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
3521 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
3522 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
3523 static Eina_Bool _ewk_view_composite(void* data)
3525 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
3526 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
3528 if (!evas_object_visible_get(smartData->image))
3529 return ECORE_CALLBACK_CANCEL;
3532 evas_object_image_size_get(smartData->image, &ow, &oh);
3533 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
3535 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)));
3536 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
3538 cairo_save(context.get());
3539 cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
3540 cairo_rectangle(context.get(), 0, 0, ow, oh);
3541 cairo_fill(context.get());
3542 cairo_restore(context.get());
3544 priv->pageClient->drawContents(context.get());
3546 evas_object_image_data_set(smartData->image, pixels);
3547 evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
3549 ewkViewFrameRendered(smartData->self);
3551 priv->compositionAnimator = 0;
3553 return ECORE_CALLBACK_CANCEL;
3557 void ewk_view_mark_for_sync(Evas_Object* ewkView)
3559 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3560 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
3562 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
3563 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3565 if (!ewk_view_is_opengl_backend(ewkView)) {
3566 if (!priv->compositionAnimator)
3567 priv->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
3572 evas_object_image_pixels_dirty_set(smartData->image, true);
3575 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
3577 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
3578 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3579 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3580 priv->pageClient->drawContents();
3583 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
3585 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3586 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3588 if (!smartData->image)
3591 evas_object_image_native_surface_set(smartData->image, nativeSurface);
3592 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
3598 void _ewk_view_suspend_painting(Evas_Object* ewkView)
3600 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3601 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3603 if (!priv->suspendedPainting) {
3604 priv->pageClient->page()->suspendPainting();
3605 priv->suspendedPainting = true;
3609 void _ewk_view_resume_painting(Evas_Object* ewkView)
3611 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3612 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3614 if (priv->suspendedPainting) {
3615 priv->pageClient->page()->resumePainting();
3616 priv->suspendedPainting = false;
3620 void ewk_view_suspend(Evas_Object* ewkView)
3622 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3623 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3625 if (priv->pageClient->page()->estimatedProgress() < 1.0) {
3626 priv->suspendRequested = true;
3629 priv->suspendRequested = false;
3631 _ewk_view_suspend_painting(ewkView);
3633 // FIXME Workaround for suspend/resume while javascript popup is displayed.
3634 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
3635 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
3637 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
3638 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
3639 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
3640 // will be suspended again.
3641 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
3642 // the ActiveDOMObject.
3643 if (!priv->suspendedResources && !priv->isWaitingForJavaScriptPopupReply) {
3644 priv->pageClient->page()->suspendJavaScriptAndResource();
3645 priv->suspendedResources = true;
3648 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
3649 priv->pageClient->page()->suspendPlugin();
3653 void ewk_view_resume(Evas_Object* ewkView)
3655 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3656 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3658 if (priv->suspendRequested) {
3659 priv->suspendRequested = false;
3663 _ewk_view_resume_painting(ewkView);
3665 // FIXME Workaround for suspend/resume while javascript popup is displayed.
3666 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
3667 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
3669 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
3670 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
3671 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
3672 // will be suspended again.
3673 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
3674 // the ActiveDOMObject.
3675 if (priv->suspendedResources && !priv->isWaitingForJavaScriptPopupReply) {
3676 priv->pageClient->page()->resumeJavaScriptAndResource();
3677 priv->suspendedResources = false;
3680 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
3681 priv->pageClient->page()->resumePlugin();
3685 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
3687 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3688 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3689 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
3691 ResourceRequest request(String::fromUTF8(url));
3694 case EWK_HTTP_METHOD_GET:
3695 request.setHTTPMethod("GET");
3697 case EWK_HTTP_METHOD_HEAD:
3698 request.setHTTPMethod("HEAD");
3700 case EWK_HTTP_METHOD_POST:
3701 request.setHTTPMethod("POST");
3703 case EWK_HTTP_METHOD_PUT:
3704 request.setHTTPMethod("PUT");
3706 case EWK_HTTP_METHOD_DELETE:
3707 request.setHTTPMethod("DELETE");
3714 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
3716 while (eina_iterator_next(it, &data)) {
3717 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
3718 const char* name = static_cast<const char*>(t->key);
3719 const char* value = static_cast<const char*>(t->data);
3720 request.addHTTPHeaderField(name, value);
3722 eina_iterator_free(it);
3726 request.setHTTPBody(FormData::create(body));
3728 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
3729 WKPageLoadURLRequest(toAPI(priv->pageClient->page()), urlRequest.get());
3734 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
3736 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3737 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3739 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
3740 WKPageLoadPlainTextString(toAPI(priv->pageClient->page()), plainTextRef.get());
3745 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
3747 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3748 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3749 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
3751 if (contentsSize == 0)
3754 String mimeTypeString;
3756 mimeTypeString = String::fromUTF8(mimeType);
3758 mimeTypeString = String::fromUTF8("text/html");
3760 String encodingString;
3762 encodingString = String::fromUTF8(encoding);
3764 encodingString = String::fromUTF8("UTF-8");
3766 String baseUriString;
3768 baseUriString = String::fromUTF8(baseUri);
3770 baseUriString = String::fromUTF8("about:blank");
3772 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
3773 priv->pageClient->page()->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
3778 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
3780 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3781 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3783 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
3784 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
3786 WKPageLoadHTMLString(toAPI(priv->pageClient->page()), htmlString.get(), baseURL.get());
3791 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
3793 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3794 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3796 TIZEN_LOGI("initialState (%d)", initialState);
3797 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
3798 WKPageSetPageVisibility(toAPI(priv->pageClient->page()), static_cast<WKPageVisibilityState
3799 >(pageVisibilityState), initialState);
3807 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
3809 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
3811 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3812 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3814 eina_stringshare_replace(&priv->userAgent, userAgent);
3816 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
3817 WKPageSetCustomUserAgent(toAPI(priv->pageClient->page()), userAgentString.get());
3822 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
3824 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3825 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3827 if (!priv->userAgent) {
3828 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(priv->pageClient->page())));
3830 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
3831 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3832 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
3833 eina_stringshare_replace(&priv->userAgent, buffer.get());
3836 return priv->userAgent;
3838 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
3840 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3841 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3842 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3844 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
3845 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
3847 WKPageAddCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get(), customHeaderValue.get());
3850 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3855 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
3857 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3858 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3859 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3861 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
3863 WKPageRemoveCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get());
3866 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3871 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
3873 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3874 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3875 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3877 WKPageClearCustomHeaders(toAPI(priv->pageClient->page()));
3880 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3885 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
3886 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
3888 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3889 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3891 priv->pageClient->setIsVisible(enable);
3896 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
3898 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
3900 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3901 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3904 rect.origin.x = viewArea.x;
3905 rect.origin.y = viewArea.y;
3906 rect.size.width = viewArea.w;
3907 rect.size.height = viewArea.h;
3909 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(priv->pageClient->page()), rect, scaleFactor));
3910 if (!snapshot.get())
3913 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
3915 Evas_Object* screenshotImage = evas_object_image_add(canvas);
3916 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
3917 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
3918 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
3919 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
3921 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
3923 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)));
3924 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
3926 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
3927 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
3928 cairo_fill(cairo.get());
3930 evas_object_image_smooth_scale_set(screenshotImage, true);
3931 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
3932 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
3933 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
3934 evas_object_image_data_set(screenshotImage, pixels);
3936 return screenshotImage;
3939 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
3941 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
3942 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
3943 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, 0);
3945 return priv->pageClient->page()->startInspectorServer(port);
3947 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
3952 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
3954 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
3955 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
3956 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
3958 return priv->pageClient->page()->stopInspectorServer();
3960 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
3965 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
3967 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3968 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3970 WKPageScrollBy(toAPI(priv->pageClient->page()), toAPI(IntSize(deltaX, deltaY)));
3973 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
3979 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3980 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3982 IntPoint scrollPosition = priv->pageClient->scrollPosition();
3984 *x = scrollPosition.x();
3986 *y = scrollPosition.y();
3991 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
3993 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3994 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3996 priv->pageClient->page()->scrollMainFrameTo(IntPoint(x, y));
4000 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
4006 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4007 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4009 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4010 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
4011 contentsSize.scale(priv->pageClient->scaleFactor());
4014 if (width && contentsSize.width() > smartData->view.w)
4015 *width = contentsSize.width() - smartData->view.w;
4016 if (height && contentsSize.height() > smartData->view.h)
4017 *height = contentsSize.height() - smartData->view.h;
4021 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
4023 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4024 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4025 if (!priv->alertContext || !priv->alertContext->javascriptAlertCallback)
4027 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->alertContext->ewkView == ewkView, false);
4029 priv->isWaitingForJavaScriptPopupReply = true;
4030 int length = WKStringGetMaximumUTF8CStringSize(alertText);
4031 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
4032 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
4033 return priv->alertContext->javascriptAlertCallback(priv->alertContext->ewkView, alertTextBuffer.get(), priv->alertContext->userData) == EINA_TRUE;
4036 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
4038 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4039 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4040 if (!priv->confirmContext || !priv->confirmContext->javascriptConfirmCallback)
4042 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->confirmContext->ewkView == ewkView, false);
4044 priv->isWaitingForJavaScriptPopupReply = true;
4045 int length = WKStringGetMaximumUTF8CStringSize(message);
4046 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4047 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4048 return priv->confirmContext->javascriptConfirmCallback(priv->confirmContext->ewkView, messageBuffer.get(), priv->confirmContext->userData) == EINA_TRUE;
4051 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
4053 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4054 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4055 if (!priv->promptContext || !priv->promptContext->javascriptPromptCallback)
4057 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->promptContext->ewkView == ewkView, false);
4059 priv->isWaitingForJavaScriptPopupReply = true;
4060 int length = WKStringGetMaximumUTF8CStringSize(message);
4061 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4062 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4063 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
4064 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
4065 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
4066 return priv->promptContext->javascriptPromptCallback(priv->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), priv->promptContext->userData) == EINA_TRUE;
4069 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
4070 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
4072 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4073 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4074 if (!priv->beforeUnloadConfirmPanelContext || !priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
4076 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
4078 priv->isWaitingForJavaScriptPopupReply = true;
4079 int length = WKStringGetMaximumUTF8CStringSize(message);
4080 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4081 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4082 bool result = priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(priv->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), priv->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
4087 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
4089 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4090 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4091 if (!priv->openpanelContext || !priv->openpanelContext->openPanelCallback)
4094 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->openpanelContext->ewkView == ewkView, false);
4096 priv->openPanelListener = listener;
4098 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
4099 Eina_List* acceptedMimeTypes = 0;
4100 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
4101 size_t len = WKArrayGetSize(array.get());
4102 for (size_t i = 0; i < len; i++) {
4103 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
4104 if (WKGetTypeID(item) != WKStringGetTypeID())
4106 WKStringRef mime = static_cast<WKStringRef>(item);
4107 int length = WKStringGetMaximumUTF8CStringSize(mime);
4108 char* buffer = new char[length];
4109 WKStringGetUTF8CString(mime, buffer, length);
4110 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
4112 const char* capture = 0;
4113 #if ENABLE(MEDIA_CAPTURE)
4114 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
4115 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
4117 bool result = priv->openpanelContext->openPanelCallback(priv->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
4118 if (!acceptedMimeTypes)
4123 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
4124 delete[] (char*)data;
4125 eina_list_free(acceptedMimeTypes);
4129 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
4131 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4132 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4134 if (!priv->alertContext)
4135 priv->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4136 priv->alertContext->javascriptAlertCallback = callback;
4137 priv->alertContext->ewkView = ewkView;
4138 priv->alertContext->userData = userData;
4141 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
4143 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4144 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4146 WKPageReplyJavaScriptAlert(toAPI(ewk_view_page_get(ewkView)));
4147 priv->isWaitingForJavaScriptPopupReply = false;
4150 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
4152 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4153 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4155 if (!priv->confirmContext)
4156 priv->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4157 priv->confirmContext->javascriptConfirmCallback = callback;
4158 priv->confirmContext->ewkView = ewkView;
4159 priv->confirmContext->userData = userData;
4162 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
4164 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4165 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4167 WKPageReplyJavaScriptConfirm(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
4168 priv->isWaitingForJavaScriptPopupReply = false;
4171 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
4173 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4174 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4176 if (!priv->promptContext)
4177 priv->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4178 priv->promptContext->javascriptPromptCallback = callback;
4179 priv->promptContext->ewkView = ewkView;
4180 priv->promptContext->userData = userData;
4183 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
4185 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4186 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4188 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
4189 WKPageReplyJavaScriptPrompt(toAPI(ewk_view_page_get(ewkView)), result ? resultString.get() : 0);
4190 priv->isWaitingForJavaScriptPopupReply = false;
4193 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
4194 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
4196 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4197 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4199 if (!priv->beforeUnloadConfirmPanelContext)
4200 priv->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4201 priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
4202 priv->beforeUnloadConfirmPanelContext->ewkView = ewkView;
4203 priv->beforeUnloadConfirmPanelContext->userData = userData;
4206 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
4208 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4209 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4211 WKPageReplyBeforeUnloadConfirmPanel(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
4212 priv->isWaitingForJavaScriptPopupReply = false;
4216 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
4218 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4219 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4221 if (!priv->openpanelContext)
4222 priv->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4224 priv->openpanelContext->openPanelCallback = callback;
4225 priv->openpanelContext->ewkView = ewkView;
4226 priv->openpanelContext->userData = userData;
4229 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
4231 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4232 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4234 if (!priv->openPanelListener)
4237 unsigned int size = eina_list_count(fileUrls);
4238 if ((result == EINA_FALSE) || (size == 0)) {
4239 WKOpenPanelResultListenerCancel(priv->openPanelListener);
4240 priv->openPanelListener = 0;
4244 WKTypeRef* items = new WKTypeRef[size];
4248 KURL base(KURL(), "file://");
4249 EINA_LIST_FOREACH(fileUrls, list, data) {
4250 KURL url(base, static_cast<char*>(data));
4251 items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
4253 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
4254 WKOpenPanelResultListenerChooseFiles(priv->openPanelListener, filesArray.get());
4255 priv->openPanelListener = 0;
4257 eina_list_free(fileUrls);
4260 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4261 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
4263 EINA_SAFETY_ON_NULL_RETURN(capable);
4264 EINA_SAFETY_ON_NULL_RETURN(context);
4266 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4268 ASSERT(webAppContext->webAppCapableCallback);
4271 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
4273 webAppContext->webAppCapableCallback(0, webAppContext->userData);
4275 delete webAppContext;
4278 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
4280 EINA_SAFETY_ON_NULL_RETURN(iconURL);
4281 EINA_SAFETY_ON_NULL_RETURN(context);
4283 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4285 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
4286 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4288 ASSERT(webAppContext->webAppIconURLCallback);
4291 eina_stringshare_replace(&priv->webAppIconURL, toImpl(iconURL)->string().utf8().data());
4292 webAppContext->webAppIconURLCallback(priv->webAppIconURL, webAppContext->userData);
4294 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
4296 delete webAppContext;
4300 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
4302 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4303 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4304 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4305 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4307 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4308 context->webAppCapableCallback = callback;
4309 context->ewkView = ewkView;
4310 context->userData = userData;
4312 WKPageGetWebAppCapable(toAPI(priv->pageClient->page()), context, didGetWebAppCapable);
4320 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
4322 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4323 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4324 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4325 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4327 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4328 context->webAppIconURLCallback = callback;
4329 context->ewkView = ewkView;
4330 context->userData = userData;
4332 WKPageGetWebAppIconURL(toAPI(priv->pageClient->page()), context, didGetWebAppIconURL);
4340 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
4342 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4343 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4344 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
4346 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
4347 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
4348 WKPageExecuteCommandWithArgument(toAPI(priv->pageClient->page()), commandString.get(), valueString.get());
4353 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4355 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4356 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4357 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4359 // FixMe: Comment should be removed when pageClient is removed.
4360 //priv->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4361 priv->pageClient->page()->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4366 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4368 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4369 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4371 // FixMe: Comment should be removed when pageClient is removed.
4372 //priv->pageProxy->hideFindUI();
4373 priv->pageClient->page()->hideFindUI();
4378 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
4385 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4386 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4388 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4391 *width = contentsSize.width();
4393 *height = contentsSize.height();
4398 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
4400 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
4401 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4402 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4403 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
4405 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4406 WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
4414 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, int width, int height, const char* fileName)
4416 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
4417 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4418 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4419 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
4421 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4422 WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
4430 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
4432 EINA_SAFETY_ON_NULL_RETURN(context);
4433 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4435 if (!callbackContext->scriptExecuteCallback) {
4436 delete callbackContext;
4440 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
4443 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
4444 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
4445 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
4446 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
4447 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
4448 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
4450 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
4452 delete callbackContext;
4455 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
4457 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4458 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4459 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
4460 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient, false);
4462 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4463 context->scriptExecuteCallback = callback;
4464 context->ewkView = ewkView;
4465 context->userData = user_data;
4466 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
4467 WKPageRunJavaScriptInMainFrame(toAPI(priv->pageClient->page()), scriptString.get(), context, runJavaScriptCallback);
4472 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
4473 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
4475 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
4478 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
4480 storageContext->webStorageQuotaCallback(0, storageContext->userData);
4482 delete storageContext;
4486 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
4488 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
4489 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
4490 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
4491 TIZEN_LOGI("resultCallback (%p)", resultCallback);
4493 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4494 context->webStorageQuotaCallback = resultCallback;
4495 context->userData = userData;
4497 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
4498 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
4506 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
4508 #if ENABLE(TIZEN_WEB_STORAGE)
4509 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
4511 TIZEN_LOGI("quota (%d)", quota);
4512 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
4513 WKPageSetWebStorageQuota(pageRef, quota);
4521 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
4523 EINA_SAFETY_ON_NULL_RETURN(context);
4524 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4526 ASSERT(callbackContext->plainTextGetCallback);
4529 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
4530 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
4531 WKStringGetUTF8CString(plain_text, buffer.get(), length);
4533 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
4535 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
4537 delete callbackContext;
4540 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
4542 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4543 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4544 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4545 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient, false);
4547 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4548 context->plainTextGetCallback = callback;
4549 context->ewkView = ewkView;
4550 context->userData = user_data;
4551 WKPageGetContentsAsString(toAPI(priv->pageClient->page()), context, getContentsAsStringCallback);
4556 #if ENABLE(TIZEN_SUPPORT_MHTML)
4559 * Callback function used for ewk_view_mhtml_data_get().
4561 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4563 EINA_SAFETY_ON_NULL_RETURN(context);
4564 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4566 ASSERT(callbackContext->mhtmlDataGetCallback);
4568 callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
4570 delete callbackContext;
4573 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
4575 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4576 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4577 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4579 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4580 context->mhtmlDataGetCallback = callback;
4581 context->ewkView = ewkView;
4582 context->userData = user_data;
4584 WKPageGetContentsAsMHTMLData(toAPI(priv->pageClient->page()), false, context, getContentsAsMHTMLCallback);
4588 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
4590 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
4592 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
4593 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4594 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4595 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, 0);
4597 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
4598 WebHitTestResult::Data hitTestResultData = priv->pageClient->page()->hitTestResultAtPoint(pointForHitTest, hitTestMode);
4599 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
4607 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
4609 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
4610 WebPageProxy* page = ewk_view_page_get(ewkView);
4611 EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
4613 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
4616 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
4618 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4619 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4621 WKPageRecordingSurfaceSetEnable(toAPI(priv->pageClient->page()), enable);
4626 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
4628 #if ENABLE(TIZEN_NOTIFICATIONS)
4629 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4630 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4631 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->context, false);
4633 TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
4634 if (!eina_list_count(ewkNotifications))
4637 Eina_List* listIterator = 0;
4639 Vector<WKTypeRef> ids;
4640 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
4641 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
4642 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
4644 priv->notifications = eina_list_remove(priv->notifications, notification);
4647 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
4648 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(ewk_context_WKContext_get(priv->context));
4649 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
4650 ewkNotificationDeleteNotificationList(ewkNotifications);
4658 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
4660 Eina_List* popupItems = 0;
4661 size_t size = items.size();
4662 for (size_t i = 0; i < size; ++i) {
4663 Ewk_Popup_Menu_Item* item = ewk_popup_menu_item_new(items[i].m_type,
4664 items[i].m_text.utf8().data(),
4665 items[i].m_textDirection,
4666 items[i].m_hasTextDirectionOverride,
4667 items[i].m_toolTip.utf8().data(),
4668 items[i].m_accessibilityText.utf8().data(),
4669 items[i].m_isEnabled,
4670 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4671 items[i].m_isSelected,
4673 items[i].m_isLabel);
4674 popupItems = eina_list_append(popupItems, item);
4676 TIZEN_LOGI("size : %d", size);
4680 static void releasePopupMenuList(Eina_List* popupMenuItems)
4682 if (!popupMenuItems)
4686 EINA_LIST_FREE(popupMenuItems, item)
4687 ewk_popup_menu_item_free(static_cast<Ewk_Popup_Menu_Item*>(item));
4690 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4691 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)
4693 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)
4696 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4697 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4698 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4699 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4703 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4704 if (!smartData->api->popup_menu_show && !smartData->api->multiple_popup_menu_show)
4706 if (!smartData->api->popup_menu_show)
4710 if (priv->popupMenuProxy)
4711 ewk_view_popup_menu_close(ewkView);
4712 priv->popupMenuProxy = popupMenu;
4714 priv->popupMenuItems = createPopupMenuList(items);
4716 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4717 if ((!multiple && smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems, selectedIndex)) ||
4718 (multiple && smartData->api->multiple_popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems))) {
4720 if (smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems, selectedIndex)) {
4722 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
4723 /* maps.google.com generate mouse event in touch down without preventDefault.
4724 * So, popup menu is opend in touch down event and closed via fake mouse down
4725 * which generated by endTap.
4726 * In order to fix select of maps.google.com (based on touch behavior),
4727 * We should disable touch events when select popup is open.
4730 #if ENABLE(TIZEN_GESTURE)
4731 priv->gestureClient->reset();
4733 ewk_view_touch_events_enabled_set(ewkView, false);
4738 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
4740 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4741 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4742 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4743 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4745 if (!priv->popupMenuProxy)
4748 priv->popupMenuProxy = 0;
4750 if (smartData->api->popup_menu_hide)
4751 smartData->api->popup_menu_hide(smartData);
4752 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
4753 ewk_view_touch_events_enabled_set(ewkView, true);
4756 releasePopupMenuList(priv->popupMenuItems);
4757 priv->popupMenuItems = 0;
4762 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
4764 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4765 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4766 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4767 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4769 if (!priv->popupMenuProxy)
4772 if (!smartData->api->popup_menu_update)
4775 releasePopupMenuList(priv->popupMenuItems);
4776 priv->popupMenuItems = createPopupMenuList(items);
4778 // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
4779 smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), priv->popupMenuItems, selectedIndex);
4782 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
4784 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4785 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4786 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
4787 TIZEN_LOGI("proxy : %p / index : %d", priv->popupMenuProxy, selectedIndex);
4789 if (!priv->popupMenuItems)
4792 if (selectedIndex >= eina_list_count(priv->popupMenuItems))
4795 priv->popupMenuProxy->valueChanged(selectedIndex);
4800 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4801 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
4803 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4804 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4805 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
4807 Vector<int> selectedIndex;
4809 if (!priv->popupMenuItems)
4814 itr = eina_inarray_iterator_new(changeList);
4815 EINA_ITERATOR_FOREACH(itr, data)
4817 int* pData = static_cast<int*>(data);
4818 selectedIndex.append(*pData);
4820 eina_iterator_free(itr);
4822 priv->popupMenuProxy->multipleValueChanged(selectedIndex);
4827 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
4829 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
4830 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4831 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4832 TIZEN_LOGI("orientation : %d", orientation);
4834 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
4837 if (priv->orientation == orientation)
4840 priv->orientation = orientation;
4842 priv->pageClient->page()->sendOrientationChangeEvent(orientation);
4846 void ewkViewFrameRendered(Evas_Object* ewkView)
4848 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
4851 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4852 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
4854 return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
4857 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
4859 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4860 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4861 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
4863 IntRect leftSelectionRect;
4864 IntRect rightSelectionRect;
4865 if (!priv->pageClient->page()->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
4878 AffineTransform contentToScreen = impl->transformToScene();
4879 leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
4880 rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
4882 leftRect->x = leftSelectionRect.x();
4883 leftRect->y = leftSelectionRect.y();
4884 leftRect->w = leftSelectionRect.width();
4885 leftRect->h = leftSelectionRect.height();
4887 rightRect->x = rightSelectionRect.x();
4888 rightRect->y = rightSelectionRect.y();
4889 rightRect->w = rightSelectionRect.width();
4890 rightRect->h = rightSelectionRect.height();
4895 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
4897 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4898 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4900 const CString selectedString = priv->pageClient->page()->getSelectionText().utf8();
4901 eina_stringshare_replace(&priv->selectedText, selectedString.data());
4903 return priv->selectedText;
4906 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
4908 return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
4911 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
4913 return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
4915 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4917 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4918 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
4920 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4921 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4922 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
4924 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
4928 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
4929 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
4931 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4932 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4933 IntPoint drawingPosition = (IntPoint)(priv->pageClient->visibleContentRect().location() - priv->pageClient->scrollPosition());
4935 *x = drawingPosition.x();
4937 *y = drawingPosition.y();
4939 *w = priv->pageClient->visibleContentRect().width();
4941 *h = priv->pageClient->visibleContentRect().height();
4945 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
4947 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4948 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4949 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4951 priv->pageClient->page()->setFocusedInputElementValue(String::fromUTF8(value));
4952 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4955 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
4957 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4958 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4959 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4961 eina_stringshare_replace(&priv->inputValue, priv->pageClient->page()->getFocusedInputElementValue().utf8().data());
4962 return priv->inputValue;
4965 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4968 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4969 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
4971 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4972 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4973 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4974 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
4977 ewkViewDataListHideRequest(ewkView, inputType);
4979 for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
4981 priv->dataList = eina_list_append(priv->dataList, eina_stringshare_add(value.utf8().data()));
4984 smartData->api->data_list_show(smartData, inputType, priv->dataList);
4987 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
4989 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4990 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4991 EINA_SAFETY_ON_NULL_RETURN(priv->dataList);
4992 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4993 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
4995 if (priv->dataList) {
4996 _ewk_view_data_list_del(priv->dataList);
5000 smartData->api->data_list_hide(smartData, inputType);
5004 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
5006 #if ENABLE(TIZEN_DATALIST_ELEMENT)
5007 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5008 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5010 if (priv->dataList) {
5011 _ewk_view_data_list_del(priv->dataList);
5015 ewk_view_focused_input_element_value_set(ewkView, value);
5019 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
5021 #if ENABLE(TIZEN_GESTURE)
5022 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
5023 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
5024 return priv->holdHorizontalPanning;
5030 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
5032 #if ENABLE(TIZEN_GESTURE)
5033 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5034 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5035 priv->holdHorizontalPanning = hold;
5039 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
5041 #if ENABLE(TIZEN_GESTURE)
5042 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
5043 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
5044 return priv->holdVerticalPanning;
5050 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
5052 #if ENABLE(TIZEN_GESTURE)
5053 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5054 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5055 priv->holdVerticalPanning = hold;
5059 void ewk_view_use_smart_selection_set(Evas_Object* ewkView, Eina_Bool use)
5061 #if ENABLE(TIZEN_GESTURE)
5062 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5063 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5064 priv->useSmartSelection = use;
5068 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
5070 #if ENABLE(TIZEN_GESTURE)
5071 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5072 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5074 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5075 if (priv->focusRing && wasHandled)
5076 priv->focusRing->hide();
5077 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5079 if (priv->areMouseEventsEnabled)
5082 // We have to check TouchStart, TouchMove and TouchEnd with handled.
5083 // The Pan and Flick will be enabled if Touch Start was not handled,
5084 // and Touch Move was not handled or did not occur.
5085 // Tap will be enabled if Touch Start and End was not handled
5086 // and Touch Move did not occur.
5087 // The gestures are disabled as a default.
5088 // o: handled, x: not handled
5089 // ------------------------------------------------------------
5090 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
5091 // ------------------------------------------------------------
5092 // o | o or x | o or x || disable | disable
5093 // x | o | o or x || disable | disable
5094 // x | x | o or x || disable | enable
5095 // x |not occured | x || enable | enable
5096 // ------------------------------------------------------------
5097 if (type == WebEvent::TouchStart) {
5098 priv->gestureClient->setGestureEnabled(!wasHandled);
5099 priv->wasHandledTouchStart = wasHandled;
5101 // Initialize wasHandledTouchMove to true and notify that to the application
5102 // to prevent applications scrolling at the beginning of touch.
5103 priv->wasHandledTouchMove = true;
5104 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&priv->wasHandledTouchMove));
5105 } else if (type == WebEvent::TouchMove) {
5106 priv->gestureClient->setMovingEnabled(!wasHandled);
5108 // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
5109 if (priv->wasHandledTouchStart)
5112 // Notify the result of touchmove to applications when handled value is changed
5113 // in order to make applications to choose whether scrolling its scrollable objects or not.
5114 if (priv->wasHandledTouchMove != wasHandled)
5115 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
5116 priv->wasHandledTouchMove = wasHandled;
5117 } else if (type == WebEvent::TouchEnd && !priv->exceedTouchMoveThreshold && !wasHandled) {
5118 priv->gestureClient->setMovingEnabled(!wasHandled);
5119 priv->gestureClient->setTapEnabled(!wasHandled);
5124 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
5125 void ewkViewDidGetTextStyleStateForSelection(Evas_Object* ewkView, int underlineState, int italicState, int boldState, const IntPoint& startPoint, const IntPoint& endPoint)
5127 Ewk_Text_Style* textStyle = ewkTextStyleCreate(underlineState, italicState, boldState, startPoint, endPoint);
5128 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
5129 ewkTextStyleDelete(textStyle);
5133 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
5134 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
5136 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5137 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
5139 TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
5140 if (!smartData->api->orientation_lock) {
5145 return smartData->api->orientation_lock(smartData, willLockOrientation);
5148 void ewk_view_orientation_unlock(Evas_Object* ewkView)
5150 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5151 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
5153 TIZEN_LOGI("ewkView (%p)", ewkView);
5154 if (!smartData->api->orientation_unlock) {
5159 smartData->api->orientation_unlock(smartData);
5163 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
5165 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
5166 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5167 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5168 TIZEN_LOGI("callbacks: %p / data: %p", func, data);
5170 priv->orientationLock.callback = func;
5171 priv->orientationLock.data = data;
5175 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
5176 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
5178 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
5179 TIZEN_LOGI("locked orientations : %d", orientations);
5181 if (priv->orientationLock.callback)
5182 return priv->orientationLock.callback(sd->self, true, orientations, priv->orientationLock.data);
5187 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
5189 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
5190 TIZEN_LOGI("unlock is requested");
5192 if (priv->orientationLock.callback)
5193 priv->orientationLock.callback(sd->self, false, 0, priv->orientationLock.data);
5197 void ewk_view_fullscreen_enter(Evas_Object* ewkView)
5199 TIZEN_LOGI("fullscreen,enterfullscreen");
5200 ewk_view_main_frame_scrollbar_visible_set(ewkView, false);
5201 evas_object_smart_callback_call(ewkView, "fullscreen,enterfullscreen", 0);
5204 void ewk_view_fullscreen_exit(Evas_Object* ewkView)
5206 TIZEN_LOGI("fullscreen,exitfullscreen");
5207 ewk_view_main_frame_scrollbar_visible_set(ewkView, true);
5208 evas_object_smart_callback_call(ewkView, "fullscreen,exitfullscreen", 0);
5211 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
5212 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
5214 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5216 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
5217 const char *engine = ecore_evas_engine_name_get(ee);
5218 if (engine && !strcmp(engine, "opengl_x11"))
5224 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
5226 #if ENABLE(TIZEN_GESTURE)
5227 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5228 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5230 priv->gestureClient->setZoomableArea(target, area);
5234 #if ENABLE(TIZEN_ISF_PORT)
5235 static void imfInputPanelStateEventCb(void* data, Ecore_IMF_Context* ctx, int state)
5237 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5238 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5240 if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
5241 evas_object_smart_callback_call(smartData->self, "editorclient,ime,closed", 0);
5242 LOG(ISF, "[SIGNAL] editorclient,ime,closed\n");
5243 } else if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
5244 evas_object_smart_callback_call(smartData->self, "editorclient,ime,opened", 0);
5245 LOG(ISF, "[SIGNAL] editorclient,ime,opened\n");
5249 static void imfInputPanelGeometryEventCb(void* data, Ecore_IMF_Context* ctx, int value)
5251 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5252 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5254 Eina_Rectangle rect;
5255 ecore_imf_context_input_panel_geometry_get(priv->imfContext, &rect.x, &rect.y, &rect.w, &rect.h);
5256 evas_object_smart_callback_call(smartData->self, "inputmethod,changed", &rect);
5257 LOG(ISF, "%s : [SIGNAL] inputmethod,changed (%d,%d,%d,%d)\n", __func__, rect.x, rect.y, rect.w, rect.h);
5260 static void imfCandidatePanelStateEventCb(void* data, Ecore_IMF_Context* ctx, int state)
5262 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5263 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5265 if (state == ECORE_IMF_CANDIDATE_PANEL_SHOW)
5266 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,opened", 0);
5268 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,closed", 0);
5271 static void imfCandidatePanelGeometryEventCb(void* data, Ecore_IMF_Context* ctx, int value)
5273 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5274 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5276 Eina_Rectangle rect;
5277 ecore_imf_context_candidate_panel_geometry_get(priv->imfContext, &rect.x, &rect.y, &rect.w, &rect.h);
5278 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,changed", &rect);
5281 static Eina_Bool imfRetrieveSurroundingCb(void* data, Ecore_IMF_Context* context, char** text, int* offset)
5283 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5284 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5286 if (!priv->pageClient->page()->focusedFrame() || (!text && !offset))
5289 String surroundingText;
5291 priv->pageClient->page()->getSurroundingTextAndCursorOffset(surroundingText, cursorOffset);
5294 CString utf8Text(surroundingText.utf8());
5295 size_t length = utf8Text.length();
5297 *text = static_cast<char*>(malloc((length + 1) * sizeof(char)));
5302 strncpy(*text, utf8Text.data(), length);
5303 (*text)[length] = 0;
5307 *offset = cursorOffset;
5312 static void imfPreeditChangedCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5314 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5315 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5317 priv->pageClient->imContextPreeditChanged(context);
5320 static void imfEventCommittedCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5322 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5323 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5325 priv->pageClient->imContextCommitted(context, static_cast<char*>(eventInfo));
5328 static void imfContextDeleteSurroundingCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5330 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5331 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5333 Ecore_IMF_Event_Delete_Surrounding* event = static_cast<Ecore_IMF_Event_Delete_Surrounding*>(eventInfo);
5337 priv->pageClient->page()->deleteSurroundingText(event->offset, event->n_chars);
5340 Ecore_IMF_Context* ewk_view_imf_context_get(Evas_Object* ewkView)
5342 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5343 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5345 return priv->imfContext;
5348 Ecore_IMF_Context* ewk_view_imf_context_set(Evas_Object* ewkView, Ecore_IMF_Input_Panel_Layout layout)
5350 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5351 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5353 Ecore_IMF_Context* imfContext;
5354 Eina_List* iterator;
5357 EINA_LIST_FOREACH(priv->imfContextList, iterator, data) {
5358 imfContext = static_cast<Ecore_IMF_Context*>(data);
5359 if (ecore_imf_context_input_panel_layout_get(imfContext) == layout) {
5360 priv->imfContext = imfContext;
5365 imfContext = ecore_imf_context_add(ecore_imf_context_default_id_get());
5369 ecore_imf_context_input_panel_enabled_set(imfContext, false);
5370 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, imfInputPanelStateEventCb, smartData);
5371 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, imfInputPanelGeometryEventCb, smartData);
5372 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, imfCandidatePanelStateEventCb, smartData);
5373 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, imfCandidatePanelGeometryEventCb, smartData);
5374 ecore_imf_context_retrieve_surrounding_callback_set(imfContext, imfRetrieveSurroundingCb, smartData); // Support for Auto Capitalization
5375 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, imfPreeditChangedCb, smartData);
5376 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_COMMIT, imfEventCommittedCb, smartData);
5377 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, imfContextDeleteSurroundingCb, smartData); //Support for Automatic Full Stop
5378 ecore_imf_context_input_panel_layout_set(imfContext, layout);
5380 priv->imfContextList = eina_list_append(priv->imfContextList, imfContext);
5381 priv->imfContext = imfContext;
5386 void ewk_view_imf_context_reset(Evas_Object* ewkView)
5388 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5389 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5391 if (!priv->imfContext)
5394 ecore_imf_context_reset(priv->imfContext);
5396 if (ecore_imf_context_input_panel_state_get(priv->imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
5397 priv->imfContext = 0;
5400 void ewk_view_imf_context_hide(Evas_Object* ewkView)
5402 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5403 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5405 if (!priv->imfContext)
5408 if (ecore_imf_context_input_panel_state_get(priv->imfContext) != ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
5409 ecore_imf_context_reset(priv->imfContext);
5410 ecore_imf_context_input_panel_hide(priv->imfContext);
5411 ecore_imf_context_focus_out(priv->imfContext);
5414 priv->imfContext = 0;
5417 static void _ewk_view_imf_context_destroy(Ewk_View_Private_Data* priv)
5419 if (!priv->imfContextList)
5423 EINA_LIST_FREE(priv->imfContextList, item) {
5424 Ecore_IMF_Context* imfContext = static_cast<Ecore_IMF_Context*>(item);
5428 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, imfInputPanelStateEventCb);
5429 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, imfInputPanelGeometryEventCb);
5430 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, imfCandidatePanelStateEventCb);
5431 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, imfCandidatePanelGeometryEventCb);
5432 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, imfPreeditChangedCb);
5433 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_COMMIT, imfEventCommittedCb);
5434 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, imfContextDeleteSurroundingCb);
5435 ecore_imf_context_del(imfContext);
5438 priv->imfContextList = 0;
5439 priv->imfContext = 0;
5442 void ewk_view_imf_context_destroy(Evas_Object* ewkView)
5444 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5445 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5447 _ewk_view_imf_context_destroy(priv);
5451 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
5452 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
5454 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5455 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5457 WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(priv->pageClient->page())));
5461 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
5462 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
5464 evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
5468 #if ENABLE(TIZEN_ICON_DATABASE)
5469 void ewkViewIconReceived(Evas_Object* ewkView)
5473 evas_object_smart_callback_call(ewkView, "icon,received", 0);
5477 #endif // #if OS(TIZEN)
5479 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
5480 #if ENABLE(INPUT_TYPE_COLOR)
5483 * Reqeusts to show external color picker.
5485 void ewk_view_color_picker_request(Evas_Object* ewkView, int r, int g, int b, int a, WKColorPickerResultListenerRef listener)
5487 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5488 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5489 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_request);
5491 priv->colorPickerResultListener = listener;
5493 smartData->api->input_picker_color_request(smartData, r, g, b, a);
5498 * Reqeusts to hide external color picker.
5500 void ewk_view_color_picker_dismiss(Evas_Object* ewkView)
5502 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5503 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5504 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_dismiss);
5506 priv->colorPickerResultListener = 0;
5508 smartData->api->input_picker_color_dismiss(smartData);
5512 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
5514 #if ENABLE(INPUT_TYPE_COLOR)
5515 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5516 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5517 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->colorPickerResultListener, false);
5519 WebCore::Color color = WebCore::Color(r, g, b, a);
5520 WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(color.serialized().utf8().data()));
5521 WKColorPickerResultListenerSetColor(priv->colorPickerResultListener, colorString.get());
5522 priv->colorPickerResultListener = 0;
5529 #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
5531 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
5533 #if ENABLE(TOUCH_EVENTS)
5534 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
5535 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5536 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5537 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
5539 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
5540 if (priv->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
5541 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5542 IntPoint handlePoint(point->x, point->y);
5544 if (type == EWK_TOUCH_START)
5545 priv->pageClient->textSelectonHandleDown(handlePoint);
5546 else if (type == EWK_TOUCH_MOVE)
5547 priv->pageClient->textSelectonHandleMove(handlePoint);
5549 priv->pageClient->textSelectonHandleUp();
5553 #if ENABLE(TIZEN_GESTURE)
5554 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
5555 // We don't want to process touch event when context menu is shown.
5556 if (priv->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
5559 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
5560 if (priv->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
5564 if (type == EWK_TOUCH_START) {
5565 if (eina_list_count(points) == 1) {
5566 priv->gestureClient->reset();
5567 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5568 priv->touchDownPoint.x = point->x;
5569 priv->touchDownPoint.y = point->y;
5570 priv->exceedTouchMoveThreshold = false;
5572 } else if (type == EWK_TOUCH_MOVE && !priv->exceedTouchMoveThreshold) {
5573 if (eina_list_count(points) == 1) {
5574 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
5575 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5576 int diffX = priv->touchDownPoint.x - point->x;
5577 int diffY = priv->touchDownPoint.y - point->y;
5578 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
5579 priv->exceedTouchMoveThreshold = true;
5583 priv->exceedTouchMoveThreshold = true;
5586 #endif // #if ENABLE(TIZEN_GESTURE)
5588 // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
5589 //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
5590 priv->pageClient->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
5598 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
5600 #if ENABLE(TOUCH_EVENTS)
5601 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5602 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5604 enabled = !!enabled;
5605 if (priv->areTouchEventsEnabled == enabled)
5608 priv->areTouchEventsEnabled = enabled;
5610 // FIXME: We have to connect touch callbacks with mouse and multi events
5611 // because the Evas creates mouse events for first touch and multi events
5612 // for second and third touches. Below codes should be fixed when the Evas
5613 // supports the touch events.
5614 // See https://bugs.webkit.org/show_bug.cgi?id=97785 for details.
5615 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down, smartData);
5616 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up, smartData);
5617 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move, smartData);
5618 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down, smartData);
5619 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up, smartData);
5620 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move, smartData);
5622 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down);
5623 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up);
5624 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move);
5625 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down);
5626 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up);
5627 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move);
5636 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
5638 #if ENABLE(TOUCH_EVENTS)
5639 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5640 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5642 return priv->areTouchEventsEnabled;
5648 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
5650 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
5651 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5652 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5654 priv->mainFrameScrollbarVisibility = visible;
5655 priv->pageClient->updateVisibility();
5663 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
5665 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
5666 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5667 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5669 return priv->mainFrameScrollbarVisibility;
5675 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
5677 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
5678 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5679 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5680 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
5682 String title = ewk_view_title_get(ewkView);
5683 String url = ewk_view_url_get(ewkView);
5684 String directoryPath(path);
5685 priv->pageClient->startOfflinePageSave(directoryPath, url, title);
5689 UNUSED_PARAM(ewkView);
5697 * Callback function used for ewk_view_page_contents_get().
5699 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
5701 EINA_SAFETY_ON_NULL_RETURN(context);
5703 RefPtr<WebData> webData = toImpl(wkData);
5704 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
5705 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
5710 * Callback function used for ewk_view_page_contents_get().
5712 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
5714 EINA_SAFETY_ON_NULL_RETURN(context);
5716 RefPtr<WebString> webString = toImpl(wkString);
5717 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
5718 contentsContext->callback(contentsContext->type, webString->string().utf8().data());
5721 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
5723 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
5724 EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
5725 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5726 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5728 switch (context->type) {
5729 case EWK_PAGE_CONTENTS_TYPE_MHTML:
5730 priv->pageClient->page()->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
5733 case EWK_PAGE_CONTENTS_TYPE_STRING:
5734 priv->pageClient->page()->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
5738 ASSERT_NOT_REACHED();
5745 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
5747 #if ENABLE(TIZEN_GESTURE)
5748 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5749 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5751 return priv->gestureClient->scrollToWithAnimation(x, y);
5753 UNUSED_PARAM(ewkView);
5760 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5761 void ewkViewFocusRingHide(Evas_Object* ewkView)
5763 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5764 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5766 if (priv->focusRing)
5767 priv->focusRing->hide();
5771 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
5773 #if ENABLE(TIZEN_CSP)
5774 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
5775 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
5777 TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
5778 priv->pageClient->page()->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));