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 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
554 impl->focusRing->requestToHide(true);
556 impl->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
559 case EWK_GESTURE_LONG_PRESS:
560 // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
561 impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
563 case EWK_GESTURE_PAN:
564 impl->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
566 case EWK_GESTURE_FLICK:
567 impl->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
569 case EWK_GESTURE_PINCH:
570 impl->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
573 ASSERT_NOT_REACHED();
580 #endif // #if ENABLE(TIZEN_GESTURE)
583 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
585 #if ENABLE(TIZEN_GESTURE)
586 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
588 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
589 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
593 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
594 if (impl->focusRing && !(event->type == EWK_GESTURE_PAN && !impl->exceedTouchMoveThreshold)) {
595 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
596 if (!impl->pageClient->isContextMenuVisible())
598 impl->focusRing->requestToHide(true);
602 switch (event->type) {
603 case EWK_GESTURE_PAN:
604 impl->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
606 case EWK_GESTURE_TAP:
607 case EWK_GESTURE_LONG_PRESS:
608 case EWK_GESTURE_FLICK:
610 case EWK_GESTURE_PINCH:
611 if (impl->pageClient->viewportConstraints().userScalable)
612 impl->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
615 ASSERT_NOT_REACHED();
622 #endif // #if ENABLE(TIZEN_GESTURE)
624 #endif //#if OS(TIZEN)
627 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
629 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
630 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
631 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
632 smartData->api->focus_in(smartData);
635 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
637 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
638 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
639 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
640 smartData->api->focus_out(smartData);
643 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
645 Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
646 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
647 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
648 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
649 smartData->api->mouse_wheel(smartData, wheelEvent);
652 static void _ewk_view_on_key_down(void* data, Evas*, Evas_Object*, void* eventInfo)
654 Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
655 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
656 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
657 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
658 smartData->api->key_down(smartData, downEvent);
661 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
663 Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
664 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
665 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
666 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
667 smartData->api->key_up(smartData, upEvent);
670 static void _ewk_view_on_show(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
672 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
673 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
674 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
677 static void _ewk_view_on_hide(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
679 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
680 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
682 // This call may look wrong, but we really need to pass ViewIsVisible here.
683 // viewStateDidChange() itself is responsible for actually setting the visibility to Visible or Hidden
684 // depending on what WebPageProxy::isViewVisible() returns, this simply triggers the process.
685 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
690 #if ENABLE(TIZEN_FULLSCREEN_API)
691 Eina_Bool _ewk_view_smart_fullscreen_enter(Ewk_View_Smart_Data* smartData)
693 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
695 ewk_view_main_frame_scrollbar_visible_set(impl->view(), false);
696 evas_object_smart_callback_call(impl->view(), "fullscreen,enterfullscreen", 0);
700 Eina_Bool _ewk_view_smart_fullscreen_exit(Ewk_View_Smart_Data* smartData)
702 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
704 ewk_view_main_frame_scrollbar_visible_set(impl->view(), true);
705 evas_object_smart_callback_call(impl->view(), "fullscreen,exitfullscreen", 0);
710 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
711 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
713 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
715 return impl->pageClient->textSelectionDown(IntPoint(x, y));
718 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
720 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
722 IntPoint point(x, y);
723 impl->pageClient->textSelectionMove(point);
728 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
730 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
732 IntPoint point(x, y);
733 impl->pageClient->textSelectionUp(point, true);
739 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
740 Eina_Bool _ewk_view_smart_formdata_candidate_show(Ewk_View_Smart_Data* smartData, int x, int y, int w, int h)
742 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
744 impl->pageClient->showFormDataCandidate(IntRect(x, y, w, h));
749 Eina_Bool _ewk_view_smart_formdata_candidate_hide(Ewk_View_Smart_Data* smartData)
751 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
753 impl->pageClient->hideFormDataCandidate();
758 Eina_Bool _ewk_view_smart_formdata_candidate_update_data(Ewk_View_Smart_Data* smartData, Eina_List* dataList)
760 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
762 Vector<String> formData;
765 EINA_LIST_FOREACH(dataList, list, data)
766 formData.append(String::fromUTF8(static_cast<char*>(data)));
768 impl->pageClient->updateFormDataCandidate(formData);
773 Eina_Bool _ewk_view_smart_formdata_candidate_is_showing(Ewk_View_Smart_Data* smartData)
775 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
777 return impl->pageClient->isShowingFormDataCandidate();
781 #if ENABLE(TIZEN_SCREEN_READER)
782 Eina_Bool _ewk_view_screen_reader_action_execute(Ewk_View_Smart_Data* smartData, void* actionInfo)
784 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
786 return ScreenReaderProxy::executeAction(impl, 0, static_cast<Elm_Access_Action_Info*>(actionInfo));
789 #endif // #if OS(TIZEN)
791 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
793 static void _ewk_view_impl_del(EwkViewImpl* impl)
795 #if !ENABLE(TIZEN_ICON_DATABASE)
796 /* Unregister icon change callback */
797 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
798 iconDatabase->unwatchChanges(_ewk_view_on_favicon_changed);
804 static void _ewk_view_smart_add(Evas_Object* ewkView)
806 const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
807 const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
808 const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
809 EWK_VIEW_SD_GET(ewkView, smartData);
812 smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
814 EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
817 evas_object_smart_data_set(ewkView, smartData);
820 smartData->self = ewkView;
821 smartData->api = api;
823 g_parentSmartClass.add(ewkView);
825 smartData->priv = new EwkViewImpl(ewkView);
826 if (!smartData->priv) {
827 EINA_LOG_CRIT("could not allocate EwkViewImpl");
828 evas_object_smart_data_set(ewkView, 0);
833 // Create evas_object_image to draw web contents.
834 smartData->image = evas_object_image_add(smartData->base.evas);
835 evas_object_image_alpha_set(smartData->image, false);
836 evas_object_image_filled_set(smartData->image, true);
837 evas_object_smart_member_add(smartData->image, ewkView);
840 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
841 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
842 const char *engine = ecore_evas_engine_name_get(ee);
843 if (engine && !strcmp(engine, "opengl_x11"))
844 evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
846 ewk_view_mouse_events_enabled_set(ewkView, false);
847 ewk_view_touch_events_enabled_set(ewkView, true);
849 // FIXME: This code should be removed if side effect occur.
850 // WebView does not have focus after url loading.
851 // If focus is set as true to webview,
852 // elementary steal webview's focus during mouse up event
853 // So, added code that events are not propagated to smart parent according to guide from EFL
854 evas_object_propagate_events_set(ewkView, false);
855 #endif // #if OS(TIZEN)
857 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
858 CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
859 CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
860 CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
861 CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
862 CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
863 CONNECT(EVAS_CALLBACK_SHOW, _ewk_view_on_show);
864 CONNECT(EVAS_CALLBACK_HIDE, _ewk_view_on_hide);
868 static void _ewk_view_smart_del(Evas_Object* ewkView)
870 EwkViewImpl::removeFromPageViewMap(ewkView);
871 EWK_VIEW_SD_GET(ewkView, smartData);
872 #if ENABLE(TIZEN_SCREEN_READER)
873 ScreenReaderProxy::screenReader().finalize(smartData->priv);
875 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
876 // Close color picker if it's opened.
877 if (smartData && smartData->priv && smartData->priv->inputPicker->isColorPickerShown())
878 ewk_view_color_picker_color_set(ewkView, 0, 0, 0, 0);
880 if (smartData && smartData->priv)
881 _ewk_view_impl_del(smartData->priv);
883 g_parentSmartClass.del(ewkView);
886 static Eina_Bool _ewk_view_composite(void* data);
888 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
890 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
892 evas_object_resize(smartData->image, width, height);
893 evas_object_image_size_set(smartData->image, width, height);
894 evas_object_image_fill_set(smartData->image, 0, 0, width, height);
896 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
897 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
898 evas_object_image_native_surface_set(smartData->image, 0);
900 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
901 if (impl->pageClient->isVisible()) {
902 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
903 impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee));
905 impl->pageClient->setDeferUpdateViewportSize(true);
907 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
908 impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee));
911 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
912 if (!ewk_view_is_opengl_backend(ewkView))
913 _ewk_view_composite(smartData);
914 else // OpenGL backend
916 impl->pageClient->displayViewport();
918 #endif // #if OS(TIZEN)
920 smartData->changed.size = true;
921 _ewk_view_smart_changed(smartData);
924 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
926 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
928 smartData->changed.position = true;
929 _ewk_view_smart_changed(smartData);
932 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
934 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
935 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
937 Evas_Coord x, y, width, height;
939 smartData->changed.any = false;
941 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
943 if (smartData->changed.size) {
945 #if USE(COORDINATED_GRAPHICS)
946 impl->pageViewportControllerClient->updateViewportSize(IntSize(width, height));
948 #if USE(ACCELERATED_COMPOSITING)
949 needsNewSurface = impl->evasGlSurface;
952 if (impl->pageProxy->drawingArea())
953 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
955 #if USE(ACCELERATED_COMPOSITING)
956 if (!impl->evasGlSurface)
958 evas_gl_surface_destroy(impl->evasGl, impl->evasGlSurface);
959 impl->evasGlSurface = 0;
960 ewk_view_create_gl_surface(ewkView, IntSize(width, height));
961 ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
963 #endif // #if !OS(TIZEN)
965 smartData->view.w = width;
966 smartData->view.h = height;
967 smartData->changed.size = false;
970 if (impl->pageClient) {
971 if (DrawingAreaProxy* drawingArea = impl->pageProxy->drawingArea()) {
972 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
973 if (impl->pageProxy->isViewVisible())
974 drawingArea->setSize(IntSize(width, height), IntSize());
976 drawingArea->setSize(IntSize(width, height), IntSize());
978 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
979 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
980 int newAngle = ecore_evas_rotation_get(ee);
981 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
982 if (impl->pageClient->deferUpdateViewportSize()) {
983 impl->pageClient->updateViewportSize(IntSize(width, height), newAngle);
986 impl->pageClient->updateVisibleContentRectSize(IntSize(width, height));
987 if (ewk_view_is_opengl_backend(ewkView))
988 impl->pageClient->displayViewport();
991 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
992 impl->pageClient->frameRectChanged();
995 #endif // #if OS(TIZEN)
998 if (smartData->changed.position) {
999 evas_object_move(smartData->image, x, y);
1000 smartData->view.x = x;
1001 smartData->view.y = y;
1002 smartData->changed.position = false;
1004 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1005 impl->pageClient->frameRectChanged();
1007 #if ENABLE(TIZEN_SCREEN_READER)
1008 impl->pageProxy->recalcScreenReaderFocusRect();
1010 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1011 impl->pageClient->updateTextSelectionHandlesAndContextMenu(true);
1013 #endif // #if OS(TIZEN)
1016 if (impl->popupPicker)
1017 ewk_popup_picker_resize(impl->popupPicker);
1018 #endif // #if OS(TIZEN)
1021 static void _ewk_view_smart_show(Evas_Object* ewkView)
1023 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1024 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1026 if (evas_object_clipees_get(smartData->base.clipper))
1027 evas_object_show(smartData->base.clipper);
1028 evas_object_show(smartData->image);
1030 #if ENABLE(TIZEN_SCREEN_READER)
1031 ScreenReaderProxy::screenReader().initialize(impl);
1035 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1037 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1039 evas_object_hide(smartData->base.clipper);
1040 evas_object_hide(smartData->image);
1041 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1042 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1043 if (impl->pageClient->isTextSelectionMode())
1044 impl->pageClient->setIsTextSelectionMode(false);
1048 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1050 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1051 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1055 else if (alpha > 255)
1058 #define CHECK_COLOR(color, alpha) \
1061 else if (color > alpha) \
1063 CHECK_COLOR(red, alpha);
1064 CHECK_COLOR(green, alpha);
1065 CHECK_COLOR(blue, alpha);
1068 evas_object_image_alpha_set(smartData->image, alpha < 255);
1069 impl->pageProxy->setDrawsBackground(red || green || blue);
1070 impl->pageProxy->setDrawsTransparentBackground(alpha < 255);
1071 impl->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1074 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1078 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1080 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1082 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1083 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1084 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1088 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1089 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1091 evas_object_smart_clipped_smart_set(&api->sc);
1093 // Set Evas_Smart_Class functions.
1094 api->sc.add = _ewk_view_smart_add;
1095 api->sc.del = _ewk_view_smart_del;
1096 api->sc.move = _ewk_view_smart_move;
1097 api->sc.resize = _ewk_view_smart_resize;
1098 api->sc.show = _ewk_view_smart_show;
1099 api->sc.hide = _ewk_view_smart_hide;
1100 api->sc.color_set = _ewk_view_smart_color_set;
1101 api->sc.calculate = _ewk_view_smart_calculate;
1102 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1104 // Set Ewk_View_Smart_Class functions.
1105 api->focus_in = _ewk_view_smart_focus_in;
1106 api->focus_out = _ewk_view_smart_focus_out;
1107 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1108 api->mouse_down = _ewk_view_smart_mouse_down;
1109 api->mouse_up = _ewk_view_smart_mouse_up;
1110 api->mouse_move = _ewk_view_smart_mouse_move;
1111 api->key_down = _ewk_view_smart_key_down;
1112 api->key_up = _ewk_view_smart_key_up;
1114 api->gesture_start = _ewk_view_smart_gesture_start;
1115 api->gesture_end = _ewk_view_smart_gesture_end;
1116 api->gesture_move = _ewk_view_smart_gesture_move;
1118 #if ENABLE(TIZEN_FULLSCREEN_API)
1119 api->fullscreen_enter = _ewk_view_smart_fullscreen_enter;
1120 api->fullscreen_exit = _ewk_view_smart_fullscreen_exit;
1123 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1124 api->popup_menu_show = _ewk_view_popup_menu_show;
1125 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1126 api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1128 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1129 api->popup_menu_update = _ewk_view_popup_menu_update;
1131 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1132 api->text_selection_down = _ewk_view_text_selection_down;
1133 api->text_selection_move = _ewk_view_text_selection_move;
1134 api->text_selection_up = _ewk_view_text_selection_up;
1136 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1137 api->input_picker_show = _ewk_view_input_picker_show;
1139 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1140 api->data_list_show = _ewk_view_data_list_show;
1141 api->data_list_hide = _ewk_view_data_list_hide;
1143 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1144 api->orientation_lock = _ewk_orientation_lock;
1145 api->orientation_unlock = _ewk_orientation_unlock;
1147 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1148 api->input_picker_color_request = _ewk_input_picker_color_request;
1149 api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1151 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1152 api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1153 api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1154 api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1155 api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1157 #if ENABLE(TIZEN_SCREEN_READER)
1158 api->screen_reader_action_execute = _ewk_view_screen_reader_action_execute;
1160 #endif //#if OS(TIZEN)
1165 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1167 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1168 static Evas_Smart* smart = 0;
1170 if (EINA_UNLIKELY(!smart)) {
1171 ewk_view_smart_class_set(&api);
1172 smart = evas_smart_class_new(&api.sc);
1178 static void _ewk_view_initialize(Evas_Object* ewkView, PassRefPtr<Ewk_Context> context, WKPageGroupRef pageGroupRef)
1180 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1181 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1182 EINA_SAFETY_ON_NULL_RETURN(context);
1184 if (impl->pageClient)
1187 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1188 bool isOpenGL = ewk_view_is_opengl_backend(ewkView);
1190 impl->pageClient = PageClientEvasGL::create(impl);
1192 impl->pageClient = PageClientImpl::create(impl);
1194 impl->pageClient = PageClientImpl::create(impl);
1198 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), toImpl(pageGroupRef));
1200 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), WebPageGroup::create().get());
1202 EwkViewImpl::addToPageViewMap(ewkView);
1205 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
1206 impl->pageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
1207 impl->pageProxy->pageGroup()->preferences()->setFrameFlatteningEnabled(true);
1208 impl->pageProxy->pageGroup()->preferences()->setAllowUniversalAccessFromFileURLs(true);
1211 impl->pageProxy->initializeWebPage();
1213 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
1214 impl->pageProxy->setCustomDeviceScaleFactor((float)getMobileDPI() / 160);
1216 impl->pageProxy->setCustomDeviceScaleFactor((float)getDPI() / 160);
1219 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1220 impl->pageProxy->setUseFixedLayout(true);
1222 #if ENABLE(FULLSCREEN_API)
1223 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1226 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1228 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1230 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1231 impl->pageProxy->pageGroup()->preferences()->setWebGLEnabled(false);
1232 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1236 impl->backForwardList = Ewk_Back_Forward_List::create(toAPI(impl->pageProxy->backForwardList()));
1238 impl->context = context;
1241 ewkViewContextMenuClientAttachClient(ewkView);
1242 ewkViewTizenClientAttachClient(ewkView);
1244 #if ENABLE(TIZEN_GEOLOCATION)
1245 ewkViewGeolocationProviderAttachProvider(ewkView, impl->context->wkContext());
1248 #if ENABLE(TIZEN_NOTIFICATIONS)
1249 ewkViewNotificationProviderAttachProvider(ewkView, impl->context->wkContext());
1252 #if ENABLE(TIZEN_ICON_DATABASE)
1253 ewk_view_icondatabase_client_attach(ewkView, impl->context->wkContext());
1256 ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1257 ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1258 ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1259 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1260 ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1262 ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1263 #else // #if OS(TIZEN)
1264 #if USE(COORDINATED_GRAPHICS)
1265 impl->viewportHandler = EflViewportHandler::create(impl->pageClient.get());
1267 #endif // #if OS(TIZEN)
1269 #if ENABLE(FULLSCREEN_API)
1270 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1271 impl->pageProxy->pageGroup()->preferences()->setFullScreenEnabled(true);
1274 // Initialize page clients.
1275 impl->pageLoadClient = PageLoadClientEfl::create(impl);
1276 impl->pagePolicyClient = PagePolicyClientEfl::create(impl);
1277 impl->pageUIClient = PageUIClientEfl::create(impl);
1278 impl->resourceLoadClient = ResourceLoadClientEfl::create(impl);
1279 impl->findClient = FindClientEfl::create(impl);
1280 impl->formClient = FormClientEfl::create(impl);
1281 #if !ENABLE(TIZEN_ICON_DATABASE)
1282 /* Listen for favicon changes */
1283 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
1284 iconDatabase->watchChanges(IconChangeCallbackData(_ewk_view_on_favicon_changed, ewkView));
1286 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1287 ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1290 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1291 if (!impl->context->xWindow())
1292 impl->context->setXWindow(elm_win_xwindow_get(ewkView));
1295 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1296 impl->focusRing = FocusRing::create(impl);
1300 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1302 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1303 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1305 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1307 using namespace EGL;
1308 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1309 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1315 Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1319 EWK_VIEW_SD_GET(ewkView, smartData);
1321 evas_object_del(ewkView);
1325 EWK_VIEW_IMPL_GET(smartData, impl);
1327 evas_object_del(ewkView);
1336 * Constructs a ewk_view Evas_Object with WKType parameters.
1338 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1340 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1341 EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1343 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1347 _ewk_view_initialize(ewkView, Ewk_Context::create(contextRef), pageGroupRef);
1352 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1354 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1355 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1356 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1358 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1362 #if ENABLE(TIZEN_ICON_DATABASE)
1363 //set default iconDatabasePath
1364 WKContextRef contextRef = context->wkContext();
1365 toImpl(contextRef)->setIconDatabasePath(toImpl(contextRef)->iconDatabasePath());
1368 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1369 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1370 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1371 _ewk_view_initialize(ewkView, context, toAPI(impl->pageGroup.get()));
1373 _ewk_view_initialize(ewkView, context, 0);
1379 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1381 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1382 return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1385 Evas_Object* ewk_view_add(Evas* canvas)
1387 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1390 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
1392 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1393 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1395 return impl->ewkContext();
1398 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* url)
1400 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1401 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1402 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
1404 impl->pageProxy->loadURL(String::fromUTF8(url));
1405 impl->informURLChange();
1410 const char* ewk_view_url_get(const Evas_Object* ewkView)
1412 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1413 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1418 const char *ewk_view_icon_url_get(const Evas_Object *ewkView)
1420 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1421 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1423 return impl->faviconURL();
1426 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1428 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1429 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1431 impl->pageClient->prepareRestoredVisibleContectRect();
1432 impl->pageProxy->reload(/*reloadFromOrigin*/ false);
1433 impl->informURLChange();
1438 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1440 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1441 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1443 impl->pageProxy->reload(/*reloadFromOrigin*/ true);
1444 impl->informURLChange();
1449 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1451 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1452 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1454 impl->pageProxy->stopLoading();
1459 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1461 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1462 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1464 return impl->settings();
1467 const char* ewk_view_title_get(const Evas_Object* ewkView)
1469 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1470 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1472 return impl->title();
1477 * Reports that the requested text was found.
1479 * Emits signal: "text,found" with the number of matches.
1481 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
1483 evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
1486 double ewk_view_load_progress_get(const Evas_Object* ewkView)
1488 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1489 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1491 return impl->pageProxy->estimatedProgress();
1494 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
1496 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1497 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1503 scaleFactor = impl->pageClient->adjustScaleWithViewport(scaleFactor);
1505 IntPoint scrollPosition = impl->pageClient->scrollPosition();
1506 double scaleDifference = scaleFactor / impl->pageClient->scaleFactor();
1507 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
1508 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
1510 impl->pageProxy->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
1512 impl->pageProxy->scalePage(scaleFactor, IntPoint(x, y));
1517 double ewk_view_scale_get(const Evas_Object* ewkView)
1519 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
1520 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1);
1523 return impl->pageProxy->scaleFactor();
1525 return impl->pageProxy->pageScaleFactor();
1529 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
1531 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1532 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1534 impl->pageProxy->setCustomDeviceScaleFactor(ratio);
1539 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
1541 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1542 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1544 return impl->pageProxy->deviceScaleFactor();
1547 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
1549 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1550 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1552 impl->setThemePath(path);
1555 const char* ewk_view_theme_get(const Evas_Object* ewkView)
1557 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1558 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1560 return impl->themePath();
1563 Eina_Bool ewk_view_back(Evas_Object* ewkView)
1565 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1566 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1568 WebPageProxy* page = impl->pageProxy.get();
1569 if (page->canGoBack()) {
1577 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
1579 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1580 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1582 WebPageProxy* page = impl->pageProxy.get();
1583 if (page->canGoForward()) {
1591 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
1593 #if ENABLE(WEB_INTENTS)
1594 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1595 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1596 EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
1598 WebPageProxy* page = impl->pageProxy.get();
1599 page->deliverIntentToFrame(page->mainFrame(), intent->webIntentData());
1607 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
1609 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1610 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1612 return impl->pageProxy->canGoBack();
1615 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
1617 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1618 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1620 return impl->pageProxy->canGoForward();
1623 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
1625 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1626 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1628 return impl->backForwardList.get();
1631 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1632 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
1634 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1635 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1637 if (!ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
1640 if (value.isEmpty()) {
1641 if(smartData->api->formdata_candidate_is_showing(smartData))
1642 smartData->api->formdata_candidate_hide(smartData);
1646 Vector<String> popupCandidates;
1647 ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
1648 std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
1650 Eina_List* candidateList = 0;
1651 for (size_t i = 0; i < popupCandidates.size(); ++i) {
1652 if (popupCandidates[i].startsWith(value, false))
1653 candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
1656 if (!eina_list_count(candidateList)) {
1657 if(smartData->api->formdata_candidate_is_showing(smartData))
1658 smartData->api->formdata_candidate_hide(smartData);
1662 smartData->api->formdata_candidate_update_data(smartData, candidateList);
1664 IntRect inputFieldRect = impl->transformToScene().mapRect(impl->pageClient->focusedNodeRect());
1665 smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
1668 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm)
1670 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1671 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1672 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
1673 && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
1675 ewk_view_context_get(ewkView)->addFormData(impl->url(), formData, isPasswordForm);
1678 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
1680 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1681 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1683 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
1686 Vector<std::pair<String, String> > passwordFormData;
1687 ewk_view_context_get(ewkView)->passwordFormData(impl->url(), passwordFormData);
1689 if (!passwordFormData.size())
1692 String passwordFormAutofill = String::fromUTF8("try { function passwordFormAutofill() { var inputFields;");
1693 for (size_t i = 0; i < passwordFormData.size(); i++) {
1694 passwordFormAutofill += String::fromUTF8(" inputFields = document.getElementsByName(\"");
1695 passwordFormAutofill += passwordFormData[i].first;
1696 passwordFormAutofill += String::fromUTF8("\");");
1697 passwordFormAutofill += String::fromUTF8(" for (var i = 0; i < inputFields.length; i++)");
1698 passwordFormAutofill += String::fromUTF8(" if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\" || inputFields[i].type.toLowerCase() == \"email\"))");
1699 passwordFormAutofill += String::fromUTF8(" inputFields[i].value = \"");
1700 passwordFormAutofill += passwordFormData[i].second;
1701 passwordFormAutofill += String::fromUTF8("\";");
1703 passwordFormAutofill += String::fromUTF8("} passwordFormAutofill(); } catch(e) { }");
1704 ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
1707 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
1709 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1710 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1711 ewk_view_context_get(ewkView)->candidateFormData(name, candidates);
1715 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
1717 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1718 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1719 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
1721 if (unreachableUrl && *unreachableUrl)
1722 impl->pageProxy->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
1724 impl->pageProxy->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
1726 impl->informURLChange();
1731 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
1733 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1734 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1736 return impl->customTextEncodingName();
1739 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
1741 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1742 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1744 impl->setCustomTextEncodingName(encoding);
1750 // FIXME: It should be removed.
1751 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
1753 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1754 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1756 return toAPI(impl->pageProxy.get());
1759 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
1761 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1762 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1764 impl->setMouseEventsEnabled(!!enabled);
1769 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
1771 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1772 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1774 return impl->mouseEventsEnabled();
1777 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
1779 #if ENABLE(INPUT_TYPE_COLOR)
1780 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1781 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1783 return impl->setColorPickerColor(WebCore::Color(r, g, b, a));
1789 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
1791 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1792 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1794 return impl->javascriptPopup->alert(alertText);
1797 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
1799 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1800 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1802 return impl->javascriptPopup->confirm(message);
1805 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
1807 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1808 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1810 return impl->javascriptPopup->prompt(message, defaultValue);
1813 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1814 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, void* userData)
1816 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1817 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1819 return impl->javascriptPopup->beforeUnloadConfirmPanel(message);
1823 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)
1825 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1826 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1828 return impl->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, impl);
1831 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1832 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)
1834 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1836 if (impl->popupPicker)
1837 ewk_popup_picker_del(impl->popupPicker);
1839 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1840 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
1842 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
1848 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1849 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)
1851 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1853 if (impl->popupPicker)
1854 ewk_popup_picker_del(impl->popupPicker);
1856 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
1862 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
1864 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1866 if (!impl->popupPicker)
1869 ewk_popup_picker_del(impl->popupPicker);
1870 impl->popupPicker = 0;
1875 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)
1877 // FIXME: The rect should be updated if it was changed
1879 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1881 if (!impl->popupPicker)
1884 ewk_popup_picker_update(smartData->self, impl->popupPicker, items, selectedIndex);
1890 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1891 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
1893 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1895 impl->inputPicker->show(inputType, inputValue);
1900 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1901 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
1903 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1905 impl->inputPicker->showDataList(inputType, optionList);
1909 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
1911 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1913 impl->inputPicker->hideDataList(inputType);
1918 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1919 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
1921 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1923 impl->inputPicker->showColorPicker(r, g, b, a);
1927 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
1929 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1931 impl->inputPicker->hideColorPicker();
1936 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
1938 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1939 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1941 return impl->pageClient.get();
1944 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
1946 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
1947 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 1);
1949 return WKPageGetTextZoomFactor(toAPI(impl->pageProxy.get()));
1952 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
1954 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1955 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1957 WKPageSetTextZoomFactor(toAPI(impl->pageProxy.get()), textZoomFactor);
1961 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1962 FocusRing* ewkViewGetFocusRing(Evas_Object* ewkView)
1964 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1965 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1967 return impl->focusRing.get();
1971 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
1973 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1974 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1976 return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(impl->pageProxy.get())));
1979 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
1981 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1982 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1984 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(impl->pageProxy.get())));
1987 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
1989 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1990 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1992 if (!impl->javascriptGlobalContext)
1993 impl->javascriptGlobalContext = JSGlobalContextCreate(0);
1994 return impl->javascriptGlobalContext;
1997 void ewkViewLoadCommitted(Evas_Object* ewkView)
1999 #if ENABLE(TIZEN_GESTURE)
2000 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2001 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2002 impl->gestureClient->reset();
2004 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
2005 if (impl->focusRing)
2006 impl->focusRing->hide();
2008 #if ENABLE(TIZEN_ISF_PORT)
2009 impl->inputMethodContext()->hideIMFContext();
2011 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2012 if (smartData->api->formdata_candidate_is_showing(smartData))
2013 smartData->api->formdata_candidate_hide(smartData);
2015 impl->informURLChange();
2016 evas_object_smart_callback_call(ewkView, "load,committed", 0);
2019 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
2021 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2022 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2024 OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error);
2025 ewk_error_load_error_page(ewkError.get(), toAPI(impl->pageProxy.get()));
2026 evas_object_smart_callback_call(ewkView, "load,error", ewkError.get());
2029 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
2031 #if ENABLE(TIZEN_GESTURE)
2032 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2033 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2034 impl->gestureClient->reset();
2036 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
2039 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
2041 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2042 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2044 if (impl->authChallenge)
2045 ewkAuthChallengeDelete(impl->authChallenge);
2046 impl->authChallenge = authChallenge;
2048 evas_object_smart_callback_call(ewkView, "authentication,challenge", impl->authChallenge);
2051 void ewk_view_process_crashed(Evas_Object* ewkView)
2053 bool handled = false;
2054 evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
2060 #if ENABLE(TIZEN_SQL_DATABASE)
2061 bool ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef databaseName, unsigned long long expectedUsage)
2063 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2064 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2066 if (!impl->exceededDatabaseQuotaContext || !impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback)
2069 TIZEN_LOGI("No error in prameter. Request to display user confirm popup. expectedUsage(%llu)", expectedUsage);
2070 impl->isWaitingForExceededQuotaPopupReply = true;
2071 if (impl->exceededQuotaOrigin)
2072 deleteSecurityOrigin(impl->exceededQuotaOrigin);
2073 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
2075 int length = WKStringGetMaximumUTF8CStringSize(databaseName);
2076 OwnArrayPtr<char> databaseNameBuffer = adoptArrayPtr(new char[length]);
2077 WKStringGetUTF8CString(databaseName, databaseNameBuffer.get(), length);
2079 return impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, databaseNameBuffer.get(), expectedUsage, impl->exceededDatabaseQuotaContext->userData) == EINA_TRUE;
2083 #if ENABLE(TIZEN_NOTIFICATIONS)
2084 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
2086 TIZEN_LOGI("notification,cancel");
2087 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
2090 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
2092 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2093 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2095 TIZEN_LOGI("notification,permission,request");
2096 impl->notificationPermissionRequests = eina_list_append(impl->notificationPermissionRequests, notificationPermissionRequest);
2097 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
2100 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
2102 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2103 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2105 TIZEN_LOGI("notification,show");
2106 Eina_List* listIterator=0;
2108 const char* replaceID = ewkNotificationGetReplaceID(notification);
2109 if(strlen(replaceID)) {
2110 EINA_LIST_FOREACH(impl->notifications, listIterator, data) {
2111 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
2112 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
2113 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
2117 impl->notifications = eina_list_append(impl->notifications, notification);
2118 evas_object_smart_callback_call(ewkView, "notification,show", notification);
2121 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
2123 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2124 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2126 impl->notificationPermissionRequests = eina_list_remove(impl->notificationPermissionRequests, ewkNotificationPermissionRequest);
2130 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
2131 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
2133 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2135 TIZEN_LOGI("protocolhandler,registration,requested");
2136 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
2137 evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
2138 ewkCustomHandlersDeleteData(customHandlersData);
2142 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
2143 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2145 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2147 TIZEN_LOGI("protocolhandler,isregistered");
2148 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2149 evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
2151 Ewk_Custom_Handlers_State result;
2152 result = ewkGetCustomHandlersDataResult(customHandlersData);
2153 ewkCustomHandlersDeleteData(customHandlersData);
2158 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2160 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2162 TIZEN_LOGI("protocolhandler,unregistration,requested");
2163 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2164 evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
2165 ewkCustomHandlersDeleteData(customHandlersData);
2169 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
2170 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
2172 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2174 TIZEN_LOGI("contenthandler,registration,requested");
2175 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
2176 evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
2177 ewkCustomHandlersDeleteData(customHandlersData);
2180 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2182 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2184 TIZEN_LOGI("contenthandler,isregistered");
2185 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2186 evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
2188 Ewk_Custom_Handlers_State result;
2189 result = ewkGetCustomHandlersDataResult(customHandlersData);
2190 ewkCustomHandlersDeleteData(customHandlersData);
2195 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2197 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2199 TIZEN_LOGI("contenthandler,unregistration,requested");
2200 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2201 evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
2202 ewkCustomHandlersDeleteData(customHandlersData);
2206 #if ENABLE(TIZEN_SEARCH_PROVIDER)
2207 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2209 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2211 TIZEN_LOGI("searchProvider,add");
2212 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2213 evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
2214 ewkSearchProviderDeleteData(searchProviderData);
2217 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2219 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
2221 TIZEN_LOGI("searchProvider,installed");
2222 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2223 evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
2224 unsigned long result;
2225 result = ewkGetSearchProviderResult(searchProviderData);
2226 ewkSearchProviderDeleteData(searchProviderData);
2231 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
2232 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
2234 TIZEN_LOGI("webapp,metatag,standalone");
2235 bool standalone = true;
2236 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
2241 #if ENABLE(TIZEN_MEDIA_STREAM)
2242 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
2244 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2245 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2247 impl->userMediaPermissionRequests = eina_list_append(impl->userMediaPermissionRequests, userMediaPermission);
2248 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
2251 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
2253 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2254 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2256 impl->userMediaPermissionRequests = eina_list_remove(impl->userMediaPermissionRequests, permission);
2261 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
2262 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
2264 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
2265 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
2266 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
2267 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
2268 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
2269 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
2271 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
2275 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
2276 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
2278 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2279 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2280 if (impl->certificatePolicyDecision)
2281 ewkCertificatePolicyDecisionDelete(impl->certificatePolicyDecision);
2282 impl->certificatePolicyDecision = certificatePolicyDecision;
2284 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
2288 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
2290 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
2293 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
2295 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
2298 #if ENABLE(TIZEN_GEOLOCATION)
2299 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2301 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2302 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2304 TIZEN_LOGI("geolocation,permission,request");
2305 impl->geolocationPermissionRequests = eina_list_append(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2306 evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
2309 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2311 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2312 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2314 impl->geolocationPermissionRequests = eina_list_remove(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2317 void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
2319 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2320 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2322 impl->geolocation = geolocation;
2325 Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
2327 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2328 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2330 return impl->geolocation;
2333 bool ewkViewIsValidLocationService(Evas_Object* ewkView)
2335 TIZEN_LOGI("geolocation,valid");
2338 evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
2343 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
2345 evas_object_smart_callback_call(ewkView, "form,submit", formData);
2348 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2350 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2351 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2352 if (impl->policyDecision)
2353 ewkPolicyDecisionDelete(impl->policyDecision);
2354 impl->policyDecision = policyDecision;
2356 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", impl->policyDecision);
2359 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2361 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2362 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2363 if (impl->policyDecision)
2364 ewkPolicyDecisionDelete(impl->policyDecision);
2365 impl->policyDecision = policyDecision;
2367 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", impl->policyDecision);
2370 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2372 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2373 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2374 if (impl->policyDecision)
2375 ewkPolicyDecisionDelete(impl->policyDecision);
2376 impl->policyDecision = policyDecision;
2378 evas_object_smart_callback_call(ewkView, "policy,response,decide", impl->policyDecision);
2381 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
2383 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2384 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2386 IntPoint scrollPosition = impl->pageClient->scrollPosition();
2387 IntSize contentsSize = impl->pageProxy->contentsSize();
2388 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2389 contentsSize.scale(impl->pageClient->scaleFactor());
2392 // some website's contents size is smaller than view size,
2393 // so we have to adjust contents size to view size for that case.
2394 if (contentsSize.width() < smartData->view.w)
2395 contentsSize.setWidth(smartData->view.w);
2396 if (contentsSize.height() < smartData->view.h)
2397 contentsSize.setHeight(smartData->view.h);
2399 // Call "scroll,down" if webview can be scrolled down.
2400 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
2401 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
2402 // Call "scroll,up" if webview can be scrolled up.
2403 else if (deltaY < 0 && scrollPosition.y() > 0)
2404 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
2406 // Call "scroll,right" if webview can be scrolled down.
2407 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
2408 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
2409 // Call "scroll,left" if webview can be scrolled up.
2410 else if (deltaX < 0 && scrollPosition.x() > 0)
2411 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
2414 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
2416 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2417 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2419 IntSize contentsSize = impl->pageProxy->contentsSize();
2420 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2421 contentsSize.scale(impl->pageClient->scaleFactor());
2424 int maxScrollY = contentsSize.height() - smartData->view.h;
2425 if (!impl->isVerticalEdge) {
2426 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
2427 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
2428 impl->isVerticalEdge = true;
2429 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
2430 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
2431 impl->isVerticalEdge = true;
2434 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
2435 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
2436 impl->isVerticalEdge = false;
2439 int maxScrollX = contentsSize.width() - smartData->view.w;
2440 if (!impl->isHorizontalEdge) {
2441 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
2442 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
2443 impl->isHorizontalEdge = true;
2444 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
2445 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
2446 impl->isHorizontalEdge = true;
2449 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
2450 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
2451 impl->isHorizontalEdge = false;
2455 void ewkViewClearEdges(Evas_Object* ewkView)
2457 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2458 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2460 impl->isVerticalEdge = false;
2461 impl->isHorizontalEdge = false;
2464 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
2466 EWK_VIEW_SD_GET(ewkView, smartData);
2467 if (!smartData || !smartData->priv) {
2475 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
2477 *minimumScale = constraints.minimumScale;
2479 *maximumScale = constraints.maximumScale;
2482 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard)
2484 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2485 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2487 double scaleFactor = impl->pageClient->scaleFactor();
2488 IntSize contentsSize = impl->pageProxy->contentsSize();
2490 double newScaleFactor = scaleFactor;
2491 // Readable zoom value is dependent on device DPI
2492 if (scaleFactor < impl->pageProxy->deviceScaleFactor()
2493 && impl->pageClient->viewportConstraints().userScalable)
2494 newScaleFactor = impl->pageProxy->deviceScaleFactor();
2496 // Readable zoom value should be inside of viewport scale range
2497 newScaleFactor = impl->pageClient->adjustScaleWithViewport(newScaleFactor);
2499 // scale contents' size with new scale factor
2500 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2501 contentsSize.scale(newScaleFactor);
2503 contentsSize.scale(newScaleFactor / scaleFactor);
2506 #if ENABLE(TIZEN_ISF_PORT)
2507 Ecore_X_Window rootWin = ecore_x_window_root_first_get();
2508 ecore_x_event_mask_set(rootWin, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
2509 Ecore_X_Atom xAtom = ecore_x_atom_get("X External Keyboard Exist");
2510 unsigned int connectedKeyboardNum = 0;
2511 bool isExternalKeyboardConnected = false;
2513 // get connected keyboard number
2514 if (ecore_x_window_prop_card32_get(rootWin, xAtom, &connectedKeyboardNum, 1)
2515 && connectedKeyboardNum)
2516 isExternalKeyboardConnected = true;
2518 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
2519 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
2520 // input field zoom should not work with below conditions
2521 // 1. view is not focused
2522 // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
2523 // 3. imfContext is null(if adjustForExternalKeyboard is false)
2524 // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
2525 if ((!(static_cast<PageClient*>(impl->pageClient.get()))->isViewFocused()
2526 || (adjustForExternalKeyboard && !isExternalKeyboardConnected)
2527 || (!adjustForExternalKeyboard && !impl->inputMethodContext())
2528 || (!adjustForExternalKeyboard && !impl->inputMethodContext()->isShow()))
2529 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
2530 && !(impl->pageClient->isClipboardWindowOpened())
2536 // caret position can be outside of visible rect.
2537 // we need to consider it.
2538 IntRect selectionRect = impl->pageProxy->getSelectionRect(true);
2539 IntRect focusedNodeRect = impl->pageClient->focusedNodeRect();
2540 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2541 selectionRect.scale(newScaleFactor);
2542 focusedNodeRect.scale(newScaleFactor);
2544 selectionRect.scale(newScaleFactor / scaleFactor);
2545 focusedNodeRect.scale(newScaleFactor / scaleFactor);
2547 if (selectionRect.isEmpty())
2550 IntRect visibleRect = impl->pageClient->visibleContentRect();
2551 IntPoint scrollPosition = visibleRect.location();
2552 // Do not adjust scroll position if content is userscalable or selection rect (caret) is visible after scaling
2553 if (impl->pageClient->userScalable() || !visibleRect.contains(selectionRect)) {
2555 scrollPosition = IntPoint(selectionRect.x() - visibleRect.width() / 3, selectionRect.y() - visibleRect.height() / 3);
2556 // If both input field's position x and selection rect can be displayed together,
2557 // adjust scroll position to input field's position x.
2558 if (!focusedNodeRect.isEmpty() && selectionRect.x() - focusedNodeRect.x() < visibleRect.width() * 4 / 5)
2559 scrollPosition.setX(focusedNodeRect.x());
2562 #if ENABLE(TIZEN_DLOG_SUPPORT)
2563 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", scrollPosition.x(), scrollPosition.y(), newScaleFactor);
2566 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2567 impl->pageClient->setVisibleContentRect(IntRect(scrollPosition, impl->size()), newScaleFactor);
2569 if (newScaleFactor != scaleFactor)
2570 impl->pageProxy->scalePage(newScaleFactor, scrollPosition);
2572 impl->pageProxy->scrollMainFrameTo(scrollPosition);
2574 evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
2578 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
2579 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2580 static Eina_Bool _ewk_view_composite(void* data)
2582 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
2583 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2585 if (!evas_object_visible_get(smartData->image))
2586 return ECORE_CALLBACK_CANCEL;
2589 evas_object_image_size_get(smartData->image, &ow, &oh);
2590 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
2592 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)));
2593 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
2595 cairo_save(context.get());
2596 cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
2597 cairo_rectangle(context.get(), 0, 0, ow, oh);
2598 cairo_fill(context.get());
2599 cairo_restore(context.get());
2601 impl->pageClient->drawContents(context.get());
2603 evas_object_image_data_set(smartData->image, pixels);
2604 evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
2606 if (impl->pageClient->notifiedNonemptyLayout())
2607 ewkViewFrameRendered(smartData->self);
2609 impl->compositionAnimator = 0;
2611 return ECORE_CALLBACK_CANCEL;
2615 void ewk_view_mark_for_sync(Evas_Object* ewkView)
2617 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2618 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
2620 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2621 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2623 if (!ewk_view_is_opengl_backend(ewkView)) {
2624 if (!impl->compositionAnimator)
2625 impl->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
2630 evas_object_image_pixels_dirty_set(smartData->image, true);
2633 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
2635 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
2636 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2637 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2638 impl->pageClient->drawContents();
2641 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
2643 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2644 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2646 if (!smartData->image)
2649 evas_object_image_native_surface_set(smartData->image, nativeSurface);
2650 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
2656 void _ewk_view_suspend_painting(Evas_Object* ewkView)
2658 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2659 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2661 if (!impl->suspendedPainting) {
2662 impl->pageProxy->suspendPainting();
2663 impl->suspendedPainting = true;
2667 void _ewk_view_resume_painting(Evas_Object* ewkView)
2669 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2670 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2672 if (impl->suspendedPainting) {
2673 impl->pageProxy->resumePainting();
2674 impl->suspendedPainting = false;
2678 void ewk_view_suspend(Evas_Object* ewkView)
2680 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2681 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2683 if (impl->pageProxy->estimatedProgress() < 1.0) {
2684 impl->suspendRequested = true;
2687 impl->suspendRequested = false;
2689 _ewk_view_suspend_painting(ewkView);
2691 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2692 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2693 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2695 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2696 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2697 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2698 // will be suspended again.
2699 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2700 // the ActiveDOMObject.
2701 if (!impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2702 impl->pageProxy->suspendAnimations();
2703 impl->pageProxy->suspendJavaScriptAndResource();
2704 impl->suspendedResources = true;
2707 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2708 impl->pageProxy->suspendPlugin();
2712 void ewk_view_resume(Evas_Object* ewkView)
2714 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2715 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2717 if (impl->suspendRequested) {
2718 impl->suspendRequested = false;
2722 _ewk_view_resume_painting(ewkView);
2724 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2725 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2726 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2728 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2729 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2730 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2731 // will be suspended again.
2732 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2733 // the ActiveDOMObject.
2734 if (impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2735 impl->pageProxy->resumeAnimations();
2736 impl->pageProxy->resumeJavaScriptAndResource();
2737 impl->suspendedResources = false;
2740 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2741 impl->pageProxy->resumePlugin();
2745 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
2747 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2748 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2749 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
2751 ResourceRequest request(String::fromUTF8(url));
2754 case EWK_HTTP_METHOD_GET:
2755 request.setHTTPMethod("GET");
2757 case EWK_HTTP_METHOD_HEAD:
2758 request.setHTTPMethod("HEAD");
2760 case EWK_HTTP_METHOD_POST:
2761 request.setHTTPMethod("POST");
2763 case EWK_HTTP_METHOD_PUT:
2764 request.setHTTPMethod("PUT");
2766 case EWK_HTTP_METHOD_DELETE:
2767 request.setHTTPMethod("DELETE");
2774 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
2776 while (eina_iterator_next(it, &data)) {
2777 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
2778 const char* name = static_cast<const char*>(t->key);
2779 const char* value = static_cast<const char*>(t->data);
2780 request.addHTTPHeaderField(name, value);
2782 eina_iterator_free(it);
2786 request.setHTTPBody(FormData::create(body));
2788 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
2789 WKPageLoadURLRequest(toAPI(impl->pageProxy.get()), urlRequest.get());
2794 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
2796 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2797 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2799 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
2800 WKPageLoadPlainTextString(toAPI(impl->pageProxy.get()), plainTextRef.get());
2805 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
2807 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2808 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2809 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
2811 if (contentsSize == 0)
2814 String mimeTypeString;
2816 mimeTypeString = String::fromUTF8(mimeType);
2818 mimeTypeString = String::fromUTF8("text/html");
2820 String encodingString;
2822 encodingString = String::fromUTF8(encoding);
2824 encodingString = String::fromUTF8("UTF-8");
2826 String baseUriString;
2828 baseUriString = String::fromUTF8(baseUri);
2830 baseUriString = String::fromUTF8("about:blank");
2832 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
2833 impl->pageProxy->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
2838 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
2840 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2841 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2843 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
2844 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
2846 WKPageLoadHTMLString(toAPI(impl->pageProxy.get()), htmlString.get(), baseURL.get());
2851 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
2853 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2854 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2856 TIZEN_LOGI("initialState (%d)", initialState);
2857 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
2858 WKPageSetPageVisibility(toAPI(impl->pageProxy.get()), static_cast<WKPageVisibilityState>(pageVisibilityState), initialState);
2865 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
2867 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
2869 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2870 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2872 impl->userAgent = userAgent;
2874 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
2875 WKPageSetCustomUserAgent(toAPI(impl->pageProxy.get()), userAgentString.get());
2880 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
2882 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2883 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2885 if (!impl->userAgent) {
2886 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
2888 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
2889 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2890 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
2891 impl->userAgent = buffer.get();
2894 return impl->userAgent;
2896 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
2898 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2899 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2900 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2902 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2903 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
2905 WKPageAddCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get(), customHeaderValue.get());
2908 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2913 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
2915 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2916 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2917 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2919 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2921 WKPageRemoveCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get());
2924 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2929 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
2931 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2932 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2933 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2935 WKPageClearCustomHeaders(toAPI(impl->pageProxy.get()));
2938 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2943 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
2944 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
2946 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2947 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2949 #if ENABLE(TIZEN_DRAG_SUPPORT)
2950 if (impl->pageClient->isDragMode())
2951 impl->pageClient->setDragMode(false);
2954 impl->pageClient->setIsVisible(enable);
2959 #if ENABLE(TIZEN_BACKGROUND_DISK_CACHE)
2960 Eina_Bool ewk_view_foreground_set(Evas_Object* ewkView, Eina_Bool enable)
2966 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
2968 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
2970 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2971 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2974 rect.origin.x = viewArea.x;
2975 rect.origin.y = viewArea.y;
2976 rect.size.width = viewArea.w;
2977 rect.size.height = viewArea.h;
2979 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(impl->pageProxy.get()), rect, scaleFactor));
2980 if (!snapshot.get())
2983 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
2985 Evas_Object* screenshotImage = evas_object_image_add(canvas);
2986 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
2987 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
2988 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
2989 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
2991 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
2993 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)));
2994 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
2996 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
2997 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
2998 cairo_fill(cairo.get());
3000 evas_object_image_smooth_scale_set(screenshotImage, true);
3001 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
3002 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
3003 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
3004 evas_object_image_data_set(screenshotImage, pixels);
3006 return screenshotImage;
3009 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
3011 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
3012 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
3013 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, 0);
3015 return impl->pageProxy->startInspectorServer(port);
3017 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
3022 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
3024 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
3025 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
3026 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
3028 return impl->pageProxy->stopInspectorServer();
3030 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
3035 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
3037 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3038 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3040 WKPageScrollBy(toAPI(impl->pageProxy.get()), toAPI(IntSize(deltaX, deltaY)));
3043 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
3049 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3050 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3052 IntPoint scrollPosition = impl->pageClient->scrollPosition();
3054 *x = scrollPosition.x();
3056 *y = scrollPosition.y();
3061 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
3063 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3064 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3066 impl->pageProxy->scrollMainFrameTo(IntPoint(x, y));
3070 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
3076 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3077 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3079 IntSize contentsSize = impl->pageProxy->contentsSize();
3080 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3081 contentsSize.scale(impl->pageClient->scaleFactor());
3084 if (width && contentsSize.width() > smartData->view.w)
3085 *width = contentsSize.width() - smartData->view.w;
3086 if (height && contentsSize.height() > smartData->view.h)
3087 *height = contentsSize.height() - smartData->view.h;
3091 #if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
3092 void ewkViewNotifyPopupReplyWaitingState(Evas_Object* ewkView, bool isWaiting)
3095 evas_object_smart_callback_call(ewkView, "popup,reply,wait,start", 0);
3097 evas_object_smart_callback_call(ewkView, "popup,reply,wait,finish", 0);
3101 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
3103 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3104 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3105 if (!impl->alertContext || !impl->alertContext->javascriptAlertCallback)
3107 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->alertContext->ewkView == ewkView, false);
3109 impl->isWaitingForJavaScriptPopupReply = true;
3110 int length = WKStringGetMaximumUTF8CStringSize(alertText);
3111 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
3112 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
3113 return impl->alertContext->javascriptAlertCallback(impl->alertContext->ewkView, alertTextBuffer.get(), impl->alertContext->userData) == EINA_TRUE;
3116 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
3118 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3119 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3120 if (!impl->confirmContext || !impl->confirmContext->javascriptConfirmCallback)
3122 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->confirmContext->ewkView == ewkView, false);
3124 impl->isWaitingForJavaScriptPopupReply = true;
3125 int length = WKStringGetMaximumUTF8CStringSize(message);
3126 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3127 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3128 return impl->confirmContext->javascriptConfirmCallback(impl->confirmContext->ewkView, messageBuffer.get(), impl->confirmContext->userData) == EINA_TRUE;
3131 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
3133 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3134 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3135 if (!impl->promptContext || !impl->promptContext->javascriptPromptCallback)
3137 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->promptContext->ewkView == ewkView, false);
3139 impl->isWaitingForJavaScriptPopupReply = true;
3140 int length = WKStringGetMaximumUTF8CStringSize(message);
3141 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3142 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3143 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
3144 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
3145 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
3146 return impl->promptContext->javascriptPromptCallback(impl->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), impl->promptContext->userData) == EINA_TRUE;
3149 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3150 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
3152 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3153 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3154 if (!impl->beforeUnloadConfirmPanelContext || !impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
3156 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
3158 impl->isWaitingForJavaScriptPopupReply = true;
3159 int length = WKStringGetMaximumUTF8CStringSize(message);
3160 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3161 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3162 bool result = impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(impl->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), impl->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
3167 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
3169 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3170 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3171 if (!impl->openpanelContext || !impl->openpanelContext->openPanelCallback)
3174 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->openpanelContext->ewkView == ewkView, false);
3176 impl->openPanelListener = listener;
3178 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
3179 Eina_List* acceptedMimeTypes = 0;
3180 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
3181 size_t len = WKArrayGetSize(array.get());
3182 for (size_t i = 0; i < len; i++) {
3183 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
3184 if (WKGetTypeID(item) != WKStringGetTypeID())
3186 WKStringRef mime = static_cast<WKStringRef>(item);
3187 int length = WKStringGetMaximumUTF8CStringSize(mime);
3188 char* buffer = new char[length];
3189 WKStringGetUTF8CString(mime, buffer, length);
3190 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
3192 const char* capture = 0;
3193 #if ENABLE(MEDIA_CAPTURE)
3194 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
3195 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
3197 bool result = impl->openpanelContext->openPanelCallback(impl->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
3198 if (!acceptedMimeTypes)
3203 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
3204 delete[] (char*)data;
3205 eina_list_free(acceptedMimeTypes);
3209 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
3211 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3212 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3214 if (!impl->alertContext)
3215 impl->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3216 impl->alertContext->javascriptAlertCallback = callback;
3217 impl->alertContext->ewkView = ewkView;
3218 impl->alertContext->userData = userData;
3221 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
3223 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3224 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3226 WKPageReplyJavaScriptAlert(toAPI(impl->page()));
3227 impl->isWaitingForJavaScriptPopupReply = false;
3230 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
3232 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3233 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3235 if (!impl->confirmContext)
3236 impl->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3237 impl->confirmContext->javascriptConfirmCallback = callback;
3238 impl->confirmContext->ewkView = ewkView;
3239 impl->confirmContext->userData = userData;
3242 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
3244 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3245 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3247 WKPageReplyJavaScriptConfirm(toAPI(impl->page()), result == EINA_TRUE);
3248 impl->isWaitingForJavaScriptPopupReply = false;
3251 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
3253 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3254 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3256 if (!impl->promptContext)
3257 impl->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3258 impl->promptContext->javascriptPromptCallback = callback;
3259 impl->promptContext->ewkView = ewkView;
3260 impl->promptContext->userData = userData;
3263 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
3265 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3266 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3268 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
3269 WKPageReplyJavaScriptPrompt(toAPI(impl->page()), result ? resultString.get() : 0);
3270 impl->isWaitingForJavaScriptPopupReply = false;
3273 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3274 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
3276 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3277 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3279 if (!impl->beforeUnloadConfirmPanelContext)
3280 impl->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3281 impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
3282 impl->beforeUnloadConfirmPanelContext->ewkView = ewkView;
3283 impl->beforeUnloadConfirmPanelContext->userData = userData;
3286 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
3288 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3289 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3291 WKPageReplyBeforeUnloadConfirmPanel(toAPI(impl->page()), result == EINA_TRUE);
3292 impl->isWaitingForJavaScriptPopupReply = false;
3296 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
3298 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3299 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3301 if (!impl->openpanelContext)
3302 impl->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3304 impl->openpanelContext->openPanelCallback = callback;
3305 impl->openpanelContext->ewkView = ewkView;
3306 impl->openpanelContext->userData = userData;
3309 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
3311 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3312 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3314 if (!impl->openPanelListener)
3317 unsigned int size = eina_list_count(fileUrls);
3318 if ((result == EINA_FALSE) || (size == 0)) {
3319 WKOpenPanelResultListenerCancel(impl->openPanelListener);
3320 impl->openPanelListener = 0;
3324 WKTypeRef* items = new WKTypeRef[size];
3328 KURL base(KURL(), "file://");
3329 EINA_LIST_FOREACH(fileUrls, list, data) {
3330 KURL url(base, String::fromUTF8(static_cast<char*>(data)));
3331 items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
3333 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
3334 WKOpenPanelResultListenerChooseFiles(impl->openPanelListener, filesArray.get());
3335 impl->openPanelListener = 0;
3337 eina_list_free(fileUrls);
3340 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3341 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
3343 EINA_SAFETY_ON_NULL_RETURN(capable);
3344 EINA_SAFETY_ON_NULL_RETURN(context);
3346 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3348 ASSERT(webAppContext->webAppCapableCallback);
3350 TIZEN_LOGI("webAppCapableCallback exist. capable(%b)", capable);
3352 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
3354 webAppContext->webAppCapableCallback(0, webAppContext->userData);
3356 delete webAppContext;
3359 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
3361 EINA_SAFETY_ON_NULL_RETURN(iconURL);
3362 EINA_SAFETY_ON_NULL_RETURN(context);
3364 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3366 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3367 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3369 ASSERT(webAppContext->webAppIconURLCallback);
3372 impl->webAppIconURL = toImpl(iconURL)->string().utf8().data();
3373 webAppContext->webAppIconURLCallback(impl->webAppIconURL, webAppContext->userData);
3375 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
3377 delete webAppContext;
3380 static void didGetWebAppIconURLs(WKDictionaryRef iconURLs, WKErrorRef, void* context)
3382 EINA_SAFETY_ON_NULL_RETURN(iconURLs);
3383 EINA_SAFETY_ON_NULL_RETURN(context);
3385 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3387 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3388 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3390 ASSERT(webAppContext->webAppIconURLsCallback);
3392 if (impl->webAppIconURLs) {
3394 EINA_LIST_FREE(impl->webAppIconURLs, data)
3395 ewkWebAppIconDataDelete(static_cast<Ewk_Web_App_Icon_Data*>(data));
3398 WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(iconURLs));
3399 size_t iconURLCount = WKArrayGetSize(wkKeys.get());
3400 for (size_t i = 0; i < iconURLCount; i++) {
3401 WKStringRef urlRef = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
3402 WKStringRef sizeRef = static_cast<WKStringRef>(WKDictionaryGetItemForKey(iconURLs, urlRef));
3403 impl->webAppIconURLs = eina_list_append(impl->webAppIconURLs, ewkWebAppIconDataCreate(sizeRef, urlRef));
3405 TIZEN_LOGI("webAppIconURLsCallback exist. found %d icon urls", iconURLCount);
3407 webAppContext->webAppIconURLsCallback(impl->webAppIconURLs, webAppContext->userData);
3408 delete webAppContext;
3412 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
3414 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3415 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3416 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3417 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3419 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3420 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3421 context->webAppCapableCallback = callback;
3422 context->ewkView = ewkView;
3423 context->userData = userData;
3425 WKPageGetWebAppCapable(toAPI(impl->pageProxy.get()), context, didGetWebAppCapable);
3433 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
3435 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3436 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3437 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3438 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3440 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3441 context->webAppIconURLCallback = callback;
3442 context->ewkView = ewkView;
3443 context->userData = userData;
3445 WKPageGetWebAppIconURL(toAPI(impl->page()), context, didGetWebAppIconURL);
3453 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
3455 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3456 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3457 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3458 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3460 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3461 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3462 context->webAppIconURLsCallback = callback;
3463 context->ewkView = ewkView;
3464 context->userData = userData;
3466 WKPageGetWebAppIconURLs(toAPI(impl->page()), context, didGetWebAppIconURLs);
3470 UNUSED_PARAM(ewkView);
3471 UNUSED_PARAM(callback);
3472 UNUSED_PARAM(userData);
3477 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
3479 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3480 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3481 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
3483 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
3484 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
3485 WKPageExecuteCommandWithArgument(toAPI(impl->pageProxy.get()), commandString.get(), valueString.get());
3490 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
3497 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3498 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3500 IntSize contentsSize = impl->pageProxy->contentsSize();
3503 *width = contentsSize.width();
3505 *height = contentsSize.height();
3510 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
3512 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3513 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3514 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3515 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3517 IntSize contentsSize = impl->pageProxy->contentsSize();
3518 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3526 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, int width, int height, const char* fileName)
3528 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3529 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3530 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3531 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3533 IntSize contentsSize = impl->pageProxy->contentsSize();
3534 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3542 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
3544 EINA_SAFETY_ON_NULL_RETURN(context);
3545 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3547 if (!callbackContext->scriptExecuteCallback) {
3548 delete callbackContext;
3552 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
3555 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
3556 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
3557 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
3558 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3559 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
3560 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3562 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
3564 delete callbackContext;
3567 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
3569 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3570 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3571 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
3572 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3574 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3575 context->scriptExecuteCallback = callback;
3576 context->ewkView = ewkView;
3577 context->userData = user_data;
3578 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
3579 WKPageRunJavaScriptInMainFrame(toAPI(impl->pageProxy.get()), scriptString.get(), context, runJavaScriptCallback);
3584 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3585 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
3587 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
3590 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
3592 storageContext->webStorageQuotaCallback(0, storageContext->userData);
3594 delete storageContext;
3598 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
3600 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3601 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3602 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
3603 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3604 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3605 TIZEN_LOGI("resultCallback (%p)", resultCallback);
3607 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3608 context->webStorageQuotaCallback = resultCallback;
3609 context->userData = userData;
3611 WKPageRef pageRef = toAPI(impl->page());
3612 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
3620 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
3622 #if ENABLE(TIZEN_WEB_STORAGE)
3623 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3624 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3625 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3627 TIZEN_LOGI("quota (%d)", quota);
3628 WKPageRef pageRef = toAPI(impl->page());
3629 WKPageSetWebStorageQuota(pageRef, quota);
3637 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
3639 EINA_SAFETY_ON_NULL_RETURN(context);
3640 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3642 ASSERT(callbackContext->plainTextGetCallback);
3645 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
3646 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3647 WKStringGetUTF8CString(plain_text, buffer.get(), length);
3649 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3651 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
3653 delete callbackContext;
3656 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
3658 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3659 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3660 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3661 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3663 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3664 context->plainTextGetCallback = callback;
3665 context->ewkView = ewkView;
3666 context->userData = user_data;
3667 WKPageGetContentsAsString(toAPI(impl->pageProxy.get()), context, getContentsAsStringCallback);
3672 #if ENABLE(TIZEN_SUPPORT_MHTML)
3675 * Callback function used for ewk_view_mhtml_data_get().
3677 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
3679 EINA_SAFETY_ON_NULL_RETURN(context);
3680 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3682 ASSERT(callbackContext->mhtmlDataGetCallback);
3684 callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
3686 delete callbackContext;
3689 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
3691 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3692 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3693 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3695 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3696 context->mhtmlDataGetCallback = callback;
3697 context->ewkView = ewkView;
3698 context->userData = user_data;
3700 WKPageGetContentsAsMHTMLData(toAPI(impl->page()), false, context, getContentsAsMHTMLCallback);
3704 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
3706 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
3708 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
3709 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3710 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3712 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
3713 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest, hitTestMode);
3714 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
3722 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
3724 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3725 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3726 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3727 WebPageProxy* page = impl->page();
3728 EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
3730 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
3733 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3738 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
3740 #if ENABLE(TIZEN_NOTIFICATIONS)
3741 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3742 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3743 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context, false);
3745 TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
3746 if (!eina_list_count(ewkNotifications))
3749 Eina_List* listIterator = 0;
3751 Vector<WKTypeRef> ids;
3752 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
3753 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
3754 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
3756 impl->notifications = eina_list_remove(impl->notifications, notification);
3759 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
3760 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(impl->context->wkContext());
3761 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
3762 ewkNotificationDeleteNotificationList(ewkNotifications);
3770 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3771 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
3773 Eina_List* popupItems = 0;
3774 size_t size = items.size();
3775 for (size_t i = 0; i < size; ++i)
3776 popupItems = eina_list_append(popupItems, Ewk_Popup_Menu_Item::create(items[i]).leakPtr());
3777 TIZEN_LOGI("size : %d", size);
3781 static void releasePopupMenuList(Eina_List* popupMenuItems)
3783 if (!popupMenuItems)
3787 EINA_LIST_FREE(popupMenuItems, item)
3788 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3792 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
3794 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3795 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3796 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
3798 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3801 if (!impl->popupMenuProxy)
3804 impl->popupMenuProxy = 0;
3806 if (smartData->api->popup_menu_hide)
3807 smartData->api->popup_menu_hide(smartData);
3808 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3809 ewk_view_touch_events_enabled_set(ewkView, true);
3811 releasePopupMenuList(impl->popupMenuItems);
3812 impl->popupMenuItems = 0;
3815 EINA_LIST_FREE(impl->popupMenuItems, item)
3816 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3822 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
3824 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3825 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3826 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3828 TIZEN_LOGI("proxy : %p / index : %d", impl->popupMenuProxy, selectedIndex);
3830 if (!impl->popupMenuItems)
3834 if (selectedIndex >= eina_list_count(impl->popupMenuItems))
3837 impl->popupMenuProxy->valueChanged(selectedIndex);
3842 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3843 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
3845 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3846 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3847 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3848 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3850 if (!impl->popupMenuProxy)
3853 if (!smartData->api->popup_menu_update)
3856 releasePopupMenuList(impl->popupMenuItems);
3857 impl->popupMenuItems = createPopupMenuList(items);
3859 // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
3860 smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), impl->popupMenuItems, selectedIndex);
3864 #if ENABLE(TIZEN_MULTIPLE_SELECT)
3865 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
3867 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3868 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3869 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3871 Vector<int> selectedIndex;
3873 if (!impl->popupMenuItems)
3878 itr = eina_inarray_iterator_new(changeList);
3879 EINA_ITERATOR_FOREACH(itr, data)
3881 int* pData = static_cast<int*>(data);
3882 selectedIndex.append(*pData);
3884 eina_iterator_free(itr);
3886 impl->popupMenuProxy->multipleValueChanged(selectedIndex);
3891 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
3893 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
3894 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3895 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3896 TIZEN_LOGI("orientation : %d", orientation);
3898 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
3901 if (impl->orientation == orientation)
3904 impl->orientation = orientation;
3906 impl->pageProxy->sendOrientationChangeEvent(orientation);
3910 void ewkViewFrameRendered(Evas_Object* ewkView)
3912 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
3915 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3916 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3918 return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
3921 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
3923 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3924 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3926 IntRect leftSelectionRect;
3927 IntRect rightSelectionRect;
3928 if (!impl->pageProxy->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
3941 AffineTransform contentToScreen = impl->transformToScene();
3942 leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
3943 rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
3945 leftRect->x = leftSelectionRect.x();
3946 leftRect->y = leftSelectionRect.y();
3947 leftRect->w = leftSelectionRect.width();
3948 leftRect->h = leftSelectionRect.height();
3950 rightRect->x = rightSelectionRect.x();
3951 rightRect->y = rightSelectionRect.y();
3952 rightRect->w = rightSelectionRect.width();
3953 rightRect->h = rightSelectionRect.height();
3958 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
3960 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3961 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3963 const CString selectedString = impl->pageProxy->getSelectionText().utf8();
3964 impl->selectedText = selectedString.data();
3966 return impl->selectedText;
3969 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
3971 return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
3974 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
3976 return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
3979 void ewk_view_text_selection_range_clear(Evas_Object* ewkView)
3981 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3982 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3984 impl->pageProxy->selectionRangeClear();
3986 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3988 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3989 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
3991 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3992 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3993 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
3995 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
3999 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
4000 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
4002 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4003 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4004 IntPoint drawingPosition = (IntPoint)(impl->pageClient->visibleContentRect().location() - impl->pageClient->scrollPosition());
4006 *x = drawingPosition.x();
4008 *y = drawingPosition.y();
4010 *w = impl->pageClient->visibleContentRect().width();
4012 *h = impl->pageClient->visibleContentRect().height();
4016 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
4018 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4019 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4020 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4022 impl->pageProxy->setFocusedInputElementValue(String::fromUTF8(value));
4023 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4026 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
4028 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4029 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4030 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
4032 impl->inputValue = impl->pageProxy->getFocusedInputElementValue().utf8().data();
4033 return impl->inputValue;
4036 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4039 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4040 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
4042 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4043 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4044 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4045 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
4048 ewkViewDataListHideRequest(ewkView, inputType);
4050 for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
4052 impl->dataList = eina_list_append(impl->dataList, eina_stringshare_add(value.utf8().data()));
4055 smartData->api->data_list_show(smartData, inputType, impl->dataList);
4058 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
4060 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4061 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4062 EINA_SAFETY_ON_NULL_RETURN(impl->dataList);
4063 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4064 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
4066 impl->deleteDataList();
4068 smartData->api->data_list_hide(smartData, inputType);
4072 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
4074 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4075 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4076 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4078 impl->deleteDataList();
4080 ewk_view_focused_input_element_value_set(ewkView, value);
4084 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
4086 #if ENABLE(TIZEN_GESTURE)
4087 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4088 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4089 return impl->holdHorizontalPanning;
4095 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4097 #if ENABLE(TIZEN_GESTURE)
4098 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4099 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4100 impl->holdHorizontalPanning = hold;
4104 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
4106 #if ENABLE(TIZEN_GESTURE)
4107 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4108 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4109 return impl->holdVerticalPanning;
4115 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4117 #if ENABLE(TIZEN_GESTURE)
4118 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4119 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4120 impl->holdVerticalPanning = hold;
4124 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
4126 #if ENABLE(TIZEN_GESTURE)
4127 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4128 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4130 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4131 if (impl->focusRing && wasHandled)
4132 impl->focusRing->hide();
4133 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4135 if (impl->mouseEventsEnabled())
4138 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4139 if (wasHandled && impl->pageClient->isTextSelectionMode()) {
4140 if (type == WebEvent::TouchStart)
4141 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4142 else if (type == WebEvent::TouchMove)
4143 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4144 else if (type == WebEvent::TouchEnd)
4145 impl->pageClient->requestToShowTextSelectionHandlesAndContextMenu();
4149 // We have to check TouchStart, TouchMove and TouchEnd with handled.
4150 // The Pan and Flick will be enabled if Touch Start was not handled,
4151 // and Touch Move was not handled or did not occur.
4152 // Tap will be enabled if Touch Start and End was not handled
4153 // and Touch Move did not occur.
4154 // The gestures are disabled as a default.
4155 // o: handled, x: not handled
4156 // ------------------------------------------------------------
4157 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
4158 // ------------------------------------------------------------
4159 // o | o or x | o or x || disable | disable
4160 // x | o | o or x || disable | disable
4161 // x | x | o or x || disable | enable
4162 // x |not occured | x || enable | enable
4163 // ------------------------------------------------------------
4164 if (type == WebEvent::TouchStart) {
4165 impl->gestureClient->setGestureEnabled(!wasHandled);
4166 impl->wasHandledTouchStart = wasHandled;
4168 // Initialize wasHandledTouchMove to true and notify that to the application
4169 // to prevent applications scrolling at the beginning of touch.
4170 impl->wasHandledTouchMove = true;
4171 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&impl->wasHandledTouchMove));
4172 } else if (type == WebEvent::TouchMove) {
4173 impl->gestureClient->setMovingEnabled(!wasHandled);
4175 // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
4176 if (impl->wasHandledTouchStart)
4179 // Notify the result of touchmove to applications when handled value is changed
4180 // in order to make applications to choose whether scrolling its scrollable objects or not.
4181 if (impl->wasHandledTouchMove != wasHandled)
4182 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
4183 impl->wasHandledTouchMove = wasHandled;
4184 } else if (type == WebEvent::TouchEnd && !impl->exceedTouchMoveThreshold) {
4186 impl->gestureClient->setMovingEnabled(!wasHandled);
4187 impl->gestureClient->setTapEnabled(!wasHandled);
4189 #if ENABLE(TIZEN_ISF_PORT)
4190 else if (impl->pageProxy->isViewVisible()) {
4191 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(impl->touchDownPoint.x, impl->touchDownPoint.y));
4192 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest);
4193 if (hitTestResultData.isContentEditable && impl->inputMethodContext()) {
4194 evas_object_focus_set(ewkView, true);
4195 impl->inputMethodContext()->updateTextInputState();
4203 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
4204 void ewkViewTextStyleState(Evas_Object* ewkView, const IntPoint& startPoint, const IntPoint& endPoint)
4206 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4207 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4209 EditorState editorState = impl->page()->editorState();
4210 Ewk_Text_Style* textStyle = ewkTextStyleCreate(editorState, startPoint, endPoint);
4211 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
4212 ewkTextStyleDelete(textStyle);
4216 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
4217 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
4219 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4220 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4222 TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
4223 if (!smartData->api->orientation_lock) {
4228 return smartData->api->orientation_lock(smartData, willLockOrientation);
4231 void ewk_view_orientation_unlock(Evas_Object* ewkView)
4233 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4234 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4236 TIZEN_LOGI("ewkView (%p)", ewkView);
4237 if (!smartData->api->orientation_unlock) {
4242 smartData->api->orientation_unlock(smartData);
4246 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
4248 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4249 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4250 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4251 TIZEN_LOGI("callbacks: %p / data: %p", func, data);
4253 impl->orientationLock.callback = func;
4254 impl->orientationLock.data = data;
4258 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4259 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
4261 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
4262 TIZEN_LOGI("locked orientations : %d", orientations);
4264 if (impl->orientationLock.callback)
4265 return impl->orientationLock.callback(sd->self, true, orientations, impl->orientationLock.data);
4270 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
4272 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4273 TIZEN_LOGI("unlock is requested");
4275 if (impl->orientationLock.callback)
4276 impl->orientationLock.callback(sd->self, false, 0, impl->orientationLock.data);
4280 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
4281 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
4283 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4285 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
4286 const char *engine = ecore_evas_engine_name_get(ee);
4287 if (engine && !strcmp(engine, "opengl_x11"))
4293 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
4295 #if ENABLE(TIZEN_GESTURE)
4296 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4297 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4299 impl->gestureClient->setZoomableArea(target, area);
4303 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
4304 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
4306 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4307 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4309 WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(impl->pageProxy.get())));
4313 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
4314 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
4316 evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
4320 #if ENABLE(TIZEN_ICON_DATABASE)
4321 void ewkViewIconReceived(Evas_Object* ewkView)
4325 evas_object_smart_callback_call(ewkView, "icon,received", 0);
4329 #endif // #if OS(TIZEN)
4331 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
4333 #if ENABLE(TOUCH_EVENTS)
4334 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
4335 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4336 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4338 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
4339 if (impl->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
4340 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4341 IntPoint handlePoint(point->x, point->y);
4343 if (type == EWK_TOUCH_START)
4344 impl->pageClient->textSelectonHandleDown(handlePoint);
4345 else if (type == EWK_TOUCH_MOVE)
4346 impl->pageClient->textSelectonHandleMove(handlePoint);
4348 impl->pageClient->textSelectonHandleUp();
4350 if (impl->pageClient->isTextSelectionHandleDowned())
4355 #if ENABLE(TIZEN_GESTURE)
4356 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
4357 // We don't want to process touch event when context menu is shown.
4358 if ((impl->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
4359 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4360 && !impl->pageClient->isTextSelectionMode()
4365 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4366 if (impl->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
4370 if (type == EWK_TOUCH_START) {
4371 if (eina_list_count(points) == 1) {
4372 impl->gestureClient->reset();
4373 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4374 impl->touchDownPoint.x = point->x;
4375 impl->touchDownPoint.y = point->y;
4376 impl->exceedTouchMoveThreshold = false;
4378 } else if (type == EWK_TOUCH_MOVE && !impl->exceedTouchMoveThreshold) {
4379 if (eina_list_count(points) == 1) {
4380 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
4381 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4382 int diffX = impl->touchDownPoint.x - point->x;
4383 int diffY = impl->touchDownPoint.y - point->y;
4384 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
4385 impl->exceedTouchMoveThreshold = true;
4389 impl->exceedTouchMoveThreshold = true;
4392 #endif // #if ENABLE(TIZEN_GESTURE)
4394 // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
4395 //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4396 impl->pageProxy->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4404 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
4406 #if ENABLE(TOUCH_EVENTS)
4407 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4408 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4410 impl->setTouchEventsEnabled(!!enabled);
4418 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
4420 #if ENABLE(TOUCH_EVENTS)
4421 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4422 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4424 return impl->touchEventsEnabled();
4430 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
4432 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4433 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4434 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4436 impl->mainFrameScrollbarVisibility = visible;
4437 impl->pageClient->updateVisibility();
4445 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
4447 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4448 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4449 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4451 return impl->mainFrameScrollbarVisibility;
4457 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
4459 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
4460 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4461 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4462 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
4464 String title = ewk_view_title_get(ewkView);
4465 String url = ewk_view_url_get(ewkView);
4466 String directoryPath(path);
4467 impl->pageClient->startOfflinePageSave(directoryPath, url, title);
4471 UNUSED_PARAM(ewkView);
4479 * Callback function used for ewk_view_page_contents_get().
4481 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4483 EINA_SAFETY_ON_NULL_RETURN(context);
4485 RefPtr<WebData> webData = toImpl(wkData);
4486 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4487 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
4492 * Callback function used for ewk_view_page_contents_get().
4494 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
4496 EINA_SAFETY_ON_NULL_RETURN(context);
4498 RefPtr<WebString> webString = toImpl(wkString);
4499 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4500 contentsContext->callback(contentsContext->type, webString->string().utf8().data());
4503 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
4505 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
4506 EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
4507 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4508 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4510 switch (context->type) {
4511 case EWK_PAGE_CONTENTS_TYPE_MHTML:
4512 impl->pageProxy->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
4515 case EWK_PAGE_CONTENTS_TYPE_STRING:
4516 impl->pageProxy->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
4520 ASSERT_NOT_REACHED();
4527 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
4529 #if ENABLE(TIZEN_GESTURE)
4530 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4531 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4533 return impl->gestureClient->scrollToWithAnimation(x, y);
4535 UNUSED_PARAM(ewkView);
4542 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4543 void ewkViewFocusRingHide(Evas_Object* ewkView)
4545 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4546 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4548 if (impl->focusRing)
4549 impl->focusRing->hide();
4553 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
4555 #if ENABLE(TIZEN_CSP)
4556 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
4557 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4559 TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
4560 impl->pageProxy->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));
4564 #if ENABLE(TIZEN_APPLICATION_CACHE)
4565 Eina_Bool ewkViewRequestApplicationCachePermission(Evas_Object* ewkView, WKSecurityOriginRef origin)
4567 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4568 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4570 if (!impl->applicationCachePermissionContext || !impl->applicationCachePermissionContext->applicationCachePermissionCallback)
4573 impl->isWaitingForApplicationCachePermission = true;
4574 if (impl->applicationCachePermissionOrigin)
4575 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4576 impl->applicationCachePermissionOrigin = createSecurityOrigin(origin);
4578 return impl->applicationCachePermissionContext->applicationCachePermissionCallback(ewkView, impl->applicationCachePermissionOrigin, impl->applicationCachePermissionContext->userData) == EINA_TRUE;
4582 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
4584 #if ENABLE(TIZEN_APPLICATION_CACHE)
4585 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4586 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4588 if (!impl->applicationCachePermissionContext)
4589 impl->applicationCachePermissionContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4590 impl->applicationCachePermissionContext->applicationCachePermissionCallback = callback;
4591 impl->applicationCachePermissionContext->userData = userData;
4593 UNUSED_PARAM(ewkView);
4594 UNUSED_PARAM(callback);
4595 UNUSED_PARAM(userData);
4599 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
4601 #if ENABLE(TIZEN_APPLICATION_CACHE)
4602 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4603 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4605 TIZEN_LOGI("allow %d", allow);
4606 WKPageReplyApplicationCachePermission(toAPI(impl->page()), allow);
4607 if (impl->applicationCachePermissionOrigin)
4608 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4609 impl->applicationCachePermissionOrigin = 0;
4610 impl->isWaitingForApplicationCachePermission = false;
4612 UNUSED_PARAM(ewkView);
4613 UNUSED_PARAM(allow);
4617 #if ENABLE(TIZEN_INDEXED_DATABASE)
4618 bool ewkViewExceededIndexedDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4620 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4621 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4623 if (!impl->exceededIndexedDatabaseQuotaContext || !impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback)
4626 impl->isWaitingForExceededQuotaPopupReply = true;
4627 if (impl->exceededQuotaOrigin)
4628 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4629 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4631 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4633 return impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, currentUsage, impl->exceededIndexedDatabaseQuotaContext->userData) == EINA_TRUE;
4637 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4639 #if ENABLE(TIZEN_INDEXED_DATABASE)
4640 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4641 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4643 if (!impl->exceededIndexedDatabaseQuotaContext)
4644 impl->exceededIndexedDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4645 impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback = callback;
4646 impl->exceededIndexedDatabaseQuotaContext->userData = userData;
4648 UNUSED_PARAM(ewkView);
4649 UNUSED_PARAM(callback);
4650 UNUSED_PARAM(userData);
4654 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4656 #if ENABLE(TIZEN_INDEXED_DATABASE)
4657 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4658 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4660 TIZEN_LOGI("allow %d", allow);
4661 WKPageReplyExceededIndexedDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4662 if (impl->exceededQuotaOrigin)
4663 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4664 impl->exceededQuotaOrigin = 0;
4665 impl->isWaitingForExceededQuotaPopupReply = false;
4667 UNUSED_PARAM(ewkView);
4668 UNUSED_PARAM(allow);
4672 // EwkFindOptions should be matched up orders with WkFindOptions.
4673 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_CASE_INSENSITIVE, kWKFindOptionsCaseInsensitive);
4674 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_AT_WORD_STARTS, kWKFindOptionsAtWordStarts);
4675 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, kWKFindOptionsTreatMedialCapitalAsWordStart);
4676 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_BACKWARDS, kWKFindOptionsBackwards);
4677 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_WRAP_AROUND, kWKFindOptionsWrapAround);
4678 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_OVERLAY, kWKFindOptionsShowOverlay);
4679 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR, kWKFindOptionsShowFindIndicator);
4680 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShowHighlight);
4682 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4684 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4685 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4686 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4688 impl->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4693 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4695 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4696 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4698 impl->pageProxy->hideFindUI();
4703 Eina_Bool ewk_view_text_matches_count(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4705 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4706 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4707 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4709 impl->pageProxy->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4714 void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData)
4716 #if ENABLE(TIZEN_SQL_DATABASE)
4717 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4718 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4720 if (!impl->exceededDatabaseQuotaContext)
4721 impl->exceededDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4722 impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback = callback;
4723 impl->exceededDatabaseQuotaContext->userData = userData;
4725 UNUSED_PARAM(ewkView);
4726 UNUSED_PARAM(callback);
4727 UNUSED_PARAM(userData);
4731 void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4733 #if ENABLE(TIZEN_SQL_DATABASE)
4734 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4735 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4737 TIZEN_LOGI("allow %d", allow);
4738 WKPageReplyExceededDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4739 if (impl->exceededQuotaOrigin)
4740 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4741 impl->exceededQuotaOrigin = 0;
4742 impl->isWaitingForExceededQuotaPopupReply = false;
4744 UNUSED_PARAM(ewkView);
4745 UNUSED_PARAM(allow);
4749 #if ENABLE(TIZEN_FILE_SYSTEM)
4750 bool ewkViewExceededLocalFileSystemQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4752 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4753 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4755 if (!impl->exceededLocalFileSystemQuotaContext || !impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback)
4758 impl->isWaitingForExceededQuotaPopupReply = true;
4759 if (impl->exceededQuotaOrigin)
4760 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4761 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4763 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4765 return impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback(ewkView, impl->exceededQuotaOrigin , currentUsage, impl->exceededLocalFileSystemQuotaContext->userData) == EINA_TRUE;
4769 void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4771 #if ENABLE(TIZEN_FILE_SYSTEM)
4772 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4773 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4775 if (!impl->exceededLocalFileSystemQuotaContext)
4776 impl->exceededLocalFileSystemQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4777 impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback = callback;
4778 impl->exceededLocalFileSystemQuotaContext->userData = userData;
4780 UNUSED_PARAM(ewkView);
4781 UNUSED_PARAM(callback);
4782 UNUSED_PARAM(userData);
4786 void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4788 #if ENABLE(TIZEN_FILE_SYSTEM)
4789 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4790 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4792 TIZEN_LOGI("allow %d", allow);
4793 WKPageReplyExceededLocalFileSystemQuota(toAPI(impl->page()), allow == EINA_TRUE);
4794 if (impl->exceededQuotaOrigin)
4795 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4796 impl->exceededQuotaOrigin = 0;
4797 impl->isWaitingForExceededQuotaPopupReply = false;
4799 UNUSED_PARAM(ewkView);
4800 UNUSED_PARAM(result);
4804 void ewk_view_rotation_prepare(Evas_Object* ewkView, int angle)
4806 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4807 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4808 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4811 if (angle == 0 || angle == 180) {
4812 width = WebCore::getDefaultScreenResolution().width();
4813 height = WebCore::getDefaultScreenResolution().height() + 100;
4815 if (angle == 90 || angle == 270) {
4816 width = WebCore::getDefaultScreenResolution().height();
4817 height = WebCore::getDefaultScreenResolution().width() + 100;
4820 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
4821 impl->pageClient->setWaitFrameOfNewViewortSize(true);
4822 ewk_view_suspend(ewkView);
4823 impl->pageClient->updateViewportSize(IntSize(width, height), angle);
4827 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4828 void ewkViewRotatePrepared(Evas_Object* ewkView)
4830 evas_object_smart_callback_call(ewkView, "rotate,prepared", 0);
4834 void ewk_view_use_settings_font(Evas_Object* ewkView)
4836 #if ENABLE(TIZEN_USE_SETTINGS_FONT)
4837 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4838 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4840 impl->pageProxy->useSettingsFont();
4844 void ewk_view_fullscreen_exit(Evas_Object* ewkView)
4846 #if ENABLE(TIZEN_FULLSCREEN_API)
4849 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4850 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4852 if (!impl->pageProxy->fullScreenManager()->isFullScreen())
4855 impl->pageProxy->fullScreenManager()->requestExitFullScreen();
4857 UNUSED_PARAM(ewkView);