2 Copyright (C) 2011 Samsung Electronics
3 Copyright (C) 2012 Intel Corporation. All rights reserved.
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
24 #include "EwkViewImpl.h"
25 #include "FindClientEfl.h"
26 #include "FormClientEfl.h"
27 #include "LayerTreeCoordinatorProxy.h"
28 #include "InputMethodContextEfl.h"
29 #include "NativeWebKeyboardEvent.h"
30 #include "NativeWebMouseEvent.h"
31 #include "NativeWebWheelEvent.h"
32 #include "PageClientImpl.h"
33 #include "PageLoadClientEfl.h"
34 #include "PagePolicyClientEfl.h"
35 #include "PageUIClientEfl.h"
36 #include "ResourceLoadClientEfl.h"
37 #include "WKAPICast.h"
38 #include "WKEinaSharedString.h"
39 #include "WKFindOptions.h"
40 #include "WKRetainPtr.h"
42 #include "WebContext.h"
44 #include "WebPageGroup.h"
45 #include "WebPopupItem.h"
46 #include "WebPopupMenuProxyEfl.h"
47 #include "WebPreferences.h"
48 #include "ewk_back_forward_list_private.h"
49 #include "ewk_context.h"
50 #include "ewk_context_private.h"
51 #include "ewk_favicon_database_private.h"
52 #include "ewk_intent_private.h"
53 #include "ewk_popup_menu_item_private.h"
54 #include "ewk_private.h"
55 #include "ewk_settings_private.h"
56 #include "ewk_view_private.h"
57 #include <Ecore_Evas.h>
59 #include <WebKit2/WKPageGroup.h>
60 #include <wtf/text/CString.h>
62 #if ENABLE(FULLSCREEN_API)
63 #include "WebFullScreenManagerProxy.h"
66 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
73 #include "DrawingAreaProxyImpl.h"
76 #include "WKDownload.h"
78 #include "WKGeolocationPermissionRequest.h"
79 #include "WKImageCairo.h"
80 #include "WKOpenPanelParameters.h"
81 #include "WKOpenPanelResultListener.h"
83 #include "WKPageGroup.h"
85 #include "WKPageTizen.h"
86 #include "WKPreferences.h"
87 #include "WKSerializedScriptValue.h"
89 #include "WKURLRequest.h"
90 #include "ewk_context_menu_private.h"
91 #include "ewk_error.h"
92 #include "ewk_error_private.h"
93 #include "ewk_history_private.h"
94 #include "ewk_popup_menu_item.h"
95 #include "ewk_popup_menu_item_private.h"
96 #include "ewk_view_context_menu_client.h"
97 #include "ewk_view_icondatabase_client.h"
98 #include "ewk_view_tizen_client.h"
100 #include <Elementary.h>
101 #include <WebCore/EflScreenUtilities.h>
102 #include <WebCore/NotImplemented.h>
105 #if ENABLE(TIZEN_ICON_DATABASE)
106 #include "WKContextPrivate.h"
109 #if ENABLE(TIZEN_GEOLOCATION)
110 #include "ewk_geolocation_private.h"
111 #include "ewk_security_origin.h"
112 #include "ewk_view_geolocation_provider.h"
115 #if ENABLE(TOUCH_EVENTS)
116 #include "NativeWebTouchEvent.h"
117 #include "WebEvent.h"
120 #if ENABLE(TIZEN_ISF_PORT)
121 #include <Ecore_IMF.h>
124 #if ENABLE(TIZEN_NOTIFICATIONS)
126 #include "WKNotificationManager.h"
127 #include "WKNumber.h"
128 #include "ewk_notification_private.h"
129 #include "ewk_view_notification_provider.h"
132 #if ENABLE(TIZEN_MEDIA_STREAM)
133 #include "WKUserMediaPermissionRequest.h"
134 #include "ewk_user_media_private.h"
137 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
138 #include "WebPageGroup.h"
139 #include "WebPreferences.h"
142 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
143 #include "ewk_hit_test_private.h"
146 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
147 #include "ewk_text_style.h"
150 #if ENABLE(TIZEN_SCREEN_READER)
151 #include "ScreenReaderProxy.h"
154 #if ENABLE(TIZEN_CSP)
155 #include <WebCore/ContentSecurityPolicy.h>
158 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
159 #include "WKDictionary.h"
160 #include "ewk_web_application_icon_data_private.h"
163 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
164 #include "AutoFillPopup.h"
166 #endif // #if OS(TIZEN)
168 using namespace WebKit;
169 using namespace WebCore;
171 static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
173 #define EWK_VIEW_TYPE_CHECK(ewkView, result) \
174 bool result = true; \
177 EINA_LOG_CRIT("null is not a ewk_view"); \
181 const char* _tmp_otype = evas_object_type_get(ewkView); \
182 const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
183 if (EINA_UNLIKELY(!_tmp_s)) { \
185 ("%p (%s) is not a smart object!", \
186 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
190 const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
191 if (EINA_UNLIKELY(!_tmp_sc)) { \
193 ("%p (%s) is not a smart object!", \
194 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
198 else if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \
200 ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
201 ewkView, _tmp_otype ? _tmp_otype : "(null)", \
202 EWK_VIEW_TYPE_STR, _tmp_sc->data); \
207 #define EWK_VIEW_SD_GET(ewkView, smartData) \
208 EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \
209 Ewk_View_Smart_Data* smartData = 0; \
211 smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView)
213 #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \
214 EWK_VIEW_SD_GET(ewkView, smartData); \
217 EINA_LOG_CRIT("no smart data for object %p (%s)", \
218 ewkView, evas_object_type_get(ewkView)); \
219 return __VA_ARGS__; \
224 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object*, const char* alertText, void* userData);
225 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object*, const char* message, void* userData);
226 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object*, const char* message, const char* defaultValue, void* userData);
227 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
228 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object*, const char* message, void* userData);
230 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);
232 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
233 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);
234 #if ENABLE(TIZEN_MULTIPLE_SELECT)
235 Eina_Bool _ewk_view_multiple_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items);
237 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data*);
238 Eina_Bool _ewk_view_popup_menu_update(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, Eina_List*, int);
240 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
241 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations);
242 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd);
245 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
246 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data*, Ewk_Input_Type, const char* inputValue);
249 #if ENABLE(TIZEN_DATALIST_ELEMENT)
250 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data*, Ewk_Input_Type, Eina_List*);
251 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data*, Ewk_Input_Type);
254 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
255 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data*, int, int, int, int);
256 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data*);
258 #endif // #if OS(TIZEN)
260 static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
262 if (smartData->changed.any)
264 smartData->changed.any = true;
265 evas_object_smart_changed(smartData->self);
268 #if !ENABLE(TIZEN_ICON_DATABASE)
269 static void _ewk_view_on_favicon_changed(const char* pageURL, void* eventInfo)
271 Evas_Object* ewkView = static_cast<Evas_Object*>(eventInfo);
272 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
273 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
275 const char* viewURL = ewk_view_url_get(ewkView);
276 if (!viewURL || strcasecmp(viewURL, pageURL))
279 impl->informIconChange();
283 // Default Event Handling.
284 static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
286 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
290 impl->pageClient->setViewFocused(true);
291 #endif // #if OS(TIZEN)
292 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
293 #if ENABLE(TIZEN_ISF_PORT)
294 if (impl->inputMethodContext())
295 impl->inputMethodContext()->onFocusIn();
300 static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
302 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
306 #if ENABLE(TIZEN_ISF_PORT)
307 // Keypad should be hidden rapidly when moving focus on elementary
308 // because Ecore-ime doesn't support it.
309 if (impl->inputMethodContext())
310 impl->inputMethodContext()->onFocusOut();
313 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
314 if (impl->pageClient->isTextSelectionMode() && ewk_settings_clear_text_selection_automatically_get(impl->settings()))
315 impl->pageClient->setIsTextSelectionMode(false);
318 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
319 if (impl->pageClient->isContextMenuVisible())
320 impl->pageProxy->hideContextMenu();
323 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
324 if (impl->pageClient->isClipboardWindowOpened())
325 impl->pageClient->closeClipboardWindow();
328 #if ENABLE(TIZEN_DRAG_SUPPORT)
329 if (impl->pageClient->isDragMode())
330 impl->pageClient->setDragMode(false);
333 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
334 if (smartData->api->formdata_candidate_is_showing(smartData))
335 smartData->api->formdata_candidate_hide(smartData);
338 impl->pageClient->setViewFocused(false);
339 #endif // #if OS(TIZEN)
340 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
344 static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
346 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
348 impl->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
352 static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
354 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
356 impl->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
360 static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
362 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
364 impl->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
366 InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
367 if (inputMethodContext)
368 inputMethodContext->handleMouseUpEvent(upEvent);
373 static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
375 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
377 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
378 impl->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
382 static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
384 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
386 bool isFiltered = false;
387 InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
388 if (inputMethodContext)
389 inputMethodContext->handleKeyDownEvent(downEvent, &isFiltered);
391 impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, isFiltered));
395 static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
397 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
399 impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
404 static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
406 #if ENABLE(TIZEN_GESTURE)
407 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
409 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
410 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
414 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
415 FocusRing* focusRing = impl->focusRing();
417 if (event->type == EWK_GESTURE_TAP && event->count == 1) {
418 focusRing->requestToShow(IntPoint(event->position.x, event->position.y));
419 } else if (event->type == EWK_GESTURE_PAN) {
420 if (impl->exceedTouchMoveThreshold)
421 focusRing->requestToHide();
423 if (event->type != EWK_GESTURE_LONG_PRESS) {
424 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
425 if (!impl->pageClient->isContextMenuVisible())
427 focusRing->requestToHide();
433 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
434 if (smartData->api->formdata_candidate_is_showing(smartData))
435 smartData->api->formdata_candidate_hide(smartData);
438 switch (event->type) {
439 case EWK_GESTURE_TAP:
440 impl->gestureClient->startTap(IntPoint(event->position.x, event->position.y));
442 case EWK_GESTURE_LONG_PRESS: {
443 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
444 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
445 if (ewk_settings_text_selection_enabled_get(impl->settings()))
446 impl->pageClient->setIsTextSelectionMode(false);
449 IntPoint scenePoint(event->position.x, event->position.y);
450 IntPoint contentsPoint = impl->transformFromScene().mapPoint(scenePoint);
451 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(contentsPoint, WebHitTestResult::HitTestModeDefault | WebHitTestResult::HitTestModeSetFocus);
452 if (!hitTestResultData.absoluteMediaURL.isEmpty())
455 #if ENABLE(TIZEN_DRAG_SUPPORT)
456 // 1. Check to start dragging.
457 if (hitTestResultData.isDragSupport && !hitTestResultData.isContentEditable) {
458 impl->pageClient->setDragPoint(scenePoint);
459 if (impl->pageClient->isDragMode())
460 impl->pageClient->setDragMode(false);
462 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
464 focusRing->showWithContextMenu(scenePoint, hitTestResultData.focusedColor, hitTestResultData.focusedRects);
470 // 2. Check to show context menu.
471 if ((!hitTestResultData.absoluteImageURL.isEmpty() || !hitTestResultData.absoluteLinkURL.isEmpty())
472 && !hitTestResultData.isContentEditable) {
473 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
475 focusRing->showWithContextMenu(scenePoint, hitTestResultData.focusedColor, hitTestResultData.focusedRects);
480 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
481 // 3. Check for text selection.
482 if (ewk_settings_text_selection_enabled_get(impl->settings())) {
483 // Process gesture_end(EWK_GESTURE_TAP) to activate the editing if node under point is editable.
484 if (hitTestResultData.context & WebHitTestResult::HitTestResultContextEditable) {
485 if (smartData->api && smartData->api->gesture_end) {
486 Ewk_Event_Gesture tapEvent = {EWK_GESTURE_TAP, event->position, {0, 0}, 0, 1, ecore_time_get() * 1000};
487 smartData->api->gesture_end(smartData, &tapEvent);
491 if (impl->pageClient->textSelectionDown(scenePoint)) {
492 impl->gestureClient->setGestureEnabled(false);
493 impl->feedTouchEventsByType(EWK_TOUCH_CANCEL);
498 #endif // #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
500 case EWK_GESTURE_PAN:
501 impl->gestureClient->startPan(IntPoint(event->position.x, event->position.y));
503 case EWK_GESTURE_FLICK:
504 impl->gestureClient->startFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
506 case EWK_GESTURE_PINCH:
507 if (impl->pageClient->viewportConstraints().userScalable)
508 impl->gestureClient->startPinch(IntPoint(event->position.x, event->position.y), event->scale);
511 ASSERT_NOT_REACHED();
518 #endif // #if ENABLE(TIZEN_GESTURE)
521 static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
523 #if ENABLE(TIZEN_GESTURE)
524 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
526 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
527 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned()) {
528 impl->pageClient->initTextSelectionHandlesMouseDownedStatus();
533 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
534 FocusRing* focusRing = impl->focusRing();
536 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
537 if (!impl->pageClient->isContextMenuVisible() || impl->pageClient->isTextSelectionMode())
539 focusRing->requestToHide();
543 switch (event->type) {
544 case EWK_GESTURE_TAP:
545 if (event->count == 1) {
546 #if ENABLE(TIZEN_DRAG_SUPPORT)
547 if (impl->pageClient->isDragMode())
548 impl->pageClient->setDragMode(false);
550 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
551 if (impl->pageClient->isTextSelectionMode())
552 impl->pageClient->setIsTextSelectionMode(false);
555 #if ENABLE(TIZEN_ISF_PORT)
556 if (impl->inputMethodContext()->isIMEPostion(event->position.x, event->position.y))
560 impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
561 } else if (event->count == 2) {
562 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
564 focusRing->requestToHide(true);
566 impl->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
569 case EWK_GESTURE_LONG_PRESS:
570 // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
571 impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
573 case EWK_GESTURE_PAN:
574 impl->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
576 case EWK_GESTURE_FLICK:
577 impl->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
579 case EWK_GESTURE_PINCH:
580 impl->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
583 ASSERT_NOT_REACHED();
590 #endif // #if ENABLE(TIZEN_GESTURE)
593 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
595 #if ENABLE(TIZEN_GESTURE)
596 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
598 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
599 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
603 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
604 FocusRing* focusRing = impl->focusRing();
605 if (focusRing && !(event->type == EWK_GESTURE_PAN && !impl->exceedTouchMoveThreshold)) {
606 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
607 if (!impl->pageClient->isContextMenuVisible())
609 focusRing->requestToHide(true);
613 switch (event->type) {
614 case EWK_GESTURE_PAN:
615 impl->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
617 case EWK_GESTURE_TAP:
618 case EWK_GESTURE_LONG_PRESS:
619 case EWK_GESTURE_FLICK:
621 case EWK_GESTURE_PINCH:
622 if (impl->pageClient->viewportConstraints().userScalable)
623 impl->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
626 ASSERT_NOT_REACHED();
633 #endif // #if ENABLE(TIZEN_GESTURE)
635 #endif //#if OS(TIZEN)
638 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
640 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
641 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
642 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
643 smartData->api->focus_in(smartData);
646 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
648 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
649 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
650 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
651 smartData->api->focus_out(smartData);
654 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
656 Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
657 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
658 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
659 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
660 smartData->api->mouse_wheel(smartData, wheelEvent);
663 static void _ewk_view_on_key_down(void* data, Evas*, Evas_Object*, void* eventInfo)
665 Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
666 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
667 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
668 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
669 smartData->api->key_down(smartData, downEvent);
672 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
674 Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
675 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
676 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
677 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
678 smartData->api->key_up(smartData, upEvent);
681 static void _ewk_view_on_show(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
683 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
684 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
685 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
688 static void _ewk_view_on_hide(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
690 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
691 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
693 // This call may look wrong, but we really need to pass ViewIsVisible here.
694 // viewStateDidChange() itself is responsible for actually setting the visibility to Visible or Hidden
695 // depending on what WebPageProxy::isViewVisible() returns, this simply triggers the process.
696 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
701 #if ENABLE(TIZEN_FULLSCREEN_API)
702 Eina_Bool _ewk_view_smart_fullscreen_enter(Ewk_View_Smart_Data* smartData)
704 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
706 ewk_view_main_frame_scrollbar_visible_set(impl->view(), false);
707 evas_object_smart_callback_call(impl->view(), "fullscreen,enterfullscreen", 0);
711 Eina_Bool _ewk_view_smart_fullscreen_exit(Ewk_View_Smart_Data* smartData)
713 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
715 ewk_view_main_frame_scrollbar_visible_set(impl->view(), true);
716 evas_object_smart_callback_call(impl->view(), "fullscreen,exitfullscreen", 0);
721 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
722 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
724 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
726 return impl->pageClient->textSelectionDown(IntPoint(x, y));
729 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
731 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
733 IntPoint point(x, y);
734 impl->pageClient->textSelectionMove(point);
739 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
741 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
743 IntPoint point(x, y);
744 impl->pageClient->textSelectionUp(point, true);
750 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
751 Eina_Bool _ewk_view_smart_formdata_candidate_show(Ewk_View_Smart_Data* smartData, int x, int y, int w, int h)
753 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
755 impl->pageClient->showAutoFillPopup(IntRect(x, y, w, h));
760 Eina_Bool _ewk_view_smart_formdata_candidate_hide(Ewk_View_Smart_Data* smartData)
762 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
764 impl->pageClient->hideAutoFillPopup();
769 Eina_Bool _ewk_view_smart_formdata_candidate_update_data(Ewk_View_Smart_Data* smartData, Eina_List* dataList)
771 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
773 Vector<AutoFillPopupItem> formData;
776 EINA_LIST_FOREACH(dataList, list, data)
777 formData.append(AutoFillPopupItem(String::fromUTF8(static_cast<char*>(data)), candidateAutoFill));
779 impl->pageClient->updateAutoFillPopup(formData);
784 Eina_Bool _ewk_view_smart_formdata_candidate_is_showing(Ewk_View_Smart_Data* smartData)
786 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
788 return impl->pageClient->isShowingAutoFillPopup();
792 #if ENABLE(TIZEN_SCREEN_READER)
793 Eina_Bool _ewk_view_screen_reader_action_execute(Ewk_View_Smart_Data* smartData, void* actionInfo)
795 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
797 return ScreenReaderProxy::executeAction(impl, 0, static_cast<Elm_Access_Action_Info*>(actionInfo));
800 #endif // #if OS(TIZEN)
802 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
804 static void _ewk_view_impl_del(EwkViewImpl* impl)
806 #if !ENABLE(TIZEN_ICON_DATABASE)
807 /* Unregister icon change callback */
808 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
809 iconDatabase->unwatchChanges(_ewk_view_on_favicon_changed);
815 static void _ewk_view_smart_add(Evas_Object* ewkView)
817 const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
818 const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
819 const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
820 EWK_VIEW_SD_GET(ewkView, smartData);
823 smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
825 EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
828 evas_object_smart_data_set(ewkView, smartData);
831 smartData->self = ewkView;
832 smartData->api = api;
834 g_parentSmartClass.add(ewkView);
836 smartData->priv = new EwkViewImpl(ewkView);
837 if (!smartData->priv) {
838 EINA_LOG_CRIT("could not allocate EwkViewImpl");
839 evas_object_smart_data_set(ewkView, 0);
844 // Create evas_object_image to draw web contents.
845 smartData->image = evas_object_image_add(smartData->base.evas);
846 evas_object_image_alpha_set(smartData->image, false);
847 evas_object_image_filled_set(smartData->image, true);
848 evas_object_smart_member_add(smartData->image, ewkView);
851 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
852 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
853 const char *engine = ecore_evas_engine_name_get(ee);
854 if (engine && !strcmp(engine, "opengl_x11"))
855 evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
857 ewk_view_mouse_events_enabled_set(ewkView, false);
858 ewk_view_touch_events_enabled_set(ewkView, true);
860 // FIXME: This code should be removed if side effect occur.
861 // WebView does not have focus after url loading.
862 // If focus is set as true to webview,
863 // elementary steal webview's focus during mouse up event
864 // So, added code that events are not propagated to smart parent according to guide from EFL
865 evas_object_propagate_events_set(ewkView, false);
866 #endif // #if OS(TIZEN)
868 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
869 CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
870 CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
871 CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
872 CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
873 CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
874 CONNECT(EVAS_CALLBACK_SHOW, _ewk_view_on_show);
875 CONNECT(EVAS_CALLBACK_HIDE, _ewk_view_on_hide);
879 static void _ewk_view_smart_del(Evas_Object* ewkView)
881 EwkViewImpl::removeFromPageViewMap(ewkView);
882 EWK_VIEW_SD_GET(ewkView, smartData);
883 #if ENABLE(TIZEN_SCREEN_READER)
884 ScreenReaderProxy::screenReader().finalize(smartData->priv);
886 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
887 // Close color picker if it's opened.
888 if (smartData && smartData->priv && smartData->priv->inputPicker->isColorPickerShown())
889 ewk_view_color_picker_color_set(ewkView, 0, 0, 0, 0);
891 if (smartData && smartData->priv)
892 _ewk_view_impl_del(smartData->priv);
894 g_parentSmartClass.del(ewkView);
897 static Eina_Bool _ewk_view_composite(void* data);
899 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
901 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
903 evas_object_resize(smartData->image, width, height);
904 evas_object_image_size_set(smartData->image, width, height);
905 evas_object_image_fill_set(smartData->image, 0, 0, width, height);
907 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
908 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
909 evas_object_image_native_surface_set(smartData->image, 0);
911 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
912 if (impl->pageClient->isVisible()) {
913 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
914 impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee));
916 impl->pageClient->setDeferUpdateViewportSize(true);
918 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
919 impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee));
922 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
923 if (!ewk_view_is_opengl_backend(ewkView))
924 _ewk_view_composite(smartData);
925 else // OpenGL backend
927 impl->pageClient->displayViewport();
929 #endif // #if OS(TIZEN)
931 smartData->changed.size = true;
932 _ewk_view_smart_changed(smartData);
935 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
937 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
939 smartData->changed.position = true;
940 _ewk_view_smart_changed(smartData);
943 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
945 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
946 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
948 Evas_Coord x, y, width, height;
950 smartData->changed.any = false;
952 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
954 if (smartData->changed.size) {
956 #if USE(COORDINATED_GRAPHICS)
957 impl->pageViewportControllerClient->updateViewportSize(IntSize(width, height));
959 #if USE(ACCELERATED_COMPOSITING)
960 needsNewSurface = impl->evasGlSurface;
963 if (impl->pageProxy->drawingArea())
964 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
966 #if USE(ACCELERATED_COMPOSITING)
967 if (!impl->evasGlSurface)
969 evas_gl_surface_destroy(impl->evasGl, impl->evasGlSurface);
970 impl->evasGlSurface = 0;
971 ewk_view_create_gl_surface(ewkView, IntSize(width, height));
972 ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
974 #endif // #if !OS(TIZEN)
976 smartData->view.w = width;
977 smartData->view.h = height;
978 smartData->changed.size = false;
981 if (impl->pageClient) {
982 if (DrawingAreaProxy* drawingArea = impl->pageProxy->drawingArea()) {
983 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
984 if (impl->pageProxy->isViewVisible())
985 drawingArea->setSize(IntSize(width, height), IntSize());
987 drawingArea->setSize(IntSize(width, height), IntSize());
989 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
990 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
991 int newAngle = ecore_evas_rotation_get(ee);
992 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
993 if (impl->pageClient->deferUpdateViewportSize()) {
994 impl->pageClient->updateViewportSize(IntSize(width, height), newAngle);
997 impl->pageClient->updateVisibleContentRectSize(IntSize(width, height));
998 if (ewk_view_is_opengl_backend(ewkView))
999 impl->pageClient->displayViewport();
1002 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1003 impl->pageClient->frameRectChanged();
1006 #endif // #if OS(TIZEN)
1009 if (smartData->changed.position) {
1010 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1011 IntSize diff(x - smartData->view.x, y - smartData->view.y);
1014 evas_object_move(smartData->image, x, y);
1015 smartData->view.x = x;
1016 smartData->view.y = y;
1017 smartData->changed.position = false;
1019 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1020 impl->pageClient->frameRectChanged();
1022 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1023 impl->pageClient->updateTextSelectionHandlesAndContextMenu(true);
1025 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1026 if (impl->focusRing())
1027 impl->focusRing()->moveBy(diff);
1029 #endif // #if OS(TIZEN)
1032 if (impl->popupPicker)
1033 ewk_popup_picker_resize(impl->popupPicker);
1034 #endif // #if OS(TIZEN)
1037 static void _ewk_view_smart_show(Evas_Object* ewkView)
1039 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1040 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1042 if (evas_object_clipees_get(smartData->base.clipper))
1043 evas_object_show(smartData->base.clipper);
1044 evas_object_show(smartData->image);
1046 #if ENABLE(TIZEN_SCREEN_READER)
1047 ScreenReaderProxy::screenReader().initialize(impl);
1051 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1053 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1055 evas_object_hide(smartData->base.clipper);
1056 evas_object_hide(smartData->image);
1057 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1058 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1059 if (impl->pageClient->isTextSelectionMode())
1060 impl->pageClient->setIsTextSelectionMode(false);
1064 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1066 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1067 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1071 else if (alpha > 255)
1074 #define CHECK_COLOR(color, alpha) \
1077 else if (color > alpha) \
1079 CHECK_COLOR(red, alpha);
1080 CHECK_COLOR(green, alpha);
1081 CHECK_COLOR(blue, alpha);
1084 evas_object_image_alpha_set(smartData->image, alpha < 255);
1085 impl->pageProxy->setDrawsBackground(red || green || blue);
1086 impl->pageProxy->setDrawsTransparentBackground(alpha < 255);
1087 impl->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1090 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1094 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1096 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1098 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1099 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1100 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1104 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1105 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1107 evas_object_smart_clipped_smart_set(&api->sc);
1109 // Set Evas_Smart_Class functions.
1110 api->sc.add = _ewk_view_smart_add;
1111 api->sc.del = _ewk_view_smart_del;
1112 api->sc.move = _ewk_view_smart_move;
1113 api->sc.resize = _ewk_view_smart_resize;
1114 api->sc.show = _ewk_view_smart_show;
1115 api->sc.hide = _ewk_view_smart_hide;
1116 api->sc.color_set = _ewk_view_smart_color_set;
1117 api->sc.calculate = _ewk_view_smart_calculate;
1118 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1120 // Set Ewk_View_Smart_Class functions.
1121 api->focus_in = _ewk_view_smart_focus_in;
1122 api->focus_out = _ewk_view_smart_focus_out;
1123 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1124 api->mouse_down = _ewk_view_smart_mouse_down;
1125 api->mouse_up = _ewk_view_smart_mouse_up;
1126 api->mouse_move = _ewk_view_smart_mouse_move;
1127 api->key_down = _ewk_view_smart_key_down;
1128 api->key_up = _ewk_view_smart_key_up;
1130 api->gesture_start = _ewk_view_smart_gesture_start;
1131 api->gesture_end = _ewk_view_smart_gesture_end;
1132 api->gesture_move = _ewk_view_smart_gesture_move;
1134 #if ENABLE(TIZEN_FULLSCREEN_API)
1135 api->fullscreen_enter = _ewk_view_smart_fullscreen_enter;
1136 api->fullscreen_exit = _ewk_view_smart_fullscreen_exit;
1139 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1140 api->popup_menu_show = _ewk_view_popup_menu_show;
1141 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1142 api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1144 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1145 api->popup_menu_update = _ewk_view_popup_menu_update;
1147 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1148 api->text_selection_down = _ewk_view_text_selection_down;
1149 api->text_selection_move = _ewk_view_text_selection_move;
1150 api->text_selection_up = _ewk_view_text_selection_up;
1152 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1153 api->input_picker_show = _ewk_view_input_picker_show;
1155 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1156 api->data_list_show = _ewk_view_data_list_show;
1157 api->data_list_hide = _ewk_view_data_list_hide;
1159 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1160 api->orientation_lock = _ewk_orientation_lock;
1161 api->orientation_unlock = _ewk_orientation_unlock;
1163 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1164 api->input_picker_color_request = _ewk_input_picker_color_request;
1165 api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1167 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1168 api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1169 api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1170 api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1171 api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1173 #if ENABLE(TIZEN_SCREEN_READER)
1174 api->screen_reader_action_execute = _ewk_view_screen_reader_action_execute;
1176 #endif //#if OS(TIZEN)
1181 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1183 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1184 static Evas_Smart* smart = 0;
1186 if (EINA_UNLIKELY(!smart)) {
1187 ewk_view_smart_class_set(&api);
1188 smart = evas_smart_class_new(&api.sc);
1194 static void _ewk_view_initialize(Evas_Object* ewkView, PassRefPtr<Ewk_Context> context, WKPageGroupRef pageGroupRef)
1196 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1197 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1198 EINA_SAFETY_ON_NULL_RETURN(context);
1200 if (impl->pageClient)
1203 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1204 bool isOpenGL = ewk_view_is_opengl_backend(ewkView);
1206 impl->pageClient = PageClientEvasGL::create(impl);
1208 impl->pageClient = PageClientImpl::create(impl);
1210 impl->pageClient = PageClientImpl::create(impl);
1214 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), toImpl(pageGroupRef));
1216 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), WebPageGroup::create().get());
1218 EwkViewImpl::addToPageViewMap(ewkView);
1221 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
1222 impl->pageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
1223 impl->pageProxy->pageGroup()->preferences()->setFrameFlatteningEnabled(true);
1224 impl->pageProxy->pageGroup()->preferences()->setAllowUniversalAccessFromFileURLs(true);
1227 impl->pageProxy->initializeWebPage();
1229 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
1230 impl->pageProxy->setCustomDeviceScaleFactor((float)getMobileDPI() / 160);
1232 impl->pageProxy->setCustomDeviceScaleFactor((float)getDPI() / 160);
1235 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1236 impl->pageProxy->setUseFixedLayout(true);
1238 #if ENABLE(FULLSCREEN_API)
1239 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1242 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1244 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1246 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1247 impl->pageProxy->pageGroup()->preferences()->setWebGLEnabled(false);
1248 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1252 impl->backForwardList = Ewk_Back_Forward_List::create(toAPI(impl->pageProxy->backForwardList()));
1254 impl->context = context;
1257 ewkViewContextMenuClientAttachClient(ewkView);
1258 ewkViewTizenClientAttachClient(ewkView);
1260 #if ENABLE(TIZEN_GEOLOCATION)
1261 ewkViewGeolocationProviderAttachProvider(ewkView, impl->context->wkContext());
1264 #if ENABLE(TIZEN_NOTIFICATIONS)
1265 ewkViewNotificationProviderAttachProvider(ewkView, impl->context->wkContext());
1268 #if ENABLE(TIZEN_ICON_DATABASE)
1269 ewk_view_icondatabase_client_attach(ewkView, impl->context->wkContext());
1272 ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1273 ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1274 ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1275 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1276 ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1278 ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1279 #else // #if OS(TIZEN)
1280 #if USE(COORDINATED_GRAPHICS)
1281 impl->viewportHandler = EflViewportHandler::create(impl->pageClient.get());
1283 #endif // #if OS(TIZEN)
1285 #if ENABLE(FULLSCREEN_API)
1286 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1287 impl->pageProxy->pageGroup()->preferences()->setFullScreenEnabled(true);
1290 // Initialize page clients.
1291 impl->pageLoadClient = PageLoadClientEfl::create(impl);
1292 impl->pagePolicyClient = PagePolicyClientEfl::create(impl);
1293 impl->pageUIClient = PageUIClientEfl::create(impl);
1294 impl->resourceLoadClient = ResourceLoadClientEfl::create(impl);
1295 impl->findClient = FindClientEfl::create(impl);
1296 impl->formClient = FormClientEfl::create(impl);
1297 #if !ENABLE(TIZEN_ICON_DATABASE)
1298 /* Listen for favicon changes */
1299 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
1300 iconDatabase->watchChanges(IconChangeCallbackData(_ewk_view_on_favicon_changed, ewkView));
1302 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1303 ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1306 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1307 if (!impl->context->xWindow())
1308 impl->context->setXWindow(elm_win_xwindow_get(ewkView));
1312 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1314 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1315 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1317 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1319 using namespace EGL;
1320 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1321 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1327 Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1331 EWK_VIEW_SD_GET(ewkView, smartData);
1333 evas_object_del(ewkView);
1337 EWK_VIEW_IMPL_GET(smartData, impl);
1339 evas_object_del(ewkView);
1348 * Constructs a ewk_view Evas_Object with WKType parameters.
1350 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1352 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1353 EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1355 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1359 _ewk_view_initialize(ewkView, Ewk_Context::create(contextRef), pageGroupRef);
1364 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1366 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1367 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1368 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1370 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1374 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1375 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1376 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1377 _ewk_view_initialize(ewkView, context, toAPI(impl->pageGroup.get()));
1379 _ewk_view_initialize(ewkView, context, 0);
1385 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1387 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1388 return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1391 Evas_Object* ewk_view_add(Evas* canvas)
1393 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1396 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
1398 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1399 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1401 return impl->ewkContext();
1404 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* url)
1406 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1407 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1408 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
1410 impl->pageProxy->loadURL(String::fromUTF8(url));
1411 impl->informURLChange();
1416 const char* ewk_view_url_get(const Evas_Object* ewkView)
1418 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1419 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1424 const char *ewk_view_icon_url_get(const Evas_Object *ewkView)
1426 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1427 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1429 return impl->faviconURL();
1432 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1434 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1435 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1437 impl->pageClient->prepareRestoredVisibleContectRect();
1438 impl->pageProxy->reload(/*reloadFromOrigin*/ false);
1439 impl->informURLChange();
1444 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1446 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1447 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1449 impl->pageProxy->reload(/*reloadFromOrigin*/ true);
1450 impl->informURLChange();
1455 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1457 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1458 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1460 impl->pageProxy->stopLoading();
1465 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1467 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1468 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1470 return impl->settings();
1473 const char* ewk_view_title_get(const Evas_Object* ewkView)
1475 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1476 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1478 return impl->title();
1483 * Reports that the requested text was found.
1485 * Emits signal: "text,found" with the number of matches.
1487 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
1489 evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
1492 double ewk_view_load_progress_get(const Evas_Object* ewkView)
1494 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1495 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1497 return impl->pageProxy->estimatedProgress();
1500 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
1502 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1503 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1509 scaleFactor = impl->pageClient->adjustScaleWithViewport(scaleFactor);
1511 IntPoint scrollPosition = impl->pageClient->scrollPosition();
1512 double scaleDifference = scaleFactor / impl->pageClient->scaleFactor();
1513 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
1514 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
1516 impl->pageProxy->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
1518 impl->pageProxy->scalePage(scaleFactor, IntPoint(x, y));
1523 double ewk_view_scale_get(const Evas_Object* ewkView)
1525 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
1526 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1);
1529 return impl->pageProxy->scaleFactor();
1531 return impl->pageProxy->pageScaleFactor();
1535 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
1537 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1538 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1540 impl->pageProxy->setCustomDeviceScaleFactor(ratio);
1545 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
1547 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1548 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1550 return impl->pageProxy->deviceScaleFactor();
1553 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
1555 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1556 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1558 impl->setThemePath(path);
1561 const char* ewk_view_theme_get(const Evas_Object* ewkView)
1563 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1564 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1566 return impl->themePath();
1569 Eina_Bool ewk_view_back(Evas_Object* ewkView)
1571 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1572 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1574 WebPageProxy* page = impl->pageProxy.get();
1575 if (page->canGoBack()) {
1583 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
1585 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1586 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1588 WebPageProxy* page = impl->pageProxy.get();
1589 if (page->canGoForward()) {
1597 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
1599 #if ENABLE(WEB_INTENTS)
1600 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1601 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1602 EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
1604 WebPageProxy* page = impl->pageProxy.get();
1605 page->deliverIntentToFrame(page->mainFrame(), intent->webIntentData());
1613 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
1615 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1616 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1618 return impl->pageProxy->canGoBack();
1621 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
1623 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1624 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1626 return impl->pageProxy->canGoForward();
1629 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
1631 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1632 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1634 return impl->backForwardList.get();
1637 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1638 #if ENABLE(TIZEN_WEBKIT2_AUTOFILL_PROFILE_FORM)
1639 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value, bool isInputInForm)
1641 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
1642 #endif // TIZEN_WEBKIT2_AUTOFILL_PROFILE_FORM
1644 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1645 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1647 if (value.isEmpty()) {
1648 if(smartData->api->formdata_candidate_is_showing(smartData))
1649 smartData->api->formdata_candidate_hide(smartData);
1653 Eina_List* optionList = 0;
1654 Vector<String> popupOptionLists = impl->pageProxy->getFocusedInputElementDataList();
1655 std::sort(popupOptionLists.begin(), popupOptionLists.end(), WTF::codePointCompareLessThan);
1656 for (size_t i = 0; i < popupOptionLists.size(); ++i) {
1657 if (popupOptionLists[i].startsWith(value, false))
1658 optionList = eina_list_append(optionList, eina_stringshare_add(popupOptionLists[i].utf8().data()));
1661 Eina_List* candidateList = 0;
1662 if (ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView))) {
1663 Vector<String> popupCandidates;
1664 ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
1665 std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
1667 for (size_t i = 0; i < popupCandidates.size(); ++i) {
1668 if (popupCandidates[i].startsWith(value, false))
1669 candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
1673 Vector<AutoFillPopupItem> formData;
1675 #if ENABLE(TIZEN_WEBKIT2_AUTOFILL_PROFILE_FORM)
1676 if (ewk_settings_form_profile_data_enabled_get(ewk_view_settings_get(ewkView)) && isInputInForm) {
1677 Vector<std::pair<int, std::pair<String, String> > > profileFormCandidates;
1678 ewk_view_profile_form_candidate_data_get(ewkView, name, value, profileFormCandidates);
1679 for (size_t ittr = 0; ittr < profileFormCandidates.size(); ++ittr) {
1680 std::pair<int, std::pair<String, String> > fullData(profileFormCandidates[ittr]);
1681 std::pair<String, String> dispStrings(fullData.second);
1682 formData.append(AutoFillPopupItem(dispStrings.first, dispStrings.second, fullData.first, profileAutoFill));
1689 if (eina_list_count(optionList)) {
1690 EINA_LIST_FOREACH(optionList, list, data)
1691 formData.append(AutoFillPopupItem(String::fromUTF8(static_cast<char*>(data)), dataListAutoFill));
1694 if (eina_list_count(candidateList) && ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView))) {
1695 EINA_LIST_FOREACH(candidateList, list, data)
1696 formData.append(AutoFillPopupItem(String::fromUTF8(static_cast<char*>(data)), candidateAutoFill));
1699 if (!formData.size()) {
1700 if(smartData->api->formdata_candidate_is_showing(smartData))
1701 smartData->api->formdata_candidate_hide(smartData);
1705 if (formData[0].itemtype == profileAutoFill)
1706 impl->pageClient->updateAutoFillPopup(formData);
1708 Eina_List* autoFillList = 0;
1710 if (eina_list_count(optionList)) {
1711 EINA_LIST_FOREACH(optionList, list, data)
1712 autoFillList = eina_list_append(autoFillList, eina_stringshare_add(static_cast<char*>(data)));
1714 if (eina_list_count(candidateList)) {
1715 EINA_LIST_FOREACH(candidateList, list, data)
1716 autoFillList = eina_list_append(autoFillList, eina_stringshare_add(static_cast<char*>(data)));
1718 smartData->api->formdata_candidate_update_data(smartData, autoFillList);
1721 IntRect inputFieldRect = impl->transformToScene().mapRect(impl->pageClient->focusedNodeRect());
1722 smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
1725 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm, bool isAutoComplete)
1727 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1728 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1729 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
1730 && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
1733 // if isAutoComplete is off then return
1734 if (isPasswordForm && !isAutoComplete)
1737 ewk_view_context_get(ewkView)->addFormData(impl->url(), formData, isPasswordForm);
1740 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
1742 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1743 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1745 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
1748 Vector<std::pair<String, String> > passwordFormData;
1749 ewk_view_context_get(ewkView)->passwordFormData(impl->url(), passwordFormData);
1751 if (!passwordFormData.size())
1754 String passwordFormAutofill = "try { function passwordFormAutofill() { var inputFields;";
1755 for (size_t i = 0; i < passwordFormData.size(); i++) {
1756 passwordFormAutofill += String::format(" inputFields = document.getElementsByName(\"%s\");"
1757 " for (var i = 0; i < inputFields.length; i++)"
1758 " if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\" || inputFields[i].type.toLowerCase() == \"email\")"
1759 " && inputFields[i].autocomplete.toLowerCase() != \"off\")"
1760 " inputFields[i].value = \"",passwordFormData[i].first.utf8().data());
1761 passwordFormAutofill.append(passwordFormData[i].second);
1762 passwordFormAutofill += "\";";
1764 passwordFormAutofill += "} passwordFormAutofill(); } catch(e) { }";
1765 ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
1768 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
1770 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1771 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1772 ewk_view_context_get(ewkView)->candidateFormData(name, candidates);
1776 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
1778 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1779 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1780 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
1782 if (unreachableUrl && *unreachableUrl)
1783 impl->pageProxy->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
1785 impl->pageProxy->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
1787 impl->informURLChange();
1792 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
1794 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1795 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1797 return impl->customTextEncodingName();
1800 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
1802 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1803 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1805 impl->setCustomTextEncodingName(encoding);
1811 // FIXME: It should be removed.
1812 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
1814 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1815 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1817 return toAPI(impl->pageProxy.get());
1820 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
1822 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1823 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1825 impl->setMouseEventsEnabled(!!enabled);
1830 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
1832 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1833 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1835 return impl->mouseEventsEnabled();
1838 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
1840 #if ENABLE(INPUT_TYPE_COLOR)
1841 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1842 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1844 return impl->setColorPickerColor(WebCore::Color(r, g, b, a));
1850 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
1852 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1853 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1855 return impl->javascriptPopup->alert(alertText);
1858 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
1860 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1861 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1863 return impl->javascriptPopup->confirm(message);
1866 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
1868 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1869 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1871 return impl->javascriptPopup->prompt(message, defaultValue);
1874 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1875 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, void* userData)
1877 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1878 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1880 return impl->javascriptPopup->beforeUnloadConfirmPanel(message);
1884 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)
1886 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1887 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1889 return impl->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, impl);
1892 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1893 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)
1895 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1897 if (impl->popupPicker)
1898 ewk_popup_picker_del(impl->popupPicker);
1900 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1901 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
1903 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
1909 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1910 Eina_Bool _ewk_view_multiple_popup_menu_show(Ewk_View_Smart_Data* smartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* items)
1912 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1914 if (impl->popupPicker)
1915 ewk_popup_picker_del(impl->popupPicker);
1917 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
1923 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
1925 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1927 if (!impl->popupPicker)
1930 ewk_popup_picker_del(impl->popupPicker);
1931 impl->popupPicker = 0;
1936 Eina_Bool _ewk_view_popup_menu_update(Ewk_View_Smart_Data* smartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, Eina_List* items, int selectedIndex)
1938 // FIXME: The rect should be updated if it was changed
1940 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1942 if (!impl->popupPicker)
1945 ewk_popup_picker_update(smartData->self, impl->popupPicker, items, selectedIndex);
1951 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1952 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
1954 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1956 impl->inputPicker->show(inputType, inputValue);
1961 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1962 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
1964 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1966 impl->inputPicker->showDataList(inputType, optionList);
1970 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
1972 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1974 impl->inputPicker->hideDataList(inputType);
1979 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1980 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
1982 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1984 impl->inputPicker->showColorPicker(r, g, b, a);
1988 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
1990 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1992 impl->inputPicker->hideColorPicker();
1997 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
1999 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2000 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2002 return impl->pageClient.get();
2005 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
2007 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
2008 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 1);
2010 return WKPageGetTextZoomFactor(toAPI(impl->pageProxy.get()));
2013 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
2015 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2016 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2018 WKPageSetTextZoomFactor(toAPI(impl->pageProxy.get()), textZoomFactor);
2022 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
2024 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2025 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2027 return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(impl->pageProxy.get())));
2030 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
2032 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2033 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2035 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(impl->pageProxy.get())));
2038 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
2040 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2041 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2043 if (!impl->javascriptGlobalContext)
2044 impl->javascriptGlobalContext = JSGlobalContextCreate(0);
2045 return impl->javascriptGlobalContext;
2048 void ewkViewLoadCommitted(Evas_Object* ewkView)
2050 #if ENABLE(TIZEN_GESTURE)
2051 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2052 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2053 impl->gestureClient->reset();
2055 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
2056 if (impl->focusRing())
2057 impl->focusRing()->hide(false);
2059 #if ENABLE(TIZEN_ISF_PORT)
2060 impl->inputMethodContext()->hideIMFContext();
2062 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2063 if (smartData->api->formdata_candidate_is_showing(smartData))
2064 smartData->api->formdata_candidate_hide(smartData);
2066 impl->informURLChange();
2067 evas_object_smart_callback_call(ewkView, "load,committed", 0);
2070 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
2072 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2073 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2075 OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error);
2076 ewk_error_load_error_page(ewkError.get(), toAPI(impl->pageProxy.get()));
2077 evas_object_smart_callback_call(ewkView, "load,error", ewkError.get());
2080 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
2082 #if ENABLE(TIZEN_GESTURE)
2083 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2084 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2085 impl->gestureClient->reset();
2087 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
2090 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
2092 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2093 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2095 if (impl->authChallenge)
2096 ewkAuthChallengeDelete(impl->authChallenge);
2097 impl->authChallenge = authChallenge;
2099 evas_object_smart_callback_call(ewkView, "authentication,challenge", impl->authChallenge);
2102 void ewk_view_process_crashed(Evas_Object* ewkView)
2104 bool handled = false;
2105 evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
2111 #if ENABLE(TIZEN_SQL_DATABASE)
2112 bool ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef databaseName, unsigned long long expectedUsage)
2114 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2115 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2117 if (!impl->exceededDatabaseQuotaContext || !impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback)
2120 TIZEN_LOGI("No error in prameter. Request to display user confirm popup. expectedUsage(%llu)", expectedUsage);
2121 impl->isWaitingForExceededQuotaPopupReply = true;
2122 if (impl->exceededQuotaOrigin)
2123 deleteSecurityOrigin(impl->exceededQuotaOrigin);
2124 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
2126 int length = WKStringGetMaximumUTF8CStringSize(databaseName);
2127 OwnArrayPtr<char> databaseNameBuffer = adoptArrayPtr(new char[length]);
2128 WKStringGetUTF8CString(databaseName, databaseNameBuffer.get(), length);
2130 return impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, databaseNameBuffer.get(), expectedUsage, impl->exceededDatabaseQuotaContext->userData) == EINA_TRUE;
2134 #if ENABLE(TIZEN_NOTIFICATIONS)
2135 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
2137 TIZEN_LOGI("notification,cancel");
2138 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
2141 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
2143 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2144 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2146 TIZEN_LOGI("notification,permission,request");
2147 impl->notificationPermissionRequests = eina_list_append(impl->notificationPermissionRequests, notificationPermissionRequest);
2148 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
2151 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
2153 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2154 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2156 TIZEN_LOGI("notification,show");
2157 Eina_List* listIterator=0;
2159 const char* replaceID = ewkNotificationGetReplaceID(notification);
2160 if(strlen(replaceID)) {
2161 EINA_LIST_FOREACH(impl->notifications, listIterator, data) {
2162 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
2163 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
2164 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
2168 impl->notifications = eina_list_append(impl->notifications, notification);
2169 evas_object_smart_callback_call(ewkView, "notification,show", notification);
2172 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
2174 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2175 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2177 impl->notificationPermissionRequests = eina_list_remove(impl->notificationPermissionRequests, ewkNotificationPermissionRequest);
2181 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
2182 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
2184 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2186 TIZEN_LOGI("protocolhandler,registration,requested");
2187 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
2188 evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
2189 ewkCustomHandlersDeleteData(customHandlersData);
2193 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
2194 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2196 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2198 TIZEN_LOGI("protocolhandler,isregistered");
2199 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2200 evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
2202 Ewk_Custom_Handlers_State result;
2203 result = ewkGetCustomHandlersDataResult(customHandlersData);
2204 ewkCustomHandlersDeleteData(customHandlersData);
2209 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2211 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2213 TIZEN_LOGI("protocolhandler,unregistration,requested");
2214 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2215 evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
2216 ewkCustomHandlersDeleteData(customHandlersData);
2220 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
2221 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
2223 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2225 TIZEN_LOGI("contenthandler,registration,requested");
2226 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
2227 evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
2228 ewkCustomHandlersDeleteData(customHandlersData);
2231 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2233 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2235 TIZEN_LOGI("contenthandler,isregistered");
2236 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2237 evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
2239 Ewk_Custom_Handlers_State result;
2240 result = ewkGetCustomHandlersDataResult(customHandlersData);
2241 ewkCustomHandlersDeleteData(customHandlersData);
2246 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2248 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2250 TIZEN_LOGI("contenthandler,unregistration,requested");
2251 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2252 evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
2253 ewkCustomHandlersDeleteData(customHandlersData);
2257 #if ENABLE(TIZEN_SEARCH_PROVIDER)
2258 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2260 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2262 TIZEN_LOGI("searchProvider,add");
2263 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2264 evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
2265 ewkSearchProviderDeleteData(searchProviderData);
2268 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2270 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
2272 TIZEN_LOGI("searchProvider,installed");
2273 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2274 evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
2275 unsigned long result;
2276 result = ewkGetSearchProviderResult(searchProviderData);
2277 ewkSearchProviderDeleteData(searchProviderData);
2282 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
2283 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
2285 TIZEN_LOGI("webapp,metatag,standalone");
2286 bool standalone = true;
2287 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
2292 #if ENABLE(TIZEN_MEDIA_STREAM)
2293 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
2295 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2296 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2298 impl->userMediaPermissionRequests = eina_list_append(impl->userMediaPermissionRequests, userMediaPermission);
2299 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
2302 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
2304 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2305 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2307 impl->userMediaPermissionRequests = eina_list_remove(impl->userMediaPermissionRequests, permission);
2312 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
2313 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
2315 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
2316 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
2317 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
2318 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
2319 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
2320 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
2322 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
2326 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
2327 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
2329 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2330 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2331 if (impl->certificatePolicyDecision)
2332 ewkCertificatePolicyDecisionDelete(impl->certificatePolicyDecision);
2333 impl->certificatePolicyDecision = certificatePolicyDecision;
2335 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
2339 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
2341 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
2344 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
2346 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
2349 #if ENABLE(TIZEN_GEOLOCATION)
2350 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2352 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2353 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2355 TIZEN_LOGI("geolocation,permission,request");
2356 impl->geolocationPermissionRequests = eina_list_append(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2357 evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
2360 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2362 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2363 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2365 impl->geolocationPermissionRequests = eina_list_remove(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2368 void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
2370 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2371 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2373 impl->geolocation = geolocation;
2376 Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
2378 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2379 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2381 return impl->geolocation;
2384 bool ewkViewIsValidLocationService(Evas_Object* ewkView)
2386 TIZEN_LOGI("geolocation,valid");
2389 evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
2394 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
2396 evas_object_smart_callback_call(ewkView, "form,submit", formData);
2399 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2401 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2402 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2403 if (impl->policyDecision)
2404 ewkPolicyDecisionDelete(impl->policyDecision);
2405 impl->policyDecision = policyDecision;
2407 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", impl->policyDecision);
2410 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2412 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2413 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2414 if (impl->policyDecision)
2415 ewkPolicyDecisionDelete(impl->policyDecision);
2416 impl->policyDecision = policyDecision;
2418 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", impl->policyDecision);
2421 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2423 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2424 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2425 if (impl->policyDecision)
2426 ewkPolicyDecisionDelete(impl->policyDecision);
2427 impl->policyDecision = policyDecision;
2429 evas_object_smart_callback_call(ewkView, "policy,response,decide", impl->policyDecision);
2432 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
2434 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2435 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2437 IntPoint scrollPosition = impl->pageClient->scrollPosition();
2438 IntSize contentsSize = impl->pageProxy->contentsSize();
2439 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2440 contentsSize.scale(impl->pageClient->scaleFactor());
2443 // some website's contents size is smaller than view size,
2444 // so we have to adjust contents size to view size for that case.
2445 if (contentsSize.width() < smartData->view.w)
2446 contentsSize.setWidth(smartData->view.w);
2447 if (contentsSize.height() < smartData->view.h)
2448 contentsSize.setHeight(smartData->view.h);
2450 // Call "scroll,down" if webview can be scrolled down.
2451 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
2452 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
2453 // Call "scroll,up" if webview can be scrolled up.
2454 else if (deltaY < 0 && scrollPosition.y() > 0)
2455 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
2457 // Call "scroll,right" if webview can be scrolled down.
2458 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
2459 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
2460 // Call "scroll,left" if webview can be scrolled up.
2461 else if (deltaX < 0 && scrollPosition.x() > 0)
2462 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
2465 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
2467 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2468 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2470 IntSize contentsSize = impl->pageProxy->contentsSize();
2471 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2472 contentsSize.scale(impl->pageClient->scaleFactor());
2475 int maxScrollY = contentsSize.height() - smartData->view.h;
2476 if (!impl->isVerticalEdge) {
2477 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
2478 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
2479 impl->isVerticalEdge = true;
2480 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
2481 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
2482 impl->isVerticalEdge = true;
2485 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
2486 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
2487 impl->isVerticalEdge = false;
2490 int maxScrollX = contentsSize.width() - smartData->view.w;
2491 if (!impl->isHorizontalEdge) {
2492 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
2493 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
2494 impl->isHorizontalEdge = true;
2495 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
2496 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
2497 impl->isHorizontalEdge = true;
2500 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
2501 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
2502 impl->isHorizontalEdge = false;
2506 void ewkViewClearEdges(Evas_Object* ewkView)
2508 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2509 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2511 impl->isVerticalEdge = false;
2512 impl->isHorizontalEdge = false;
2515 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
2517 EWK_VIEW_SD_GET(ewkView, smartData);
2518 if (!smartData || !smartData->priv) {
2526 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
2528 *minimumScale = constraints.minimumScale;
2530 *maximumScale = constraints.maximumScale;
2533 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard)
2535 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2536 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2538 #if ENABLE(TIZEN_ISF_PORT)
2539 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
2540 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
2541 // input field zoom should not work with below conditions
2542 // 1. view is not focused
2543 // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
2544 // 3. imfContext is null(if adjustForExternalKeyboard is false)
2545 // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
2547 if ((!(static_cast<PageClient*>(impl->pageClient.get()))->isViewFocused()
2548 || (!adjustForExternalKeyboard && !impl->inputMethodContext())
2549 || (!adjustForExternalKeyboard && !impl->inputMethodContext()->isShow()))
2550 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
2551 && !(impl->pageClient->isClipboardWindowOpened())
2557 double scaleFactor = impl->pageClient->scaleFactor();
2558 IntSize contentsSize = impl->pageProxy->contentsSize();
2560 double newScaleFactor = scaleFactor;
2561 // Readable zoom value is dependent on device DPI
2562 if (scaleFactor < impl->pageProxy->deviceScaleFactor()
2563 && impl->pageClient->viewportConstraints().userScalable)
2564 newScaleFactor = impl->pageProxy->deviceScaleFactor();
2566 // Readable zoom value should be inside of viewport scale range
2567 newScaleFactor = impl->pageClient->adjustScaleWithViewport(newScaleFactor);
2569 // caret position can be outside of visible rect.
2570 // we need to consider it.
2571 IntRect selectionRect = impl->pageProxy->editorState().selectionRect;
2572 IntRect focusedNodeRect = impl->pageClient->focusedNodeRect();
2573 IntRect focusedNodeRectScaled = focusedNodeRect;
2575 if (selectionRect.isEmpty())
2578 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2579 focusedNodeRectScaled.scale(newScaleFactor);
2581 focusedNodeRectScaled.scale(newScaleFactor / scaleFactor);
2584 IntRect visibleRect = impl->pageClient->visibleContentRect();
2585 if (visibleRect.contains(focusedNodeRectScaled))
2588 #if ENABLE(TIZEN_WEBKIT2_INPUT_FIELD_ZOOM)
2589 impl->inputFieldZoom->startInputFieldZoom(impl->transformFromScene().mapPoint(IntPoint(focusedNodeRect.x(), focusedNodeRect.y())) ,focusedNodeRect);
2595 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
2596 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2597 static Eina_Bool _ewk_view_composite(void* data)
2599 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
2600 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2602 if (!evas_object_visible_get(smartData->image))
2603 return ECORE_CALLBACK_CANCEL;
2606 evas_object_image_size_get(smartData->image, &ow, &oh);
2607 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
2609 RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_ARGB32, ow, oh, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, ow)));
2610 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
2612 cairo_save(context.get());
2613 cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
2614 cairo_rectangle(context.get(), 0, 0, ow, oh);
2615 cairo_fill(context.get());
2616 cairo_restore(context.get());
2618 impl->pageClient->drawContents(context.get());
2620 evas_object_image_data_set(smartData->image, pixels);
2621 evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
2623 if (impl->pageClient->notifiedNonemptyLayout() && impl->pageClient->canUpdateVisibleContentRect())
2624 ewkViewFrameRendered(smartData->self);
2626 impl->compositionAnimator = 0;
2628 return ECORE_CALLBACK_CANCEL;
2632 void ewk_view_mark_for_sync(Evas_Object* ewkView)
2634 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2635 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
2637 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2638 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2640 if (!ewk_view_is_opengl_backend(ewkView)) {
2641 if (!impl->compositionAnimator)
2642 impl->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
2647 evas_object_image_pixels_dirty_set(smartData->image, true);
2650 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
2652 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
2653 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2654 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2655 impl->pageClient->drawContents();
2658 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
2660 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2661 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2663 if (!smartData->image)
2666 evas_object_image_native_surface_set(smartData->image, nativeSurface);
2667 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
2673 void _ewk_view_suspend_painting(Evas_Object* ewkView)
2675 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2676 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2678 if (!impl->suspendedPainting) {
2679 impl->pageProxy->suspendPainting();
2680 impl->suspendedPainting = true;
2684 void _ewk_view_resume_painting(Evas_Object* ewkView)
2686 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2687 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2689 if (impl->suspendedPainting) {
2690 impl->pageProxy->resumePainting();
2691 impl->suspendedPainting = false;
2695 void ewk_view_suspend(Evas_Object* ewkView)
2697 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2698 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2700 if (impl->pageProxy->estimatedProgress() < 1.0) {
2701 impl->suspendRequested = true;
2704 impl->suspendRequested = false;
2706 _ewk_view_suspend_painting(ewkView);
2708 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2709 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2710 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2712 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2713 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2714 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2715 // will be suspended again.
2716 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2717 // the ActiveDOMObject.
2718 if (!impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2719 impl->pageProxy->suspendAnimations();
2720 impl->pageProxy->suspendJavaScriptAndResource();
2721 impl->suspendedResources = true;
2724 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2725 impl->pageProxy->suspendPlugin();
2729 void ewk_view_resume(Evas_Object* ewkView)
2731 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2732 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2734 if (impl->suspendRequested) {
2735 impl->suspendRequested = false;
2739 _ewk_view_resume_painting(ewkView);
2741 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2742 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2743 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2745 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2746 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2747 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2748 // will be suspended again.
2749 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2750 // the ActiveDOMObject.
2751 if (impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2752 impl->pageProxy->resumeAnimations();
2753 impl->pageProxy->resumeJavaScriptAndResource();
2754 impl->suspendedResources = false;
2757 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2758 impl->pageProxy->resumePlugin();
2762 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
2764 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2765 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2766 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
2768 ResourceRequest request(String::fromUTF8(url));
2771 case EWK_HTTP_METHOD_GET:
2772 request.setHTTPMethod("GET");
2774 case EWK_HTTP_METHOD_HEAD:
2775 request.setHTTPMethod("HEAD");
2777 case EWK_HTTP_METHOD_POST:
2778 request.setHTTPMethod("POST");
2780 case EWK_HTTP_METHOD_PUT:
2781 request.setHTTPMethod("PUT");
2783 case EWK_HTTP_METHOD_DELETE:
2784 request.setHTTPMethod("DELETE");
2791 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
2793 while (eina_iterator_next(it, &data)) {
2794 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
2795 const char* name = static_cast<const char*>(t->key);
2796 const char* value = static_cast<const char*>(t->data);
2797 request.addHTTPHeaderField(name, value);
2799 eina_iterator_free(it);
2803 request.setHTTPBody(FormData::create(body));
2805 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
2806 WKPageLoadURLRequest(toAPI(impl->pageProxy.get()), urlRequest.get());
2811 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
2813 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2814 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2816 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
2817 WKPageLoadPlainTextString(toAPI(impl->pageProxy.get()), plainTextRef.get());
2822 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
2824 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2825 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2826 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
2828 if (contentsSize == 0)
2831 String mimeTypeString;
2833 mimeTypeString = String::fromUTF8(mimeType);
2835 mimeTypeString = String::fromUTF8("text/html");
2837 String encodingString;
2839 encodingString = String::fromUTF8(encoding);
2841 encodingString = String::fromUTF8("UTF-8");
2843 String baseUriString;
2845 baseUriString = String::fromUTF8(baseUri);
2847 baseUriString = String::fromUTF8("about:blank");
2849 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
2850 impl->pageProxy->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
2855 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
2857 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2858 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2860 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
2861 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
2863 WKPageLoadHTMLString(toAPI(impl->pageProxy.get()), htmlString.get(), baseURL.get());
2868 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
2870 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2871 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2873 TIZEN_LOGI("initialState (%d)", initialState);
2874 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
2875 WKPageSetPageVisibility(toAPI(impl->pageProxy.get()), static_cast<WKPageVisibilityState>(pageVisibilityState), initialState);
2882 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
2884 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
2886 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2887 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2889 impl->userAgent = userAgent;
2891 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
2892 WKPageSetCustomUserAgent(toAPI(impl->pageProxy.get()), userAgentString.get());
2897 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
2899 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2900 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2903 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
2905 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
2906 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2907 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
2908 impl->userAgent = buffer.get();
2910 if (!impl->userAgent) {
2911 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
2913 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
2914 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2915 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
2916 impl->userAgent = buffer.get();
2920 return impl->userAgent;
2924 Eina_Bool ewk_view_application_name_for_user_agent_set(Evas_Object* ewkView, const char* applicationName)
2926 EINA_SAFETY_ON_NULL_RETURN_VAL(applicationName, false);
2928 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2929 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2931 WKRetainPtr<WKStringRef> applicationNameString(AdoptWK, WKStringCreateWithUTF8CString(applicationName));
2932 WKPageSetApplicationNameForUserAgent(toAPI(impl->pageProxy.get()), applicationNameString.get());
2937 const char* ewk_view_application_name_for_user_agent_get(const Evas_Object* ewkView)
2939 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2940 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2942 WKRetainPtr<WKStringRef> applicationNameString(AdoptWK, WKPageCopyApplicationNameForUserAgent(toAPI(impl->pageProxy.get())));
2944 int length = WKStringGetMaximumUTF8CStringSize(applicationNameString.get());
2945 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2946 WKStringGetUTF8CString(applicationNameString.get(), buffer.get(), length);
2947 impl->applicationName = buffer.get();
2949 return impl->applicationName;
2953 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
2955 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2956 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2957 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2959 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2960 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
2962 WKPageAddCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get(), customHeaderValue.get());
2965 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2970 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
2972 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2973 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2974 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2976 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2978 WKPageRemoveCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get());
2981 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2986 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
2988 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2989 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2990 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2992 WKPageClearCustomHeaders(toAPI(impl->pageProxy.get()));
2995 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
3000 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
3001 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
3003 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3004 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3006 #if ENABLE(TIZEN_DRAG_SUPPORT)
3007 if (impl->pageClient->isDragMode())
3008 impl->pageClient->setDragMode(false);
3011 impl->pageClient->setIsVisible(enable);
3016 #if ENABLE(TIZEN_BACKGROUND_DISK_CACHE)
3017 Eina_Bool ewk_view_foreground_set(Evas_Object* ewkView, Eina_Bool enable)
3023 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
3025 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
3027 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3028 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3031 rect.origin.x = viewArea.x;
3032 rect.origin.y = viewArea.y;
3033 rect.size.width = viewArea.w;
3034 rect.size.height = viewArea.h;
3036 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(impl->pageProxy.get()), rect, scaleFactor));
3037 if (!snapshot.get())
3040 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
3042 Evas_Object* screenshotImage = evas_object_image_add(canvas);
3043 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
3044 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
3045 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
3046 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
3048 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
3050 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)));
3051 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
3053 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
3054 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
3055 cairo_fill(cairo.get());
3057 evas_object_image_smooth_scale_set(screenshotImage, true);
3058 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
3059 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
3060 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
3061 evas_object_image_data_set(screenshotImage, pixels);
3063 return screenshotImage;
3066 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
3068 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
3069 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
3070 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, 0);
3072 return impl->pageProxy->startInspectorServer(port);
3074 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
3079 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
3081 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
3082 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
3083 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
3085 return impl->pageProxy->stopInspectorServer();
3087 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
3092 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
3094 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3095 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3097 WKPageScrollBy(toAPI(impl->pageProxy.get()), toAPI(IntSize(deltaX, deltaY)));
3100 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
3106 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3107 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3109 IntPoint scrollPosition = impl->pageClient->scrollPosition();
3111 *x = scrollPosition.x();
3113 *y = scrollPosition.y();
3118 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
3120 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3121 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3123 impl->pageProxy->scrollMainFrameTo(IntPoint(x, y));
3127 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
3133 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3134 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3136 IntSize contentsSize = impl->pageProxy->contentsSize();
3137 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3138 contentsSize.scale(impl->pageClient->scaleFactor());
3141 if (width && contentsSize.width() > smartData->view.w)
3142 *width = contentsSize.width() - smartData->view.w;
3143 if (height && contentsSize.height() > smartData->view.h)
3144 *height = contentsSize.height() - smartData->view.h;
3148 #if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
3149 void ewkViewNotifyPopupReplyWaitingState(Evas_Object* ewkView, bool isWaiting)
3152 evas_object_smart_callback_call(ewkView, "popup,reply,wait,start", 0);
3154 evas_object_smart_callback_call(ewkView, "popup,reply,wait,finish", 0);
3158 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
3160 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3161 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3162 if (!impl->alertContext || !impl->alertContext->javascriptAlertCallback)
3164 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->alertContext->ewkView == ewkView, false);
3166 impl->isWaitingForJavaScriptPopupReply = true;
3167 int length = WKStringGetMaximumUTF8CStringSize(alertText);
3168 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
3169 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
3170 return impl->alertContext->javascriptAlertCallback(impl->alertContext->ewkView, alertTextBuffer.get(), impl->alertContext->userData) == EINA_TRUE;
3173 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
3175 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3176 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3177 if (!impl->confirmContext || !impl->confirmContext->javascriptConfirmCallback)
3179 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->confirmContext->ewkView == ewkView, false);
3181 impl->isWaitingForJavaScriptPopupReply = true;
3182 int length = WKStringGetMaximumUTF8CStringSize(message);
3183 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3184 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3185 return impl->confirmContext->javascriptConfirmCallback(impl->confirmContext->ewkView, messageBuffer.get(), impl->confirmContext->userData) == EINA_TRUE;
3188 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
3190 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3191 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3192 if (!impl->promptContext || !impl->promptContext->javascriptPromptCallback)
3194 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->promptContext->ewkView == ewkView, false);
3196 impl->isWaitingForJavaScriptPopupReply = true;
3197 int length = WKStringGetMaximumUTF8CStringSize(message);
3198 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3199 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3200 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
3201 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
3202 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
3203 return impl->promptContext->javascriptPromptCallback(impl->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), impl->promptContext->userData) == EINA_TRUE;
3206 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3207 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
3209 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3210 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3211 if (!impl->beforeUnloadConfirmPanelContext || !impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
3213 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
3215 impl->isWaitingForJavaScriptPopupReply = true;
3216 int length = WKStringGetMaximumUTF8CStringSize(message);
3217 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3218 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3219 bool result = impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(impl->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), impl->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
3224 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
3226 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3227 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3228 if (!impl->openpanelContext || !impl->openpanelContext->openPanelCallback)
3231 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->openpanelContext->ewkView == ewkView, false);
3233 impl->openPanelListener = listener;
3235 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
3236 Eina_List* acceptedMimeTypes = 0;
3237 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
3238 size_t len = WKArrayGetSize(array.get());
3239 for (size_t i = 0; i < len; i++) {
3240 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
3241 if (WKGetTypeID(item) != WKStringGetTypeID())
3243 WKStringRef mime = static_cast<WKStringRef>(item);
3244 int length = WKStringGetMaximumUTF8CStringSize(mime);
3245 char* buffer = new char[length];
3246 WKStringGetUTF8CString(mime, buffer, length);
3247 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
3249 const char* capture = 0;
3250 #if ENABLE(MEDIA_CAPTURE)
3251 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
3252 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
3254 bool result = impl->openpanelContext->openPanelCallback(impl->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
3255 if (!acceptedMimeTypes)
3260 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
3261 delete[] (char*)data;
3262 eina_list_free(acceptedMimeTypes);
3266 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
3268 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3269 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3271 if (!impl->alertContext)
3272 impl->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3273 impl->alertContext->javascriptAlertCallback = callback;
3274 impl->alertContext->ewkView = ewkView;
3275 impl->alertContext->userData = userData;
3278 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
3280 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3281 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3283 WKPageReplyJavaScriptAlert(toAPI(impl->page()));
3284 impl->isWaitingForJavaScriptPopupReply = false;
3287 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
3289 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3290 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3292 if (!impl->confirmContext)
3293 impl->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3294 impl->confirmContext->javascriptConfirmCallback = callback;
3295 impl->confirmContext->ewkView = ewkView;
3296 impl->confirmContext->userData = userData;
3299 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
3301 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3302 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3304 WKPageReplyJavaScriptConfirm(toAPI(impl->page()), result == EINA_TRUE);
3305 impl->isWaitingForJavaScriptPopupReply = false;
3308 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
3310 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3311 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3313 if (!impl->promptContext)
3314 impl->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3315 impl->promptContext->javascriptPromptCallback = callback;
3316 impl->promptContext->ewkView = ewkView;
3317 impl->promptContext->userData = userData;
3320 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
3322 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3323 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3325 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
3326 WKPageReplyJavaScriptPrompt(toAPI(impl->page()), result ? resultString.get() : 0);
3327 impl->isWaitingForJavaScriptPopupReply = false;
3330 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3331 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
3333 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3334 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3336 if (!impl->beforeUnloadConfirmPanelContext)
3337 impl->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3338 impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
3339 impl->beforeUnloadConfirmPanelContext->ewkView = ewkView;
3340 impl->beforeUnloadConfirmPanelContext->userData = userData;
3343 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
3345 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3346 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3348 WKPageReplyBeforeUnloadConfirmPanel(toAPI(impl->page()), result == EINA_TRUE);
3349 impl->isWaitingForJavaScriptPopupReply = false;
3353 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
3355 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3356 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3358 if (!impl->openpanelContext)
3359 impl->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3361 impl->openpanelContext->openPanelCallback = callback;
3362 impl->openpanelContext->ewkView = ewkView;
3363 impl->openpanelContext->userData = userData;
3366 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
3368 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3369 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3371 if (!impl->openPanelListener)
3374 unsigned int size = eina_list_count(fileUrls);
3375 if ((result == EINA_FALSE) || (size == 0)) {
3376 WKOpenPanelResultListenerCancel(impl->openPanelListener);
3377 impl->openPanelListener = 0;
3381 WKTypeRef* items = new WKTypeRef[size];
3385 KURL base(KURL(), "file://");
3386 EINA_LIST_FOREACH(fileUrls, list, data) {
3387 KURL url(base, String::fromUTF8(static_cast<char*>(data)));
3388 items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
3390 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
3391 WKOpenPanelResultListenerChooseFiles(impl->openPanelListener, filesArray.get());
3392 impl->openPanelListener = 0;
3394 eina_list_free(fileUrls);
3397 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3398 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
3400 EINA_SAFETY_ON_NULL_RETURN(capable);
3401 EINA_SAFETY_ON_NULL_RETURN(context);
3403 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3405 ASSERT(webAppContext->webAppCapableCallback);
3407 TIZEN_LOGI("webAppCapableCallback exist. capable(%b)", capable);
3409 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
3411 webAppContext->webAppCapableCallback(0, webAppContext->userData);
3413 delete webAppContext;
3416 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
3418 EINA_SAFETY_ON_NULL_RETURN(iconURL);
3419 EINA_SAFETY_ON_NULL_RETURN(context);
3421 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3423 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3424 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3426 ASSERT(webAppContext->webAppIconURLCallback);
3429 impl->webAppIconURL = toImpl(iconURL)->string().utf8().data();
3430 webAppContext->webAppIconURLCallback(impl->webAppIconURL, webAppContext->userData);
3432 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
3434 delete webAppContext;
3437 static void didGetWebAppIconURLs(WKDictionaryRef iconURLs, WKErrorRef, void* context)
3439 EINA_SAFETY_ON_NULL_RETURN(iconURLs);
3440 EINA_SAFETY_ON_NULL_RETURN(context);
3442 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3444 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3445 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3447 ASSERT(webAppContext->webAppIconURLsCallback);
3449 if (impl->webAppIconURLs) {
3451 EINA_LIST_FREE(impl->webAppIconURLs, data)
3452 ewkWebAppIconDataDelete(static_cast<Ewk_Web_App_Icon_Data*>(data));
3455 WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(iconURLs));
3456 size_t iconURLCount = WKArrayGetSize(wkKeys.get());
3457 for (size_t i = 0; i < iconURLCount; i++) {
3458 WKStringRef urlRef = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
3459 WKStringRef sizeRef = static_cast<WKStringRef>(WKDictionaryGetItemForKey(iconURLs, urlRef));
3460 impl->webAppIconURLs = eina_list_append(impl->webAppIconURLs, ewkWebAppIconDataCreate(sizeRef, urlRef));
3462 TIZEN_LOGI("webAppIconURLsCallback exist. found %d icon urls", iconURLCount);
3464 webAppContext->webAppIconURLsCallback(impl->webAppIconURLs, webAppContext->userData);
3465 delete webAppContext;
3469 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
3471 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3472 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3473 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3474 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3476 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3477 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3478 context->webAppCapableCallback = callback;
3479 context->ewkView = ewkView;
3480 context->userData = userData;
3482 WKPageGetWebAppCapable(toAPI(impl->pageProxy.get()), context, didGetWebAppCapable);
3490 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
3492 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3493 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3494 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3495 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3497 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3498 context->webAppIconURLCallback = callback;
3499 context->ewkView = ewkView;
3500 context->userData = userData;
3502 WKPageGetWebAppIconURL(toAPI(impl->page()), context, didGetWebAppIconURL);
3510 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
3512 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3513 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3514 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3515 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3517 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3518 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3519 context->webAppIconURLsCallback = callback;
3520 context->ewkView = ewkView;
3521 context->userData = userData;
3523 WKPageGetWebAppIconURLs(toAPI(impl->page()), context, didGetWebAppIconURLs);
3527 UNUSED_PARAM(ewkView);
3528 UNUSED_PARAM(callback);
3529 UNUSED_PARAM(userData);
3534 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
3536 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3537 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3538 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
3540 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
3541 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
3542 WKPageExecuteCommandWithArgument(toAPI(impl->pageProxy.get()), commandString.get(), valueString.get());
3547 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
3554 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3555 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3557 IntSize contentsSize = impl->pageProxy->contentsSize();
3560 *width = contentsSize.width();
3562 *height = contentsSize.height();
3567 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
3569 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3570 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3571 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3572 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3574 IntSize contentsSize = impl->pageProxy->contentsSize();
3575 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3583 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, int width, int height, const char* fileName)
3585 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3586 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3587 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3588 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3590 IntSize contentsSize = impl->pageProxy->contentsSize();
3591 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3599 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
3601 EINA_SAFETY_ON_NULL_RETURN(context);
3602 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3604 if (!callbackContext->scriptExecuteCallback) {
3605 delete callbackContext;
3609 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
3612 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
3613 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
3614 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
3615 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3616 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
3617 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3619 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
3621 delete callbackContext;
3624 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
3626 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3627 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3628 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
3629 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3631 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3632 context->scriptExecuteCallback = callback;
3633 context->ewkView = ewkView;
3634 context->userData = user_data;
3635 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
3636 WKPageRunJavaScriptInMainFrame(toAPI(impl->pageProxy.get()), scriptString.get(), context, runJavaScriptCallback);
3641 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3642 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
3644 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
3647 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
3649 storageContext->webStorageQuotaCallback(0, storageContext->userData);
3651 delete storageContext;
3655 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
3657 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3658 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3659 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
3660 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3661 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3662 TIZEN_LOGI("resultCallback (%p)", resultCallback);
3664 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3665 context->webStorageQuotaCallback = resultCallback;
3666 context->userData = userData;
3668 WKPageRef pageRef = toAPI(impl->page());
3669 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
3677 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
3679 #if ENABLE(TIZEN_WEB_STORAGE)
3680 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3681 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3682 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3684 TIZEN_LOGI("quota (%d)", quota);
3685 WKPageRef pageRef = toAPI(impl->page());
3686 WKPageSetWebStorageQuota(pageRef, quota);
3694 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
3696 EINA_SAFETY_ON_NULL_RETURN(context);
3697 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3699 ASSERT(callbackContext->plainTextGetCallback);
3702 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
3703 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3704 WKStringGetUTF8CString(plain_text, buffer.get(), length);
3706 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3708 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
3710 delete callbackContext;
3713 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
3715 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3716 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3717 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3718 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3720 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3721 context->plainTextGetCallback = callback;
3722 context->ewkView = ewkView;
3723 context->userData = user_data;
3724 WKPageGetContentsAsString(toAPI(impl->pageProxy.get()), context, getContentsAsStringCallback);
3729 #if ENABLE(TIZEN_SUPPORT_MHTML)
3732 * Callback function used for ewk_view_mhtml_data_get().
3734 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
3736 EINA_SAFETY_ON_NULL_RETURN(context);
3737 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3739 ASSERT(callbackContext->mhtmlDataGetCallback);
3741 callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
3743 delete callbackContext;
3746 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
3748 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3749 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3750 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3752 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3753 context->mhtmlDataGetCallback = callback;
3754 context->ewkView = ewkView;
3755 context->userData = user_data;
3757 WKPageGetContentsAsMHTMLData(toAPI(impl->page()), false, context, getContentsAsMHTMLCallback);
3761 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
3763 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
3765 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
3766 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3767 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3769 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
3770 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest, hitTestMode);
3771 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
3779 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
3781 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3782 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3783 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3784 WebPageProxy* page = impl->page();
3785 EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
3787 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
3790 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3795 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
3797 #if ENABLE(TIZEN_NOTIFICATIONS)
3798 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3799 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3800 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context, false);
3802 TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
3803 if (!eina_list_count(ewkNotifications))
3806 Eina_List* listIterator = 0;
3808 Vector<WKTypeRef> ids;
3809 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
3810 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
3811 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
3813 impl->notifications = eina_list_remove(impl->notifications, notification);
3816 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
3817 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(impl->context->wkContext());
3818 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
3819 ewkNotificationDeleteNotificationList(ewkNotifications);
3827 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3828 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
3830 Eina_List* popupItems = 0;
3831 size_t size = items.size();
3832 for (size_t i = 0; i < size; ++i)
3833 popupItems = eina_list_append(popupItems, Ewk_Popup_Menu_Item::create(items[i]).leakPtr());
3834 TIZEN_LOGI("size : %d", size);
3838 static void releasePopupMenuList(Eina_List* popupMenuItems)
3840 if (!popupMenuItems)
3844 EINA_LIST_FREE(popupMenuItems, item)
3845 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3849 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
3851 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3852 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3853 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
3855 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3858 if (!impl->popupMenuProxy)
3861 impl->popupMenuProxy = 0;
3863 if (smartData->api->popup_menu_hide)
3864 smartData->api->popup_menu_hide(smartData);
3865 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3866 ewk_view_touch_events_enabled_set(ewkView, true);
3868 releasePopupMenuList(impl->popupMenuItems);
3869 impl->popupMenuItems = 0;
3872 EINA_LIST_FREE(impl->popupMenuItems, item)
3873 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3879 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
3881 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3882 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3883 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3885 TIZEN_LOGI("proxy : %p / index : %d", impl->popupMenuProxy, selectedIndex);
3887 if (!impl->popupMenuItems)
3891 if (selectedIndex >= eina_list_count(impl->popupMenuItems))
3894 impl->popupMenuProxy->valueChanged(selectedIndex);
3899 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3900 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
3902 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3903 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3904 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3905 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3907 if (!impl->popupMenuProxy)
3910 if (!smartData->api->popup_menu_update)
3913 releasePopupMenuList(impl->popupMenuItems);
3914 impl->popupMenuItems = createPopupMenuList(items);
3916 // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
3917 smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), impl->popupMenuItems, selectedIndex);
3921 #if ENABLE(TIZEN_MULTIPLE_SELECT)
3922 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
3924 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3925 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3926 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3928 Vector<int> selectedIndex;
3930 if (!impl->popupMenuItems)
3935 itr = eina_inarray_iterator_new(changeList);
3936 EINA_ITERATOR_FOREACH(itr, data)
3938 int* pData = static_cast<int*>(data);
3939 selectedIndex.append(*pData);
3941 eina_iterator_free(itr);
3943 impl->popupMenuProxy->multipleValueChanged(selectedIndex);
3948 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
3950 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
3951 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3952 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3953 TIZEN_LOGI("orientation : %d", orientation);
3955 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
3958 if (impl->orientation == orientation)
3961 impl->orientation = orientation;
3963 impl->pageProxy->sendOrientationChangeEvent(orientation);
3967 void ewkViewFrameRendered(Evas_Object* ewkView)
3969 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
3972 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3973 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3975 return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
3978 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
3980 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3981 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3983 IntRect leftSelectionRect;
3984 IntRect rightSelectionRect;
3985 if (!impl->pageProxy->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
3998 AffineTransform contentToScreen = impl->transformToScene();
3999 leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
4000 rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
4002 leftRect->x = leftSelectionRect.x();
4003 leftRect->y = leftSelectionRect.y();
4004 leftRect->w = leftSelectionRect.width();
4005 leftRect->h = leftSelectionRect.height();
4007 rightRect->x = rightSelectionRect.x();
4008 rightRect->y = rightSelectionRect.y();
4009 rightRect->w = rightSelectionRect.width();
4010 rightRect->h = rightSelectionRect.height();
4015 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
4017 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4018 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
4020 const CString selectedString = impl->pageProxy->getSelectionText().utf8();
4021 impl->selectedText = selectedString.data();
4023 return impl->selectedText;
4026 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
4028 return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
4031 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
4033 return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
4036 Eina_Bool ewk_view_text_selection_range_clear(Evas_Object* ewkView)
4038 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4039 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4041 bool isTextSelectionMode = impl->pageClient->isTextSelectionMode();
4042 impl->pageClient->setIsTextSelectionMode(false);
4043 return isTextSelectionMode;
4045 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4047 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4048 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
4050 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4051 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4052 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
4054 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
4058 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
4059 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
4061 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4062 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4063 IntPoint drawingPosition = (IntPoint)(impl->pageClient->visibleContentRect().location() - impl->pageClient->scrollPosition());
4065 *x = drawingPosition.x();
4067 *y = drawingPosition.y();
4069 *w = impl->pageClient->visibleContentRect().width();
4071 *h = impl->pageClient->visibleContentRect().height();
4075 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
4077 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4078 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4079 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4081 impl->pageProxy->setFocusedInputElementValue(String::fromUTF8(value));
4082 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4085 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
4087 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4088 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4089 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
4091 impl->inputValue = impl->pageProxy->getFocusedInputElementValue().utf8().data();
4092 return impl->inputValue;
4095 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4098 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4099 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
4101 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4102 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4103 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4104 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
4107 ewkViewDataListHideRequest(ewkView, inputType);
4109 for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
4111 impl->dataList = eina_list_append(impl->dataList, eina_stringshare_add(value.utf8().data()));
4114 smartData->api->data_list_show(smartData, inputType, impl->dataList);
4117 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
4119 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4120 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4121 EINA_SAFETY_ON_NULL_RETURN(impl->dataList);
4122 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4123 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
4125 impl->deleteDataList();
4127 smartData->api->data_list_hide(smartData, inputType);
4131 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
4133 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4134 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4135 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4137 impl->deleteDataList();
4139 ewk_view_focused_input_element_value_set(ewkView, value);
4143 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
4145 #if ENABLE(TIZEN_GESTURE)
4146 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4147 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4148 return impl->holdHorizontalPanning;
4154 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4156 #if ENABLE(TIZEN_GESTURE)
4157 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4158 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4159 impl->holdHorizontalPanning = hold;
4163 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
4165 #if ENABLE(TIZEN_GESTURE)
4166 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4167 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4168 return impl->holdVerticalPanning;
4174 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4176 #if ENABLE(TIZEN_GESTURE)
4177 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4178 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4179 impl->holdVerticalPanning = hold;
4183 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
4185 #if ENABLE(TIZEN_GESTURE)
4186 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4187 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4189 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4190 if (impl->focusRing() && wasHandled)
4191 impl->focusRing()->hide();
4192 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4194 if (impl->mouseEventsEnabled())
4197 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4198 if (wasHandled && impl->pageClient->isTextSelectionMode()) {
4199 if (type == WebEvent::TouchStart)
4200 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4201 else if (type == WebEvent::TouchMove)
4202 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4203 else if (type == WebEvent::TouchEnd)
4204 impl->pageClient->requestToShowTextSelectionHandlesAndContextMenu();
4208 // We have to check TouchStart, TouchMove and TouchEnd with handled.
4209 // The Pan and Flick will be enabled if Touch Start was not handled,
4210 // and Touch Move was not handled or did not occur.
4211 // Tap will be enabled if Touch Start and End was not handled
4212 // and Touch Move did not occur.
4213 // The gestures are disabled as a default.
4214 // o: handled, x: not handled
4215 // ------------------------------------------------------------
4216 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
4217 // ------------------------------------------------------------
4218 // o | o or x | o or x || disable | disable
4219 // x | o | o or x || disable | disable
4220 // x | x | o or x || disable | enable
4221 // x |not occured | x || enable | enable
4222 // ------------------------------------------------------------
4223 if (type == WebEvent::TouchStart) {
4224 impl->gestureClient->setGestureEnabled(!wasHandled);
4225 impl->wasHandledTouchStart = wasHandled;
4227 // Initialize wasHandledTouchMove to true and notify that to the application
4228 // to prevent applications scrolling at the beginning of touch.
4229 impl->wasHandledTouchMove = true;
4230 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&impl->wasHandledTouchMove));
4231 } else if (type == WebEvent::TouchMove) {
4232 impl->gestureClient->setMovingEnabled(!wasHandled);
4234 // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
4235 if (impl->wasHandledTouchStart)
4238 // Notify the result of touchmove to applications when handled value is changed
4239 // in order to make applications to choose whether scrolling its scrollable objects or not.
4240 if (impl->wasHandledTouchMove != wasHandled)
4241 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
4242 impl->wasHandledTouchMove = wasHandled;
4243 } else if (type == WebEvent::TouchEnd && !impl->exceedTouchMoveThreshold) {
4245 impl->gestureClient->setMovingEnabled(!wasHandled);
4246 impl->gestureClient->setTapEnabled(!wasHandled);
4248 #if ENABLE(TIZEN_ISF_PORT)
4249 else if (impl->pageProxy->isViewVisible()) {
4250 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(impl->touchDownPoint.x, impl->touchDownPoint.y));
4251 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest);
4252 if (hitTestResultData.isContentEditable && impl->inputMethodContext()) {
4253 evas_object_focus_set(ewkView, true);
4254 impl->inputMethodContext()->updateTextInputState();
4262 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
4263 void ewkViewTextStyleState(Evas_Object* ewkView, const IntPoint& startPoint, const IntPoint& endPoint)
4265 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4266 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4268 EditorState editorState = impl->page()->editorState();
4269 Ewk_Text_Style* textStyle = ewkTextStyleCreate(editorState, startPoint, endPoint);
4270 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
4271 ewkTextStyleDelete(textStyle);
4275 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
4276 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
4278 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4279 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4281 TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
4282 if (!smartData->api->orientation_lock) {
4287 return smartData->api->orientation_lock(smartData, willLockOrientation);
4290 void ewk_view_orientation_unlock(Evas_Object* ewkView)
4292 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4293 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4295 TIZEN_LOGI("ewkView (%p)", ewkView);
4296 if (!smartData->api->orientation_unlock) {
4301 smartData->api->orientation_unlock(smartData);
4305 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
4307 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4308 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4309 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4310 TIZEN_LOGI("callbacks: %p / data: %p", func, data);
4312 impl->orientationLock.callback = func;
4313 impl->orientationLock.data = data;
4317 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4318 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
4320 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
4321 TIZEN_LOGI("locked orientations : %d", orientations);
4323 if (impl->orientationLock.callback)
4324 return impl->orientationLock.callback(sd->self, true, orientations, impl->orientationLock.data);
4329 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
4331 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4332 TIZEN_LOGI("unlock is requested");
4334 if (impl->orientationLock.callback)
4335 impl->orientationLock.callback(sd->self, false, 0, impl->orientationLock.data);
4339 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
4340 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
4342 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4344 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
4345 const char *engine = ecore_evas_engine_name_get(ee);
4346 if (engine && !strcmp(engine, "opengl_x11"))
4352 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
4354 #if ENABLE(TIZEN_GESTURE)
4355 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4356 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4358 impl->gestureClient->setZoomableArea(target, area);
4362 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
4363 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
4365 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4366 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4368 WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(impl->pageProxy.get())));
4372 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
4373 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
4375 evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
4379 #if ENABLE(TIZEN_ICON_DATABASE)
4380 void ewkViewIconReceived(Evas_Object* ewkView)
4384 evas_object_smart_callback_call(ewkView, "icon,received", 0);
4388 #endif // #if OS(TIZEN)
4390 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
4392 #if ENABLE(TOUCH_EVENTS)
4393 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
4394 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4395 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4397 #if ENABLE(TIZEN_FOCUS_UI)
4398 if (type == EWK_TOUCH_START)
4399 impl->page()->setSpatialNavigationEnabled(false);
4402 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
4403 if (impl->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
4404 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4405 IntPoint handlePoint(point->x, point->y);
4407 if (type == EWK_TOUCH_START)
4408 impl->pageClient->textSelectonHandleDown(handlePoint);
4409 else if (type == EWK_TOUCH_MOVE)
4410 impl->pageClient->textSelectonHandleMove(handlePoint);
4412 impl->pageClient->textSelectonHandleUp();
4414 if (impl->pageClient->isTextSelectionHandleDowned())
4419 #if ENABLE(TIZEN_GESTURE)
4420 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
4421 // We don't want to process touch event when context menu is shown.
4422 if ((impl->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
4423 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4424 && !impl->pageClient->isTextSelectionMode()
4429 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4430 if (impl->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
4434 if (type == EWK_TOUCH_START) {
4435 if (eina_list_count(points) == 1) {
4436 impl->gestureClient->reset();
4437 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4438 impl->touchDownPoint.x = point->x;
4439 impl->touchDownPoint.y = point->y;
4440 impl->exceedTouchMoveThreshold = false;
4442 } else if (type == EWK_TOUCH_MOVE && !impl->exceedTouchMoveThreshold) {
4443 if (eina_list_count(points) == 1) {
4444 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
4445 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4446 int diffX = impl->touchDownPoint.x - point->x;
4447 int diffY = impl->touchDownPoint.y - point->y;
4448 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
4449 impl->exceedTouchMoveThreshold = true;
4453 impl->exceedTouchMoveThreshold = true;
4456 #endif // #if ENABLE(TIZEN_GESTURE)
4458 // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
4459 //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4460 impl->pageProxy->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4468 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
4470 #if ENABLE(TOUCH_EVENTS)
4471 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4472 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4474 impl->setTouchEventsEnabled(!!enabled);
4482 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
4484 #if ENABLE(TOUCH_EVENTS)
4485 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4486 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4488 return impl->touchEventsEnabled();
4494 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
4496 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4497 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4498 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4500 impl->mainFrameScrollbarVisibility = visible;
4501 impl->pageClient->updateVisibility();
4509 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
4511 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4512 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4513 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4515 return impl->mainFrameScrollbarVisibility;
4521 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
4523 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
4524 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4525 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4526 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
4528 String title = ewk_view_title_get(ewkView);
4529 String url = ewk_view_url_get(ewkView);
4530 String directoryPath(path);
4531 impl->pageClient->startOfflinePageSave(directoryPath, url, title);
4535 UNUSED_PARAM(ewkView);
4543 * Callback function used for ewk_view_page_contents_get().
4545 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4547 EINA_SAFETY_ON_NULL_RETURN(context);
4549 RefPtr<WebData> webData = toImpl(wkData);
4550 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4551 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
4556 * Callback function used for ewk_view_page_contents_get().
4558 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
4560 EINA_SAFETY_ON_NULL_RETURN(context);
4562 RefPtr<WebString> webString = toImpl(wkString);
4563 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4564 contentsContext->callback(contentsContext->type, webString->string().utf8().data());
4567 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
4569 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
4570 EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
4571 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4572 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4574 switch (context->type) {
4575 case EWK_PAGE_CONTENTS_TYPE_MHTML:
4576 impl->pageProxy->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
4579 case EWK_PAGE_CONTENTS_TYPE_STRING:
4580 impl->pageProxy->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
4584 ASSERT_NOT_REACHED();
4591 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
4593 #if ENABLE(TIZEN_GESTURE)
4594 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4595 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4597 return impl->gestureClient->scrollToWithAnimation(x, y);
4599 UNUSED_PARAM(ewkView);
4606 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
4608 #if ENABLE(TIZEN_CSP)
4609 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
4610 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4612 TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
4613 impl->pageProxy->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));
4617 #if ENABLE(TIZEN_APPLICATION_CACHE)
4618 Eina_Bool ewkViewRequestApplicationCachePermission(Evas_Object* ewkView, WKSecurityOriginRef origin)
4620 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4621 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4623 if (!impl->applicationCachePermissionContext || !impl->applicationCachePermissionContext->applicationCachePermissionCallback)
4626 impl->isWaitingForApplicationCachePermission = true;
4627 if (impl->applicationCachePermissionOrigin)
4628 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4629 impl->applicationCachePermissionOrigin = createSecurityOrigin(origin);
4631 return impl->applicationCachePermissionContext->applicationCachePermissionCallback(ewkView, impl->applicationCachePermissionOrigin, impl->applicationCachePermissionContext->userData) == EINA_TRUE;
4635 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
4637 #if ENABLE(TIZEN_APPLICATION_CACHE)
4638 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4639 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4641 if (!impl->applicationCachePermissionContext)
4642 impl->applicationCachePermissionContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4643 impl->applicationCachePermissionContext->applicationCachePermissionCallback = callback;
4644 impl->applicationCachePermissionContext->userData = userData;
4646 UNUSED_PARAM(ewkView);
4647 UNUSED_PARAM(callback);
4648 UNUSED_PARAM(userData);
4652 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
4654 #if ENABLE(TIZEN_APPLICATION_CACHE)
4655 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4656 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4658 TIZEN_LOGI("allow %d", allow);
4659 WKPageReplyApplicationCachePermission(toAPI(impl->page()), allow);
4660 if (impl->applicationCachePermissionOrigin)
4661 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4662 impl->applicationCachePermissionOrigin = 0;
4663 impl->isWaitingForApplicationCachePermission = false;
4665 UNUSED_PARAM(ewkView);
4666 UNUSED_PARAM(allow);
4670 #if ENABLE(TIZEN_INDEXED_DATABASE)
4671 bool ewkViewExceededIndexedDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4673 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4674 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4676 if (!impl->exceededIndexedDatabaseQuotaContext || !impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback)
4679 impl->isWaitingForExceededQuotaPopupReply = true;
4680 if (impl->exceededQuotaOrigin)
4681 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4682 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4684 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4686 return impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, currentUsage, impl->exceededIndexedDatabaseQuotaContext->userData) == EINA_TRUE;
4690 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4692 #if ENABLE(TIZEN_INDEXED_DATABASE)
4693 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4694 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4696 if (!impl->exceededIndexedDatabaseQuotaContext)
4697 impl->exceededIndexedDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4698 impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback = callback;
4699 impl->exceededIndexedDatabaseQuotaContext->userData = userData;
4701 UNUSED_PARAM(ewkView);
4702 UNUSED_PARAM(callback);
4703 UNUSED_PARAM(userData);
4707 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4709 #if ENABLE(TIZEN_INDEXED_DATABASE)
4710 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4711 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4713 TIZEN_LOGI("allow %d", allow);
4714 WKPageReplyExceededIndexedDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4715 if (impl->exceededQuotaOrigin)
4716 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4717 impl->exceededQuotaOrigin = 0;
4718 impl->isWaitingForExceededQuotaPopupReply = false;
4720 UNUSED_PARAM(ewkView);
4721 UNUSED_PARAM(allow);
4725 // EwkFindOptions should be matched up orders with WkFindOptions.
4726 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_CASE_INSENSITIVE, kWKFindOptionsCaseInsensitive);
4727 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_AT_WORD_STARTS, kWKFindOptionsAtWordStarts);
4728 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, kWKFindOptionsTreatMedialCapitalAsWordStart);
4729 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_BACKWARDS, kWKFindOptionsBackwards);
4730 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_WRAP_AROUND, kWKFindOptionsWrapAround);
4731 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_OVERLAY, kWKFindOptionsShowOverlay);
4732 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR, kWKFindOptionsShowFindIndicator);
4733 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShowHighlight);
4735 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4737 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4738 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4739 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4741 impl->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4746 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4748 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4749 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4751 impl->pageProxy->hideFindUI();
4756 Eina_Bool ewk_view_text_matches_count(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4758 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4759 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4760 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4762 impl->pageProxy->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4767 void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData)
4769 #if ENABLE(TIZEN_SQL_DATABASE)
4770 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4771 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4773 if (!impl->exceededDatabaseQuotaContext)
4774 impl->exceededDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4775 impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback = callback;
4776 impl->exceededDatabaseQuotaContext->userData = userData;
4778 UNUSED_PARAM(ewkView);
4779 UNUSED_PARAM(callback);
4780 UNUSED_PARAM(userData);
4784 void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4786 #if ENABLE(TIZEN_SQL_DATABASE)
4787 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4788 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4790 TIZEN_LOGI("allow %d", allow);
4791 WKPageReplyExceededDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4792 if (impl->exceededQuotaOrigin)
4793 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4794 impl->exceededQuotaOrigin = 0;
4795 impl->isWaitingForExceededQuotaPopupReply = false;
4797 UNUSED_PARAM(ewkView);
4798 UNUSED_PARAM(allow);
4802 #if ENABLE(TIZEN_FILE_SYSTEM)
4803 bool ewkViewExceededLocalFileSystemQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4805 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4806 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4808 if (!impl->exceededLocalFileSystemQuotaContext || !impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback)
4811 impl->isWaitingForExceededQuotaPopupReply = true;
4812 if (impl->exceededQuotaOrigin)
4813 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4814 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4816 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4818 return impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback(ewkView, impl->exceededQuotaOrigin , currentUsage, impl->exceededLocalFileSystemQuotaContext->userData) == EINA_TRUE;
4822 void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4824 #if ENABLE(TIZEN_FILE_SYSTEM)
4825 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4826 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4828 if (!impl->exceededLocalFileSystemQuotaContext)
4829 impl->exceededLocalFileSystemQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4830 impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback = callback;
4831 impl->exceededLocalFileSystemQuotaContext->userData = userData;
4833 UNUSED_PARAM(ewkView);
4834 UNUSED_PARAM(callback);
4835 UNUSED_PARAM(userData);
4839 void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4841 #if ENABLE(TIZEN_FILE_SYSTEM)
4842 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4843 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4845 TIZEN_LOGI("allow %d", allow);
4846 WKPageReplyExceededLocalFileSystemQuota(toAPI(impl->page()), allow == EINA_TRUE);
4847 if (impl->exceededQuotaOrigin)
4848 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4849 impl->exceededQuotaOrigin = 0;
4850 impl->isWaitingForExceededQuotaPopupReply = false;
4852 UNUSED_PARAM(ewkView);
4853 UNUSED_PARAM(result);
4857 void ewk_view_rotation_prepare(Evas_Object* ewkView, int angle)
4859 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4860 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4861 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4864 if (angle == 0 || angle == 180) {
4865 width = WebCore::getDefaultScreenResolution().width();
4866 height = WebCore::getDefaultScreenResolution().height() + 100;
4868 if (angle == 90 || angle == 270) {
4869 width = WebCore::getDefaultScreenResolution().height();
4870 height = WebCore::getDefaultScreenResolution().width() + 100;
4873 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
4874 impl->pageClient->setWaitFrameOfNewViewortSize(true);
4875 ewk_view_suspend(ewkView);
4876 impl->pageClient->updateViewportSize(IntSize(width, height), angle);
4880 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4881 void ewkViewRotatePrepared(Evas_Object* ewkView)
4883 evas_object_smart_callback_call(ewkView, "rotate,prepared", 0);
4887 void ewk_view_use_settings_font(Evas_Object* ewkView)
4889 #if ENABLE(TIZEN_USE_SETTINGS_FONT)
4890 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4891 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4893 impl->pageProxy->useSettingsFont();
4897 void ewk_view_fullscreen_exit(Evas_Object* ewkView)
4899 #if ENABLE(TIZEN_FULLSCREEN_API)
4902 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4903 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4905 if (!impl->pageProxy->fullScreenManager()->isFullScreen())
4908 impl->pageProxy->fullScreenManager()->requestExitFullScreen();
4910 UNUSED_PARAM(ewkView);
4914 Eina_Bool ewk_view_draws_transparent_background_set(Evas_Object* ewkView, Eina_Bool enabled)
4916 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4917 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4919 impl->pageProxy->setDrawsTransparentBackground(enabled);
4920 evas_object_image_alpha_set(smartData->image, enabled);
4925 Eina_Bool ewk_view_draws_transparent_background_get(Evas_Object* ewkView)
4927 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4928 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4930 return impl->pageProxy->drawsTransparentBackground();