2 Copyright (C) 2011 Samsung Electronics
3 Copyright (C) 2012 Intel Corporation. All rights reserved.
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
24 #include "EwkViewImpl.h"
25 #include "LayerTreeCoordinatorProxy.h"
26 #include "NativeWebKeyboardEvent.h"
27 #include "NativeWebMouseEvent.h"
28 #include "NativeWebWheelEvent.h"
29 #include "PageClientImpl.h"
30 #include "WKAPICast.h"
31 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
32 #include "WKColorPickerResultListener.h"
34 #include "WKRetainPtr.h"
38 #include "WebPageGroup.h"
39 #include "WebPopupItem.h"
40 #include "WebPopupMenuProxyEfl.h"
41 #include "ewk_context.h"
42 #include "ewk_context_private.h"
43 #include "ewk_intent_private.h"
44 #include "ewk_settings_private.h"
45 #include "ewk_view_form_client_private.h"
46 #include "ewk_view_loader_client_private.h"
47 #include "ewk_view_policy_client_private.h"
48 #include "ewk_view_private.h"
49 #include "ewk_view_resource_load_client_private.h"
50 #include "ewk_web_resource.h"
51 #include <Ecore_Evas.h>
54 #include <WebCore/Cursor.h>
55 #include <WebCore/EflScreenUtilities.h>
56 #include <WebKit2/WKPageGroup.h>
57 #include <wtf/text/CString.h>
59 #if USE(ACCELERATED_COMPOSITING)
63 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
65 #define Cursor WebCore::Cursor
69 #include "DrawingAreaProxyImpl.h"
70 #include "JavaScriptPopup.h"
71 #include "OpenPanel.h"
74 #include "WKDownload.h"
76 #include "WKGeolocationPermissionRequest.h"
77 #include "WKImageCairo.h"
78 #include "WKOpenPanelParameters.h"
79 #include "WKOpenPanelResultListener.h"
81 #include "WKPageGroup.h"
83 #include "WKPageTizen.h"
84 #include "WKPreferences.h"
85 #include "WKSerializedScriptValue.h"
87 #include "WKURLRequest.h"
88 #include "ewk_auth_challenge_private.h"
89 #include "ewk_context_menu_private.h"
90 #include "ewk_error.h"
91 #include "ewk_error_private.h"
92 #include "ewk_history_private.h"
93 #include "ewk_popup_menu_item.h"
94 #include "ewk_popup_menu_item_private.h"
95 #include "ewk_view_context_menu_client.h"
96 #include "ewk_view_find_client.h"
97 #include "ewk_view_icondatabase_client.h"
98 #include "ewk_view_tizen_client.h"
99 #include "ewk_view_ui_client.h"
101 #include <Ecore_Evas.h>
102 #include <Elementary.h>
103 #include <JavaScriptCore/JSRetainPtr.h>
104 #include <WebCore/NotImplemented.h>
107 #if ENABLE(TIZEN_ICON_DATABASE)
108 #include "WKContextPrivate.h"
109 #include "WebContext.h"
112 #if ENABLE(TIZEN_GEOLOCATION)
113 #include "ewk_geolocation_private.h"
114 #include "ewk_security_origin.h"
115 #include "ewk_view_geolocation_provider.h"
118 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
119 #include "InputPicker.h"
122 #if ENABLE(TIZEN_GESTURE)
123 #include "GestureRecognizer.h"
124 #include "GestureClient.h"
127 #if ENABLE(TOUCH_EVENTS)
128 #include "NativeWebTouchEvent.h"
129 #include "WebEvent.h"
132 #if ENABLE(TIZEN_ISF_PORT)
133 #include <Ecore_IMF.h>
136 #if ENABLE(TIZEN_NOTIFICATIONS)
138 #include "WKNotificationManager.h"
139 #include "WKNumber.h"
140 #include "ewk_notification_private.h"
141 #include "ewk_view_notification_provider.h"
144 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
145 #include "ewk_popup_picker.h"
148 #if ENABLE(TIZEN_MEDIA_STREAM)
149 #include "WKUserMediaPermissionRequest.h"
150 #include "ewk_user_media_private.h"
153 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
154 #include "WebPageGroup.h"
155 #include "WebPreferences.h"
158 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
159 #include "ewk_hit_test_private.h"
162 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
163 #include "FocusRing.h"
166 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
167 #include "ewk_text_style.h"
170 #if ENABLE(TIZEN_SCREEN_READER)
171 #include "ScreenReaderProxy.h"
174 #if ENABLE(TIZEN_CSP)
175 #include <WebCore/ContentSecurityPolicy.h>
178 #endif // #if OS(TIZEN)
180 using namespace WebKit;
181 using namespace WebCore;
183 static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
186 typedef struct _Ewk_View_Callback_Context Ewk_View_Callback_Context;
187 #endif // #if OS(TIZEN)
189 static const int defaultCursorSize = 16;
191 typedef HashMap<uint64_t, Ewk_Web_Resource*> LoadingResourcesMap;
192 static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap);
194 struct _Ewk_View_Private_Data {
195 OwnPtr<PageClientImpl> pageClient;
200 const char* customEncoding;
201 const char* cursorGroup;
202 Evas_Object* cursorObject;
203 LoadingResourcesMap loadingResourcesMap;
204 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
205 WKColorPickerResultListenerRef colorPickerResultListener;
207 #if ENABLE(TOUCH_EVENTS)
208 bool areTouchEventsEnabled;
210 OwnPtr<Ewk_Settings> settings;
216 #if USE(ACCELERATED_COMPOSITING)
218 Evas_GL_Context* evasGlContext;
219 Evas_GL_Surface* evasGlSurface;
223 bool areMouseEventsEnabled;
224 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
228 JSGlobalContextRef javascriptGlobalContext;
230 const char* userAgent;
231 const char* encoding;
232 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
233 const char* webAppIconURL;
236 OwnPtr<Ewk_View_Callback_Context> alertContext;
237 OwnPtr<Ewk_View_Callback_Context> confirmContext;
238 OwnPtr<Ewk_View_Callback_Context> promptContext;
239 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
240 OwnPtr<Ewk_View_Callback_Context> beforeUnloadConfirmPanelContext;
242 OwnPtr<Ewk_View_Callback_Context> openpanelContext;
243 OwnPtr<JavaScriptPopup> javascriptPopup;
244 bool isWaitingForJavaScriptPopupReply;
245 OwnPtr<OpenPanel> openPanel;
246 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
247 OwnPtr<InputPicker> inputPicker;
248 const char* inputValue;
251 Ewk_Auth_Challenge* authChallenge;
252 Ewk_Policy_Decision* policyDecision;
253 WKOpenPanelResultListenerRef openPanelListener;
255 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
256 Ewk_Certificate_Policy_Decision* certificatePolicyDecision;
259 #if ENABLE(TIZEN_MEDIA_STREAM)
260 Eina_List* userMediaPermissionRequests;
263 Ewk_Context* context;
265 #if ENABLE(TIZEN_GEOLOCATION)
266 Ewk_Geolocation* geolocation;
267 Eina_List* geolocationPermissionRequests;
270 #if ENABLE(TIZEN_ISF_PORT)
271 Eina_List* imfContextList;
272 Ecore_IMF_Context* imfContext;
275 bool suspendRequested;
276 bool suspendedPainting;
277 bool suspendedResources;
279 #if ENABLE(TIZEN_NOTIFICATIONS)
280 Eina_List* notifications;
281 Eina_List* notificationPermissionRequests;
283 #if ENABLE(TIZEN_SQL_DATABASE)
284 Ewk_Context_Exceeded_Quota* exceededDatabaseQuota;
286 WebPopupMenuProxyEfl* popupMenuProxy;
287 Eina_List* popupMenuItems;
288 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
289 Ewk_Popup_Picker* popupPicker;
293 bool isHorizontalEdge;
294 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
295 OwnPtr<FocusRing> focusRing;
296 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
298 #if ENABLE(TIZEN_GESTURE)
299 OwnPtr<GestureRecognizer> gestureRecognizer;
300 OwnPtr<GestureClient> gestureClient;
301 #if ENABLE(TOUCH_EVENTS)
302 Evas_Coord_Point touchDownPoint;
303 bool exceedTouchMoveThreshold;
304 bool wasHandledTouchStart;
305 bool wasHandledTouchMove;
306 #endif // #if ENABLE(TOUCH_EVENTS)
307 bool holdHorizontalPanning;
308 bool holdVerticalPanning;
309 #endif // #if ENABLE(TIZEN_GESTURE)
310 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
311 bool mainFrameScrollbarVisibility;
314 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
315 Ecore_Animator* compositionAnimator;
318 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
319 const char* selectedText;
321 #if ENABLE(TIZEN_DATALIST_ELEMENT)
324 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
326 Ewk_Orientation_Lock_Cb callback;
330 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
331 RefPtr<WebPageGroup> pageGroup;
333 #endif // #if OS(TIZEN)
335 _Ewk_View_Private_Data()
342 #if ENABLE(TIZEN_INPUT_COLOR_TYPE) // wait for upstream
343 , colorPickerResultListener(0)
345 #if ENABLE(TOUCH_EVENTS)
346 , areTouchEventsEnabled(false)
349 , isUsingEcoreX(false)
351 #if USE(ACCELERATED_COMPOSITING)
358 ~_Ewk_View_Private_Data()
360 eina_stringshare_del(uri);
361 eina_stringshare_del(title);
362 eina_stringshare_del(theme);
363 eina_stringshare_del(customEncoding);
364 _ewk_view_priv_loading_resources_clear(loadingResourcesMap);
367 evas_object_del(cursorObject);
369 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
370 if (compositionAnimator) {
371 ecore_animator_del(compositionAnimator);
372 compositionAnimator = 0;
380 struct _Ewk_View_Callback_Context {
382 Ewk_Web_App_Capable_Get_Callback webAppCapableCallback;
383 Ewk_Web_App_Icon_URL_Get_Callback webAppIconURLCallback;
384 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
385 Ewk_Web_Storage_Quota_Get_Callback webStorageQuotaCallback;
387 Ewk_View_Script_Execute_Callback scriptExecuteCallback;
388 Ewk_View_Plain_Text_Get_Callback plainTextGetCallback;
389 #if ENABLE(TIZEN_SUPPORT_MHTML)
390 Ewk_View_MHTML_Data_Get_Callback mhtmlDataGetCallback;
392 Ewk_View_JavaScript_Alert_Callback javascriptAlertCallback;
393 Ewk_View_JavaScript_Confirm_Callback javascriptConfirmCallback;
394 Ewk_View_JavaScript_Prompt_Callback javascriptPromptCallback;
395 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
396 Ewk_View_Before_Unload_Confirm_Panel_Callback beforeUnloadConfirmPanelCallback;
398 Ewk_View_Open_Panel_Callback openPanelCallback;
401 Evas_Object* ewkView;
404 #endif // #if OS(TIZEN)
406 #define EWK_VIEW_TYPE_CHECK(ewkView, result) \
407 bool result = true; \
409 const char* _tmp_otype = evas_object_type_get(ewkView); \
410 const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
411 if (EINA_UNLIKELY(!_tmp_s)) { \
413 ("%p (%s) is not a smart object!", \
414 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
418 const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
419 if (EINA_UNLIKELY(!_tmp_sc)) { \
421 ("%p (%s) is not a smart object!", \
422 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
426 else if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \
428 ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
429 ewkView, _tmp_otype ? _tmp_otype : "(null)", \
430 EWK_VIEW_TYPE_STR, _tmp_sc->data); \
435 #define EWK_VIEW_SD_GET(ewkView, smartData) \
436 EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \
437 Ewk_View_Smart_Data* smartData = 0; \
439 smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView);
441 #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \
442 EWK_VIEW_SD_GET(ewkView, smartData); \
444 EINA_LOG_CRIT("no smart data for object %p (%s)", \
445 ewkView, evas_object_type_get(ewkView)); \
446 return __VA_ARGS__; \
449 #define EWK_VIEW_PRIV_GET(smartData, priv) \
450 Ewk_View_Private_Data* priv = smartData->priv
452 #define EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, ...) \
454 EINA_LOG_CRIT("smart data is null"); \
455 return __VA_ARGS__; \
457 EWK_VIEW_PRIV_GET(smartData, priv); \
459 EINA_LOG_CRIT("no private data for object %p (%s)", \
460 smartData->self, evas_object_type_get(smartData->self)); \
461 return __VA_ARGS__; \
464 #define EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, ...) \
466 EINA_LOG_CRIT("smart data is null"); \
467 return __VA_ARGS__; \
469 EwkViewImpl* impl = smartData->ewkViewImpl; \
472 EINA_LOG_CRIT("no private data for object %p (%s)", \
473 smartData->self, evas_object_type_get(smartData->self)); \
474 return __VA_ARGS__; \
478 #define EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, ...) \
479 EwkViewImpl* impl = 0; \
481 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, __VA_ARGS__); \
482 impl = smartData->ewkViewImpl; \
484 EINA_LOG_CRIT("no private data for object %p (%s)", \
485 smartData->self, evas_object_type_get(smartData->self)); \
486 return __VA_ARGS__; \
491 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object*, const char* alertText, void* userData);
492 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object*, const char* message, void* userData);
493 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object*, const char* message, const char* defaultValue, void* userData);
494 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
495 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object*, const char* message, void* userData);
497 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);
499 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
500 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);
501 #if ENABLE(TIZEN_MULTIPLE_SELECT)
502 Eina_Bool _ewk_view_multiple_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items);
504 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data*);
505 Eina_Bool _ewk_view_popup_menu_update(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, Eina_List*, int);
507 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
508 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations);
509 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd);
512 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
513 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data*, Ewk_Input_Type, const char* inputValue);
516 #if ENABLE(TIZEN_DATALIST_ELEMENT)
517 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data*, Ewk_Input_Type, Eina_List*);
518 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data*, Ewk_Input_Type);
521 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
522 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data*, int, int, int, int);
523 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data*);
526 #if ENABLE(TIZEN_ISF_PORT)
527 static void _ewk_view_imf_context_destroy(Ewk_View_Private_Data*);
530 #endif // #if OS(TIZEN)
532 static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
534 if (smartData->changed.any)
536 smartData->changed.any = true;
537 evas_object_smart_changed(smartData->self);
540 // Default Event Handling.
541 static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
543 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
547 priv->pageClient->setViewFocused(true);
548 #endif // #if OS(TIZEN)
549 priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
550 #if ENABLE(TIZEN_ISF_PORT)
551 if (priv->imfContext) {
552 ecore_imf_context_focus_in(priv->imfContext);
553 ecore_imf_context_input_panel_show(priv->imfContext);
559 static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
561 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
565 #if ENABLE(TIZEN_ISF_PORT)
566 // Keypad should be hidden rapidly when moving focus on elementary
567 // because Ecore-ime doesn't support it.
568 if (priv->imfContext) {
569 ecore_imf_context_input_panel_hide(priv->imfContext);
570 ecore_imf_context_focus_out(priv->imfContext);
574 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
575 if (priv->pageClient->isTextSelectionMode())
576 priv->pageClient->setIsTextSelectionMode(false);
579 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
580 if (priv->pageClient->isContextMenuVisible())
581 priv->pageClient->page()->hideContextMenu();
584 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
585 priv->pageClient->clearClipboardSelectionHandler();
588 #if ENABLE(TIZEN_DRAG_SUPPORT)
589 if (priv->pageClient->isDragMode())
590 priv->pageClient->setDragMode(false);
593 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
594 if (smartData->api->formdata_candidate_is_showing(smartData))
595 smartData->api->formdata_candidate_hide(smartData);
598 priv->pageClient->setViewFocused(false);
599 #endif // #if OS(TIZEN)
600 priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
604 static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
606 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
607 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
609 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
610 //impl->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
611 priv->pageClient->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
615 static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
617 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
618 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
620 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
621 //impl->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
622 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
626 static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
628 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
629 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
631 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
632 //impl->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
633 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
637 static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
639 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
640 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
642 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
643 //impl->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
644 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
648 static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
650 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
652 #if ENABLE(TIZEN_ISF_PORT)
653 Ecore_IMF_Event IMFEvent;
654 ecore_imf_evas_event_key_down_wrap(const_cast<Evas_Event_Key_Down*>(downEvent), &IMFEvent.key_down);
655 bool filtered = ecore_imf_context_filter_event(priv->imfContext, ECORE_IMF_EVENT_KEY_DOWN, &IMFEvent);
657 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, filtered));
659 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent));
660 #endif // #if ENABLE(TIZEN_ISF_PORT)
664 static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
666 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
668 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
673 static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
675 #if ENABLE(TIZEN_GESTURE)
676 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
677 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
679 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
680 if (priv->pageClient->isTextSelectionMode() && priv->pageClient->isTextSelectionHandleDowned())
684 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
685 if (priv->focusRing) {
686 if (event->type == EWK_GESTURE_TAP && event->count == 1) {
687 priv->focusRing->requestToShow(IntPoint(event->position.x, event->position.y));
688 } else if (event->type == EWK_GESTURE_PAN) {
689 if (priv->exceedTouchMoveThreshold)
690 priv->focusRing->hide();
692 if (!event->type == EWK_GESTURE_LONG_PRESS) {
693 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
694 if (!priv->pageClient->isContextMenuVisible())
696 priv->focusRing->hide();
702 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
703 if (smartData->api->formdata_candidate_is_showing(smartData))
704 smartData->api->formdata_candidate_hide(smartData);
707 switch (event->type) {
708 case EWK_GESTURE_TAP:
709 priv->gestureClient->startTap(IntPoint(event->position.x, event->position.y));
711 case EWK_GESTURE_LONG_PRESS: {
712 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
713 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
714 if (ewk_settings_text_selection_enabled_get(priv->settings.get()))
715 priv->pageClient->setIsTextSelectionMode(false);
717 IntPoint scenePoint(event->position.x, event->position.y);
718 IntPoint contentsPoint = impl->transformFromScene().mapPoint(scenePoint);
719 WebHitTestResult::Data hitTestResultData = priv->pageClient->page()->hitTestResultAtPoint(contentsPoint);
720 #if ENABLE(TIZEN_DRAG_SUPPORT)
721 // 1. Check to start dragging.
722 if (hitTestResultData.isDragSupport) {
723 priv->pageClient->setDragPoint(scenePoint);
724 priv->gestureClient->showContextMenu(scenePoint);
728 // 2. Check to show context menu.
729 if (!hitTestResultData.absoluteImageURL.isEmpty()
730 || !hitTestResultData.absoluteLinkURL.isEmpty()
731 || !hitTestResultData.absoluteMediaURL.isEmpty()) {
732 priv->gestureClient->showContextMenu(scenePoint);
735 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
736 // 3. Check for text selection.
737 if (ewk_settings_text_selection_enabled_get(priv->settings.get())) {
738 // Process gesture_end(EWK_GESTURE_TAP) to activate the editing if node under point is editable.
739 if (hitTestResultData.context & WebHitTestResult::HitTestResultContextEditable) {
740 if (smartData->api && smartData->api->gesture_end) {
741 Ewk_Event_Gesture tapEvent = {EWK_GESTURE_TAP, event->position, {0, 0}, 0, 1, ecore_time_get() * 1000};
742 smartData->api->gesture_end(smartData, &tapEvent);
746 if (priv->pageClient->textSelectionDown(scenePoint)) {
747 priv->gestureClient->setGestureEnabled(false);
748 ewkViewHandleTouchEvent(smartData->self, EWK_TOUCH_CANCEL);
753 #endif // #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
755 case EWK_GESTURE_PAN:
756 priv->gestureClient->startPan(IntPoint(event->position.x, event->position.y));
758 case EWK_GESTURE_FLICK:
759 priv->gestureClient->startFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
761 case EWK_GESTURE_PINCH:
762 if (priv->pageClient->viewportConstraints().userScalable)
763 priv->gestureClient->startPinch(IntPoint(event->position.x, event->position.y), event->scale);
766 ASSERT_NOT_REACHED();
773 #endif // #if ENABLE(TIZEN_GESTURE)
776 static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
778 #if ENABLE(TIZEN_GESTURE)
779 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
781 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
782 if (priv->pageClient->isTextSelectionMode() && priv->pageClient->isTextSelectionHandleDowned())
786 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
787 if (priv->focusRing) {
788 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
789 if (!priv->pageClient->isContextMenuVisible())
791 priv->focusRing->hide();
795 switch (event->type) {
796 case EWK_GESTURE_TAP:
797 if (event->count == 1) {
798 #if ENABLE(TIZEN_DRAG_SUPPORT)
799 if (priv->pageClient->isDragMode())
800 priv->pageClient->setDragMode(false);
802 priv->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
803 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
804 if (priv->pageClient->isTextSelectionMode())
805 priv->pageClient->setIsTextSelectionMode(false);
807 #if ENABLE(TIZEN_ISF_PORT)
808 evas_object_focus_set(smartData->self, true);
810 } else if (event->count == 2)
811 priv->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
813 case EWK_GESTURE_LONG_PRESS:
814 #if ENABLE(TIZEN_DRAG_SUPPORT)
815 if (priv->pageClient->isDragMode())
816 priv->pageClient->setDragMode(false);
818 // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
819 priv->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
821 case EWK_GESTURE_PAN:
822 priv->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
824 case EWK_GESTURE_FLICK:
825 priv->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
827 case EWK_GESTURE_PINCH:
828 priv->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
831 ASSERT_NOT_REACHED();
838 #endif // #if ENABLE(TIZEN_GESTURE)
841 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
843 #if ENABLE(TIZEN_GESTURE)
844 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
846 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
847 if (priv->pageClient->isTextSelectionMode() && priv->pageClient->isTextSelectionHandleDowned())
851 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
852 if (priv->focusRing && !(event->type == EWK_GESTURE_PAN && !priv->exceedTouchMoveThreshold))
853 priv->focusRing->hide();
856 switch (event->type) {
857 case EWK_GESTURE_PAN:
858 priv->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
860 case EWK_GESTURE_TAP:
861 case EWK_GESTURE_LONG_PRESS:
862 case EWK_GESTURE_FLICK:
864 case EWK_GESTURE_PINCH:
865 if (priv->pageClient->viewportConstraints().userScalable)
866 priv->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
869 ASSERT_NOT_REACHED();
876 #endif // #if ENABLE(TIZEN_GESTURE)
878 #endif //#if OS(TIZEN)
881 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
883 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
884 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
885 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
886 smartData->api->focus_in(smartData);
889 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
891 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
892 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
893 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
894 smartData->api->focus_out(smartData);
897 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
899 Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
900 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
901 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
902 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
903 smartData->api->mouse_wheel(smartData, wheelEvent);
906 static void _ewk_view_on_mouse_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
908 Evas_Event_Mouse_Down* downEvent = static_cast<Evas_Event_Mouse_Down*>(eventInfo);
909 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
910 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
911 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_down);
912 smartData->api->mouse_down(smartData, downEvent);
915 static void _ewk_view_on_mouse_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
917 Evas_Event_Mouse_Up* upEvent = static_cast<Evas_Event_Mouse_Up*>(eventInfo);
918 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
919 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
920 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_up);
921 smartData->api->mouse_up(smartData, upEvent);
924 static void _ewk_view_on_mouse_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
926 Evas_Event_Mouse_Move* moveEvent = static_cast<Evas_Event_Mouse_Move*>(eventInfo);
927 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
928 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
929 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_move);
930 smartData->api->mouse_move(smartData, moveEvent);
933 static void _ewk_view_on_key_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
935 Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
936 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
937 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
938 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
939 smartData->api->key_down(smartData, downEvent);
942 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
944 Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
945 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
946 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
947 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
948 smartData->api->key_up(smartData, upEvent);
951 #if ENABLE(TOUCH_EVENTS)
952 static inline void _ewk_view_feed_touch_event_using_touch_point_list_of_evas(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
954 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
956 unsigned count = evas_touch_point_list_count(smartData->base.evas);
960 Eina_List* points = 0;
961 for (unsigned i = 0; i < count; ++i) {
962 Ewk_Touch_Point* point = new Ewk_Touch_Point;
963 point->id = evas_touch_point_list_nth_id_get(smartData->base.evas, i);
964 evas_touch_point_list_nth_xy_get(smartData->base.evas, i, &point->x, &point->y);
965 point->state = evas_touch_point_list_nth_state_get(smartData->base.evas, i);
966 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_GESTURE)
967 if (type == EWK_TOUCH_CANCEL)
968 point->state = EVAS_TOUCH_POINT_CANCEL;
970 points = eina_list_append(points, point);
973 ewk_view_feed_touch_event(ewkView, type, points, evas_key_modifier_get(smartData->base.evas));
976 EINA_LIST_FREE(points, data)
977 delete static_cast<Ewk_Touch_Point*>(data);
980 static void _ewk_view_on_touch_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
982 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_START);
985 static void _ewk_view_on_touch_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
987 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_END);
990 static void _ewk_view_on_touch_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
992 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, EWK_TOUCH_MOVE);
996 void ewkViewHandleTouchEvent(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
998 _ewk_view_feed_touch_event_using_touch_point_list_of_evas(ewkView, type);
1004 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1005 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
1007 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1009 return priv->pageClient->textSelectionDown(IntPoint(x, y), true);
1012 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
1014 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1016 IntPoint point(x, y);
1017 priv->pageClient->textSelectionMove(point, true);
1022 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
1024 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1026 IntPoint point(x, y);
1027 priv->pageClient->textSelectionUp(point, true);
1033 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1034 static void _ewk_view_data_list_del(Eina_List* dataList)
1036 EINA_SAFETY_ON_NULL_RETURN(dataList);
1039 EINA_LIST_FREE(dataList, item)
1040 eina_stringshare_del(static_cast<char*>(item));
1044 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1045 Eina_Bool _ewk_view_smart_formdata_candidate_show(Ewk_View_Smart_Data* smartData, int x, int y, int w, int h)
1047 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1049 priv->pageClient->showFormDataCandidate(IntRect(x, y, w, h));
1054 Eina_Bool _ewk_view_smart_formdata_candidate_hide(Ewk_View_Smart_Data* smartData)
1056 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1058 priv->pageClient->hideFormDataCandidate();
1063 Eina_Bool _ewk_view_smart_formdata_candidate_update_data(Ewk_View_Smart_Data* smartData, Eina_List* dataList)
1065 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1067 Vector<String> formData;
1070 EINA_LIST_FOREACH(dataList, list, data)
1071 formData.append(String::fromUTF8(static_cast<char*>(data)));
1073 priv->pageClient->updateFormDataCandidate(formData);
1078 Eina_Bool _ewk_view_smart_formdata_candidate_is_showing(Ewk_View_Smart_Data* smartData)
1080 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1082 return priv->pageClient->isShowingFormDataCandidate();
1086 #if ENABLE(TIZEN_SCREEN_READER)
1087 Eina_Bool _ewk_view_screen_reader_command_execute(Ewk_View_Smart_Data* smartData, unsigned int command, int data1, int data2)
1089 return ScreenReaderProxy::screenReader().executeCommand(smartData->self, command, data1, data2);
1092 #endif // #if OS(TIZEN)
1094 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
1096 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1097 static uint64_t generatePageGroupIdentifierID()
1099 static uint64_t uniquePageGroupIdentifierID = 1;
1100 return uniquePageGroupIdentifierID++;
1104 static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
1106 Ewk_View_Private_Data* priv = new Ewk_View_Private_Data;
1107 memset(priv, 0, sizeof(Ewk_View_Private_Data)); // FIXME : below code should be considered to move to constructor.
1109 priv->areMouseEventsEnabled = false;
1111 priv->javascriptPopup = adoptPtr<JavaScriptPopup>(new JavaScriptPopup(smartData->self));
1112 priv->openPanel = adoptPtr<OpenPanel>(new OpenPanel(smartData->self));
1114 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1115 priv->inputPicker = adoptPtr<InputPicker>(new InputPicker(smartData->self));
1116 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1118 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1119 priv->focusRing = FocusRing::create(smartData->self);
1120 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1122 #if ENABLE(TIZEN_GESTURE)
1123 priv->gestureRecognizer = GestureRecognizer::create(smartData->self);
1124 priv->gestureClient = GestureClient::create(smartData->ewkViewImpl);
1125 #endif // #if ENABLE(TIZEN_GESTURE)
1126 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1127 const char* hideScrollbar = getenv("TIZEN_WEBKIT2_TILED_SCROLLBAR_HIDE");
1128 if (hideScrollbar && atoi(hideScrollbar) == 1)
1129 priv->mainFrameScrollbarVisibility = false;
1131 priv->mainFrameScrollbarVisibility = true;
1134 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1138 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1139 String pageGroupIdentifierID = String::number(generatePageGroupIdentifierID());
1140 String pageGroupIdentifier = String::format("PageGroup%s", pageGroupIdentifierID.utf8().data());
1142 WKRetainPtr<WKStringRef> pageGroupIdentifierRef(AdoptWK, WKStringCreateWithUTF8CString(pageGroupIdentifier.utf8().data()));
1143 priv->pageGroup = WebPageGroup::create(toWTFString(pageGroupIdentifierRef.get()));
1146 priv->suspendRequested = false;
1147 priv->suspendedPainting = false;
1148 priv->suspendedResources = false;
1149 #endif // #if OS(TIZEN)
1152 priv->isUsingEcoreX = WebCore::isUsingEcoreX(smartData->base.evas);
1158 static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingResourcesMap)
1160 // Clear the loadingResources HashMap.
1161 LoadingResourcesMap::iterator it = loadingResourcesMap.begin();
1162 LoadingResourcesMap::iterator end = loadingResourcesMap.end();
1163 for ( ; it != end; ++it)
1164 ewk_web_resource_unref(it->second);
1166 loadingResourcesMap.clear();
1169 static void _ewk_view_priv_del(Ewk_View_Private_Data* priv)
1175 if (priv->javascriptGlobalContext)
1176 JSGlobalContextRelease(priv->javascriptGlobalContext);
1178 eina_stringshare_del(priv->userAgent);
1179 eina_stringshare_del(priv->encoding);
1180 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1181 eina_stringshare_del(priv->webAppIconURL);
1184 if (priv->authChallenge)
1185 ewkAuthChallengeDelete(priv->authChallenge);
1186 if (priv->policyDecision)
1187 ewkPolicyDecisionDelete(priv->policyDecision);
1189 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1190 if (priv->certificatePolicyDecision)
1191 ewkCertificatePolicyDecisionDelete(priv->certificatePolicyDecision);
1194 #if ENABLE(TIZEN_MEDIA_STREAM)
1195 if (priv->userMediaPermissionRequests)
1196 ewkUserMediaDeletePermissionRequestList(priv->userMediaPermissionRequests);
1199 priv->openPanelListener = 0;
1200 priv->openPanel = nullptr;
1201 priv->javascriptPopup = nullptr;
1202 priv->alertContext = nullptr;
1203 priv->confirmContext = nullptr;
1204 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1205 priv->beforeUnloadConfirmPanelContext = nullptr;
1207 priv->promptContext = nullptr;
1208 priv->isWaitingForJavaScriptPopupReply = false;
1209 priv->openpanelContext = nullptr;
1210 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1211 priv->inputPicker = nullptr;
1212 eina_stringshare_del(priv->inputValue);
1215 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1216 if (priv->dataList) {
1217 _ewk_view_data_list_del(priv->dataList);
1222 #if ENABLE(TIZEN_GEOLOCATION)
1223 if (priv->geolocation)
1224 ewkGeolocationDeleteGeolocation(priv->geolocation);
1225 if (priv->geolocationPermissionRequests)
1226 ewkGeolocationDeletePermissionRequestList(priv->geolocationPermissionRequests);
1229 #if ENABLE(TIZEN_NOTIFICATIONS)
1230 if (priv->notifications)
1231 ewkNotificationDeleteNotificationList(priv->notifications);
1232 if (priv->notificationPermissionRequests)
1233 ewkNotificationDeletePermissionRequestList(priv->notificationPermissionRequests);
1235 #if ENABLE(TIZEN_SQL_DATABASE)
1236 if (priv->exceededDatabaseQuota)
1237 ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
1239 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1240 priv->focusRing = nullptr;
1241 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1242 #if ENABLE(TIZEN_GESTURE)
1243 priv->gestureRecognizer = nullptr;
1244 priv->gestureClient = nullptr;
1245 #endif // #if ENABLE(TIZEN_GESTURE)
1247 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1248 eina_stringshare_del(priv->selectedText);
1250 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1251 priv->pageGroup = nullptr;
1254 #if ENABLE(TIZEN_ISF_PORT)
1255 _ewk_view_imf_context_destroy(priv);
1257 #endif // #if OS(TIZEN)
1262 static void _ewk_view_smart_add(Evas_Object* ewkView)
1264 const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
1265 const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
1266 const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
1267 EWK_VIEW_SD_GET(ewkView, smartData);
1270 smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
1272 EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
1275 evas_object_smart_data_set(ewkView, smartData);
1278 smartData->self = ewkView;
1279 smartData->api = api;
1281 g_parentSmartClass.add(ewkView);
1283 // FIXME: Ewk_View_Private_Data was replaced with EwkViewImpl in the webkit opensource.
1284 // So, we have both Ewk_View_Private_Data and EwkViewImpl now,
1285 // but Ewk_View_Private_Data should be removed later.
1286 smartData->ewkViewImpl = new EwkViewImpl(ewkView);
1287 smartData->priv = _ewk_view_priv_new(smartData);
1289 // Create evas_object_image to draw web contents.
1290 smartData->image = evas_object_image_add(smartData->base.evas);
1291 evas_object_image_alpha_set(smartData->image, false);
1292 evas_object_image_filled_set(smartData->image, true);
1293 evas_object_smart_member_add(smartData->image, ewkView);
1296 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1297 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
1298 const char *engine = ecore_evas_engine_name_get(ee);
1299 if (engine && !strcmp(engine, "opengl_x11"))
1300 evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
1302 ewk_view_mouse_events_enabled_set(ewkView, false);
1303 ewk_view_touch_events_enabled_set(ewkView, true);
1305 // FIXME: This code should be removed if side effect occur.
1306 // WebView does not have focus after url loading.
1307 // If focus is set as true to webview,
1308 // elementary steal webview's focus during mouse up event
1309 // So, added code that events are not propagated to smart parent according to guide from EFL
1310 evas_object_propagate_events_set(ewkView, false);
1312 #if ENABLE(TIZEN_SCREEN_READER)
1313 ScreenReaderProxy::screenReader().addView(ewkView);
1315 #endif // #if OS(TIZEN)
1317 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
1318 CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
1319 CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
1320 CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
1322 CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
1323 CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
1324 CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
1326 CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
1327 CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
1331 static void _ewk_view_smart_del(Evas_Object* ewkView)
1333 EWK_VIEW_SD_GET(ewkView, smartData);
1334 #if ENABLE(TIZEN_SCREEN_READER)
1335 ScreenReaderProxy::screenReader().removeView(ewkView);
1337 if (smartData && smartData->priv) {
1338 _ewk_view_priv_del(smartData->priv);
1339 smartData->priv = 0;
1342 // FIXME: Ewk_View_Private_Data was replaced with EwkViewImpl in the webkit opensource.
1343 // If then, ewkViewImpl will be changed to priv.
1345 delete smartData->ewkViewImpl;
1347 g_parentSmartClass.del(ewkView);
1350 static Eina_Bool _ewk_view_composite(void* data);
1352 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
1354 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1356 evas_object_resize(smartData->image, width, height);
1357 evas_object_image_size_set(smartData->image, width, height);
1358 evas_object_image_fill_set(smartData->image, 0, 0, width, height);
1360 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1361 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1362 evas_object_image_native_surface_set(smartData->image, 0);
1364 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1365 if (!ewk_view_is_opengl_backend(ewkView))
1366 _ewk_view_composite(smartData);
1367 else // OpenGL backend
1369 priv->pageClient->displayViewport();
1371 #endif // #if OS(TIZEN)
1373 smartData->changed.size = true;
1374 _ewk_view_smart_changed(smartData);
1377 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
1379 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1381 smartData->changed.position = true;
1382 _ewk_view_smart_changed(smartData);
1385 IntSize ewk_view_size_get(const Evas_Object* ewkView)
1388 evas_object_geometry_get(ewkView, 0, 0, &width, &height);
1389 return IntSize(width, height);
1392 #if USE(ACCELERATED_COMPOSITING)
1393 static bool ewk_view_create_gl_surface(const Evas_Object* ewkView, const IntSize& viewSize)
1395 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1396 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1398 Evas_GL_Config evasGlConfig = {
1400 EVAS_GL_DEPTH_BIT_8,
1401 EVAS_GL_STENCIL_NONE,
1402 EVAS_GL_OPTIONS_NONE,
1403 EVAS_GL_MULTISAMPLE_NONE
1406 ASSERT(!priv->evasGlSurface);
1407 priv->evasGlSurface = evas_gl_surface_create(priv->evasGl, &evasGlConfig, viewSize.width(), viewSize.height());
1408 if (!priv->evasGlSurface)
1411 Evas_Native_Surface nativeSurface;
1412 evas_gl_native_surface_get(priv->evasGl, priv->evasGlSurface, &nativeSurface);
1413 evas_object_image_native_surface_set(smartData->image, &nativeSurface);
1418 bool ewk_view_accelerated_compositing_mode_enter(const Evas_Object* ewkView)
1420 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1421 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1423 EINA_SAFETY_ON_TRUE_RETURN_VAL(!!priv->evasGl, false);
1425 Evas* evas = evas_object_evas_get(ewkView);
1426 priv->evasGl = evas_gl_new(evas);
1430 priv->evasGlContext = evas_gl_context_create(priv->evasGl, 0);
1431 if (!priv->evasGlContext) {
1432 evas_gl_free(priv->evasGl);
1437 if (!ewk_view_create_gl_surface(ewkView, ewk_view_size_get(ewkView))) {
1438 evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
1439 priv->evasGlContext = 0;
1441 evas_gl_free(priv->evasGl);
1449 bool ewk_view_accelerated_compositing_mode_exit(const Evas_Object* ewkView)
1451 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1452 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1454 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->evasGl, false);
1456 if (priv->evasGlSurface) {
1457 evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
1458 priv->evasGlSurface = 0;
1461 if (priv->evasGlContext) {
1462 evas_gl_context_destroy(priv->evasGl, priv->evasGlContext);
1463 priv->evasGlContext = 0;
1466 evas_gl_free(priv->evasGl);
1473 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
1475 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1476 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1477 Evas_Coord x, y, width, height;
1479 smartData->changed.any = false;
1481 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
1483 if (smartData->changed.size) {
1485 if (priv->pageClient->page()->drawingArea())
1486 priv->pageClient->page()->drawingArea()->setSize(IntSize(width, height), IntSize());
1488 #if USE(ACCELERATED_COMPOSITING)
1489 if (!priv->evasGlSurface)
1491 evas_gl_surface_destroy(priv->evasGl, priv->evasGlSurface);
1492 priv->evasGlSurface = 0;
1493 ewk_view_create_gl_surface(ewkView, IntSize(width, height));
1494 ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
1496 #endif // #if !OS(TIZEN)
1498 smartData->view.w = width;
1499 smartData->view.h = height;
1500 smartData->changed.size = false;
1503 if (priv->pageClient) {
1504 if (DrawingAreaProxy* drawingArea = priv->pageClient->page()->drawingArea()) {
1505 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1506 if (priv->pageClient->page()->isViewVisible())
1507 drawingArea->setSize(IntSize(width, height), IntSize());
1509 drawingArea->setSize(IntSize(width, height), IntSize());
1511 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1512 priv->pageClient->updateViewportSize(IntSize(width, height));
1513 if (ewk_view_is_opengl_backend(ewkView))
1514 priv->pageClient->displayViewport();
1517 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1518 priv->pageClient->frameRectChanged();
1521 #endif // #if OS(TIZEN)
1524 if (smartData->changed.position) {
1525 evas_object_move(smartData->image, x, y);
1526 smartData->view.x = x;
1527 smartData->view.y = y;
1528 smartData->changed.position = false;
1530 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1531 priv->pageClient->frameRectChanged();
1533 #if ENABLE(TIZEN_SCREEN_READER)
1534 priv->pageClient->page()->recalcScreenReaderFocusRect();
1536 #endif // #if OS(TIZEN)
1539 if (priv->popupPicker)
1540 ewk_popup_picker_resize(priv->popupPicker);
1541 #endif // #if OS(TIZEN)
1544 static void _ewk_view_smart_show(Evas_Object* ewkView)
1546 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1547 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1549 if (evas_object_clipees_get(smartData->base.clipper))
1550 evas_object_show(smartData->base.clipper);
1551 evas_object_show(smartData->image);
1554 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1556 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1558 evas_object_hide(smartData->base.clipper);
1559 evas_object_hide(smartData->image);
1560 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1561 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1562 if (priv->pageClient->isTextSelectionMode())
1563 priv->pageClient->setIsTextSelectionMode(false);
1567 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1569 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1570 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1574 else if (alpha > 255)
1577 #define CHECK_COLOR(color, alpha) \
1580 else if (color > alpha) \
1582 CHECK_COLOR(red, alpha);
1583 CHECK_COLOR(green, alpha);
1584 CHECK_COLOR(blue, alpha);
1587 evas_object_image_alpha_set(smartData->image, alpha < 255);
1588 priv->pageClient->page()->setDrawsBackground(red || green || blue);
1589 priv->pageClient->page()->setDrawsTransparentBackground(alpha < 255);
1590 priv->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1593 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1597 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1599 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1601 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1602 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1603 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1607 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1608 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1610 evas_object_smart_clipped_smart_set(&api->sc);
1612 // Set Evas_Smart_Class functions.
1613 api->sc.add = _ewk_view_smart_add;
1614 api->sc.del = _ewk_view_smart_del;
1615 api->sc.move = _ewk_view_smart_move;
1616 api->sc.resize = _ewk_view_smart_resize;
1617 api->sc.show = _ewk_view_smart_show;
1618 api->sc.hide = _ewk_view_smart_hide;
1619 api->sc.color_set = _ewk_view_smart_color_set;
1620 api->sc.calculate = _ewk_view_smart_calculate;
1621 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1623 // Set Ewk_View_Smart_Class functions.
1624 api->focus_in = _ewk_view_smart_focus_in;
1625 api->focus_out = _ewk_view_smart_focus_out;
1626 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1627 api->mouse_down = _ewk_view_smart_mouse_down;
1628 api->mouse_up = _ewk_view_smart_mouse_up;
1629 api->mouse_move = _ewk_view_smart_mouse_move;
1630 api->key_down = _ewk_view_smart_key_down;
1631 api->key_up = _ewk_view_smart_key_up;
1633 api->gesture_start = _ewk_view_smart_gesture_start;
1634 api->gesture_end = _ewk_view_smart_gesture_end;
1635 api->gesture_move = _ewk_view_smart_gesture_move;
1637 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1638 api->popup_menu_show = _ewk_view_popup_menu_show;
1639 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1640 api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1642 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1643 api->popup_menu_update = _ewk_view_popup_menu_update;
1645 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1646 api->text_selection_down = _ewk_view_text_selection_down;
1647 api->text_selection_move = _ewk_view_text_selection_move;
1648 api->text_selection_up = _ewk_view_text_selection_up;
1650 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1651 api->input_picker_show = _ewk_view_input_picker_show;
1653 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1654 api->data_list_show = _ewk_view_data_list_show;
1655 api->data_list_hide = _ewk_view_data_list_hide;
1657 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1658 api->orientation_lock = _ewk_orientation_lock;
1659 api->orientation_unlock = _ewk_orientation_unlock;
1661 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1662 api->input_picker_color_request = _ewk_input_picker_color_request;
1663 api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1665 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1666 api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1667 api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1668 api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1669 api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1671 #if ENABLE(TIZEN_SCREEN_READER)
1672 api->screen_reader_command_execute = _ewk_view_screen_reader_command_execute;
1674 #endif //#if OS(TIZEN)
1679 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1681 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1682 static Evas_Smart* smart = 0;
1684 if (EINA_UNLIKELY(!smart)) {
1685 ewk_view_smart_class_set(&api);
1686 smart = evas_smart_class_new(&api.sc);
1692 static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKPageGroupRef pageGroupRef)
1694 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1695 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
1696 EINA_SAFETY_ON_NULL_RETURN(context);
1698 if (priv->pageClient)
1701 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1702 if (ewk_view_is_opengl_backend(ewkView)) {
1703 priv->pageClient = PageClientEvasGL::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1704 priv->pageClient->page()->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1707 priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1708 priv->pageClient->page()->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1709 priv->pageClient->page()->pageGroup()->preferences()->setWebGLEnabled(false);
1710 priv->pageClient->page()->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1713 priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView);
1715 // FixMe: Comment should be removed when pageClient is removed.
1716 //priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageProxy.get())))));
1717 priv->settings = adoptPtr(new Ewk_Settings(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageClient->page())))));
1720 priv->context = context;
1722 ewkViewContextMenuClientAttachClient(ewkView);
1723 ewkViewFindClientAttatchClient(ewkView);
1724 ewkViewTizenClientAttachClient(ewkView);
1725 ewkViewUIClientAttatchClient(ewkView);
1727 #if ENABLE(TIZEN_GEOLOCATION)
1728 ewkViewGeolocationProviderAttachProvider(ewkView, ewk_context_WKContext_get(context));
1731 #if ENABLE(TIZEN_NOTIFICATIONS)
1732 ewkViewNotificationProviderAttachProvider(ewkView, ewk_context_WKContext_get(context));
1735 #if ENABLE(TIZEN_ICON_DATABASE)
1736 ewk_view_icondatabase_client_attach(ewkView, ewk_context_WKContext_get(context));
1739 ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1740 ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1741 ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1742 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1743 ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1745 ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1746 #else // #if OS(TIZEN)
1747 priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageClient->page()->backForwardList()));
1749 #if USE(COORDINATED_GRAPHICS)
1750 priv->viewportHandler = EflViewportHandler::create(priv->pageClient.get());
1752 #endif // #if OS(TIZEN)
1754 WKPageRef wkPage = toAPI(priv->pageClient->page());
1755 ewk_view_form_client_attach(wkPage, ewkView);
1756 ewk_view_loader_client_attach(wkPage, ewkView);
1757 ewk_view_policy_client_attach(wkPage, ewkView);
1758 ewk_view_resource_load_client_attach(wkPage, ewkView);
1760 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1761 ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1764 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1765 if (!ewk_context_x_window_get(context))
1766 ewk_context_x_window_set(context, elm_win_xwindow_get(ewkView));
1770 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1772 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1773 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1775 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1776 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1777 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1782 Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1786 EWK_VIEW_SD_GET(ewkView, smartData);
1788 evas_object_del(ewkView);
1792 EWK_VIEW_PRIV_GET(smartData, priv);
1794 evas_object_del(ewkView);
1803 * Constructs a ewk_view Evas_Object with WKType parameters.
1805 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1807 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1808 EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1810 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1814 _ewk_view_initialize(ewkView, ewk_context_new_from_WKContext(contextRef), pageGroupRef);
1819 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1821 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1822 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1823 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1825 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1829 #if ENABLE(TIZEN_ICON_DATABASE)
1830 //set default iconDatabasePath
1831 WKContextRef contextRef = ewk_context_WKContext_get(context);
1832 toImpl(contextRef)->setIconDatabasePath(toImpl(contextRef)->iconDatabasePath());
1835 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1836 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1837 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1838 _ewk_view_initialize(ewkView, context, toAPI(priv->pageGroup.get()));
1840 _ewk_view_initialize(ewkView, context, 0);
1846 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1848 return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1851 Evas_Object* ewk_view_add(Evas* canvas)
1853 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1858 * The uri of view was changed by the frame loader.
1860 * Emits signal: "uri,changed" with pointer to new uri string.
1862 void ewk_view_uri_update(Evas_Object* ewkView)
1864 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1865 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1867 String activeURL = priv->pageClient->page()->activeURL();
1868 if (activeURL.isEmpty())
1871 if (!eina_stringshare_replace(&priv->uri, activeURL.utf8().data()))
1874 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1875 evas_object_smart_callback_call(ewkView, "url,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1878 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* uri)
1880 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1881 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1882 EINA_SAFETY_ON_NULL_RETURN_VAL(uri, false);
1884 priv->pageClient->page()->loadURL(String::fromUTF8(uri));
1885 ewk_view_uri_update(ewkView);
1890 const char* ewk_view_url_get(const Evas_Object* ewkView)
1892 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1893 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1898 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1900 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1901 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1903 priv->pageClient->page()->reload(/*reloadFromOrigin*/ false);
1904 ewk_view_uri_update(ewkView);
1909 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1911 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1912 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1914 priv->pageClient->page()->reload(/*reloadFromOrigin*/ true);
1915 ewk_view_uri_update(ewkView);
1920 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1922 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1923 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1925 priv->pageClient->page()->stopLoading();
1930 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1932 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1933 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1935 return priv->settings.get();
1940 * Load was initiated for a resource in the view.
1942 * Emits signal: "resource,request,new" with pointer to resource request.
1944 void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request)
1946 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1947 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1949 Ewk_Web_Resource_Request resourceRequest = {resource, request, 0};
1951 // Keep the resource internally to reuse it later.
1952 ewk_web_resource_ref(resource);
1953 priv->loadingResourcesMap.add(resourceIdentifier, resource);
1955 evas_object_smart_callback_call(ewkView, "resource,request,new", &resourceRequest);
1960 * Received a response to a resource load request in the view.
1962 * Emits signal: "resource,request,response" with pointer to resource response.
1964 void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response)
1966 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1967 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1969 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
1972 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
1973 Ewk_Web_Resource_Load_Response resourceLoadResponse = {resource, response};
1974 evas_object_smart_callback_call(ewkView, "resource,request,response", &resourceLoadResponse);
1979 * Failed loading a resource in the view.
1981 * Emits signal: "resource,request,finished" with pointer to the resource load error.
1983 void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Error* error)
1985 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1986 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1988 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
1991 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
1992 Ewk_Web_Resource_Load_Error resourceLoadError = {resource, error};
1993 evas_object_smart_callback_call(ewkView, "resource,request,failed", &resourceLoadError);
1998 * Finished loading a resource in the view.
2000 * Emits signal: "resource,request,finished" with pointer to the resource.
2002 void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIdentifier)
2004 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2005 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2007 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2010 Ewk_Web_Resource* resource = priv->loadingResourcesMap.take(resourceIdentifier);
2011 evas_object_smart_callback_call(ewkView, "resource,request,finished", resource);
2013 ewk_web_resource_unref(resource);
2018 * Request was sent for a resource in the view.
2020 * Emits signal: "resource,request,sent" with pointer to resource request and possible redirect response.
2022 void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse)
2024 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2025 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2027 if (!priv->loadingResourcesMap.contains(resourceIdentifier))
2030 Ewk_Web_Resource* resource = priv->loadingResourcesMap.get(resourceIdentifier);
2031 Ewk_Web_Resource_Request resourceRequest = {resource, request, redirectResponse};
2033 evas_object_smart_callback_call(ewkView, "resource,request,sent", &resourceRequest);
2036 const char* ewk_view_title_get(const Evas_Object* ewkView)
2038 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2039 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2041 CString title = priv->pageClient->page()->pageTitle().utf8();
2042 eina_stringshare_replace(&priv->title, title.data());
2049 * Reports that the requested text was found.
2051 * Emits signal: "text,found" with the number of matches.
2053 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
2055 evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
2060 * The view title was changed by the frame loader.
2062 * Emits signal: "title,changed" with pointer to new title string.
2064 void ewk_view_title_changed(Evas_Object* ewkView, const char* title)
2066 evas_object_smart_callback_call(ewkView, "title,changed", const_cast<char*>(title));
2069 double ewk_view_load_progress_get(const Evas_Object* ewkView)
2071 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2072 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2074 return priv->pageClient->page()->estimatedProgress();
2077 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
2079 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2080 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2086 scaleFactor = priv->pageClient->adjustScaleWithViewport(scaleFactor);
2088 IntPoint scrollPosition = priv->pageClient->scrollPosition();
2089 double scaleDifference = scaleFactor / priv->pageClient->scaleFactor();
2090 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
2091 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
2093 priv->pageClient->page()->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
2095 priv->pageClient->page()->scalePage(scaleFactor, IntPoint(x, y));
2100 double ewk_view_scale_get(const Evas_Object* ewkView)
2102 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
2103 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1);
2106 return priv->pageClient->page()->scaleFactor();
2108 return priv->pageClient->page()->pageScaleFactor();
2112 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
2114 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2115 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2117 priv->pageClient->page()->setCustomDeviceScaleFactor(ratio);
2122 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
2124 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
2125 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1.0);
2127 return priv->pageClient->page()->deviceScaleFactor();
2130 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
2131 void ewk_view_load_progress_started(Evas_Object* ewkView)
2133 evas_object_smart_callback_call(ewkView, "load,progress,started", 0);
2139 * Reports load progress changed.
2141 * Emits signal: "load,progress" with pointer to a double from 0.0 to 1.0.
2143 void ewk_view_load_progress_changed(Evas_Object* ewkView, double progress)
2145 evas_object_smart_callback_call(ewkView, "load,progress", &progress);
2148 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
2149 void ewk_view_load_progress_finished(Evas_Object* ewkView)
2151 evas_object_smart_callback_call(ewkView, "load,progress,finished", 0);
2155 #if ENABLE(WEB_INTENTS)
2158 * The view received a new intent request.
2160 * Emits signal: "intent,request,new" with pointer to a Ewk_Intent.
2162 void ewk_view_intent_request_new(Evas_Object* ewkView, const Ewk_Intent* ewkIntent)
2164 evas_object_smart_callback_call(ewkView, "intent,request,new", const_cast<Ewk_Intent*>(ewkIntent));
2168 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
2170 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2171 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2173 if (!eina_stringshare_replace(&priv->theme, path))
2176 priv->pageClient->page()->setThemePath(path);
2179 const char* ewk_view_theme_get(const Evas_Object* ewkView)
2181 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2182 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2187 void ewk_view_cursor_set(Evas_Object* ewkView, const Cursor& cursor)
2189 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2190 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2192 const char* group = cursor.platformCursor();
2193 if (!group || group == priv->cursorGroup)
2196 priv->cursorGroup = group;
2198 if (priv->cursorObject)
2199 evas_object_del(priv->cursorObject);
2200 priv->cursorObject = edje_object_add(smartData->base.evas);
2202 Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
2203 if (!priv->theme || !edje_object_file_set(priv->cursorObject, priv->theme, group)) {
2204 evas_object_del(priv->cursorObject);
2205 priv->cursorObject = 0;
2207 ecore_evas_object_cursor_set(ecoreEvas, 0, 0, 0, 0);
2209 if (priv->isUsingEcoreX)
2210 WebCore::applyFallbackCursor(ecoreEvas, group);
2215 Evas_Coord width, height;
2216 edje_object_size_min_get(priv->cursorObject, &width, &height);
2217 if (width <= 0 || height <= 0)
2218 edje_object_size_min_calc(priv->cursorObject, &width, &height);
2219 if (width <= 0 || height <= 0) {
2220 width = defaultCursorSize;
2221 height = defaultCursorSize;
2223 evas_object_resize(priv->cursorObject, width, height);
2227 data = edje_object_data_get(priv->cursorObject, "hot.x");
2229 hotspotX = atoi(data);
2232 data = edje_object_data_get(priv->cursorObject, "hot.y");
2234 hotspotY = atoi(data);
2236 ecore_evas_object_cursor_set(ecoreEvas, priv->cursorObject, EVAS_LAYER_MAX, hotspotX, hotspotY);
2239 void ewk_view_display(Evas_Object* ewkView, const IntRect& rect)
2241 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2242 if (!smartData->image)
2245 evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height());
2250 * A download for that view was cancelled.
2252 * Emits signal: "download,cancelled" with pointer to a Ewk_Download_Job.
2254 void ewk_view_download_job_cancelled(Evas_Object* ewkView, Ewk_Download_Job* download)
2256 evas_object_smart_callback_call(ewkView, "download,cancelled", download);
2261 * A new download has been requested for that view.
2263 * Emits signal: "download,request" with pointer to a Ewk_Download_Job.
2265 void ewk_view_download_job_requested(Evas_Object* ewkView, Ewk_Download_Job* download)
2267 evas_object_smart_callback_call(ewkView, "download,request", download);
2272 * A download for that view has failed.
2274 * Emits signal: "download,failed" with pointer to a Ewk_Download_Job_Error.
2276 void ewk_view_download_job_failed(Evas_Object* ewkView, Ewk_Download_Job* download, Ewk_Web_Error* error)
2278 Ewk_Download_Job_Error downloadError = { download, error };
2279 evas_object_smart_callback_call(ewkView, "download,failed", &downloadError);
2284 * A download for that view finished successfully.
2286 * Emits signal: "download,finished" with pointer to a Ewk_Download_Job.
2288 void ewk_view_download_job_finished(Evas_Object* ewkView, Ewk_Download_Job* download)
2290 evas_object_smart_callback_call(ewkView, "download,finished", download);
2293 Eina_Bool ewk_view_back(Evas_Object* ewkView)
2295 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2296 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2298 WebPageProxy* page = priv->pageClient->page();
2299 if (page->canGoBack()) {
2307 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
2309 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2310 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2312 WebPageProxy* page = priv->pageClient->page();
2313 if (page->canGoForward()) {
2321 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
2323 #if ENABLE(WEB_INTENTS)
2324 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2325 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2326 EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
2328 WebPageProxy* page = priv->pageClient->page();
2329 page->deliverIntentToFrame(page->mainFrame(), toImpl(ewk_intent_WKIntentDataRef_get(intent)));
2337 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
2339 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2340 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2342 return priv->pageClient->page()->canGoBack();
2345 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
2347 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2348 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2350 return priv->pageClient->page()->canGoForward();
2353 void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size)
2355 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2356 if (!imageData || !smartData->image)
2359 evas_object_resize(smartData->image, size.width(), size.height());
2360 evas_object_image_size_set(smartData->image, size.width(), size.height());
2361 evas_object_image_data_copy_set(smartData->image, imageData);
2366 * Reports that a form request is about to be submitted.
2368 * Emits signal: "form,submission,request" with pointer to Ewk_Form_Submission_Request.
2370 void ewk_view_form_submission_request_new(Evas_Object* ewkView, Ewk_Form_Submission_Request* request)
2372 evas_object_smart_callback_call(ewkView, "form,submission,request", request);
2375 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2376 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
2378 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2379 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2381 if (!ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
2384 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(ewkView);
2385 if (!imfContext || ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
2388 if (value.isEmpty()) {
2389 if(smartData->api->formdata_candidate_is_showing(smartData))
2390 smartData->api->formdata_candidate_hide(smartData);
2394 Vector<String> popupCandidates;
2395 ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
2396 std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
2398 Eina_List* candidateList = 0;
2399 for (size_t i = 0; i < popupCandidates.size(); ++i) {
2400 if (popupCandidates[i].startsWith(value, false))
2401 candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
2404 if (!eina_list_count(candidateList)) {
2405 if(smartData->api->formdata_candidate_is_showing(smartData))
2406 smartData->api->formdata_candidate_hide(smartData);
2410 smartData->api->formdata_candidate_update_data(smartData, candidateList);
2412 if (!smartData->api->formdata_candidate_is_showing(smartData))
2413 smartData->api->formdata_candidate_hide(smartData);
2415 IntRect inputFieldRect = priv->pageClient->focusedNodeRect();
2416 smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
2419 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm)
2421 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2422 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2423 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
2424 && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
2426 ewk_context_form_data_add(ewk_view_context_get(ewkView), priv->uri, formData, isPasswordForm);
2429 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
2431 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2432 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2434 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
2437 Vector<std::pair<String, String> > passwordFormData;
2438 ewk_context_form_password_data_get(ewk_view_context_get(ewkView), priv->uri, passwordFormData);
2440 if (!passwordFormData.size())
2443 String passwordFormAutofill = "try { function passwordFormAutofill() { var inputFields;";
2444 for (size_t i = 0; i < passwordFormData.size(); i++) {
2445 passwordFormAutofill += String::format(" inputFields = document.getElementsByName(\"%s\");"
2446 " for (var i = 0; i < inputFields.length; i++)"
2447 " if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\"))"
2448 " inputFields[i].value = \"%s\";",
2449 passwordFormData[i].first.utf8().data(), passwordFormData[i].second.utf8().data());
2451 passwordFormAutofill += "} passwordFormAutofill(); } catch(e) { }";
2452 ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
2455 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
2457 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2458 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2459 ewk_context_form_candidate_data_get(ewk_view_context_get(ewkView), name, candidates);
2465 * Reports load failed with error information.
2467 * Emits signal: "load,error" with pointer to Ewk_Web_Error.
2469 void ewk_view_load_error(Evas_Object* ewkView, const Ewk_Web_Error* error)
2471 evas_object_smart_callback_call(ewkView, "load,error", const_cast<Ewk_Web_Error*>(error));
2476 * Reports load finished.
2478 * Emits signal: "load,finished".
2480 void ewk_view_load_finished(Evas_Object* ewkView)
2482 ewk_view_uri_update(ewkView);
2483 evas_object_smart_callback_call(ewkView, "load,finished", 0);
2485 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2486 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2488 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
2489 priv->pageClient->page()->setLoadingFinished(true);
2492 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2493 ewk_view_form_password_data_fill(ewkView);
2496 if (!priv->suspendRequested)
2499 priv->suspendRequested = false;
2501 if (!priv->suspendedPainting) {
2502 priv->pageClient->page()->suspendPainting();
2503 priv->suspendedPainting = true;
2505 if (!priv->suspendedResources) {
2506 priv->pageClient->page()->suspendJavaScriptAndResource();
2507 priv->suspendedResources = true;
2513 * Reports view provisional load failed with error information.
2515 * Emits signal: "load,provisional,failed" with pointer to Ewk_Web_Error.
2517 void ewk_view_load_provisional_failed(Evas_Object* ewkView, const Ewk_Web_Error* error)
2519 evas_object_smart_callback_call(ewkView, "load,provisional,failed", const_cast<Ewk_Web_Error*>(error));
2524 * Reports view received redirect for provisional load.
2526 * Emits signal: "load,provisional,redirect".
2528 void ewk_view_load_provisional_redirect(Evas_Object* ewkView)
2530 ewk_view_uri_update(ewkView);
2531 evas_object_smart_callback_call(ewkView, "load,provisional,redirect", 0);
2536 * Reports view provisional load started.
2538 * Emits signal: "load,provisional,started".
2540 void ewk_view_load_provisional_started(Evas_Object* ewkView)
2543 evas_object_smart_callback_call(ewkView, "load,started", 0);
2546 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2547 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2549 #if ENABLE(TIZEN_DRAG_SUPPORT)
2550 if (priv->pageClient->isDragMode())
2551 priv->pageClient->setDragMode(false);
2554 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
2555 priv->pageClient->page()->setLoadingFinished(false);
2558 // The main frame started provisional load, we should clear
2559 // the loadingResources HashMap to start clean.
2560 _ewk_view_priv_loading_resources_clear(priv->loadingResourcesMap);
2562 ewk_view_uri_update(ewkView);
2563 evas_object_smart_callback_call(ewkView, "load,provisional,started", 0);
2568 * Reports that a navigation policy decision should be taken.
2570 * Emits signal: "policy,decision,navigation".
2572 void ewk_view_navigation_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision)
2574 evas_object_smart_callback_call(ewkView, "policy,decision,navigation", decision);
2579 * Reports that a new window policy decision should be taken.
2581 * Emits signal: "policy,decision,new,window".
2583 void ewk_view_new_window_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision)
2585 evas_object_smart_callback_call(ewkView, "policy,decision,new,window", decision);
2588 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
2590 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2591 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2592 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
2594 if (unreachableUrl && *unreachableUrl)
2595 priv->pageClient->page()->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
2597 priv->pageClient->page()->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
2598 ewk_view_uri_update(ewkView);
2603 #if ENABLE(WEB_INTENTS_TAG)
2606 * The view received a new intent service registration.
2608 * Emits signal: "intent,service,register" with pointer to a Ewk_Intent_Service.
2610 void ewk_view_intent_service_register(Evas_Object* ewkView, const Ewk_Intent_Service* ewkIntentService)
2612 evas_object_smart_callback_call(ewkView, "intent,service,register", const_cast<Ewk_Intent_Service*>(ewkIntentService));
2614 #endif // ENABLE(WEB_INTENTS_TAG)
2616 WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView)
2618 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2619 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2621 return priv->pageClient->page();
2624 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
2626 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2627 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2629 String customEncoding = priv->pageClient->page()->customTextEncodingName();
2630 if (customEncoding.isEmpty())
2633 eina_stringshare_replace(&priv->customEncoding, customEncoding.utf8().data());
2635 return priv->customEncoding;
2638 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
2640 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2641 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2643 if (eina_stringshare_replace(&priv->customEncoding, encoding))
2644 priv->pageClient->page()->setCustomTextEncodingName(encoding ? String::fromUTF8(encoding) : String());
2650 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
2652 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2653 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2654 return priv->context;
2657 // FIXME: It should be removed.
2658 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
2660 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2661 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2663 return toAPI(priv->pageClient->page());
2666 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
2668 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2669 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2671 enabled = !!enabled;
2672 if (priv->areMouseEventsEnabled == enabled)
2675 priv->areMouseEventsEnabled = enabled;
2677 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down, smartData);
2678 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up, smartData);
2679 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move, smartData);
2681 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
2682 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
2683 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
2689 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
2691 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2692 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2694 return priv->areMouseEventsEnabled;
2697 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
2699 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2700 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2702 return priv->javascriptPopup->alert(alertText);
2705 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
2707 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2708 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2710 return priv->javascriptPopup->confirm(message);
2713 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
2715 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2716 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2718 return priv->javascriptPopup->prompt(message, defaultValue);
2721 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
2722 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, void* userData)
2724 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2725 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2727 return priv->javascriptPopup->beforeUnloadConfirmPanel(message);
2731 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)
2733 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2734 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2736 return priv->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, priv);
2739 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
2740 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)
2742 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2744 if (priv->popupPicker)
2745 ewk_popup_picker_del(priv->popupPicker);
2747 #if ENABLE(TIZEN_MULTIPLE_SELECT)
2748 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
2750 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
2756 #if ENABLE(TIZEN_MULTIPLE_SELECT)
2757 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)
2759 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2761 if (priv->popupPicker)
2762 ewk_popup_picker_del(priv->popupPicker);
2764 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
2770 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
2772 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2774 if (!priv->popupPicker)
2777 ewk_popup_picker_del(priv->popupPicker);
2778 priv->popupPicker = 0;
2783 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)
2785 // FIXME: The rect should be updated if it was changed
2787 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2789 if (!priv->popupPicker)
2792 ewk_popup_picker_update(smartData->self, priv->popupPicker, items, selectedIndex);
2798 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
2799 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
2801 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2803 priv->inputPicker->show(inputType, inputValue);
2808 #if ENABLE(TIZEN_DATALIST_ELEMENT)
2809 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
2811 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2813 priv->inputPicker->showDataList(inputType, optionList);
2817 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
2819 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2821 priv->inputPicker->hideDataList(inputType);
2826 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
2827 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
2829 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2831 priv->inputPicker->showColorPicker(r, g, b, a);
2835 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
2837 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2839 priv->inputPicker->hideColorPicker();
2844 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
2846 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2847 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2849 return priv->pageClient.get();
2852 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
2854 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
2855 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1);
2857 return WKPageGetTextZoomFactor(toAPI(priv->pageClient->page()));
2860 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
2862 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2863 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2865 WKPageSetTextZoomFactor(toAPI(priv->pageClient->page()), textZoomFactor);
2869 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
2870 FocusRing* ewkViewGetFocusRing(Evas_Object* ewkView)
2872 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2873 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2875 return priv->focusRing.get();
2879 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
2881 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2882 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2884 return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(priv->pageClient->page())));
2887 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
2889 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2890 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2892 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(priv->pageClient->page())));
2895 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
2897 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2898 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2900 if (!priv->javascriptGlobalContext)
2901 priv->javascriptGlobalContext = JSGlobalContextCreate(0);
2902 return priv->javascriptGlobalContext;
2905 void ewkViewLoadCommitted(Evas_Object* ewkView)
2907 #if ENABLE(TIZEN_GESTURE)
2908 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2909 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2910 priv->gestureClient->reset();
2912 #if ENABLE(TIZEN_ISF_PORT)
2913 ewk_view_imf_context_hide(ewkView);
2915 ewk_view_uri_update(ewkView);
2916 evas_object_smart_callback_call(ewkView, "load,committed", 0);
2919 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
2921 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2922 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2924 Ewk_Error* ewkError = ewkErrorCreate(error);
2925 ewkErrorLoadErrorPage(ewkError, toAPI(priv->pageClient->page()));
2926 evas_object_smart_callback_call(ewkView, "load,error", ewkError);
2927 ewkErrorDelete(ewkError);
2930 void ewkViewSetTitleAndURL(Evas_Object* ewkView, const char* title, const char* url)
2932 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2933 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2935 if (title && eina_stringshare_replace(&priv->title, title))
2936 evas_object_smart_callback_call(ewkView, "title,changed", static_cast<void*>(const_cast<char*>(priv->title)));
2937 if (url && eina_stringshare_replace(&priv->uri, url))
2938 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
2941 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
2943 #if ENABLE(TIZEN_GESTURE)
2944 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2945 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2946 priv->gestureClient->reset();
2948 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
2951 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
2953 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2954 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2956 if (priv->authChallenge)
2957 ewkAuthChallengeDelete(priv->authChallenge);
2958 priv->authChallenge = authChallenge;
2960 evas_object_smart_callback_call(ewkView, "authentication,challenge", priv->authChallenge);
2963 void ewk_view_process_crashed(Evas_Object* ewkView)
2965 bool handled = false;
2966 evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
2972 #if ENABLE(TIZEN_SQL_DATABASE)
2973 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)
2975 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, currentQuota);
2976 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, currentQuota);
2978 TIZEN_LOGI("database,quota,exceeded");
2979 uint64_t defaultQuota = ewkContextGetDatabaseQuota(priv->context);
2980 if (defaultQuota >= expectedUsage + currentQuota)
2981 return defaultQuota;
2983 if (priv->exceededDatabaseQuota)
2984 ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
2985 priv->exceededDatabaseQuota = ewkContextCreateExceededQuota(origin, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
2986 evas_object_smart_callback_call(ewkView, "database,quota,exceeded", priv->exceededDatabaseQuota);
2988 return ewkContextGetNewQuotaForExceededQuota(priv->context, priv->exceededDatabaseQuota);
2992 #if ENABLE(TIZEN_NOTIFICATIONS)
2993 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
2995 TIZEN_LOGI("notification,cancel");
2996 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
2999 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
3001 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3002 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3004 TIZEN_LOGI("notification,permission,request");
3005 priv->notificationPermissionRequests = eina_list_append(priv->notificationPermissionRequests, notificationPermissionRequest);
3006 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
3009 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
3011 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3012 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3014 TIZEN_LOGI("notification,show");
3015 Eina_List* listIterator=0;
3017 const char* replaceID = ewkNotificationGetReplaceID(notification);
3018 if(strlen(replaceID)) {
3019 EINA_LIST_FOREACH(priv->notifications, listIterator, data) {
3020 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
3021 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
3022 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
3026 priv->notifications = eina_list_append(priv->notifications, notification);
3027 evas_object_smart_callback_call(ewkView, "notification,show", notification);
3030 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
3032 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3033 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3035 priv->notificationPermissionRequests = eina_list_remove(priv->notificationPermissionRequests, ewkNotificationPermissionRequest);
3039 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
3040 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
3042 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3044 TIZEN_LOGI("protocolhandler,registration,requested");
3045 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
3046 evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
3047 ewkCustomHandlersDeleteData(customHandlersData);
3051 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
3052 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
3054 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
3056 TIZEN_LOGI("protocolhandler,isregistered");
3057 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
3058 evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
3060 Ewk_Custom_Handlers_State result;
3061 result = ewkGetCustomHandlersDataResult(customHandlersData);
3062 ewkCustomHandlersDeleteData(customHandlersData);
3067 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
3069 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3071 TIZEN_LOGI("protocolhandler,unregistration,requested");
3072 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
3073 evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
3074 ewkCustomHandlersDeleteData(customHandlersData);
3078 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
3079 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
3081 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3083 TIZEN_LOGI("contenthandler,registration,requested");
3084 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
3085 evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
3086 ewkCustomHandlersDeleteData(customHandlersData);
3089 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
3091 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
3093 TIZEN_LOGI("contenthandler,isregistered");
3094 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
3095 evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
3097 Ewk_Custom_Handlers_State result;
3098 result = ewkGetCustomHandlersDataResult(customHandlersData);
3099 ewkCustomHandlersDeleteData(customHandlersData);
3104 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
3106 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3108 TIZEN_LOGI("contenthandler,unregistration,requested");
3109 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
3110 evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
3111 ewkCustomHandlersDeleteData(customHandlersData);
3115 #if ENABLE(TIZEN_SEARCH_PROVIDER)
3116 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
3118 EINA_SAFETY_ON_NULL_RETURN(ewkView);
3120 TIZEN_LOGI("searchProvider,add");
3121 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
3122 evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
3123 ewkSearchProviderDeleteData(searchProviderData);
3126 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
3128 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3130 TIZEN_LOGI("searchProvider,installed");
3131 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
3132 evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
3133 unsigned long result;
3134 result = ewkGetSearchProviderResult(searchProviderData);
3135 ewkSearchProviderDeleteData(searchProviderData);
3140 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3141 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
3143 bool standalone = true;
3144 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
3149 #if ENABLE(TIZEN_MEDIA_STREAM)
3150 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
3152 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3153 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3155 priv->userMediaPermissionRequests = eina_list_append(priv->userMediaPermissionRequests, userMediaPermission);
3156 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
3159 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
3161 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3162 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3164 priv->userMediaPermissionRequests = eina_list_remove(priv->userMediaPermissionRequests, permission);
3169 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
3170 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
3172 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
3173 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
3174 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
3175 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
3176 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
3177 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
3179 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
3183 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
3184 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
3186 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3187 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3188 if (priv->certificatePolicyDecision)
3189 ewkCertificatePolicyDecisionDelete(priv->certificatePolicyDecision);
3190 priv->certificatePolicyDecision = certificatePolicyDecision;
3192 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
3196 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
3198 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
3201 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
3203 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
3206 void ewkViewClosePage(Evas_Object* ewkView)
3208 evas_object_smart_callback_call(ewkView, "close,window", 0);
3211 #if ENABLE(TIZEN_GEOLOCATION)
3212 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
3214 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3215 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3217 TIZEN_LOGI("geolocation,permission,request");
3218 priv->geolocationPermissionRequests = eina_list_append(priv->geolocationPermissionRequests, geolocationPermissionRequest);
3219 evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
3222 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
3224 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3225 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3227 priv->geolocationPermissionRequests = eina_list_remove(priv->geolocationPermissionRequests, geolocationPermissionRequest);
3230 void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
3232 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3233 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3235 priv->geolocation = geolocation;
3238 Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
3240 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3241 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3243 return priv->geolocation;
3246 bool ewkViewIsValidLocationService(Evas_Object* ewkView)
3248 TIZEN_LOGI("geolocation,valid");
3251 evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
3256 WKPageRef ewkViewCreateNewPage(Evas_Object* ewkView)
3258 Evas_Object* createdEwkView = 0;
3260 evas_object_smart_callback_call(ewkView, "create,window", &createdEwkView);
3262 if (!createdEwkView)
3265 return static_cast<WKPageRef>(WKRetain(toAPI(ewk_view_page_get(createdEwkView))));
3268 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
3270 evas_object_smart_callback_call(ewkView, "form,submit", formData);
3273 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3275 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3276 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3277 if (priv->policyDecision)
3278 ewkPolicyDecisionDelete(priv->policyDecision);
3279 priv->policyDecision = policyDecision;
3281 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", priv->policyDecision);
3284 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3286 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3287 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3288 if (priv->policyDecision)
3289 ewkPolicyDecisionDelete(priv->policyDecision);
3290 priv->policyDecision = policyDecision;
3292 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", priv->policyDecision);
3295 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
3297 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
3298 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
3299 if (priv->policyDecision)
3300 ewkPolicyDecisionDelete(priv->policyDecision);
3301 priv->policyDecision = policyDecision;
3303 evas_object_smart_callback_call(ewkView, "policy,response,decide", priv->policyDecision);
3306 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
3308 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3309 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3311 IntPoint scrollPosition = priv->pageClient->scrollPosition();
3312 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3313 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3314 contentsSize.scale(priv->pageClient->scaleFactor());
3317 // some website's contents size is smaller than view size,
3318 // so we have to adjust contents size to view size for that case.
3319 if (contentsSize.width() < smartData->view.w)
3320 contentsSize.setWidth(smartData->view.w);
3321 if (contentsSize.height() < smartData->view.h)
3322 contentsSize.setHeight(smartData->view.h);
3324 // Call "scroll,down" if webview can be scrolled down.
3325 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
3326 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
3327 // Call "scroll,up" if webview can be scrolled up.
3328 else if (deltaY < 0 && scrollPosition.y() > 0)
3329 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
3331 // Call "scroll,right" if webview can be scrolled down.
3332 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
3333 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
3334 // Call "scroll,left" if webview can be scrolled up.
3335 else if (deltaX < 0 && scrollPosition.x() > 0)
3336 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
3339 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
3341 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3342 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3344 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3345 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3346 contentsSize.scale(priv->pageClient->scaleFactor());
3349 int maxScrollY = contentsSize.height() - smartData->view.h;
3350 if (!priv->isVerticalEdge) {
3351 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
3352 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
3353 priv->isVerticalEdge = true;
3354 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
3355 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
3356 priv->isVerticalEdge = true;
3359 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
3360 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
3361 priv->isVerticalEdge = false;
3364 int maxScrollX = contentsSize.width() - smartData->view.w;
3365 if (!priv->isHorizontalEdge) {
3366 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
3367 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
3368 priv->isHorizontalEdge = true;
3369 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
3370 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
3371 priv->isHorizontalEdge = true;
3374 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
3375 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
3376 priv->isHorizontalEdge = false;
3380 void ewkViewClearEdges(Evas_Object* ewkView)
3382 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3383 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3385 priv->isVerticalEdge = false;
3386 priv->isHorizontalEdge = false;
3389 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
3391 EWK_VIEW_SD_GET(ewkView, smartData);
3392 if (!smartData || !smartData->priv) {
3400 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
3402 *minimumScale = constraints.minimumScale;
3404 *maximumScale = constraints.maximumScale;
3407 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard)
3409 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3410 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3412 double scaleFactor = priv->pageClient->scaleFactor();
3413 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3415 double newScaleFactor = scaleFactor;
3416 // Readable zoom value is dependent on device DPI
3417 if (scaleFactor < priv->pageClient->page()->deviceScaleFactor()
3418 && priv->pageClient->viewportConstraints().userScalable)
3419 newScaleFactor = priv->pageClient->page()->deviceScaleFactor();
3421 // Readable zoom value should be inside of viewport scale range
3422 newScaleFactor = priv->pageClient->adjustScaleWithViewport(newScaleFactor);
3424 // scale contents' size with new scale factor
3425 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3426 contentsSize.scale(newScaleFactor);
3428 contentsSize.scale(newScaleFactor / scaleFactor);
3431 #if ENABLE(TIZEN_ISF_PORT)
3432 Ecore_X_Window rootWin = ecore_x_window_root_first_get();
3433 ecore_x_event_mask_set(rootWin, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
3434 Ecore_X_Atom xAtom = ecore_x_atom_get("X External Keyboard Exist");
3435 unsigned int connectedKeyboardNum = 0;
3436 bool isExternalKeyboardConnected = false;
3438 // get connected keyboard number
3439 if (ecore_x_window_prop_card32_get(rootWin, xAtom, &connectedKeyboardNum, 1)
3440 && connectedKeyboardNum)
3441 isExternalKeyboardConnected = true;
3443 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
3444 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
3445 // input field zoom should not work with below conditions
3446 // 1. view is not focused
3447 // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
3448 // 3. imfContext is null(if adjustForExternalKeyboard is false)
3449 // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
3450 if ((!(static_cast<PageClient*>(priv->pageClient.get()))->isViewFocused()
3451 || (adjustForExternalKeyboard && !isExternalKeyboardConnected)
3452 || (!adjustForExternalKeyboard && !priv->imfContext)
3453 || (!adjustForExternalKeyboard && ecore_imf_context_input_panel_state_get(priv->imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE))
3454 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
3455 && !(priv->pageClient->isClipboardWindowOpened())
3461 IntSize visibleSize(smartData->view.w, smartData->view.h);
3462 // caret position can be outside of visible rect.
3463 // we need to consider it.
3464 IntRect selectionRect = priv->pageClient->page()->getSelectionRect(true);
3465 IntRect focusedNodeRect = priv->pageClient->focusedNodeRect();
3466 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3467 selectionRect.scale(newScaleFactor);
3468 focusedNodeRect.scale(newScaleFactor);
3470 selectionRect.scale(newScaleFactor / scaleFactor);
3471 focusedNodeRect.scale(newScaleFactor / scaleFactor);
3473 if (selectionRect.isEmpty())
3477 IntPoint scrollPosition(selectionRect.x() - visibleSize.width() / 3, selectionRect.y() - visibleSize.height() / 3);
3478 // If both input field's position x and selection rect can be displayed together,
3479 // adjust scroll position to input field's position x.
3480 if (!focusedNodeRect.isEmpty()
3481 && selectionRect.x() - focusedNodeRect.x() < visibleSize.width() * 4 / 5)
3482 scrollPosition.setX(focusedNodeRect.x());
3484 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3485 priv->pageClient->setVisibleContentRect(IntRect(scrollPosition, ewk_view_size_get(ewkView)), newScaleFactor);
3487 if (newScaleFactor != scaleFactor)
3488 priv->pageClient->page()->scalePage(newScaleFactor, scrollPosition);
3490 priv->pageClient->page()->scrollMainFrameTo(scrollPosition);
3492 evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
3496 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
3497 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
3498 static Eina_Bool _ewk_view_composite(void* data)
3500 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
3501 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
3503 if (!evas_object_visible_get(smartData->image))
3504 return ECORE_CALLBACK_CANCEL;
3507 evas_object_image_size_get(smartData->image, &ow, &oh);
3508 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
3510 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)));
3511 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
3513 cairo_save(context.get());
3514 cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
3515 cairo_rectangle(context.get(), 0, 0, ow, oh);
3516 cairo_fill(context.get());
3517 cairo_restore(context.get());
3519 priv->pageClient->drawContents(context.get());
3521 evas_object_image_data_set(smartData->image, pixels);
3522 evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
3524 ewkViewFrameRendered(smartData->self);
3526 priv->compositionAnimator = 0;
3528 return ECORE_CALLBACK_CANCEL;
3532 void ewk_view_mark_for_sync(Evas_Object* ewkView)
3534 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3535 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
3537 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
3538 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3540 if (!ewk_view_is_opengl_backend(ewkView)) {
3541 if (!priv->compositionAnimator)
3542 priv->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
3547 evas_object_image_pixels_dirty_set(smartData->image, true);
3550 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
3552 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
3553 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3554 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3555 priv->pageClient->drawContents();
3558 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
3560 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3561 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3563 if (!smartData->image)
3566 evas_object_image_native_surface_set(smartData->image, nativeSurface);
3567 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
3573 void _ewk_view_suspend_painting(Evas_Object* ewkView)
3575 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3576 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3578 if (!priv->suspendedPainting) {
3579 priv->pageClient->page()->suspendPainting();
3580 priv->suspendedPainting = true;
3584 void _ewk_view_resume_painting(Evas_Object* ewkView)
3586 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3587 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3589 if (priv->suspendedPainting) {
3590 priv->pageClient->page()->resumePainting();
3591 priv->suspendedPainting = false;
3595 void ewk_view_suspend(Evas_Object* ewkView)
3597 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3598 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3600 if (priv->pageClient->page()->estimatedProgress() < 1.0) {
3601 priv->suspendRequested = true;
3604 priv->suspendRequested = false;
3606 _ewk_view_suspend_painting(ewkView);
3608 // FIXME Workaround for suspend/resume while javascript popup is displayed.
3609 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
3610 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
3612 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
3613 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
3614 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
3615 // will be suspended again.
3616 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
3617 // the ActiveDOMObject.
3618 if (!priv->suspendedResources && !priv->isWaitingForJavaScriptPopupReply) {
3619 priv->pageClient->page()->suspendJavaScriptAndResource();
3620 priv->suspendedResources = true;
3623 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
3624 priv->pageClient->page()->suspendPlugin();
3628 void ewk_view_resume(Evas_Object* ewkView)
3630 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3631 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3633 if (priv->suspendRequested) {
3634 priv->suspendRequested = false;
3638 _ewk_view_resume_painting(ewkView);
3640 // FIXME Workaround for suspend/resume while javascript popup is displayed.
3641 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
3642 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
3644 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
3645 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
3646 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
3647 // will be suspended again.
3648 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
3649 // the ActiveDOMObject.
3650 if (priv->suspendedResources && !priv->isWaitingForJavaScriptPopupReply) {
3651 priv->pageClient->page()->resumeJavaScriptAndResource();
3652 priv->suspendedResources = false;
3655 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
3656 priv->pageClient->page()->resumePlugin();
3660 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
3662 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3663 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3664 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
3666 ResourceRequest request(String::fromUTF8(url));
3669 case EWK_HTTP_METHOD_GET:
3670 request.setHTTPMethod("GET");
3672 case EWK_HTTP_METHOD_HEAD:
3673 request.setHTTPMethod("HEAD");
3675 case EWK_HTTP_METHOD_POST:
3676 request.setHTTPMethod("POST");
3678 case EWK_HTTP_METHOD_PUT:
3679 request.setHTTPMethod("PUT");
3681 case EWK_HTTP_METHOD_DELETE:
3682 request.setHTTPMethod("DELETE");
3689 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
3691 while (eina_iterator_next(it, &data)) {
3692 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
3693 const char* name = static_cast<const char*>(t->key);
3694 const char* value = static_cast<const char*>(t->data);
3695 request.addHTTPHeaderField(name, value);
3697 eina_iterator_free(it);
3701 request.setHTTPBody(FormData::create(body));
3703 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
3704 WKPageLoadURLRequest(toAPI(priv->pageClient->page()), urlRequest.get());
3709 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
3711 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3712 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3714 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
3715 WKPageLoadPlainTextString(toAPI(priv->pageClient->page()), plainTextRef.get());
3720 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
3722 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3723 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3724 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
3726 if (contentsSize == 0)
3729 String mimeTypeString;
3731 mimeTypeString = String::fromUTF8(mimeType);
3733 mimeTypeString = String::fromUTF8("text/html");
3735 String encodingString;
3737 encodingString = String::fromUTF8(encoding);
3739 encodingString = String::fromUTF8("UTF-8");
3741 String baseUriString;
3743 baseUriString = String::fromUTF8(baseUri);
3745 baseUriString = String::fromUTF8("about:blank");
3747 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
3748 priv->pageClient->page()->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
3753 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
3755 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3756 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3758 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
3759 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
3761 WKPageLoadHTMLString(toAPI(priv->pageClient->page()), htmlString.get(), baseURL.get());
3766 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
3768 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3769 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3771 TIZEN_LOGI("initialState (%d)", initialState);
3772 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
3773 WKPageSetPageVisibility(toAPI(priv->pageClient->page()), static_cast<WKPageVisibilityState
3774 >(pageVisibilityState), initialState);
3782 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
3784 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
3786 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3787 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3789 eina_stringshare_replace(&priv->userAgent, userAgent);
3791 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
3792 WKPageSetCustomUserAgent(toAPI(priv->pageClient->page()), userAgentString.get());
3797 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
3799 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3800 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3802 if (!priv->userAgent) {
3803 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(priv->pageClient->page())));
3805 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
3806 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3807 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
3808 eina_stringshare_replace(&priv->userAgent, buffer.get());
3811 return priv->userAgent;
3813 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
3815 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3816 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3817 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3819 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
3820 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
3822 WKPageAddCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get(), customHeaderValue.get());
3825 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3830 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
3832 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3833 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3834 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3836 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
3838 WKPageRemoveCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get());
3841 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3846 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
3848 #if ENABLE(TIZEN_CUSTOM_HEADERS)
3849 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3850 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3852 WKPageClearCustomHeaders(toAPI(priv->pageClient->page()));
3855 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3860 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
3861 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
3863 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3864 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3866 priv->pageClient->setIsVisible(enable);
3871 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
3873 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
3875 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3876 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3879 rect.origin.x = viewArea.x;
3880 rect.origin.y = viewArea.y;
3881 rect.size.width = viewArea.w;
3882 rect.size.height = viewArea.h;
3884 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(priv->pageClient->page()), rect, scaleFactor));
3885 if (!snapshot.get())
3888 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
3890 Evas_Object* screenshotImage = evas_object_image_add(canvas);
3891 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
3892 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
3893 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
3894 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
3896 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
3898 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)));
3899 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
3901 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
3902 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
3903 cairo_fill(cairo.get());
3905 evas_object_image_smooth_scale_set(screenshotImage, true);
3906 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
3907 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
3908 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
3909 evas_object_image_data_set(screenshotImage, pixels);
3911 return screenshotImage;
3914 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
3916 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
3917 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
3918 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, 0);
3920 return priv->pageClient->page()->startInspectorServer(port);
3922 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
3927 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
3929 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
3930 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
3931 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
3933 return priv->pageClient->page()->stopInspectorServer();
3935 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
3940 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
3942 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3943 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3945 WKPageScrollBy(toAPI(priv->pageClient->page()), toAPI(IntSize(deltaX, deltaY)));
3948 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
3954 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3955 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3957 IntPoint scrollPosition = priv->pageClient->scrollPosition();
3959 *x = scrollPosition.x();
3961 *y = scrollPosition.y();
3966 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
3968 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3969 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3971 priv->pageClient->page()->scrollMainFrameTo(IntPoint(x, y));
3975 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
3981 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3982 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3984 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3985 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3986 contentsSize.scale(priv->pageClient->scaleFactor());
3989 if (width && contentsSize.width() > smartData->view.w)
3990 *width = contentsSize.width() - smartData->view.w;
3991 if (height && contentsSize.height() > smartData->view.h)
3992 *height = contentsSize.height() - smartData->view.h;
3996 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
3998 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3999 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4000 if (!priv->alertContext || !priv->alertContext->javascriptAlertCallback)
4002 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->alertContext->ewkView == ewkView, false);
4004 priv->isWaitingForJavaScriptPopupReply = true;
4005 int length = WKStringGetMaximumUTF8CStringSize(alertText);
4006 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
4007 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
4008 return priv->alertContext->javascriptAlertCallback(priv->alertContext->ewkView, alertTextBuffer.get(), priv->alertContext->userData) == EINA_TRUE;
4011 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
4013 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4014 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4015 if (!priv->confirmContext || !priv->confirmContext->javascriptConfirmCallback)
4017 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->confirmContext->ewkView == ewkView, false);
4019 priv->isWaitingForJavaScriptPopupReply = true;
4020 int length = WKStringGetMaximumUTF8CStringSize(message);
4021 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4022 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4023 return priv->confirmContext->javascriptConfirmCallback(priv->confirmContext->ewkView, messageBuffer.get(), priv->confirmContext->userData) == EINA_TRUE;
4026 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
4028 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4029 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4030 if (!priv->promptContext || !priv->promptContext->javascriptPromptCallback)
4032 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->promptContext->ewkView == ewkView, false);
4034 priv->isWaitingForJavaScriptPopupReply = true;
4035 int length = WKStringGetMaximumUTF8CStringSize(message);
4036 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4037 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4038 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
4039 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
4040 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
4041 return priv->promptContext->javascriptPromptCallback(priv->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), priv->promptContext->userData) == EINA_TRUE;
4044 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
4045 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
4047 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4048 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4049 if (!priv->beforeUnloadConfirmPanelContext || !priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
4051 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
4053 priv->isWaitingForJavaScriptPopupReply = true;
4054 int length = WKStringGetMaximumUTF8CStringSize(message);
4055 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
4056 WKStringGetUTF8CString(message, messageBuffer.get(), length);
4057 bool result = priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(priv->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), priv->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
4062 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
4064 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4065 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4066 if (!priv->openpanelContext || !priv->openpanelContext->openPanelCallback)
4069 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->openpanelContext->ewkView == ewkView, false);
4071 priv->openPanelListener = listener;
4073 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
4074 Eina_List* acceptedMimeTypes = 0;
4075 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
4076 size_t len = WKArrayGetSize(array.get());
4077 for (size_t i = 0; i < len; i++) {
4078 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
4079 if (WKGetTypeID(item) != WKStringGetTypeID())
4081 WKStringRef mime = static_cast<WKStringRef>(item);
4082 int length = WKStringGetMaximumUTF8CStringSize(mime);
4083 char* buffer = new char[length];
4084 WKStringGetUTF8CString(mime, buffer, length);
4085 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
4087 const char* capture = 0;
4088 #if ENABLE(MEDIA_CAPTURE)
4089 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
4090 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
4092 bool result = priv->openpanelContext->openPanelCallback(priv->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
4093 if (!acceptedMimeTypes)
4098 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
4099 delete[] (char*)data;
4100 eina_list_free(acceptedMimeTypes);
4104 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
4106 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4107 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4109 if (!priv->alertContext)
4110 priv->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4111 priv->alertContext->javascriptAlertCallback = callback;
4112 priv->alertContext->ewkView = ewkView;
4113 priv->alertContext->userData = userData;
4116 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
4118 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4119 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4121 WKPageReplyJavaScriptAlert(toAPI(ewk_view_page_get(ewkView)));
4122 priv->isWaitingForJavaScriptPopupReply = false;
4125 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
4127 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4128 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4130 if (!priv->confirmContext)
4131 priv->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4132 priv->confirmContext->javascriptConfirmCallback = callback;
4133 priv->confirmContext->ewkView = ewkView;
4134 priv->confirmContext->userData = userData;
4137 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
4139 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4140 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4142 WKPageReplyJavaScriptConfirm(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
4143 priv->isWaitingForJavaScriptPopupReply = false;
4146 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
4148 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4149 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4151 if (!priv->promptContext)
4152 priv->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4153 priv->promptContext->javascriptPromptCallback = callback;
4154 priv->promptContext->ewkView = ewkView;
4155 priv->promptContext->userData = userData;
4158 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
4160 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4161 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4163 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
4164 WKPageReplyJavaScriptPrompt(toAPI(ewk_view_page_get(ewkView)), result ? resultString.get() : 0);
4165 priv->isWaitingForJavaScriptPopupReply = false;
4168 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
4169 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
4171 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4172 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4174 if (!priv->beforeUnloadConfirmPanelContext)
4175 priv->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4176 priv->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
4177 priv->beforeUnloadConfirmPanelContext->ewkView = ewkView;
4178 priv->beforeUnloadConfirmPanelContext->userData = userData;
4181 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
4183 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4184 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4186 WKPageReplyBeforeUnloadConfirmPanel(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
4187 priv->isWaitingForJavaScriptPopupReply = false;
4191 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
4193 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4194 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4196 if (!priv->openpanelContext)
4197 priv->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4199 priv->openpanelContext->openPanelCallback = callback;
4200 priv->openpanelContext->ewkView = ewkView;
4201 priv->openpanelContext->userData = userData;
4204 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
4206 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4207 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4209 if (!priv->openPanelListener)
4212 unsigned int size = eina_list_count(fileUrls);
4213 if ((result == EINA_FALSE) || (size == 0)) {
4214 WKOpenPanelResultListenerCancel(priv->openPanelListener);
4215 priv->openPanelListener = 0;
4219 WKTypeRef* items = new WKTypeRef[size];
4223 KURL base(KURL(), "file://");
4224 EINA_LIST_FOREACH(fileUrls, list, data) {
4225 KURL url(base, static_cast<char*>(data));
4226 items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
4228 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
4229 WKOpenPanelResultListenerChooseFiles(priv->openPanelListener, filesArray.get());
4230 priv->openPanelListener = 0;
4232 eina_list_free(fileUrls);
4235 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4236 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
4238 EINA_SAFETY_ON_NULL_RETURN(capable);
4239 EINA_SAFETY_ON_NULL_RETURN(context);
4241 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4243 ASSERT(webAppContext->webAppCapableCallback);
4246 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
4248 webAppContext->webAppCapableCallback(0, webAppContext->userData);
4250 delete webAppContext;
4253 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
4255 EINA_SAFETY_ON_NULL_RETURN(iconURL);
4256 EINA_SAFETY_ON_NULL_RETURN(context);
4258 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
4260 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
4261 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4263 ASSERT(webAppContext->webAppIconURLCallback);
4266 eina_stringshare_replace(&priv->webAppIconURL, toImpl(iconURL)->string().utf8().data());
4267 webAppContext->webAppIconURLCallback(priv->webAppIconURL, webAppContext->userData);
4269 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
4271 delete webAppContext;
4275 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
4277 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4278 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4279 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4280 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4282 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4283 context->webAppCapableCallback = callback;
4284 context->ewkView = ewkView;
4285 context->userData = userData;
4287 WKPageGetWebAppCapable(toAPI(priv->pageClient->page()), context, didGetWebAppCapable);
4295 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
4297 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4298 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4299 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4300 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4302 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4303 context->webAppIconURLCallback = callback;
4304 context->ewkView = ewkView;
4305 context->userData = userData;
4307 WKPageGetWebAppIconURL(toAPI(priv->pageClient->page()), context, didGetWebAppIconURL);
4315 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
4317 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4318 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4319 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
4321 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
4322 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
4323 WKPageExecuteCommandWithArgument(toAPI(priv->pageClient->page()), commandString.get(), valueString.get());
4328 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4330 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4331 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4332 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4334 // FixMe: Comment should be removed when pageClient is removed.
4335 //priv->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4336 priv->pageClient->page()->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4341 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4343 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4344 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4346 // FixMe: Comment should be removed when pageClient is removed.
4347 //priv->pageProxy->hideFindUI();
4348 priv->pageClient->page()->hideFindUI();
4353 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
4360 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4361 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4363 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4366 *width = contentsSize.width();
4368 *height = contentsSize.height();
4373 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
4375 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
4376 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4377 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4378 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
4380 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4381 WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
4389 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, int width, int height, const char* fileName)
4391 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
4392 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4393 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4394 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
4396 IntSize contentsSize = priv->pageClient->page()->contentsSize();
4397 WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
4405 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
4407 EINA_SAFETY_ON_NULL_RETURN(context);
4408 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4410 if (!callbackContext->scriptExecuteCallback) {
4411 delete callbackContext;
4415 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
4418 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
4419 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
4420 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
4421 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
4422 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
4423 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
4425 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
4427 delete callbackContext;
4430 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
4432 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4433 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4434 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
4435 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient, false);
4437 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4438 context->scriptExecuteCallback = callback;
4439 context->ewkView = ewkView;
4440 context->userData = user_data;
4441 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
4442 WKPageRunJavaScriptInMainFrame(toAPI(priv->pageClient->page()), scriptString.get(), context, runJavaScriptCallback);
4447 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
4448 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
4450 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
4453 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
4455 storageContext->webStorageQuotaCallback(0, storageContext->userData);
4457 delete storageContext;
4461 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
4463 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
4464 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
4465 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
4466 TIZEN_LOGI("resultCallback (%p)", resultCallback);
4468 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4469 context->webStorageQuotaCallback = resultCallback;
4470 context->userData = userData;
4472 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
4473 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
4481 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
4483 #if ENABLE(TIZEN_WEB_STORAGE)
4484 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
4486 TIZEN_LOGI("quota (%d)", quota);
4487 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
4488 WKPageSetWebStorageQuota(pageRef, quota);
4496 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
4498 EINA_SAFETY_ON_NULL_RETURN(context);
4499 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4501 ASSERT(callbackContext->plainTextGetCallback);
4504 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
4505 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
4506 WKStringGetUTF8CString(plain_text, buffer.get(), length);
4508 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
4510 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
4512 delete callbackContext;
4515 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
4517 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4518 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4519 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4520 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient, false);
4522 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4523 context->plainTextGetCallback = callback;
4524 context->ewkView = ewkView;
4525 context->userData = user_data;
4526 WKPageGetContentsAsString(toAPI(priv->pageClient->page()), context, getContentsAsStringCallback);
4531 #if ENABLE(TIZEN_SUPPORT_MHTML)
4534 * Callback function used for ewk_view_mhtml_data_get().
4536 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4538 EINA_SAFETY_ON_NULL_RETURN(context);
4539 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
4541 ASSERT(callbackContext->mhtmlDataGetCallback);
4543 callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
4545 delete callbackContext;
4548 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
4550 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
4551 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4552 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4554 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
4555 context->mhtmlDataGetCallback = callback;
4556 context->ewkView = ewkView;
4557 context->userData = user_data;
4559 WKPageGetContentsAsMHTMLData(toAPI(priv->pageClient->page()), false, context, getContentsAsMHTMLCallback);
4563 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
4565 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
4567 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
4568 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4569 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4570 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, 0);
4572 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
4573 WebHitTestResult::Data hitTestResultData = priv->pageClient->page()->hitTestResultAtPoint(pointForHitTest, hitTestMode);
4574 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
4582 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
4584 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
4585 WebPageProxy* page = ewk_view_page_get(ewkView);
4586 EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
4588 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
4591 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
4593 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4594 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4596 WKPageRecordingSurfaceSetEnable(toAPI(priv->pageClient->page()), enable);
4601 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
4603 #if ENABLE(TIZEN_NOTIFICATIONS)
4604 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4605 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4606 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->context, false);
4608 TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
4609 if (!eina_list_count(ewkNotifications))
4612 Eina_List* listIterator = 0;
4614 Vector<WKTypeRef> ids;
4615 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
4616 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
4617 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
4619 priv->notifications = eina_list_remove(priv->notifications, notification);
4622 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
4623 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(ewk_context_WKContext_get(priv->context));
4624 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
4625 ewkNotificationDeleteNotificationList(ewkNotifications);
4633 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
4635 Eina_List* popupItems = 0;
4636 size_t size = items.size();
4637 for (size_t i = 0; i < size; ++i) {
4638 Ewk_Popup_Menu_Item* item = ewk_popup_menu_item_new(items[i].m_type,
4639 items[i].m_text.utf8().data(),
4640 items[i].m_textDirection,
4641 items[i].m_hasTextDirectionOverride,
4642 items[i].m_toolTip.utf8().data(),
4643 items[i].m_accessibilityText.utf8().data(),
4644 items[i].m_isEnabled,
4645 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4646 items[i].m_isSelected,
4648 items[i].m_isLabel);
4649 popupItems = eina_list_append(popupItems, item);
4651 TIZEN_LOGI("size : %d", size);
4655 static void releasePopupMenuList(Eina_List* popupMenuItems)
4657 if (!popupMenuItems)
4661 EINA_LIST_FREE(popupMenuItems, item)
4662 ewk_popup_menu_item_free(static_cast<Ewk_Popup_Menu_Item*>(item));
4665 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4666 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)
4668 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)
4671 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4672 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4673 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4674 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4678 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4679 if (!smartData->api->popup_menu_show && !smartData->api->multiple_popup_menu_show)
4681 if (!smartData->api->popup_menu_show)
4685 if (priv->popupMenuProxy)
4686 ewk_view_popup_menu_close(ewkView);
4687 priv->popupMenuProxy = popupMenu;
4689 priv->popupMenuItems = createPopupMenuList(items);
4691 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4692 if ((!multiple && smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems, selectedIndex)) ||
4693 (multiple && smartData->api->multiple_popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems))) {
4695 if (smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, priv->popupMenuItems, selectedIndex)) {
4697 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
4698 /* maps.google.com generate mouse event in touch down without preventDefault.
4699 * So, popup menu is opend in touch down event and closed via fake mouse down
4700 * which generated by endTap.
4701 * In order to fix select of maps.google.com (based on touch behavior),
4702 * We should disable touch events when select popup is open.
4705 #if ENABLE(TIZEN_GESTURE)
4706 priv->gestureClient->reset();
4708 ewk_view_touch_events_enabled_set(ewkView, false);
4713 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
4715 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4716 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4717 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4718 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4720 if (!priv->popupMenuProxy)
4723 priv->popupMenuProxy = 0;
4725 if (smartData->api->popup_menu_hide)
4726 smartData->api->popup_menu_hide(smartData);
4727 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
4728 ewk_view_touch_events_enabled_set(ewkView, true);
4731 releasePopupMenuList(priv->popupMenuItems);
4732 priv->popupMenuItems = 0;
4737 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
4739 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4740 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4741 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4742 TIZEN_LOGI("proxy : %p", priv->popupMenuProxy);
4744 if (!priv->popupMenuProxy)
4747 if (!smartData->api->popup_menu_update)
4750 releasePopupMenuList(priv->popupMenuItems);
4751 priv->popupMenuItems = createPopupMenuList(items);
4753 // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
4754 smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), priv->popupMenuItems, selectedIndex);
4757 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
4759 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4760 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4761 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
4762 TIZEN_LOGI("proxy : %p / index : %d", priv->popupMenuProxy, selectedIndex);
4764 if (!priv->popupMenuItems)
4767 if (selectedIndex >= eina_list_count(priv->popupMenuItems))
4770 priv->popupMenuProxy->valueChanged(selectedIndex);
4775 #if ENABLE(TIZEN_MULTIPLE_SELECT)
4776 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
4778 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4779 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4780 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
4782 Vector<int> selectedIndex;
4784 if (!priv->popupMenuItems)
4789 itr = eina_inarray_iterator_new(changeList);
4790 EINA_ITERATOR_FOREACH(itr, data)
4792 int* pData = static_cast<int*>(data);
4793 selectedIndex.append(*pData);
4795 eina_iterator_free(itr);
4797 priv->popupMenuProxy->multipleValueChanged(selectedIndex);
4802 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
4804 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
4805 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4806 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4807 TIZEN_LOGI("orientation : %d", orientation);
4809 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
4812 if (priv->orientation == orientation)
4815 priv->orientation = orientation;
4817 priv->pageClient->page()->sendOrientationChangeEvent(orientation);
4821 void ewkViewFrameRendered(Evas_Object* ewkView)
4823 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
4826 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4827 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
4829 return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
4832 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
4834 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4835 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
4836 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
4838 IntRect leftSelectionRect;
4839 IntRect rightSelectionRect;
4840 if (!priv->pageClient->page()->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
4853 AffineTransform contentToScreen = impl->transformToScene();
4854 leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
4855 rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
4857 leftRect->x = leftSelectionRect.x();
4858 leftRect->y = leftSelectionRect.y();
4859 leftRect->w = leftSelectionRect.width();
4860 leftRect->h = leftSelectionRect.height();
4862 rightRect->x = rightSelectionRect.x();
4863 rightRect->y = rightSelectionRect.y();
4864 rightRect->w = rightSelectionRect.width();
4865 rightRect->h = rightSelectionRect.height();
4870 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
4872 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4873 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4875 const CString selectedString = priv->pageClient->page()->getSelectionText().utf8();
4876 eina_stringshare_replace(&priv->selectedText, selectedString.data());
4878 return priv->selectedText;
4881 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
4883 return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
4886 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
4888 return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
4890 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4892 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4893 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
4895 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4896 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4897 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
4899 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
4903 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
4904 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
4906 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4907 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4908 IntPoint drawingPosition = (IntPoint)(priv->pageClient->visibleContentRect().location() - priv->pageClient->scrollPosition());
4910 *x = drawingPosition.x();
4912 *y = drawingPosition.y();
4914 *w = priv->pageClient->visibleContentRect().width();
4916 *h = priv->pageClient->visibleContentRect().height();
4920 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
4922 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4923 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4924 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4926 priv->pageClient->page()->setFocusedInputElementValue(String::fromUTF8(value));
4927 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4930 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
4932 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4933 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4934 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
4936 eina_stringshare_replace(&priv->inputValue, priv->pageClient->page()->getFocusedInputElementValue().utf8().data());
4937 return priv->inputValue;
4940 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4943 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4944 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
4946 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4947 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4948 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4949 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
4952 ewkViewDataListHideRequest(ewkView, inputType);
4954 for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
4956 priv->dataList = eina_list_append(priv->dataList, eina_stringshare_add(value.utf8().data()));
4959 smartData->api->data_list_show(smartData, inputType, priv->dataList);
4962 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
4964 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4965 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4966 EINA_SAFETY_ON_NULL_RETURN(priv->dataList);
4967 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4968 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
4970 if (priv->dataList) {
4971 _ewk_view_data_list_del(priv->dataList);
4975 smartData->api->data_list_hide(smartData, inputType);
4979 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
4981 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4982 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4983 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4985 if (priv->dataList) {
4986 _ewk_view_data_list_del(priv->dataList);
4990 ewk_view_focused_input_element_value_set(ewkView, value);
4994 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
4996 #if ENABLE(TIZEN_GESTURE)
4997 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
4998 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
4999 return priv->holdHorizontalPanning;
5005 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
5007 #if ENABLE(TIZEN_GESTURE)
5008 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5009 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5010 priv->holdHorizontalPanning = hold;
5014 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
5016 #if ENABLE(TIZEN_GESTURE)
5017 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
5018 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
5019 return priv->holdVerticalPanning;
5025 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
5027 #if ENABLE(TIZEN_GESTURE)
5028 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5029 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5030 priv->holdVerticalPanning = hold;
5034 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
5036 #if ENABLE(TIZEN_GESTURE)
5037 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
5038 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
5040 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5041 if (priv->focusRing && wasHandled)
5042 priv->focusRing->hide();
5043 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5045 if (priv->areMouseEventsEnabled)
5048 // We have to check TouchStart, TouchMove and TouchEnd with handled.
5049 // The Pan and Flick will be enabled if Touch Start was not handled,
5050 // and Touch Move was not handled or did not occur.
5051 // Tap will be enabled if Touch Start and End was not handled
5052 // and Touch Move did not occur.
5053 // The gestures are disabled as a default.
5054 // o: handled, x: not handled
5055 // ------------------------------------------------------------
5056 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
5057 // ------------------------------------------------------------
5058 // o | o or x | o or x || disable | disable
5059 // x | o | o or x || disable | disable
5060 // x | x | o or x || disable | enable
5061 // x |not occured | x || enable | enable
5062 // ------------------------------------------------------------
5063 if (type == WebEvent::TouchStart) {
5064 priv->gestureClient->setGestureEnabled(!wasHandled);
5065 priv->wasHandledTouchStart = wasHandled;
5067 // Initialize wasHandledTouchMove to true and notify that to the application
5068 // to prevent applications scrolling at the beginning of touch.
5069 priv->wasHandledTouchMove = true;
5070 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&priv->wasHandledTouchMove));
5071 } else if (type == WebEvent::TouchMove) {
5072 priv->gestureClient->setMovingEnabled(!wasHandled);
5074 // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
5075 if (priv->wasHandledTouchStart)
5078 // Notify the result of touchmove to applications when handled value is changed
5079 // in order to make applications to choose whether scrolling its scrollable objects or not.
5080 if (priv->wasHandledTouchMove != wasHandled)
5081 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
5082 priv->wasHandledTouchMove = wasHandled;
5083 } else if (type == WebEvent::TouchEnd && !priv->exceedTouchMoveThreshold && !wasHandled) {
5084 priv->gestureClient->setMovingEnabled(!wasHandled);
5085 priv->gestureClient->setTapEnabled(!wasHandled);
5090 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
5091 void ewkViewDidGetTextStyleStateForSelection(Evas_Object* ewkView, int underlineState, int italicState, int boldState, const IntPoint& startPoint, const IntPoint& endPoint)
5093 Ewk_Text_Style* textStyle = ewkTextStyleCreate(underlineState, italicState, boldState, startPoint, endPoint);
5094 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
5095 ewkTextStyleDelete(textStyle);
5099 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
5100 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
5102 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5103 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
5105 TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
5106 if (!smartData->api->orientation_lock) {
5111 return smartData->api->orientation_lock(smartData, willLockOrientation);
5114 void ewk_view_orientation_unlock(Evas_Object* ewkView)
5116 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5117 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
5119 TIZEN_LOGI("ewkView (%p)", ewkView);
5120 if (!smartData->api->orientation_unlock) {
5125 smartData->api->orientation_unlock(smartData);
5129 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
5131 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
5132 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5133 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5134 TIZEN_LOGI("callbacks: %p / data: %p", func, data);
5136 priv->orientationLock.callback = func;
5137 priv->orientationLock.data = data;
5141 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
5142 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
5144 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
5145 TIZEN_LOGI("locked orientations : %d", orientations);
5147 if (priv->orientationLock.callback)
5148 return priv->orientationLock.callback(sd->self, true, orientations, priv->orientationLock.data);
5153 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
5155 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
5156 TIZEN_LOGI("unlock is requested");
5158 if (priv->orientationLock.callback)
5159 priv->orientationLock.callback(sd->self, false, 0, priv->orientationLock.data);
5163 void ewk_view_fullscreen_enter(Evas_Object* ewkView)
5165 TIZEN_LOGI("fullscreen,enterfullscreen");
5166 ewk_view_main_frame_scrollbar_visible_set(ewkView, false);
5167 evas_object_smart_callback_call(ewkView, "fullscreen,enterfullscreen", 0);
5170 void ewk_view_fullscreen_exit(Evas_Object* ewkView)
5172 TIZEN_LOGI("fullscreen,exitfullscreen");
5173 ewk_view_main_frame_scrollbar_visible_set(ewkView, true);
5174 evas_object_smart_callback_call(ewkView, "fullscreen,exitfullscreen", 0);
5177 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
5178 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
5180 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5182 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
5183 const char *engine = ecore_evas_engine_name_get(ee);
5184 if (engine && !strcmp(engine, "opengl_x11"))
5190 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
5192 #if ENABLE(TIZEN_GESTURE)
5193 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5194 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5196 priv->gestureClient->setZoomableArea(target, area);
5200 #if ENABLE(TIZEN_ISF_PORT)
5201 static void imfInputPanelStateEventCb(void* data, Ecore_IMF_Context* ctx, int state)
5203 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5204 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5206 if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
5207 evas_object_smart_callback_call(smartData->self, "editorclient,ime,closed", 0);
5208 LOG(ISF, "[SIGNAL] editorclient,ime,closed\n");
5209 } else if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
5210 evas_object_smart_callback_call(smartData->self, "editorclient,ime,opened", 0);
5211 LOG(ISF, "[SIGNAL] editorclient,ime,opened\n");
5215 static void imfInputPanelGeometryEventCb(void* data, Ecore_IMF_Context* ctx, int value)
5217 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5218 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5220 Eina_Rectangle rect;
5221 ecore_imf_context_input_panel_geometry_get(priv->imfContext, &rect.x, &rect.y, &rect.w, &rect.h);
5222 evas_object_smart_callback_call(smartData->self, "inputmethod,changed", &rect);
5223 LOG(ISF, "%s : [SIGNAL] inputmethod,changed (%d,%d,%d,%d)\n", __func__, rect.x, rect.y, rect.w, rect.h);
5226 static void imfCandidatePanelStateEventCb(void* data, Ecore_IMF_Context* ctx, int state)
5228 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5229 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5231 if (state == ECORE_IMF_CANDIDATE_PANEL_SHOW)
5232 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,opened", 0);
5234 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,closed", 0);
5237 static void imfCandidatePanelGeometryEventCb(void* data, Ecore_IMF_Context* ctx, int value)
5239 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5240 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5242 Eina_Rectangle rect;
5243 ecore_imf_context_candidate_panel_geometry_get(priv->imfContext, &rect.x, &rect.y, &rect.w, &rect.h);
5244 evas_object_smart_callback_call(smartData->self, "editorclient,candidate,changed", &rect);
5247 static Eina_Bool imfRetrieveSurroundingCb(void* data, Ecore_IMF_Context* context, char** text, int* offset)
5249 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5250 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5252 if (!priv->pageClient->page()->focusedFrame() || (!text && !offset))
5255 String surroundingText;
5257 priv->pageClient->page()->getSurroundingTextAndCursorOffset(surroundingText, cursorOffset);
5260 CString utf8Text(surroundingText.utf8());
5261 size_t length = utf8Text.length();
5263 *text = static_cast<char*>(malloc((length + 1) * sizeof(char)));
5268 strncpy(*text, utf8Text.data(), length);
5269 (*text)[length] = 0;
5273 *offset = cursorOffset;
5278 static void imfPreeditChangedCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5280 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5281 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5283 priv->pageClient->imContextPreeditChanged(context);
5286 static void imfEventCommittedCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5288 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5289 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5291 priv->pageClient->imContextCommitted(context, static_cast<char*>(eventInfo));
5294 static void imfContextDeleteSurroundingCb(void* data, Ecore_IMF_Context* context, void* eventInfo)
5296 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
5297 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5299 Ecore_IMF_Event_Delete_Surrounding* event = static_cast<Ecore_IMF_Event_Delete_Surrounding*>(eventInfo);
5303 priv->pageClient->page()->deleteSurroundingText(event->offset, event->n_chars);
5306 Ecore_IMF_Context* ewk_view_imf_context_get(Evas_Object* ewkView)
5308 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5309 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5311 return priv->imfContext;
5314 Ecore_IMF_Context* ewk_view_imf_context_set(Evas_Object* ewkView, Ecore_IMF_Input_Panel_Layout layout)
5316 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
5317 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
5319 Ecore_IMF_Context* imfContext;
5320 Eina_List* iterator;
5323 EINA_LIST_FOREACH(priv->imfContextList, iterator, data) {
5324 imfContext = static_cast<Ecore_IMF_Context*>(data);
5325 if (ecore_imf_context_input_panel_layout_get(imfContext) == layout) {
5326 priv->imfContext = imfContext;
5331 imfContext = ecore_imf_context_add(ecore_imf_context_default_id_get());
5335 ecore_imf_context_input_panel_enabled_set(imfContext, false);
5336 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, imfInputPanelStateEventCb, smartData);
5337 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, imfInputPanelGeometryEventCb, smartData);
5338 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, imfCandidatePanelStateEventCb, smartData);
5339 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, imfCandidatePanelGeometryEventCb, smartData);
5340 ecore_imf_context_retrieve_surrounding_callback_set(imfContext, imfRetrieveSurroundingCb, smartData); // Support for Auto Capitalization
5341 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, imfPreeditChangedCb, smartData);
5342 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_COMMIT, imfEventCommittedCb, smartData);
5343 ecore_imf_context_event_callback_add(imfContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, imfContextDeleteSurroundingCb, smartData); //Support for Automatic Full Stop
5344 ecore_imf_context_input_panel_layout_set(imfContext, layout);
5346 priv->imfContextList = eina_list_append(priv->imfContextList, imfContext);
5347 priv->imfContext = imfContext;
5352 void ewk_view_imf_context_reset(Evas_Object* ewkView)
5354 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5355 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5357 if (!priv->imfContext)
5360 ecore_imf_context_reset(priv->imfContext);
5362 if (ecore_imf_context_input_panel_state_get(priv->imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
5363 priv->imfContext = 0;
5366 void ewk_view_imf_context_hide(Evas_Object* ewkView)
5368 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5369 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5371 if (!priv->imfContext)
5374 if (ecore_imf_context_input_panel_state_get(priv->imfContext) != ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
5375 ecore_imf_context_reset(priv->imfContext);
5376 ecore_imf_context_input_panel_hide(priv->imfContext);
5377 ecore_imf_context_focus_out(priv->imfContext);
5380 priv->imfContext = 0;
5383 static void _ewk_view_imf_context_destroy(Ewk_View_Private_Data* priv)
5385 if (!priv->imfContextList)
5389 EINA_LIST_FREE(priv->imfContextList, item) {
5390 Ecore_IMF_Context* imfContext = static_cast<Ecore_IMF_Context*>(item);
5394 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, imfInputPanelStateEventCb);
5395 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, imfInputPanelGeometryEventCb);
5396 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, imfCandidatePanelStateEventCb);
5397 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, imfCandidatePanelGeometryEventCb);
5398 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, imfPreeditChangedCb);
5399 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_COMMIT, imfEventCommittedCb);
5400 ecore_imf_context_event_callback_del(imfContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, imfContextDeleteSurroundingCb);
5401 ecore_imf_context_del(imfContext);
5404 priv->imfContextList = 0;
5405 priv->imfContext = 0;
5408 void ewk_view_imf_context_destroy(Evas_Object* ewkView)
5410 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5411 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5413 _ewk_view_imf_context_destroy(priv);
5417 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
5418 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
5420 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5421 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5423 WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(priv->pageClient->page())));
5427 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
5428 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
5430 evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
5434 #if ENABLE(TIZEN_ICON_DATABASE)
5435 void ewkViewIconReceived(Evas_Object* ewkView)
5439 evas_object_smart_callback_call(ewkView, "icon,received", 0);
5443 #endif // #if OS(TIZEN)
5445 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
5446 #if ENABLE(INPUT_TYPE_COLOR)
5449 * Reqeusts to show external color picker.
5451 void ewk_view_color_picker_request(Evas_Object* ewkView, int r, int g, int b, int a, WKColorPickerResultListenerRef listener)
5453 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5454 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5455 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_request);
5457 priv->colorPickerResultListener = listener;
5459 smartData->api->input_picker_color_request(smartData, r, g, b, a);
5464 * Reqeusts to hide external color picker.
5466 void ewk_view_color_picker_dismiss(Evas_Object* ewkView)
5468 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5469 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5470 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_color_dismiss);
5472 priv->colorPickerResultListener = 0;
5474 smartData->api->input_picker_color_dismiss(smartData);
5478 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
5480 #if ENABLE(INPUT_TYPE_COLOR)
5481 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5482 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5483 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->colorPickerResultListener, false);
5485 WebCore::Color color = WebCore::Color(r, g, b, a);
5486 WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(color.serialized().utf8().data()));
5487 WKColorPickerResultListenerSetColor(priv->colorPickerResultListener, colorString.get());
5488 priv->colorPickerResultListener = 0;
5495 #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
5497 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
5499 #if ENABLE(TOUCH_EVENTS)
5500 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
5501 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5502 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5503 EWK_VIEW_IMPL_GET_BY_SD_OR_RETURN(smartData, impl, false);
5505 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
5506 if (priv->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
5507 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5508 IntPoint handlePoint(point->x, point->y);
5510 if (type == EWK_TOUCH_START)
5511 priv->pageClient->textSelectonHandleDown(handlePoint);
5512 else if (type == EWK_TOUCH_MOVE)
5513 priv->pageClient->textSelectonHandleMove(handlePoint);
5515 priv->pageClient->textSelectonHandleUp();
5519 #if ENABLE(TIZEN_GESTURE)
5520 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
5521 // We don't want to process touch event when context menu is shown.
5522 if (priv->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
5525 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
5526 if (priv->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
5530 if (type == EWK_TOUCH_START) {
5531 if (eina_list_count(points) == 1) {
5532 priv->gestureClient->reset();
5533 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5534 priv->touchDownPoint.x = point->x;
5535 priv->touchDownPoint.y = point->y;
5536 priv->exceedTouchMoveThreshold = false;
5538 } else if (type == EWK_TOUCH_MOVE && !priv->exceedTouchMoveThreshold) {
5539 if (eina_list_count(points) == 1) {
5540 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
5541 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
5542 int diffX = priv->touchDownPoint.x - point->x;
5543 int diffY = priv->touchDownPoint.y - point->y;
5544 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
5545 priv->exceedTouchMoveThreshold = true;
5549 priv->exceedTouchMoveThreshold = true;
5552 #endif // #if ENABLE(TIZEN_GESTURE)
5554 // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
5555 //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
5556 priv->pageClient->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
5564 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
5566 #if ENABLE(TOUCH_EVENTS)
5567 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5568 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5570 enabled = !!enabled;
5571 if (priv->areTouchEventsEnabled == enabled)
5574 priv->areTouchEventsEnabled = enabled;
5576 // FIXME: We have to connect touch callbacks with mouse and multi events
5577 // because the Evas creates mouse events for first touch and multi events
5578 // for second and third touches. Below codes should be fixed when the Evas
5579 // supports the touch events.
5580 // See https://bugs.webkit.org/show_bug.cgi?id=97785 for details.
5581 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down, smartData);
5582 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up, smartData);
5583 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move, smartData);
5584 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down, smartData);
5585 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up, smartData);
5586 evas_object_event_callback_add(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move, smartData);
5588 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down);
5589 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up);
5590 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move);
5591 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down);
5592 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up);
5593 evas_object_event_callback_del(ewkView, EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move);
5602 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
5604 #if ENABLE(TOUCH_EVENTS)
5605 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5606 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5608 return priv->areTouchEventsEnabled;
5614 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
5616 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
5617 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5618 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5620 priv->mainFrameScrollbarVisibility = visible;
5621 priv->pageClient->updateVisibility();
5629 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
5631 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
5632 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5633 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5635 return priv->mainFrameScrollbarVisibility;
5641 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
5643 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
5644 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5645 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5646 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
5648 String title = ewk_view_title_get(ewkView);
5649 String url = ewk_view_url_get(ewkView);
5650 String directoryPath(path);
5651 priv->pageClient->startOfflinePageSave(directoryPath, url, title);
5655 UNUSED_PARAM(ewkView);
5663 * Callback function used for ewk_view_page_contents_get().
5665 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
5667 EINA_SAFETY_ON_NULL_RETURN(context);
5669 RefPtr<WebData> webData = toImpl(wkData);
5670 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
5671 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
5676 * Callback function used for ewk_view_page_contents_get().
5678 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
5680 EINA_SAFETY_ON_NULL_RETURN(context);
5682 RefPtr<WebString> webString = toImpl(wkString);
5683 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
5684 contentsContext->callback(contentsContext->type, webString->string().utf8().data());
5687 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
5689 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
5690 EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
5691 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5692 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5694 switch (context->type) {
5695 case EWK_PAGE_CONTENTS_TYPE_MHTML:
5696 priv->pageClient->page()->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
5699 case EWK_PAGE_CONTENTS_TYPE_STRING:
5700 priv->pageClient->page()->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
5704 ASSERT_NOT_REACHED();
5711 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
5713 #if ENABLE(TIZEN_GESTURE)
5714 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
5715 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
5717 return priv->gestureClient->scrollToWithAnimation(x, y);
5719 UNUSED_PARAM(ewkView);
5726 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
5727 void ewkViewFocusRingHide(Evas_Object* ewkView)
5729 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
5730 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
5732 if (priv->focusRing)
5733 priv->focusRing->hide();
5737 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
5739 #if ENABLE(TIZEN_CSP)
5740 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
5741 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
5743 TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
5744 priv->pageClient->page()->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));