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->hide();
418 if (event->type != EWK_GESTURE_LONG_PRESS) {
419 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
420 if (!impl->pageClient->isContextMenuVisible())
422 impl->focusRing->hide();
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->hide();
533 switch (event->type) {
534 case EWK_GESTURE_TAP:
535 if (event->count == 1) {
536 #if ENABLE(TIZEN_DRAG_SUPPORT)
537 if (impl->pageClient->isDragMode())
538 impl->pageClient->setDragMode(false);
540 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
541 if (impl->pageClient->isTextSelectionMode())
542 impl->pageClient->setIsTextSelectionMode(false);
545 #if ENABLE(TIZEN_ISF_PORT)
546 if (impl->inputMethodContext()->isIMEPostion(event->position.x, event->position.y))
550 impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
551 } else if (event->count == 2)
552 impl->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
554 case EWK_GESTURE_LONG_PRESS:
555 // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
556 impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
558 case EWK_GESTURE_PAN:
559 impl->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
561 case EWK_GESTURE_FLICK:
562 impl->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
564 case EWK_GESTURE_PINCH:
565 impl->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
568 ASSERT_NOT_REACHED();
575 #endif // #if ENABLE(TIZEN_GESTURE)
578 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
580 #if ENABLE(TIZEN_GESTURE)
581 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
583 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
584 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
588 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
589 if (impl->focusRing && !(event->type == EWK_GESTURE_PAN && !impl->exceedTouchMoveThreshold))
590 impl->focusRing->hide();
593 switch (event->type) {
594 case EWK_GESTURE_PAN:
595 impl->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
597 case EWK_GESTURE_TAP:
598 case EWK_GESTURE_LONG_PRESS:
599 case EWK_GESTURE_FLICK:
601 case EWK_GESTURE_PINCH:
602 if (impl->pageClient->viewportConstraints().userScalable)
603 impl->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
606 ASSERT_NOT_REACHED();
613 #endif // #if ENABLE(TIZEN_GESTURE)
615 #endif //#if OS(TIZEN)
618 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
620 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
621 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
622 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
623 smartData->api->focus_in(smartData);
626 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
628 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
629 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
630 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
631 smartData->api->focus_out(smartData);
634 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
636 Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(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->mouse_wheel);
640 smartData->api->mouse_wheel(smartData, wheelEvent);
643 static void _ewk_view_on_key_down(void* data, Evas*, Evas_Object*, void* eventInfo)
645 Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(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->key_down);
649 smartData->api->key_down(smartData, downEvent);
652 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
654 Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(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_up);
658 smartData->api->key_up(smartData, upEvent);
661 static void _ewk_view_on_show(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
663 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
664 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
665 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
668 static void _ewk_view_on_hide(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
670 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
671 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
673 // This call may look wrong, but we really need to pass ViewIsVisible here.
674 // viewStateDidChange() itself is responsible for actually setting the visibility to Visible or Hidden
675 // depending on what WebPageProxy::isViewVisible() returns, this simply triggers the process.
676 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
681 #if ENABLE(TIZEN_FULLSCREEN_API)
682 Eina_Bool _ewk_view_smart_fullscreen_enter(Ewk_View_Smart_Data* smartData)
684 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
686 ewk_view_main_frame_scrollbar_visible_set(impl->view(), false);
687 evas_object_smart_callback_call(impl->view(), "fullscreen,enterfullscreen", 0);
691 Eina_Bool _ewk_view_smart_fullscreen_exit(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(), true);
696 evas_object_smart_callback_call(impl->view(), "fullscreen,exitfullscreen", 0);
701 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
702 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
704 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
706 return impl->pageClient->textSelectionDown(IntPoint(x, y));
709 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
711 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
713 IntPoint point(x, y);
714 impl->pageClient->textSelectionMove(point);
719 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
721 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
723 IntPoint point(x, y);
724 impl->pageClient->textSelectionUp(point, true);
730 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
731 Eina_Bool _ewk_view_smart_formdata_candidate_show(Ewk_View_Smart_Data* smartData, int x, int y, int w, int h)
733 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
735 impl->pageClient->showFormDataCandidate(IntRect(x, y, w, h));
740 Eina_Bool _ewk_view_smart_formdata_candidate_hide(Ewk_View_Smart_Data* smartData)
742 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
744 impl->pageClient->hideFormDataCandidate();
749 Eina_Bool _ewk_view_smart_formdata_candidate_update_data(Ewk_View_Smart_Data* smartData, Eina_List* dataList)
751 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
753 Vector<String> formData;
756 EINA_LIST_FOREACH(dataList, list, data)
757 formData.append(String::fromUTF8(static_cast<char*>(data)));
759 impl->pageClient->updateFormDataCandidate(formData);
764 Eina_Bool _ewk_view_smart_formdata_candidate_is_showing(Ewk_View_Smart_Data* smartData)
766 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
768 return impl->pageClient->isShowingFormDataCandidate();
772 #if ENABLE(TIZEN_SCREEN_READER)
773 Eina_Bool _ewk_view_screen_reader_action_execute(Ewk_View_Smart_Data* smartData, void* actionInfo)
775 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
777 return ScreenReaderProxy::executeAction(impl, 0, static_cast<Elm_Access_Action_Info*>(actionInfo));
780 #endif // #if OS(TIZEN)
782 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
784 static void _ewk_view_impl_del(EwkViewImpl* impl)
786 #if !ENABLE(TIZEN_ICON_DATABASE)
787 /* Unregister icon change callback */
788 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
789 iconDatabase->unwatchChanges(_ewk_view_on_favicon_changed);
795 static void _ewk_view_smart_add(Evas_Object* ewkView)
797 const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
798 const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
799 const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
800 EWK_VIEW_SD_GET(ewkView, smartData);
803 smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
805 EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
808 evas_object_smart_data_set(ewkView, smartData);
811 smartData->self = ewkView;
812 smartData->api = api;
814 g_parentSmartClass.add(ewkView);
816 smartData->priv = new EwkViewImpl(ewkView);
817 if (!smartData->priv) {
818 EINA_LOG_CRIT("could not allocate EwkViewImpl");
819 evas_object_smart_data_set(ewkView, 0);
824 // Create evas_object_image to draw web contents.
825 smartData->image = evas_object_image_add(smartData->base.evas);
826 evas_object_image_alpha_set(smartData->image, false);
827 evas_object_image_filled_set(smartData->image, true);
828 evas_object_smart_member_add(smartData->image, ewkView);
831 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
832 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
833 const char *engine = ecore_evas_engine_name_get(ee);
834 if (engine && !strcmp(engine, "opengl_x11"))
835 evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
837 ewk_view_mouse_events_enabled_set(ewkView, false);
838 ewk_view_touch_events_enabled_set(ewkView, true);
840 // FIXME: This code should be removed if side effect occur.
841 // WebView does not have focus after url loading.
842 // If focus is set as true to webview,
843 // elementary steal webview's focus during mouse up event
844 // So, added code that events are not propagated to smart parent according to guide from EFL
845 evas_object_propagate_events_set(ewkView, false);
846 #endif // #if OS(TIZEN)
848 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
849 CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
850 CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
851 CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
852 CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
853 CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
854 CONNECT(EVAS_CALLBACK_SHOW, _ewk_view_on_show);
855 CONNECT(EVAS_CALLBACK_HIDE, _ewk_view_on_hide);
859 static void _ewk_view_smart_del(Evas_Object* ewkView)
861 EwkViewImpl::removeFromPageViewMap(ewkView);
862 EWK_VIEW_SD_GET(ewkView, smartData);
863 #if ENABLE(TIZEN_SCREEN_READER)
864 ScreenReaderProxy::screenReader().finalize(smartData->priv);
866 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
867 // Close color picker if it's opened.
868 if (smartData && smartData->priv && smartData->priv->inputPicker->isColorPickerShown())
869 ewk_view_color_picker_color_set(ewkView, 0, 0, 0, 0);
871 if (smartData && smartData->priv)
872 _ewk_view_impl_del(smartData->priv);
874 g_parentSmartClass.del(ewkView);
877 static Eina_Bool _ewk_view_composite(void* data);
879 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
881 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
883 evas_object_resize(smartData->image, width, height);
884 evas_object_image_size_set(smartData->image, width, height);
885 evas_object_image_fill_set(smartData->image, 0, 0, width, height);
887 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
888 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
889 evas_object_image_native_surface_set(smartData->image, 0);
891 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
892 if (impl->pageClient->isVisible()) {
893 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
894 impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee));
896 impl->pageClient->setDeferUpdateViewportSize(true);
898 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
899 impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee));
902 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
903 if (!ewk_view_is_opengl_backend(ewkView))
904 _ewk_view_composite(smartData);
905 else // OpenGL backend
907 impl->pageClient->displayViewport();
909 #endif // #if OS(TIZEN)
911 smartData->changed.size = true;
912 _ewk_view_smart_changed(smartData);
915 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
917 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
919 smartData->changed.position = true;
920 _ewk_view_smart_changed(smartData);
923 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
925 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
926 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
928 Evas_Coord x, y, width, height;
930 smartData->changed.any = false;
932 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
934 if (smartData->changed.size) {
936 #if USE(COORDINATED_GRAPHICS)
937 impl->pageViewportControllerClient->updateViewportSize(IntSize(width, height));
939 #if USE(ACCELERATED_COMPOSITING)
940 needsNewSurface = impl->evasGlSurface;
943 if (impl->pageProxy->drawingArea())
944 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
946 #if USE(ACCELERATED_COMPOSITING)
947 if (!impl->evasGlSurface)
949 evas_gl_surface_destroy(impl->evasGl, impl->evasGlSurface);
950 impl->evasGlSurface = 0;
951 ewk_view_create_gl_surface(ewkView, IntSize(width, height));
952 ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
954 #endif // #if !OS(TIZEN)
956 smartData->view.w = width;
957 smartData->view.h = height;
958 smartData->changed.size = false;
961 if (impl->pageClient) {
962 if (DrawingAreaProxy* drawingArea = impl->pageProxy->drawingArea()) {
963 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
964 if (impl->pageProxy->isViewVisible())
965 drawingArea->setSize(IntSize(width, height), IntSize());
967 drawingArea->setSize(IntSize(width, height), IntSize());
969 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
970 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
971 int newAngle = ecore_evas_rotation_get(ee);
972 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
973 if (impl->pageClient->deferUpdateViewportSize()) {
974 impl->pageClient->updateViewportSize(IntSize(width, height), newAngle);
977 impl->pageClient->updateVisibleContentRectSize(IntSize(width, height));
978 if (ewk_view_is_opengl_backend(ewkView))
979 impl->pageClient->displayViewport();
982 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
983 impl->pageClient->frameRectChanged();
986 #endif // #if OS(TIZEN)
989 if (smartData->changed.position) {
990 evas_object_move(smartData->image, x, y);
991 smartData->view.x = x;
992 smartData->view.y = y;
993 smartData->changed.position = false;
995 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
996 impl->pageClient->frameRectChanged();
998 #if ENABLE(TIZEN_SCREEN_READER)
999 impl->pageProxy->recalcScreenReaderFocusRect();
1001 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1002 impl->pageClient->updateTextSelectionHandlesAndContextMenu(true);
1004 #endif // #if OS(TIZEN)
1007 if (impl->popupPicker)
1008 ewk_popup_picker_resize(impl->popupPicker);
1009 #endif // #if OS(TIZEN)
1012 static void _ewk_view_smart_show(Evas_Object* ewkView)
1014 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1015 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1017 if (evas_object_clipees_get(smartData->base.clipper))
1018 evas_object_show(smartData->base.clipper);
1019 evas_object_show(smartData->image);
1021 #if ENABLE(TIZEN_SCREEN_READER)
1022 ScreenReaderProxy::screenReader().initialize(impl);
1026 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1028 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1030 evas_object_hide(smartData->base.clipper);
1031 evas_object_hide(smartData->image);
1032 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1033 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1034 if (impl->pageClient->isTextSelectionMode())
1035 impl->pageClient->setIsTextSelectionMode(false);
1039 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1041 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1042 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1046 else if (alpha > 255)
1049 #define CHECK_COLOR(color, alpha) \
1052 else if (color > alpha) \
1054 CHECK_COLOR(red, alpha);
1055 CHECK_COLOR(green, alpha);
1056 CHECK_COLOR(blue, alpha);
1059 evas_object_image_alpha_set(smartData->image, alpha < 255);
1060 impl->pageProxy->setDrawsBackground(red || green || blue);
1061 impl->pageProxy->setDrawsTransparentBackground(alpha < 255);
1062 impl->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1065 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1069 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1071 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1073 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1074 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1075 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1079 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1080 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1082 evas_object_smart_clipped_smart_set(&api->sc);
1084 // Set Evas_Smart_Class functions.
1085 api->sc.add = _ewk_view_smart_add;
1086 api->sc.del = _ewk_view_smart_del;
1087 api->sc.move = _ewk_view_smart_move;
1088 api->sc.resize = _ewk_view_smart_resize;
1089 api->sc.show = _ewk_view_smart_show;
1090 api->sc.hide = _ewk_view_smart_hide;
1091 api->sc.color_set = _ewk_view_smart_color_set;
1092 api->sc.calculate = _ewk_view_smart_calculate;
1093 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1095 // Set Ewk_View_Smart_Class functions.
1096 api->focus_in = _ewk_view_smart_focus_in;
1097 api->focus_out = _ewk_view_smart_focus_out;
1098 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1099 api->mouse_down = _ewk_view_smart_mouse_down;
1100 api->mouse_up = _ewk_view_smart_mouse_up;
1101 api->mouse_move = _ewk_view_smart_mouse_move;
1102 api->key_down = _ewk_view_smart_key_down;
1103 api->key_up = _ewk_view_smart_key_up;
1105 api->gesture_start = _ewk_view_smart_gesture_start;
1106 api->gesture_end = _ewk_view_smart_gesture_end;
1107 api->gesture_move = _ewk_view_smart_gesture_move;
1109 #if ENABLE(TIZEN_FULLSCREEN_API)
1110 api->fullscreen_enter = _ewk_view_smart_fullscreen_enter;
1111 api->fullscreen_exit = _ewk_view_smart_fullscreen_exit;
1114 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1115 api->popup_menu_show = _ewk_view_popup_menu_show;
1116 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1117 api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1119 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1120 api->popup_menu_update = _ewk_view_popup_menu_update;
1122 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1123 api->text_selection_down = _ewk_view_text_selection_down;
1124 api->text_selection_move = _ewk_view_text_selection_move;
1125 api->text_selection_up = _ewk_view_text_selection_up;
1127 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1128 api->input_picker_show = _ewk_view_input_picker_show;
1130 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1131 api->data_list_show = _ewk_view_data_list_show;
1132 api->data_list_hide = _ewk_view_data_list_hide;
1134 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1135 api->orientation_lock = _ewk_orientation_lock;
1136 api->orientation_unlock = _ewk_orientation_unlock;
1138 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1139 api->input_picker_color_request = _ewk_input_picker_color_request;
1140 api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1142 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1143 api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1144 api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1145 api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1146 api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1148 #if ENABLE(TIZEN_SCREEN_READER)
1149 api->screen_reader_action_execute = _ewk_view_screen_reader_action_execute;
1151 #endif //#if OS(TIZEN)
1156 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1158 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1159 static Evas_Smart* smart = 0;
1161 if (EINA_UNLIKELY(!smart)) {
1162 ewk_view_smart_class_set(&api);
1163 smart = evas_smart_class_new(&api.sc);
1169 static void _ewk_view_initialize(Evas_Object* ewkView, PassRefPtr<Ewk_Context> context, WKPageGroupRef pageGroupRef)
1171 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1172 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1173 EINA_SAFETY_ON_NULL_RETURN(context);
1175 if (impl->pageClient)
1178 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1179 bool isOpenGL = ewk_view_is_opengl_backend(ewkView);
1181 impl->pageClient = PageClientEvasGL::create(impl);
1183 impl->pageClient = PageClientImpl::create(impl);
1185 impl->pageClient = PageClientImpl::create(impl);
1189 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), toImpl(pageGroupRef));
1191 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), WebPageGroup::create().get());
1193 EwkViewImpl::addToPageViewMap(ewkView);
1196 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
1197 impl->pageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
1198 impl->pageProxy->pageGroup()->preferences()->setFrameFlatteningEnabled(true);
1199 impl->pageProxy->pageGroup()->preferences()->setAllowUniversalAccessFromFileURLs(true);
1202 impl->pageProxy->initializeWebPage();
1204 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
1205 impl->pageProxy->setCustomDeviceScaleFactor((float)getMobileDPI() / 160);
1207 impl->pageProxy->setCustomDeviceScaleFactor((float)getDPI() / 160);
1210 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1211 impl->pageProxy->setUseFixedLayout(true);
1213 #if ENABLE(FULLSCREEN_API)
1214 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1217 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1219 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1221 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1222 impl->pageProxy->pageGroup()->preferences()->setWebGLEnabled(false);
1223 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1227 impl->backForwardList = Ewk_Back_Forward_List::create(toAPI(impl->pageProxy->backForwardList()));
1229 impl->context = context;
1232 ewkViewContextMenuClientAttachClient(ewkView);
1233 ewkViewTizenClientAttachClient(ewkView);
1235 #if ENABLE(TIZEN_GEOLOCATION)
1236 ewkViewGeolocationProviderAttachProvider(ewkView, impl->context->wkContext());
1239 #if ENABLE(TIZEN_NOTIFICATIONS)
1240 ewkViewNotificationProviderAttachProvider(ewkView, impl->context->wkContext());
1243 #if ENABLE(TIZEN_ICON_DATABASE)
1244 ewk_view_icondatabase_client_attach(ewkView, impl->context->wkContext());
1247 ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1248 ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1249 ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1250 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1251 ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1253 ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1254 #else // #if OS(TIZEN)
1255 #if USE(COORDINATED_GRAPHICS)
1256 impl->viewportHandler = EflViewportHandler::create(impl->pageClient.get());
1258 #endif // #if OS(TIZEN)
1260 #if ENABLE(FULLSCREEN_API)
1261 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1262 impl->pageProxy->pageGroup()->preferences()->setFullScreenEnabled(true);
1265 // Initialize page clients.
1266 impl->pageLoadClient = PageLoadClientEfl::create(impl);
1267 impl->pagePolicyClient = PagePolicyClientEfl::create(impl);
1268 impl->pageUIClient = PageUIClientEfl::create(impl);
1269 impl->resourceLoadClient = ResourceLoadClientEfl::create(impl);
1270 impl->findClient = FindClientEfl::create(impl);
1271 impl->formClient = FormClientEfl::create(impl);
1272 #if !ENABLE(TIZEN_ICON_DATABASE)
1273 /* Listen for favicon changes */
1274 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
1275 iconDatabase->watchChanges(IconChangeCallbackData(_ewk_view_on_favicon_changed, ewkView));
1277 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1278 ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1281 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1282 if (!impl->context->xWindow())
1283 impl->context->setXWindow(elm_win_xwindow_get(ewkView));
1286 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1287 impl->focusRing = FocusRing::create(impl);
1291 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1293 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1294 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1296 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1298 using namespace EGL;
1299 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1300 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1306 Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1310 EWK_VIEW_SD_GET(ewkView, smartData);
1312 evas_object_del(ewkView);
1316 EWK_VIEW_IMPL_GET(smartData, impl);
1318 evas_object_del(ewkView);
1327 * Constructs a ewk_view Evas_Object with WKType parameters.
1329 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1331 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1332 EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1334 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1338 _ewk_view_initialize(ewkView, Ewk_Context::create(contextRef), pageGroupRef);
1343 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1345 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1346 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1347 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1349 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1353 #if ENABLE(TIZEN_ICON_DATABASE)
1354 //set default iconDatabasePath
1355 WKContextRef contextRef = context->wkContext();
1356 toImpl(contextRef)->setIconDatabasePath(toImpl(contextRef)->iconDatabasePath());
1359 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1360 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1361 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1362 _ewk_view_initialize(ewkView, context, toAPI(impl->pageGroup.get()));
1364 _ewk_view_initialize(ewkView, context, 0);
1370 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1372 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1373 return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1376 Evas_Object* ewk_view_add(Evas* canvas)
1378 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1381 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
1383 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1384 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1386 return impl->ewkContext();
1389 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* url)
1391 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1392 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1393 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
1395 impl->pageProxy->loadURL(String::fromUTF8(url));
1396 impl->informURLChange();
1401 const char* ewk_view_url_get(const Evas_Object* ewkView)
1403 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1404 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1409 const char *ewk_view_icon_url_get(const Evas_Object *ewkView)
1411 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1412 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1414 return impl->faviconURL();
1417 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1419 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1420 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1422 impl->pageClient->prepareRestoredVisibleContectRect();
1423 impl->pageProxy->reload(/*reloadFromOrigin*/ false);
1424 impl->informURLChange();
1429 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1431 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1432 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1434 impl->pageProxy->reload(/*reloadFromOrigin*/ true);
1435 impl->informURLChange();
1440 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1442 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1443 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1445 impl->pageProxy->stopLoading();
1450 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1452 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1453 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1455 return impl->settings();
1458 const char* ewk_view_title_get(const Evas_Object* ewkView)
1460 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1461 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1463 return impl->title();
1468 * Reports that the requested text was found.
1470 * Emits signal: "text,found" with the number of matches.
1472 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
1474 evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
1477 double ewk_view_load_progress_get(const Evas_Object* ewkView)
1479 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1480 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1482 return impl->pageProxy->estimatedProgress();
1485 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
1487 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1488 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1494 scaleFactor = impl->pageClient->adjustScaleWithViewport(scaleFactor);
1496 IntPoint scrollPosition = impl->pageClient->scrollPosition();
1497 double scaleDifference = scaleFactor / impl->pageClient->scaleFactor();
1498 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
1499 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
1501 impl->pageProxy->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
1503 impl->pageProxy->scalePage(scaleFactor, IntPoint(x, y));
1508 double ewk_view_scale_get(const Evas_Object* ewkView)
1510 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
1511 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1);
1514 return impl->pageProxy->scaleFactor();
1516 return impl->pageProxy->pageScaleFactor();
1520 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
1522 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1523 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1525 impl->pageProxy->setCustomDeviceScaleFactor(ratio);
1530 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
1532 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1533 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1535 return impl->pageProxy->deviceScaleFactor();
1538 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
1540 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1541 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1543 impl->setThemePath(path);
1546 const char* ewk_view_theme_get(const Evas_Object* ewkView)
1548 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1549 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1551 return impl->themePath();
1554 Eina_Bool ewk_view_back(Evas_Object* ewkView)
1556 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1557 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1559 WebPageProxy* page = impl->pageProxy.get();
1560 if (page->canGoBack()) {
1568 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
1570 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1571 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1573 WebPageProxy* page = impl->pageProxy.get();
1574 if (page->canGoForward()) {
1582 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
1584 #if ENABLE(WEB_INTENTS)
1585 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1586 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1587 EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
1589 WebPageProxy* page = impl->pageProxy.get();
1590 page->deliverIntentToFrame(page->mainFrame(), intent->webIntentData());
1598 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
1600 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1601 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1603 return impl->pageProxy->canGoBack();
1606 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
1608 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1609 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1611 return impl->pageProxy->canGoForward();
1614 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
1616 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1617 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1619 return impl->backForwardList.get();
1622 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1623 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
1625 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1626 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1628 if (!ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
1631 if (value.isEmpty()) {
1632 if(smartData->api->formdata_candidate_is_showing(smartData))
1633 smartData->api->formdata_candidate_hide(smartData);
1637 Vector<String> popupCandidates;
1638 ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
1639 std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
1641 Eina_List* candidateList = 0;
1642 for (size_t i = 0; i < popupCandidates.size(); ++i) {
1643 if (popupCandidates[i].startsWith(value, false))
1644 candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
1647 if (!eina_list_count(candidateList)) {
1648 if(smartData->api->formdata_candidate_is_showing(smartData))
1649 smartData->api->formdata_candidate_hide(smartData);
1653 smartData->api->formdata_candidate_update_data(smartData, candidateList);
1655 IntRect inputFieldRect = impl->transformToScene().mapRect(impl->pageClient->focusedNodeRect());
1656 smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
1659 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm)
1661 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1662 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1663 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
1664 && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
1666 ewk_view_context_get(ewkView)->addFormData(impl->url(), formData, isPasswordForm);
1669 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
1671 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1672 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1674 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
1677 Vector<std::pair<String, String> > passwordFormData;
1678 ewk_view_context_get(ewkView)->passwordFormData(impl->url(), passwordFormData);
1680 if (!passwordFormData.size())
1683 String passwordFormAutofill = String::fromUTF8("try { function passwordFormAutofill() { var inputFields;");
1684 for (size_t i = 0; i < passwordFormData.size(); i++) {
1685 passwordFormAutofill += String::fromUTF8(" inputFields = document.getElementsByName(\"");
1686 passwordFormAutofill += passwordFormData[i].first;
1687 passwordFormAutofill += String::fromUTF8("\");");
1688 passwordFormAutofill += String::fromUTF8(" for (var i = 0; i < inputFields.length; i++)");
1689 passwordFormAutofill += String::fromUTF8(" if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\" || inputFields[i].type.toLowerCase() == \"email\"))");
1690 passwordFormAutofill += String::fromUTF8(" inputFields[i].value = \"");
1691 passwordFormAutofill += passwordFormData[i].second;
1692 passwordFormAutofill += String::fromUTF8("\";");
1694 passwordFormAutofill += String::fromUTF8("} passwordFormAutofill(); } catch(e) { }");
1695 ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
1698 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
1700 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1701 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1702 ewk_view_context_get(ewkView)->candidateFormData(name, candidates);
1706 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
1708 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1709 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1710 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
1712 if (unreachableUrl && *unreachableUrl)
1713 impl->pageProxy->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
1715 impl->pageProxy->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
1717 impl->informURLChange();
1722 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
1724 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1725 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1727 return impl->customTextEncodingName();
1730 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
1732 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1733 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1735 impl->setCustomTextEncodingName(encoding);
1741 // FIXME: It should be removed.
1742 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
1744 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1745 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1747 return toAPI(impl->pageProxy.get());
1750 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
1752 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1753 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1755 impl->setMouseEventsEnabled(!!enabled);
1760 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
1762 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1763 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1765 return impl->mouseEventsEnabled();
1768 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
1770 #if ENABLE(INPUT_TYPE_COLOR)
1771 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1772 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1774 return impl->setColorPickerColor(WebCore::Color(r, g, b, a));
1780 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
1782 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1783 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1785 return impl->javascriptPopup->alert(alertText);
1788 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
1790 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1791 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1793 return impl->javascriptPopup->confirm(message);
1796 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
1798 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1799 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1801 return impl->javascriptPopup->prompt(message, defaultValue);
1804 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1805 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, 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->beforeUnloadConfirmPanel(message);
1814 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)
1816 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1817 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1819 return impl->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, impl);
1822 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1823 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)
1825 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1827 if (impl->popupPicker)
1828 ewk_popup_picker_del(impl->popupPicker);
1830 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1831 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
1833 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
1839 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1840 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)
1842 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1844 if (impl->popupPicker)
1845 ewk_popup_picker_del(impl->popupPicker);
1847 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
1853 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
1855 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1857 if (!impl->popupPicker)
1860 ewk_popup_picker_del(impl->popupPicker);
1861 impl->popupPicker = 0;
1866 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)
1868 // FIXME: The rect should be updated if it was changed
1870 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1872 if (!impl->popupPicker)
1875 ewk_popup_picker_update(smartData->self, impl->popupPicker, items, selectedIndex);
1881 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1882 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
1884 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1886 impl->inputPicker->show(inputType, inputValue);
1891 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1892 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
1894 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1896 impl->inputPicker->showDataList(inputType, optionList);
1900 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
1902 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1904 impl->inputPicker->hideDataList(inputType);
1909 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1910 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
1912 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1914 impl->inputPicker->showColorPicker(r, g, b, a);
1918 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
1920 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1922 impl->inputPicker->hideColorPicker();
1927 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
1929 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1930 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1932 return impl->pageClient.get();
1935 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
1937 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
1938 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 1);
1940 return WKPageGetTextZoomFactor(toAPI(impl->pageProxy.get()));
1943 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
1945 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1946 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1948 WKPageSetTextZoomFactor(toAPI(impl->pageProxy.get()), textZoomFactor);
1952 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1953 FocusRing* ewkViewGetFocusRing(Evas_Object* ewkView)
1955 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1956 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1958 return impl->focusRing.get();
1962 Ewk_Frame_Ref ewk_view_main_frame_get(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 static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(impl->pageProxy.get())));
1970 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
1972 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1973 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1975 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(impl->pageProxy.get())));
1978 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
1980 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1981 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1983 if (!impl->javascriptGlobalContext)
1984 impl->javascriptGlobalContext = JSGlobalContextCreate(0);
1985 return impl->javascriptGlobalContext;
1988 void ewkViewLoadCommitted(Evas_Object* ewkView)
1990 #if ENABLE(TIZEN_GESTURE)
1991 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1992 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1993 impl->gestureClient->reset();
1995 #if ENABLE(TIZEN_ISF_PORT)
1996 impl->inputMethodContext()->hideIMFContext();
1998 impl->informURLChange();
1999 evas_object_smart_callback_call(ewkView, "load,committed", 0);
2002 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
2004 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2005 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2007 OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error);
2008 ewk_error_load_error_page(ewkError.get(), toAPI(impl->pageProxy.get()));
2009 evas_object_smart_callback_call(ewkView, "load,error", ewkError.get());
2012 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
2014 #if ENABLE(TIZEN_GESTURE)
2015 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2016 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2017 impl->gestureClient->reset();
2019 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
2022 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
2024 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2025 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2027 if (impl->authChallenge)
2028 ewkAuthChallengeDelete(impl->authChallenge);
2029 impl->authChallenge = authChallenge;
2031 evas_object_smart_callback_call(ewkView, "authentication,challenge", impl->authChallenge);
2034 void ewk_view_process_crashed(Evas_Object* ewkView)
2036 bool handled = false;
2037 evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
2043 #if ENABLE(TIZEN_SQL_DATABASE)
2044 bool ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef databaseName, unsigned long long expectedUsage)
2046 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2047 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2049 if (!impl->exceededDatabaseQuotaContext || !impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback)
2052 TIZEN_LOGI("No error in prameter. Request to display user confirm popup. expectedUsage(%llu)", expectedUsage);
2053 impl->isWaitingForExceededQuotaPopupReply = true;
2054 if (impl->exceededQuotaOrigin)
2055 deleteSecurityOrigin(impl->exceededQuotaOrigin);
2056 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
2058 int length = WKStringGetMaximumUTF8CStringSize(databaseName);
2059 OwnArrayPtr<char> databaseNameBuffer = adoptArrayPtr(new char[length]);
2060 WKStringGetUTF8CString(databaseName, databaseNameBuffer.get(), length);
2062 return impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, databaseNameBuffer.get(), expectedUsage, impl->exceededDatabaseQuotaContext->userData) == EINA_TRUE;
2066 #if ENABLE(TIZEN_NOTIFICATIONS)
2067 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
2069 TIZEN_LOGI("notification,cancel");
2070 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
2073 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
2075 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2076 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2078 TIZEN_LOGI("notification,permission,request");
2079 impl->notificationPermissionRequests = eina_list_append(impl->notificationPermissionRequests, notificationPermissionRequest);
2080 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
2083 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
2085 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2086 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2088 TIZEN_LOGI("notification,show");
2089 Eina_List* listIterator=0;
2091 const char* replaceID = ewkNotificationGetReplaceID(notification);
2092 if(strlen(replaceID)) {
2093 EINA_LIST_FOREACH(impl->notifications, listIterator, data) {
2094 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
2095 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
2096 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
2100 impl->notifications = eina_list_append(impl->notifications, notification);
2101 evas_object_smart_callback_call(ewkView, "notification,show", notification);
2104 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
2106 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2107 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2109 impl->notificationPermissionRequests = eina_list_remove(impl->notificationPermissionRequests, ewkNotificationPermissionRequest);
2113 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
2114 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
2116 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2118 TIZEN_LOGI("protocolhandler,registration,requested");
2119 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
2120 evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
2121 ewkCustomHandlersDeleteData(customHandlersData);
2125 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
2126 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2128 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2130 TIZEN_LOGI("protocolhandler,isregistered");
2131 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2132 evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
2134 Ewk_Custom_Handlers_State result;
2135 result = ewkGetCustomHandlersDataResult(customHandlersData);
2136 ewkCustomHandlersDeleteData(customHandlersData);
2141 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2143 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2145 TIZEN_LOGI("protocolhandler,unregistration,requested");
2146 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2147 evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
2148 ewkCustomHandlersDeleteData(customHandlersData);
2152 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
2153 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
2155 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2157 TIZEN_LOGI("contenthandler,registration,requested");
2158 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
2159 evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
2160 ewkCustomHandlersDeleteData(customHandlersData);
2163 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2165 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2167 TIZEN_LOGI("contenthandler,isregistered");
2168 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2169 evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
2171 Ewk_Custom_Handlers_State result;
2172 result = ewkGetCustomHandlersDataResult(customHandlersData);
2173 ewkCustomHandlersDeleteData(customHandlersData);
2178 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2180 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2182 TIZEN_LOGI("contenthandler,unregistration,requested");
2183 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2184 evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
2185 ewkCustomHandlersDeleteData(customHandlersData);
2189 #if ENABLE(TIZEN_SEARCH_PROVIDER)
2190 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2192 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2194 TIZEN_LOGI("searchProvider,add");
2195 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2196 evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
2197 ewkSearchProviderDeleteData(searchProviderData);
2200 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2202 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
2204 TIZEN_LOGI("searchProvider,installed");
2205 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2206 evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
2207 unsigned long result;
2208 result = ewkGetSearchProviderResult(searchProviderData);
2209 ewkSearchProviderDeleteData(searchProviderData);
2214 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
2215 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
2217 TIZEN_LOGI("webapp,metatag,standalone");
2218 bool standalone = true;
2219 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
2224 #if ENABLE(TIZEN_MEDIA_STREAM)
2225 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
2227 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2228 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2230 impl->userMediaPermissionRequests = eina_list_append(impl->userMediaPermissionRequests, userMediaPermission);
2231 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
2234 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
2236 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2237 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2239 impl->userMediaPermissionRequests = eina_list_remove(impl->userMediaPermissionRequests, permission);
2244 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
2245 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
2247 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
2248 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
2249 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
2250 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
2251 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
2252 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
2254 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
2258 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
2259 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
2261 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2262 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2263 if (impl->certificatePolicyDecision)
2264 ewkCertificatePolicyDecisionDelete(impl->certificatePolicyDecision);
2265 impl->certificatePolicyDecision = certificatePolicyDecision;
2267 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
2271 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
2273 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
2276 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
2278 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
2281 #if ENABLE(TIZEN_GEOLOCATION)
2282 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2284 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2285 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2287 TIZEN_LOGI("geolocation,permission,request");
2288 impl->geolocationPermissionRequests = eina_list_append(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2289 evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
2292 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2294 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2295 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2297 impl->geolocationPermissionRequests = eina_list_remove(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2300 void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
2302 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2303 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2305 impl->geolocation = geolocation;
2308 Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
2310 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2311 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2313 return impl->geolocation;
2316 bool ewkViewIsValidLocationService(Evas_Object* ewkView)
2318 TIZEN_LOGI("geolocation,valid");
2321 evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
2326 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
2328 evas_object_smart_callback_call(ewkView, "form,submit", formData);
2331 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2333 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2334 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2335 if (impl->policyDecision)
2336 ewkPolicyDecisionDelete(impl->policyDecision);
2337 impl->policyDecision = policyDecision;
2339 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", impl->policyDecision);
2342 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2344 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2345 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2346 if (impl->policyDecision)
2347 ewkPolicyDecisionDelete(impl->policyDecision);
2348 impl->policyDecision = policyDecision;
2350 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", impl->policyDecision);
2353 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2355 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2356 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2357 if (impl->policyDecision)
2358 ewkPolicyDecisionDelete(impl->policyDecision);
2359 impl->policyDecision = policyDecision;
2361 evas_object_smart_callback_call(ewkView, "policy,response,decide", impl->policyDecision);
2364 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
2366 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2367 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2369 IntPoint scrollPosition = impl->pageClient->scrollPosition();
2370 IntSize contentsSize = impl->pageProxy->contentsSize();
2371 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2372 contentsSize.scale(impl->pageClient->scaleFactor());
2375 // some website's contents size is smaller than view size,
2376 // so we have to adjust contents size to view size for that case.
2377 if (contentsSize.width() < smartData->view.w)
2378 contentsSize.setWidth(smartData->view.w);
2379 if (contentsSize.height() < smartData->view.h)
2380 contentsSize.setHeight(smartData->view.h);
2382 // Call "scroll,down" if webview can be scrolled down.
2383 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
2384 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
2385 // Call "scroll,up" if webview can be scrolled up.
2386 else if (deltaY < 0 && scrollPosition.y() > 0)
2387 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
2389 // Call "scroll,right" if webview can be scrolled down.
2390 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
2391 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
2392 // Call "scroll,left" if webview can be scrolled up.
2393 else if (deltaX < 0 && scrollPosition.x() > 0)
2394 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
2397 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
2399 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2400 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2402 IntSize contentsSize = impl->pageProxy->contentsSize();
2403 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2404 contentsSize.scale(impl->pageClient->scaleFactor());
2407 int maxScrollY = contentsSize.height() - smartData->view.h;
2408 if (!impl->isVerticalEdge) {
2409 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
2410 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
2411 impl->isVerticalEdge = true;
2412 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
2413 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
2414 impl->isVerticalEdge = true;
2417 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
2418 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
2419 impl->isVerticalEdge = false;
2422 int maxScrollX = contentsSize.width() - smartData->view.w;
2423 if (!impl->isHorizontalEdge) {
2424 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
2425 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
2426 impl->isHorizontalEdge = true;
2427 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
2428 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
2429 impl->isHorizontalEdge = true;
2432 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
2433 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
2434 impl->isHorizontalEdge = false;
2438 void ewkViewClearEdges(Evas_Object* ewkView)
2440 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2441 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2443 impl->isVerticalEdge = false;
2444 impl->isHorizontalEdge = false;
2447 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
2449 EWK_VIEW_SD_GET(ewkView, smartData);
2450 if (!smartData || !smartData->priv) {
2458 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
2460 *minimumScale = constraints.minimumScale;
2462 *maximumScale = constraints.maximumScale;
2465 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard)
2467 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2468 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2470 double scaleFactor = impl->pageClient->scaleFactor();
2471 IntSize contentsSize = impl->pageProxy->contentsSize();
2473 double newScaleFactor = scaleFactor;
2474 // Readable zoom value is dependent on device DPI
2475 if (scaleFactor < impl->pageProxy->deviceScaleFactor()
2476 && impl->pageClient->viewportConstraints().userScalable)
2477 newScaleFactor = impl->pageProxy->deviceScaleFactor();
2479 // Readable zoom value should be inside of viewport scale range
2480 newScaleFactor = impl->pageClient->adjustScaleWithViewport(newScaleFactor);
2482 // scale contents' size with new scale factor
2483 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2484 contentsSize.scale(newScaleFactor);
2486 contentsSize.scale(newScaleFactor / scaleFactor);
2489 #if ENABLE(TIZEN_ISF_PORT)
2490 Ecore_X_Window rootWin = ecore_x_window_root_first_get();
2491 ecore_x_event_mask_set(rootWin, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
2492 Ecore_X_Atom xAtom = ecore_x_atom_get("X External Keyboard Exist");
2493 unsigned int connectedKeyboardNum = 0;
2494 bool isExternalKeyboardConnected = false;
2496 // get connected keyboard number
2497 if (ecore_x_window_prop_card32_get(rootWin, xAtom, &connectedKeyboardNum, 1)
2498 && connectedKeyboardNum)
2499 isExternalKeyboardConnected = true;
2501 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
2502 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
2503 // input field zoom should not work with below conditions
2504 // 1. view is not focused
2505 // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
2506 // 3. imfContext is null(if adjustForExternalKeyboard is false)
2507 // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
2508 if ((!(static_cast<PageClient*>(impl->pageClient.get()))->isViewFocused()
2509 || (adjustForExternalKeyboard && !isExternalKeyboardConnected)
2510 || (!adjustForExternalKeyboard && !impl->inputMethodContext())
2511 || (!adjustForExternalKeyboard && !impl->inputMethodContext()->isShow()))
2512 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
2513 && !(impl->pageClient->isClipboardWindowOpened())
2519 // caret position can be outside of visible rect.
2520 // we need to consider it.
2521 IntRect selectionRect = impl->pageProxy->getSelectionRect(true);
2522 IntRect focusedNodeRect = impl->pageClient->focusedNodeRect();
2523 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2524 selectionRect.scale(newScaleFactor);
2525 focusedNodeRect.scale(newScaleFactor);
2527 selectionRect.scale(newScaleFactor / scaleFactor);
2528 focusedNodeRect.scale(newScaleFactor / scaleFactor);
2530 if (selectionRect.isEmpty())
2533 IntRect visibleRect = impl->pageClient->visibleContentRect();
2534 IntPoint scrollPosition = visibleRect.location();
2535 // Do not adjust scroll position if content is userscalable or selection rect (caret) is visible after scaling
2536 if (impl->pageClient->userScalable() || !visibleRect.contains(selectionRect)) {
2538 scrollPosition = IntPoint(selectionRect.x() - visibleRect.width() / 3, selectionRect.y() - visibleRect.height() / 3);
2539 // If both input field's position x and selection rect can be displayed together,
2540 // adjust scroll position to input field's position x.
2541 if (!focusedNodeRect.isEmpty() && selectionRect.x() - focusedNodeRect.x() < visibleRect.width() * 4 / 5)
2542 scrollPosition.setX(focusedNodeRect.x());
2545 #if ENABLE(TIZEN_DLOG_SUPPORT)
2546 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", scrollPosition.x(), scrollPosition.y(), newScaleFactor);
2549 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2550 impl->pageClient->setVisibleContentRect(IntRect(scrollPosition, impl->size()), newScaleFactor);
2552 if (newScaleFactor != scaleFactor)
2553 impl->pageProxy->scalePage(newScaleFactor, scrollPosition);
2555 impl->pageProxy->scrollMainFrameTo(scrollPosition);
2557 evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
2561 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
2562 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2563 static Eina_Bool _ewk_view_composite(void* data)
2565 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
2566 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2568 if (!evas_object_visible_get(smartData->image))
2569 return ECORE_CALLBACK_CANCEL;
2572 evas_object_image_size_get(smartData->image, &ow, &oh);
2573 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
2575 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)));
2576 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
2578 cairo_save(context.get());
2579 cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
2580 cairo_rectangle(context.get(), 0, 0, ow, oh);
2581 cairo_fill(context.get());
2582 cairo_restore(context.get());
2584 impl->pageClient->drawContents(context.get());
2586 evas_object_image_data_set(smartData->image, pixels);
2587 evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
2589 if (impl->pageClient->notifiedNonemptyLayout())
2590 ewkViewFrameRendered(smartData->self);
2592 impl->compositionAnimator = 0;
2594 return ECORE_CALLBACK_CANCEL;
2598 void ewk_view_mark_for_sync(Evas_Object* ewkView)
2600 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2601 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
2603 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2604 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2606 if (!ewk_view_is_opengl_backend(ewkView)) {
2607 if (!impl->compositionAnimator)
2608 impl->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
2613 evas_object_image_pixels_dirty_set(smartData->image, true);
2616 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
2618 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
2619 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2620 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2621 impl->pageClient->drawContents();
2624 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
2626 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2627 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2629 if (!smartData->image)
2632 evas_object_image_native_surface_set(smartData->image, nativeSurface);
2633 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
2639 void _ewk_view_suspend_painting(Evas_Object* ewkView)
2641 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2642 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2644 if (!impl->suspendedPainting) {
2645 impl->pageProxy->suspendPainting();
2646 impl->suspendedPainting = true;
2650 void _ewk_view_resume_painting(Evas_Object* ewkView)
2652 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2653 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2655 if (impl->suspendedPainting) {
2656 impl->pageProxy->resumePainting();
2657 impl->suspendedPainting = false;
2661 void ewk_view_suspend(Evas_Object* ewkView)
2663 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2664 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2666 if (impl->pageProxy->estimatedProgress() < 1.0) {
2667 impl->suspendRequested = true;
2670 impl->suspendRequested = false;
2672 _ewk_view_suspend_painting(ewkView);
2674 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2675 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2676 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2678 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2679 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2680 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2681 // will be suspended again.
2682 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2683 // the ActiveDOMObject.
2684 if (!impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2685 impl->pageProxy->suspendAnimations();
2686 impl->pageProxy->suspendJavaScriptAndResource();
2687 impl->suspendedResources = true;
2690 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2691 impl->pageProxy->suspendPlugin();
2695 void ewk_view_resume(Evas_Object* ewkView)
2697 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2698 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2700 if (impl->suspendRequested) {
2701 impl->suspendRequested = false;
2705 _ewk_view_resume_painting(ewkView);
2707 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2708 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2709 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2711 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2712 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2713 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2714 // will be suspended again.
2715 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2716 // the ActiveDOMObject.
2717 if (impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2718 impl->pageProxy->resumeAnimations();
2719 impl->pageProxy->resumeJavaScriptAndResource();
2720 impl->suspendedResources = false;
2723 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2724 impl->pageProxy->resumePlugin();
2728 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
2730 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2731 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2732 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
2734 ResourceRequest request(String::fromUTF8(url));
2737 case EWK_HTTP_METHOD_GET:
2738 request.setHTTPMethod("GET");
2740 case EWK_HTTP_METHOD_HEAD:
2741 request.setHTTPMethod("HEAD");
2743 case EWK_HTTP_METHOD_POST:
2744 request.setHTTPMethod("POST");
2746 case EWK_HTTP_METHOD_PUT:
2747 request.setHTTPMethod("PUT");
2749 case EWK_HTTP_METHOD_DELETE:
2750 request.setHTTPMethod("DELETE");
2757 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
2759 while (eina_iterator_next(it, &data)) {
2760 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
2761 const char* name = static_cast<const char*>(t->key);
2762 const char* value = static_cast<const char*>(t->data);
2763 request.addHTTPHeaderField(name, value);
2765 eina_iterator_free(it);
2769 request.setHTTPBody(FormData::create(body));
2771 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
2772 WKPageLoadURLRequest(toAPI(impl->pageProxy.get()), urlRequest.get());
2777 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
2779 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2780 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2782 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
2783 WKPageLoadPlainTextString(toAPI(impl->pageProxy.get()), plainTextRef.get());
2788 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
2790 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2791 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2792 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
2794 if (contentsSize == 0)
2797 String mimeTypeString;
2799 mimeTypeString = String::fromUTF8(mimeType);
2801 mimeTypeString = String::fromUTF8("text/html");
2803 String encodingString;
2805 encodingString = String::fromUTF8(encoding);
2807 encodingString = String::fromUTF8("UTF-8");
2809 String baseUriString;
2811 baseUriString = String::fromUTF8(baseUri);
2813 baseUriString = String::fromUTF8("about:blank");
2815 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
2816 impl->pageProxy->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
2821 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
2823 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2824 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2826 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
2827 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
2829 WKPageLoadHTMLString(toAPI(impl->pageProxy.get()), htmlString.get(), baseURL.get());
2834 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
2836 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2837 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2839 TIZEN_LOGI("initialState (%d)", initialState);
2840 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
2841 WKPageSetPageVisibility(toAPI(impl->pageProxy.get()), static_cast<WKPageVisibilityState>(pageVisibilityState), initialState);
2848 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
2850 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
2852 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2853 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2855 impl->userAgent = userAgent;
2857 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
2858 WKPageSetCustomUserAgent(toAPI(impl->pageProxy.get()), userAgentString.get());
2863 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
2865 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2866 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2868 if (!impl->userAgent) {
2869 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
2871 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
2872 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2873 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
2874 impl->userAgent = buffer.get();
2877 return impl->userAgent;
2879 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
2881 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2882 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2883 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2885 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2886 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
2888 WKPageAddCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get(), customHeaderValue.get());
2891 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2896 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
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));
2904 WKPageRemoveCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get());
2907 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2912 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
2914 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2915 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2916 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2918 WKPageClearCustomHeaders(toAPI(impl->pageProxy.get()));
2921 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2926 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
2927 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
2929 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2930 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2932 #if ENABLE(TIZEN_DRAG_SUPPORT)
2933 if (impl->pageClient->isDragMode())
2934 impl->pageClient->setDragMode(false);
2937 impl->pageClient->setIsVisible(enable);
2942 #if ENABLE(TIZEN_BACKGROUND_DISK_CACHE)
2943 Eina_Bool ewk_view_foreground_set(Evas_Object* ewkView, Eina_Bool enable)
2949 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
2951 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
2953 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2954 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2957 rect.origin.x = viewArea.x;
2958 rect.origin.y = viewArea.y;
2959 rect.size.width = viewArea.w;
2960 rect.size.height = viewArea.h;
2962 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(impl->pageProxy.get()), rect, scaleFactor));
2963 if (!snapshot.get())
2966 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
2968 Evas_Object* screenshotImage = evas_object_image_add(canvas);
2969 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
2970 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
2971 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
2972 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
2974 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
2976 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)));
2977 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
2979 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
2980 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
2981 cairo_fill(cairo.get());
2983 evas_object_image_smooth_scale_set(screenshotImage, true);
2984 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
2985 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
2986 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
2987 evas_object_image_data_set(screenshotImage, pixels);
2989 return screenshotImage;
2992 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
2994 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
2995 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
2996 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, 0);
2998 return impl->pageProxy->startInspectorServer(port);
3000 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
3005 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
3007 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
3008 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
3009 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
3011 return impl->pageProxy->stopInspectorServer();
3013 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
3018 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
3020 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3021 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3023 WKPageScrollBy(toAPI(impl->pageProxy.get()), toAPI(IntSize(deltaX, deltaY)));
3026 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
3032 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3033 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3035 IntPoint scrollPosition = impl->pageClient->scrollPosition();
3037 *x = scrollPosition.x();
3039 *y = scrollPosition.y();
3044 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
3046 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3047 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3049 impl->pageProxy->scrollMainFrameTo(IntPoint(x, y));
3053 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
3059 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3060 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3062 IntSize contentsSize = impl->pageProxy->contentsSize();
3063 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3064 contentsSize.scale(impl->pageClient->scaleFactor());
3067 if (width && contentsSize.width() > smartData->view.w)
3068 *width = contentsSize.width() - smartData->view.w;
3069 if (height && contentsSize.height() > smartData->view.h)
3070 *height = contentsSize.height() - smartData->view.h;
3074 #if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
3075 void ewkViewNotifyPopupReplyWaitingState(Evas_Object* ewkView, bool isWaiting)
3078 evas_object_smart_callback_call(ewkView, "popup,reply,wait,start", 0);
3080 evas_object_smart_callback_call(ewkView, "popup,reply,wait,finish", 0);
3084 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
3086 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3087 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3088 if (!impl->alertContext || !impl->alertContext->javascriptAlertCallback)
3090 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->alertContext->ewkView == ewkView, false);
3092 impl->isWaitingForJavaScriptPopupReply = true;
3093 int length = WKStringGetMaximumUTF8CStringSize(alertText);
3094 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
3095 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
3096 return impl->alertContext->javascriptAlertCallback(impl->alertContext->ewkView, alertTextBuffer.get(), impl->alertContext->userData) == EINA_TRUE;
3099 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
3101 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3102 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3103 if (!impl->confirmContext || !impl->confirmContext->javascriptConfirmCallback)
3105 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->confirmContext->ewkView == ewkView, false);
3107 impl->isWaitingForJavaScriptPopupReply = true;
3108 int length = WKStringGetMaximumUTF8CStringSize(message);
3109 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3110 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3111 return impl->confirmContext->javascriptConfirmCallback(impl->confirmContext->ewkView, messageBuffer.get(), impl->confirmContext->userData) == EINA_TRUE;
3114 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
3116 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3117 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3118 if (!impl->promptContext || !impl->promptContext->javascriptPromptCallback)
3120 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->promptContext->ewkView == ewkView, false);
3122 impl->isWaitingForJavaScriptPopupReply = true;
3123 int length = WKStringGetMaximumUTF8CStringSize(message);
3124 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3125 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3126 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
3127 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
3128 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
3129 return impl->promptContext->javascriptPromptCallback(impl->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), impl->promptContext->userData) == EINA_TRUE;
3132 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3133 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
3135 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3136 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3137 if (!impl->beforeUnloadConfirmPanelContext || !impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
3139 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
3141 impl->isWaitingForJavaScriptPopupReply = true;
3142 int length = WKStringGetMaximumUTF8CStringSize(message);
3143 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3144 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3145 bool result = impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(impl->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), impl->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
3150 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
3152 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3153 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3154 if (!impl->openpanelContext || !impl->openpanelContext->openPanelCallback)
3157 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->openpanelContext->ewkView == ewkView, false);
3159 impl->openPanelListener = listener;
3161 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
3162 Eina_List* acceptedMimeTypes = 0;
3163 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
3164 size_t len = WKArrayGetSize(array.get());
3165 for (size_t i = 0; i < len; i++) {
3166 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
3167 if (WKGetTypeID(item) != WKStringGetTypeID())
3169 WKStringRef mime = static_cast<WKStringRef>(item);
3170 int length = WKStringGetMaximumUTF8CStringSize(mime);
3171 char* buffer = new char[length];
3172 WKStringGetUTF8CString(mime, buffer, length);
3173 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
3175 const char* capture = 0;
3176 #if ENABLE(MEDIA_CAPTURE)
3177 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
3178 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
3180 bool result = impl->openpanelContext->openPanelCallback(impl->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
3181 if (!acceptedMimeTypes)
3186 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
3187 delete[] (char*)data;
3188 eina_list_free(acceptedMimeTypes);
3192 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
3194 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3195 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3197 if (!impl->alertContext)
3198 impl->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3199 impl->alertContext->javascriptAlertCallback = callback;
3200 impl->alertContext->ewkView = ewkView;
3201 impl->alertContext->userData = userData;
3204 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
3206 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3207 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3209 WKPageReplyJavaScriptAlert(toAPI(impl->page()));
3210 impl->isWaitingForJavaScriptPopupReply = false;
3213 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
3215 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3216 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3218 if (!impl->confirmContext)
3219 impl->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3220 impl->confirmContext->javascriptConfirmCallback = callback;
3221 impl->confirmContext->ewkView = ewkView;
3222 impl->confirmContext->userData = userData;
3225 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
3227 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3228 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3230 WKPageReplyJavaScriptConfirm(toAPI(impl->page()), result == EINA_TRUE);
3231 impl->isWaitingForJavaScriptPopupReply = false;
3234 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
3236 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3237 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3239 if (!impl->promptContext)
3240 impl->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3241 impl->promptContext->javascriptPromptCallback = callback;
3242 impl->promptContext->ewkView = ewkView;
3243 impl->promptContext->userData = userData;
3246 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
3248 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3249 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3251 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
3252 WKPageReplyJavaScriptPrompt(toAPI(impl->page()), result ? resultString.get() : 0);
3253 impl->isWaitingForJavaScriptPopupReply = false;
3256 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3257 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
3259 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3260 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3262 if (!impl->beforeUnloadConfirmPanelContext)
3263 impl->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3264 impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
3265 impl->beforeUnloadConfirmPanelContext->ewkView = ewkView;
3266 impl->beforeUnloadConfirmPanelContext->userData = userData;
3269 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
3271 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3272 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3274 WKPageReplyBeforeUnloadConfirmPanel(toAPI(impl->page()), result == EINA_TRUE);
3275 impl->isWaitingForJavaScriptPopupReply = false;
3279 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
3281 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3282 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3284 if (!impl->openpanelContext)
3285 impl->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3287 impl->openpanelContext->openPanelCallback = callback;
3288 impl->openpanelContext->ewkView = ewkView;
3289 impl->openpanelContext->userData = userData;
3292 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
3294 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3295 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3297 if (!impl->openPanelListener)
3300 unsigned int size = eina_list_count(fileUrls);
3301 if ((result == EINA_FALSE) || (size == 0)) {
3302 WKOpenPanelResultListenerCancel(impl->openPanelListener);
3303 impl->openPanelListener = 0;
3307 WKTypeRef* items = new WKTypeRef[size];
3311 KURL base(KURL(), "file://");
3312 EINA_LIST_FOREACH(fileUrls, list, data) {
3313 KURL url(base, String::fromUTF8(static_cast<char*>(data)));
3314 items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
3316 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
3317 WKOpenPanelResultListenerChooseFiles(impl->openPanelListener, filesArray.get());
3318 impl->openPanelListener = 0;
3320 eina_list_free(fileUrls);
3323 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3324 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
3326 EINA_SAFETY_ON_NULL_RETURN(capable);
3327 EINA_SAFETY_ON_NULL_RETURN(context);
3329 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3331 ASSERT(webAppContext->webAppCapableCallback);
3333 TIZEN_LOGI("webAppCapableCallback exist. capable(%b)", capable);
3335 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
3337 webAppContext->webAppCapableCallback(0, webAppContext->userData);
3339 delete webAppContext;
3342 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
3344 EINA_SAFETY_ON_NULL_RETURN(iconURL);
3345 EINA_SAFETY_ON_NULL_RETURN(context);
3347 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3349 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3350 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3352 ASSERT(webAppContext->webAppIconURLCallback);
3355 impl->webAppIconURL = toImpl(iconURL)->string().utf8().data();
3356 webAppContext->webAppIconURLCallback(impl->webAppIconURL, webAppContext->userData);
3358 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
3360 delete webAppContext;
3363 static void didGetWebAppIconURLs(WKDictionaryRef iconURLs, WKErrorRef, void* context)
3365 EINA_SAFETY_ON_NULL_RETURN(iconURLs);
3366 EINA_SAFETY_ON_NULL_RETURN(context);
3368 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3370 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3371 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3373 ASSERT(webAppContext->webAppIconURLsCallback);
3375 if (impl->webAppIconURLs) {
3377 EINA_LIST_FREE(impl->webAppIconURLs, data)
3378 ewkWebAppIconDataDelete(static_cast<Ewk_Web_App_Icon_Data*>(data));
3381 WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(iconURLs));
3382 size_t iconURLCount = WKArrayGetSize(wkKeys.get());
3383 for (size_t i = 0; i < iconURLCount; i++) {
3384 WKStringRef urlRef = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
3385 WKStringRef sizeRef = static_cast<WKStringRef>(WKDictionaryGetItemForKey(iconURLs, urlRef));
3386 impl->webAppIconURLs = eina_list_append(impl->webAppIconURLs, ewkWebAppIconDataCreate(sizeRef, urlRef));
3388 TIZEN_LOGI("webAppIconURLsCallback exist. found %d icon urls", iconURLCount);
3390 webAppContext->webAppIconURLsCallback(impl->webAppIconURLs, webAppContext->userData);
3391 delete webAppContext;
3395 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
3397 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3398 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3399 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3400 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3402 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3403 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3404 context->webAppCapableCallback = callback;
3405 context->ewkView = ewkView;
3406 context->userData = userData;
3408 WKPageGetWebAppCapable(toAPI(impl->pageProxy.get()), context, didGetWebAppCapable);
3416 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
3418 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3419 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3420 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3421 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3423 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3424 context->webAppIconURLCallback = callback;
3425 context->ewkView = ewkView;
3426 context->userData = userData;
3428 WKPageGetWebAppIconURL(toAPI(impl->page()), context, didGetWebAppIconURL);
3436 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
3438 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3439 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3440 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3441 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3443 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3444 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3445 context->webAppIconURLsCallback = callback;
3446 context->ewkView = ewkView;
3447 context->userData = userData;
3449 WKPageGetWebAppIconURLs(toAPI(impl->page()), context, didGetWebAppIconURLs);
3453 UNUSED_PARAM(ewkView);
3454 UNUSED_PARAM(callback);
3455 UNUSED_PARAM(userData);
3460 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
3462 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3463 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3464 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
3466 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
3467 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
3468 WKPageExecuteCommandWithArgument(toAPI(impl->pageProxy.get()), commandString.get(), valueString.get());
3473 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
3480 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3481 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3483 IntSize contentsSize = impl->pageProxy->contentsSize();
3486 *width = contentsSize.width();
3488 *height = contentsSize.height();
3493 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
3495 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3496 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3497 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3498 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3500 IntSize contentsSize = impl->pageProxy->contentsSize();
3501 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3509 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, int width, int height, const char* fileName)
3511 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3512 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3513 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3514 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3516 IntSize contentsSize = impl->pageProxy->contentsSize();
3517 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3525 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
3527 EINA_SAFETY_ON_NULL_RETURN(context);
3528 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3530 if (!callbackContext->scriptExecuteCallback) {
3531 delete callbackContext;
3535 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
3538 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
3539 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
3540 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
3541 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3542 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
3543 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3545 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
3547 delete callbackContext;
3550 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
3552 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3553 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3554 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
3555 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3557 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3558 context->scriptExecuteCallback = callback;
3559 context->ewkView = ewkView;
3560 context->userData = user_data;
3561 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
3562 WKPageRunJavaScriptInMainFrame(toAPI(impl->pageProxy.get()), scriptString.get(), context, runJavaScriptCallback);
3567 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3568 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
3570 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
3573 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
3575 storageContext->webStorageQuotaCallback(0, storageContext->userData);
3577 delete storageContext;
3581 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
3583 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3584 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3585 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
3586 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3587 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3588 TIZEN_LOGI("resultCallback (%p)", resultCallback);
3590 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3591 context->webStorageQuotaCallback = resultCallback;
3592 context->userData = userData;
3594 WKPageRef pageRef = toAPI(impl->page());
3595 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
3603 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
3605 #if ENABLE(TIZEN_WEB_STORAGE)
3606 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3607 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3608 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3610 TIZEN_LOGI("quota (%d)", quota);
3611 WKPageRef pageRef = toAPI(impl->page());
3612 WKPageSetWebStorageQuota(pageRef, quota);
3620 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
3622 EINA_SAFETY_ON_NULL_RETURN(context);
3623 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3625 ASSERT(callbackContext->plainTextGetCallback);
3628 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
3629 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3630 WKStringGetUTF8CString(plain_text, buffer.get(), length);
3632 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3634 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
3636 delete callbackContext;
3639 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
3641 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3642 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3643 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3644 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3646 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3647 context->plainTextGetCallback = callback;
3648 context->ewkView = ewkView;
3649 context->userData = user_data;
3650 WKPageGetContentsAsString(toAPI(impl->pageProxy.get()), context, getContentsAsStringCallback);
3655 #if ENABLE(TIZEN_SUPPORT_MHTML)
3658 * Callback function used for ewk_view_mhtml_data_get().
3660 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
3662 EINA_SAFETY_ON_NULL_RETURN(context);
3663 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3665 ASSERT(callbackContext->mhtmlDataGetCallback);
3667 callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
3669 delete callbackContext;
3672 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
3674 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3675 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3676 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3678 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3679 context->mhtmlDataGetCallback = callback;
3680 context->ewkView = ewkView;
3681 context->userData = user_data;
3683 WKPageGetContentsAsMHTMLData(toAPI(impl->page()), false, context, getContentsAsMHTMLCallback);
3687 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
3689 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
3691 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
3692 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3693 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3695 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
3696 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest, hitTestMode);
3697 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
3705 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
3707 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3708 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3709 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3710 WebPageProxy* page = impl->page();
3711 EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
3713 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
3716 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3721 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
3723 #if ENABLE(TIZEN_NOTIFICATIONS)
3724 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3725 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3726 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context, false);
3728 TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
3729 if (!eina_list_count(ewkNotifications))
3732 Eina_List* listIterator = 0;
3734 Vector<WKTypeRef> ids;
3735 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
3736 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
3737 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
3739 impl->notifications = eina_list_remove(impl->notifications, notification);
3742 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
3743 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(impl->context->wkContext());
3744 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
3745 ewkNotificationDeleteNotificationList(ewkNotifications);
3753 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3754 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
3756 Eina_List* popupItems = 0;
3757 size_t size = items.size();
3758 for (size_t i = 0; i < size; ++i)
3759 popupItems = eina_list_append(popupItems, Ewk_Popup_Menu_Item::create(items[i]).leakPtr());
3760 TIZEN_LOGI("size : %d", size);
3764 static void releasePopupMenuList(Eina_List* popupMenuItems)
3766 if (!popupMenuItems)
3770 EINA_LIST_FREE(popupMenuItems, item)
3771 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3775 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
3777 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3778 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3779 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
3781 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3784 if (!impl->popupMenuProxy)
3787 impl->popupMenuProxy = 0;
3789 if (smartData->api->popup_menu_hide)
3790 smartData->api->popup_menu_hide(smartData);
3791 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3792 ewk_view_touch_events_enabled_set(ewkView, true);
3794 releasePopupMenuList(impl->popupMenuItems);
3795 impl->popupMenuItems = 0;
3798 EINA_LIST_FREE(impl->popupMenuItems, item)
3799 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3805 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
3807 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3808 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3809 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3811 TIZEN_LOGI("proxy : %p / index : %d", impl->popupMenuProxy, selectedIndex);
3813 if (!impl->popupMenuItems)
3817 if (selectedIndex >= eina_list_count(impl->popupMenuItems))
3820 impl->popupMenuProxy->valueChanged(selectedIndex);
3825 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3826 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
3828 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3829 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3830 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3831 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3833 if (!impl->popupMenuProxy)
3836 if (!smartData->api->popup_menu_update)
3839 releasePopupMenuList(impl->popupMenuItems);
3840 impl->popupMenuItems = createPopupMenuList(items);
3842 // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
3843 smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), impl->popupMenuItems, selectedIndex);
3847 #if ENABLE(TIZEN_MULTIPLE_SELECT)
3848 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
3850 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3851 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3852 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3854 Vector<int> selectedIndex;
3856 if (!impl->popupMenuItems)
3861 itr = eina_inarray_iterator_new(changeList);
3862 EINA_ITERATOR_FOREACH(itr, data)
3864 int* pData = static_cast<int*>(data);
3865 selectedIndex.append(*pData);
3867 eina_iterator_free(itr);
3869 impl->popupMenuProxy->multipleValueChanged(selectedIndex);
3874 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
3876 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
3877 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3878 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3879 TIZEN_LOGI("orientation : %d", orientation);
3881 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
3884 if (impl->orientation == orientation)
3887 impl->orientation = orientation;
3889 impl->pageProxy->sendOrientationChangeEvent(orientation);
3893 void ewkViewFrameRendered(Evas_Object* ewkView)
3895 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
3898 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3899 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3901 return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
3904 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
3906 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3907 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3909 IntRect leftSelectionRect;
3910 IntRect rightSelectionRect;
3911 if (!impl->pageProxy->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
3924 AffineTransform contentToScreen = impl->transformToScene();
3925 leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
3926 rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
3928 leftRect->x = leftSelectionRect.x();
3929 leftRect->y = leftSelectionRect.y();
3930 leftRect->w = leftSelectionRect.width();
3931 leftRect->h = leftSelectionRect.height();
3933 rightRect->x = rightSelectionRect.x();
3934 rightRect->y = rightSelectionRect.y();
3935 rightRect->w = rightSelectionRect.width();
3936 rightRect->h = rightSelectionRect.height();
3941 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
3943 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3944 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3946 const CString selectedString = impl->pageProxy->getSelectionText().utf8();
3947 impl->selectedText = selectedString.data();
3949 return impl->selectedText;
3952 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
3954 return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
3957 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
3959 return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
3962 void ewk_view_text_selection_range_clear(Evas_Object* ewkView)
3964 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3965 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3967 impl->pageProxy->selectionRangeClear();
3969 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3971 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
3972 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
3974 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3975 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3976 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
3978 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
3982 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
3983 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
3985 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3986 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3987 IntPoint drawingPosition = (IntPoint)(impl->pageClient->visibleContentRect().location() - impl->pageClient->scrollPosition());
3989 *x = drawingPosition.x();
3991 *y = drawingPosition.y();
3993 *w = impl->pageClient->visibleContentRect().width();
3995 *h = impl->pageClient->visibleContentRect().height();
3999 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
4001 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4002 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4003 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4005 impl->pageProxy->setFocusedInputElementValue(String::fromUTF8(value));
4006 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4009 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
4011 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4012 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4013 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
4015 impl->inputValue = impl->pageProxy->getFocusedInputElementValue().utf8().data();
4016 return impl->inputValue;
4019 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4022 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4023 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
4025 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4026 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4027 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4028 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
4031 ewkViewDataListHideRequest(ewkView, inputType);
4033 for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
4035 impl->dataList = eina_list_append(impl->dataList, eina_stringshare_add(value.utf8().data()));
4038 smartData->api->data_list_show(smartData, inputType, impl->dataList);
4041 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
4043 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4044 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4045 EINA_SAFETY_ON_NULL_RETURN(impl->dataList);
4046 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4047 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
4049 impl->deleteDataList();
4051 smartData->api->data_list_hide(smartData, inputType);
4055 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
4057 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4058 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4059 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4061 impl->deleteDataList();
4063 ewk_view_focused_input_element_value_set(ewkView, value);
4067 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
4069 #if ENABLE(TIZEN_GESTURE)
4070 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4071 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4072 return impl->holdHorizontalPanning;
4078 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4080 #if ENABLE(TIZEN_GESTURE)
4081 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4082 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4083 impl->holdHorizontalPanning = hold;
4087 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
4089 #if ENABLE(TIZEN_GESTURE)
4090 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4091 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4092 return impl->holdVerticalPanning;
4098 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4100 #if ENABLE(TIZEN_GESTURE)
4101 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4102 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4103 impl->holdVerticalPanning = hold;
4107 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
4109 #if ENABLE(TIZEN_GESTURE)
4110 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4111 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4113 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4114 if (impl->focusRing && wasHandled)
4115 impl->focusRing->hide();
4116 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4118 if (impl->mouseEventsEnabled())
4121 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4122 if (wasHandled && impl->pageClient->isTextSelectionMode()) {
4123 if (type == WebEvent::TouchStart)
4124 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4125 else if (type == WebEvent::TouchMove)
4126 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4127 else if (type == WebEvent::TouchEnd)
4128 impl->pageClient->requestToShowTextSelectionHandlesAndContextMenu();
4132 // We have to check TouchStart, TouchMove and TouchEnd with handled.
4133 // The Pan and Flick will be enabled if Touch Start was not handled,
4134 // and Touch Move was not handled or did not occur.
4135 // Tap will be enabled if Touch Start and End was not handled
4136 // and Touch Move did not occur.
4137 // The gestures are disabled as a default.
4138 // o: handled, x: not handled
4139 // ------------------------------------------------------------
4140 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
4141 // ------------------------------------------------------------
4142 // o | o or x | o or x || disable | disable
4143 // x | o | o or x || disable | disable
4144 // x | x | o or x || disable | enable
4145 // x |not occured | x || enable | enable
4146 // ------------------------------------------------------------
4147 if (type == WebEvent::TouchStart) {
4148 impl->gestureClient->setGestureEnabled(!wasHandled);
4149 impl->wasHandledTouchStart = wasHandled;
4151 // Initialize wasHandledTouchMove to true and notify that to the application
4152 // to prevent applications scrolling at the beginning of touch.
4153 impl->wasHandledTouchMove = true;
4154 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&impl->wasHandledTouchMove));
4155 } else if (type == WebEvent::TouchMove) {
4156 impl->gestureClient->setMovingEnabled(!wasHandled);
4158 // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
4159 if (impl->wasHandledTouchStart)
4162 // Notify the result of touchmove to applications when handled value is changed
4163 // in order to make applications to choose whether scrolling its scrollable objects or not.
4164 if (impl->wasHandledTouchMove != wasHandled)
4165 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
4166 impl->wasHandledTouchMove = wasHandled;
4167 } else if (type == WebEvent::TouchEnd && !impl->exceedTouchMoveThreshold) {
4169 impl->gestureClient->setMovingEnabled(!wasHandled);
4170 impl->gestureClient->setTapEnabled(!wasHandled);
4172 #if ENABLE(TIZEN_ISF_PORT)
4173 else if (impl->pageProxy->isViewVisible()) {
4174 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(impl->touchDownPoint.x, impl->touchDownPoint.y));
4175 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest);
4176 if (hitTestResultData.isContentEditable && impl->inputMethodContext()) {
4177 evas_object_focus_set(ewkView, true);
4178 impl->inputMethodContext()->updateTextInputState();
4186 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
4187 void ewkViewTextStyleState(Evas_Object* ewkView, const IntPoint& startPoint, const IntPoint& endPoint)
4189 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4190 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4192 EditorState editorState = impl->page()->editorState();
4193 Ewk_Text_Style* textStyle = ewkTextStyleCreate(editorState, startPoint, endPoint);
4194 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
4195 ewkTextStyleDelete(textStyle);
4199 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
4200 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
4202 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4203 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4205 TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
4206 if (!smartData->api->orientation_lock) {
4211 return smartData->api->orientation_lock(smartData, willLockOrientation);
4214 void ewk_view_orientation_unlock(Evas_Object* ewkView)
4216 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4217 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4219 TIZEN_LOGI("ewkView (%p)", ewkView);
4220 if (!smartData->api->orientation_unlock) {
4225 smartData->api->orientation_unlock(smartData);
4229 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
4231 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4232 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4233 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4234 TIZEN_LOGI("callbacks: %p / data: %p", func, data);
4236 impl->orientationLock.callback = func;
4237 impl->orientationLock.data = data;
4241 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4242 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
4244 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
4245 TIZEN_LOGI("locked orientations : %d", orientations);
4247 if (impl->orientationLock.callback)
4248 return impl->orientationLock.callback(sd->self, true, orientations, impl->orientationLock.data);
4253 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
4255 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4256 TIZEN_LOGI("unlock is requested");
4258 if (impl->orientationLock.callback)
4259 impl->orientationLock.callback(sd->self, false, 0, impl->orientationLock.data);
4263 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
4264 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
4266 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4268 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
4269 const char *engine = ecore_evas_engine_name_get(ee);
4270 if (engine && !strcmp(engine, "opengl_x11"))
4276 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
4278 #if ENABLE(TIZEN_GESTURE)
4279 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4280 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4282 impl->gestureClient->setZoomableArea(target, area);
4286 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
4287 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
4289 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4290 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4292 WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(impl->pageProxy.get())));
4296 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
4297 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
4299 evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
4303 #if ENABLE(TIZEN_ICON_DATABASE)
4304 void ewkViewIconReceived(Evas_Object* ewkView)
4308 evas_object_smart_callback_call(ewkView, "icon,received", 0);
4312 #endif // #if OS(TIZEN)
4314 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
4316 #if ENABLE(TOUCH_EVENTS)
4317 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
4318 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4319 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4321 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
4322 if (impl->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
4323 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4324 IntPoint handlePoint(point->x, point->y);
4326 if (type == EWK_TOUCH_START)
4327 impl->pageClient->textSelectonHandleDown(handlePoint);
4328 else if (type == EWK_TOUCH_MOVE)
4329 impl->pageClient->textSelectonHandleMove(handlePoint);
4331 impl->pageClient->textSelectonHandleUp();
4333 if (impl->pageClient->isTextSelectionHandleDowned())
4338 #if ENABLE(TIZEN_GESTURE)
4339 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
4340 // We don't want to process touch event when context menu is shown.
4341 if ((impl->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
4342 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4343 && !impl->pageClient->isTextSelectionMode()
4348 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4349 if (impl->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
4353 if (type == EWK_TOUCH_START) {
4354 if (eina_list_count(points) == 1) {
4355 impl->gestureClient->reset();
4356 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4357 impl->touchDownPoint.x = point->x;
4358 impl->touchDownPoint.y = point->y;
4359 impl->exceedTouchMoveThreshold = false;
4361 } else if (type == EWK_TOUCH_MOVE && !impl->exceedTouchMoveThreshold) {
4362 if (eina_list_count(points) == 1) {
4363 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
4364 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4365 int diffX = impl->touchDownPoint.x - point->x;
4366 int diffY = impl->touchDownPoint.y - point->y;
4367 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
4368 impl->exceedTouchMoveThreshold = true;
4372 impl->exceedTouchMoveThreshold = true;
4375 #endif // #if ENABLE(TIZEN_GESTURE)
4377 // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
4378 //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4379 impl->pageProxy->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4387 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
4389 #if ENABLE(TOUCH_EVENTS)
4390 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4391 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4393 impl->setTouchEventsEnabled(!!enabled);
4401 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
4403 #if ENABLE(TOUCH_EVENTS)
4404 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4405 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4407 return impl->touchEventsEnabled();
4413 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
4415 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4416 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4417 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4419 impl->mainFrameScrollbarVisibility = visible;
4420 impl->pageClient->updateVisibility();
4428 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
4430 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4431 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4432 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4434 return impl->mainFrameScrollbarVisibility;
4440 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
4442 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
4443 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4444 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4445 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
4447 String title = ewk_view_title_get(ewkView);
4448 String url = ewk_view_url_get(ewkView);
4449 String directoryPath(path);
4450 impl->pageClient->startOfflinePageSave(directoryPath, url, title);
4454 UNUSED_PARAM(ewkView);
4462 * Callback function used for ewk_view_page_contents_get().
4464 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4466 EINA_SAFETY_ON_NULL_RETURN(context);
4468 RefPtr<WebData> webData = toImpl(wkData);
4469 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4470 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
4475 * Callback function used for ewk_view_page_contents_get().
4477 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
4479 EINA_SAFETY_ON_NULL_RETURN(context);
4481 RefPtr<WebString> webString = toImpl(wkString);
4482 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4483 contentsContext->callback(contentsContext->type, webString->string().utf8().data());
4486 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
4488 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
4489 EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
4490 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4491 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4493 switch (context->type) {
4494 case EWK_PAGE_CONTENTS_TYPE_MHTML:
4495 impl->pageProxy->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
4498 case EWK_PAGE_CONTENTS_TYPE_STRING:
4499 impl->pageProxy->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
4503 ASSERT_NOT_REACHED();
4510 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
4512 #if ENABLE(TIZEN_GESTURE)
4513 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4514 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4516 return impl->gestureClient->scrollToWithAnimation(x, y);
4518 UNUSED_PARAM(ewkView);
4525 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4526 void ewkViewFocusRingHide(Evas_Object* ewkView)
4528 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4529 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4531 if (impl->focusRing)
4532 impl->focusRing->hide();
4536 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
4538 #if ENABLE(TIZEN_CSP)
4539 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
4540 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4542 TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
4543 impl->pageProxy->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));
4547 #if ENABLE(TIZEN_APPLICATION_CACHE)
4548 Eina_Bool ewkViewRequestApplicationCachePermission(Evas_Object* ewkView, WKSecurityOriginRef origin)
4550 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4551 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4553 if (!impl->applicationCachePermissionContext || !impl->applicationCachePermissionContext->applicationCachePermissionCallback)
4556 impl->isWaitingForApplicationCachePermission = true;
4557 if (impl->applicationCachePermissionOrigin)
4558 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4559 impl->applicationCachePermissionOrigin = createSecurityOrigin(origin);
4561 return impl->applicationCachePermissionContext->applicationCachePermissionCallback(ewkView, impl->applicationCachePermissionOrigin, impl->applicationCachePermissionContext->userData) == EINA_TRUE;
4565 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
4567 #if ENABLE(TIZEN_APPLICATION_CACHE)
4568 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4569 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4571 if (!impl->applicationCachePermissionContext)
4572 impl->applicationCachePermissionContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4573 impl->applicationCachePermissionContext->applicationCachePermissionCallback = callback;
4574 impl->applicationCachePermissionContext->userData = userData;
4576 UNUSED_PARAM(ewkView);
4577 UNUSED_PARAM(callback);
4578 UNUSED_PARAM(userData);
4582 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
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 TIZEN_LOGI("allow %d", allow);
4589 WKPageReplyApplicationCachePermission(toAPI(impl->page()), allow);
4590 if (impl->applicationCachePermissionOrigin)
4591 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4592 impl->applicationCachePermissionOrigin = 0;
4593 impl->isWaitingForApplicationCachePermission = false;
4595 UNUSED_PARAM(ewkView);
4596 UNUSED_PARAM(allow);
4600 #if ENABLE(TIZEN_INDEXED_DATABASE)
4601 bool ewkViewExceededIndexedDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4603 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4604 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4606 if (!impl->exceededIndexedDatabaseQuotaContext || !impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback)
4609 impl->isWaitingForExceededQuotaPopupReply = true;
4610 if (impl->exceededQuotaOrigin)
4611 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4612 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4614 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4616 return impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, currentUsage, impl->exceededIndexedDatabaseQuotaContext->userData) == EINA_TRUE;
4620 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4622 #if ENABLE(TIZEN_INDEXED_DATABASE)
4623 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4624 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4626 if (!impl->exceededIndexedDatabaseQuotaContext)
4627 impl->exceededIndexedDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4628 impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback = callback;
4629 impl->exceededIndexedDatabaseQuotaContext->userData = userData;
4631 UNUSED_PARAM(ewkView);
4632 UNUSED_PARAM(callback);
4633 UNUSED_PARAM(userData);
4637 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
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 TIZEN_LOGI("allow %d", allow);
4644 WKPageReplyExceededIndexedDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4645 if (impl->exceededQuotaOrigin)
4646 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4647 impl->exceededQuotaOrigin = 0;
4648 impl->isWaitingForExceededQuotaPopupReply = false;
4650 UNUSED_PARAM(ewkView);
4651 UNUSED_PARAM(allow);
4655 // EwkFindOptions should be matched up orders with WkFindOptions.
4656 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_CASE_INSENSITIVE, kWKFindOptionsCaseInsensitive);
4657 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_AT_WORD_STARTS, kWKFindOptionsAtWordStarts);
4658 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, kWKFindOptionsTreatMedialCapitalAsWordStart);
4659 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_BACKWARDS, kWKFindOptionsBackwards);
4660 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_WRAP_AROUND, kWKFindOptionsWrapAround);
4661 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_OVERLAY, kWKFindOptionsShowOverlay);
4662 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR, kWKFindOptionsShowFindIndicator);
4663 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShowHighlight);
4665 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4667 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4668 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4669 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4671 impl->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4676 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4678 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4679 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4681 impl->pageProxy->hideFindUI();
4686 Eina_Bool ewk_view_text_matches_count(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4688 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4689 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4690 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4692 impl->pageProxy->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4697 void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData)
4699 #if ENABLE(TIZEN_SQL_DATABASE)
4700 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4701 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4703 if (!impl->exceededDatabaseQuotaContext)
4704 impl->exceededDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4705 impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback = callback;
4706 impl->exceededDatabaseQuotaContext->userData = userData;
4708 UNUSED_PARAM(ewkView);
4709 UNUSED_PARAM(callback);
4710 UNUSED_PARAM(userData);
4714 void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
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 TIZEN_LOGI("allow %d", allow);
4721 WKPageReplyExceededDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4722 if (impl->exceededQuotaOrigin)
4723 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4724 impl->exceededQuotaOrigin = 0;
4725 impl->isWaitingForExceededQuotaPopupReply = false;
4727 UNUSED_PARAM(ewkView);
4728 UNUSED_PARAM(allow);
4732 #if ENABLE(TIZEN_FILE_SYSTEM)
4733 bool ewkViewExceededLocalFileSystemQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4735 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4736 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4738 if (!impl->exceededLocalFileSystemQuotaContext || !impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback)
4741 impl->isWaitingForExceededQuotaPopupReply = true;
4742 if (impl->exceededQuotaOrigin)
4743 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4744 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4746 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4748 return impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback(ewkView, impl->exceededQuotaOrigin , currentUsage, impl->exceededLocalFileSystemQuotaContext->userData) == EINA_TRUE;
4752 void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4754 #if ENABLE(TIZEN_FILE_SYSTEM)
4755 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4756 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4758 if (!impl->exceededLocalFileSystemQuotaContext)
4759 impl->exceededLocalFileSystemQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4760 impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback = callback;
4761 impl->exceededLocalFileSystemQuotaContext->userData = userData;
4763 UNUSED_PARAM(ewkView);
4764 UNUSED_PARAM(callback);
4765 UNUSED_PARAM(userData);
4769 void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
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 TIZEN_LOGI("allow %d", allow);
4776 WKPageReplyExceededLocalFileSystemQuota(toAPI(impl->page()), allow == EINA_TRUE);
4777 if (impl->exceededQuotaOrigin)
4778 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4779 impl->exceededQuotaOrigin = 0;
4780 impl->isWaitingForExceededQuotaPopupReply = false;
4782 UNUSED_PARAM(ewkView);
4783 UNUSED_PARAM(result);
4787 void ewk_view_rotation_prepare(Evas_Object* ewkView, int angle)
4789 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4790 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4791 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4794 if (angle == 0 || angle == 180) {
4795 width = WebCore::getDefaultScreenResolution().width();
4796 height = WebCore::getDefaultScreenResolution().height() + 100;
4798 if (angle == 90 || angle == 270) {
4799 width = WebCore::getDefaultScreenResolution().height();
4800 height = WebCore::getDefaultScreenResolution().width() + 100;
4803 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
4804 impl->pageClient->setWaitFrameOfNewViewortSize(true);
4805 ewk_view_suspend(ewkView);
4806 impl->pageClient->updateViewportSize(IntSize(width, height), angle);
4810 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4811 void ewkViewRotatePrepared(Evas_Object* ewkView)
4813 evas_object_smart_callback_call(ewkView, "rotate,prepared", 0);
4817 void ewk_view_use_settings_font(Evas_Object* ewkView)
4819 #if ENABLE(TIZEN_USE_SETTINGS_FONT)
4820 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4821 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4823 impl->pageProxy->useSettingsFont();