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 "NativeWebKeyboardEvent.h"
25 #include "NativeWebMouseEvent.h"
26 #include "NativeWebWheelEvent.h"
27 #include "PageClientImpl.h"
28 #include "WKAPICast.h"
29 #include "WKRetainPtr.h"
31 #include "ewk_context.h"
32 #include "ewk_context_private.h"
33 #include "ewk_view_private.h"
34 #include <wtf/text/CString.h>
37 #include "DrawingAreaProxyImpl.h"
38 #include "JavaScriptPopup.h"
39 #include "OpenPanel.h"
42 #include "WKDownload.h"
44 #include "WKGeolocationPermissionRequest.h"
45 #include "WKImageCairo.h"
46 #include "WKOpenPanelParameters.h"
47 #include "WKOpenPanelResultListener.h"
49 #include "WKPageGroup.h"
50 #include "WKPageTizen.h"
51 #include "WKPreferences.h"
52 #include "WKSerializedScriptValue.h"
54 #include "WKURLRequest.h"
55 #include "ewk_auth_challenge_private.h"
56 #include "ewk_context_menu_private.h"
57 #include "ewk_error.h"
58 #include "ewk_error_private.h"
59 #include "ewk_history_private.h"
60 #include "ewk_setting_private.h"
61 #include "ewk_view_context_menu_client.h"
62 #include "ewk_view_find_client.h"
63 #include "ewk_view_form_client.h"
64 #include "ewk_view_loader_client.h"
65 #include "ewk_view_policy_client.h"
66 #include "ewk_view_tizen_client.h"
67 #include "ewk_view_ui_client.h"
69 #include <Ecore_Evas.h>
70 #include <Elementary.h>
71 #include <JavaScriptCore/JSRetainPtr.h>
72 #include <WebCore/NotImplemented.h>
75 #if ENABLE(TIZEN_ERROR_PAGE)
76 #include "WebErrorPageEfl.h"
79 #if ENABLE(TIZEN_GEOLOCATION)
80 #include "ewk_security_origin.h"
81 #include "ewk_view_geolocation_provider.h"
84 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
85 #include "InputPicker.h"
88 #if ENABLE(TIZEN_GESTURE)
89 #include "GestureRecognizer.h"
90 #include "GestureClient.h"
93 #if ENABLE(TOUCH_EVENTS)
94 #include "NativeWebTouchEvent.h"
98 #if ENABLE(TIZEN_ISF_PORT)
99 #include <Ecore_IMF.h>
102 #if ENABLE(TIZEN_NOTIFICATION)
104 #include "WKNotificationManager.h"
105 #include "WKNumber.h"
106 #include "ewk_view_notification_provider.h"
109 #if ENABLE(TIZEN_READER)
110 #include "WKDictionary.h"
113 #if ENABLE(TIZEN_WEBKIT2_POPUP)
114 #include "WebPopupItem.h"
115 #include "WebPopupMenuProxyEfl.h"
118 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
119 #include "ewk_popup_picker.h"
122 #if ENABLE(TIZEN_MEDIA_STREAM)
123 #include "WKUserMediaPermissionRequest.h"
126 #if ENABLE(TIZEN_PREFERENCE)
127 #include "WebPageGroup.h"
128 #include "WebPreferences.h"
131 #if ENABLE(TIZEN_WEBKIT_PASTEBOARD)
132 #include "ewk_util.h"
135 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
136 #include "ewk_hit_test_private.h"
139 #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
140 #include <Ecore_Evas.h>
141 #include <WebCore/Cursor.h>
142 #include <WebCore/EflScreenUtilities.h>
145 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
146 #include "FocusRing.h"
149 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
150 #include "WebColorChooserProxyEfl.h"
151 #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
153 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
154 #include "ewk_text_style.h"
157 #endif // #if OS(TIZEN)
159 using namespace WebKit;
160 using namespace WebCore;
162 static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
164 typedef struct _Ewk_View_Callback_Context Ewk_View_Callback_Context;
166 struct _Ewk_View_Private_Data {
167 OwnPtr<PageClientImpl> pageClient;
169 #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
170 const char* cursorGroup;
177 bool areMouseEventsEnabled;
178 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
187 JSGlobalContextRef javascriptGlobalContext;
190 const char* userAgent;
192 const char* encoding;
193 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
194 const char* webAppIconURL;
197 OwnPtr<Ewk_View_Callback_Context> alertContext;
198 OwnPtr<Ewk_View_Callback_Context> confirmContext;
199 OwnPtr<Ewk_View_Callback_Context> promptContext;
200 OwnPtr<Ewk_View_Callback_Context> openpanelContext;
201 OwnPtr<JavaScriptPopup> javascriptPopup;
202 OwnPtr<OpenPanel> openPanel;
203 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
204 OwnPtr<InputPicker> inputPicker;
205 const char* inputValue;
208 Ewk_Auth_Challenge* authChallenge;
209 Ewk_Policy_Decision* policyDecision;
210 WKOpenPanelResultListenerRef openPanelListener;
212 #if ENABLE(TIZEN_MEDIA_STREAM)
213 Ewk_User_Media_Permission* userMediaPermission;
217 Ewk_View_String_Find_Callback callback;
221 Ewk_Setting* setting;
222 Ewk_Context* context;
224 #if ENABLE(TIZEN_GEOLOCATION)
225 Ewk_Geolocation* geolocation;
226 Ewk_Geolocation_Permission_Data* geolocationPermission;
229 #if ENABLE(TIZEN_NOTIFICATION)
230 Eina_List* notifications;
231 Ewk_Notification_Permission_Request* notificationPermissionRequest;
233 #if ENABLE(TIZEN_SQL_DATABASE)
234 Ewk_Context_Exceeded_Quota* exceededDatabaseQuota;
236 #if ENABLE(TIZEN_WEBKIT2_POPUP)
237 WebPopupMenuProxyEfl* popupMenuProxy;
238 Eina_List* popupMenuItems;
240 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
241 Ewk_Popup_Picker* popupPicker;
245 bool isHorizontalEdge;
246 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
247 OwnPtr<FocusRing> focusRing;
248 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
250 #if ENABLE(TIZEN_GESTURE)
251 OwnPtr<GestureRecognizer> gestureRecognizer;
252 OwnPtr<GestureClient> gestureClient;
253 #if ENABLE(TOUCH_EVENTS)
254 Ecore_Animator* touchAnimator;
255 Evas_Coord_Point touchDownPoint;
256 bool exceedTouchMoveThreshold;
257 #endif // #if ENABLE(TOUCH_EVENTS)
258 bool holdHorizontalPanning;
259 bool holdVerticalPanning;
260 #endif // #if ENABLE(TIZEN_GESTURE)
262 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
263 const char* selectedText;
265 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
266 WebColorChooserProxyEfl* colorChooser;
267 #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
268 #if ENABLE(TIZEN_DATALIST_ELEMENT)
271 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
273 Ewk_Orientation_Lock_Cb callback;
277 #endif // #if OS(TIZEN)
281 #if ENABLE(TIZEN_MM_PLAYER)
282 struct _Ewk_View_Html5_Video_Data {
286 #endif // #if ENABLE(TIZEN_MM_PLAYER)
288 struct _Ewk_View_Callback_Context {
290 Ewk_View_Rss_Items_Get_Callback rssItemsGetCallback;
291 Ewk_Web_App_Capable_Get_Callback webAppCapableCallback;
292 Ewk_Web_App_Icon_URL_Get_Callback webAppIconURLCallback;
293 #if ENABLE(TIZEN_READER)
294 Ewk_View_Reader_Callback readerCallback;
295 #endif // #if ENABLE(TIZEN_READER)
296 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
297 Ewk_Web_Storage_Quota_Get_Callback webStorageQuotaCallback;
299 Ewk_View_Script_Execute_Callback scriptExecuteCallback;
300 Ewk_View_Plain_Text_Get_Callback plainTextGetCallback;
302 Ewk_View_JavaScript_Alert_Callback javascriptAlertCallback;
303 Ewk_View_JavaScript_Confirm_Callback javascriptConfirmCallback;
304 Ewk_View_JavaScript_Prompt_Callback javascriptPromptCallback;
305 Ewk_View_Open_Panel_Callback openPanelCallback;
306 #endif // #if OS(TIZEN)
309 Evas_Object* ewkView;
313 #define READABLE_SCALE_FACTOR 1.0
314 #endif // #if OS(TIZEN)
316 #define EWK_VIEW_TYPE_CHECK(ewkView, result) \
317 bool result = true; \
319 const char* _tmp_otype = evas_object_type_get(ewkView); \
320 const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
321 if (EINA_UNLIKELY(!_tmp_s)) { \
323 ("%p (%s) is not a smart object!", \
324 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
327 const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
328 if (EINA_UNLIKELY(!_tmp_sc)) { \
330 ("%p (%s) is not a smart object!", \
331 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
334 else if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \
336 ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
337 ewkView, _tmp_otype ? _tmp_otype : "(null)", \
338 EWK_VIEW_TYPE_STR, _tmp_sc->data); \
343 #define EWK_VIEW_SD_GET(ewkView, smartData) \
344 EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \
345 Ewk_View_Smart_Data* smartData = 0; \
347 smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView);
349 #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \
350 EWK_VIEW_SD_GET(ewkView, smartData); \
352 EINA_LOG_CRIT("no smart data for object %p (%s)", \
353 ewkView, evas_object_type_get(ewkView)); \
354 return __VA_ARGS__; \
357 #define EWK_VIEW_PRIV_GET(smartData, priv) \
358 Ewk_View_Private_Data* priv = smartData->priv
360 #define EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, ...) \
362 EINA_LOG_CRIT("smart data is null"); \
363 return __VA_ARGS__; \
365 EWK_VIEW_PRIV_GET(smartData, priv); \
367 EINA_LOG_CRIT("no private data for object %p (%s)", \
368 smartData->self, evas_object_type_get(smartData->self)); \
369 return __VA_ARGS__; \
373 #define DECLARE_EVENT_FUNC(func) \
374 static void func(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
376 DECLARE_EVENT_FUNC(_ewk_view_on_touch_down);
377 DECLARE_EVENT_FUNC(_ewk_view_on_touch_move);
378 DECLARE_EVENT_FUNC(_ewk_view_on_touch_up);
380 #undef DECLARE_EVENT_FUNC
382 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object*, const char* alertText, void* userData);
383 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object*, const char* message, void* userData);
384 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object*, const char* message, const char* defaultValue, void* userData);
385 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);
387 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
388 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);
389 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data*);
391 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
392 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations);
393 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd);
396 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
397 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data*, Ewk_Input_Type, const char* inputValue);
400 #if ENABLE(TIZEN_DATALIST_ELEMENT)
401 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data*, Ewk_Input_Type, Eina_List*);
402 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data*, Ewk_Input_Type);
405 #endif // #if OS(TIZEN)
407 static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
409 if (smartData->changed.any)
411 smartData->changed.any = true;
412 evas_object_smart_changed(smartData->self);
415 // Default Event Handling.
416 static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
418 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
421 priv->pageClient->setViewFocused(true);
422 #endif // #if OS(TIZEN)
423 priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
424 #if ENABLE(TIZEN_ISF_PORT)
425 priv->pageClient->handleInputMethodForFocusedNode();
430 static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
432 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
433 #if ENABLE(TIZEN_ISF_PORT)
434 Ecore_IMF_Context* imContext = priv->pageClient->getIMFContext();
435 Ecore_IMF_Input_Panel_State state = ecore_imf_context_input_panel_state_get(imContext);
436 if (imContext && state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
437 ecore_imf_context_input_panel_hide(imContext);
438 ecore_imf_context_focus_out(imContext);
439 priv->pageClient->setImeState(false);
440 LOG(ISF, "[STATUS] HIDE - focus_out\n");
444 priv->pageClient->setViewFocused(false);
445 #endif // #if OS(TIZEN)
446 priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
450 static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
452 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
454 Evas_Point position = {smartData->view.x, smartData->view.y};
455 priv->pageClient->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, &position));
459 #if OS(TIZEN) && ENABLE(TOUCH_EVENTS)
460 void ewkViewHandleTouchEvent(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
462 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(ewkView));
463 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
465 Eina_List* points = 0;
466 int count = evas_touch_point_list_count(smartData->base.evas);
467 Ewk_Touch_Point* point;
468 for (int i = 0; i < count; ++i) {
469 point = static_cast<Ewk_Touch_Point*>(calloc(1, sizeof(Ewk_Touch_Point)));
470 point->id = evas_touch_point_list_nth_id_get(smartData->base.evas, i);
471 evas_touch_point_list_nth_xy_get(smartData->base.evas, i, &point->x, &point->y);
472 point->state = evas_touch_point_list_nth_state_get(smartData->base.evas, i);
473 points = eina_list_append(points, point);
476 ewk_view_feed_touch_event(ewkView, type, points, evas_key_modifier_get(smartData->base.evas));
479 EINA_LIST_FREE(points, data)
483 static Eina_Bool _ewk_view_touch_animator(void *data)
485 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
486 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
488 if (!priv->exceedTouchMoveThreshold && evas_touch_point_list_count(smartData->base.evas)) {
490 evas_touch_point_list_nth_xy_get(smartData->base.evas, 0, &x, &y);
491 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
492 int diffX = priv->touchDownPoint.x - x;
493 int diffY = priv->touchDownPoint.y - y;
494 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
495 priv->exceedTouchMoveThreshold = true;
497 if (priv->exceedTouchMoveThreshold)
498 ewkViewHandleTouchEvent(smartData->self, EWK_TOUCH_MOVE);
500 return ECORE_CALLBACK_RENEW;
502 #endif // #if OS(TIZEN) && ENABLE(TOUCH_EVENTS)
504 static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
506 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
509 priv->pageClient->handleInputMethodMousePress();
510 #endif // #if OS(TIZEN)
512 Evas_Point position = {smartData->view.x, smartData->view.y};
513 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, &position));
517 static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
519 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
521 Evas_Point position = {smartData->view.x, smartData->view.y};
522 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, &position));
526 static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
528 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
530 Evas_Point position = {smartData->view.x, smartData->view.y};
531 priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, &position));
535 static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
537 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
539 #if ENABLE(TIZEN_ISF_PORT)
540 Ecore_IMF_Event IMFEvent;
541 ecore_imf_evas_event_key_down_wrap(const_cast<Evas_Event_Key_Down*>(downEvent), &IMFEvent.key_down);
542 bool filtered = ecore_imf_context_filter_event(priv->pageClient->getIMFContext(), ECORE_IMF_EVENT_KEY_DOWN, &IMFEvent);
544 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, filtered));
546 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent));
547 #endif // #if ENABLE(TIZEN_ISF_PORT)
552 static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
554 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
556 priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
561 #if ENABLE(TOUCH_EVENTS)
562 static Eina_Bool _ewk_view_smart_multi_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Multi_Down* downEvent)
564 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData, false);
566 _ewk_view_on_touch_down(0, smartData->base.evas, smartData->self, 0);
571 static Eina_Bool _ewk_view_smart_multi_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Multi_Up* upEvent)
573 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData, false);
575 _ewk_view_on_touch_up(0, smartData->base.evas, smartData->self, 0);
580 static Eina_Bool _ewk_view_smart_multi_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Multi_Move* moveEvent)
582 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData, false);
584 _ewk_view_on_touch_move(0, smartData->base.evas, smartData->self, 0);
588 #endif // #if ENABLE(TOUCH_EVENTS)
590 static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
592 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
594 switch (event->type) {
595 case EWK_GESTURE_TAP:
596 priv->gestureClient->startTap(IntPoint(event->position.x, event->position.y));
598 case EWK_GESTURE_LONG_PRESS:
599 priv->gestureClient->startLongPress(IntPoint(event->position.x, event->position.y));
601 case EWK_GESTURE_PAN:
602 priv->gestureClient->startPan(IntPoint(event->position.x, event->position.y));
604 case EWK_GESTURE_FLICK:
605 priv->gestureClient->startFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
607 case EWK_GESTURE_PINCH: {
608 PageClientImpl* pageClient = ewkViewGetPageClient(smartData->self);
609 if (pageClient->viewportConstraints().userScalable)
610 priv->gestureClient->startPinch(IntPoint(event->position.x, event->position.y), event->scale);
614 ASSERT_NOT_REACHED();
621 static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
623 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
625 switch (event->type) {
626 case EWK_GESTURE_TAP:
627 if (event->count == 1)
628 priv->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
630 case EWK_GESTURE_LONG_PRESS:
631 priv->gestureClient->endLongPress(IntPoint(event->position.x, event->position.y));
633 case EWK_GESTURE_PAN:
634 priv->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
636 case EWK_GESTURE_FLICK:
637 priv->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
639 case EWK_GESTURE_PINCH:
640 priv->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
643 ASSERT_NOT_REACHED();
650 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
652 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
654 switch (event->type) {
655 case EWK_GESTURE_PAN:
656 priv->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
658 case EWK_GESTURE_TAP:
659 case EWK_GESTURE_LONG_PRESS:
660 case EWK_GESTURE_FLICK:
662 case EWK_GESTURE_PINCH: {
663 PageClientImpl* pageClient = ewkViewGetPageClient(smartData->self);
664 if (pageClient->viewportConstraints().userScalable)
665 priv->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
669 ASSERT_NOT_REACHED();
676 static void _ewk_view_clients_attach(Ewk_View_Smart_Data* smartData)
678 EINA_SAFETY_ON_NULL_RETURN(smartData);
680 ewkViewContextMenuClientAttachClient(smartData->self);
681 ewkViewFindClientAttatchClient(smartData->self);
682 ewkViewFormClientAttachClient(smartData->self);
683 ewkViewLoaderClientAttachClient(smartData->self);
684 ewkViewPolicyClientAttatchClient(smartData->self);
685 ewkViewTizenClientAttachClient(smartData->self);
686 ewkViewUIClientAttatchClient(smartData->self);
689 static void _ewk_view_providers_attach(Ewk_View_Smart_Data* smartData, WKContextRef contextRef)
691 EINA_SAFETY_ON_NULL_RETURN(smartData);
692 EINA_SAFETY_ON_NULL_RETURN(contextRef);
694 #if ENABLE(TIZEN_GEOLOCATION)
695 ewkViewGeolocationProviderAttachProvider(smartData->self, contextRef);
697 #if ENABLE(TIZEN_NOTIFICATION)
698 ewkViewNotificationProviderAttachProvider(smartData->self, contextRef);
702 static void _ewk_view_default_callbacks_set(Ewk_View_Smart_Data* smartData)
704 EINA_SAFETY_ON_NULL_RETURN(smartData);
706 ewk_view_javascript_alert_callback_set(smartData->self, _ewk_view_default_javascript_alert, 0);
707 ewk_view_javascript_confirm_callback_set(smartData->self, _ewk_view_default_javascript_confirm, 0);
708 ewk_view_javascript_prompt_callback_set(smartData->self, _ewk_view_default_javascript_prompt, 0);
709 ewk_view_open_panel_callback_set(smartData->self, _ewk_view_default_open_panel, 0);
712 static void _ewk_view_page_initialize(Ewk_View_Smart_Data* smartData, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
714 EINA_SAFETY_ON_NULL_RETURN(smartData);
715 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
717 priv->pageClient = PageClientImpl::create(toImpl(contextRef), toImpl(pageGroupRef), smartData->self);
718 priv->setting = ewkSettingCreate(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageClient->page()))));
719 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
720 ewk_view_theme_set(smartData->self, DEFAULT_THEME_PATH"/default.edj");
723 _ewk_view_clients_attach(smartData);
724 _ewk_view_providers_attach(smartData, contextRef);
725 _ewk_view_default_callbacks_set(smartData);
728 static Eina_Bool _ewk_view_initialize(Ewk_View_Smart_Data* smartData, Ewk_Context* context)
730 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData, false);
731 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
732 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
734 priv->context = context;
735 _ewk_view_page_initialize(smartData, ewk_context_WKContext_get(context), 0);
739 #endif //#if OS(TIZEN)
742 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
744 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
745 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
746 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
747 smartData->api->focus_in(smartData);
750 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
752 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
753 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
754 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
755 smartData->api->focus_out(smartData);
758 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
760 Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
761 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
762 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
763 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
764 smartData->api->mouse_wheel(smartData, wheelEvent);
767 static void _ewk_view_on_mouse_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
769 Evas_Event_Mouse_Down* downEvent = static_cast<Evas_Event_Mouse_Down*>(eventInfo);
770 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
771 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
772 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_down);
773 smartData->api->mouse_down(smartData, downEvent);
776 static void _ewk_view_on_mouse_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
778 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
779 Evas_Event_Mouse_Up* upEvent = static_cast<Evas_Event_Mouse_Up*>(eventInfo);
780 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
781 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_up);
782 smartData->api->mouse_up(smartData, upEvent);
785 static void _ewk_view_on_mouse_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
787 Evas_Event_Mouse_Move* moveEvent = static_cast<Evas_Event_Mouse_Move*>(eventInfo);
788 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
789 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
790 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_move);
791 smartData->api->mouse_move(smartData, moveEvent);
794 static void _ewk_view_on_key_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
796 Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
797 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
799 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
800 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
801 smartData->api->key_down(smartData, downEvent);
804 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
806 Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
807 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
808 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
809 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
810 smartData->api->key_up(smartData, upEvent);
814 static void _ewk_view_mouse_events_connect(Ewk_View_Smart_Data* smartData)
816 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
817 EINA_SAFETY_ON_FALSE_RETURN(priv->areMouseEventsEnabled);
819 #define CONNECT(s, c) evas_object_event_callback_add(smartData->self, s, c, smartData)
820 CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
821 CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
822 CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
826 static void _ewk_view_mouse_events_disconnect(Ewk_View_Smart_Data* smartData)
828 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
829 EINA_SAFETY_ON_TRUE_RETURN(priv->areMouseEventsEnabled);
831 #define DISCONNECT(s, c) evas_object_event_callback_del(smartData->self, s, c)
832 DISCONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
833 DISCONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
834 DISCONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
838 #if ENABLE(TOUCH_EVENTS)
839 static void _ewk_view_on_touch_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
841 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
842 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
844 // Start touchAnimator if current number of touch is one.
845 if (evas_touch_point_list_count(smartData->base.evas) == 1) {
846 priv->gestureRecognizer->initializeGesture();
847 if (priv->touchAnimator)
848 ecore_animator_del(priv->touchAnimator);
849 priv->touchAnimator = ecore_animator_add(_ewk_view_touch_animator, smartData);
851 priv->pageClient->handleInputMethodMousePress();
852 evas_touch_point_list_nth_xy_get(canvas, 0, &priv->touchDownPoint.x, &priv->touchDownPoint.y);
853 priv->exceedTouchMoveThreshold = false;
854 #endif // #if OS(TIZEN)
856 ewkViewHandleTouchEvent(ewkView, EWK_TOUCH_START);
859 static void _ewk_view_on_touch_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
861 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
862 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
864 // Stop touchAnimator if current number of touch is one.
865 if (evas_touch_point_list_count(smartData->base.evas) == 1 && priv->touchAnimator) {
866 ecore_animator_del(priv->touchAnimator);
867 priv->touchAnimator = 0;
869 ewkViewHandleTouchEvent(ewkView, EWK_TOUCH_END);
872 static void _ewk_view_on_touch_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
878 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
879 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
881 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
883 IntPoint point(x, y);
884 priv->pageClient->textSelectionDown(point, true);
889 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
891 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
893 IntPoint point(x, y);
894 priv->pageClient->textSelectionMove(point, true);
899 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
901 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
903 IntPoint point(x, y);
904 priv->pageClient->textSelectionUp(point);
910 #if ENABLE(TIZEN_DATALIST_ELEMENT)
911 static void _ewk_view_data_list_del(Eina_List* dataList)
913 EINA_SAFETY_ON_NULL_RETURN(dataList);
916 EINA_LIST_FREE(dataList, item)
917 eina_stringshare_del(static_cast<char*>(item));
921 #endif // #if OS(TIZEN)
923 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
925 static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
927 Ewk_View_Private_Data* priv =
928 static_cast<Ewk_View_Private_Data*>(calloc(1, sizeof(Ewk_View_Private_Data)));
930 EINA_LOG_CRIT("could not allocate Ewk_View_Private_Data");
933 #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
935 priv->isUsingEcoreX = WebCore::isUsingEcoreX(smartData->base.evas);
939 priv->areMouseEventsEnabled = false;
941 priv->javascriptPopup = adoptPtr<JavaScriptPopup>(new JavaScriptPopup(smartData->self));
942 priv->openPanel = adoptPtr<OpenPanel>(new OpenPanel(smartData->self));
944 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
945 priv->inputPicker = adoptPtr<InputPicker>(new InputPicker(smartData->self));
946 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
948 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
949 priv->focusRing = FocusRing::create(smartData->self);
950 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
952 #if ENABLE(TIZEN_GESTURE)
953 priv->gestureRecognizer = GestureRecognizer::create(smartData->self);
954 priv->gestureClient = GestureClient::create(smartData->self);
955 #endif // #if ENABLE(TIZEN_GESTURE)
957 #if ENABLE(TIZEN_DATALIST_ELEMENT)
961 #endif // #if OS(TIZEN)
966 static void _ewk_view_priv_del(Ewk_View_Private_Data* priv)
971 priv->pageClient = nullptr;
973 if (priv->javascriptGlobalContext)
974 JSGlobalContextRelease(priv->javascriptGlobalContext);
976 eina_stringshare_del(priv->uri);
977 eina_stringshare_del(priv->title);
978 eina_stringshare_del(priv->userAgent);
979 eina_stringshare_del(priv->encoding);
980 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
981 eina_stringshare_del(priv->webAppIconURL);
984 if (priv->authChallenge)
985 ewkAuthChallengeDelete(priv->authChallenge);
986 if (priv->policyDecision)
987 ewkPolicyDecisionDelete(priv->policyDecision);
989 #if ENABLE(TIZEN_MEDIA_STREAM)
990 if (priv->userMediaPermission)
991 ewkUserMediaPermissionDelete(priv->userMediaPermission);
994 ewkSettingDelete(priv->setting);
995 priv->openPanelListener = 0;
996 priv->openPanel = nullptr;
997 priv->javascriptPopup = nullptr;
998 priv->alertContext = nullptr;
999 priv->confirmContext = nullptr;
1000 priv->promptContext = nullptr;
1001 priv->openpanelContext = nullptr;
1002 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1003 priv->inputPicker = nullptr;
1004 eina_stringshare_del(priv->inputValue);
1008 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1009 _ewk_view_data_list_del(priv->dataList);
1013 #if ENABLE(TIZEN_GEOLOCATION)
1014 if (priv->geolocation)
1015 ewkGeolocationDeleteGeolocation(priv->geolocation);
1016 if (priv->geolocationPermission)
1017 ewkGeolocationDeletePermission(priv->geolocationPermission);
1020 #if ENABLE(TIZEN_NOTIFICATION)
1021 if (priv->notifications)
1022 ewkNotificationDeleteNotificationList(priv->notifications);
1023 if (priv->notificationPermissionRequest)
1024 ewkNotificationDeletePermissionRequest(priv->notificationPermissionRequest);
1026 #if ENABLE(TIZEN_SQL_DATABASE)
1027 if (priv->exceededDatabaseQuota)
1028 ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
1030 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1031 priv->focusRing = nullptr;
1032 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1033 #if ENABLE(TIZEN_GESTURE)
1034 priv->gestureRecognizer = nullptr;
1035 priv->gestureClient = nullptr;
1036 #if ENABLE(TOUCH_EVENTS)
1037 if (priv->touchAnimator)
1038 ecore_animator_del(priv->touchAnimator);
1039 #endif // #if ENABLE(TOUCH_EVENTS)
1040 #endif // #if ENABLE(TIZEN_GESTURE)
1042 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1043 eina_stringshare_del(priv->selectedText);
1049 static void _ewk_view_smart_add(Evas_Object* ewkView)
1051 const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
1052 const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
1053 const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
1054 EWK_VIEW_SD_GET(ewkView, smartData);
1057 smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
1059 EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
1062 evas_object_smart_data_set(ewkView, smartData);
1065 smartData->self = ewkView;
1066 #if !ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
1067 smartData->priv = _ewk_view_priv_new(smartData);
1069 smartData->api = api;
1071 #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
1072 g_parentSmartClass.add(ewkView);
1074 smartData->priv = _ewk_view_priv_new(smartData);
1076 if (!smartData->priv) {
1077 EINA_LOG_CRIT("could not allocate _Ewk_View_Private_Data");
1078 evas_object_smart_data_set(ewkView, 0);
1083 #if !ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
1084 g_parentSmartClass.add(ewkView);
1089 smartData->bg_rect = evas_object_rectangle_add(smartData->base.evas);
1090 evas_object_color_set(smartData->bg_rect, 255, 255, 255, 255);
1091 evas_object_show(smartData->bg_rect);
1092 evas_object_smart_member_add(smartData->bg_rect, ewkView);
1093 #endif // #if OS(TIZEN)
1095 // Create evas_object_image to draw web contents.
1096 smartData->image = evas_object_image_add(smartData->base.evas);
1098 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1099 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
1100 const char *engine = ecore_evas_engine_name_get(ee);
1101 if (engine && !strcmp(engine, "opengl_x11"))
1102 evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
1104 #endif // #if OS(TIZEN)
1105 evas_object_image_alpha_set(smartData->image, false);
1106 evas_object_image_filled_set(smartData->image, true);
1107 evas_object_smart_member_add(smartData->image, ewkView);
1108 evas_object_show(smartData->image);
1110 evas_object_pass_events_set(smartData->image, true);
1112 // create events_rect
1113 smartData->events_rect = evas_object_rectangle_add(smartData->base.evas);
1114 evas_object_color_set(smartData->events_rect, 0, 0, 0, 0);
1115 evas_object_smart_member_add(smartData->events_rect, ewkView);
1116 evas_object_show(smartData->events_rect);
1118 if (smartData->priv->areMouseEventsEnabled)
1119 _ewk_view_mouse_events_connect(smartData);
1120 #endif // #if OS(TIZEN)
1122 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
1123 CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
1124 CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
1125 CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
1127 CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
1128 CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
1129 CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
1131 CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
1132 CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
1133 #if OS(TIZEN) && ENABLE(TOUCH_EVENTS)
1134 // FIXME: We have to connect touch callbacks with Mouse and Multi event
1135 // because the Evas sends the Touch event using them.
1136 // It should be fixed when the Evas supports the Touch event.
1137 CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down);
1138 CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up);
1139 CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move);
1140 CONNECT(EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down);
1141 CONNECT(EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up);
1142 CONNECT(EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move);
1143 #endif // #if OS(TIZEN) && ENABLE(TOUCH_EVENTS)
1147 static void _ewk_view_smart_del(Evas_Object* ewkView)
1149 EWK_VIEW_SD_GET(ewkView, smartData);
1150 if (smartData && smartData->priv)
1151 _ewk_view_priv_del(smartData->priv);
1153 g_parentSmartClass.del(ewkView);
1156 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
1158 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1160 evas_object_resize(smartData->image, width, height);
1161 evas_object_image_size_set(smartData->image, width, height);
1162 evas_object_image_fill_set(smartData->image, 0, 0, width, height);
1164 evas_object_resize(smartData->events_rect, width, height);
1166 EWK_VIEW_PRIV_GET(smartData, priv);
1167 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1168 evas_object_image_native_surface_set(smartData->image, 0);
1170 priv->pageClient->displayViewport();
1173 #if ENABLE(TIZEN_PREFERENCE)
1174 if (priv && priv->pageClient->page()) {
1175 priv->pageClient->page()->pageGroup()->preferences()->setViewWidth(width);
1176 priv->pageClient->page()->pageGroup()->preferences()->setViewHeight(height);
1179 #endif // #if OS(TIZEN)
1181 smartData->changed.size = true;
1182 _ewk_view_smart_changed(smartData);
1185 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
1187 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1189 smartData->changed.position = true;
1190 _ewk_view_smart_changed(smartData);
1193 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
1195 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1196 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1197 Evas_Coord x, y, width, height;
1199 smartData->changed.any = false;
1201 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
1203 if (smartData->changed.size) {
1204 smartData->view.w = width;
1205 smartData->view.h = height;
1206 smartData->changed.size = false;
1209 if (priv->pageClient) {
1210 if (DrawingAreaProxy* drawingArea = priv->pageClient->page()->drawingArea()) {
1211 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
1212 if (priv->pageClient->page()->isViewVisible())
1213 drawingArea->setSize(IntSize(width, height), IntSize());
1215 drawingArea->setSize(IntSize(width, height), IntSize());
1217 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1218 priv->pageClient->updateViewportSize(IntSize(width, height));
1219 priv->pageClient->displayViewport();
1222 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1223 priv->pageClient->frameRectChanged();
1226 evas_object_resize(smartData->bg_rect, width, height);
1228 #endif // #if OS(TIZEN)
1231 if (smartData->changed.position) {
1232 evas_object_move(smartData->image, x, y);
1234 evas_object_move(smartData->events_rect, x, y);
1235 evas_object_move(smartData->bg_rect, x, y);
1236 #endif // #if OS(TIZEN)
1237 smartData->view.x = x;
1238 smartData->view.y = y;
1239 smartData->changed.position = false;
1241 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1242 priv->pageClient->frameRectChanged();
1246 if (priv->popupPicker)
1247 ewk_popup_picker_resize(priv->popupPicker);
1250 static void _ewk_view_smart_show(Evas_Object* ewkView)
1252 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1253 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1255 if (evas_object_clipees_get(smartData->base.clipper))
1256 evas_object_show(smartData->base.clipper);
1257 evas_object_show(smartData->image);
1260 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1262 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1263 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1265 evas_object_hide(smartData->base.clipper);
1266 evas_object_hide(smartData->image);
1269 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1271 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1272 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1276 else if (alpha > 255)
1279 #define CHECK_COLOR(color, alpha) \
1282 else if (color > alpha) \
1284 CHECK_COLOR(red, alpha);
1285 CHECK_COLOR(green, alpha);
1286 CHECK_COLOR(blue, alpha);
1290 evas_object_color_set(smartData->bg_rect, red, green, blue, alpha);
1292 evas_object_image_alpha_set(smartData->image, alpha < 255);
1293 priv->pageClient->page()->setDrawsBackground(red || green || blue);
1294 priv->pageClient->page()->setDrawsTransparentBackground(alpha < 255);
1296 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1300 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1302 Eina_Bool ewk_view_smart_class_init(Ewk_View_Smart_Class* api)
1305 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1307 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1308 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1309 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1313 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1314 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1316 evas_object_smart_clipped_smart_set(&api->sc);
1318 // Set Evas_Smart_Class functions.
1319 api->sc.add = _ewk_view_smart_add;
1320 api->sc.del = _ewk_view_smart_del;
1321 api->sc.move = _ewk_view_smart_move;
1322 api->sc.resize = _ewk_view_smart_resize;
1323 api->sc.show = _ewk_view_smart_show;
1324 api->sc.hide = _ewk_view_smart_hide;
1325 api->sc.color_set = _ewk_view_smart_color_set;
1326 api->sc.calculate = _ewk_view_smart_calculate;
1327 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1329 // Set Ewk_View_Smart_Class functions.
1330 api->focus_in = _ewk_view_smart_focus_in;
1331 api->focus_out = _ewk_view_smart_focus_out;
1332 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1333 api->mouse_down = _ewk_view_smart_mouse_down;
1334 api->mouse_up = _ewk_view_smart_mouse_up;
1335 api->mouse_move = _ewk_view_smart_mouse_move;
1336 api->key_down = _ewk_view_smart_key_down;
1337 api->key_up = _ewk_view_smart_key_up;
1339 api->initialize = _ewk_view_initialize;
1340 #if ENABLE(TOUCH_EVENTS)
1341 api->multi_down = _ewk_view_smart_multi_down;
1342 api->multi_up = _ewk_view_smart_multi_up;
1343 api->multi_move = _ewk_view_smart_multi_move;
1344 #endif // #if ENABLE(TOUCH_EVENTS)
1345 api->gesture_start = _ewk_view_smart_gesture_start;
1346 api->gesture_end = _ewk_view_smart_gesture_end;
1347 api->gesture_move = _ewk_view_smart_gesture_move;
1349 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1350 api->popup_menu_show = _ewk_view_popup_menu_show;
1351 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1353 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1354 api->text_selection_down = _ewk_view_text_selection_down;
1355 api->text_selection_move = _ewk_view_text_selection_move;
1356 api->text_selection_up = _ewk_view_text_selection_up;
1358 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1359 api->input_picker_show = _ewk_view_input_picker_show;
1361 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1362 api->data_list_show = _ewk_view_data_list_show;
1363 api->data_list_hide = _ewk_view_data_list_hide;
1365 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1366 api->orientation_lock = _ewk_orientation_lock;
1367 api->orientation_unlock = _ewk_orientation_unlock;
1369 #endif //#if OS(TIZEN)
1374 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1376 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION(ewkViewLegacyName);
1377 static Evas_Smart* smart = 0;
1379 if (EINA_UNLIKELY(!smart)) {
1381 ewk_view_smart_class_set(&api);
1383 ewk_view_smart_class_init(&api);
1385 smart = evas_smart_class_new(&api.sc);
1392 static Evas_Object* _ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1394 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1397 Evas_Object* ewkView = evas_object_smart_add(canvas, _ewk_view_smart_class_new());
1401 EWK_VIEW_SD_GET(ewkView, smartData);
1403 evas_object_del(ewkView);
1407 EWK_VIEW_PRIV_GET(smartData, priv);
1409 evas_object_del(ewkView);
1414 priv->pageClient = PageClientImpl::create(toImpl(contextRef), toImpl(pageGroupRef), ewkView);
1423 * Constructs a ewk_view Evas_Object with WKType parameters.
1425 Evas_Object* ewk_view_add_with_WKType(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1427 Evas_Object* ewkView = _ewk_view_base_add(canvas, contextRef, pageGroupRef);
1429 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ewkView);
1430 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, ewkView);
1432 priv->context = ewk_context_new_with_WKContext(contextRef);
1433 _ewk_view_page_initialize(smartData, contextRef, pageGroupRef);
1437 #endif // #if OS(TIZEN)
1439 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1442 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1443 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1445 Evas_Object* ewkView = _ewk_view_base_add(canvas, ewk_context_WKContext_get(context), 0);
1447 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ewkView);
1448 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, ewkView);
1449 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->initialize, ewkView);
1450 smartData->api->initialize(smartData, context);
1454 return ewk_view_base_add(canvas, ewk_context_WKContext_get(context), 0);
1458 Evas_Object* ewk_view_add(Evas* canvas)
1460 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1463 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
1465 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1466 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1467 return priv->context;
1470 Eina_Bool ewk_view_uri_set(Evas_Object* ewkView, const char* uri)
1472 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1473 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1475 WKRetainPtr<WKURLRef> url(AdoptWK, WKURLCreateWithUTF8CString(uri));
1476 WKPageLoadURL(toAPI(priv->pageClient->page()), url.get());
1478 eina_stringshare_replace(&priv->uri, uri);
1483 const char* ewk_view_uri_get(const Evas_Object* ewkView)
1485 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1486 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1491 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1493 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1494 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1496 WKPageReload(toAPI(priv->pageClient->page()));
1500 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1502 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1503 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1505 WKPageReloadFromOrigin(toAPI(priv->pageClient->page()));
1510 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1512 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1513 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1515 WKPageStopLoading(toAPI(priv->pageClient->page()));
1519 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
1521 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1522 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1524 priv->pageClient->page()->setCustomDeviceScaleFactor(ratio);
1528 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
1530 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
1531 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1);
1533 return priv->pageClient->page()->deviceScaleFactor();
1536 void ewk_view_display(Evas_Object* ewkView, const IntRect& rect)
1538 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1539 if (!smartData->image)
1542 evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height());
1545 Eina_Bool ewk_view_back(Evas_Object* ewkView)
1547 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1548 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1550 WKPageRef pageRef = toAPI(priv->pageClient->page());
1551 if (WKPageCanGoBack(pageRef)) {
1552 WKPageGoBack(pageRef);
1558 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
1560 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1561 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1563 WKPageRef pageRef = toAPI(priv->pageClient->page());
1564 if (WKPageCanGoForward(pageRef)) {
1565 WKPageGoForward(pageRef);
1571 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
1573 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1574 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1576 return WKPageCanGoBack(toAPI(priv->pageClient->page()));
1579 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
1581 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1582 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1584 return WKPageCanGoForward(toAPI(priv->pageClient->page()));
1587 void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size)
1589 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1590 if (!imageData || !smartData->image)
1593 evas_object_resize(smartData->image, size.width(), size.height());
1594 evas_object_image_size_set(smartData->image, size.width(), size.height());
1595 evas_object_image_data_copy_set(smartData->image, imageData);
1598 WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView)
1600 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1601 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1603 return priv->pageClient->page();
1607 // FIXME: It should be removed.
1608 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
1610 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1611 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1613 return toAPI(priv->pageClient->page());
1616 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
1618 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1619 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1621 enabled = !!enabled;
1622 if (priv->areMouseEventsEnabled == enabled)
1625 priv->areMouseEventsEnabled = enabled;
1627 _ewk_view_mouse_events_connect(smartData);
1629 _ewk_view_mouse_events_disconnect(smartData);
1634 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
1636 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1637 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1639 return priv->areMouseEventsEnabled;
1642 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, Eina_List* points, const Evas_Modifier* modifiers)
1644 #if ENABLE(TOUCH_EVENTS)
1645 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
1646 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1647 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1649 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
1650 // We don't want to process touch event when context menu is shown.
1651 if (priv->pageClient->isContextMenuVisible()) {
1652 #if ENABLE(TIZEN_GESTURE)
1653 priv->gestureRecognizer->setEnableGesture(true);
1654 priv->gestureRecognizer->setEnableMoving(true);
1660 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1661 const Eina_List* list;
1663 EINA_LIST_FOREACH(points, list, item) {
1664 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(item);
1665 float revertScale = 1 / priv->pageClient->scaleFactor();
1666 IntPoint scrollPosition = priv->pageClient->scrollPosition();
1667 point->x = (scrollPosition.x() + (point->x - smartData->view.x)) * revertScale + smartData->view.x;
1668 point->y = (scrollPosition.y() + (point->y - smartData->view.y)) * revertScale + smartData->view.y;
1672 Evas_Point position = {smartData->view.x, smartData->view.y};
1673 priv->pageClient->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, position, smartData->base.evas, ecore_time_get()));
1681 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
1683 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1684 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1686 return priv->javascriptPopup->alert(alertText);
1689 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
1691 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1692 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1694 return priv->javascriptPopup->confirm(message);
1697 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
1699 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1700 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1702 return priv->javascriptPopup->prompt(message, defaultValue);
1705 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)
1707 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1708 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1710 return priv->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, priv);
1713 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1714 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)
1716 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1718 if (priv->popupPicker)
1719 ewk_popup_picker_del(priv->popupPicker);
1721 priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
1726 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
1728 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1730 if (!priv->popupPicker)
1733 ewk_popup_picker_del(priv->popupPicker);
1734 priv->popupPicker = 0;
1740 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1741 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
1743 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1745 priv->inputPicker->show(inputType, inputValue);
1750 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1751 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
1753 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1755 priv->inputPicker->showDataList(inputType, optionList);
1759 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
1761 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1763 priv->inputPicker->hideDataList(inputType);
1768 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
1770 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1771 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1773 return priv->pageClient.get();
1776 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
1778 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
1779 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1);
1781 return WKPageGetTextZoomFactor(toAPI(priv->pageClient->page()));
1784 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
1786 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1787 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
1789 WKPageSetTextZoomFactor(toAPI(priv->pageClient->page()), textZoomFactor);
1793 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1794 void ewkViewShowFocusRing(Evas_Object* ewkView, const IntPoint& position)
1796 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1797 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1798 if (!priv->focusRing)
1801 priv->focusRing->requestToShow(position);
1804 void ewkViewHideFocusRing(Evas_Object* ewkView)
1806 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1807 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1808 if (!priv->focusRing)
1811 priv->focusRing->hide();
1813 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1815 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
1817 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1818 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1820 return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(priv->pageClient->page())));
1823 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
1825 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1826 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1828 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(priv->pageClient->page())));
1831 Ewk_Setting* ewk_view_setting_get(Evas_Object* ewkView)
1833 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1834 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1836 return priv->setting;
1839 #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
1840 void ewk_view_cursor_set(Evas_Object* ewkView, const Cursor& cursor)
1843 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1844 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1846 if (!priv->isUsingEcoreX)
1849 const char* group = cursor.platformCursor();
1850 if (!group || group == priv->cursorGroup)
1852 priv->cursorGroup = group;
1854 Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
1855 WebCore::applyFallbackCursor(ecoreEvas, group);
1860 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
1862 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1863 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
1865 if (!priv->javascriptGlobalContext)
1866 priv->javascriptGlobalContext = JSGlobalContextCreate(0);
1867 return priv->javascriptGlobalContext;
1870 static void setURI(Evas_Object* ewkView)
1872 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1873 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1875 WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKPageCopyActiveURL(toAPI(priv->pageClient->page())));
1879 CString activeURI = toImpl(wkURL.get())->string().utf8();
1881 if (priv->uri && (activeURI == CString(priv->uri)))
1884 eina_stringshare_replace(&priv->uri, activeURI.data());
1886 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1889 void ewkViewLoadStarted(Evas_Object* ewkView)
1892 evas_object_smart_callback_call(ewkView, "load,started", 0);
1895 void ewkViewLoadCommitted(Evas_Object* ewkView)
1898 evas_object_smart_callback_call(ewkView, "load,committed", 0);
1901 void ewkViewLoadFinished(Evas_Object* ewkView)
1904 evas_object_smart_callback_call(ewkView, "load,finished", 0);
1907 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
1909 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1910 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1912 Ewk_Error* ewkError = ewkErrorCreate(error);
1913 ewkErrorLoadErrorPage(ewkError, toAPI(priv->pageClient->page()));
1914 evas_object_smart_callback_call(ewkView, "load,error", ewkError);
1915 ewkErrorDelete(ewkError);
1918 void ewkViewSetTitleAndURL(Evas_Object* ewkView, const char* title, const char* url)
1920 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1921 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1923 if (title && eina_stringshare_replace(&priv->title, title))
1924 evas_object_smart_callback_call(ewkView, "title,changed", static_cast<void*>(const_cast<char*>(priv->title)));
1925 if (url && eina_stringshare_replace(&priv->uri, title))
1926 evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
1929 void ewkViewSetTitle(Evas_Object* ewkView, const char* title)
1931 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1932 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1934 if (!title || !eina_stringshare_replace(&priv->title, title))
1936 evas_object_smart_callback_call(ewkView, "title,changed", static_cast<void*>(const_cast<char*>(priv->title)));
1939 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
1941 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
1944 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
1946 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1947 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1949 if (priv->authChallenge)
1950 ewkAuthChallengeDelete(priv->authChallenge);
1951 priv->authChallenge = authChallenge;
1953 evas_object_smart_callback_call(ewkView, "authentication,challenge", priv->authChallenge);
1956 void ewkViewLoadProgressChanged(Evas_Object* ewkView, double progress)
1958 evas_object_smart_callback_call(ewkView, "load,progress", &progress);
1961 void ewkViewProcessCrashed(Evas_Object* ewkView)
1963 evas_object_smart_callback_call(ewkView, "process,crashed", 0);
1966 #if ENABLE(TIZEN_SQL_DATABASE)
1967 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)
1969 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, currentQuota);
1970 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, currentQuota);
1972 if (priv->exceededDatabaseQuota)
1973 ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
1974 priv->exceededDatabaseQuota = ewkContextCreateExceededQuota(origin, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
1975 evas_object_smart_callback_call(ewkView, "database,quota,exceeded", priv->exceededDatabaseQuota);
1977 return ewkContextGetNewQuotaForExceededQuota(priv->context, priv->exceededDatabaseQuota);
1981 #if ENABLE(TIZEN_NOTIFICATION)
1982 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
1984 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
1987 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
1989 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1990 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
1992 if(priv->notificationPermissionRequest)
1993 ewkNotificationDeletePermissionRequest(priv->notificationPermissionRequest);
1994 priv->notificationPermissionRequest = notificationPermissionRequest;
1996 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
1999 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
2001 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2002 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2004 Eina_List* listIterator=0;
2006 const char* replaceID = ewkNotificationGetReplaceID(notification);
2007 if(strlen(replaceID)) {
2008 EINA_LIST_FOREACH(priv->notifications, listIterator, data) {
2009 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
2010 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
2011 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
2015 priv->notifications = eina_list_append(priv->notifications, notification);
2016 evas_object_smart_callback_call(ewkView, "notification,show", notification);
2020 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
2021 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
2023 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2024 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
2025 evas_object_smart_callback_call(ewkView, "protocolhandlers,register", static_cast<void*>(customHandlersData));
2026 ewkCustomHandlersDeleteData(customHandlersData);
2030 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
2031 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
2033 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2034 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
2035 evas_object_smart_callback_call(ewkView, "contenthandlers,register", static_cast<void*>(customHandlersData));
2036 ewkCustomHandlersDeleteData(customHandlersData);
2040 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
2041 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
2043 bool standalone = true;
2044 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
2049 #if ENABLE(TIZEN_MM_PLAYER)
2050 void ewkViewProcessHTML5Video(Evas_Object* ewkView, WKStringRef url, WKStringRef cookie)
2052 Ewk_View_Html5_Video_Data videoData;
2053 videoData.url = url;
2054 videoData.cookie = cookie;
2055 evas_object_smart_callback_call(ewkView, "request,html5video", &videoData);
2059 #if ENABLE(TIZEN_MEDIA_STREAM)
2060 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission* userMediaPermission)
2062 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2063 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2064 if (priv->userMediaPermission)
2065 ewkUserMediaPermissionDelete(priv->userMediaPermission);
2066 priv->userMediaPermission = userMediaPermission;
2068 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", priv->userMediaPermission);
2072 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
2073 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
2075 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
2076 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
2077 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
2078 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
2079 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
2080 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
2082 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
2086 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
2087 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
2089 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
2093 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
2095 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
2098 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
2100 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
2103 void ewkViewClosePage(Evas_Object* ewkView)
2105 evas_object_smart_callback_call(ewkView, "close,window", 0);
2108 #if ENABLE(TIZEN_GEOLOCATION)
2109 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Data* permissionData)
2111 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2112 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2114 if (priv->geolocationPermission)
2115 ewkGeolocationDeletePermission(priv->geolocationPermission);
2116 priv->geolocationPermission = permissionData;
2118 evas_object_smart_callback_call(ewkView, "request,geolocation,permission", priv->geolocationPermission);
2121 void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
2123 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2124 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2126 priv->geolocation = geolocation;
2129 Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
2131 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2132 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2134 return priv->geolocation;
2137 bool ewkViewIsValidLocationService(Evas_Object* ewkView)
2140 evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
2145 WKPageRef ewkViewCreateNewPage(Evas_Object* ewkView)
2147 Evas_Object* createdEwkView = 0;
2149 evas_object_smart_callback_call(ewkView, "create,window", &createdEwkView);
2151 if (!createdEwkView)
2154 return static_cast<WKPageRef>(WKRetain(toAPI(ewk_view_page_get(createdEwkView))));
2157 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
2159 evas_object_smart_callback_call(ewkView, "form,submit", formData);
2162 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2164 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2165 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
2166 if (priv->policyDecision)
2167 ewkPolicyDecisionDelete(priv->policyDecision);
2168 priv->policyDecision = policyDecision;
2170 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", priv->policyDecision);
2173 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2175 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2176 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
2177 if (priv->policyDecision)
2178 ewkPolicyDecisionDelete(priv->policyDecision);
2179 priv->policyDecision = policyDecision;
2181 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", priv->policyDecision);
2184 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2186 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2187 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
2188 if (priv->policyDecision)
2189 ewkPolicyDecisionDelete(priv->policyDecision);
2190 priv->policyDecision = policyDecision;
2192 evas_object_smart_callback_call(ewkView, "policy,response,decide", priv->policyDecision);
2195 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
2197 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2198 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2200 IntPoint scrollPosition = priv->pageClient->scrollPosition();
2201 IntSize contentsSize = priv->pageClient->page()->contentsSize();
2202 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2203 contentsSize.scale(priv->pageClient->scaleFactor());
2206 // some website's contents size is smaller than view size,
2207 // so we have to adjust contents size to view size for that case.
2208 if (contentsSize.width() < smartData->view.w)
2209 contentsSize.setWidth(smartData->view.w);
2210 if (contentsSize.height() < smartData->view.h)
2211 contentsSize.setHeight(smartData->view.h);
2213 // Call "scroll,down" if webview can be scrolled down.
2214 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
2215 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
2216 // Call "scroll,up" if webview can be scrolled up.
2217 else if (deltaY < 0 && scrollPosition.y() > 0)
2218 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
2220 // Call "scroll,right" if webview can be scrolled down.
2221 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
2222 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
2223 // Call "scroll,left" if webview can be scrolled up.
2224 else if (deltaX < 0 && scrollPosition.x() > 0)
2225 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
2228 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
2230 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2231 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2233 IntSize contentsSize = priv->pageClient->page()->contentsSize();
2234 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2235 contentsSize.scale(priv->pageClient->scaleFactor());
2238 int maxScrollY = contentsSize.height() - smartData->view.h;
2239 if (!priv->isVerticalEdge) {
2240 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
2241 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
2242 priv->isVerticalEdge = true;
2243 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
2244 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
2245 priv->isVerticalEdge = true;
2248 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
2249 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
2250 priv->isVerticalEdge = false;
2253 int maxScrollX = contentsSize.width() - smartData->view.w;
2254 if (!priv->isHorizontalEdge) {
2255 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
2256 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
2257 priv->isHorizontalEdge = true;
2258 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
2259 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
2260 priv->isHorizontalEdge = true;
2263 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
2264 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
2265 priv->isHorizontalEdge = false;
2269 void ewkViewClearEdges(Evas_Object* ewkView)
2271 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2272 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2274 priv->isVerticalEdge = false;
2275 priv->isHorizontalEdge = false;
2278 void ewk_view_top_of_contents_go(Evas_Object* ewkView)
2280 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2281 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2283 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2284 priv->pageClient->setVisibleContentRect(IntPoint(), priv->pageClient->scaleFactor(), FloatPoint());
2285 priv->pageClient->displayViewport();
2287 priv->pageClient->page()->scrollMainFrameTo(IntPoint());
2291 Eina_Bool ewk_view_enable_specified_plugin_set(Evas_Object* ewkView, Eina_Bool enable, const char* mimeType)
2293 #if ENABLE(TIZEN_ON_OFF_SPECIFIED_PLUGINS)
2297 PluginDatabase* pluginDatabase = PluginDatabase::installedPlugins(true);
2298 if (!pluginDatabase)
2301 // Find pluginPackage.
2302 String key = String(mimeType).lower();
2303 Vector<PluginPackage*, 2> pluginChoices;
2304 const Vector<WebCore::PluginPackage *> plugins = pluginDatabase->plugins();
2305 for (unsigned int i = 0; i < plugins.size(); i++) {
2306 PluginPackage* plugin = plugins[i];
2307 if (plugin->mimeToDescriptions().contains(key))
2308 pluginChoices.append(plugin);
2311 // Set enable/disable to choiced pluginPackage.
2312 if (!pluginChoices.isEmpty()) {
2313 qsort(pluginChoices.data(), pluginChoices.size(), sizeof(PluginPackage*), PluginDatabase::preferredPluginCompare);
2314 pluginChoices[0].setEnabled(enable);
2324 double ewk_view_scale_get(Evas_Object* ewkView)
2326 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
2327 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1);
2329 return priv->pageClient->page()->scaleFactor();
2332 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, Evas_Coord centerX, Evas_Coord centerY)
2334 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2335 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2337 scaleFactor = priv->pageClient->adjustScaleWithViewport(scaleFactor);
2339 IntPoint scrollPosition = priv->pageClient->scrollPosition();
2340 double scaleDifference = scaleFactor / priv->pageClient->scaleFactor();
2341 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
2342 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
2344 priv->pageClient->page()->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
2349 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
2351 EWK_VIEW_SD_GET(ewkView, smartData);
2352 if (!smartData || !smartData->priv) {
2360 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
2362 *minimumScale = constraints.minimumScale;
2364 *maximumScale = constraints.maximumScale;
2367 static void inputPickerClosed(void* data, Evas_Object*, void*)
2369 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
2370 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2371 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
2373 ecore_imf_context_input_panel_hide(priv->pageClient->getIMFContext());
2374 ecore_imf_context_focus_out(priv->pageClient->getIMFContext());
2377 Evas_Object* ewk_view_image_get(Evas_Object* o)
2379 EWK_VIEW_SD_GET_OR_RETURN(o, sd, 0);
2383 void ewk_view_form_navigation_move(Evas_Object* ewkView, int newPosition)
2385 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2386 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2388 priv->pageClient->page()->moveFocus(newPosition);
2389 priv->formNavigation.position = newPosition;
2392 bool ewk_view_focused_node_adjust(Evas_Object* ewkView)
2394 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2395 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2397 double scaleFactor = priv->pageClient->scaleFactor();
2398 IntSize contentsSize = priv->pageClient->page()->contentsSize();
2400 IntSize visibleSize(0, 0);
2401 IntPoint scrollPosition(0, 0);
2402 IntRect caretRect(0, 0, 0, 0);
2404 double newScaleFactor = scaleFactor;
2405 // Readable zoom value is dependent on device DPI
2406 if (scaleFactor < priv->pageClient->page()->pageGroup()->preferences()->devicePixelRatio()
2407 && priv->pageClient->viewportConstraints().userScalable)
2408 newScaleFactor = ((float)priv->pageClient->page()->pageGroup()->preferences()->devicePixelRatio()) / 160;
2410 // Readable zoom value should be inside of viewport scale range
2411 newScaleFactor = priv->pageClient->adjustScaleWithViewport(newScaleFactor);
2413 // scale contents' size with new scale factor
2414 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2415 contentsSize.scale(newScaleFactor);
2417 contentsSize.scale(newScaleFactor / scaleFactor);
2420 Ecore_IMF_Context* imfContext = priv->pageClient->getIMFContext();
2421 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
2422 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
2423 if (!(static_cast<PageClient*>(priv->pageClient.get()))->isViewFocused()
2425 || ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
2428 visibleSize = IntSize(smartData->view.w, smartData->view.h);
2429 // caret position can be outside of visible rect.
2430 // we need to consider it.
2431 priv->pageClient->page()->getCaretPosition(caretRect);
2432 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2433 caretRect.scale(newScaleFactor);
2435 caretRect.scale(newScaleFactor / scaleFactor);
2437 if (caretRect.isEmpty())
2441 scrollPosition.setX(caretRect.x() - 20);
2442 scrollPosition.setY(caretRect.y() - visibleSize.height() / 2);
2444 // Restrict visible content rect inside of contents boundary
2445 if (scrollPosition.x() < 0)
2446 scrollPosition.setX(0);
2447 if (scrollPosition.y() < 0)
2448 scrollPosition.setY(0);
2449 if (scrollPosition.x() + visibleSize.width() > contentsSize.width())
2450 scrollPosition.setX(contentsSize.width() - visibleSize.width());
2451 if (scrollPosition.y() + visibleSize.height() > contentsSize.height())
2452 scrollPosition.setY(contentsSize.height() - visibleSize.height());
2454 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2455 priv->pageClient->setVisibleContentRect(scrollPosition, newScaleFactor, FloatPoint());
2456 if (newScaleFactor == scaleFactor)
2457 priv->pageClient->displayViewport();
2459 if (newScaleFactor != scaleFactor)
2460 priv->pageClient->page()->scalePage(newScaleFactor, scrollPosition);
2462 priv->pageClient->page()->scrollMainFrameTo(scrollPosition);
2464 evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
2468 #if ENABLE(TIZEN_READER)
2469 static void getReaderCallback(WKDictionaryRef reader, WKErrorRef error, void* functionContext)
2471 EINA_SAFETY_ON_NULL_RETURN(functionContext);
2472 Ewk_View_Callback_Context* context = static_cast<Ewk_View_Callback_Context*>(functionContext);
2474 if (!reader || error) {
2479 WKRetainPtr<WKStringRef> urlKey(AdoptWK, WKStringCreateWithUTF8CString("url"));
2480 WKRetainPtr<WKStringRef> htmlKey(AdoptWK, WKStringCreateWithUTF8CString("html"));
2481 WKStringRef urlString = static_cast<WKStringRef>(WKDictionaryGetItemForKey(reader, urlKey.get()));
2482 WKStringRef htmlString = static_cast<WKStringRef>(WKDictionaryGetItemForKey(reader, htmlKey.get()));
2486 int htmlLength = WKStringGetMaximumUTF8CStringSize(htmlString);
2488 OwnArrayPtr<char> html = adoptArrayPtr(new char[htmlLength]);
2489 WKStringGetUTF8CString(htmlString, html.get(), htmlLength);
2491 ASSERT(context->readerCallback);
2493 int urlLength = WKStringGetMaximumUTF8CStringSize(urlString);
2495 OwnArrayPtr<char> url = adoptArrayPtr(new char[urlLength]);
2496 WKStringGetUTF8CString(urlString, url.get(), urlLength);
2497 context->readerCallback(context->ewkView, url.get(), html.get(), context->userData);
2499 context->readerCallback(context->ewkView, "", html.get(), context->userData);
2506 void ewk_view_reader_article_check(Evas_Object* ewkView, Ewk_View_Reader_Callback callback, void* userData)
2508 #if ENABLE(TIZEN_READER)
2509 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2510 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2511 EINA_SAFETY_ON_NULL_RETURN(callback);
2513 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
2514 context->readerCallback = callback;
2515 context->ewkView = ewkView;
2516 context->userData = userData;
2517 WKPageCheckReaderArticle(toAPI(priv->pageClient->page()), context, getReaderCallback);
2521 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
2522 void ewk_view_mark_for_sync(Evas_Object* ewkView)
2524 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2525 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
2526 evas_object_image_pixels_dirty_set(smartData->image, true);
2529 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
2531 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
2532 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2533 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2534 priv->pageClient->drawContents();
2537 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
2539 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2540 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2542 if (!smartData->image)
2545 evas_object_image_native_surface_set(smartData->image, nativeSurface);
2546 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
2552 #if ENABLE(TIZEN_WEBKIT_PASTEBOARD)
2553 void ewk_view_write_data_to_clipboard_with_type(Evas_Object* ewkView, const String& data, Pasteboard::PasteboardDataType type)
2555 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2558 case Pasteboard::PlainText:
2559 elm_cnp_selection_set(elm_object_parent_widget_get(ewkView), ELM_SEL_TYPE_CLIPBOARD,
2560 ELM_SEL_FORMAT_TEXT, data.utf8().data(), data.length());
2562 case Pasteboard::Markup:
2563 elm_cnp_selection_set(elm_object_parent_widget_get(ewkView), ELM_SEL_TYPE_CLIPBOARD,
2564 ELM_SEL_FORMAT_HTML, data.utf8().data(), data.length());
2566 case Pasteboard::ImageURI:
2567 // FIXME: We pass data.length() + 1 because of a bug in elementary which adds some random characters
2568 // to copied image path. '+1' should be removed when the bug will be fixed on elementary side.
2569 elm_cnp_selection_set(elm_object_parent_widget_get(ewkView), ELM_SEL_TYPE_CLIPBOARD,
2570 ELM_SEL_FORMAT_IMAGE, data.utf8().data(), data.length() + 1);
2577 static Eina_Bool pasteCallback(void* data, Evas_Object* object, Elm_Selection_Data* selectionData)
2579 WebPageProxy* webPageProxy = static_cast<WebPageProxy*>(data);
2581 if (!selectionData || selectionData->len <= 0) {
2582 webPageProxy->sendPasteMessageWithData(String(""), WebCore::Pasteboard::PlainText);
2584 String data = String::fromUTF8(static_cast<const char*>(selectionData->data));
2585 if (selectionData->format == ELM_SEL_FORMAT_TEXT)
2586 webPageProxy->sendPasteMessageWithData(data, WebCore::Pasteboard::PlainText);
2587 else if (selectionData->format == ELM_SEL_FORMAT_HTML)
2588 webPageProxy->sendPasteMessageWithData(data, WebCore::Pasteboard::Markup);
2589 else if (selectionData->format == ELM_SEL_FORMAT_IMAGE)
2590 webPageProxy->sendPasteMessageWithData(data, WebCore::Pasteboard::ImageURI);
2596 void ewk_view_paste_with_clipboard(Evas_Object* ewkView)
2598 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2599 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2601 if (!ewk_util_number_of_clipboard_items_get(ewkView)) {
2602 priv->pageClient->page()->sendPasteMessageWithData(String(""), WebCore::Pasteboard::PlainText);
2606 Eina_Bool result = elm_cnp_selection_get(elm_object_parent_widget_get(ewkView), ELM_SEL_TYPE_CLIPBOARD,
2607 static_cast<Elm_Sel_Format>(ELM_SEL_FORMAT_TEXT | ELM_SEL_FORMAT_HTML | ELM_SEL_FORMAT_IMAGE),
2608 pasteCallback, priv->pageClient->page());
2610 priv->pageClient->page()->sendPasteMessageWithData(String(""), WebCore::Pasteboard::PlainText);
2612 #endif // ENABLE(TIZEN_WEBKIT_PASTEBOARD)
2614 void ewk_view_suspend(Evas_Object* ewkView)
2616 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2617 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2619 priv->pageClient->suspendIfNeeded();
2622 void ewk_view_resume(Evas_Object* ewkView)
2624 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2625 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2627 priv->pageClient->resumeIfNeeded();
2630 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
2632 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2633 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2634 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
2636 ResourceRequest request(url);
2639 case EWK_HTTP_METHOD_GET:
2640 request.setHTTPMethod("GET");
2642 case EWK_HTTP_METHOD_HEAD:
2643 request.setHTTPMethod("HEAD");
2645 case EWK_HTTP_METHOD_POST:
2646 request.setHTTPMethod("POST");
2648 case EWK_HTTP_METHOD_PUT:
2649 request.setHTTPMethod("PUT");
2651 case EWK_HTTP_METHOD_DELETE:
2652 request.setHTTPMethod("DELETE");
2659 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
2661 while (eina_iterator_next(it, &data)) {
2662 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
2663 const char* name = static_cast<const char*>(t->key);
2664 const char* value = static_cast<const char*>(t->data);
2665 request.addHTTPHeaderField(name, value);
2667 eina_iterator_free(it);
2671 request.setHTTPBody(FormData::create(body));
2673 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
2674 WKPageLoadURLRequest(toAPI(priv->pageClient->page()), urlRequest.get());
2679 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
2681 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2682 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2684 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
2685 WKPageLoadPlainTextString(toAPI(priv->pageClient->page()), plainTextRef.get());
2690 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
2692 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2693 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2694 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
2696 if (contentsSize == 0)
2699 String mimeTypeString;
2701 mimeTypeString = String::fromUTF8(mimeType);
2703 mimeTypeString = String::fromUTF8("text/html");
2705 String encodingString;
2707 encodingString = String::fromUTF8(encoding);
2709 encodingString = String::fromUTF8("UTF-8");
2711 String baseUriString;
2713 baseUriString = String::fromUTF8(baseUri);
2715 baseUriString = String::fromUTF8("about:blank");
2717 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
2718 priv->pageClient->page()->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
2723 const char* ewk_view_title_get(const Evas_Object* ewkView)
2725 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2726 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2731 double ewk_view_load_progress_get(const Evas_Object* ewkView)
2733 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
2734 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1);
2736 return WKPageGetEstimatedProgress(toAPI(priv->pageClient->page()));
2739 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
2741 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2742 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2744 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
2745 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
2747 WKPageLoadHTMLString(toAPI(priv->pageClient->page()), htmlString.get(), baseURL.get());
2752 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
2754 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2755 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2757 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
2758 WKPageSetPageVisibility(toAPI(priv->pageClient->page()), static_cast<WKPageVisibilityState
2759 >(pageVisibilityState), initialState);
2767 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
2769 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
2771 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2772 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2774 eina_stringshare_replace(&priv->userAgent, userAgent);
2776 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
2777 WKPageSetCustomUserAgent(toAPI(priv->pageClient->page()), userAgentString.get());
2782 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
2784 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2785 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2787 if (!priv->userAgent) {
2788 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(priv->pageClient->page())));
2790 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
2791 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2792 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
2793 eina_stringshare_replace(&priv->userAgent, buffer.get());
2796 return priv->userAgent;
2798 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
2800 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2801 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2802 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2804 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2805 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
2807 WKPageAddCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get(), customHeaderValue.get());
2810 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2815 const char* ewk_view_video_data_url_get(const Ewk_View_Html5_Video_Data* videoData)
2817 #if ENABLE(TIZEN_MM_PLAYER)
2818 if (!videoData || !videoData->url)
2821 return toImpl(videoData->url)->string().utf8().data();
2827 const char* ewk_view_video_data_cookie_get(const Ewk_View_Html5_Video_Data* videoData)
2829 #if ENABLE(TIZEN_MM_PLAYER)
2830 if (!videoData || videoData->cookie)
2833 return toImpl(videoData->cookie)->string().utf8().data();
2839 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
2840 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
2842 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2843 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2845 priv->pageClient->setIsVisible(enable);
2850 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
2852 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
2854 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2855 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
2858 rect.origin.x = viewArea.x;
2859 rect.origin.y = viewArea.y;
2860 rect.size.width = viewArea.w;
2861 rect.size.height = viewArea.h;
2863 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(priv->pageClient->page()), rect, scaleFactor));
2864 if (!snapshot.get())
2867 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
2869 Evas_Object* screenshotImage = evas_object_image_add(canvas);
2870 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
2871 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
2872 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
2873 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
2875 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
2877 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)));
2878 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
2880 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
2881 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
2882 cairo_fill(cairo.get());
2884 evas_object_image_smooth_scale_set(screenshotImage, true);
2885 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
2886 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
2887 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
2888 evas_object_image_data_set(screenshotImage, pixels);
2890 return screenshotImage;
2893 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
2895 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
2896 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
2897 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, 0);
2899 return priv->pageClient->page()->startInspectorServer(port);
2901 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
2906 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
2908 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
2909 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
2910 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
2912 return priv->pageClient->page()->stopInspectorServer();
2914 LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
2919 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
2921 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2922 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
2924 WKPageScrollBy(toAPI(priv->pageClient->page()), toAPI(IntSize(deltaX, deltaY)));
2927 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
2933 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2934 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2936 IntPoint scrollPosition = priv->pageClient->scrollPosition();
2938 *x = scrollPosition.x();
2940 *y = scrollPosition.y();
2945 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
2947 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2948 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2950 priv->pageClient->page()->scrollMainFrameTo(IntPoint(x, y));
2954 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
2960 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2961 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2963 IntSize contentsSize = priv->pageClient->page()->contentsSize();
2964 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2965 contentsSize.scale(priv->pageClient->scaleFactor());
2968 if (width && contentsSize.width() > smartData->view.w)
2969 *width = contentsSize.width() - smartData->view.w;
2970 if (height && contentsSize.height() > smartData->view.h)
2971 *height = contentsSize.height() - smartData->view.h;
2975 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
2977 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2978 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2979 if (!priv->alertContext || !priv->alertContext->javascriptAlertCallback)
2981 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->alertContext->ewkView == ewkView, false);
2983 int length = WKStringGetMaximumUTF8CStringSize(alertText);
2984 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
2985 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
2986 return priv->alertContext->javascriptAlertCallback(priv->alertContext->ewkView, alertTextBuffer.get(), priv->alertContext->userData) == EINA_TRUE;
2989 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
2991 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2992 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
2993 if (!priv->confirmContext || !priv->confirmContext->javascriptConfirmCallback)
2995 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->confirmContext->ewkView == ewkView, false);
2997 int length = WKStringGetMaximumUTF8CStringSize(message);
2998 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
2999 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3000 return priv->confirmContext->javascriptConfirmCallback(priv->confirmContext->ewkView, messageBuffer.get(), priv->confirmContext->userData) == EINA_TRUE;
3003 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
3005 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3006 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3007 if (!priv->promptContext || !priv->promptContext->javascriptPromptCallback)
3009 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->promptContext->ewkView == ewkView, false);
3011 int length = WKStringGetMaximumUTF8CStringSize(message);
3012 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3013 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3014 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
3015 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
3016 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
3017 return priv->promptContext->javascriptPromptCallback(priv->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), priv->promptContext->userData) == EINA_TRUE;
3020 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
3022 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3023 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3024 if (!priv->openpanelContext || !priv->openpanelContext->openPanelCallback)
3027 EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->openpanelContext->ewkView == ewkView, false);
3029 priv->openPanelListener = listener;
3031 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
3032 Eina_List* acceptedMimeTypes = 0;
3033 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
3034 size_t len = WKArrayGetSize(array.get());
3035 for (size_t i = 0; i < len; i++) {
3036 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
3037 if (WKGetTypeID(item) != WKStringGetTypeID())
3039 WKStringRef mime = static_cast<WKStringRef>(item);
3040 int length = WKStringGetMaximumUTF8CStringSize(mime);
3041 char* buffer = new char[length];
3042 WKStringGetUTF8CString(mime, buffer, length);
3043 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
3045 const char* capture = 0;
3046 #if ENABLE(MEDIA_CAPTURE)
3047 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
3048 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
3050 bool result = priv->openpanelContext->openPanelCallback(priv->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
3051 if (!acceptedMimeTypes)
3056 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
3057 delete[] (char*)data;
3058 eina_list_free(acceptedMimeTypes);
3062 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
3064 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3065 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3067 if (!priv->alertContext)
3068 priv->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3069 priv->alertContext->javascriptAlertCallback = callback;
3070 priv->alertContext->ewkView = ewkView;
3071 priv->alertContext->userData = userData;
3074 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
3076 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3077 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3079 WKPageReplyJavaScriptAlert(toAPI(ewk_view_page_get(ewkView)));
3082 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
3084 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3085 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3087 if (!priv->confirmContext)
3088 priv->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3089 priv->confirmContext->javascriptConfirmCallback = callback;
3090 priv->confirmContext->ewkView = ewkView;
3091 priv->confirmContext->userData = userData;
3094 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
3096 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3097 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3099 WKPageReplyJavaScriptConfirm(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
3102 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
3104 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3105 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3107 if (!priv->promptContext)
3108 priv->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3109 priv->promptContext->javascriptPromptCallback = callback;
3110 priv->promptContext->ewkView = ewkView;
3111 priv->promptContext->userData = userData;
3114 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
3116 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3117 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3119 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
3120 WKPageReplyJavaScriptPrompt(toAPI(ewk_view_page_get(ewkView)), result ? resultString.get() : 0);
3123 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
3125 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3126 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3128 if (!priv->openpanelContext)
3129 priv->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3131 priv->openpanelContext->openPanelCallback = callback;
3132 priv->openpanelContext->ewkView = ewkView;
3133 priv->openpanelContext->userData = userData;
3136 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
3138 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3139 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3141 if (!priv->openPanelListener)
3144 unsigned int size = eina_list_count(fileUrls);
3145 if ((result == EINA_FALSE) || (size == 0)) {
3146 WKOpenPanelResultListenerCancel(priv->openPanelListener);
3147 priv->openPanelListener = 0;
3151 WKTypeRef* items = new WKTypeRef[size];
3155 EINA_LIST_FOREACH(fileUrls, list, data)
3156 items[i++] = WKURLCreateWithUTF8CString((char*)data);
3157 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
3158 WKOpenPanelResultListenerChooseFiles(priv->openPanelListener, filesArray.get());
3159 priv->openPanelListener = 0;
3161 eina_list_free(fileUrls);
3164 static void getRssItemsCallback(const Eina_List* rss_items, WKErrorRef, void* context)
3166 EINA_SAFETY_ON_NULL_RETURN(context);
3168 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3170 ASSERT(callbackContext->rssItemsGetCallback);
3171 callbackContext->rssItemsGetCallback(callbackContext->ewkView, rss_items, callbackContext->userData);
3173 delete callbackContext;
3176 Eina_Bool ewk_view_rss_items_get(Evas_Object* ewkView, Ewk_View_Rss_Items_Get_Callback callback, void* user_data)
3178 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
3179 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
3180 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3182 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3183 context->rssItemsGetCallback = callback;
3184 context->ewkView = ewkView;
3185 context->userData = user_data;
3187 WKPageGetRssItems(toAPI(priv->pageClient->page()), context, getRssItemsCallback);
3192 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3193 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
3195 EINA_SAFETY_ON_NULL_RETURN(capable);
3196 EINA_SAFETY_ON_NULL_RETURN(context);
3198 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3200 ASSERT(webAppContext->webAppCapableCallback);
3203 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
3205 webAppContext->webAppCapableCallback(0, webAppContext->userData);
3207 delete webAppContext;
3210 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
3212 EINA_SAFETY_ON_NULL_RETURN(iconURL);
3213 EINA_SAFETY_ON_NULL_RETURN(context);
3215 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3217 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3218 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3220 ASSERT(webAppContext->webAppIconURLCallback);
3223 eina_stringshare_replace(&priv->webAppIconURL, toImpl(iconURL)->string().utf8().data());
3224 webAppContext->webAppIconURLCallback(priv->webAppIconURL, webAppContext->userData);
3226 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
3228 delete webAppContext;
3232 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
3234 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3235 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3236 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3237 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3239 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3240 context->webAppCapableCallback = callback;
3241 context->ewkView = ewkView;
3242 context->userData = userData;
3244 WKPageGetWebAppCapable(toAPI(priv->pageClient->page()), context, didGetWebAppCapable);
3252 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
3254 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3255 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3256 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3257 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3259 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3260 context->webAppIconURLCallback = callback;
3261 context->ewkView = ewkView;
3262 context->userData = userData;
3264 WKPageGetWebAppIconURL(toAPI(priv->pageClient->page()), context, didGetWebAppIconURL);
3272 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
3274 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3275 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3276 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
3278 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
3279 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
3280 WKPageExecuteCommandWithArgument(toAPI(priv->pageClient->page()), commandString.get(), valueString.get());
3285 Eina_Bool ewk_view_string_find(Evas_Object* ewkView, const char* string, EwkFindOptions options, unsigned maxMatchCount, Ewk_View_String_Find_Callback callback, void* userData)
3287 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3288 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3290 EINA_SAFETY_ON_NULL_RETURN_VAL(string, false);
3291 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3293 priv->findClientInfo.callback = callback;
3294 priv->findClientInfo.userData = userData;
3296 WKRetainPtr<WKStringRef> findString(AdoptWK, WKStringCreateWithUTF8CString(string));
3298 WKPageFindString(toAPI(priv->pageClient->page()), findString.get(), options, maxMatchCount);
3303 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
3310 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3311 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3313 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3316 *width = contentsSize.width();
3318 *height = contentsSize.height();
3323 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, const char* fileName)
3325 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3326 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3327 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3328 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3330 IntSize contentsSize = priv->pageClient->page()->contentsSize();
3331 WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3339 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
3341 EINA_SAFETY_ON_NULL_RETURN(context);
3342 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3344 if (!callbackContext->scriptExecuteCallback) {
3345 delete callbackContext;
3349 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
3352 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
3353 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
3354 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
3355 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3356 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
3357 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3359 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
3361 delete callbackContext;
3364 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
3366 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3367 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3368 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
3369 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3371 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3372 context->scriptExecuteCallback = callback;
3373 context->ewkView = ewkView;
3374 context->userData = user_data;
3375 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
3376 WKPageRunJavaScriptInMainFrame(toAPI(priv->pageClient->page()), scriptString.get(), context, runJavaScriptCallback);
3381 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
3383 #if ENABLE(TIZEN_WEBKIT2_THEME_SET)
3384 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3385 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3386 if (!eina_stringshare_replace(&priv->theme, path))
3389 priv->pageClient->page()->setThemePath(path);
3393 const char* ewk_view_theme_get(const Evas_Object* ewkView)
3395 #if ENABLE(TIZEN_WEBKIT2_THEME_SET)
3396 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3397 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3404 void ewkViewDidFindString(Evas_Object* ewkView, WKStringRef string, unsigned maxMatchCount)
3406 EINA_SAFETY_ON_NULL_RETURN(string);
3408 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3409 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3411 int length = WKStringGetMaximumUTF8CStringSize(string);
3412 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3413 WKStringGetUTF8CString(string, buffer.get(), length);
3415 if (priv->findClientInfo.callback)
3416 priv->findClientInfo.callback(ewkView, buffer.get(), maxMatchCount, priv->findClientInfo.userData);
3419 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3420 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
3422 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
3425 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
3427 storageContext->webStorageQuotaCallback(0, storageContext->userData);
3429 delete storageContext;
3433 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
3435 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3436 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3437 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
3439 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3440 context->webStorageQuotaCallback = resultCallback;
3441 context->userData = userData;
3443 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
3444 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
3452 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
3454 #if ENABLE(TIZEN_WEB_STORAGE)
3455 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3457 WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
3458 WKPageSetWebStorageQuota(pageRef, quota);
3466 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
3468 EINA_SAFETY_ON_NULL_RETURN(context);
3469 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3471 ASSERT(callbackContext->plainTextGetCallback);
3474 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
3475 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3476 WKStringGetUTF8CString(plain_text, buffer.get(), length);
3478 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3480 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
3482 delete callbackContext;
3485 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
3487 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3488 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3489 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3491 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3492 context->plainTextGetCallback = callback;
3493 context->ewkView = ewkView;
3494 context->userData = user_data;
3495 WKPageGetContentsAsString(toAPI(priv->pageClient->page()), context, getContentsAsStringCallback);
3500 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
3502 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
3503 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3504 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3509 evas_object_geometry_get(ewkView, &viewPositionX, &viewPositionY, 0, 0);
3511 IntPoint pointForHitTest(x, y);
3512 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3513 float revertScale = 1 / priv->pageClient->scaleFactor();
3514 IntPoint scrollPosition = priv->pageClient->scrollPosition();
3516 pointForHitTest.setX((scrollPosition.x() + (x - viewPositionX)) * revertScale);
3517 pointForHitTest.setY((scrollPosition.y() + (y - viewPositionY)) * revertScale);
3519 pointForHitTest.setX(x - viewPositionX);
3520 pointForHitTest.setY(y - viewPositionY);
3523 WebHitTestResult::Data hitTestResultData = priv->pageClient->page()->hitTestResultAtPoint(pointForHitTest, hitTestMode);
3524 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
3532 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
3534 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3536 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(ewk_view_page_get(ewkView))));
3539 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3541 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3542 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3544 WKPageRecordingSurfaceSetEnable(toAPI(priv->pageClient->page()), enable);
3549 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
3551 #if ENABLE(TIZEN_NOTIFICATION)
3552 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3553 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3554 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->context, false);
3556 if (!eina_list_count(ewkNotifications))
3559 Eina_List* listIterator = 0;
3561 Vector<WKTypeRef> ids;
3562 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
3563 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
3564 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
3566 priv->notifications = eina_list_remove(priv->notifications, notification);
3569 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
3570 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(ewk_context_WKContext_get(priv->context));
3571 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
3572 ewkNotificationDeleteNotificationList(ewkNotifications);
3580 #if ENABLE(TIZEN_WEBKIT2_POPUP)
3581 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)
3583 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3584 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3585 EINA_SAFETY_ON_NULL_RETURN(smartData->api->popup_menu_show);
3587 ASSERT(popupMenenu);
3589 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3590 if (priv->popupMenuProxy)
3591 ewk_view_popup_menu_close(ewkView);
3592 priv->popupMenuProxy = popupMenu;
3594 Eina_List* popupItems = 0;
3595 for (size_t i = 0; i < items.size(); ++i) {
3596 Ewk_Popup_Menu_Item* item = new Ewk_Popup_Menu_Item;
3597 if (items[i].m_type == WebPopupItem::Separator) {
3598 item->type = EWK_POPUP_MENU_SEPARATOR;
3601 item->type = EWK_POPUP_MENU_ITEM;
3602 item->text = eina_stringshare_add(items[i].m_text.utf8().data());
3605 popupItems = eina_list_append(popupItems, item);
3607 priv->popupMenuItems = popupItems;
3609 smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, popupItems, selectedIndex);
3612 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
3614 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3615 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3616 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
3618 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
3619 if (smartData->api->popup_menu_hide)
3620 smartData->api->popup_menu_hide(smartData);
3623 EINA_LIST_FREE(priv->popupMenuItems, itemv) {
3624 Ewk_Popup_Menu_Item* item = static_cast<Ewk_Popup_Menu_Item*>(itemv);
3625 eina_stringshare_del(item->text);
3629 priv->popupMenuProxy = 0;
3632 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
3634 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3635 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3636 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
3638 if (selectedIndex > eina_list_count(priv->popupMenuItems))
3641 priv->popupMenuProxy->valueChanged(selectedIndex);
3646 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
3648 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
3649 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3650 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3652 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
3655 if (priv->orientation == orientation)
3658 priv->orientation = orientation;
3660 priv->pageClient->page()->sendOrientationChangeEvent(orientation);
3664 void ewkViewFrameRendered(Evas_Object* ewkView)
3666 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
3669 const char* ewk_view_encoding_custom_get(const Evas_Object* ewkView)
3671 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3672 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3674 WKRetainPtr<WKStringRef> encodingString(AdoptWK, WKPageCopyCustomTextEncodingName(toAPI(priv->pageClient->page())));
3675 eina_stringshare_replace(&priv->encoding, toImpl(encodingString.get())->string().utf8().data());
3677 return priv->encoding;
3680 void ewk_view_encoding_custom_set(Evas_Object* ewkView, const char* encoding)
3682 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3683 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3685 WKRetainPtr<WKStringRef> encodingString(AdoptWK, WKStringCreateWithUTF8CString(encoding));
3686 WKPageSetCustomTextEncodingName(toAPI(priv->pageClient->page()), encodingString.get());
3689 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3690 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3692 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3693 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3695 priv->pageClient->setIsTextSelectionEnable(enable);
3699 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
3701 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3702 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
3704 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient->page()->focusedFrame(), false);
3706 IntRect leftSelectionRect;
3707 IntRect rightSelectionRect;
3708 if (!priv->pageClient->page()->focusedFrame()->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
3723 evas_object_geometry_get(ewkView, &viewPositionX, &viewPositionY, 0, 0);
3725 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3726 float scaleFactor = priv->pageClient->scaleFactor();
3727 IntPoint scrollPosition = priv->pageClient->scrollPosition();
3729 leftSelectionRect.scale(scaleFactor);
3730 leftSelectionRect.move(-scrollPosition.x(), -scrollPosition.y());
3732 leftSelectionRect.move(viewPositionX, viewPositionY);
3734 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3735 rightSelectionRect.scale(scaleFactor);
3736 rightSelectionRect.move(-scrollPosition.x(), -scrollPosition.y());
3738 rightSelectionRect.move(viewPositionX, viewPositionY);
3740 leftRect->x = leftSelectionRect.x();
3741 leftRect->y = leftSelectionRect.y();
3742 leftRect->w = leftSelectionRect.width();
3743 leftRect->h = leftSelectionRect.height();
3745 rightRect->x = rightSelectionRect.x();
3746 rightRect->y = rightSelectionRect.y();
3747 rightRect->w = rightSelectionRect.width();
3748 rightRect->h = rightSelectionRect.height();
3753 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
3755 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3756 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3758 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient->page()->focusedFrame(), 0);
3760 const CString selectedString = priv->pageClient->page()->focusedFrame()->getSelectionText().utf8();
3761 eina_stringshare_replace(&priv->selectedText, selectedString.data());
3763 return priv->selectedText;
3765 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3767 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3768 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
3770 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3771 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3772 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
3774 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
3777 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
3778 void ewkViewColorChooserRequest(Evas_Object* ewkView, WebColorChooserProxyEfl* colorChooser, const String& inputValue)
3780 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3781 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3783 priv->colorChooser = colorChooser;
3785 ewkViewInputPickerRequest(ewkView, EWK_INPUT_TYPE_COLOR, inputValue);
3787 #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
3790 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
3792 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3793 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3794 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3796 priv->pageClient->page()->setFocusedInputElementValue(String(value));
3797 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3800 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
3802 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3803 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3804 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
3806 eina_stringshare_replace(&priv->inputValue, priv->pageClient->page()->getFocusedInputElementValue().utf8().data());
3807 return priv->inputValue;
3810 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3813 void ewk_view_color_chooser_color_set(Evas_Object* ewkView, const char* color)
3815 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
3816 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3817 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3819 if (priv->colorChooser)
3820 priv->colorChooser->setSelectedColor(Color(color));
3821 #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
3824 void ewk_view_color_chooser_close(Evas_Object* ewkView)
3826 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
3827 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3828 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3830 if (priv->colorChooser)
3831 priv->colorChooser->endChooser();
3833 priv->colorChooser = 0;
3834 #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
3837 #if ENABLE(TIZEN_DATALIST_ELEMENT)
3838 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
3840 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3841 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3842 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3843 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
3846 ewkViewDataListHideRequest(ewkView, inputType);
3848 for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
3850 priv->dataList = eina_list_append(priv->dataList, eina_stringshare_add(value.utf8().data()));
3853 smartData->api->data_list_show(smartData, inputType, priv->dataList);
3856 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
3858 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3859 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3860 EINA_SAFETY_ON_NULL_RETURN(priv->dataList);
3861 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3862 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
3864 _ewk_view_data_list_del(priv->dataList);
3867 smartData->api->data_list_hide(smartData, inputType);
3871 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
3873 #if ENABLE(TIZEN_DATALIST_ELEMENT)
3874 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3875 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
3877 _ewk_view_data_list_del(priv->dataList);
3880 ewk_view_focused_input_element_value_set(ewkView, value);
3884 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
3886 #if ENABLE(TIZEN_GESTURE)
3887 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
3888 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
3889 return priv->holdHorizontalPanning;
3895 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
3897 #if ENABLE(TIZEN_GESTURE)
3898 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
3899 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
3900 priv->holdHorizontalPanning = hold;
3904 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
3906 #if ENABLE(TIZEN_GESTURE)
3907 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
3908 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
3909 return priv->holdVerticalPanning;
3915 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
3917 #if ENABLE(TIZEN_GESTURE)
3918 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
3919 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
3920 priv->holdVerticalPanning = hold;
3924 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
3926 #if ENABLE(TIZEN_GESTURE)
3927 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
3928 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
3930 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
3932 ewkViewHideFocusRing(ewkView);
3933 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
3935 if (priv->areMouseEventsEnabled)
3938 // We have to check TouchStart, TouchMove and TouchEnd with handled.
3939 // The Pan and Flick will be enabled if Touch Start was not handled,
3940 // and Touch Move was not handled or did not occur.
3941 // Tap will be enabled if Touch Start and End was not handled
3942 // and Touch Move did not occur.
3943 // The gestures are disabled as a default.
3944 // o: handled, x: not handled
3945 // ------------------------------------------------------------
3946 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
3947 // ------------------------------------------------------------
3948 // o | o or x | o or x || disable | disable
3949 // x | o | o or x || disable | disable
3950 // x | x | o or x || disable | enable
3951 // x |not occured | x || enable | enable
3952 // ------------------------------------------------------------
3953 if (type == WebEvent::TouchStart)
3954 priv->gestureRecognizer->setEnableGesture(!wasHandled);
3955 else if (type == WebEvent::TouchMove)
3956 priv->gestureRecognizer->setEnableMoving(!wasHandled);
3957 else if (type == WebEvent::TouchEnd && !priv->exceedTouchMoveThreshold && !wasHandled) {
3958 priv->gestureRecognizer->setEnableMoving(!wasHandled);
3959 priv->gestureRecognizer->setEnableTap(!wasHandled);
3964 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
3965 void ewkViewDidGetTextStyleStateForSelection(Evas_Object* ewkView, int underlineState, int italicState, int boldState)
3967 Ewk_Text_Style* textStyle = ewkTextStyleCreate(underlineState, italicState, boldState);
3968 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
3969 ewkTextStyleDelete(textStyle);
3973 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
3974 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
3976 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3977 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
3979 if (!smartData->api->orientation_lock)
3982 return smartData->api->orientation_lock(smartData, willLockOrientation);
3985 void ewk_view_orientation_unlock(Evas_Object* ewkView)
3987 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3988 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3990 if (!smartData->api->orientation_unlock)
3993 smartData->api->orientation_unlock(smartData);
3997 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
3999 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4000 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4001 EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
4003 priv->orientationLock.callback = func;
4004 priv->orientationLock.data = data;
4008 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4009 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
4011 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
4012 if (priv->orientationLock.callback) {
4013 return priv->orientationLock.callback(sd->self, true, orientations, priv->orientationLock.data);
4018 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
4020 EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
4022 priv->orientationLock.callback(sd->self, false, 0, priv->orientationLock.data);
4026 #endif // #if OS(TIZEN)