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_geolocation_provider_private.h"
112 #include "ewk_security_origin.h"
115 #if ENABLE(TOUCH_EVENTS)
116 #include "NativeWebTouchEvent.h"
117 #include "WebEvent.h"
120 #if ENABLE(TIZEN_ISF_PORT)
121 #include <Ecore_IMF.h>
124 #if ENABLE(TIZEN_NOTIFICATIONS)
126 #include "WKNotificationManager.h"
127 #include "WKNumber.h"
128 #include "ewk_notification_private.h"
129 #include "ewk_view_notification_provider.h"
132 #if ENABLE(TIZEN_MEDIA_STREAM)
133 #include "WKUserMediaPermissionRequest.h"
134 #include "ewk_user_media_private.h"
137 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
138 #include "WebPageGroup.h"
139 #include "WebPreferences.h"
142 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
143 #include "ewk_hit_test_private.h"
146 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
147 #include "ewk_text_style.h"
150 #if ENABLE(TIZEN_SCREEN_READER)
151 #include "ScreenReaderProxy.h"
154 #if ENABLE(TIZEN_CSP)
155 #include <WebCore/ContentSecurityPolicy.h>
158 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
159 #include "WKDictionary.h"
160 #include "ewk_web_application_icon_data_private.h"
163 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
164 #include "AutoFillPopup.h"
166 #endif // #if OS(TIZEN)
168 using namespace WebKit;
169 using namespace WebCore;
171 static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
173 #define EWK_VIEW_TYPE_CHECK(ewkView, result) \
174 bool result = true; \
177 EINA_LOG_CRIT("null is not a ewk_view"); \
181 const char* _tmp_otype = evas_object_type_get(ewkView); \
182 const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
183 if (EINA_UNLIKELY(!_tmp_s)) { \
185 ("%p (%s) is not a smart object!", \
186 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
190 const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
191 if (EINA_UNLIKELY(!_tmp_sc)) { \
193 ("%p (%s) is not a smart object!", \
194 ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
198 else if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \
200 ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
201 ewkView, _tmp_otype ? _tmp_otype : "(null)", \
202 EWK_VIEW_TYPE_STR, _tmp_sc->data); \
207 #define EWK_VIEW_SD_GET(ewkView, smartData) \
208 EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \
209 Ewk_View_Smart_Data* smartData = 0; \
211 smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView)
213 #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \
214 EWK_VIEW_SD_GET(ewkView, smartData); \
217 EINA_LOG_CRIT("no smart data for object %p (%s)", \
218 ewkView, evas_object_type_get(ewkView)); \
219 return __VA_ARGS__; \
224 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object*, const char* alertText, void* userData);
225 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object*, const char* message, void* userData);
226 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object*, const char* message, const char* defaultValue, void* userData);
227 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
228 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object*, const char* message, void* userData);
230 static Eina_Bool _ewk_view_default_open_panel(Evas_Object*, Eina_Bool allow_multiple_files, Eina_List *accepted_mime_types, const char* capture, void* userData);
232 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
233 Eina_Bool _ewk_view_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items, int selectedIndex);
234 #if ENABLE(TIZEN_MULTIPLE_SELECT)
235 Eina_Bool _ewk_view_multiple_popup_menu_show(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, double page_scale_factor, Eina_List* items);
237 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data*);
238 Eina_Bool _ewk_view_popup_menu_update(Ewk_View_Smart_Data*, Eina_Rectangle, Ewk_Text_Direction, Eina_List*, int);
240 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
241 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations);
242 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd);
245 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
246 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data*, Ewk_Input_Type, const char* inputValue);
249 #if ENABLE(TIZEN_DATALIST_ELEMENT)
250 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data*, Ewk_Input_Type, Eina_List*);
251 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data*, Ewk_Input_Type);
254 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
255 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data*, int, int, int, int);
256 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data*);
258 #endif // #if OS(TIZEN)
260 static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
262 if (smartData->changed.any)
264 smartData->changed.any = true;
265 evas_object_smart_changed(smartData->self);
268 #if !ENABLE(TIZEN_ICON_DATABASE)
269 static void _ewk_view_on_favicon_changed(const char* pageURL, void* eventInfo)
271 Evas_Object* ewkView = static_cast<Evas_Object*>(eventInfo);
272 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
273 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
275 const char* viewURL = ewk_view_url_get(ewkView);
276 if (!viewURL || strcasecmp(viewURL, pageURL))
279 impl->informIconChange();
283 #if ENABLE(TIZEN_GEOLOCATION)
284 static Eina_Bool _ewk_view_geolocation_validity_check(void* eventInfo)
286 Evas_Object* ewkView = static_cast<Evas_Object*>(eventInfo);
287 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, true);
288 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, true);
290 return impl->isValidLocationService();
294 // Default Event Handling.
295 static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
297 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
301 impl->pageClient->setViewFocused(true);
302 #endif // #if OS(TIZEN)
303 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
304 #if ENABLE(TIZEN_ISF_PORT)
305 if (impl->inputMethodContext())
306 impl->inputMethodContext()->onFocusIn();
311 static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
313 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
317 #if ENABLE(TIZEN_ISF_PORT)
318 // Keypad should be hidden rapidly when moving focus on elementary
319 // because Ecore-ime doesn't support it.
320 if (impl->inputMethodContext())
321 impl->inputMethodContext()->onFocusOut();
324 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
325 if (impl->pageClient->isTextSelectionMode() && ewk_settings_clear_text_selection_automatically_get(impl->settings()))
326 impl->pageClient->setIsTextSelectionMode(false);
329 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
330 if (impl->pageClient->isContextMenuVisible())
331 impl->pageProxy->hideContextMenu();
334 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
335 if (impl->pageClient->isClipboardWindowOpened())
336 impl->pageClient->closeClipboardWindow();
339 #if ENABLE(TIZEN_DRAG_SUPPORT)
340 if (impl->pageClient->isDragMode())
341 impl->pageClient->setDragMode(false);
344 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
345 if (smartData->api->formdata_candidate_is_showing(smartData))
346 smartData->api->formdata_candidate_hide(smartData);
349 impl->pageClient->setViewFocused(false);
350 #endif // #if OS(TIZEN)
351 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
355 static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
357 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
359 impl->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, impl->transformFromScene(), impl->transformToScreen()));
363 static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
365 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
367 impl->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, impl->transformFromScene(), impl->transformToScreen()));
371 static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
373 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
375 impl->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, impl->transformFromScene(), impl->transformToScreen()));
377 InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
378 if (inputMethodContext)
379 inputMethodContext->handleMouseUpEvent(upEvent);
384 static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
386 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
388 // FIXME: impl->page() is used in the webkit opensource, but tizen webkit does not use it yet.
389 impl->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, impl->transformFromScene(), impl->transformToScreen()));
393 static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
395 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
397 bool isFiltered = false;
398 InputMethodContextEfl* inputMethodContext = impl->inputMethodContext();
399 if (inputMethodContext)
400 inputMethodContext->handleKeyDownEvent(downEvent, &isFiltered);
402 impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, isFiltered));
406 static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
408 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
410 impl->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
415 static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
417 #if ENABLE(TIZEN_GESTURE)
418 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
420 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
421 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
425 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
426 FocusRing* focusRing = impl->focusRing();
428 if (event->type == EWK_GESTURE_TAP) {
429 if (event->count == 1)
430 focusRing->requestToShow(IntPoint(event->position.x, event->position.y));
431 } else if (event->type == EWK_GESTURE_PAN) {
432 if (impl->exceedTouchMoveThreshold)
433 focusRing->requestToHide();
434 } else if (event->type != EWK_GESTURE_LONG_PRESS) {
435 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
436 if (!impl->pageClient->isContextMenuVisible())
438 focusRing->requestToHide();
443 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
444 if (smartData->api->formdata_candidate_is_showing(smartData))
445 smartData->api->formdata_candidate_hide(smartData);
448 switch (event->type) {
449 case EWK_GESTURE_TAP:
450 impl->gestureClient->startTap(IntPoint(event->position.x, event->position.y));
452 case EWK_GESTURE_LONG_PRESS: {
453 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
454 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
455 if (ewk_settings_text_selection_enabled_get(impl->settings()))
456 impl->pageClient->setIsTextSelectionMode(false);
459 IntPoint scenePoint(event->position.x, event->position.y);
460 IntPoint contentsPoint = impl->transformFromScene().mapPoint(scenePoint);
461 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(contentsPoint, WebHitTestResult::HitTestModeDefault | WebHitTestResult::HitTestModeSetFocus);
462 if (!hitTestResultData.absoluteMediaURL.isEmpty())
465 #if ENABLE(TIZEN_DRAG_SUPPORT)
466 // 1. Check to start dragging.
467 if (hitTestResultData.isDragSupport && !hitTestResultData.isContentEditable) {
468 impl->pageClient->setDragPoint(scenePoint);
469 if (impl->pageClient->isDragMode())
470 impl->pageClient->setDragMode(false);
472 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
474 focusRing->showWithContextMenu(scenePoint, hitTestResultData.focusedColor, hitTestResultData.focusedRects);
480 // 2. Check to show context menu.
481 if ((!hitTestResultData.absoluteImageURL.isEmpty() || !hitTestResultData.absoluteLinkURL.isEmpty())
482 && !hitTestResultData.isContentEditable) {
483 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
485 focusRing->showWithContextMenu(scenePoint, hitTestResultData.focusedColor, hitTestResultData.focusedRects);
490 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
491 // 3. Check for text selection.
492 if (ewk_settings_text_selection_enabled_get(impl->settings())) {
493 // Process gesture_end(EWK_GESTURE_TAP) to activate the editing if node under point is editable.
494 if (hitTestResultData.context & WebHitTestResult::HitTestResultContextEditable) {
495 if (smartData->api && smartData->api->gesture_end) {
496 Ewk_Event_Gesture tapEvent = {EWK_GESTURE_TAP, event->position, {0, 0}, 0, 1, ecore_time_get() * 1000};
497 smartData->api->gesture_end(smartData, &tapEvent);
501 if (impl->pageClient->textSelectionDown(scenePoint)) {
502 impl->gestureClient->setGestureEnabled(false);
503 impl->feedTouchEventsByType(EWK_TOUCH_CANCEL);
508 #endif // #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
510 case EWK_GESTURE_PAN:
511 impl->gestureClient->startPan(IntPoint(event->position.x, event->position.y));
513 case EWK_GESTURE_FLICK:
514 impl->gestureClient->startFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
516 case EWK_GESTURE_PINCH:
517 if (impl->pageClient->viewportConstraints().userScalable)
518 impl->gestureClient->startPinch(IntPoint(event->position.x, event->position.y), event->scale);
521 ASSERT_NOT_REACHED();
528 #endif // #if ENABLE(TIZEN_GESTURE)
531 static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
533 #if ENABLE(TIZEN_GESTURE)
534 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
536 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
537 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned()) {
538 impl->pageClient->initTextSelectionHandlesMouseDownedStatus();
543 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
544 FocusRing* focusRing = impl->focusRing();
546 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
547 if (!impl->pageClient->isContextMenuVisible() || impl->pageClient->isTextSelectionMode())
549 focusRing->requestToHide();
553 switch (event->type) {
554 case EWK_GESTURE_TAP:
555 if (event->count == 1) {
556 #if ENABLE(TIZEN_DRAG_SUPPORT)
557 if (impl->pageClient->isDragMode())
558 impl->pageClient->setDragMode(false);
560 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
561 if (impl->pageClient->isTextSelectionMode())
562 impl->pageClient->setIsTextSelectionMode(false);
565 #if ENABLE(TIZEN_ISF_PORT)
566 if (impl->inputMethodContext()->isIMEPostion(event->position.x, event->position.y))
570 impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
571 } else if (event->count == 2) {
572 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
574 focusRing->requestToHide(true);
576 impl->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
579 case EWK_GESTURE_LONG_PRESS:
580 // Prcess endTap for LONG_PRESS gesture if text-selection and context menu did not work
581 impl->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
583 case EWK_GESTURE_PAN:
584 impl->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
586 case EWK_GESTURE_FLICK:
587 impl->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
589 case EWK_GESTURE_PINCH:
590 impl->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
593 ASSERT_NOT_REACHED();
600 #endif // #if ENABLE(TIZEN_GESTURE)
603 static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
605 #if ENABLE(TIZEN_GESTURE)
606 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
608 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
609 if (impl->pageClient->isTextSelectionMode() && impl->pageClient->isTextSelectionHandleDowned())
613 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
614 FocusRing* focusRing = impl->focusRing();
615 if (focusRing && !(event->type == EWK_GESTURE_PAN && !impl->exceedTouchMoveThreshold)) {
616 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
617 if (!impl->pageClient->isContextMenuVisible())
619 focusRing->requestToHide(true);
623 switch (event->type) {
624 case EWK_GESTURE_PAN:
625 impl->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
627 case EWK_GESTURE_TAP:
628 case EWK_GESTURE_LONG_PRESS:
629 case EWK_GESTURE_FLICK:
631 case EWK_GESTURE_PINCH:
632 if (impl->pageClient->viewportConstraints().userScalable)
633 impl->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
636 ASSERT_NOT_REACHED();
643 #endif // #if ENABLE(TIZEN_GESTURE)
645 #endif //#if OS(TIZEN)
648 static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
650 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
651 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
652 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
653 smartData->api->focus_in(smartData);
656 static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
658 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
659 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
660 EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
661 smartData->api->focus_out(smartData);
664 static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
666 Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
667 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
668 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
669 EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
670 smartData->api->mouse_wheel(smartData, wheelEvent);
673 static void _ewk_view_on_key_down(void* data, Evas*, Evas_Object*, void* eventInfo)
675 Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
676 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
677 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
678 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
679 smartData->api->key_down(smartData, downEvent);
682 static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
684 Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
685 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
686 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
687 EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
688 smartData->api->key_up(smartData, upEvent);
691 static void _ewk_view_on_show(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
693 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
694 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
695 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
698 static void _ewk_view_on_hide(void* data, Evas*, Evas_Object*, void* /*eventInfo*/)
700 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
701 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
703 // This call may look wrong, but we really need to pass ViewIsVisible here.
704 // viewStateDidChange() itself is responsible for actually setting the visibility to Visible or Hidden
705 // depending on what WebPageProxy::isViewVisible() returns, this simply triggers the process.
706 impl->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
711 #if ENABLE(TIZEN_FULLSCREEN_API)
712 Eina_Bool _ewk_view_smart_fullscreen_enter(Ewk_View_Smart_Data* smartData)
714 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
716 ewk_view_main_frame_scrollbar_visible_set(impl->view(), false);
717 bool isNeed = impl->page()->fullScreenManager()->exitFullScreenByHwBackKey();
718 evas_object_smart_callback_call(impl->view(), "fullscreen,enterfullscreen", &isNeed);
722 Eina_Bool _ewk_view_smart_fullscreen_exit(Ewk_View_Smart_Data* smartData)
724 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
726 ewk_view_main_frame_scrollbar_visible_set(impl->view(), true);
727 evas_object_smart_callback_call(impl->view(), "fullscreen,exitfullscreen", 0);
732 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
733 Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
735 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
737 return impl->pageClient->textSelectionDown(IntPoint(x, y));
740 Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
742 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
744 IntPoint point(x, y);
745 impl->pageClient->textSelectionMove(point);
750 Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
752 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
754 IntPoint point(x, y);
755 impl->pageClient->textSelectionUp(point, true);
761 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
762 Eina_Bool _ewk_view_smart_formdata_candidate_show(Ewk_View_Smart_Data* smartData, int x, int y, int w, int h)
764 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
766 impl->pageClient->showAutoFillPopup(IntRect(x, y, w, h));
771 Eina_Bool _ewk_view_smart_formdata_candidate_hide(Ewk_View_Smart_Data* smartData)
773 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
775 impl->pageClient->hideAutoFillPopup();
780 Eina_Bool _ewk_view_smart_formdata_candidate_update_data(Ewk_View_Smart_Data* smartData, Eina_List* dataList)
782 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
784 Vector<AutoFillPopupItem> formData;
787 EINA_LIST_FOREACH(dataList, list, data)
788 formData.append(AutoFillPopupItem(String::fromUTF8(static_cast<char*>(data)), candidateAutoFill));
790 impl->pageClient->updateAutoFillPopup(formData);
795 Eina_Bool _ewk_view_smart_formdata_candidate_is_showing(Ewk_View_Smart_Data* smartData)
797 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
799 return impl->pageClient->isShowingAutoFillPopup();
803 #if ENABLE(TIZEN_SCREEN_READER)
804 Eina_Bool _ewk_view_screen_reader_action_execute(Ewk_View_Smart_Data* smartData, void* actionInfo)
806 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
808 return ScreenReaderProxy::executeAction(impl, 0, static_cast<Elm_Access_Action_Info*>(actionInfo));
811 #endif // #if OS(TIZEN)
813 static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
815 static void _ewk_view_impl_del(EwkViewImpl* impl)
817 #if !ENABLE(TIZEN_ICON_DATABASE)
818 /* Unregister icon change callback */
819 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
820 iconDatabase->unwatchChanges(_ewk_view_on_favicon_changed);
826 static void _ewk_view_smart_add(Evas_Object* ewkView)
828 const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
829 const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
830 const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
831 EWK_VIEW_SD_GET(ewkView, smartData);
834 smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
836 EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
839 evas_object_smart_data_set(ewkView, smartData);
842 smartData->self = ewkView;
843 smartData->api = api;
845 g_parentSmartClass.add(ewkView);
847 smartData->priv = new EwkViewImpl(ewkView);
848 if (!smartData->priv) {
849 EINA_LOG_CRIT("could not allocate EwkViewImpl");
850 evas_object_smart_data_set(ewkView, 0);
855 // Create evas_object_image to draw web contents.
856 smartData->image = evas_object_image_add(smartData->base.evas);
857 evas_object_image_alpha_set(smartData->image, false);
858 evas_object_image_filled_set(smartData->image, true);
859 evas_object_smart_member_add(smartData->image, ewkView);
862 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
863 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
864 const char *engine = ecore_evas_engine_name_get(ee);
865 if (engine && !strcmp(engine, "opengl_x11"))
866 evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
868 ewk_view_mouse_events_enabled_set(ewkView, false);
869 ewk_view_touch_events_enabled_set(ewkView, true);
871 // FIXME: This code should be removed if side effect occur.
872 // WebView does not have focus after url loading.
873 // If focus is set as true to webview,
874 // elementary steal webview's focus during mouse up event
875 // So, added code that events are not propagated to smart parent according to guide from EFL
876 evas_object_propagate_events_set(ewkView, false);
877 #endif // #if OS(TIZEN)
879 #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
880 CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
881 CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
882 CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
883 CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
884 CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
885 CONNECT(EVAS_CALLBACK_SHOW, _ewk_view_on_show);
886 CONNECT(EVAS_CALLBACK_HIDE, _ewk_view_on_hide);
890 static void _ewk_view_smart_del(Evas_Object* ewkView)
892 EwkViewImpl::removeFromPageViewMap(ewkView);
893 EWK_VIEW_SD_GET(ewkView, smartData);
894 #if ENABLE(TIZEN_SCREEN_READER)
895 ScreenReaderProxy::screenReader().finalize(smartData->priv);
897 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
898 // Close color picker if it's opened.
899 if (smartData && smartData->priv && smartData->priv->inputPicker->isColorPickerShown())
900 ewk_view_color_picker_color_set(ewkView, 0, 0, 0, 0);
903 #if ENABLE(TIZEN_GEOLOCATION)
905 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
906 Ewk_Geolocation_Provider* geolocationProvider = impl->context->geolocationProvider();
907 TIZEN_LOGI("_ewk_view_smart_del:: unwatch validity");
908 geolocationProvider->unwatchValidity(ewkView);
912 if (smartData && smartData->priv)
913 _ewk_view_impl_del(smartData->priv);
915 g_parentSmartClass.del(ewkView);
918 static Eina_Bool _ewk_view_composite(void* data);
920 static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
922 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
924 evas_object_resize(smartData->image, width, height);
925 evas_object_image_size_set(smartData->image, width, height);
926 evas_object_image_fill_set(smartData->image, 0, 0, width, height);
928 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
929 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
930 evas_object_image_native_surface_set(smartData->image, 0);
932 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
933 impl->pageClient->updateViewportSize(IntSize(width, height), ecore_evas_rotation_get(ee));
934 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
935 if (!ewk_view_is_opengl_backend(ewkView))
936 _ewk_view_composite(smartData);
937 else // OpenGL backend
939 impl->pageClient->displayViewport();
941 #endif // #if OS(TIZEN)
943 smartData->changed.size = true;
944 _ewk_view_smart_changed(smartData);
947 static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
949 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
951 smartData->changed.position = true;
952 _ewk_view_smart_changed(smartData);
955 static void _ewk_view_smart_calculate(Evas_Object* ewkView)
957 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
958 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
960 Evas_Coord x, y, width, height;
962 smartData->changed.any = false;
964 evas_object_geometry_get(ewkView, &x, &y, &width, &height);
966 if (smartData->changed.size) {
968 #if USE(COORDINATED_GRAPHICS)
969 impl->pageViewportControllerClient->updateViewportSize(IntSize(width, height));
971 #if USE(ACCELERATED_COMPOSITING)
972 needsNewSurface = impl->evasGlSurface;
975 if (impl->pageProxy->drawingArea())
976 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
978 #if USE(ACCELERATED_COMPOSITING)
979 if (!impl->evasGlSurface)
981 evas_gl_surface_destroy(impl->evasGl, impl->evasGlSurface);
982 impl->evasGlSurface = 0;
983 ewk_view_create_gl_surface(ewkView, IntSize(width, height));
984 ewk_view_display(ewkView, IntRect(IntPoint(), IntSize(width, height)));
986 #endif // #if !OS(TIZEN)
988 smartData->view.w = width;
989 smartData->view.h = height;
990 smartData->changed.size = false;
993 if (impl->pageClient) {
994 if (DrawingAreaProxy* drawingArea = impl->pageProxy->drawingArea()) {
995 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
996 if (impl->pageProxy->isViewVisible())
997 drawingArea->setSize(IntSize(width, height), IntSize());
999 drawingArea->setSize(IntSize(width, height), IntSize());
1001 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1002 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
1003 impl->pageClient->updateVisibleContentRectSize(IntSize(width, height));
1004 if (ewk_view_is_opengl_backend(ewkView))
1005 impl->pageClient->displayViewport();
1008 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1009 impl->pageClient->frameRectChanged();
1012 #endif // #if OS(TIZEN)
1015 if (smartData->changed.position) {
1016 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1017 IntSize diff(x - smartData->view.x, y - smartData->view.y);
1020 evas_object_move(smartData->image, x, y);
1021 smartData->view.x = x;
1022 smartData->view.y = y;
1023 smartData->changed.position = false;
1025 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1026 impl->pageClient->frameRectChanged();
1028 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1029 impl->pageClient->updateTextSelectionHandlesAndContextMenu(true);
1031 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1032 if (impl->focusRing())
1033 impl->focusRing()->moveBy(diff);
1035 #endif // #if OS(TIZEN)
1038 if (impl->popupPicker)
1039 ewk_popup_picker_resize(impl->popupPicker);
1040 #endif // #if OS(TIZEN)
1043 static void _ewk_view_smart_show(Evas_Object* ewkView)
1045 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1046 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1048 if (evas_object_clipees_get(smartData->base.clipper))
1049 evas_object_show(smartData->base.clipper);
1050 evas_object_show(smartData->image);
1052 #if ENABLE(TIZEN_SCREEN_READER)
1053 ScreenReaderProxy::screenReader().initialize(impl);
1057 static void _ewk_view_smart_hide(Evas_Object* ewkView)
1059 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1061 evas_object_hide(smartData->base.clipper);
1062 evas_object_hide(smartData->image);
1063 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1064 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1065 if (impl->pageClient->isTextSelectionMode())
1066 impl->pageClient->setIsTextSelectionMode(false);
1070 static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
1072 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1073 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1077 else if (alpha > 255)
1080 #define CHECK_COLOR(color, alpha) \
1083 else if (color > alpha) \
1085 CHECK_COLOR(red, alpha);
1086 CHECK_COLOR(green, alpha);
1087 CHECK_COLOR(blue, alpha);
1090 evas_object_image_alpha_set(smartData->image, alpha < 255);
1091 impl->pageProxy->setDrawsBackground(red || green || blue);
1092 impl->pageProxy->setDrawsTransparentBackground(alpha < 255);
1093 impl->pageClient->setBackgroundColor(red/255.0, green/255.0, blue/255.0, alpha/255.0);
1096 g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
1100 Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
1102 EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
1104 if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
1105 EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
1106 api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
1110 if (EINA_UNLIKELY(!g_parentSmartClass.add))
1111 evas_object_smart_clipped_smart_set(&g_parentSmartClass);
1113 evas_object_smart_clipped_smart_set(&api->sc);
1115 // Set Evas_Smart_Class functions.
1116 api->sc.add = _ewk_view_smart_add;
1117 api->sc.del = _ewk_view_smart_del;
1118 api->sc.move = _ewk_view_smart_move;
1119 api->sc.resize = _ewk_view_smart_resize;
1120 api->sc.show = _ewk_view_smart_show;
1121 api->sc.hide = _ewk_view_smart_hide;
1122 api->sc.color_set = _ewk_view_smart_color_set;
1123 api->sc.calculate = _ewk_view_smart_calculate;
1124 api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
1126 // Set Ewk_View_Smart_Class functions.
1127 api->focus_in = _ewk_view_smart_focus_in;
1128 api->focus_out = _ewk_view_smart_focus_out;
1129 api->mouse_wheel = _ewk_view_smart_mouse_wheel;
1130 api->mouse_down = _ewk_view_smart_mouse_down;
1131 api->mouse_up = _ewk_view_smart_mouse_up;
1132 api->mouse_move = _ewk_view_smart_mouse_move;
1133 api->key_down = _ewk_view_smart_key_down;
1134 api->key_up = _ewk_view_smart_key_up;
1136 api->gesture_start = _ewk_view_smart_gesture_start;
1137 api->gesture_end = _ewk_view_smart_gesture_end;
1138 api->gesture_move = _ewk_view_smart_gesture_move;
1140 #if ENABLE(TIZEN_FULLSCREEN_API)
1141 api->fullscreen_enter = _ewk_view_smart_fullscreen_enter;
1142 api->fullscreen_exit = _ewk_view_smart_fullscreen_exit;
1145 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1146 api->popup_menu_show = _ewk_view_popup_menu_show;
1147 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1148 api->multiple_popup_menu_show = _ewk_view_multiple_popup_menu_show;
1150 api->popup_menu_hide = _ewk_view_popup_menu_hide;
1151 api->popup_menu_update = _ewk_view_popup_menu_update;
1153 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1154 api->text_selection_down = _ewk_view_text_selection_down;
1155 api->text_selection_move = _ewk_view_text_selection_move;
1156 api->text_selection_up = _ewk_view_text_selection_up;
1158 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1159 api->input_picker_show = _ewk_view_input_picker_show;
1161 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1162 api->data_list_show = _ewk_view_data_list_show;
1163 api->data_list_hide = _ewk_view_data_list_hide;
1165 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
1166 api->orientation_lock = _ewk_orientation_lock;
1167 api->orientation_unlock = _ewk_orientation_unlock;
1169 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1170 api->input_picker_color_request = _ewk_input_picker_color_request;
1171 api->input_picker_color_dismiss = _ewk_input_picker_color_dismiss;
1173 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1174 api->formdata_candidate_show = _ewk_view_smart_formdata_candidate_show;
1175 api->formdata_candidate_hide = _ewk_view_smart_formdata_candidate_hide;
1176 api->formdata_candidate_update_data = _ewk_view_smart_formdata_candidate_update_data;
1177 api->formdata_candidate_is_showing = _ewk_view_smart_formdata_candidate_is_showing;
1179 #if ENABLE(TIZEN_SCREEN_READER)
1180 api->screen_reader_action_execute = _ewk_view_screen_reader_action_execute;
1182 #endif //#if OS(TIZEN)
1187 static inline Evas_Smart* _ewk_view_smart_class_new(void)
1189 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
1190 static Evas_Smart* smart = 0;
1192 if (EINA_UNLIKELY(!smart)) {
1193 ewk_view_smart_class_set(&api);
1194 smart = evas_smart_class_new(&api.sc);
1200 static void _ewk_view_initialize(Evas_Object* ewkView, PassRefPtr<Ewk_Context> context, WKPageGroupRef pageGroupRef)
1202 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1203 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1204 EINA_SAFETY_ON_NULL_RETURN(context);
1206 if (impl->pageClient)
1209 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1210 bool isOpenGL = ewk_view_is_opengl_backend(ewkView);
1212 impl->pageClient = PageClientEvasGL::create(impl);
1214 impl->pageClient = PageClientImpl::create(impl);
1216 impl->pageClient = PageClientImpl::create(impl);
1220 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), toImpl(pageGroupRef));
1222 impl->pageProxy = toImpl(context->wkContext())->createWebPage(impl->pageClient.get(), WebPageGroup::create().get());
1224 EwkViewImpl::addToPageViewMap(ewkView);
1227 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
1228 impl->pageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
1229 impl->pageProxy->pageGroup()->preferences()->setFrameFlatteningEnabled(true);
1230 impl->pageProxy->pageGroup()->preferences()->setAllowUniversalAccessFromFileURLs(true);
1233 impl->pageProxy->initializeWebPage();
1235 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
1236 impl->pageProxy->setCustomDeviceScaleFactor((float)getMobileDPI() / 160);
1238 impl->pageProxy->setCustomDeviceScaleFactor((float)getDPI() / 160);
1241 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
1242 impl->pageProxy->setUseFixedLayout(true);
1244 #if ENABLE(FULLSCREEN_API)
1245 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1248 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1250 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(true);
1252 impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(false);
1253 impl->pageProxy->pageGroup()->preferences()->setWebGLEnabled(false);
1254 impl->pageProxy->drawingArea()->layerTreeCoordinatorProxy()->initializeAcceleratedCompositingMode(false);
1258 impl->backForwardList = Ewk_Back_Forward_List::create(toAPI(impl->pageProxy->backForwardList()));
1260 impl->context = context;
1263 ewkViewContextMenuClientAttachClient(ewkView);
1264 ewkViewTizenClientAttachClient(ewkView);
1266 #if ENABLE(TIZEN_GEOLOCATION)
1267 Ewk_Geolocation_Provider* geolocationProvider = impl->context->geolocationProvider();
1268 geolocationProvider->watchValidity(GeolocationValidityCallbackData(_ewk_view_geolocation_validity_check, ewkView));
1271 #if ENABLE(TIZEN_NOTIFICATIONS)
1272 ewkViewNotificationProviderAttachProvider(ewkView, impl->context->wkContext());
1275 #if ENABLE(TIZEN_ICON_DATABASE)
1276 ewk_view_icondatabase_client_attach(ewkView, impl->context->wkContext());
1279 ewk_view_javascript_alert_callback_set(ewkView, _ewk_view_default_javascript_alert, 0);
1280 ewk_view_javascript_confirm_callback_set(ewkView, _ewk_view_default_javascript_confirm, 0);
1281 ewk_view_javascript_prompt_callback_set(ewkView, _ewk_view_default_javascript_prompt, 0);
1282 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1283 ewk_view_before_unload_confirm_panel_callback_set(ewkView, _ewk_view_default_before_unload_confirm_panel, 0);
1285 ewk_view_open_panel_callback_set(ewkView, _ewk_view_default_open_panel, 0);
1286 #else // #if OS(TIZEN)
1287 #if USE(COORDINATED_GRAPHICS)
1288 impl->viewportHandler = EflViewportHandler::create(impl->pageClient.get());
1290 #endif // #if OS(TIZEN)
1292 #if ENABLE(FULLSCREEN_API)
1293 impl->pageProxy->fullScreenManager()->setWebView(ewkView);
1294 impl->pageProxy->pageGroup()->preferences()->setFullScreenEnabled(true);
1297 // Initialize page clients.
1298 impl->pageLoadClient = PageLoadClientEfl::create(impl);
1299 impl->pagePolicyClient = PagePolicyClientEfl::create(impl);
1300 impl->pageUIClient = PageUIClientEfl::create(impl);
1301 impl->resourceLoadClient = ResourceLoadClientEfl::create(impl);
1302 impl->findClient = FindClientEfl::create(impl);
1303 impl->formClient = FormClientEfl::create(impl);
1304 #if !ENABLE(TIZEN_ICON_DATABASE)
1305 /* Listen for favicon changes */
1306 Ewk_Favicon_Database* iconDatabase = impl->context->faviconDatabase();
1307 iconDatabase->watchChanges(IconChangeCallbackData(_ewk_view_on_favicon_changed, ewkView));
1309 #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
1310 ewk_view_theme_set(ewkView, "/usr/share/edje/webkit.edj");
1313 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
1314 if (!impl->context->xWindow())
1315 impl->context->setXWindow(elm_win_xwindow_get(ewkView));
1319 static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart)
1321 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1322 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1324 #if ENABLE(TIZEN_WEBKIT2_DDK_CHECK)
1326 using namespace EGL;
1327 if(!eglGetDisplay(EGL_DEFAULT_DISPLAY)) {
1328 EINA_LOG_CRIT("Fail in initiziling view because No DDK is installed.");
1334 Evas_Object* ewkView = evas_object_smart_add(canvas, smart);
1338 EWK_VIEW_SD_GET(ewkView, smartData);
1340 evas_object_del(ewkView);
1344 EWK_VIEW_IMPL_GET(smartData, impl);
1346 evas_object_del(ewkView);
1355 * Constructs a ewk_view Evas_Object with WKType parameters.
1357 Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
1359 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1360 EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0);
1362 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new());
1366 _ewk_view_initialize(ewkView, Ewk_Context::create(contextRef), pageGroupRef);
1371 Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context)
1373 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
1374 EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0);
1375 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1377 Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart);
1381 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
1382 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1383 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1384 _ewk_view_initialize(ewkView, context, toAPI(impl->pageGroup.get()));
1386 _ewk_view_initialize(ewkView, context, 0);
1392 Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
1394 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
1395 return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context);
1398 Evas_Object* ewk_view_add(Evas* canvas)
1400 return ewk_view_add_with_context(canvas, ewk_context_default_get());
1403 Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
1405 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1406 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1408 return impl->ewkContext();
1411 Eina_Bool ewk_view_url_set(Evas_Object* ewkView, const char* url)
1413 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1414 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1415 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
1417 impl->pageProxy->loadURL(String::fromUTF8(url));
1418 impl->informURLChange();
1423 const char* ewk_view_url_get(const Evas_Object* ewkView)
1425 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1426 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1431 const char *ewk_view_icon_url_get(const Evas_Object *ewkView)
1433 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1434 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1436 return impl->faviconURL();
1439 Eina_Bool ewk_view_reload(Evas_Object* ewkView)
1441 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1442 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1444 impl->pageClient->prepareRestoredVisibleContectRect();
1445 impl->pageProxy->reload(/*reloadFromOrigin*/ false);
1446 impl->informURLChange();
1451 Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
1453 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1454 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1456 impl->pageProxy->reload(/*reloadFromOrigin*/ true);
1457 impl->informURLChange();
1462 Eina_Bool ewk_view_stop(Evas_Object* ewkView)
1464 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1465 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1467 impl->pageProxy->stopLoading();
1472 Ewk_Settings* ewk_view_settings_get(const Evas_Object* ewkView)
1474 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1475 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1477 return impl->settings();
1480 const char* ewk_view_title_get(const Evas_Object* ewkView)
1482 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1483 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1485 return impl->title();
1490 * Reports that the requested text was found.
1492 * Emits signal: "text,found" with the number of matches.
1494 void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount)
1496 evas_object_smart_callback_call(ewkView, "text,found", &matchCount);
1499 double ewk_view_load_progress_get(const Evas_Object* ewkView)
1501 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1502 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1504 return impl->pageProxy->estimatedProgress();
1507 Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, int x, int y)
1509 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1510 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1516 scaleFactor = impl->pageClient->adjustScaleWithViewport(scaleFactor);
1518 IntPoint scrollPosition = impl->pageClient->scrollPosition();
1519 double scaleDifference = scaleFactor / impl->pageClient->scaleFactor();
1520 int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
1521 int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
1523 impl->pageProxy->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
1525 impl->pageProxy->scalePage(scaleFactor, IntPoint(x, y));
1530 double ewk_view_scale_get(const Evas_Object* ewkView)
1532 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
1533 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1);
1536 return impl->pageProxy->scaleFactor();
1538 return impl->pageProxy->pageScaleFactor();
1542 Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
1544 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1545 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1547 impl->pageProxy->setCustomDeviceScaleFactor(ratio);
1552 float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
1554 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1.0);
1555 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, -1.0);
1557 return impl->pageProxy->deviceScaleFactor();
1560 void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
1562 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1563 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1565 impl->setThemePath(path);
1568 const char* ewk_view_theme_get(const Evas_Object* ewkView)
1570 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1571 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1573 return impl->themePath();
1576 Eina_Bool ewk_view_back(Evas_Object* ewkView)
1578 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1579 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1581 WebPageProxy* page = impl->pageProxy.get();
1582 if (page->canGoBack()) {
1590 Eina_Bool ewk_view_forward(Evas_Object* ewkView)
1592 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1593 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1595 WebPageProxy* page = impl->pageProxy.get();
1596 if (page->canGoForward()) {
1604 Eina_Bool ewk_view_intent_deliver(Evas_Object* ewkView, Ewk_Intent* intent)
1606 #if ENABLE(WEB_INTENTS)
1607 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1608 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1609 EINA_SAFETY_ON_NULL_RETURN_VAL(intent, false);
1611 WebPageProxy* page = impl->pageProxy.get();
1612 page->deliverIntentToFrame(page->mainFrame(), intent->webIntentData());
1620 Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
1622 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1623 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1625 return impl->pageProxy->canGoBack();
1628 Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
1630 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1631 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1633 return impl->pageProxy->canGoForward();
1636 Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView)
1638 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1639 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1641 return impl->backForwardList.get();
1644 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1645 #if ENABLE(TIZEN_WEBKIT2_AUTOFILL_PROFILE_FORM)
1646 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value, bool isInputInForm)
1648 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value)
1649 #endif // TIZEN_WEBKIT2_AUTOFILL_PROFILE_FORM
1651 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1652 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1654 if (value.isEmpty()) {
1655 if(smartData->api->formdata_candidate_is_showing(smartData))
1656 smartData->api->formdata_candidate_hide(smartData);
1660 Eina_List* optionList = 0;
1661 Vector<String> popupOptionLists = impl->pageProxy->getFocusedInputElementDataList();
1662 std::sort(popupOptionLists.begin(), popupOptionLists.end(), WTF::codePointCompareLessThan);
1663 for (size_t i = 0; i < popupOptionLists.size(); ++i) {
1664 if (popupOptionLists[i].startsWith(value, false))
1665 optionList = eina_list_append(optionList, eina_stringshare_add(popupOptionLists[i].utf8().data()));
1668 Eina_List* candidateList = 0;
1669 if (ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView))) {
1670 Vector<String> popupCandidates;
1671 ewk_view_form_candidate_data_get(ewkView, name, popupCandidates);
1672 std::sort(popupCandidates.begin(), popupCandidates.end(), WTF::codePointCompareLessThan);
1674 for (size_t i = 0; i < popupCandidates.size(); ++i) {
1675 if (popupCandidates[i].startsWith(value, false))
1676 candidateList = eina_list_append(candidateList, eina_stringshare_add(popupCandidates[i].utf8().data()));
1680 Vector<AutoFillPopupItem> formData;
1682 #if ENABLE(TIZEN_WEBKIT2_AUTOFILL_PROFILE_FORM)
1683 if (ewk_settings_form_profile_data_enabled_get(ewk_view_settings_get(ewkView)) && isInputInForm) {
1684 Vector<std::pair<int, std::pair<String, String> > > profileFormCandidates;
1685 ewk_view_profile_form_candidate_data_get(ewkView, name, value, profileFormCandidates);
1686 for (size_t ittr = 0; ittr < profileFormCandidates.size(); ++ittr) {
1687 std::pair<int, std::pair<String, String> > fullData(profileFormCandidates[ittr]);
1688 std::pair<String, String> dispStrings(fullData.second);
1689 formData.append(AutoFillPopupItem(dispStrings.first, dispStrings.second, fullData.first, profileAutoFill));
1696 if (eina_list_count(optionList)) {
1697 EINA_LIST_FOREACH(optionList, list, data)
1698 formData.append(AutoFillPopupItem(String::fromUTF8(static_cast<char*>(data)), dataListAutoFill));
1701 if (eina_list_count(candidateList) && ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView))) {
1702 EINA_LIST_FOREACH(candidateList, list, data)
1703 formData.append(AutoFillPopupItem(String::fromUTF8(static_cast<char*>(data)), candidateAutoFill));
1706 if (!formData.size()) {
1707 if(smartData->api->formdata_candidate_is_showing(smartData))
1708 smartData->api->formdata_candidate_hide(smartData);
1712 if (formData[0].itemtype == profileAutoFill)
1713 impl->pageClient->updateAutoFillPopup(formData);
1715 Eina_List* autoFillList = 0;
1717 if (eina_list_count(optionList)) {
1718 EINA_LIST_FOREACH(optionList, list, data)
1719 autoFillList = eina_list_append(autoFillList, eina_stringshare_add(static_cast<char*>(data)));
1721 if (eina_list_count(candidateList)) {
1722 EINA_LIST_FOREACH(candidateList, list, data)
1723 autoFillList = eina_list_append(autoFillList, eina_stringshare_add(static_cast<char*>(data)));
1725 smartData->api->formdata_candidate_update_data(smartData, autoFillList);
1728 IntRect inputFieldRect = impl->transformToScene().mapRect(impl->pageClient->focusedNodeRect());
1729 smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
1732 void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm, bool isAutoComplete)
1734 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1735 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1736 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
1737 && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
1740 // if isAutoComplete is off then return
1741 if (isPasswordForm && !isAutoComplete)
1744 ewk_view_context_get(ewkView)->addFormData(impl->url(), formData, isPasswordForm);
1747 void ewk_view_form_password_data_fill(Evas_Object* ewkView)
1749 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1750 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1752 if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView)))
1755 Vector<std::pair<String, String> > passwordFormData;
1756 ewk_view_context_get(ewkView)->passwordFormData(impl->url(), passwordFormData);
1758 if (!passwordFormData.size())
1761 String passwordFormAutofill = "try { function passwordFormAutofill() { var inputFields;";
1762 for (size_t i = 0; i < passwordFormData.size(); i++) {
1763 passwordFormAutofill += String::format(" inputFields = document.getElementsByName(\"%s\");"
1764 " for (var i = 0; i < inputFields.length; i++)"
1765 " if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\" || inputFields[i].type.toLowerCase() == \"email\")"
1766 " && inputFields[i].autocomplete.toLowerCase() != \"off\")"
1767 " inputFields[i].value = \"",passwordFormData[i].first.utf8().data());
1768 passwordFormAutofill.append(passwordFormData[i].second);
1769 passwordFormAutofill += "\";";
1771 passwordFormAutofill += "} passwordFormAutofill(); } catch(e) { }";
1772 ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
1775 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates)
1777 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
1778 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
1779 ewk_view_context_get(ewkView)->candidateFormData(name, candidates);
1783 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
1785 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1786 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1787 EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
1789 if (unreachableUrl && *unreachableUrl)
1790 impl->pageProxy->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
1792 impl->pageProxy->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
1794 impl->informURLChange();
1799 const char* ewk_view_custom_encoding_get(const Evas_Object* ewkView)
1801 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1802 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1804 return impl->customTextEncodingName();
1807 Eina_Bool ewk_view_custom_encoding_set(Evas_Object* ewkView, const char* encoding)
1809 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1810 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1812 impl->setCustomTextEncodingName(encoding);
1818 // FIXME: It should be removed.
1819 WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
1821 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
1822 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
1824 return toAPI(impl->pageProxy.get());
1827 Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
1829 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1830 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1832 impl->setMouseEventsEnabled(!!enabled);
1837 Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
1839 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1840 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1842 return impl->mouseEventsEnabled();
1845 Eina_Bool ewk_view_color_picker_color_set(Evas_Object* ewkView, int r, int g, int b, int a)
1847 #if ENABLE(INPUT_TYPE_COLOR)
1848 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1849 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1851 return impl->setColorPickerColor(WebCore::Color(r, g, b, a));
1857 static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
1859 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1860 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1862 return impl->javascriptPopup->alert(alertText);
1865 static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
1867 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1868 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1870 return impl->javascriptPopup->confirm(message);
1873 static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
1875 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1876 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1878 return impl->javascriptPopup->prompt(message, defaultValue);
1881 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
1882 static Eina_Bool _ewk_view_default_before_unload_confirm_panel(Evas_Object* ewkView, const char* message, void* userData)
1884 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1885 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1887 return impl->javascriptPopup->beforeUnloadConfirmPanel(message);
1891 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)
1893 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
1894 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1896 return impl->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, impl);
1899 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1900 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)
1902 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1904 if (impl->popupPicker)
1905 ewk_popup_picker_del(impl->popupPicker);
1907 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1908 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex, false);
1910 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
1916 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1917 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)
1919 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1921 if (impl->popupPicker)
1922 ewk_popup_picker_del(impl->popupPicker);
1924 impl->popupPicker = ewk_popup_picker_new(smartData->self, items, 0, true);
1930 Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
1932 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1934 if (!impl->popupPicker)
1937 ewk_popup_picker_del(impl->popupPicker);
1938 impl->popupPicker = 0;
1943 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)
1945 // FIXME: The rect should be updated if it was changed
1947 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1949 if (!impl->popupPicker)
1952 ewk_popup_picker_update(smartData->self, impl->popupPicker, items, selectedIndex);
1958 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1959 static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
1961 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1963 impl->inputPicker->show(inputType, inputValue);
1968 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1969 static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
1971 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1973 impl->inputPicker->showDataList(inputType, optionList);
1977 static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
1979 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1981 impl->inputPicker->hideDataList(inputType);
1986 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
1987 static Eina_Bool _ewk_input_picker_color_request(Ewk_View_Smart_Data* smartData, int r, int g, int b, int a)
1989 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1991 impl->inputPicker->showColorPicker(r, g, b, a);
1995 static Eina_Bool _ewk_input_picker_color_dismiss(Ewk_View_Smart_Data* smartData)
1997 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
1999 impl->inputPicker->hideColorPicker();
2004 PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
2006 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2007 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2009 return impl->pageClient.get();
2012 double ewk_view_text_zoom_get(const Evas_Object* ewkView)
2014 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
2015 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 1);
2017 return WKPageGetTextZoomFactor(toAPI(impl->pageProxy.get()));
2020 Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
2022 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2023 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2025 WKPageSetTextZoomFactor(toAPI(impl->pageProxy.get()), textZoomFactor);
2029 Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
2031 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2032 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2034 return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(impl->pageProxy.get())));
2037 Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
2039 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2040 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2042 return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(impl->pageProxy.get())));
2045 JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
2047 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2048 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2050 if (!impl->javascriptGlobalContext)
2051 impl->javascriptGlobalContext = JSGlobalContextCreate(0);
2052 return impl->javascriptGlobalContext;
2055 void ewkViewLoadCommitted(Evas_Object* ewkView)
2057 #if ENABLE(TIZEN_GESTURE)
2058 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2059 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2060 impl->gestureClient->reset();
2062 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
2063 if (impl->focusRing())
2064 impl->focusRing()->hide(false);
2066 #if ENABLE(TIZEN_ISF_PORT)
2067 impl->inputMethodContext()->hideIMFContext();
2069 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2070 if (smartData->api->formdata_candidate_is_showing(smartData))
2071 smartData->api->formdata_candidate_hide(smartData);
2073 impl->informURLChange();
2074 evas_object_smart_callback_call(ewkView, "load,committed", 0);
2077 void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
2079 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2080 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2082 OwnPtr<Ewk_Error> ewkError = Ewk_Error::create(error);
2083 ewk_error_load_error_page(ewkError.get(), toAPI(impl->pageProxy.get()));
2084 evas_object_smart_callback_call(ewkView, "load,error", ewkError.get());
2087 void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
2089 #if ENABLE(TIZEN_GESTURE)
2090 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2091 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2092 impl->gestureClient->reset();
2094 evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
2097 void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
2099 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2100 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2102 if (impl->authChallenge)
2103 ewkAuthChallengeDelete(impl->authChallenge);
2104 impl->authChallenge = authChallenge;
2106 evas_object_smart_callback_call(ewkView, "authentication,challenge", impl->authChallenge);
2109 void ewk_view_process_crashed(Evas_Object* ewkView)
2111 bool handled = false;
2112 evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
2118 #if ENABLE(TIZEN_SQL_DATABASE)
2119 bool ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef databaseName, unsigned long long expectedUsage)
2121 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2122 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2124 if (!impl->exceededDatabaseQuotaContext || !impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback)
2127 TIZEN_LOGI("No error in prameter. Request to display user confirm popup. expectedUsage(%llu)", expectedUsage);
2128 impl->isWaitingForExceededQuotaPopupReply = true;
2129 if (impl->exceededQuotaOrigin)
2130 deleteSecurityOrigin(impl->exceededQuotaOrigin);
2131 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
2133 int length = WKStringGetMaximumUTF8CStringSize(databaseName);
2134 OwnArrayPtr<char> databaseNameBuffer = adoptArrayPtr(new char[length]);
2135 WKStringGetUTF8CString(databaseName, databaseNameBuffer.get(), length);
2137 return impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, databaseNameBuffer.get(), expectedUsage, impl->exceededDatabaseQuotaContext->userData) == EINA_TRUE;
2141 #if ENABLE(TIZEN_NOTIFICATIONS)
2142 void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
2144 TIZEN_LOGI("notification,cancel");
2145 evas_object_smart_callback_call(ewkView, "notification,cancel", ¬ificationID);
2148 void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
2150 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2151 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2153 TIZEN_LOGI("notification,permission,request");
2154 impl->notificationPermissionRequests = eina_list_append(impl->notificationPermissionRequests, notificationPermissionRequest);
2155 evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
2158 void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
2160 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2161 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2163 TIZEN_LOGI("notification,show");
2164 Eina_List* listIterator=0;
2166 const char* replaceID = ewkNotificationGetReplaceID(notification);
2167 if(strlen(replaceID)) {
2168 EINA_LIST_FOREACH(impl->notifications, listIterator, data) {
2169 Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
2170 if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
2171 ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
2175 impl->notifications = eina_list_append(impl->notifications, notification);
2176 evas_object_smart_callback_call(ewkView, "notification,show", notification);
2179 void ewkViewDeleteNotificationPermissionRequest(Evas_Object* ewkView, Ewk_Notification_Permission_Request* ewkNotificationPermissionRequest)
2181 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2182 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2184 impl->notificationPermissionRequests = eina_list_remove(impl->notificationPermissionRequests, ewkNotificationPermissionRequest);
2188 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
2189 void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
2191 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2193 TIZEN_LOGI("protocolhandler,registration,requested");
2194 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
2195 evas_object_smart_callback_call(ewkView, "protocolhandler,registration,requested", static_cast<void*>(customHandlersData));
2196 ewkCustomHandlersDeleteData(customHandlersData);
2200 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
2201 Ewk_Custom_Handlers_State ewkViewIsProtocolHandlerRegistered(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2203 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2205 TIZEN_LOGI("protocolhandler,isregistered");
2206 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2207 evas_object_smart_callback_call(ewkView, "protocolhandler,isregistered", static_cast<void*>(customHandlersData));
2209 Ewk_Custom_Handlers_State result;
2210 result = ewkGetCustomHandlersDataResult(customHandlersData);
2211 ewkCustomHandlersDeleteData(customHandlersData);
2216 void ewkViewUnregisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseURL, const char* url)
2218 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2220 TIZEN_LOGI("protocolhandler,unregistration,requested");
2221 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseURL, url);
2222 evas_object_smart_callback_call(ewkView, "protocolhandler,unregistration,requested", static_cast<void*>(customHandlersData));
2223 ewkCustomHandlersDeleteData(customHandlersData);
2227 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
2228 void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
2230 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2232 TIZEN_LOGI("contenthandler,registration,requested");
2233 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
2234 evas_object_smart_callback_call(ewkView, "contenthandler,registration,requested", static_cast<void*>(customHandlersData));
2235 ewkCustomHandlersDeleteData(customHandlersData);
2238 Ewk_Custom_Handlers_State ewkViewIsContentHandlerRegistered(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2240 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, EWK_CUSTOM_HANDLERS_DECLINED);
2242 TIZEN_LOGI("contenthandler,isregistered");
2243 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2244 evas_object_smart_callback_call(ewkView, "contenthandler,isregistered", static_cast<void*>(customHandlersData));
2246 Ewk_Custom_Handlers_State result;
2247 result = ewkGetCustomHandlersDataResult(customHandlersData);
2248 ewkCustomHandlersDeleteData(customHandlersData);
2253 void ewkViewUnregisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseURL, const char* url)
2255 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2257 TIZEN_LOGI("contenthandler,unregistration,requested");
2258 Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseURL, url);
2259 evas_object_smart_callback_call(ewkView, "contenthandler,unregistration,requested", static_cast<void*>(customHandlersData));
2260 ewkCustomHandlersDeleteData(customHandlersData);
2264 #if ENABLE(TIZEN_SEARCH_PROVIDER)
2265 void ewkViewAddSearchProvider(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2267 EINA_SAFETY_ON_NULL_RETURN(ewkView);
2269 TIZEN_LOGI("searchProvider,add");
2270 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2271 evas_object_smart_callback_call(ewkView, "searchProvider,add", static_cast<void*>(searchProviderData));
2272 ewkSearchProviderDeleteData(searchProviderData);
2275 unsigned long ewkViewIsSearchProviderInstalled(Evas_Object* ewkView, const char* baseURL, const char* engineURL)
2277 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
2279 TIZEN_LOGI("searchProvider,installed");
2280 Ewk_Search_Provider_Data* searchProviderData = ewkSearchProviderCreateData(baseURL, engineURL);
2281 evas_object_smart_callback_call(ewkView, "searchProvider,installed", static_cast<void*>(searchProviderData));
2282 unsigned long result;
2283 result = ewkGetSearchProviderResult(searchProviderData);
2284 ewkSearchProviderDeleteData(searchProviderData);
2289 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
2290 bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
2292 TIZEN_LOGI("webapp,metatag,standalone");
2293 bool standalone = true;
2294 evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
2299 #if ENABLE(TIZEN_MEDIA_STREAM)
2300 void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* userMediaPermission)
2302 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2303 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2305 impl->userMediaPermissionRequests = eina_list_append(impl->userMediaPermissionRequests, userMediaPermission);
2306 evas_object_smart_callback_call(ewkView, "usermedia,permission,request", userMediaPermission);
2309 void ewkViewDeleteUserMediaPermissionRequest(Evas_Object* ewkView, Ewk_User_Media_Permission_Request* permission)
2311 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2312 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2314 impl->userMediaPermissionRequests = eina_list_remove(impl->userMediaPermissionRequests, permission);
2319 #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
2320 void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
2322 int requestLength = WKStringGetMaximumUTF8CStringSize(request);
2323 OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
2324 int messageLength = WKStringGetMaximumUTF8CStringSize(message);
2325 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
2326 WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
2327 WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
2329 evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
2333 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
2334 void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
2336 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2337 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2338 if (impl->certificatePolicyDecision)
2339 ewkCertificatePolicyDecisionDelete(impl->certificatePolicyDecision);
2340 impl->certificatePolicyDecision = certificatePolicyDecision;
2342 evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
2346 void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
2348 evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
2351 void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
2353 evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
2356 #if ENABLE(TIZEN_GEOLOCATION)
2357 void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2359 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2360 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2362 TIZEN_LOGI("geolocation,permission,request");
2363 impl->geolocationPermissionRequests = eina_list_append(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2364 evas_object_smart_callback_call(ewkView, "geolocation,permission,request", geolocationPermissionRequest);
2367 void ewkViewDeleteGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Request* geolocationPermissionRequest)
2369 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2370 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2372 impl->geolocationPermissionRequests = eina_list_remove(impl->geolocationPermissionRequests, geolocationPermissionRequest);
2376 void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
2378 evas_object_smart_callback_call(ewkView, "form,submit", formData);
2381 void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2383 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2384 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2385 if (impl->policyDecision)
2386 ewkPolicyDecisionDelete(impl->policyDecision);
2387 impl->policyDecision = policyDecision;
2389 evas_object_smart_callback_call(ewkView, "policy,navigation,decide", impl->policyDecision);
2392 void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2394 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2395 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2396 if (impl->policyDecision)
2397 ewkPolicyDecisionDelete(impl->policyDecision);
2398 impl->policyDecision = policyDecision;
2400 evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", impl->policyDecision);
2403 void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
2405 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
2406 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
2407 if (impl->policyDecision)
2408 ewkPolicyDecisionDelete(impl->policyDecision);
2409 impl->policyDecision = policyDecision;
2411 evas_object_smart_callback_call(ewkView, "policy,response,decide", impl->policyDecision);
2414 void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
2416 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2417 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2419 IntPoint scrollPosition = impl->pageClient->scrollPosition();
2420 IntSize contentsSize = impl->pageProxy->contentsSize();
2421 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2422 contentsSize.scale(impl->pageClient->scaleFactor());
2425 // some website's contents size is smaller than view size,
2426 // so we have to adjust contents size to view size for that case.
2427 if (contentsSize.width() < smartData->view.w)
2428 contentsSize.setWidth(smartData->view.w);
2429 if (contentsSize.height() < smartData->view.h)
2430 contentsSize.setHeight(smartData->view.h);
2432 // Call "scroll,down" if webview can be scrolled down.
2433 if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
2434 evas_object_smart_callback_call(ewkView, "scroll,down", 0);
2435 // Call "scroll,up" if webview can be scrolled up.
2436 else if (deltaY < 0 && scrollPosition.y() > 0)
2437 evas_object_smart_callback_call(ewkView, "scroll,up", 0);
2439 // Call "scroll,right" if webview can be scrolled down.
2440 if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
2441 evas_object_smart_callback_call(ewkView, "scroll,right", 0);
2442 // Call "scroll,left" if webview can be scrolled up.
2443 else if (deltaX < 0 && scrollPosition.x() > 0)
2444 evas_object_smart_callback_call(ewkView, "scroll,left", 0);
2447 void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
2449 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2450 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2452 IntSize contentsSize = impl->pageProxy->contentsSize();
2453 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2454 contentsSize.scale(impl->pageClient->scaleFactor());
2457 int maxScrollY = contentsSize.height() - smartData->view.h;
2458 if (!impl->isVerticalEdge) {
2459 if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
2460 evas_object_smart_callback_call(ewkView, "edge,top", NULL);
2461 impl->isVerticalEdge = true;
2462 } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
2463 evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
2464 impl->isVerticalEdge = true;
2467 if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
2468 || (scrollPosition.y() == maxScrollY && deltaY < 0)))
2469 impl->isVerticalEdge = false;
2472 int maxScrollX = contentsSize.width() - smartData->view.w;
2473 if (!impl->isHorizontalEdge) {
2474 if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
2475 evas_object_smart_callback_call(ewkView, "edge,left", NULL);
2476 impl->isHorizontalEdge = true;
2477 } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
2478 evas_object_smart_callback_call(ewkView, "edge,right", NULL);
2479 impl->isHorizontalEdge = true;
2482 if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
2483 || (scrollPosition.x() == maxScrollX && deltaX < 0)))
2484 impl->isHorizontalEdge = false;
2488 void ewkViewClearEdges(Evas_Object* ewkView)
2490 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2491 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2493 impl->isVerticalEdge = false;
2494 impl->isHorizontalEdge = false;
2497 void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
2499 EWK_VIEW_SD_GET(ewkView, smartData);
2500 if (!smartData || !smartData->priv) {
2508 PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
2510 *minimumScale = constraints.minimumScale;
2512 *maximumScale = constraints.maximumScale;
2515 bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExternalKeyboard, Eina_Bool adjustForContentSizeChanged)
2517 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2518 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2520 #if ENABLE(TIZEN_ISF_PORT)
2521 // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
2522 // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
2523 // input field zoom should not work with below conditions
2524 // 1. view is not focused
2525 // 2. external keyboard is not connected(if adjustForExternalKeyboard is true)
2526 // 3. imfContext is null(if adjustForExternalKeyboard is false)
2527 // 4. input panel state is hidden(if adjustForExternalKeyboard is false)
2529 if ((!(static_cast<PageClient*>(impl->pageClient.get()))->isViewFocused()
2530 || (!adjustForExternalKeyboard && !impl->inputMethodContext())
2531 || (!adjustForContentSizeChanged && impl->pageProxy->editorState().isContentRichlyEditable)
2532 || (adjustForContentSizeChanged && !impl->inputMethodContext()->isShow()))
2533 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
2534 && !(impl->pageClient->isClipboardWindowOpened())
2540 double scaleFactor = impl->pageClient->scaleFactor();
2541 IntSize contentsSize = impl->pageProxy->contentsSize();
2543 double newScaleFactor = scaleFactor;
2544 // Readable zoom value is dependent on device DPI
2545 if (scaleFactor < impl->pageProxy->deviceScaleFactor()
2546 && impl->pageClient->viewportConstraints().userScalable)
2547 newScaleFactor = impl->pageProxy->deviceScaleFactor();
2549 // Readable zoom value should be inside of viewport scale range
2550 newScaleFactor = impl->pageClient->adjustScaleWithViewport(newScaleFactor);
2552 // caret position can be outside of visible rect.
2553 // we need to consider it.
2554 IntRect selectionRect = impl->pageProxy->editorState().selectionRect;
2555 IntRect focusedNodeRect = impl->pageClient->focusedNodeRect();
2556 IntRect focusedNodeRectScaled = focusedNodeRect;
2558 if (selectionRect.isEmpty())
2561 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
2562 focusedNodeRectScaled.scale(newScaleFactor);
2564 focusedNodeRectScaled.scale(newScaleFactor / scaleFactor);
2567 IntRect visibleRect = impl->pageClient->visibleContentRect();
2568 if (visibleRect.contains(focusedNodeRectScaled))
2571 #if ENABLE(TIZEN_WEBKIT2_INPUT_FIELD_ZOOM)
2572 impl->inputFieldZoom->startInputFieldZoom(impl->transformFromScene().mapPoint(IntPoint(selectionRect.x(), selectionRect.y()))
2573 , IntRect(focusedNodeRect.x(), selectionRect.y(), focusedNodeRect.width(), selectionRect.height()));
2579 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
2580 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2581 static Eina_Bool _ewk_view_composite(void* data)
2583 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
2584 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2586 if (!evas_object_visible_get(smartData->image))
2587 return ECORE_CALLBACK_CANCEL;
2590 evas_object_image_size_get(smartData->image, &ow, &oh);
2591 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(smartData->image, true));
2593 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)));
2594 RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
2596 cairo_save(context.get());
2597 cairo_set_operator(context.get(), CAIRO_OPERATOR_CLEAR);
2598 cairo_rectangle(context.get(), 0, 0, ow, oh);
2599 cairo_fill(context.get());
2600 cairo_restore(context.get());
2602 impl->pageClient->drawContents(context.get());
2604 evas_object_image_data_set(smartData->image, pixels);
2605 evas_object_image_data_update_add(smartData->image, 0, 0, ow, oh);
2607 if (impl->pageClient->notifiedNonemptyLayout() && impl->pageClient->canUpdateVisibleContentRect())
2608 ewkViewFrameRendered(smartData->self);
2610 impl->compositionAnimator = 0;
2612 return ECORE_CALLBACK_CANCEL;
2616 void ewk_view_mark_for_sync(Evas_Object* ewkView)
2618 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2619 EINA_SAFETY_ON_NULL_RETURN(smartData->image);
2621 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2622 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2624 if (!ewk_view_is_opengl_backend(ewkView)) {
2625 if (!impl->compositionAnimator)
2626 impl->compositionAnimator = ecore_animator_add(_ewk_view_composite, smartData);
2631 evas_object_image_pixels_dirty_set(smartData->image, true);
2634 static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
2636 Evas_Object* ewkView = static_cast<Evas_Object*>(data);
2637 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2638 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2639 impl->pageClient->drawContents();
2642 bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
2644 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2645 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2647 if (!smartData->image)
2650 evas_object_image_native_surface_set(smartData->image, nativeSurface);
2651 evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
2657 void _ewk_view_suspend_painting(Evas_Object* ewkView)
2659 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2660 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2662 if (!impl->suspendedPainting) {
2663 impl->pageProxy->suspendPainting();
2664 impl->suspendedPainting = true;
2668 void _ewk_view_resume_painting(Evas_Object* ewkView)
2670 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2671 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2673 if (impl->suspendedPainting) {
2674 impl->pageProxy->resumePainting();
2675 impl->suspendedPainting = false;
2679 void ewk_view_suspend(Evas_Object* ewkView)
2681 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2682 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2684 if (impl->pageProxy->estimatedProgress() < 1.0) {
2685 impl->suspendRequested = true;
2688 impl->suspendRequested = false;
2690 _ewk_view_suspend_painting(ewkView);
2692 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2693 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2694 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2696 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2697 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2698 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2699 // will be suspended again.
2700 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2701 // the ActiveDOMObject.
2702 if (!impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2703 impl->pageProxy->suspendAnimations();
2704 impl->pageProxy->suspendJavaScriptAndResource();
2705 impl->suspendedResources = true;
2708 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2709 impl->pageProxy->suspendPlugin();
2713 void ewk_view_resume(Evas_Object* ewkView)
2715 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
2716 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
2718 if (impl->suspendRequested) {
2719 impl->suspendRequested = false;
2723 _ewk_view_resume_painting(ewkView);
2725 // FIXME Workaround for suspend/resume while javascript popup is displayed.
2726 // condition ' && !private->isWaitingForJavaScriptPopupReply' is added to
2727 // skip suspendJavaScriptAndResource to prevent multiple ActiveDOMObject
2729 // During the javascript popup is displayed, PageGroupLoadDeferrer is activated,
2730 // which suspends resource loading and scheduled tasks, including ActiveDOMObject.
2731 // When ewk_view_suspend() is called during the javascript popup, scheduled tasks
2732 // will be suspended again.
2733 // Multiple suspend of ActiveDOMObject makes unintended suspend/resume status of
2734 // the ActiveDOMObject.
2735 if (impl->suspendedResources && (!impl->isWaitingForJavaScriptPopupReply || !impl->isWaitingForApplicationCachePermission || !impl->isWaitingForExceededQuotaPopupReply)) {
2736 impl->pageProxy->resumeAnimations();
2737 impl->pageProxy->resumeJavaScriptAndResource();
2738 impl->suspendedResources = false;
2741 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
2742 impl->pageProxy->resumePlugin();
2746 Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
2748 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2749 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2750 EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
2752 ResourceRequest request(String::fromUTF8(url));
2755 case EWK_HTTP_METHOD_GET:
2756 request.setHTTPMethod("GET");
2758 case EWK_HTTP_METHOD_HEAD:
2759 request.setHTTPMethod("HEAD");
2761 case EWK_HTTP_METHOD_POST:
2762 request.setHTTPMethod("POST");
2764 case EWK_HTTP_METHOD_PUT:
2765 request.setHTTPMethod("PUT");
2767 case EWK_HTTP_METHOD_DELETE:
2768 request.setHTTPMethod("DELETE");
2775 Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
2777 while (eina_iterator_next(it, &data)) {
2778 Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
2779 const char* name = static_cast<const char*>(t->key);
2780 const char* value = static_cast<const char*>(t->data);
2781 request.addHTTPHeaderField(name, value);
2783 eina_iterator_free(it);
2787 request.setHTTPBody(FormData::create(body));
2789 WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
2790 WKPageLoadURLRequest(toAPI(impl->pageProxy.get()), urlRequest.get());
2795 Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
2797 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2798 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2800 WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
2801 WKPageLoadPlainTextString(toAPI(impl->pageProxy.get()), plainTextRef.get());
2806 Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
2808 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2809 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2810 EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
2812 if (contentsSize == 0)
2815 String mimeTypeString;
2817 mimeTypeString = String::fromUTF8(mimeType);
2819 mimeTypeString = String::fromUTF8("text/html");
2821 String encodingString;
2823 encodingString = String::fromUTF8(encoding);
2825 encodingString = String::fromUTF8("UTF-8");
2827 String baseUriString;
2829 baseUriString = String::fromUTF8(baseUri);
2831 baseUriString = String::fromUTF8("about:blank");
2833 WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
2834 impl->pageProxy->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
2839 Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
2841 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2842 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2844 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
2845 WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
2847 WKPageLoadHTMLString(toAPI(impl->pageProxy.get()), htmlString.get(), baseURL.get());
2852 Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
2854 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2855 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2857 TIZEN_LOGI("initialState (%d)", initialState);
2858 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
2859 WKPageSetPageVisibility(toAPI(impl->pageProxy.get()), static_cast<WKPageVisibilityState>(pageVisibilityState), initialState);
2866 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
2868 EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
2870 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2871 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2873 impl->userAgent = userAgent;
2875 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
2876 WKPageSetCustomUserAgent(toAPI(impl->pageProxy.get()), userAgentString.get());
2881 const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
2883 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2884 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2887 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
2889 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
2890 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2891 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
2892 impl->userAgent = buffer.get();
2894 if (!impl->userAgent) {
2895 WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(impl->pageProxy.get())));
2897 int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
2898 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2899 WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
2900 impl->userAgent = buffer.get();
2904 return impl->userAgent;
2908 Eina_Bool ewk_view_application_name_for_user_agent_set(Evas_Object* ewkView, const char* applicationName)
2910 EINA_SAFETY_ON_NULL_RETURN_VAL(applicationName, false);
2912 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2913 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2915 WKRetainPtr<WKStringRef> applicationNameString(AdoptWK, WKStringCreateWithUTF8CString(applicationName));
2916 WKPageSetApplicationNameForUserAgent(toAPI(impl->pageProxy.get()), applicationNameString.get());
2921 const char* ewk_view_application_name_for_user_agent_get(const Evas_Object* ewkView)
2923 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
2924 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
2926 WKRetainPtr<WKStringRef> applicationNameString(AdoptWK, WKPageCopyApplicationNameForUserAgent(toAPI(impl->pageProxy.get())));
2928 int length = WKStringGetMaximumUTF8CStringSize(applicationNameString.get());
2929 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
2930 WKStringGetUTF8CString(applicationNameString.get(), buffer.get(), length);
2931 impl->applicationName = buffer.get();
2933 return impl->applicationName;
2937 Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
2939 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2940 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2941 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2943 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2944 WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
2946 WKPageAddCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get(), customHeaderValue.get());
2949 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2954 Eina_Bool ewk_view_custom_header_remove(const Evas_Object* ewkView, const char* name)
2956 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2957 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2958 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2960 WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
2962 WKPageRemoveCustomHeader(toAPI(impl->pageProxy.get()), customHeaderName.get());
2965 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2970 Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
2972 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2973 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2974 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2976 WKPageClearCustomHeaders(toAPI(impl->pageProxy.get()));
2979 ERR("TIZEN_CUSTOM_HEADERS not enabled!");
2984 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
2985 Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
2987 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
2988 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
2990 #if ENABLE(TIZEN_DRAG_SUPPORT)
2991 if (impl->pageClient->isDragMode())
2992 impl->pageClient->setDragMode(false);
2995 impl->pageClient->setIsVisible(enable);
3000 #if ENABLE(TIZEN_BACKGROUND_DISK_CACHE)
3001 Eina_Bool ewk_view_foreground_set(Evas_Object* ewkView, Eina_Bool enable)
3007 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
3009 EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
3011 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3012 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3015 rect.origin.x = viewArea.x;
3016 rect.origin.y = viewArea.y;
3017 rect.size.width = viewArea.w;
3018 rect.size.height = viewArea.h;
3020 WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(impl->pageProxy.get()), rect, scaleFactor));
3021 if (!snapshot.get())
3024 RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
3026 Evas_Object* screenshotImage = evas_object_image_add(canvas);
3027 int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
3028 int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
3029 evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
3030 evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
3032 uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
3034 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)));
3035 RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
3037 cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
3038 cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
3039 cairo_fill(cairo.get());
3041 evas_object_image_smooth_scale_set(screenshotImage, true);
3042 evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
3043 evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
3044 evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
3045 evas_object_image_data_set(screenshotImage, pixels);
3047 return screenshotImage;
3050 unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
3052 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
3053 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
3054 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, 0);
3056 return impl->pageProxy->startInspectorServer(port);
3058 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
3063 Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
3065 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
3066 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
3067 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
3069 return impl->pageProxy->stopInspectorServer();
3071 LOG_ERROR("TIZEN_REMOTE_WEB_INSPECTOR is disabled.\n");
3076 void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
3078 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3079 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3081 WKPageScrollBy(toAPI(impl->pageProxy.get()), toAPI(IntSize(deltaX, deltaY)));
3084 Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
3090 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3091 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3093 IntPoint scrollPosition = impl->pageClient->scrollPosition();
3095 *x = scrollPosition.x();
3097 *y = scrollPosition.y();
3102 Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
3104 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3105 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3107 impl->pageProxy->scrollMainFrameTo(IntPoint(x, y));
3111 Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
3117 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3118 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3120 IntSize contentsSize = impl->pageProxy->contentsSize();
3121 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
3122 contentsSize.scale(impl->pageClient->scaleFactor());
3125 if (width && contentsSize.width() > smartData->view.w)
3126 *width = contentsSize.width() - smartData->view.w;
3127 if (height && contentsSize.height() > smartData->view.h)
3128 *height = contentsSize.height() - smartData->view.h;
3132 #if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
3133 void ewkViewNotifyPopupReplyWaitingState(Evas_Object* ewkView, bool isWaiting)
3136 evas_object_smart_callback_call(ewkView, "popup,reply,wait,start", 0);
3138 evas_object_smart_callback_call(ewkView, "popup,reply,wait,finish", 0);
3142 bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
3144 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3145 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3146 if (!impl->alertContext || !impl->alertContext->javascriptAlertCallback)
3148 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->alertContext->ewkView == ewkView, false);
3150 impl->isWaitingForJavaScriptPopupReply = true;
3151 int length = WKStringGetMaximumUTF8CStringSize(alertText);
3152 OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
3153 WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
3154 return impl->alertContext->javascriptAlertCallback(impl->alertContext->ewkView, alertTextBuffer.get(), impl->alertContext->userData) == EINA_TRUE;
3157 bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
3159 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3160 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3161 if (!impl->confirmContext || !impl->confirmContext->javascriptConfirmCallback)
3163 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->confirmContext->ewkView == ewkView, false);
3165 impl->isWaitingForJavaScriptPopupReply = true;
3166 int length = WKStringGetMaximumUTF8CStringSize(message);
3167 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3168 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3169 return impl->confirmContext->javascriptConfirmCallback(impl->confirmContext->ewkView, messageBuffer.get(), impl->confirmContext->userData) == EINA_TRUE;
3172 bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
3174 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3175 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3176 if (!impl->promptContext || !impl->promptContext->javascriptPromptCallback)
3178 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->promptContext->ewkView == ewkView, false);
3180 impl->isWaitingForJavaScriptPopupReply = true;
3181 int length = WKStringGetMaximumUTF8CStringSize(message);
3182 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3183 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3184 length = WKStringGetMaximumUTF8CStringSize(defaultValue);
3185 OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
3186 WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
3187 return impl->promptContext->javascriptPromptCallback(impl->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), impl->promptContext->userData) == EINA_TRUE;
3190 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3191 bool ewk_view_run_before_unload_confirm_panel(Evas_Object* ewkView, WKStringRef message)
3193 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3194 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3195 if (!impl->beforeUnloadConfirmPanelContext || !impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback)
3197 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->beforeUnloadConfirmPanelContext->ewkView == ewkView, false);
3199 impl->isWaitingForJavaScriptPopupReply = true;
3200 int length = WKStringGetMaximumUTF8CStringSize(message);
3201 OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
3202 WKStringGetUTF8CString(message, messageBuffer.get(), length);
3203 bool result = impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback(impl->beforeUnloadConfirmPanelContext->ewkView, messageBuffer.get(), impl->beforeUnloadConfirmPanelContext->userData) == EINA_TRUE;
3208 bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
3210 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3211 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3212 if (!impl->openpanelContext || !impl->openpanelContext->openPanelCallback)
3215 EINA_SAFETY_ON_FALSE_RETURN_VAL(impl->openpanelContext->ewkView == ewkView, false);
3217 impl->openPanelListener = listener;
3219 Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
3220 Eina_List* acceptedMimeTypes = 0;
3221 WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
3222 size_t len = WKArrayGetSize(array.get());
3223 for (size_t i = 0; i < len; i++) {
3224 WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
3225 if (WKGetTypeID(item) != WKStringGetTypeID())
3227 WKStringRef mime = static_cast<WKStringRef>(item);
3228 int length = WKStringGetMaximumUTF8CStringSize(mime);
3229 char* buffer = new char[length];
3230 WKStringGetUTF8CString(mime, buffer, length);
3231 acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
3233 const char* capture = 0;
3234 #if ENABLE(MEDIA_CAPTURE)
3235 WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
3236 capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
3238 bool result = impl->openpanelContext->openPanelCallback(impl->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
3239 if (!acceptedMimeTypes)
3244 EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
3245 delete[] (char*)data;
3246 eina_list_free(acceptedMimeTypes);
3250 void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
3252 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3253 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3255 if (!impl->alertContext)
3256 impl->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3257 impl->alertContext->javascriptAlertCallback = callback;
3258 impl->alertContext->ewkView = ewkView;
3259 impl->alertContext->userData = userData;
3262 void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
3264 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3265 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3267 WKPageReplyJavaScriptAlert(toAPI(impl->page()));
3268 impl->isWaitingForJavaScriptPopupReply = false;
3271 void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
3273 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3274 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3276 if (!impl->confirmContext)
3277 impl->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3278 impl->confirmContext->javascriptConfirmCallback = callback;
3279 impl->confirmContext->ewkView = ewkView;
3280 impl->confirmContext->userData = userData;
3283 void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
3285 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3286 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3288 WKPageReplyJavaScriptConfirm(toAPI(impl->page()), result == EINA_TRUE);
3289 impl->isWaitingForJavaScriptPopupReply = false;
3292 void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
3294 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3295 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3297 if (!impl->promptContext)
3298 impl->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3299 impl->promptContext->javascriptPromptCallback = callback;
3300 impl->promptContext->ewkView = ewkView;
3301 impl->promptContext->userData = userData;
3304 void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
3306 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3307 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3309 WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
3310 WKPageReplyJavaScriptPrompt(toAPI(impl->page()), result ? resultString.get() : 0);
3311 impl->isWaitingForJavaScriptPopupReply = false;
3314 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
3315 void ewk_view_before_unload_confirm_panel_callback_set(Evas_Object* ewkView, Ewk_View_Before_Unload_Confirm_Panel_Callback callback, void* userData)
3317 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3318 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3320 if (!impl->beforeUnloadConfirmPanelContext)
3321 impl->beforeUnloadConfirmPanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3322 impl->beforeUnloadConfirmPanelContext->beforeUnloadConfirmPanelCallback = callback;
3323 impl->beforeUnloadConfirmPanelContext->ewkView = ewkView;
3324 impl->beforeUnloadConfirmPanelContext->userData = userData;
3327 void ewk_view_before_unload_confirm_panel_reply(Evas_Object* ewkView, Eina_Bool result)
3329 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3330 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3332 WKPageReplyBeforeUnloadConfirmPanel(toAPI(impl->page()), result == EINA_TRUE);
3333 impl->isWaitingForJavaScriptPopupReply = false;
3337 void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
3339 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3340 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3342 if (!impl->openpanelContext)
3343 impl->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
3345 impl->openpanelContext->openPanelCallback = callback;
3346 impl->openpanelContext->ewkView = ewkView;
3347 impl->openpanelContext->userData = userData;
3350 void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
3352 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3353 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3355 if (!impl->openPanelListener)
3358 unsigned int size = eina_list_count(fileUrls);
3359 if ((result == EINA_FALSE) || (size == 0)) {
3360 WKOpenPanelResultListenerCancel(impl->openPanelListener);
3361 impl->openPanelListener = 0;
3365 WKTypeRef* items = new WKTypeRef[size];
3369 KURL base(KURL(), "file://");
3370 EINA_LIST_FOREACH(fileUrls, list, data) {
3371 KURL url(base, String::fromUTF8(static_cast<char*>(data)));
3372 items[i++] = WKURLCreateWithUTF8CString(url.string().utf8().data());
3374 WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
3375 WKOpenPanelResultListenerChooseFiles(impl->openPanelListener, filesArray.get());
3376 impl->openPanelListener = 0;
3378 eina_list_free(fileUrls);
3381 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3382 static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
3384 EINA_SAFETY_ON_NULL_RETURN(capable);
3385 EINA_SAFETY_ON_NULL_RETURN(context);
3387 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3389 ASSERT(webAppContext->webAppCapableCallback);
3391 TIZEN_LOGI("webAppCapableCallback exist. capable(%b)", capable);
3393 webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
3395 webAppContext->webAppCapableCallback(0, webAppContext->userData);
3397 delete webAppContext;
3400 static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
3402 EINA_SAFETY_ON_NULL_RETURN(iconURL);
3403 EINA_SAFETY_ON_NULL_RETURN(context);
3405 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3407 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3408 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3410 ASSERT(webAppContext->webAppIconURLCallback);
3413 impl->webAppIconURL = toImpl(iconURL)->string().utf8().data();
3414 webAppContext->webAppIconURLCallback(impl->webAppIconURL, webAppContext->userData);
3416 webAppContext->webAppIconURLCallback(0, webAppContext->userData);
3418 delete webAppContext;
3421 static void didGetWebAppIconURLs(WKDictionaryRef iconURLs, WKErrorRef, void* context)
3423 EINA_SAFETY_ON_NULL_RETURN(iconURLs);
3424 EINA_SAFETY_ON_NULL_RETURN(context);
3426 Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
3428 EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
3429 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3431 ASSERT(webAppContext->webAppIconURLsCallback);
3433 if (impl->webAppIconURLs) {
3435 EINA_LIST_FREE(impl->webAppIconURLs, data)
3436 ewkWebAppIconDataDelete(static_cast<Ewk_Web_App_Icon_Data*>(data));
3439 WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(iconURLs));
3440 size_t iconURLCount = WKArrayGetSize(wkKeys.get());
3441 for (size_t i = 0; i < iconURLCount; i++) {
3442 WKStringRef urlRef = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
3443 WKStringRef sizeRef = static_cast<WKStringRef>(WKDictionaryGetItemForKey(iconURLs, urlRef));
3444 impl->webAppIconURLs = eina_list_append(impl->webAppIconURLs, ewkWebAppIconDataCreate(sizeRef, urlRef));
3446 TIZEN_LOGI("webAppIconURLsCallback exist. found %d icon urls", iconURLCount);
3448 webAppContext->webAppIconURLsCallback(impl->webAppIconURLs, webAppContext->userData);
3449 delete webAppContext;
3453 Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
3455 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3456 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3457 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3458 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3460 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3461 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3462 context->webAppCapableCallback = callback;
3463 context->ewkView = ewkView;
3464 context->userData = userData;
3466 WKPageGetWebAppCapable(toAPI(impl->pageProxy.get()), context, didGetWebAppCapable);
3474 Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
3476 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3477 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3478 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3479 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3481 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3482 context->webAppIconURLCallback = callback;
3483 context->ewkView = ewkView;
3484 context->userData = userData;
3486 WKPageGetWebAppIconURL(toAPI(impl->page()), context, didGetWebAppIconURL);
3494 Eina_Bool ewk_view_web_application_icon_urls_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URLs_Get_Callback callback, void* userData)
3496 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3497 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3498 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3499 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3501 TIZEN_LOGI("callback(%d), userData(%d)", callback, userData);
3502 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3503 context->webAppIconURLsCallback = callback;
3504 context->ewkView = ewkView;
3505 context->userData = userData;
3507 WKPageGetWebAppIconURLs(toAPI(impl->page()), context, didGetWebAppIconURLs);
3511 UNUSED_PARAM(ewkView);
3512 UNUSED_PARAM(callback);
3513 UNUSED_PARAM(userData);
3518 Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
3520 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3521 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3522 EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
3524 WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
3525 WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
3526 WKPageExecuteCommandWithArgument(toAPI(impl->pageProxy.get()), commandString.get(), valueString.get());
3531 Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
3538 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3539 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3541 IntSize contentsSize = impl->pageProxy->contentsSize();
3544 *width = contentsSize.width();
3546 *height = contentsSize.height();
3551 Eina_Bool ewk_view_contents_pdf_get_temp(Evas_Object* ewkView, int width, int height, const char* fileName)
3553 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3554 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3555 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3556 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3558 IntSize contentsSize = impl->pageProxy->contentsSize();
3559 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3567 Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, int width, int height, const char* fileName)
3569 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
3570 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3571 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3572 EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
3574 IntSize contentsSize = impl->pageProxy->contentsSize();
3575 WKPageGetSnapshotPdfFile(toAPI(impl->pageProxy.get()), toAPI(IntSize(width, height)), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
3583 static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
3585 EINA_SAFETY_ON_NULL_RETURN(context);
3586 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3588 if (!callbackContext->scriptExecuteCallback) {
3589 delete callbackContext;
3593 JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
3596 JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
3597 JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
3598 size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
3599 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3600 JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
3601 callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3603 callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
3605 delete callbackContext;
3608 Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
3610 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3611 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3612 EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
3613 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3615 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3616 context->scriptExecuteCallback = callback;
3617 context->ewkView = ewkView;
3618 context->userData = user_data;
3619 WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
3620 WKPageRunJavaScriptInMainFrame(toAPI(impl->pageProxy.get()), scriptString.get(), context, runJavaScriptCallback);
3625 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3626 static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
3628 Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
3631 storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
3633 storageContext->webStorageQuotaCallback(0, storageContext->userData);
3635 delete storageContext;
3639 Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
3641 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
3642 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3643 EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
3644 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3645 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3646 TIZEN_LOGI("resultCallback (%p)", resultCallback);
3648 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3649 context->webStorageQuotaCallback = resultCallback;
3650 context->userData = userData;
3652 WKPageRef pageRef = toAPI(impl->page());
3653 WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
3661 Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
3663 #if ENABLE(TIZEN_WEB_STORAGE)
3664 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
3665 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3666 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3668 TIZEN_LOGI("quota (%d)", quota);
3669 WKPageRef pageRef = toAPI(impl->page());
3670 WKPageSetWebStorageQuota(pageRef, quota);
3678 static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
3680 EINA_SAFETY_ON_NULL_RETURN(context);
3681 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3683 ASSERT(callbackContext->plainTextGetCallback);
3686 size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
3687 OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
3688 WKStringGetUTF8CString(plain_text, buffer.get(), length);
3690 callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
3692 callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
3694 delete callbackContext;
3697 Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
3699 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3700 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3701 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3702 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->pageClient, false);
3704 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3705 context->plainTextGetCallback = callback;
3706 context->ewkView = ewkView;
3707 context->userData = user_data;
3708 WKPageGetContentsAsString(toAPI(impl->pageProxy.get()), context, getContentsAsStringCallback);
3713 #if ENABLE(TIZEN_SUPPORT_MHTML)
3716 * Callback function used for ewk_view_mhtml_data_get().
3718 static void getContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
3720 EINA_SAFETY_ON_NULL_RETURN(context);
3721 Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
3723 ASSERT(callbackContext->mhtmlDataGetCallback);
3725 callbackContext->mhtmlDataGetCallback(callbackContext->ewkView, reinterpret_cast<const char*>(WKDataGetBytes(wkData)), callbackContext->userData);
3727 delete callbackContext;
3730 Eina_Bool ewk_view_mhtml_data_get(Evas_Object* ewkView, Ewk_View_MHTML_Data_Get_Callback callback, void* user_data)
3732 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
3733 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3734 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3736 Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
3737 context->mhtmlDataGetCallback = callback;
3738 context->ewkView = ewkView;
3739 context->userData = user_data;
3741 WKPageGetContentsAsMHTMLData(toAPI(impl->page()), false, context, getContentsAsMHTMLCallback);
3745 #endif // ENABLE(TIZEN_SUPPORT_MHTML)
3747 Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
3749 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
3750 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
3751 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
3753 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(x, y));
3754 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest, hitTestMode);
3755 Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
3763 Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
3765 EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
3766 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3767 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3768 WebPageProxy* page = impl->page();
3769 EINA_SAFETY_ON_NULL_RETURN_VAL(page, 0);
3771 return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(page)));
3774 Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3779 Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
3781 #if ENABLE(TIZEN_NOTIFICATIONS)
3782 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3783 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3784 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->context, false);
3786 TIZEN_LOGI("ewkNotifications (%p)", ewkNotifications);
3787 if (!eina_list_count(ewkNotifications))
3790 Eina_List* listIterator = 0;
3792 Vector<WKTypeRef> ids;
3793 EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
3794 Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
3795 WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
3797 impl->notifications = eina_list_remove(impl->notifications, notification);
3800 WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
3801 WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(impl->context->wkContext());
3802 WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
3803 ewkNotificationDeleteNotificationList(ewkNotifications);
3811 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3812 static Eina_List* createPopupMenuList(const Vector<WebPopupItem>& items)
3814 Eina_List* popupItems = 0;
3815 size_t size = items.size();
3816 for (size_t i = 0; i < size; ++i)
3817 popupItems = eina_list_append(popupItems, Ewk_Popup_Menu_Item::create(items[i]).leakPtr());
3818 TIZEN_LOGI("size : %d", size);
3822 static void releasePopupMenuList(Eina_List* popupMenuItems)
3824 if (!popupMenuItems)
3828 EINA_LIST_FREE(popupMenuItems, item)
3829 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3833 Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
3835 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3836 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3837 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
3839 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3842 if (!impl->popupMenuProxy)
3845 impl->popupMenuProxy = 0;
3847 if (smartData->api->popup_menu_hide)
3848 smartData->api->popup_menu_hide(smartData);
3849 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3850 ewk_view_touch_events_enabled_set(ewkView, true);
3852 releasePopupMenuList(impl->popupMenuItems);
3853 impl->popupMenuItems = 0;
3856 EINA_LIST_FREE(impl->popupMenuItems, item)
3857 delete static_cast<Ewk_Popup_Menu_Item*>(item);
3863 Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
3865 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3866 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3867 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3869 TIZEN_LOGI("proxy : %p / index : %d", impl->popupMenuProxy, selectedIndex);
3871 if (!impl->popupMenuItems)
3875 if (selectedIndex >= eina_list_count(impl->popupMenuItems))
3878 impl->popupMenuProxy->valueChanged(selectedIndex);
3883 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3884 void ewk_view_popup_menu_update(Evas_Object* ewkView, TextDirection textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
3886 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3887 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3888 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
3889 TIZEN_LOGI("proxy : %p", impl->popupMenuProxy);
3891 if (!impl->popupMenuProxy)
3894 if (!smartData->api->popup_menu_update)
3897 releasePopupMenuList(impl->popupMenuItems);
3898 impl->popupMenuItems = createPopupMenuList(items);
3900 // TODO: Instead of passing a dummy rect, updated rect should be coming from WebProcess
3901 smartData->api->popup_menu_update(smartData, IntRect(), static_cast<Ewk_Text_Direction>(textDirection), impl->popupMenuItems, selectedIndex);
3905 #if ENABLE(TIZEN_MULTIPLE_SELECT)
3906 Eina_Bool ewk_view_popup_menu_multiple_select(Evas_Object* ewkView, Eina_Inarray* changeList)
3908 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3909 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3910 EINA_SAFETY_ON_NULL_RETURN_VAL(impl->popupMenuProxy, false);
3912 Vector<int> selectedIndex;
3914 if (!impl->popupMenuItems)
3919 itr = eina_inarray_iterator_new(changeList);
3920 EINA_ITERATOR_FOREACH(itr, data)
3922 int* pData = static_cast<int*>(data);
3923 selectedIndex.append(*pData);
3925 eina_iterator_free(itr);
3927 impl->popupMenuProxy->multipleValueChanged(selectedIndex);
3932 void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
3934 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
3935 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
3936 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
3937 TIZEN_LOGI("orientation : %d", orientation);
3939 if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
3942 if (impl->orientation == orientation)
3945 impl->orientation = orientation;
3947 impl->pageProxy->sendOrientationChangeEvent(orientation);
3951 void ewkViewFrameRendered(Evas_Object* ewkView)
3953 evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
3956 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3957 Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
3959 return ewk_settings_text_selection_enabled_set(ewk_view_settings_get(ewkView), enable);
3962 Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
3964 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
3965 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
3967 IntRect leftSelectionRect;
3968 IntRect rightSelectionRect;
3969 if (!impl->pageProxy->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
3982 AffineTransform contentToScreen = impl->transformToScene();
3983 leftSelectionRect = contentToScreen.mapRect(leftSelectionRect);
3984 rightSelectionRect = contentToScreen.mapRect(rightSelectionRect);
3986 leftRect->x = leftSelectionRect.x();
3987 leftRect->y = leftSelectionRect.y();
3988 leftRect->w = leftSelectionRect.width();
3989 leftRect->h = leftSelectionRect.height();
3991 rightRect->x = rightSelectionRect.x();
3992 rightRect->y = rightSelectionRect.y();
3993 rightRect->w = rightSelectionRect.width();
3994 rightRect->h = rightSelectionRect.height();
3999 const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
4001 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4002 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
4004 const CString selectedString = impl->pageProxy->getSelectionText().utf8();
4005 impl->selectedText = selectedString.data();
4007 return impl->selectedText;
4010 Eina_Bool ewk_view_auto_clear_text_selection_mode_set(Evas_Object* ewkView, Eina_Bool enable)
4012 return ewk_settings_clear_text_selection_automatically_set(ewk_view_settings_get(ewkView), enable);
4015 Eina_Bool ewk_view_auto_clear_text_selection_mode_get(Evas_Object* ewkView)
4017 return ewk_settings_clear_text_selection_automatically_get(ewk_view_settings_get(ewkView));
4020 Eina_Bool ewk_view_text_selection_clear(Evas_Object* ewkView)
4022 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4023 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4025 bool isTextSelectionMode = impl->pageClient->isTextSelectionMode();
4026 impl->pageClient->setIsTextSelectionMode(false);
4027 return isTextSelectionMode;
4030 Eina_Bool ewk_view_text_selection_range_clear(Evas_Object* ewkView)
4032 return ewk_view_text_selection_clear(ewkView);
4034 #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4036 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4037 void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
4039 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4040 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4041 EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
4043 smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
4047 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
4048 void ewkViewGetWindowFrame(Evas_Object* ewkView, int *x, int *y, int *w, int *h)
4050 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4051 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4052 IntPoint drawingPosition = (IntPoint)(impl->pageClient->visibleContentRect().location() - impl->pageClient->scrollPosition());
4054 *x = drawingPosition.x();
4056 *y = drawingPosition.y();
4058 *w = impl->pageClient->visibleContentRect().width();
4060 *h = impl->pageClient->visibleContentRect().height();
4064 void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
4066 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4067 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4068 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4070 impl->pageProxy->setFocusedInputElementValue(String::fromUTF8(value));
4071 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4074 const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
4076 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4077 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
4078 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, 0);
4080 impl->inputValue = impl->pageProxy->getFocusedInputElementValue().utf8().data();
4081 return impl->inputValue;
4084 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
4087 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4088 void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
4090 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4091 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4092 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4093 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
4096 ewkViewDataListHideRequest(ewkView, inputType);
4098 for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
4100 impl->dataList = eina_list_append(impl->dataList, eina_stringshare_add(value.utf8().data()));
4103 smartData->api->data_list_show(smartData, inputType, impl->dataList);
4106 void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
4108 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4109 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4110 EINA_SAFETY_ON_NULL_RETURN(impl->dataList);
4111 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4112 EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
4114 impl->deleteDataList();
4116 smartData->api->data_list_hide(smartData, inputType);
4120 void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
4122 #if ENABLE(TIZEN_DATALIST_ELEMENT)
4123 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4124 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4126 impl->deleteDataList();
4128 ewk_view_focused_input_element_value_set(ewkView, value);
4132 Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
4134 #if ENABLE(TIZEN_GESTURE)
4135 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4136 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4137 return impl->holdHorizontalPanning;
4143 void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4145 #if ENABLE(TIZEN_GESTURE)
4146 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4147 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4148 impl->holdHorizontalPanning = hold;
4152 Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
4154 #if ENABLE(TIZEN_GESTURE)
4155 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4156 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4157 return impl->holdVerticalPanning;
4163 void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
4165 #if ENABLE(TIZEN_GESTURE)
4166 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4167 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4168 impl->holdVerticalPanning = hold;
4172 void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
4174 #if ENABLE(TIZEN_GESTURE)
4175 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4176 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4178 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4179 if (impl->focusRing() && wasHandled)
4180 impl->focusRing()->hide();
4181 #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
4183 if (impl->mouseEventsEnabled())
4186 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4187 if (wasHandled && impl->pageClient->isTextSelectionMode()) {
4188 if (type == WebEvent::TouchStart)
4189 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4190 else if (type == WebEvent::TouchMove)
4191 impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
4192 else if (type == WebEvent::TouchEnd)
4193 impl->pageClient->requestToShowTextSelectionHandlesAndContextMenu();
4197 // We have to check TouchStart, TouchMove and TouchEnd with handled.
4198 // The Pan and Flick will be enabled if Touch Start was not handled,
4199 // and Touch Move was not handled or did not occur.
4200 // Tap will be enabled if Touch Start and End was not handled
4201 // and Touch Move did not occur.
4202 // The gestures are disabled as a default.
4203 // o: handled, x: not handled
4204 // ------------------------------------------------------------
4205 // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
4206 // ------------------------------------------------------------
4207 // o | o or x | o or x || disable | disable
4208 // x | o | o or x || disable | disable
4209 // x | x | o or x || disable | enable
4210 // x |not occured | x || enable | enable
4211 // ------------------------------------------------------------
4212 if (type == WebEvent::TouchStart) {
4213 impl->gestureClient->setGestureEnabled(!wasHandled);
4214 impl->wasHandledTouchStart = wasHandled;
4216 // Initialize wasHandledTouchMove to true and notify that to the application
4217 // to prevent applications scrolling at the beginning of touch.
4218 impl->wasHandledTouchMove = true;
4219 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&impl->wasHandledTouchMove));
4220 } else if (type == WebEvent::TouchMove) {
4221 impl->gestureClient->setMovingEnabled(!wasHandled);
4223 // We have to set wasHandled to true if touchstart was handled even though current touchmove was not handled.
4224 if (impl->wasHandledTouchStart)
4227 // Notify the result of touchmove to applications when handled value is changed
4228 // in order to make applications to choose whether scrolling its scrollable objects or not.
4229 if (impl->wasHandledTouchMove != wasHandled)
4230 evas_object_smart_callback_call(ewkView, "touchmove,handled", static_cast<void*>(&wasHandled));
4231 impl->wasHandledTouchMove = wasHandled;
4232 } else if (type == WebEvent::TouchEnd && !impl->exceedTouchMoveThreshold) {
4234 impl->gestureClient->setMovingEnabled(!wasHandled);
4235 impl->gestureClient->setTapEnabled(!wasHandled);
4237 #if ENABLE(TIZEN_ISF_PORT)
4238 else if (impl->pageProxy->isViewVisible()) {
4239 IntPoint pointForHitTest = impl->transformFromScene().mapPoint(IntPoint(impl->touchDownPoint.x, impl->touchDownPoint.y));
4240 WebHitTestResult::Data hitTestResultData = impl->pageProxy->hitTestResultAtPoint(pointForHitTest);
4241 if (hitTestResultData.isContentEditable && impl->inputMethodContext())
4242 impl->inputMethodContext()->updateTextInputStateByUserAction(true);
4249 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
4250 void ewkViewTextStyleState(Evas_Object* ewkView, const IntPoint& startPoint, const IntPoint& endPoint)
4252 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4253 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4255 EditorState editorState = impl->page()->editorState();
4256 Ewk_Text_Style* textStyle = ewkTextStyleCreate(editorState, startPoint, endPoint);
4257 evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
4258 ewkTextStyleDelete(textStyle);
4262 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
4263 bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
4265 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4266 EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
4268 TIZEN_LOGI("willLockOrientation (%d)", willLockOrientation);
4269 if (!smartData->api->orientation_lock) {
4274 return smartData->api->orientation_lock(smartData, willLockOrientation);
4277 void ewk_view_orientation_unlock(Evas_Object* ewkView)
4279 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4280 EINA_SAFETY_ON_NULL_RETURN(smartData->api);
4282 TIZEN_LOGI("ewkView (%p)", ewkView);
4283 if (!smartData->api->orientation_unlock) {
4288 smartData->api->orientation_unlock(smartData);
4292 void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
4294 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4295 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4296 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4297 TIZEN_LOGI("callbacks: %p / data: %p", func, data);
4299 impl->orientationLock.callback = func;
4300 impl->orientationLock.data = data;
4304 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
4305 Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
4307 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl, false);
4308 TIZEN_LOGI("locked orientations : %d", orientations);
4310 if (impl->orientationLock.callback)
4311 return impl->orientationLock.callback(sd->self, true, orientations, impl->orientationLock.data);
4316 void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
4318 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4319 TIZEN_LOGI("unlock is requested");
4321 if (impl->orientationLock.callback)
4322 impl->orientationLock.callback(sd->self, false, 0, impl->orientationLock.data);
4326 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
4327 bool ewk_view_is_opengl_backend(Evas_Object* ewkView)
4329 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4331 Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
4332 const char *engine = ecore_evas_engine_name_get(ee);
4333 if (engine && !strcmp(engine, "opengl_x11"))
4339 void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
4341 #if ENABLE(TIZEN_GESTURE)
4342 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4343 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4345 impl->gestureClient->setZoomableArea(target, area);
4349 #if ENABLE(TIZEN_BACKFORWARD_LIST_CLEAR)
4350 void ewk_view_back_forward_list_clear(const Evas_Object* ewkView)
4352 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4353 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4355 WKBackForwardListClearBackForwardList(WKPageGetBackForwardList(toAPI(impl->pageProxy.get())));
4359 #if ENABLE(TIZEN_SIGNAL_APP_BACK_FORWARD_LIST_CHANGED)
4360 void ewkViewBackForwardListChanged(Evas_Object* ewkView)
4362 evas_object_smart_callback_call(ewkView, "back,forward,list,changed", 0);
4366 #if ENABLE(TIZEN_ICON_DATABASE)
4367 void ewkViewIconReceived(Evas_Object* ewkView)
4371 evas_object_smart_callback_call(ewkView, "icon,received", 0);
4375 #endif // #if OS(TIZEN)
4377 Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers)
4379 #if ENABLE(TOUCH_EVENTS)
4380 EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
4381 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4382 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4384 #if ENABLE(TIZEN_FOCUS_UI)
4385 if (type == EWK_TOUCH_START)
4386 impl->page()->setSpatialNavigationEnabled(false);
4389 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) && ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
4390 if (impl->pageClient->isTextSelectionMode() && eina_list_count(points) == 1) {
4391 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4392 IntPoint handlePoint(point->x, point->y);
4394 if (type == EWK_TOUCH_START)
4395 impl->pageClient->textSelectonHandleDown(handlePoint);
4396 else if (type == EWK_TOUCH_MOVE)
4397 impl->pageClient->textSelectonHandleMove(handlePoint);
4399 impl->pageClient->textSelectonHandleUp();
4401 if (impl->pageClient->isTextSelectionHandleDowned())
4406 #if ENABLE(TIZEN_GESTURE)
4407 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
4408 // We don't want to process touch event when context menu is shown.
4409 if ((impl->pageClient->isContextMenuVisible() && type != EWK_TOUCH_CANCEL)
4410 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4411 && !impl->pageClient->isTextSelectionMode()
4416 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
4417 if (impl->pageClient->isTextSelectionDowned() && type != EWK_TOUCH_CANCEL)
4421 if (type == EWK_TOUCH_START) {
4422 if (eina_list_count(points) == 1) {
4423 impl->gestureClient->reset();
4424 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4425 impl->touchDownPoint.x = point->x;
4426 impl->touchDownPoint.y = point->y;
4427 impl->exceedTouchMoveThreshold = false;
4429 } else if (type == EWK_TOUCH_MOVE && !impl->exceedTouchMoveThreshold) {
4430 if (eina_list_count(points) == 1) {
4431 unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
4432 Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(eina_list_data_get(points));
4433 int diffX = impl->touchDownPoint.x - point->x;
4434 int diffY = impl->touchDownPoint.y - point->y;
4435 if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
4436 impl->exceedTouchMoveThreshold = true;
4440 impl->exceedTouchMoveThreshold = true;
4443 #endif // #if ENABLE(TIZEN_GESTURE)
4445 // FIXME: impl is used in the webkit opensource, but tizen webkit does not use it yet.
4446 //impl->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4447 impl->pageProxy->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, impl->transformFromScene(), impl->transformToScreen(), ecore_time_get()));
4455 Eina_Bool ewk_view_touch_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
4457 #if ENABLE(TOUCH_EVENTS)
4458 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4459 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4461 impl->setTouchEventsEnabled(!!enabled);
4469 Eina_Bool ewk_view_touch_events_enabled_get(const Evas_Object* ewkView)
4471 #if ENABLE(TOUCH_EVENTS)
4472 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4473 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4475 return impl->touchEventsEnabled();
4481 Eina_Bool ewk_view_main_frame_scrollbar_visible_set(Evas_Object* ewkView, Eina_Bool visible)
4483 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4484 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4485 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4487 impl->mainFrameScrollbarVisibility = visible;
4488 impl->pageClient->updateVisibility();
4496 Eina_Bool ewk_view_main_frame_scrollbar_visible_get(const Evas_Object* ewkView)
4498 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
4499 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4500 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4502 return impl->mainFrameScrollbarVisibility;
4508 Eina_Bool ewk_view_page_save(Evas_Object* ewkView, const char* path)
4510 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
4511 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4512 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4513 EINA_SAFETY_ON_NULL_RETURN_VAL(path, false);
4515 String title = ewk_view_title_get(ewkView);
4516 String url = ewk_view_url_get(ewkView);
4517 String directoryPath(path);
4518 impl->pageClient->startOfflinePageSave(directoryPath, url, title);
4522 UNUSED_PARAM(ewkView);
4530 * Callback function used for ewk_view_page_contents_get().
4532 static void ewkViewPageContentsAsMHTMLCallback(WKDataRef wkData, WKErrorRef, void* context)
4534 EINA_SAFETY_ON_NULL_RETURN(context);
4536 RefPtr<WebData> webData = toImpl(wkData);
4537 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4538 contentsContext->callback(contentsContext->type, reinterpret_cast<const char*>(webData->bytes()));
4543 * Callback function used for ewk_view_page_contents_get().
4545 static void ewkViewPageContentsAsStringCallback(WKStringRef wkString, WKErrorRef, void* context)
4547 EINA_SAFETY_ON_NULL_RETURN(context);
4549 RefPtr<WebString> webString = toImpl(wkString);
4550 Ewk_Page_Contents_Context* contentsContext= static_cast<Ewk_Page_Contents_Context*>(context);
4551 contentsContext->callback(contentsContext->type, webString->string().utf8().data());
4554 Eina_Bool ewk_view_page_contents_get(const Evas_Object* ewkView, Ewk_Page_Contents_Context* context)
4556 EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
4557 EINA_SAFETY_ON_NULL_RETURN_VAL(context->callback, false);
4558 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4559 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4561 switch (context->type) {
4562 case EWK_PAGE_CONTENTS_TYPE_MHTML:
4563 impl->pageProxy->getContentsAsMHTMLData(DataCallback::create(context, ewkViewPageContentsAsMHTMLCallback), false);
4566 case EWK_PAGE_CONTENTS_TYPE_STRING:
4567 impl->pageProxy->getContentsAsString(StringCallback::create(context, ewkViewPageContentsAsStringCallback));
4571 ASSERT_NOT_REACHED();
4578 Eina_Bool ewk_view_animated_scroll_set(Evas_Object* ewkView, int x, int y)
4580 #if ENABLE(TIZEN_GESTURE)
4581 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4582 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4584 return impl->gestureClient->scrollToWithAnimation(x, y);
4586 UNUSED_PARAM(ewkView);
4593 void ewk_view_content_security_policy_set(Evas_Object* ewkView, const char* policy, Ewk_CSP_Header_Type type)
4595 #if ENABLE(TIZEN_CSP)
4596 EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
4597 EWK_VIEW_IMPL_GET_OR_RETURN(sd, impl);
4599 TIZEN_LOGI("policy(%s), type(%d)\n", policy, type);
4600 impl->pageProxy->setContentSecurityPolicy(String::fromUTF8(policy), static_cast<WebCore::ContentSecurityPolicy::HeaderType>(type));
4604 #if ENABLE(TIZEN_APPLICATION_CACHE)
4605 Eina_Bool ewkViewRequestApplicationCachePermission(Evas_Object* ewkView, WKSecurityOriginRef origin)
4607 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4608 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4610 if (!impl->applicationCachePermissionContext || !impl->applicationCachePermissionContext->applicationCachePermissionCallback)
4613 impl->isWaitingForApplicationCachePermission = true;
4614 if (impl->applicationCachePermissionOrigin)
4615 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4616 impl->applicationCachePermissionOrigin = createSecurityOrigin(origin);
4618 return impl->applicationCachePermissionContext->applicationCachePermissionCallback(ewkView, impl->applicationCachePermissionOrigin, impl->applicationCachePermissionContext->userData) == EINA_TRUE;
4622 void ewk_view_application_cache_permission_callback_set(Evas_Object* ewkView, Ewk_View_Applicacion_Cache_Permission_Callback callback, void* userData)
4624 #if ENABLE(TIZEN_APPLICATION_CACHE)
4625 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4626 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4628 if (!impl->applicationCachePermissionContext)
4629 impl->applicationCachePermissionContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4630 impl->applicationCachePermissionContext->applicationCachePermissionCallback = callback;
4631 impl->applicationCachePermissionContext->userData = userData;
4633 UNUSED_PARAM(ewkView);
4634 UNUSED_PARAM(callback);
4635 UNUSED_PARAM(userData);
4639 void ewk_view_application_cache_permission_reply(Evas_Object* ewkView, Eina_Bool allow)
4641 #if ENABLE(TIZEN_APPLICATION_CACHE)
4642 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4643 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4645 TIZEN_LOGI("allow %d", allow);
4646 WKPageReplyApplicationCachePermission(toAPI(impl->page()), allow);
4647 if (impl->applicationCachePermissionOrigin)
4648 deleteSecurityOrigin(impl->applicationCachePermissionOrigin);
4649 impl->applicationCachePermissionOrigin = 0;
4650 impl->isWaitingForApplicationCachePermission = false;
4652 UNUSED_PARAM(ewkView);
4653 UNUSED_PARAM(allow);
4657 #if ENABLE(TIZEN_INDEXED_DATABASE)
4658 bool ewkViewExceededIndexedDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4660 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4661 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4663 if (!impl->exceededIndexedDatabaseQuotaContext || !impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback)
4666 impl->isWaitingForExceededQuotaPopupReply = true;
4667 if (impl->exceededQuotaOrigin)
4668 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4669 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4671 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4673 return impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, currentUsage, impl->exceededIndexedDatabaseQuotaContext->userData) == EINA_TRUE;
4677 void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4679 #if ENABLE(TIZEN_INDEXED_DATABASE)
4680 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4681 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4683 if (!impl->exceededIndexedDatabaseQuotaContext)
4684 impl->exceededIndexedDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4685 impl->exceededIndexedDatabaseQuotaContext->exceededIndexedDatabaseQuotaCallback = callback;
4686 impl->exceededIndexedDatabaseQuotaContext->userData = userData;
4688 UNUSED_PARAM(ewkView);
4689 UNUSED_PARAM(callback);
4690 UNUSED_PARAM(userData);
4694 void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4696 #if ENABLE(TIZEN_INDEXED_DATABASE)
4697 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4698 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4700 TIZEN_LOGI("allow %d", allow);
4701 WKPageReplyExceededIndexedDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4702 if (impl->exceededQuotaOrigin)
4703 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4704 impl->exceededQuotaOrigin = 0;
4705 impl->isWaitingForExceededQuotaPopupReply = false;
4707 UNUSED_PARAM(ewkView);
4708 UNUSED_PARAM(allow);
4712 // EwkFindOptions should be matched up orders with WkFindOptions.
4713 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_CASE_INSENSITIVE, kWKFindOptionsCaseInsensitive);
4714 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_AT_WORD_STARTS, kWKFindOptionsAtWordStarts);
4715 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, kWKFindOptionsTreatMedialCapitalAsWordStart);
4716 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_BACKWARDS, kWKFindOptionsBackwards);
4717 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_WRAP_AROUND, kWKFindOptionsWrapAround);
4718 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_OVERLAY, kWKFindOptionsShowOverlay);
4719 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR, kWKFindOptionsShowFindIndicator);
4720 COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShowHighlight);
4722 Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4724 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4725 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4726 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4728 impl->pageProxy->findString(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4733 Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView)
4735 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4736 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4738 impl->pageProxy->hideFindUI();
4743 Eina_Bool ewk_view_text_matches_count(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned maxMatchCount)
4745 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4746 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4747 EINA_SAFETY_ON_NULL_RETURN_VAL(text, false);
4749 impl->pageProxy->countStringMatches(String::fromUTF8(text), static_cast<WebKit::FindOptions>(options), maxMatchCount);
4754 void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData)
4756 #if ENABLE(TIZEN_SQL_DATABASE)
4757 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4758 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4760 if (!impl->exceededDatabaseQuotaContext)
4761 impl->exceededDatabaseQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4762 impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback = callback;
4763 impl->exceededDatabaseQuotaContext->userData = userData;
4765 UNUSED_PARAM(ewkView);
4766 UNUSED_PARAM(callback);
4767 UNUSED_PARAM(userData);
4771 void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4773 #if ENABLE(TIZEN_SQL_DATABASE)
4774 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4775 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4777 TIZEN_LOGI("allow %d", allow);
4778 WKPageReplyExceededDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE);
4779 if (impl->exceededQuotaOrigin)
4780 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4781 impl->exceededQuotaOrigin = 0;
4782 impl->isWaitingForExceededQuotaPopupReply = false;
4784 UNUSED_PARAM(ewkView);
4785 UNUSED_PARAM(allow);
4789 #if ENABLE(TIZEN_FILE_SYSTEM)
4790 bool ewkViewExceededLocalFileSystemQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, long long currentUsage)
4792 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4793 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4795 if (!impl->exceededLocalFileSystemQuotaContext || !impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback)
4798 impl->isWaitingForExceededQuotaPopupReply = true;
4799 if (impl->exceededQuotaOrigin)
4800 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4801 impl->exceededQuotaOrigin = createSecurityOrigin(origin);
4803 TIZEN_LOGI("currentUsage(%lld)", currentUsage);
4805 return impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback(ewkView, impl->exceededQuotaOrigin , currentUsage, impl->exceededLocalFileSystemQuotaContext->userData) == EINA_TRUE;
4809 void ewk_view_exceeded_local_file_system_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback, void* userData)
4811 #if ENABLE(TIZEN_FILE_SYSTEM)
4812 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4813 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4815 if (!impl->exceededLocalFileSystemQuotaContext)
4816 impl->exceededLocalFileSystemQuotaContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
4817 impl->exceededLocalFileSystemQuotaContext->exceededLocalFileSystemQuotaCallback = callback;
4818 impl->exceededLocalFileSystemQuotaContext->userData = userData;
4820 UNUSED_PARAM(ewkView);
4821 UNUSED_PARAM(callback);
4822 UNUSED_PARAM(userData);
4826 void ewk_view_exceeded_local_file_system_quota_reply(Evas_Object* ewkView, Eina_Bool allow)
4828 #if ENABLE(TIZEN_FILE_SYSTEM)
4829 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4830 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4832 TIZEN_LOGI("allow %d", allow);
4833 WKPageReplyExceededLocalFileSystemQuota(toAPI(impl->page()), allow == EINA_TRUE);
4834 if (impl->exceededQuotaOrigin)
4835 deleteSecurityOrigin(impl->exceededQuotaOrigin);
4836 impl->exceededQuotaOrigin = 0;
4837 impl->isWaitingForExceededQuotaPopupReply = false;
4839 UNUSED_PARAM(ewkView);
4840 UNUSED_PARAM(result);
4844 void ewk_view_rotation_prepare(Evas_Object* ewkView, int angle)
4846 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4847 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4848 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4851 if (angle == 0 || angle == 180) {
4852 width = WebCore::getDefaultScreenResolution().width();
4853 height = WebCore::getDefaultScreenResolution().height() + 100;
4855 if (angle == 90 || angle == 270) {
4856 width = WebCore::getDefaultScreenResolution().height();
4857 height = WebCore::getDefaultScreenResolution().width() + 100;
4860 impl->pageProxy->drawingArea()->setSize(IntSize(width, height), IntSize());
4861 impl->pageClient->setWaitFrameOfNewViewortSize(true);
4862 ewk_view_suspend(ewkView);
4863 impl->pageClient->updateViewportSize(IntSize(width, height), angle);
4867 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
4868 void ewkViewRotatePrepared(Evas_Object* ewkView)
4870 evas_object_smart_callback_call(ewkView, "rotate,prepared", 0);
4874 void ewk_view_use_settings_font(Evas_Object* ewkView)
4876 #if ENABLE(TIZEN_USE_SETTINGS_FONT)
4877 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4878 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4880 impl->pageProxy->useSettingsFont();
4884 void ewk_view_fullscreen_exit(Evas_Object* ewkView)
4886 #if ENABLE(TIZEN_FULLSCREEN_API)
4889 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
4890 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
4892 if (!impl->pageProxy->fullScreenManager()->isFullScreen())
4895 impl->pageProxy->fullScreenManager()->requestExitFullScreen();
4897 UNUSED_PARAM(ewkView);
4901 Eina_Bool ewk_view_draws_transparent_background_set(Evas_Object* ewkView, Eina_Bool enabled)
4903 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4904 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4906 impl->pageProxy->setDrawsTransparentBackground(enabled);
4907 evas_object_image_alpha_set(smartData->image, enabled);
4912 Eina_Bool ewk_view_draws_transparent_background_get(Evas_Object* ewkView)
4914 EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
4915 EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false);
4917 return impl->pageProxy->drawsTransparentBackground();