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"
162 #endif // #if OS(TIZEN)
164 using namespace WebKit;
165 using namespace WebCore;
167 static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
169 #define EWK_VIEW_TYPE_CHECK(ewkView, result) \
170 bool result = true; \
173 EINA_LOG_CRIT("null is not a ewk_view"); \
177 const char* _tmp_otype = evas_object_type_get(ewkView); \
178 const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
179 if (EINA_UNLIKELY(!_tmp_s)) { \
181 ("%p (%s) is not a smart object!", \
182 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
186 const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
187 if (EINA_UNLIKELY(!_tmp_sc)) { \
189 ("%p (%s) is not a smart object!", \
190 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
194 else if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \
196 ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
197 ewkView, _tmp_otype ? _tmp_otype : "(null)", \
198 EWK_VIEW_TYPE_STR, _tmp_sc->data); \
203 #define EWK_VIEW_SD_GET(ewkView, smartData) \
204 EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \
205 Ewk_View_Smart_Data* smartData = 0; \
207 smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView)
209 #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \
210 EWK_VIEW_SD_GET(ewkView, smartData); \
213 EINA_LOG_CRIT("no smart data for object %p (%s)", \
214 ewkView, evas_object_type_get(ewkView)); \
215 return __VA_ARGS__; \
220 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object*, const char* alertText, void* userData);
221 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object*, const char* message, void* userData);
222 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object*, const char* message, const char* defaultValue, void* userData);
223 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
224 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object*, const char* message, void* userData);
226 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);
228 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
229 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);
230 #if ENABLE(TIZEN_MULTIPLE_SELECT)
231 Eina_Bool _ewk_view_multiple_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items);
233 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data*);
234 Eina_Bool _ewk_view_popup_menu_update(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, Eina_List*, int);
236 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
237 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations);
238 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd);
241 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
242 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data*, Ewk_Input_Type, const char* inputValue);
245 #if ENABLE(TIZEN_DATALIST_ELEMENT)
246 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data*, Ewk_Input_Type, Eina_List*);
247 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data*, Ewk_Input_Type);
250 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
251 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data*, int, int, int, int);
252 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data*);
254 #endif // #if OS(TIZEN)
256 static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
258 if (smartData->changed.any)
260 smartData->changed.any = true;
261 evas_object_smart_changed(smartData->self);
264 #if !ENABLE(TIZEN_ICON_DATABASE)
265 static void _ewk_view_on_favicon_changed(const char* pageURL, void* eventInfo)
267 Evas_Object* ewkView = static_cast<Evas_Object*>(eventInfo);
268 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
269 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
271 const char* viewURL = ewk_view_url_get(ewkView);
272 if (!viewURL || strcasecmp(viewURL, pageURL))
275 impl->informIconChange();
279 // Default Event Handling.
280 static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
282 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
286 impl->pageClient->setViewFocused(true);
287 #endif // #if OS(TIZEN)
288 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
289 #if ENABLE(TIZEN_ISF_PORT)
290 if (impl->inputMethodContext())
291 impl->inputMethodContext()->onFocusIn();
296 static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
298 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
302 #if ENABLE(TIZEN_ISF_PORT)
303 // Keypad should be hidden rapidly when moving focus on elementary
304 // because Ecore-ime doesn't support it.
305 if (impl->inputMethodContext())
306 impl->inputMethodContext()->onFocusOut();
309 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
310 if (impl->pageClient->isTextSelectionMode())
311 impl->pageClient->setIsTextSelectionMode(false);
314 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
315 if (impl->pageClient->isContextMenuVisible())
316 impl->pageProxy->hideContextMenu();
319 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
320 if (impl->pageClient->isClipboardWindowOpened())
321 impl->pageClient->closeClipboardWindow();
324 #if ENABLE(TIZEN_DRAG_SUPPORT)
325 if (impl->pageClient->isDragMode())
326 impl->pageClient->setDragMode(false);
329 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
330 if (smartData->api->formdata_candidate_is_showing(smartData))
331 smartData->api->formdata_candidate_hide(smartData);
334 impl->pageClient->setViewFocused(false);
335 #endif // #if OS(TIZEN)
336 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
340 static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
342 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
344 impl->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
348 static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
350 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
352 impl->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
356 static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
358 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
360 impl->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
362 InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
363 if (inputMethodContext)
364 inputMethodContext->handleMouseUpEvent(upEvent);
369 static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
371 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
373 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
374 impl->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
378 static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
380 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
382 bool isFiltered = false;
383 InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
384 if (inputMethodContext)
385 inputMethodContext->handleKeyDownEvent(downEvent, &isFiltered);
387 impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, isFiltered));
391 static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
393 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
395 impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
400 static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
402 #if ENABLE(TIZEN_GESTURE)
403 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
405 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
406 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
410 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
411 if (impl->focusRing) {
412 if (event->type == EWK_GESTURE_TAP && event->count == 1) {
413 impl->focusRing->requestToShow(IntPoint(event->position.x, event->position.y));
414 } else if (event->type == EWK_GESTURE_PAN) {
415 if (impl->exceedTouchMoveThreshold)
416 impl->focusRing->requestToHide();
418 if (event->type != EWK_GESTURE_LONG_PRESS) {
419 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
420 if (!impl->pageClient->isContextMenuVisible())
422 impl->focusRing->requestToHide();
428 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
429 if (smartData->api->formdata_candidate_is_showing(smartData))
430 smartData->api->formdata_candidate_hide(smartData);
433 switch (event->type) {
434 case EWK_GESTURE_TAP:
435 impl->gestureClient->startTap(IntPoint(event->position.x, event->position.y));
437 case EWK_GESTURE_LONG_PRESS: {
438 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
439 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
440 if (ewk_settings_text_selection_enabled_get(impl->settings()))
441 impl->pageClient->setIsTextSelectionMode(false);
443 IntPoint scenePoint(event->position.x, event->position.y);
444 IntPoint contentsPoint = impl->transformFromScene().mapPoint(scenePoint);
445 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(contentsPoint);
446 if (!hitTestResultData.absoluteMediaURL.isEmpty())
448 #if ENABLE(TIZEN_DRAG_SUPPORT)
449 // 1. Check to start dragging.
450 if (hitTestResultData.isDragSupport && !hitTestResultData.isContentEditable) {
451 impl->pageClient->setDragPoint(scenePoint);
452 if (impl->pageClient->isDragMode()) {
453 impl->pageClient->setDragMode(false);
455 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
457 impl->focusRing->show(IntRect(), true);
459 impl->gestureClient->showContextMenu(scenePoint);
463 // 2. Check to show context menu.
464 if ((!hitTestResultData.absoluteImageURL.isEmpty() || !hitTestResultData.absoluteLinkURL.isEmpty())
465 && !hitTestResultData.isContentEditable) {
466 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
468 impl->focusRing->show(IntRect(), true);
470 impl->gestureClient->showContextMenu(scenePoint);
473 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
474 // 3. Check for text selection.
475 if (ewk_settings_text_selection_enabled_get(impl->settings())) {
476 // Process gesture_end(EWK_GESTURE_TAP) to activate the editing if node under point is editable.
477 if (hitTestResultData.context & WebHitTestResult::HitTestResultContextEditable) {
478 if (smartData->api && smartData->api->gesture_end) {
479 Ewk_Event_Gesture tapEvent = {EWK_GESTURE_TAP, event->position, {0, 0}, 0, 1, ecore_time_get() * 1000};
480 smartData->api->gesture_end(smartData, &tapEvent);
484 if (impl->pageClient->textSelectionDown(scenePoint)) {
485 impl->gestureClient->setGestureEnabled(false);
486 impl->feedTouchEventsByType(EWK_TOUCH_CANCEL);
491 #endif // #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
493 case EWK_GESTURE_PAN:
494 impl->gestureClient->startPan(IntPoint(event->position.x, event->position.y));
496 case EWK_GESTURE_FLICK:
497 impl->gestureClient->startFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
499 case EWK_GESTURE_PINCH:
500 if (impl->pageClient->viewportConstraints().userScalable)
501 impl->gestureClient->startPinch(IntPoint(event->position.x, event->position.y), event->scale);
504 ASSERT_NOT_REACHED();
511 #endif // #if ENABLE(TIZEN_GESTURE)
514 static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
516 #if ENABLE(TIZEN_GESTURE)
517 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
519 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
520 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
524 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
525 if (impl->focusRing) {
526 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
527 if (!impl->pageClient->isContextMenuVisible() || impl->pageClient->isTextSelectionMode())
529 impl->focusRing->requestToHide();
533 switch (event->type) {
534 case EWK_GESTURE_TAP:
535 if (event->count == 1) {
536 #if ENABLE(TIZEN_DRAG_SUPPORT)
537 if (impl->pageClient->isDragMode())
538 impl->pageClient->setDragMode(false);
540 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
541 if (impl->pageClient->isTextSelectionMode())
542 impl->pageClient->setIsTextSelectionMode(false);
545 #if ENABLE(TIZEN_ISF_PORT)
546 if (impl->inputMethodContext()->isIMEPostion(event->position.x, event->position.y))
550 impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
551 } else if (event->count == 2)
552 impl->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
554 case EWK_GESTURE_LONG_PRESS:
555 // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
556 impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
558 case EWK_GESTURE_PAN:
559 impl->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
561 case EWK_GESTURE_FLICK:
562 impl->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
564 case EWK_GESTURE_PINCH:
565 impl->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
568 ASSERT_NOT_REACHED();
575 #endif // #if ENABLE(TIZEN_GESTURE)
578 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
580 #if ENABLE(TIZEN_GESTURE)
581 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
583 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
584 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
588 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
589 if (impl->focusRing && !(event->type == EWK_GESTURE_PAN && !impl->exceedTouchMoveThreshold)) {
590 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
591 if (!impl->pageClient->isContextMenuVisible())
593 impl->focusRing->requestToHide(true);
597 switch (event->type) {
598 case EWK_GESTURE_PAN:
599 impl->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
601 case EWK_GESTURE_TAP:
602 case EWK_GESTURE_LONG_PRESS:
603 case EWK_GESTURE_FLICK:
605 case EWK_GESTURE_PINCH:
606 if (impl->pageClient->viewportConstraints().userScalable)
607 impl->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
610 ASSERT_NOT_REACHED();
617 #endif // #if ENABLE(TIZEN_GESTURE)
619 #endif //#if OS(TIZEN)
622 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
624 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
625 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
626 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
627 smartData->api->focus_in(smartData);
630 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
632 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
633 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
634 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
635 smartData->api->focus_out(smartData);
638 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
640 Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
641 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
642 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
643 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
644 smartData->api->mouse_wheel(smartData, wheelEvent);
647 static void _ewk_view_on_key_down(void* data, Evas*, Evas_Object*, void* eventInfo)
649 Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
650 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
651 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
652 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
653 smartData->api->key_down(smartData, downEvent);
656 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
658 Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
659 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
660 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
661 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
662 smartData->api->key_up(smartData, upEvent);
665 static void _ewk_view_on_show(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
667 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
668 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
669 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
672 static void _ewk_view_on_hide(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
674 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
675 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
677 // This call may look wrong, but we really need to pass ViewIsVisible here.
678 // viewStateDidChange() itself is responsible for actually setting the visibility to Visible or Hidden
679 // depending on what WebPageProxy::isViewVisible() returns, this simply triggers the process.
680 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
685 #if ENABLE(TIZEN_FULLSCREEN_API)
686 Eina_Bool _ewk_view_smart_fullscreen_enter(Ewk_View_Smart_Data* smartData)
688 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
690 ewk_view_main_frame_scrollbar_visible_set(impl->view(), false);
691 evas_object_smart_callback_call(impl->view(), "fullscreen,enterfullscreen", 0);
695 Eina_Bool _ewk_view_smart_fullscreen_exit(Ewk_View_Smart_Data* smartData)
697 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
699 ewk_view_main_frame_scrollbar_visible_set(impl->view(), true);
700 evas_object_smart_callback_call(impl->view(), "fullscreen,exitfullscreen", 0);
705 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
706 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
708 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
710 return impl->pageClient->textSelectionDown(IntPoint(x, y));
713 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
715 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
717 IntPoint point(x, y);
718 impl->pageClient->textSelectionMove(point);
723 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
725 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
727 IntPoint point(x, y);
728 impl->pageClient->textSelectionUp(point, true);
734 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
735 Eina_Bool _ewk_view_smart_formdata_candidate_show(Ewk_View_Smart_Data* smartData, int x, int y, int w, int h)
737 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
739 impl->pageClient->showFormDataCandidate(IntRect(x, y, w, h));
744 Eina_Bool _ewk_view_smart_formdata_candidate_hide(Ewk_View_Smart_Data* smartData)
746 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
748 impl->pageClient->hideFormDataCandidate();
753 Eina_Bool _ewk_view_smart_formdata_candidate_update_data(Ewk_View_Smart_Data* smartData, Eina_List* dataList)
755 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
757 Vector<String> formData;
760 EINA_LIST_FOREACH(dataList, list, data)
761 formData.append(String::fromUTF8(static_cast<char*>(data)));
763 impl->pageClient->updateFormDataCandidate(formData);
768 Eina_Bool _ewk_view_smart_formdata_candidate_is_showing(Ewk_View_Smart_Data* smartData)
770 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
772 return impl->pageClient->isShowingFormDataCandidate();
776 #if ENABLE(TIZEN_SCREEN_READER)
777 Eina_Bool _ewk_view_screen_reader_action_execute(Ewk_View_Smart_Data* smartData, void* actionInfo)
779 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
781 return ScreenReaderProxy::executeAction(impl, 0, static_cast<Elm_Access_Action_Info*>(actionInfo));
784 #endif // #if OS(TIZEN)
786 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
788 static void _ewk_view_impl_del(EwkViewImpl* impl)
790 #if !ENABLE(TIZEN_ICON_DATABASE)
791 /* Unregister icon change callback */
792 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
793 iconDatabase->unwatchChanges(_ewk_view_on_favicon_changed);
799 static void _ewk_view_smart_add(Evas_Object* ewkView)
801 const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
802 const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
803 const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
804 EWK_VIEW_SD_GET(ewkView, smartData);
807 smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
809 EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
812 evas_object_smart_data_set(ewkView, smartData);
815 smartData->self = ewkView;
816 smartData->api = api;
818 g_parentSmartClass.add(ewkView);
820 smartData->priv = new EwkViewImpl(ewkView);
821 if (!smartData->priv) {
822 EINA_LOG_CRIT("could not allocate EwkViewImpl");
823 evas_object_smart_data_set(ewkView, 0);
828 // Create evas_object_image to draw web contents.
829 smartData->image = evas_object_image_add(smartData->base.evas);
830 evas_object_image_alpha_set(smartData->image, false);
831 evas_object_image_filled_set(smartData->image, true);
832 evas_object_smart_member_add(smartData->image, ewkView);
835 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
836 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
837 const char *engine = ecore_evas_engine_name_get(ee);
838 if (engine && !strcmp(engine, "opengl_x11"))
839 evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
841 ewk_view_mouse_events_enabled_set(ewkView, false);
842 ewk_view_touch_events_enabled_set(ewkView, true);
844 // FIXME: This code should be removed if side effect occur.
845 // WebView does not have focus after url loading.
846 // If focus is set as true to webview,
847 // elementary steal webview's focus during mouse up event
848 // So, added code that events are not propagated to smart parent according to guide from EFL
849 evas_object_propagate_events_set(ewkView, false);
850 #endif // #if OS(TIZEN)
852 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
853 CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
854 CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
855 CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
856 CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
857 CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
858 CONNECT(EVAS_CALLBACK_SHOW, _ewk_view_on_show);
859 CONNECT(EVAS_CALLBACK_HIDE, _ewk_view_on_hide);
863 static void _ewk_view_smart_del(Evas_Object* ewkView)
865 EwkViewImpl::removeFromPageViewMap(ewkView);
866 EWK_VIEW_SD_GET(ewkView, smartData);
867 #if ENABLE(TIZEN_SCREEN_READER)
868 ScreenReaderProxy::screenReader().finalize(smartData->priv);
870 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
871 // Close color picker if it's opened.
872 if (smartData && smartData->priv && smartData->priv->inputPicker->isColorPickerShown())
873 ewk_view_color_picker_color_set(ewkView, 0, 0, 0, 0);
875 if (smartData && smartData->priv)
876 _ewk_view_impl_del(smartData->priv);
878 g_parentSmartClass.del(ewkView);
881 static Eina_Bool _ewk_view_composite(void* data);
883 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
885 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
887 evas_object_resize(smartData->image, width, height);
888 evas_object_image_size_set(smartData->image, width, height);
889 evas_object_image_fill_set(smartData->image, 0, 0, width, height);
891 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
892 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
893 evas_object_image_native_surface_set(smartData->image, 0);
895 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
896 if (impl->pageClient->isVisible()) {
897 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
898 impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee));
900 impl->pageClient->setDeferUpdateViewportSize(true);
902 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
903 impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee));
906 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
907 if (!ewk_view_is_opengl_backend(ewkView))
908 _ewk_view_composite(smartData);
909 else // OpenGL backend
911 impl->pageClient->displayViewport();
913 #endif // #if OS(TIZEN)
915 smartData->changed.size = true;
916 _ewk_view_smart_changed(smartData);
919 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
921 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
923 smartData->changed.position = true;
924 _ewk_view_smart_changed(smartData);
927 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
929 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
930 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
932 Evas_Coord x, y, width, height;
934 smartData->changed.any = false;
936 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
938 if (smartData->changed.size) {
940 #if USE(COORDINATED_GRAPHICS)
941 impl->pageViewportControllerClient->updateViewportSize(IntSize(width, height));
943 #if USE(ACCELERATED_COMPOSITING)
944 needsNewSurface = impl->evasGlSurface;
947 if (impl->pageProxy->drawingArea())
948 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
950 #if USE(ACCELERATED_COMPOSITING)
951 if (!impl->evasGlSurface)
953 evas_gl_surface_destroy(impl->evasGl, impl->evasGlSurface);
954 impl->evasGlSurface = 0;
955 ewk_view_create_gl_surface(ewkView, IntSize(width, height));
956 ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
958 #endif // #if !OS(TIZEN)
960 smartData->view.w = width;
961 smartData->view.h = height;
962 smartData->changed.size = false;
965 if (impl->pageClient) {
966 if (DrawingAreaProxy* drawingArea = impl->pageProxy->drawingArea()) {
967 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
968 if (impl->pageProxy->isViewVisible())
969 drawingArea->setSize(IntSize(width, height), IntSize());
971 drawingArea->setSize(IntSize(width, height), IntSize());
973 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
974 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
975 int newAngle = ecore_evas_rotation_get(ee);
976 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
977 if (impl->pageClient->deferUpdateViewportSize()) {
978 impl->pageClient->updateViewportSize(IntSize(width, height), newAngle);
981 impl->pageClient->updateVisibleContentRectSize(IntSize(width, height));
982 if (ewk_view_is_opengl_backend(ewkView))
983 impl->pageClient->displayViewport();
986 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
987 impl->pageClient->frameRectChanged();
990 #endif // #if OS(TIZEN)
993 if (smartData->changed.position) {
994 evas_object_move(smartData->image, x, y);
995 smartData->view.x = x;
996 smartData->view.y = y;
997 smartData->changed.position = false;
999 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1000 impl->pageClient->frameRectChanged();
1002 #if ENABLE(TIZEN_SCREEN_READER)
1003 impl->pageProxy->recalcScreenReaderFocusRect();
1005 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1006 impl->pageClient->updateTextSelectionHandlesAndContextMenu(true);
1008 #endif // #if OS(TIZEN)
1011 if (impl->popupPicker)
1012 ewk_popup_picker_resize(impl->popupPicker);
1013 #endif // #if OS(TIZEN)
1016 static void _ewk_view_smart_show(Evas_Object* ewkView)
1018 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1019 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1021 if (evas_object_clipees_get(smartData->base.clipper))
1022 evas_object_show(smartData->base.clipper);
1023 evas_object_show(smartData->image);
1025 #if ENABLE(TIZEN_SCREEN_READER)
1026 ScreenReaderProxy::screenReader().initialize(impl);
1030 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1032 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1034 evas_object_hide(smartData->base.clipper);
1035 evas_object_hide(smartData->image);
1036 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1037 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1038 if (impl->pageClient->isTextSelectionMode())
1039 impl->pageClient->setIsTextSelectionMode(false);
1043 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1045 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1046 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1050 else if (alpha > 255)
1053 #define CHECK_COLOR(color, alpha) \
1056 else if (color > alpha) \
1058 CHECK_COLOR(red, alpha);
1059 CHECK_COLOR(green, alpha);
1060 CHECK_COLOR(blue, alpha);
1063 evas_object_image_alpha_set(smartData->image, alpha < 255);
1064 impl->pageProxy->setDrawsBackground(red || green || blue);
1065 impl->pageProxy->setDrawsTransparentBackground(alpha < 255);
1066 impl->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1069 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1073 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1075 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1077 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1078 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1079 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1083 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1084 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1086 evas_object_smart_clipped_smart_set(&api->sc);
1088 // Set Evas_Smart_Class functions.
1089 api->sc.add = _ewk_view_smart_add;
1090 api->sc.del = _ewk_view_smart_del;
1091 api->sc.move = _ewk_view_smart_move;
1092 api->sc.resize = _ewk_view_smart_resize;
1093 api->sc.show = _ewk_view_smart_show;
1094 api->sc.hide = _ewk_view_smart_hide;
1095 api->sc.color_set = _ewk_view_smart_color_set;
1096 api->sc.calculate = _ewk_view_smart_calculate;
1097 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1099 // Set Ewk_View_Smart_Class functions.
1100 api->focus_in = _ewk_view_smart_focus_in;
1101 api->focus_out = _ewk_view_smart_focus_out;
1102 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1103 api->mouse_down = _ewk_view_smart_mouse_down;
1104 api->mouse_up = _ewk_view_smart_mouse_up;
1105 api->mouse_move = _ewk_view_smart_mouse_move;
1106 api->key_down = _ewk_view_smart_key_down;
1107 api->key_up = _ewk_view_smart_key_up;
1109 api->gesture_start = _ewk_view_smart_gesture_start;
1110 api->gesture_end = _ewk_view_smart_gesture_end;
1111 api->gesture_move = _ewk_view_smart_gesture_move;
1113 #if ENABLE(TIZEN_FULLSCREEN_API)
1114 api->fullscreen_enter = _ewk_view_smart_fullscreen_enter;
1115 api->fullscreen_exit = _ewk_view_smart_fullscreen_exit;
1118 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1119 api->popup_menu_show = _ewk_view_popup_menu_show;
1120 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1121 api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1123 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1124 api->popup_menu_update = _ewk_view_popup_menu_update;
1126 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1127 api->text_selection_down = _ewk_view_text_selection_down;
1128 api->text_selection_move = _ewk_view_text_selection_move;
1129 api->text_selection_up = _ewk_view_text_selection_up;
1131 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1132 api->input_picker_show = _ewk_view_input_picker_show;
1134 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1135 api->data_list_show = _ewk_view_data_list_show;
1136 api->data_list_hide = _ewk_view_data_list_hide;
1138 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1139 api->orientation_lock = _ewk_orientation_lock;
1140 api->orientation_unlock = _ewk_orientation_unlock;
1142 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1143 api->input_picker_color_request = _ewk_input_picker_color_request;
1144 api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1146 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1147 api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1148 api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1149 api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1150 api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1152 #if ENABLE(TIZEN_SCREEN_READER)
1153 api->screen_reader_action_execute = _ewk_view_screen_reader_action_execute;
1155 #endif //#if OS(TIZEN)
1160 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1162 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1163 static Evas_Smart* smart = 0;
1165 if (EINA_UNLIKELY(!smart)) {
1166 ewk_view_smart_class_set(&api);
1167 smart = evas_smart_class_new(&api.sc);
1173 static void _ewk_view_initialize(Evas_Object* ewkView, PassRefPtr<Ewk_Context> context, WKPageGroupRef pageGroupRef)
1175 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1176 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1177 EINA_SAFETY_ON_NULL_RETURN(context);
1179 if (impl->pageClient)
1182 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1183 bool isOpenGL = ewk_view_is_opengl_backend(ewkView);
1185 impl->pageClient = PageClientEvasGL::create(impl);
1187 impl->pageClient = PageClientImpl::create(impl);
1189 impl->pageClient = PageClientImpl::create(impl);
1193 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), toImpl(pageGroupRef));
1195 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), WebPageGroup::create().get());
1197 EwkViewImpl::addToPageViewMap(ewkView);
1200 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
1201 impl->pageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
1202 impl->pageProxy->pageGroup()->preferences()->setFrameFlatteningEnabled(true);
1203 impl->pageProxy->pageGroup()->preferences()->setAllowUniversalAccessFromFileURLs(true);
1206 impl->pageProxy->initializeWebPage();
1208 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
1209 impl->pageProxy->setCustomDeviceScaleFactor((float)getMobileDPI() / 160);
1211 impl->pageProxy->setCustomDeviceScaleFactor((float)getDPI() / 160);
1214 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1215 impl->pageProxy->setUseFixedLayout(true);
1217 #if ENABLE(FULLSCREEN_API)
1218 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1221 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1223 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1225 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1226 impl->pageProxy->pageGroup()->preferences()->setWebGLEnabled(false);
1227 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1231 impl->backForwardList = Ewk_Back_Forward_List::create(toAPI(impl->pageProxy->backForwardList()));
1233 impl->context = context;
1236 ewkViewContextMenuClientAttachClient(ewkView);
1237 ewkViewTizenClientAttachClient(ewkView);
1239 #if ENABLE(TIZEN_GEOLOCATION)
1240 ewkViewGeolocationProviderAttachProvider(ewkView, impl->context->wkContext());
1243 #if ENABLE(TIZEN_NOTIFICATIONS)
1244 ewkViewNotificationProviderAttachProvider(ewkView, impl->context->wkContext());
1247 #if ENABLE(TIZEN_ICON_DATABASE)
1248 ewk_view_icondatabase_client_attach(ewkView, impl->context->wkContext());
1251 ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1252 ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1253 ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1254 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1255 ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1257 ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1258 #else // #if OS(TIZEN)
1259 #if USE(COORDINATED_GRAPHICS)
1260 impl->viewportHandler = EflViewportHandler::create(impl->pageClient.get());
1262 #endif // #if OS(TIZEN)
1264 #if ENABLE(FULLSCREEN_API)
1265 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1266 impl->pageProxy->pageGroup()->preferences()->setFullScreenEnabled(true);
1269 // Initialize page clients.
1270 impl->pageLoadClient = PageLoadClientEfl::create(impl);
1271 impl->pagePolicyClient = PagePolicyClientEfl::create(impl);
1272 impl->pageUIClient = PageUIClientEfl::create(impl);
1273 impl->resourceLoadClient = ResourceLoadClientEfl::create(impl);
1274 impl->findClient = FindClientEfl::create(impl);
1275 impl->formClient = FormClientEfl::create(impl);
1276 #if !ENABLE(TIZEN_ICON_DATABASE)
1277 /* Listen for favicon changes */
1278 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
1279 iconDatabase->watchChanges(IconChangeCallbackData(_ewk_view_on_favicon_changed, ewkView));
1281 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1282 ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1285 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1286 if (!impl->context->xWindow())
1287 impl->context->setXWindow(elm_win_xwindow_get(ewkView));
1290 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1291 impl->focusRing = FocusRing::create(impl);
1295 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1297 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1298 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1300 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1302 using namespace EGL;
1303 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1304 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1310 Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1314 EWK_VIEW_SD_GET(ewkView, smartData);
1316 evas_object_del(ewkView);
1320 EWK_VIEW_IMPL_GET(smartData, impl);
1322 evas_object_del(ewkView);
1331 * Constructs a ewk_view Evas_Object with WKType parameters.
1333 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1335 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1336 EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1338 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1342 _ewk_view_initialize(ewkView, Ewk_Context::create(contextRef), pageGroupRef);
1347 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1349 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1350 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1351 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1353 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1357 #if ENABLE(TIZEN_ICON_DATABASE)
1358 //set default iconDatabasePath
1359 WKContextRef contextRef = context->wkContext();
1360 toImpl(contextRef)->setIconDatabasePath(toImpl(contextRef)->iconDatabasePath());
1363 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1364 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1365 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1366 _ewk_view_initialize(ewkView, context, toAPI(impl->pageGroup.get()));
1368 _ewk_view_initialize(ewkView, context, 0);
1374 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1376 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1377 return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1380 Evas_Object* ewk_view_add(Evas* canvas)
1382 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1385 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
1387 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1388 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1390 return impl->ewkContext();
1393 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* url)
1395 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1396 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1397 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
1399 impl->pageProxy->loadURL(String::fromUTF8(url));
1400 impl->informURLChange();
1405 const char* ewk_view_url_get(const Evas_Object* ewkView)
1407 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1408 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1413 const char *ewk_view_icon_url_get(const Evas_Object *ewkView)
1415 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1416 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1418 return impl->faviconURL();
1421 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1423 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1424 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1426 impl->pageClient->prepareRestoredVisibleContectRect();
1427 impl->pageProxy->reload(/*reloadFromOrigin*/ false);
1428 impl->informURLChange();
1433 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1435 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1436 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1438 impl->pageProxy->reload(/*reloadFromOrigin*/ true);
1439 impl->informURLChange();
1444 Eina_Bool ewk_view_stop(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->stopLoading();
1454 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1456 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1457 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1459 return impl->settings();
1462 const char* ewk_view_title_get(const Evas_Object* ewkView)
1464 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1465 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1467 return impl->title();
1472 * Reports that the requested text was found.
1474 * Emits signal: "text,found" with the number of matches.
1476 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
1478 evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
1481 double ewk_view_load_progress_get(const Evas_Object* ewkView)
1483 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1484 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1486 return impl->pageProxy->estimatedProgress();
1489 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
1491 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1492 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1498 scaleFactor = impl->pageClient->adjustScaleWithViewport(scaleFactor);
1500 IntPoint scrollPosition = impl->pageClient->scrollPosition();
1501 double scaleDifference = scaleFactor / impl->pageClient->scaleFactor();
1502 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
1503 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
1505 impl->pageProxy->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
1507 impl->pageProxy->scalePage(scaleFactor, IntPoint(x, y));
1512 double ewk_view_scale_get(const Evas_Object* ewkView)
1514 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
1515 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1);
1518 return impl->pageProxy->scaleFactor();
1520 return impl->pageProxy->pageScaleFactor();
1524 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
1526 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1527 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1529 impl->pageProxy->setCustomDeviceScaleFactor(ratio);
1534 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
1536 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1537 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1539 return impl->pageProxy->deviceScaleFactor();
1542 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
1544 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1545 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1547 impl->setThemePath(path);
1550 const char* ewk_view_theme_get(const Evas_Object* ewkView)
1552 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1553 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1555 return impl->themePath();
1558 Eina_Bool ewk_view_back(Evas_Object* ewkView)
1560 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1561 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1563 WebPageProxy* page = impl->pageProxy.get();
1564 if (page->canGoBack()) {
1572 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
1574 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1575 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1577 WebPageProxy* page = impl->pageProxy.get();
1578 if (page->canGoForward()) {
1586 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
1588 #if ENABLE(WEB_INTENTS)
1589 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1590 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1591 EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
1593 WebPageProxy* page = impl->pageProxy.get();
1594 page->deliverIntentToFrame(page->mainFrame(), intent->webIntentData());
1602 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
1604 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1605 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1607 return impl->pageProxy->canGoBack();
1610 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
1612 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1613 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1615 return impl->pageProxy->canGoForward();
1618 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
1620 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1621 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1623 return impl->backForwardList.get();
1626 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1627 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
1629 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1630 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1632 if (!ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
1635 if (value.isEmpty()) {
1636 if(smartData->api->formdata_candidate_is_showing(smartData))
1637 smartData->api->formdata_candidate_hide(smartData);
1641 Vector<String> popupCandidates;
1642 ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
1643 std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
1645 Eina_List* candidateList = 0;
1646 for (size_t i = 0; i < popupCandidates.size(); ++i) {
1647 if (popupCandidates[i].startsWith(value, false))
1648 candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
1651 if (!eina_list_count(candidateList)) {
1652 if(smartData->api->formdata_candidate_is_showing(smartData))
1653 smartData->api->formdata_candidate_hide(smartData);
1657 smartData->api->formdata_candidate_update_data(smartData, candidateList);
1659 IntRect inputFieldRect = impl->transformToScene().mapRect(impl->pageClient->focusedNodeRect());
1660 smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
1663 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm)
1665 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1666 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1667 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
1668 && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
1670 ewk_view_context_get(ewkView)->addFormData(impl->url(), formData, isPasswordForm);
1673 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
1675 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1676 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1678 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
1681 Vector<std::pair<String, String> > passwordFormData;
1682 ewk_view_context_get(ewkView)->passwordFormData(impl->url(), passwordFormData);
1684 if (!passwordFormData.size())
1687 String passwordFormAutofill = String::fromUTF8("try { function passwordFormAutofill() { var inputFields;");
1688 for (size_t i = 0; i < passwordFormData.size(); i++) {
1689 passwordFormAutofill += String::fromUTF8(" inputFields = document.getElementsByName(\"");
1690 passwordFormAutofill += passwordFormData[i].first;
1691 passwordFormAutofill += String::fromUTF8("\");");
1692 passwordFormAutofill += String::fromUTF8(" for (var i = 0; i < inputFields.length; i++)");
1693 passwordFormAutofill += String::fromUTF8(" if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\" || inputFields[i].type.toLowerCase() == \"email\"))");
1694 passwordFormAutofill += String::fromUTF8(" inputFields[i].value = \"");
1695 passwordFormAutofill += passwordFormData[i].second;
1696 passwordFormAutofill += String::fromUTF8("\";");
1698 passwordFormAutofill += String::fromUTF8("} passwordFormAutofill(); } catch(e) { }");
1699 ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
1702 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
1704 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1705 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1706 ewk_view_context_get(ewkView)->candidateFormData(name, candidates);
1710 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
1712 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1713 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1714 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
1716 if (unreachableUrl && *unreachableUrl)
1717 impl->pageProxy->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
1719 impl->pageProxy->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
1721 impl->informURLChange();
1726 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
1728 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1729 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1731 return impl->customTextEncodingName();
1734 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
1736 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1737 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1739 impl->setCustomTextEncodingName(encoding);
1745 // FIXME: It should be removed.
1746 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
1748 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1749 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1751 return toAPI(impl->pageProxy.get());
1754 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
1756 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1757 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1759 impl->setMouseEventsEnabled(!!enabled);
1764 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
1766 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1767 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1769 return impl->mouseEventsEnabled();
1772 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
1774 #if ENABLE(INPUT_TYPE_COLOR)
1775 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1776 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1778 return impl->setColorPickerColor(WebCore::Color(r, g, b, a));
1784 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
1786 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1787 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1789 return impl->javascriptPopup->alert(alertText);
1792 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
1794 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1795 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1797 return impl->javascriptPopup->confirm(message);
1800 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
1802 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1803 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1805 return impl->javascriptPopup->prompt(message, defaultValue);
1808 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1809 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, void* userData)
1811 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1812 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1814 return impl->javascriptPopup->beforeUnloadConfirmPanel(message);
1818 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)
1820 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1821 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1823 return impl->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, impl);
1826 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1827 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)
1829 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1831 if (impl->popupPicker)
1832 ewk_popup_picker_del(impl->popupPicker);
1834 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1835 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
1837 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
1843 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1844 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)
1846 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1848 if (impl->popupPicker)
1849 ewk_popup_picker_del(impl->popupPicker);
1851 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
1857 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
1859 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1861 if (!impl->popupPicker)
1864 ewk_popup_picker_del(impl->popupPicker);
1865 impl->popupPicker = 0;
1870 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)
1872 // FIXME: The rect should be updated if it was changed
1874 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1876 if (!impl->popupPicker)
1879 ewk_popup_picker_update(smartData->self, impl->popupPicker, items, selectedIndex);
1885 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1886 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
1888 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1890 impl->inputPicker->show(inputType, inputValue);
1895 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1896 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
1898 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1900 impl->inputPicker->showDataList(inputType, optionList);
1904 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
1906 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1908 impl->inputPicker->hideDataList(inputType);
1913 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1914 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
1916 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1918 impl->inputPicker->showColorPicker(r, g, b, a);
1922 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
1924 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1926 impl->inputPicker->hideColorPicker();
1931 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
1933 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1934 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1936 return impl->pageClient.get();
1939 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
1941 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
1942 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 1);
1944 return WKPageGetTextZoomFactor(toAPI(impl->pageProxy.get()));
1947 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
1949 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1950 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1952 WKPageSetTextZoomFactor(toAPI(impl->pageProxy.get()), textZoomFactor);
1956 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1957 FocusRing* ewkViewGetFocusRing(Evas_Object* ewkView)
1959 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1960 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1962 return impl->focusRing.get();
1966 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
1968 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1969 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1971 return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(impl->pageProxy.get())));
1974 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
1976 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1977 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1979 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(impl->pageProxy.get())));
1982 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
1984 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1985 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1987 if (!impl->javascriptGlobalContext)
1988 impl->javascriptGlobalContext = JSGlobalContextCreate(0);
1989 return impl->javascriptGlobalContext;
1992 void ewkViewLoadCommitted(Evas_Object* ewkView)
1994 #if ENABLE(TIZEN_GESTURE)
1995 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1996 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1997 impl->gestureClient->reset();
1999 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
2000 if (impl->focusRing)
2001 impl->focusRing->hide();
2003 #if ENABLE(TIZEN_ISF_PORT)
2004 impl->inputMethodContext()->hideIMFContext();
2006 impl->informURLChange();
2007 evas_object_smart_callback_call(ewkView, "load,committed", 0);
2010 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
2012 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2013 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2015 OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error);
2016 ewk_error_load_error_page(ewkError.get(), toAPI(impl->pageProxy.get()));
2017 evas_object_smart_callback_call(ewkView, "load,error", ewkError.get());
2020 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
2022 #if ENABLE(TIZEN_GESTURE)
2023 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2024 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2025 impl->gestureClient->reset();
2027 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
2030 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
2032 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2033 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2035 if (impl->authChallenge)
2036 ewkAuthChallengeDelete(impl->authChallenge);
2037 impl->authChallenge = authChallenge;
2039 evas_object_smart_callback_call(ewkView, "authentication,challenge", impl->authChallenge);
2042 void ewk_view_process_crashed(Evas_Object* ewkView)
2044 bool handled = false;
2045 evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
2051 #if ENABLE(TIZEN_SQL_DATABASE)
2052 bool ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef databaseName, unsigned long long expectedUsage)
2054 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2055 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2057 if (!impl->exceededDatabaseQuotaContext || !impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback)
2060 TIZEN_LOGI("No error in prameter. Request to display user confirm popup. expectedUsage(%llu)", expectedUsage);
2061 impl->isWaitingForExceededQuotaPopupReply = true;
2062 if (impl->exceededQuotaOrigin)
2063 deleteSecurityOrigin(impl->exceededQuotaOrigin);
2064 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
2066 int length = WKStringGetMaximumUTF8CStringSize(databaseName);
2067 OwnArrayPtr<char> databaseNameBuffer = adoptArrayPtr(new char[length]);
2068 WKStringGetUTF8CString(databaseName, databaseNameBuffer.get(), length);
2070 return impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, databaseNameBuffer.get(), expectedUsage, impl->exceededDatabaseQuotaContext->userData) == EINA_TRUE;
2074 #if ENABLE(TIZEN_NOTIFICATIONS)
2075 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
2077 TIZEN_LOGI("notification,cancel");
2078 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
2081 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
2083 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2084 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2086 TIZEN_LOGI("notification,permission,request");
2087 impl->notificationPermissionRequests = eina_list_append(impl->notificationPermissionRequests, notificationPermissionRequest);
2088 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
2091 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
2093 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2094 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2096 TIZEN_LOGI("notification,show");
2097 Eina_List* listIterator=0;
2099 const char* replaceID = ewkNotificationGetReplaceID(notification);
2100 if(strlen(replaceID)) {
2101 EINA_LIST_FOREACH(impl->notifications, listIterator, data) {
2102 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
2103 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
2104 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
2108 impl->notifications = eina_list_append(impl->notifications, notification);
2109 evas_object_smart_callback_call(ewkView, "notification,show", notification);
2112 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
2114 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2115 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2117 impl->notificationPermissionRequests = eina_list_remove(impl->notificationPermissionRequests, ewkNotificationPermissionRequest);
2121 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
2122 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
2124 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2126 TIZEN_LOGI("protocolhandler,registration,requested");
2127 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
2128 evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
2129 ewkCustomHandlersDeleteData(customHandlersData);
2133 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
2134 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2136 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2138 TIZEN_LOGI("protocolhandler,isregistered");
2139 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2140 evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
2142 Ewk_Custom_Handlers_State result;
2143 result = ewkGetCustomHandlersDataResult(customHandlersData);
2144 ewkCustomHandlersDeleteData(customHandlersData);
2149 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2151 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2153 TIZEN_LOGI("protocolhandler,unregistration,requested");
2154 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2155 evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
2156 ewkCustomHandlersDeleteData(customHandlersData);
2160 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
2161 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
2163 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2165 TIZEN_LOGI("contenthandler,registration,requested");
2166 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
2167 evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
2168 ewkCustomHandlersDeleteData(customHandlersData);
2171 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2173 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2175 TIZEN_LOGI("contenthandler,isregistered");
2176 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2177 evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
2179 Ewk_Custom_Handlers_State result;
2180 result = ewkGetCustomHandlersDataResult(customHandlersData);
2181 ewkCustomHandlersDeleteData(customHandlersData);
2186 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2188 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2190 TIZEN_LOGI("contenthandler,unregistration,requested");
2191 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2192 evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
2193 ewkCustomHandlersDeleteData(customHandlersData);
2197 #if ENABLE(TIZEN_SEARCH_PROVIDER)
2198 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2200 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2202 TIZEN_LOGI("searchProvider,add");
2203 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2204 evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
2205 ewkSearchProviderDeleteData(searchProviderData);
2208 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2210 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
2212 TIZEN_LOGI("searchProvider,installed");
2213 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2214 evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
2215 unsigned long result;
2216 result = ewkGetSearchProviderResult(searchProviderData);
2217 ewkSearchProviderDeleteData(searchProviderData);
2222 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
2223 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
2225 TIZEN_LOGI("webapp,metatag,standalone");
2226 bool standalone = true;
2227 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
2232 #if ENABLE(TIZEN_MEDIA_STREAM)
2233 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
2235 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2236 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2238 impl->userMediaPermissionRequests = eina_list_append(impl->userMediaPermissionRequests, userMediaPermission);
2239 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
2242 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
2244 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2245 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2247 impl->userMediaPermissionRequests = eina_list_remove(impl->userMediaPermissionRequests, permission);
2252 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
2253 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
2255 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
2256 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
2257 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
2258 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
2259 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
2260 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
2262 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
2266 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
2267 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
2269 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2270 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2271 if (impl->certificatePolicyDecision)
2272 ewkCertificatePolicyDecisionDelete(impl->certificatePolicyDecision);
2273 impl->certificatePolicyDecision = certificatePolicyDecision;
2275 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
2279 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
2281 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
2284 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
2286 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
2289 #if ENABLE(TIZEN_GEOLOCATION)
2290 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2292 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2293 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2295 TIZEN_LOGI("geolocation,permission,request");
2296 impl->geolocationPermissionRequests = eina_list_append(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2297 evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
2300 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2302 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2303 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2305 impl->geolocationPermissionRequests = eina_list_remove(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2308 void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
2310 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2311 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2313 impl->geolocation = geolocation;
2316 Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
2318 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2319 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2321 return impl->geolocation;
2324 bool ewkViewIsValidLocationService(Evas_Object* ewkView)
2326 TIZEN_LOGI("geolocation,valid");
2329 evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
2334 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
2336 evas_object_smart_callback_call(ewkView, "form,submit", formData);
2339 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2341 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2342 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2343 if (impl->policyDecision)
2344 ewkPolicyDecisionDelete(impl->policyDecision);
2345 impl->policyDecision = policyDecision;
2347 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", impl->policyDecision);
2350 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2352 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2353 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2354 if (impl->policyDecision)
2355 ewkPolicyDecisionDelete(impl->policyDecision);
2356 impl->policyDecision = policyDecision;
2358 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", impl->policyDecision);
2361 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2363 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2364 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2365 if (impl->policyDecision)
2366 ewkPolicyDecisionDelete(impl->policyDecision);
2367 impl->policyDecision = policyDecision;
2369 evas_object_smart_callback_call(ewkView, "policy,response,decide", impl->policyDecision);
2372 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
2374 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2375 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2377 IntPoint scrollPosition = impl->pageClient->scrollPosition();
2378 IntSize contentsSize = impl->pageProxy->contentsSize();
2379 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2380 contentsSize.scale(impl->pageClient->scaleFactor());
2383 // some website's contents size is smaller than view size,
2384 // so we have to adjust contents size to view size for that case.
2385 if (contentsSize.width() < smartData->view.w)
2386 contentsSize.setWidth(smartData->view.w);
2387 if (contentsSize.height() < smartData->view.h)
2388 contentsSize.setHeight(smartData->view.h);
2390 // Call "scroll,down" if webview can be scrolled down.
2391 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
2392 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
2393 // Call "scroll,up" if webview can be scrolled up.
2394 else if (deltaY < 0 && scrollPosition.y() > 0)
2395 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
2397 // Call "scroll,right" if webview can be scrolled down.
2398 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
2399 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
2400 // Call "scroll,left" if webview can be scrolled up.
2401 else if (deltaX < 0 && scrollPosition.x() > 0)
2402 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
2405 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
2407 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2408 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2410 IntSize contentsSize = impl->pageProxy->contentsSize();
2411 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2412 contentsSize.scale(impl->pageClient->scaleFactor());
2415 int maxScrollY = contentsSize.height() - smartData->view.h;
2416 if (!impl->isVerticalEdge) {
2417 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
2418 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
2419 impl->isVerticalEdge = true;
2420 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
2421 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
2422 impl->isVerticalEdge = true;
2425 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
2426 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
2427 impl->isVerticalEdge = false;
2430 int maxScrollX = contentsSize.width() - smartData->view.w;
2431 if (!impl->isHorizontalEdge) {
2432 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
2433 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
2434 impl->isHorizontalEdge = true;
2435 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
2436 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
2437 impl->isHorizontalEdge = true;
2440 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
2441 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
2442 impl->isHorizontalEdge = false;
2446 void ewkViewClearEdges(Evas_Object* ewkView)
2448 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2449 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2451 impl->isVerticalEdge = false;
2452 impl->isHorizontalEdge = false;
2455 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
2457 EWK_VIEW_SD_GET(ewkView, smartData);
2458 if (!smartData || !smartData->priv) {
2466 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
2468 *minimumScale = constraints.minimumScale;
2470 *maximumScale = constraints.maximumScale;
2473 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard)
2475 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2476 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2478 double scaleFactor = impl->pageClient->scaleFactor();
2479 IntSize contentsSize = impl->pageProxy->contentsSize();
2481 double newScaleFactor = scaleFactor;
2482 // Readable zoom value is dependent on device DPI
2483 if (scaleFactor < impl->pageProxy->deviceScaleFactor()
2484 && impl->pageClient->viewportConstraints().userScalable)
2485 newScaleFactor = impl->pageProxy->deviceScaleFactor();
2487 // Readable zoom value should be inside of viewport scale range
2488 newScaleFactor = impl->pageClient->adjustScaleWithViewport(newScaleFactor);
2490 // scale contents' size with new scale factor
2491 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2492 contentsSize.scale(newScaleFactor);
2494 contentsSize.scale(newScaleFactor / scaleFactor);
2497 #if ENABLE(TIZEN_ISF_PORT)
2498 Ecore_X_Window rootWin = ecore_x_window_root_first_get();
2499 ecore_x_event_mask_set(rootWin, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
2500 Ecore_X_Atom xAtom = ecore_x_atom_get("X External Keyboard Exist");
2501 unsigned int connectedKeyboardNum = 0;
2502 bool isExternalKeyboardConnected = false;
2504 // get connected keyboard number
2505 if (ecore_x_window_prop_card32_get(rootWin, xAtom, &connectedKeyboardNum, 1)
2506 && connectedKeyboardNum)
2507 isExternalKeyboardConnected = true;
2509 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
2510 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
2511 // input field zoom should not work with below conditions
2512 // 1. view is not focused
2513 // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
2514 // 3. imfContext is null(if adjustForExternalKeyboard is false)
2515 // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
2516 if ((!(static_cast<PageClient*>(impl->pageClient.get()))->isViewFocused()
2517 || (adjustForExternalKeyboard && !isExternalKeyboardConnected)
2518 || (!adjustForExternalKeyboard && !impl->inputMethodContext())
2519 || (!adjustForExternalKeyboard && !impl->inputMethodContext()->isShow()))
2520 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
2521 && !(impl->pageClient->isClipboardWindowOpened())
2527 // caret position can be outside of visible rect.
2528 // we need to consider it.
2529 IntRect selectionRect = impl->pageProxy->getSelectionRect(true);
2530 IntRect focusedNodeRect = impl->pageClient->focusedNodeRect();
2531 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2532 selectionRect.scale(newScaleFactor);
2533 focusedNodeRect.scale(newScaleFactor);
2535 selectionRect.scale(newScaleFactor / scaleFactor);
2536 focusedNodeRect.scale(newScaleFactor / scaleFactor);
2538 if (selectionRect.isEmpty())
2541 IntRect visibleRect = impl->pageClient->visibleContentRect();
2542 IntPoint scrollPosition = visibleRect.location();
2543 // Do not adjust scroll position if content is userscalable or selection rect (caret) is visible after scaling
2544 if (impl->pageClient->userScalable() || !visibleRect.contains(selectionRect)) {
2546 scrollPosition = IntPoint(selectionRect.x() - visibleRect.width() / 3, selectionRect.y() - visibleRect.height() / 3);
2547 // If both input field's position x and selection rect can be displayed together,
2548 // adjust scroll position to input field's position x.
2549 if (!focusedNodeRect.isEmpty() && selectionRect.x() - focusedNodeRect.x() < visibleRect.width() * 4 / 5)
2550 scrollPosition.setX(focusedNodeRect.x());
2553 #if ENABLE(TIZEN_DLOG_SUPPORT)
2554 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", scrollPosition.x(), scrollPosition.y(), newScaleFactor);
2557 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2558 impl->pageClient->setVisibleContentRect(IntRect(scrollPosition, impl->size()), newScaleFactor);
2560 if (newScaleFactor != scaleFactor)
2561 impl->pageProxy->scalePage(newScaleFactor, scrollPosition);
2563 impl->pageProxy->scrollMainFrameTo(scrollPosition);
2565 evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
2569 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
2570 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2571 static Eina_Bool _ewk_view_composite(void* data)
2573 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
2574 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2576 if (!evas_object_visible_get(smartData->image))
2577 return ECORE_CALLBACK_CANCEL;
2580 evas_object_image_size_get(smartData->image, &ow, &oh);
2581 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
2583 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)));
2584 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
2586 cairo_save(context.get());
2587 cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
2588 cairo_rectangle(context.get(), 0, 0, ow, oh);
2589 cairo_fill(context.get());
2590 cairo_restore(context.get());
2592 impl->pageClient->drawContents(context.get());
2594 evas_object_image_data_set(smartData->image, pixels);
2595 evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
2597 if (impl->pageClient->notifiedNonemptyLayout())
2598 ewkViewFrameRendered(smartData->self);
2600 impl->compositionAnimator = 0;
2602 return ECORE_CALLBACK_CANCEL;
2606 void ewk_view_mark_for_sync(Evas_Object* ewkView)
2608 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2609 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
2611 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2612 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2614 if (!ewk_view_is_opengl_backend(ewkView)) {
2615 if (!impl->compositionAnimator)
2616 impl->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
2621 evas_object_image_pixels_dirty_set(smartData->image, true);
2624 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
2626 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
2627 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2628 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2629 impl->pageClient->drawContents();
2632 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
2634 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2635 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2637 if (!smartData->image)
2640 evas_object_image_native_surface_set(smartData->image, nativeSurface);
2641 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
2647 void _ewk_view_suspend_painting(Evas_Object* ewkView)
2649 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2650 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2652 if (!impl->suspendedPainting) {
2653 impl->pageProxy->suspendPainting();
2654 impl->suspendedPainting = true;
2658 void _ewk_view_resume_painting(Evas_Object* ewkView)
2660 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2661 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2663 if (impl->suspendedPainting) {
2664 impl->pageProxy->resumePainting();
2665 impl->suspendedPainting = false;
2669 void ewk_view_suspend(Evas_Object* ewkView)
2671 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2672 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2674 if (impl->pageProxy->estimatedProgress() < 1.0) {
2675 impl->suspendRequested = true;
2678 impl->suspendRequested = false;
2680 _ewk_view_suspend_painting(ewkView);
2682 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2683 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2684 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2686 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2687 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2688 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2689 // will be suspended again.
2690 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2691 // the ActiveDOMObject.
2692 if (!impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2693 impl->pageProxy->suspendAnimations();
2694 impl->pageProxy->suspendJavaScriptAndResource();
2695 impl->suspendedResources = true;
2698 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2699 impl->pageProxy->suspendPlugin();
2703 void ewk_view_resume(Evas_Object* ewkView)
2705 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2706 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2708 if (impl->suspendRequested) {
2709 impl->suspendRequested = false;
2713 _ewk_view_resume_painting(ewkView);
2715 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2716 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2717 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2719 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2720 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2721 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2722 // will be suspended again.
2723 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2724 // the ActiveDOMObject.
2725 if (impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2726 impl->pageProxy->resumeAnimations();
2727 impl->pageProxy->resumeJavaScriptAndResource();
2728 impl->suspendedResources = false;
2731 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2732 impl->pageProxy->resumePlugin();
2736 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
2738 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2739 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2740 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
2742 ResourceRequest request(String::fromUTF8(url));
2745 case EWK_HTTP_METHOD_GET:
2746 request.setHTTPMethod("GET");
2748 case EWK_HTTP_METHOD_HEAD:
2749 request.setHTTPMethod("HEAD");
2751 case EWK_HTTP_METHOD_POST:
2752 request.setHTTPMethod("POST");
2754 case EWK_HTTP_METHOD_PUT:
2755 request.setHTTPMethod("PUT");
2757 case EWK_HTTP_METHOD_DELETE:
2758 request.setHTTPMethod("DELETE");
2765 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
2767 while (eina_iterator_next(it, &data)) {
2768 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
2769 const char* name = static_cast<const char*>(t->key);
2770 const char* value = static_cast<const char*>(t->data);
2771 request.addHTTPHeaderField(name, value);
2773 eina_iterator_free(it);
2777 request.setHTTPBody(FormData::create(body));
2779 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
2780 WKPageLoadURLRequest(toAPI(impl->pageProxy.get()), urlRequest.get());
2785 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
2787 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2788 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2790 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
2791 WKPageLoadPlainTextString(toAPI(impl->pageProxy.get()), plainTextRef.get());
2796 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
2798 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2799 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2800 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
2802 if (contentsSize == 0)
2805 String mimeTypeString;
2807 mimeTypeString = String::fromUTF8(mimeType);
2809 mimeTypeString = String::fromUTF8("text/html");
2811 String encodingString;
2813 encodingString = String::fromUTF8(encoding);
2815 encodingString = String::fromUTF8("UTF-8");
2817 String baseUriString;
2819 baseUriString = String::fromUTF8(baseUri);
2821 baseUriString = String::fromUTF8("about:blank");
2823 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
2824 impl->pageProxy->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
2829 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
2831 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2832 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2834 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
2835 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
2837 WKPageLoadHTMLString(toAPI(impl->pageProxy.get()), htmlString.get(), baseURL.get());
2842 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
2844 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2845 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2847 TIZEN_LOGI("initialState (%d)", initialState);
2848 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
2849 WKPageSetPageVisibility(toAPI(impl->pageProxy.get()), static_cast<WKPageVisibilityState>(pageVisibilityState), initialState);
2856 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
2858 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
2860 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2861 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2863 impl->userAgent = userAgent;
2865 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
2866 WKPageSetCustomUserAgent(toAPI(impl->pageProxy.get()), userAgentString.get());
2871 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
2873 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2874 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2876 if (!impl->userAgent) {
2877 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
2879 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
2880 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2881 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
2882 impl->userAgent = buffer.get();
2885 return impl->userAgent;
2887 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
2889 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2890 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2891 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2893 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2894 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
2896 WKPageAddCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get(), customHeaderValue.get());
2899 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2904 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
2906 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2907 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2908 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2910 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2912 WKPageRemoveCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get());
2915 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2920 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
2922 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2923 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2924 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2926 WKPageClearCustomHeaders(toAPI(impl->pageProxy.get()));
2929 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2934 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
2935 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
2937 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2938 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2940 #if ENABLE(TIZEN_DRAG_SUPPORT)
2941 if (impl->pageClient->isDragMode())
2942 impl->pageClient->setDragMode(false);
2945 impl->pageClient->setIsVisible(enable);
2950 #if ENABLE(TIZEN_BACKGROUND_DISK_CACHE)
2951 Eina_Bool ewk_view_foreground_set(Evas_Object* ewkView, Eina_Bool enable)
2957 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
2959 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
2961 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2962 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2965 rect.origin.x = viewArea.x;
2966 rect.origin.y = viewArea.y;
2967 rect.size.width = viewArea.w;
2968 rect.size.height = viewArea.h;
2970 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(impl->pageProxy.get()), rect, scaleFactor));
2971 if (!snapshot.get())
2974 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
2976 Evas_Object* screenshotImage = evas_object_image_add(canvas);
2977 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
2978 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
2979 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
2980 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
2982 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
2984 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)));
2985 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
2987 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
2988 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
2989 cairo_fill(cairo.get());
2991 evas_object_image_smooth_scale_set(screenshotImage, true);
2992 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
2993 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
2994 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
2995 evas_object_image_data_set(screenshotImage, pixels);
2997 return screenshotImage;
3000 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
3002 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
3003 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
3004 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, 0);
3006 return impl->pageProxy->startInspectorServer(port);
3008 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
3013 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
3015 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
3016 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
3017 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
3019 return impl->pageProxy->stopInspectorServer();
3021 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
3026 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
3028 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3029 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3031 WKPageScrollBy(toAPI(impl->pageProxy.get()), toAPI(IntSize(deltaX, deltaY)));
3034 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
3040 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3041 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3043 IntPoint scrollPosition = impl->pageClient->scrollPosition();
3045 *x = scrollPosition.x();
3047 *y = scrollPosition.y();
3052 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
3054 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3055 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3057 impl->pageProxy->scrollMainFrameTo(IntPoint(x, y));
3061 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
3067 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3068 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3070 IntSize contentsSize = impl->pageProxy->contentsSize();
3071 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3072 contentsSize.scale(impl->pageClient->scaleFactor());
3075 if (width && contentsSize.width() > smartData->view.w)
3076 *width = contentsSize.width() - smartData->view.w;
3077 if (height && contentsSize.height() > smartData->view.h)
3078 *height = contentsSize.height() - smartData->view.h;
3082 #if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
3083 void ewkViewNotifyPopupReplyWaitingState(Evas_Object* ewkView, bool isWaiting)
3086 evas_object_smart_callback_call(ewkView, "popup,reply,wait,start", 0);
3088 evas_object_smart_callback_call(ewkView, "popup,reply,wait,finish", 0);
3092 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
3094 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3095 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3096 if (!impl->alertContext || !impl->alertContext->javascriptAlertCallback)
3098 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->alertContext->ewkView == ewkView, false);
3100 impl->isWaitingForJavaScriptPopupReply = true;
3101 int length = WKStringGetMaximumUTF8CStringSize(alertText);
3102 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
3103 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
3104 return impl->alertContext->javascriptAlertCallback(impl->alertContext->ewkView, alertTextBuffer.get(), impl->alertContext->userData) == EINA_TRUE;
3107 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
3109 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3110 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3111 if (!impl->confirmContext || !impl->confirmContext->javascriptConfirmCallback)
3113 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->confirmContext->ewkView == ewkView, false);
3115 impl->isWaitingForJavaScriptPopupReply = true;
3116 int length = WKStringGetMaximumUTF8CStringSize(message);
3117 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3118 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3119 return impl->confirmContext->javascriptConfirmCallback(impl->confirmContext->ewkView, messageBuffer.get(), impl->confirmContext->userData) == EINA_TRUE;
3122 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
3124 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3125 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3126 if (!impl->promptContext || !impl->promptContext->javascriptPromptCallback)
3128 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->promptContext->ewkView == ewkView, false);
3130 impl->isWaitingForJavaScriptPopupReply = true;
3131 int length = WKStringGetMaximumUTF8CStringSize(message);
3132 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3133 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3134 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
3135 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
3136 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
3137 return impl->promptContext->javascriptPromptCallback(impl->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), impl->promptContext->userData) == EINA_TRUE;
3140 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3141 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
3143 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3144 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3145 if (!impl->beforeUnloadConfirmPanelContext || !impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
3147 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
3149 impl->isWaitingForJavaScriptPopupReply = true;
3150 int length = WKStringGetMaximumUTF8CStringSize(message);
3151 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3152 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3153 bool result = impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(impl->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), impl->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
3158 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
3160 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3161 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3162 if (!impl->openpanelContext || !impl->openpanelContext->openPanelCallback)
3165 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->openpanelContext->ewkView == ewkView, false);
3167 impl->openPanelListener = listener;
3169 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
3170 Eina_List* acceptedMimeTypes = 0;
3171 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
3172 size_t len = WKArrayGetSize(array.get());
3173 for (size_t i = 0; i < len; i++) {
3174 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
3175 if (WKGetTypeID(item) != WKStringGetTypeID())
3177 WKStringRef mime = static_cast<WKStringRef>(item);
3178 int length = WKStringGetMaximumUTF8CStringSize(mime);
3179 char* buffer = new char[length];
3180 WKStringGetUTF8CString(mime, buffer, length);
3181 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
3183 const char* capture = 0;
3184 #if ENABLE(MEDIA_CAPTURE)
3185 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
3186 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
3188 bool result = impl->openpanelContext->openPanelCallback(impl->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
3189 if (!acceptedMimeTypes)
3194 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
3195 delete[] (char*)data;
3196 eina_list_free(acceptedMimeTypes);
3200 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
3202 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3203 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3205 if (!impl->alertContext)
3206 impl->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3207 impl->alertContext->javascriptAlertCallback = callback;
3208 impl->alertContext->ewkView = ewkView;
3209 impl->alertContext->userData = userData;
3212 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
3214 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3215 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3217 WKPageReplyJavaScriptAlert(toAPI(impl->page()));
3218 impl->isWaitingForJavaScriptPopupReply = false;
3221 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
3223 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3224 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3226 if (!impl->confirmContext)
3227 impl->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3228 impl->confirmContext->javascriptConfirmCallback = callback;
3229 impl->confirmContext->ewkView = ewkView;
3230 impl->confirmContext->userData = userData;
3233 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
3235 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3236 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3238 WKPageReplyJavaScriptConfirm(toAPI(impl->page()), result == EINA_TRUE);
3239 impl->isWaitingForJavaScriptPopupReply = false;
3242 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
3244 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3245 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3247 if (!impl->promptContext)
3248 impl->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3249 impl->promptContext->javascriptPromptCallback = callback;
3250 impl->promptContext->ewkView = ewkView;
3251 impl->promptContext->userData = userData;
3254 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
3256 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3257 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3259 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
3260 WKPageReplyJavaScriptPrompt(toAPI(impl->page()), result ? resultString.get() : 0);
3261 impl->isWaitingForJavaScriptPopupReply = false;
3264 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3265 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
3267 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3268 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3270 if (!impl->beforeUnloadConfirmPanelContext)
3271 impl->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3272 impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
3273 impl->beforeUnloadConfirmPanelContext->ewkView = ewkView;
3274 impl->beforeUnloadConfirmPanelContext->userData = userData;
3277 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
3279 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3280 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3282 WKPageReplyBeforeUnloadConfirmPanel(toAPI(impl->page()), result == EINA_TRUE);
3283 impl->isWaitingForJavaScriptPopupReply = false;
3287 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_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->openpanelContext)
3293 impl->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3295 impl->openpanelContext->openPanelCallback = callback;
3296 impl->openpanelContext->ewkView = ewkView;
3297 impl->openpanelContext->userData = userData;
3300 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
3302 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3303 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3305 if (!impl->openPanelListener)
3308 unsigned int size = eina_list_count(fileUrls);
3309 if ((result == EINA_FALSE) || (size == 0)) {
3310 WKOpenPanelResultListenerCancel(impl->openPanelListener);
3311 impl->openPanelListener = 0;
3315 WKTypeRef* items = new WKTypeRef[size];
3319 KURL base(KURL(), "file://");
3320 EINA_LIST_FOREACH(fileUrls, list, data) {
3321 KURL url(base, String::fromUTF8(static_cast<char*>(data)));
3322 items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
3324 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
3325 WKOpenPanelResultListenerChooseFiles(impl->openPanelListener, filesArray.get());
3326 impl->openPanelListener = 0;
3328 eina_list_free(fileUrls);
3331 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3332 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
3334 EINA_SAFETY_ON_NULL_RETURN(capable);
3335 EINA_SAFETY_ON_NULL_RETURN(context);
3337 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3339 ASSERT(webAppContext->webAppCapableCallback);
3341 TIZEN_LOGI("webAppCapableCallback exist. capable(%b)", capable);
3343 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
3345 webAppContext->webAppCapableCallback(0, webAppContext->userData);
3347 delete webAppContext;
3350 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
3352 EINA_SAFETY_ON_NULL_RETURN(iconURL);
3353 EINA_SAFETY_ON_NULL_RETURN(context);
3355 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3357 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3358 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3360 ASSERT(webAppContext->webAppIconURLCallback);
3363 impl->webAppIconURL = toImpl(iconURL)->string().utf8().data();
3364 webAppContext->webAppIconURLCallback(impl->webAppIconURL, webAppContext->userData);
3366 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
3368 delete webAppContext;
3371 static void didGetWebAppIconURLs(WKDictionaryRef iconURLs, WKErrorRef, void* context)
3373 EINA_SAFETY_ON_NULL_RETURN(iconURLs);
3374 EINA_SAFETY_ON_NULL_RETURN(context);
3376 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3378 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3379 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3381 ASSERT(webAppContext->webAppIconURLsCallback);
3383 if (impl->webAppIconURLs) {
3385 EINA_LIST_FREE(impl->webAppIconURLs, data)
3386 ewkWebAppIconDataDelete(static_cast<Ewk_Web_App_Icon_Data*>(data));
3389 WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(iconURLs));
3390 size_t iconURLCount = WKArrayGetSize(wkKeys.get());
3391 for (size_t i = 0; i < iconURLCount; i++) {
3392 WKStringRef urlRef = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
3393 WKStringRef sizeRef = static_cast<WKStringRef>(WKDictionaryGetItemForKey(iconURLs, urlRef));
3394 impl->webAppIconURLs = eina_list_append(impl->webAppIconURLs, ewkWebAppIconDataCreate(sizeRef, urlRef));
3396 TIZEN_LOGI("webAppIconURLsCallback exist. found %d icon urls", iconURLCount);
3398 webAppContext->webAppIconURLsCallback(impl->webAppIconURLs, webAppContext->userData);
3399 delete webAppContext;
3403 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
3405 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3406 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3407 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3408 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3410 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3411 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3412 context->webAppCapableCallback = callback;
3413 context->ewkView = ewkView;
3414 context->userData = userData;
3416 WKPageGetWebAppCapable(toAPI(impl->pageProxy.get()), context, didGetWebAppCapable);
3424 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
3426 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3427 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3428 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3429 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3431 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3432 context->webAppIconURLCallback = callback;
3433 context->ewkView = ewkView;
3434 context->userData = userData;
3436 WKPageGetWebAppIconURL(toAPI(impl->page()), context, didGetWebAppIconURL);
3444 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
3446 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3447 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3448 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3449 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3451 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3452 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3453 context->webAppIconURLsCallback = callback;
3454 context->ewkView = ewkView;
3455 context->userData = userData;
3457 WKPageGetWebAppIconURLs(toAPI(impl->page()), context, didGetWebAppIconURLs);
3461 UNUSED_PARAM(ewkView);
3462 UNUSED_PARAM(callback);
3463 UNUSED_PARAM(userData);
3468 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
3470 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3471 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3472 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
3474 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
3475 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
3476 WKPageExecuteCommandWithArgument(toAPI(impl->pageProxy.get()), commandString.get(), valueString.get());
3481 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
3488 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3489 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3491 IntSize contentsSize = impl->pageProxy->contentsSize();
3494 *width = contentsSize.width();
3496 *height = contentsSize.height();
3501 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
3503 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3504 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3505 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3506 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3508 IntSize contentsSize = impl->pageProxy->contentsSize();
3509 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3517 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, int width, int height, const char* fileName)
3519 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3520 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3521 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3522 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3524 IntSize contentsSize = impl->pageProxy->contentsSize();
3525 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3533 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
3535 EINA_SAFETY_ON_NULL_RETURN(context);
3536 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3538 if (!callbackContext->scriptExecuteCallback) {
3539 delete callbackContext;
3543 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
3546 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
3547 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
3548 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
3549 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3550 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
3551 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3553 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
3555 delete callbackContext;
3558 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
3560 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3561 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3562 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
3563 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3565 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3566 context->scriptExecuteCallback = callback;
3567 context->ewkView = ewkView;
3568 context->userData = user_data;
3569 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
3570 WKPageRunJavaScriptInMainFrame(toAPI(impl->pageProxy.get()), scriptString.get(), context, runJavaScriptCallback);
3575 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3576 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
3578 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
3581 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
3583 storageContext->webStorageQuotaCallback(0, storageContext->userData);
3585 delete storageContext;
3589 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
3591 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3592 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3593 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
3594 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3595 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3596 TIZEN_LOGI("resultCallback (%p)", resultCallback);
3598 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3599 context->webStorageQuotaCallback = resultCallback;
3600 context->userData = userData;
3602 WKPageRef pageRef = toAPI(impl->page());
3603 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
3611 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
3613 #if ENABLE(TIZEN_WEB_STORAGE)
3614 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3615 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3616 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3618 TIZEN_LOGI("quota (%d)", quota);
3619 WKPageRef pageRef = toAPI(impl->page());
3620 WKPageSetWebStorageQuota(pageRef, quota);
3628 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
3630 EINA_SAFETY_ON_NULL_RETURN(context);
3631 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3633 ASSERT(callbackContext->plainTextGetCallback);
3636 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
3637 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3638 WKStringGetUTF8CString(plain_text, buffer.get(), length);
3640 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3642 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
3644 delete callbackContext;
3647 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
3649 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3650 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3651 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3652 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3654 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3655 context->plainTextGetCallback = callback;
3656 context->ewkView = ewkView;
3657 context->userData = user_data;
3658 WKPageGetContentsAsString(toAPI(impl->pageProxy.get()), context, getContentsAsStringCallback);
3663 #if ENABLE(TIZEN_SUPPORT_MHTML)
3666 * Callback function used for ewk_view_mhtml_data_get().
3668 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
3670 EINA_SAFETY_ON_NULL_RETURN(context);
3671 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3673 ASSERT(callbackContext->mhtmlDataGetCallback);
3675 callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
3677 delete callbackContext;
3680 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
3682 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3683 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3684 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3686 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3687 context->mhtmlDataGetCallback = callback;
3688 context->ewkView = ewkView;
3689 context->userData = user_data;
3691 WKPageGetContentsAsMHTMLData(toAPI(impl->page()), false, context, getContentsAsMHTMLCallback);
3695 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
3697 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
3699 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
3700 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3701 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3703 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
3704 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest, hitTestMode);
3705 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
3713 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
3715 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3716 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3717 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3718 WebPageProxy* page = impl->page();
3719 EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
3721 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
3724 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3729 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
3731 #if ENABLE(TIZEN_NOTIFICATIONS)
3732 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3733 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3734 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context, false);
3736 TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
3737 if (!eina_list_count(ewkNotifications))
3740 Eina_List* listIterator = 0;
3742 Vector<WKTypeRef> ids;
3743 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
3744 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
3745 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
3747 impl->notifications = eina_list_remove(impl->notifications, notification);
3750 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
3751 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(impl->context->wkContext());
3752 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
3753 ewkNotificationDeleteNotificationList(ewkNotifications);
3761 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3762 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
3764 Eina_List* popupItems = 0;
3765 size_t size = items.size();
3766 for (size_t i = 0; i < size; ++i)
3767 popupItems = eina_list_append(popupItems, Ewk_Popup_Menu_Item::create(items[i]).leakPtr());
3768 TIZEN_LOGI("size : %d", size);
3772 static void releasePopupMenuList(Eina_List* popupMenuItems)
3774 if (!popupMenuItems)
3778 EINA_LIST_FREE(popupMenuItems, item)
3779 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3783 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
3785 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3786 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3787 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
3789 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3792 if (!impl->popupMenuProxy)
3795 impl->popupMenuProxy = 0;
3797 if (smartData->api->popup_menu_hide)
3798 smartData->api->popup_menu_hide(smartData);
3799 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3800 ewk_view_touch_events_enabled_set(ewkView, true);
3802 releasePopupMenuList(impl->popupMenuItems);
3803 impl->popupMenuItems = 0;
3806 EINA_LIST_FREE(impl->popupMenuItems, item)
3807 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3813 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
3815 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3816 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3817 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3819 TIZEN_LOGI("proxy : %p / index : %d", impl->popupMenuProxy, selectedIndex);
3821 if (!impl->popupMenuItems)
3825 if (selectedIndex >= eina_list_count(impl->popupMenuItems))
3828 impl->popupMenuProxy->valueChanged(selectedIndex);
3833 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3834 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
3836 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3837 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3838 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3839 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3841 if (!impl->popupMenuProxy)
3844 if (!smartData->api->popup_menu_update)
3847 releasePopupMenuList(impl->popupMenuItems);
3848 impl->popupMenuItems = createPopupMenuList(items);
3850 // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
3851 smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), impl->popupMenuItems, selectedIndex);
3855 #if ENABLE(TIZEN_MULTIPLE_SELECT)
3856 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
3858 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3859 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3860 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3862 Vector<int> selectedIndex;
3864 if (!impl->popupMenuItems)
3869 itr = eina_inarray_iterator_new(changeList);
3870 EINA_ITERATOR_FOREACH(itr, data)
3872 int* pData = static_cast<int*>(data);
3873 selectedIndex.append(*pData);
3875 eina_iterator_free(itr);
3877 impl->popupMenuProxy->multipleValueChanged(selectedIndex);
3882 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
3884 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
3885 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3886 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3887 TIZEN_LOGI("orientation : %d", orientation);
3889 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
3892 if (impl->orientation == orientation)
3895 impl->orientation = orientation;
3897 impl->pageProxy->sendOrientationChangeEvent(orientation);
3901 void ewkViewFrameRendered(Evas_Object* ewkView)
3903 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
3906 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3907 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3909 return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
3912 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
3914 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3915 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3917 IntRect leftSelectionRect;
3918 IntRect rightSelectionRect;
3919 if (!impl->pageProxy->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
3932 AffineTransform contentToScreen = impl->transformToScene();
3933 leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
3934 rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
3936 leftRect->x = leftSelectionRect.x();
3937 leftRect->y = leftSelectionRect.y();
3938 leftRect->w = leftSelectionRect.width();
3939 leftRect->h = leftSelectionRect.height();
3941 rightRect->x = rightSelectionRect.x();
3942 rightRect->y = rightSelectionRect.y();
3943 rightRect->w = rightSelectionRect.width();
3944 rightRect->h = rightSelectionRect.height();
3949 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
3951 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3952 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3954 const CString selectedString = impl->pageProxy->getSelectionText().utf8();
3955 impl->selectedText = selectedString.data();
3957 return impl->selectedText;
3960 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
3962 return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
3965 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
3967 return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
3970 void ewk_view_text_selection_range_clear(Evas_Object* ewkView)
3972 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3973 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3975 impl->pageProxy->selectionRangeClear();
3977 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3979 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3980 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
3982 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3983 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3984 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
3986 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
3990 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
3991 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
3993 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3994 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3995 IntPoint drawingPosition = (IntPoint)(impl->pageClient->visibleContentRect().location() - impl->pageClient->scrollPosition());
3997 *x = drawingPosition.x();
3999 *y = drawingPosition.y();
4001 *w = impl->pageClient->visibleContentRect().width();
4003 *h = impl->pageClient->visibleContentRect().height();
4007 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
4009 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4010 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4011 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4013 impl->pageProxy->setFocusedInputElementValue(String::fromUTF8(value));
4014 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4017 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
4019 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4020 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4021 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
4023 impl->inputValue = impl->pageProxy->getFocusedInputElementValue().utf8().data();
4024 return impl->inputValue;
4027 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4030 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4031 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
4033 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4034 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4035 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4036 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
4039 ewkViewDataListHideRequest(ewkView, inputType);
4041 for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
4043 impl->dataList = eina_list_append(impl->dataList, eina_stringshare_add(value.utf8().data()));
4046 smartData->api->data_list_show(smartData, inputType, impl->dataList);
4049 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
4051 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4052 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4053 EINA_SAFETY_ON_NULL_RETURN(impl->dataList);
4054 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4055 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
4057 impl->deleteDataList();
4059 smartData->api->data_list_hide(smartData, inputType);
4063 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
4065 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4066 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4067 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4069 impl->deleteDataList();
4071 ewk_view_focused_input_element_value_set(ewkView, value);
4075 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
4077 #if ENABLE(TIZEN_GESTURE)
4078 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4079 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4080 return impl->holdHorizontalPanning;
4086 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4088 #if ENABLE(TIZEN_GESTURE)
4089 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4090 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4091 impl->holdHorizontalPanning = hold;
4095 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
4097 #if ENABLE(TIZEN_GESTURE)
4098 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4099 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4100 return impl->holdVerticalPanning;
4106 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4108 #if ENABLE(TIZEN_GESTURE)
4109 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4110 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4111 impl->holdVerticalPanning = hold;
4115 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
4117 #if ENABLE(TIZEN_GESTURE)
4118 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4119 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4121 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4122 if (impl->focusRing && wasHandled)
4123 impl->focusRing->hide();
4124 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4126 if (impl->mouseEventsEnabled())
4129 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4130 if (wasHandled && impl->pageClient->isTextSelectionMode()) {
4131 if (type == WebEvent::TouchStart)
4132 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4133 else if (type == WebEvent::TouchMove)
4134 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4135 else if (type == WebEvent::TouchEnd)
4136 impl->pageClient->requestToShowTextSelectionHandlesAndContextMenu();
4140 // We have to check TouchStart, TouchMove and TouchEnd with handled.
4141 // The Pan and Flick will be enabled if Touch Start was not handled,
4142 // and Touch Move was not handled or did not occur.
4143 // Tap will be enabled if Touch Start and End was not handled
4144 // and Touch Move did not occur.
4145 // The gestures are disabled as a default.
4146 // o: handled, x: not handled
4147 // ------------------------------------------------------------
4148 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
4149 // ------------------------------------------------------------
4150 // o | o or x | o or x || disable | disable
4151 // x | o | o or x || disable | disable
4152 // x | x | o or x || disable | enable
4153 // x |not occured | x || enable | enable
4154 // ------------------------------------------------------------
4155 if (type == WebEvent::TouchStart) {
4156 impl->gestureClient->setGestureEnabled(!wasHandled);
4157 impl->wasHandledTouchStart = wasHandled;
4159 // Initialize wasHandledTouchMove to true and notify that to the application
4160 // to prevent applications scrolling at the beginning of touch.
4161 impl->wasHandledTouchMove = true;
4162 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&impl->wasHandledTouchMove));
4163 } else if (type == WebEvent::TouchMove) {
4164 impl->gestureClient->setMovingEnabled(!wasHandled);
4166 // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
4167 if (impl->wasHandledTouchStart)
4170 // Notify the result of touchmove to applications when handled value is changed
4171 // in order to make applications to choose whether scrolling its scrollable objects or not.
4172 if (impl->wasHandledTouchMove != wasHandled)
4173 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
4174 impl->wasHandledTouchMove = wasHandled;
4175 } else if (type == WebEvent::TouchEnd && !impl->exceedTouchMoveThreshold) {
4177 impl->gestureClient->setMovingEnabled(!wasHandled);
4178 impl->gestureClient->setTapEnabled(!wasHandled);
4180 #if ENABLE(TIZEN_ISF_PORT)
4181 else if (impl->pageProxy->isViewVisible()) {
4182 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(impl->touchDownPoint.x, impl->touchDownPoint.y));
4183 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest);
4184 if (hitTestResultData.isContentEditable && impl->inputMethodContext()) {
4185 evas_object_focus_set(ewkView, true);
4186 impl->inputMethodContext()->updateTextInputState();
4194 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
4195 void ewkViewTextStyleState(Evas_Object* ewkView, const IntPoint& startPoint, const IntPoint& endPoint)
4197 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4198 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4200 EditorState editorState = impl->page()->editorState();
4201 Ewk_Text_Style* textStyle = ewkTextStyleCreate(editorState, startPoint, endPoint);
4202 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
4203 ewkTextStyleDelete(textStyle);
4207 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
4208 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
4210 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4211 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4213 TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
4214 if (!smartData->api->orientation_lock) {
4219 return smartData->api->orientation_lock(smartData, willLockOrientation);
4222 void ewk_view_orientation_unlock(Evas_Object* ewkView)
4224 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4225 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4227 TIZEN_LOGI("ewkView (%p)", ewkView);
4228 if (!smartData->api->orientation_unlock) {
4233 smartData->api->orientation_unlock(smartData);
4237 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
4239 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4240 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4241 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4242 TIZEN_LOGI("callbacks: %p / data: %p", func, data);
4244 impl->orientationLock.callback = func;
4245 impl->orientationLock.data = data;
4249 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4250 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
4252 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
4253 TIZEN_LOGI("locked orientations : %d", orientations);
4255 if (impl->orientationLock.callback)
4256 return impl->orientationLock.callback(sd->self, true, orientations, impl->orientationLock.data);
4261 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
4263 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4264 TIZEN_LOGI("unlock is requested");
4266 if (impl->orientationLock.callback)
4267 impl->orientationLock.callback(sd->self, false, 0, impl->orientationLock.data);
4271 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
4272 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
4274 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4276 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
4277 const char *engine = ecore_evas_engine_name_get(ee);
4278 if (engine && !strcmp(engine, "opengl_x11"))
4284 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
4286 #if ENABLE(TIZEN_GESTURE)
4287 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4288 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4290 impl->gestureClient->setZoomableArea(target, area);
4294 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
4295 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
4297 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4298 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4300 WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(impl->pageProxy.get())));
4304 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
4305 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
4307 evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
4311 #if ENABLE(TIZEN_ICON_DATABASE)
4312 void ewkViewIconReceived(Evas_Object* ewkView)
4316 evas_object_smart_callback_call(ewkView, "icon,received", 0);
4320 #endif // #if OS(TIZEN)
4322 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
4324 #if ENABLE(TOUCH_EVENTS)
4325 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
4326 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4327 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4329 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
4330 if (impl->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
4331 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4332 IntPoint handlePoint(point->x, point->y);
4334 if (type == EWK_TOUCH_START)
4335 impl->pageClient->textSelectonHandleDown(handlePoint);
4336 else if (type == EWK_TOUCH_MOVE)
4337 impl->pageClient->textSelectonHandleMove(handlePoint);
4339 impl->pageClient->textSelectonHandleUp();
4341 if (impl->pageClient->isTextSelectionHandleDowned())
4346 #if ENABLE(TIZEN_GESTURE)
4347 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
4348 // We don't want to process touch event when context menu is shown.
4349 if ((impl->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
4350 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4351 && !impl->pageClient->isTextSelectionMode()
4356 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4357 if (impl->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
4361 if (type == EWK_TOUCH_START) {
4362 if (eina_list_count(points) == 1) {
4363 impl->gestureClient->reset();
4364 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4365 impl->touchDownPoint.x = point->x;
4366 impl->touchDownPoint.y = point->y;
4367 impl->exceedTouchMoveThreshold = false;
4369 } else if (type == EWK_TOUCH_MOVE && !impl->exceedTouchMoveThreshold) {
4370 if (eina_list_count(points) == 1) {
4371 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
4372 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4373 int diffX = impl->touchDownPoint.x - point->x;
4374 int diffY = impl->touchDownPoint.y - point->y;
4375 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
4376 impl->exceedTouchMoveThreshold = true;
4380 impl->exceedTouchMoveThreshold = true;
4383 #endif // #if ENABLE(TIZEN_GESTURE)
4385 // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
4386 //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4387 impl->pageProxy->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4395 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
4397 #if ENABLE(TOUCH_EVENTS)
4398 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4399 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4401 impl->setTouchEventsEnabled(!!enabled);
4409 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
4411 #if ENABLE(TOUCH_EVENTS)
4412 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4413 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4415 return impl->touchEventsEnabled();
4421 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
4423 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4424 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4425 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4427 impl->mainFrameScrollbarVisibility = visible;
4428 impl->pageClient->updateVisibility();
4436 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
4438 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4439 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4440 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4442 return impl->mainFrameScrollbarVisibility;
4448 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
4450 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
4451 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4452 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4453 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
4455 String title = ewk_view_title_get(ewkView);
4456 String url = ewk_view_url_get(ewkView);
4457 String directoryPath(path);
4458 impl->pageClient->startOfflinePageSave(directoryPath, url, title);
4462 UNUSED_PARAM(ewkView);
4470 * Callback function used for ewk_view_page_contents_get().
4472 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4474 EINA_SAFETY_ON_NULL_RETURN(context);
4476 RefPtr<WebData> webData = toImpl(wkData);
4477 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4478 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
4483 * Callback function used for ewk_view_page_contents_get().
4485 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
4487 EINA_SAFETY_ON_NULL_RETURN(context);
4489 RefPtr<WebString> webString = toImpl(wkString);
4490 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4491 contentsContext->callback(contentsContext->type, webString->string().utf8().data());
4494 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
4496 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
4497 EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
4498 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4499 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4501 switch (context->type) {
4502 case EWK_PAGE_CONTENTS_TYPE_MHTML:
4503 impl->pageProxy->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
4506 case EWK_PAGE_CONTENTS_TYPE_STRING:
4507 impl->pageProxy->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
4511 ASSERT_NOT_REACHED();
4518 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
4520 #if ENABLE(TIZEN_GESTURE)
4521 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4522 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4524 return impl->gestureClient->scrollToWithAnimation(x, y);
4526 UNUSED_PARAM(ewkView);
4533 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4534 void ewkViewFocusRingHide(Evas_Object* ewkView)
4536 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4537 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4539 if (impl->focusRing)
4540 impl->focusRing->hide();
4544 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
4546 #if ENABLE(TIZEN_CSP)
4547 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
4548 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4550 TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
4551 impl->pageProxy->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));
4555 #if ENABLE(TIZEN_APPLICATION_CACHE)
4556 Eina_Bool ewkViewRequestApplicationCachePermission(Evas_Object* ewkView, WKSecurityOriginRef origin)
4558 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4559 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4561 if (!impl->applicationCachePermissionContext || !impl->applicationCachePermissionContext->applicationCachePermissionCallback)
4564 impl->isWaitingForApplicationCachePermission = true;
4565 if (impl->applicationCachePermissionOrigin)
4566 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4567 impl->applicationCachePermissionOrigin = createSecurityOrigin(origin);
4569 return impl->applicationCachePermissionContext->applicationCachePermissionCallback(ewkView, impl->applicationCachePermissionOrigin, impl->applicationCachePermissionContext->userData) == EINA_TRUE;
4573 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
4575 #if ENABLE(TIZEN_APPLICATION_CACHE)
4576 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4577 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4579 if (!impl->applicationCachePermissionContext)
4580 impl->applicationCachePermissionContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4581 impl->applicationCachePermissionContext->applicationCachePermissionCallback = callback;
4582 impl->applicationCachePermissionContext->userData = userData;
4584 UNUSED_PARAM(ewkView);
4585 UNUSED_PARAM(callback);
4586 UNUSED_PARAM(userData);
4590 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
4592 #if ENABLE(TIZEN_APPLICATION_CACHE)
4593 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4594 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4596 TIZEN_LOGI("allow %d", allow);
4597 WKPageReplyApplicationCachePermission(toAPI(impl->page()), allow);
4598 if (impl->applicationCachePermissionOrigin)
4599 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4600 impl->applicationCachePermissionOrigin = 0;
4601 impl->isWaitingForApplicationCachePermission = false;
4603 UNUSED_PARAM(ewkView);
4604 UNUSED_PARAM(allow);
4608 #if ENABLE(TIZEN_INDEXED_DATABASE)
4609 bool ewkViewExceededIndexedDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4611 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4612 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4614 if (!impl->exceededIndexedDatabaseQuotaContext || !impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback)
4617 impl->isWaitingForExceededQuotaPopupReply = true;
4618 if (impl->exceededQuotaOrigin)
4619 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4620 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4622 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4624 return impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, currentUsage, impl->exceededIndexedDatabaseQuotaContext->userData) == EINA_TRUE;
4628 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4630 #if ENABLE(TIZEN_INDEXED_DATABASE)
4631 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4632 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4634 if (!impl->exceededIndexedDatabaseQuotaContext)
4635 impl->exceededIndexedDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4636 impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback = callback;
4637 impl->exceededIndexedDatabaseQuotaContext->userData = userData;
4639 UNUSED_PARAM(ewkView);
4640 UNUSED_PARAM(callback);
4641 UNUSED_PARAM(userData);
4645 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4647 #if ENABLE(TIZEN_INDEXED_DATABASE)
4648 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4649 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4651 TIZEN_LOGI("allow %d", allow);
4652 WKPageReplyExceededIndexedDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4653 if (impl->exceededQuotaOrigin)
4654 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4655 impl->exceededQuotaOrigin = 0;
4656 impl->isWaitingForExceededQuotaPopupReply = false;
4658 UNUSED_PARAM(ewkView);
4659 UNUSED_PARAM(allow);
4663 // EwkFindOptions should be matched up orders with WkFindOptions.
4664 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_CASE_INSENSITIVE, kWKFindOptionsCaseInsensitive);
4665 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_AT_WORD_STARTS, kWKFindOptionsAtWordStarts);
4666 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, kWKFindOptionsTreatMedialCapitalAsWordStart);
4667 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_BACKWARDS, kWKFindOptionsBackwards);
4668 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_WRAP_AROUND, kWKFindOptionsWrapAround);
4669 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_OVERLAY, kWKFindOptionsShowOverlay);
4670 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR, kWKFindOptionsShowFindIndicator);
4671 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShowHighlight);
4673 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4675 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4676 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4677 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4679 impl->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4684 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4686 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4687 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4689 impl->pageProxy->hideFindUI();
4694 Eina_Bool ewk_view_text_matches_count(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4696 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4697 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4698 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4700 impl->pageProxy->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4705 void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData)
4707 #if ENABLE(TIZEN_SQL_DATABASE)
4708 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4709 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4711 if (!impl->exceededDatabaseQuotaContext)
4712 impl->exceededDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4713 impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback = callback;
4714 impl->exceededDatabaseQuotaContext->userData = userData;
4716 UNUSED_PARAM(ewkView);
4717 UNUSED_PARAM(callback);
4718 UNUSED_PARAM(userData);
4722 void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4724 #if ENABLE(TIZEN_SQL_DATABASE)
4725 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4726 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4728 TIZEN_LOGI("allow %d", allow);
4729 WKPageReplyExceededDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4730 if (impl->exceededQuotaOrigin)
4731 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4732 impl->exceededQuotaOrigin = 0;
4733 impl->isWaitingForExceededQuotaPopupReply = false;
4735 UNUSED_PARAM(ewkView);
4736 UNUSED_PARAM(allow);
4740 #if ENABLE(TIZEN_FILE_SYSTEM)
4741 bool ewkViewExceededLocalFileSystemQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4743 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4744 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4746 if (!impl->exceededLocalFileSystemQuotaContext || !impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback)
4749 impl->isWaitingForExceededQuotaPopupReply = true;
4750 if (impl->exceededQuotaOrigin)
4751 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4752 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4754 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4756 return impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback(ewkView, impl->exceededQuotaOrigin , currentUsage, impl->exceededLocalFileSystemQuotaContext->userData) == EINA_TRUE;
4760 void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4762 #if ENABLE(TIZEN_FILE_SYSTEM)
4763 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4764 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4766 if (!impl->exceededLocalFileSystemQuotaContext)
4767 impl->exceededLocalFileSystemQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4768 impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback = callback;
4769 impl->exceededLocalFileSystemQuotaContext->userData = userData;
4771 UNUSED_PARAM(ewkView);
4772 UNUSED_PARAM(callback);
4773 UNUSED_PARAM(userData);
4777 void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4779 #if ENABLE(TIZEN_FILE_SYSTEM)
4780 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4781 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4783 TIZEN_LOGI("allow %d", allow);
4784 WKPageReplyExceededLocalFileSystemQuota(toAPI(impl->page()), allow == EINA_TRUE);
4785 if (impl->exceededQuotaOrigin)
4786 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4787 impl->exceededQuotaOrigin = 0;
4788 impl->isWaitingForExceededQuotaPopupReply = false;
4790 UNUSED_PARAM(ewkView);
4791 UNUSED_PARAM(result);
4795 void ewk_view_rotation_prepare(Evas_Object* ewkView, int angle)
4797 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4798 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4799 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4802 if (angle == 0 || angle == 180) {
4803 width = WebCore::getDefaultScreenResolution().width();
4804 height = WebCore::getDefaultScreenResolution().height() + 100;
4806 if (angle == 90 || angle == 270) {
4807 width = WebCore::getDefaultScreenResolution().height();
4808 height = WebCore::getDefaultScreenResolution().width() + 100;
4811 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
4812 impl->pageClient->setWaitFrameOfNewViewortSize(true);
4813 ewk_view_suspend(ewkView);
4814 impl->pageClient->updateViewportSize(IntSize(width, height), angle);
4818 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4819 void ewkViewRotatePrepared(Evas_Object* ewkView)
4821 evas_object_smart_callback_call(ewkView, "rotate,prepared", 0);
4825 void ewk_view_use_settings_font(Evas_Object* ewkView)
4827 #if ENABLE(TIZEN_USE_SETTINGS_FONT)
4828 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4829 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4831 impl->pageProxy->useSettingsFont();
4835 void ewk_view_fullscreen_exit(Evas_Object* ewkView)
4837 #if ENABLE(TIZEN_FULLSCREEN_API)
4840 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4841 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4843 if (!impl->pageProxy->fullScreenManager()->isFullScreen())
4846 impl->pageProxy->fullScreenManager()->requestExitFullScreen();
4848 UNUSED_PARAM(ewkView);