PageRenderTime 50ms CodeModel.GetById 0ms RepoModel.GetById 2ms app.codeStats 1ms

/webkit-efl/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp

https://review.tizen.org/git/
C++ | 4031 lines | 3232 code | 725 blank | 74 comment | 318 complexity | eb18014803718e55f908732091bf7cc8 MD5 | raw file
Possible License(s): GPL-3.0, AGPL-3.0, GPL-2.0, MPL-2.0, JSON, WTFPL, CC-BY-SA-4.0, CC-BY-3.0, BSD-3-Clause, LGPL-2.0, MPL-2.0-no-copyleft-exception, AGPL-1.0, 0BSD, Zlib, Unlicense, BSD-2-Clause, Apache-2.0, LGPL-3.0, ISC, MIT, CC-BY-SA-3.0, CC0-1.0, LGPL-2.1
  1. /*
  2. Copyright (C) 2011 Samsung Electronics
  3. Copyright (C) 2012 Intel Corporation. All rights reserved.
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #include "config.h"
  18. #include "ewk_view.h"
  19. #include "NativeWebKeyboardEvent.h"
  20. #include "NativeWebMouseEvent.h"
  21. #include "NativeWebWheelEvent.h"
  22. #include "PageClientImpl.h"
  23. #include "WKAPICast.h"
  24. #include "WKRetainPtr.h"
  25. #include "WKURL.h"
  26. #include "ewk_context.h"
  27. #include "ewk_context_private.h"
  28. #include "ewk_view_private.h"
  29. #include <wtf/text/CString.h>
  30. #if OS(TIZEN)
  31. #include "DrawingAreaProxyImpl.h"
  32. #include "JavaScriptPopup.h"
  33. #include "OpenPanel.h"
  34. #include "WKArray.h"
  35. #include "WKData.h"
  36. #include "WKDownload.h"
  37. #include "WKError.h"
  38. #include "WKGeolocationPermissionRequest.h"
  39. #include "WKImageCairo.h"
  40. #include "WKOpenPanelParameters.h"
  41. #include "WKOpenPanelResultListener.h"
  42. #include "WKPage.h"
  43. #include "WKPageGroup.h"
  44. #include "WKPageTizen.h"
  45. #include "WKPreferences.h"
  46. #include "WKSerializedScriptValue.h"
  47. #include "WKString.h"
  48. #include "WKURLRequest.h"
  49. #include "ewk_auth_challenge_private.h"
  50. #include "ewk_context_menu_private.h"
  51. #include "ewk_error.h"
  52. #include "ewk_error_private.h"
  53. #include "ewk_history_private.h"
  54. #include "ewk_setting_private.h"
  55. #include "ewk_view_context_menu_client.h"
  56. #include "ewk_view_find_client.h"
  57. #include "ewk_view_form_client.h"
  58. #include "ewk_view_loader_client.h"
  59. #include "ewk_view_policy_client.h"
  60. #include "ewk_view_tizen_client.h"
  61. #include "ewk_view_ui_client.h"
  62. #include <Ecore.h>
  63. #include <Ecore_Evas.h>
  64. #include <Elementary.h>
  65. #include <JavaScriptCore/JSRetainPtr.h>
  66. #include <WebCore/NotImplemented.h>
  67. #include <cairo.h>
  68. #if ENABLE(TIZEN_ICON_DATABASE)
  69. #include "WKContextPrivate.h"
  70. #include "WebContext.h"
  71. #endif
  72. #if ENABLE(TIZEN_ERROR_PAGE)
  73. #include "WebErrorPageEfl.h"
  74. #endif
  75. #if ENABLE(TIZEN_GEOLOCATION)
  76. #include "ewk_security_origin.h"
  77. #include "ewk_view_geolocation_provider.h"
  78. #endif
  79. #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
  80. #include "InputPicker.h"
  81. #endif
  82. #if ENABLE(TIZEN_GESTURE)
  83. #include "GestureRecognizer.h"
  84. #include "GestureClient.h"
  85. #endif
  86. #if ENABLE(TOUCH_EVENTS)
  87. #include "NativeWebTouchEvent.h"
  88. #include "WebEvent.h"
  89. #endif
  90. #if ENABLE(TIZEN_ISF_PORT)
  91. #include <Ecore_IMF.h>
  92. #endif
  93. #if ENABLE(TIZEN_NOTIFICATION)
  94. #include "WKArray.h"
  95. #include "WKNotificationManager.h"
  96. #include "WKNumber.h"
  97. #include "ewk_view_notification_provider.h"
  98. #endif
  99. #if ENABLE(TIZEN_WEBKIT2_POPUP)
  100. #include "WebPopupItem.h"
  101. #include "WebPopupMenuProxyEfl.h"
  102. #endif
  103. #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
  104. #include "ewk_popup_picker.h"
  105. #endif
  106. #if ENABLE(TIZEN_MEDIA_STREAM)
  107. #include "WKUserMediaPermissionRequest.h"
  108. #endif
  109. #if ENABLE(TIZEN_PREFERENCE)
  110. #include "WebPageGroup.h"
  111. #include "WebPreferences.h"
  112. #endif
  113. #if ENABLE(TIZEN_WEBKIT_PASTEBOARD)
  114. #include "ewk_util.h"
  115. #endif
  116. #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
  117. #include "ewk_hit_test_private.h"
  118. #endif
  119. #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
  120. #include <Ecore_Evas.h>
  121. #include <WebCore/Cursor.h>
  122. #include <WebCore/EflScreenUtilities.h>
  123. #endif
  124. #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
  125. #include "FocusRing.h"
  126. #endif
  127. #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
  128. #include "WebColorChooserProxyEfl.h"
  129. #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
  130. #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
  131. #include "ewk_text_style.h"
  132. #endif
  133. #endif // #if OS(TIZEN)
  134. using namespace WebKit;
  135. using namespace WebCore;
  136. static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
  137. typedef struct _Ewk_View_Callback_Context Ewk_View_Callback_Context;
  138. struct _Ewk_View_Private_Data {
  139. OwnPtr<PageClientImpl> pageClient;
  140. const char* uri;
  141. #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
  142. const char* cursorGroup;
  143. #ifdef HAVE_ECORE_X
  144. bool isUsingEcoreX;
  145. #endif
  146. #endif
  147. #if OS(TIZEN)
  148. bool areMouseEventsEnabled;
  149. #if ENABLE(TIZEN_ORIENTATION_EVENTS)
  150. int orientation;
  151. #endif
  152. struct {
  153. int count;
  154. int position;
  155. } formNavigation;
  156. JSGlobalContextRef javascriptGlobalContext;
  157. const char* title;
  158. const char* userAgent;
  159. const char* theme;
  160. const char* encoding;
  161. #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
  162. const char* webAppIconURL;
  163. #endif
  164. OwnPtr<Ewk_View_Callback_Context> alertContext;
  165. OwnPtr<Ewk_View_Callback_Context> confirmContext;
  166. OwnPtr<Ewk_View_Callback_Context> promptContext;
  167. OwnPtr<Ewk_View_Callback_Context> openpanelContext;
  168. OwnPtr<JavaScriptPopup> javascriptPopup;
  169. OwnPtr<OpenPanel> openPanel;
  170. #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
  171. OwnPtr<InputPicker> inputPicker;
  172. const char* inputValue;
  173. #endif
  174. Ewk_Auth_Challenge* authChallenge;
  175. Ewk_Policy_Decision* policyDecision;
  176. WKOpenPanelResultListenerRef openPanelListener;
  177. #if ENABLE(TIZEN_MEDIA_STREAM)
  178. Ewk_User_Media_Permission* userMediaPermission;
  179. #endif
  180. struct {
  181. Ewk_View_String_Find_Callback callback;
  182. void* userData;
  183. } findClientInfo;
  184. Ewk_Setting* setting;
  185. Ewk_Context* context;
  186. #if ENABLE(TIZEN_GEOLOCATION)
  187. Ewk_Geolocation* geolocation;
  188. Ewk_Geolocation_Permission_Data* geolocationPermission;
  189. #endif
  190. #if ENABLE(TIZEN_NOTIFICATION)
  191. Eina_List* notifications;
  192. Ewk_Notification_Permission_Request* notificationPermissionRequest;
  193. #endif
  194. #if ENABLE(TIZEN_SQL_DATABASE)
  195. Ewk_Context_Exceeded_Quota* exceededDatabaseQuota;
  196. #endif
  197. #if ENABLE(TIZEN_WEBKIT2_POPUP)
  198. WebPopupMenuProxyEfl* popupMenuProxy;
  199. Eina_List* popupMenuItems;
  200. #endif
  201. #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
  202. Ewk_Popup_Picker* popupPicker;
  203. #endif
  204. bool isVerticalEdge;
  205. bool isHorizontalEdge;
  206. #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
  207. OwnPtr<FocusRing> focusRing;
  208. #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
  209. #if ENABLE(TIZEN_GESTURE)
  210. OwnPtr<GestureRecognizer> gestureRecognizer;
  211. OwnPtr<GestureClient> gestureClient;
  212. #if ENABLE(TOUCH_EVENTS)
  213. Ecore_Animator* touchAnimator;
  214. Evas_Coord_Point touchDownPoint;
  215. bool exceedTouchMoveThreshold;
  216. #endif // #if ENABLE(TOUCH_EVENTS)
  217. bool holdHorizontalPanning;
  218. bool holdVerticalPanning;
  219. #endif // #if ENABLE(TIZEN_GESTURE)
  220. #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
  221. const char* selectedText;
  222. #endif
  223. #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
  224. WebColorChooserProxyEfl* colorChooser;
  225. #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
  226. #if ENABLE(TIZEN_DATALIST_ELEMENT)
  227. Eina_List* dataList;
  228. #endif
  229. #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
  230. struct {
  231. Ewk_Orientation_Lock_Cb callback;
  232. void* data;
  233. } orientationLock;
  234. #endif
  235. #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
  236. RefPtr<WebPageGroup> pageGroup;
  237. #endif
  238. #endif // #if OS(TIZEN)
  239. };
  240. #if OS(TIZEN)
  241. #if ENABLE(TIZEN_MM_PLAYER)
  242. struct _Ewk_View_Html5_Video_Data {
  243. WKStringRef url;
  244. WKStringRef cookie;
  245. };
  246. #endif // #if ENABLE(TIZEN_MM_PLAYER)
  247. struct _Ewk_View_Callback_Context {
  248. union {
  249. Ewk_View_Rss_Items_Get_Callback rssItemsGetCallback;
  250. Ewk_Web_App_Capable_Get_Callback webAppCapableCallback;
  251. Ewk_Web_App_Icon_URL_Get_Callback webAppIconURLCallback;
  252. #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
  253. Ewk_Web_Storage_Quota_Get_Callback webStorageQuotaCallback;
  254. #endif
  255. Ewk_View_Script_Execute_Callback scriptExecuteCallback;
  256. Ewk_View_Plain_Text_Get_Callback plainTextGetCallback;
  257. #if OS(TIZEN)
  258. Ewk_View_JavaScript_Alert_Callback javascriptAlertCallback;
  259. Ewk_View_JavaScript_Confirm_Callback javascriptConfirmCallback;
  260. Ewk_View_JavaScript_Prompt_Callback javascriptPromptCallback;
  261. Ewk_View_Open_Panel_Callback openPanelCallback;
  262. #endif // #if OS(TIZEN)
  263. };
  264. Evas_Object* ewkView;
  265. void* userData;
  266. };
  267. #define READABLE_SCALE_FACTOR 1.0
  268. #endif // #if OS(TIZEN)
  269. #define EWK_VIEW_TYPE_CHECK(ewkView, result) \
  270. bool result = true; \
  271. do { \
  272. const char* _tmp_otype = evas_object_type_get(ewkView); \
  273. const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
  274. if (EINA_UNLIKELY(!_tmp_s)) { \
  275. EINA_LOG_CRIT \
  276. ("%p (%s) is not a smart object!", \
  277. ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
  278. result = false; \
  279. } \
  280. const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
  281. if (EINA_UNLIKELY(!_tmp_sc)) { \
  282. EINA_LOG_CRIT \
  283. ("%p (%s) is not a smart object!", \
  284. ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
  285. result = false; \
  286. } \
  287. else if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \
  288. EINA_LOG_CRIT \
  289. ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
  290. ewkView, _tmp_otype ? _tmp_otype : "(null)", \
  291. EWK_VIEW_TYPE_STR, _tmp_sc->data); \
  292. result = false; \
  293. } \
  294. } while (0)
  295. #define EWK_VIEW_SD_GET(ewkView, smartData) \
  296. EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \
  297. Ewk_View_Smart_Data* smartData = 0; \
  298. if (_tmp_result) \
  299. smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView);
  300. #define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \
  301. EWK_VIEW_SD_GET(ewkView, smartData); \
  302. if (!smartData) { \
  303. EINA_LOG_CRIT("no smart data for object %p (%s)", \
  304. ewkView, evas_object_type_get(ewkView)); \
  305. return __VA_ARGS__; \
  306. }
  307. #define EWK_VIEW_PRIV_GET(smartData, priv) \
  308. Ewk_View_Private_Data* priv = smartData->priv
  309. #define EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, ...) \
  310. if (!smartData) { \
  311. EINA_LOG_CRIT("smart data is null"); \
  312. return __VA_ARGS__; \
  313. } \
  314. EWK_VIEW_PRIV_GET(smartData, priv); \
  315. if (!priv) { \
  316. EINA_LOG_CRIT("no private data for object %p (%s)", \
  317. smartData->self, evas_object_type_get(smartData->self)); \
  318. return __VA_ARGS__; \
  319. }
  320. #if OS(TIZEN)
  321. #define DECLARE_EVENT_FUNC(func) \
  322. static void func(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
  323. DECLARE_EVENT_FUNC(_ewk_view_on_touch_down);
  324. DECLARE_EVENT_FUNC(_ewk_view_on_touch_move);
  325. DECLARE_EVENT_FUNC(_ewk_view_on_touch_up);
  326. #undef DECLARE_EVENT_FUNC
  327. static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object*, const char* alertText, void* userData);
  328. static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object*, const char* message, void* userData);
  329. static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object*, const char* message, const char* defaultValue, void* userData);
  330. 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);
  331. #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
  332. 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);
  333. Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data*);
  334. #endif
  335. #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
  336. Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations);
  337. void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd);
  338. #endif
  339. #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
  340. static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data*, Ewk_Input_Type, const char* inputValue);
  341. #endif
  342. #if ENABLE(TIZEN_DATALIST_ELEMENT)
  343. static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data*, Ewk_Input_Type, Eina_List*);
  344. static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data*, Ewk_Input_Type);
  345. #endif
  346. #endif // #if OS(TIZEN)
  347. static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
  348. {
  349. if (smartData->changed.any)
  350. return;
  351. smartData->changed.any = true;
  352. evas_object_smart_changed(smartData->self);
  353. }
  354. // Default Event Handling.
  355. static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
  356. {
  357. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  358. #if OS(TIZEN)
  359. priv->pageClient->setViewFocused(true);
  360. #endif // #if OS(TIZEN)
  361. priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
  362. return true;
  363. }
  364. static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
  365. {
  366. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  367. #if ENABLE(TIZEN_ISF_PORT)
  368. // Keypad should be hidden rapidly when moving focus on elementary
  369. // because Ecore-ime doesn't support it.
  370. Ecore_IMF_Context* context = priv->pageClient->getIMFContext();
  371. if (context && priv->pageClient->getInputMethodState()) {
  372. LOG(ISF, "%s\n - keypad status : hide\n", __func__);
  373. ecore_imf_context_input_panel_hide(context);
  374. ecore_imf_context_focus_out(context);
  375. }
  376. #endif
  377. #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
  378. if (priv->pageClient->isTextSelectionMode())
  379. priv->pageClient->setIsTextSelectionMode(false);
  380. #endif
  381. #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
  382. if (priv->pageClient->isContextMenuVisible())
  383. priv->pageClient->page()->hideContextMenu();
  384. #endif
  385. #if OS(TIZEN)
  386. priv->pageClient->setViewFocused(false);
  387. #endif // #if OS(TIZEN)
  388. priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
  389. return true;
  390. }
  391. static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
  392. {
  393. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  394. Evas_Point position = {smartData->view.x, smartData->view.y};
  395. priv->pageClient->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, &position));
  396. return true;
  397. }
  398. #if OS(TIZEN) && ENABLE(TOUCH_EVENTS)
  399. void ewkViewHandleTouchEvent(Evas_Object* ewkView, Ewk_Touch_Event_Type type)
  400. {
  401. Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(ewkView));
  402. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
  403. Eina_List* points = 0;
  404. int count = evas_touch_point_list_count(smartData->base.evas);
  405. Ewk_Touch_Point* point;
  406. for (int i = 0; i < count; ++i) {
  407. point = static_cast<Ewk_Touch_Point*>(calloc(1, sizeof(Ewk_Touch_Point)));
  408. point->id = evas_touch_point_list_nth_id_get(smartData->base.evas, i);
  409. evas_touch_point_list_nth_xy_get(smartData->base.evas, i, &point->x, &point->y);
  410. point->state = evas_touch_point_list_nth_state_get(smartData->base.evas, i);
  411. points = eina_list_append(points, point);
  412. }
  413. ewk_view_feed_touch_event(ewkView, type, points, evas_key_modifier_get(smartData->base.evas));
  414. void* data;
  415. EINA_LIST_FREE(points, data)
  416. free(data);
  417. }
  418. static Eina_Bool _ewk_view_touch_animator(void *data)
  419. {
  420. Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
  421. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  422. if (!priv->exceedTouchMoveThreshold && evas_touch_point_list_count(smartData->base.evas)) {
  423. Evas_Coord x, y;
  424. evas_touch_point_list_nth_xy_get(smartData->base.evas, 0, &x, &y);
  425. unsigned int threshold = elm_config_scroll_thumbscroll_threshold_get();
  426. int diffX = priv->touchDownPoint.x - x;
  427. int diffY = priv->touchDownPoint.y - y;
  428. if (static_cast<unsigned int>(diffX * diffX + diffY * diffY) > threshold * threshold)
  429. priv->exceedTouchMoveThreshold = true;
  430. }
  431. if (priv->exceedTouchMoveThreshold)
  432. ewkViewHandleTouchEvent(smartData->self, EWK_TOUCH_MOVE);
  433. return ECORE_CALLBACK_RENEW;
  434. }
  435. #endif // #if OS(TIZEN) && ENABLE(TOUCH_EVENTS)
  436. static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
  437. {
  438. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  439. Evas_Point position = {smartData->view.x, smartData->view.y};
  440. priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, &position));
  441. return true;
  442. }
  443. static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
  444. {
  445. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  446. Evas_Point position = {smartData->view.x, smartData->view.y};
  447. priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, &position));
  448. return true;
  449. }
  450. static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
  451. {
  452. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  453. Evas_Point position = {smartData->view.x, smartData->view.y};
  454. priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, &position));
  455. return true;
  456. }
  457. static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
  458. {
  459. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  460. #if ENABLE(TIZEN_ISF_PORT)
  461. Ecore_IMF_Event IMFEvent;
  462. ecore_imf_evas_event_key_down_wrap(const_cast<Evas_Event_Key_Down*>(downEvent), &IMFEvent.key_down);
  463. bool filtered = ecore_imf_context_filter_event(priv->pageClient->getIMFContext(), ECORE_IMF_EVENT_KEY_DOWN, &IMFEvent);
  464. priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, filtered));
  465. #else
  466. priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent));
  467. #endif // #if ENABLE(TIZEN_ISF_PORT)
  468. return true;
  469. }
  470. static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
  471. {
  472. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  473. priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
  474. return true;
  475. }
  476. #if OS(TIZEN)
  477. #if ENABLE(TOUCH_EVENTS)
  478. static Eina_Bool _ewk_view_smart_multi_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Multi_Down* downEvent)
  479. {
  480. EINA_SAFETY_ON_NULL_RETURN_VAL(smartData, false);
  481. _ewk_view_on_touch_down(0, smartData->base.evas, smartData->self, 0);
  482. return true;
  483. }
  484. static Eina_Bool _ewk_view_smart_multi_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Multi_Up* upEvent)
  485. {
  486. EINA_SAFETY_ON_NULL_RETURN_VAL(smartData, false);
  487. _ewk_view_on_touch_up(0, smartData->base.evas, smartData->self, 0);
  488. return true;
  489. }
  490. static Eina_Bool _ewk_view_smart_multi_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Multi_Move* moveEvent)
  491. {
  492. EINA_SAFETY_ON_NULL_RETURN_VAL(smartData, false);
  493. _ewk_view_on_touch_move(0, smartData->base.evas, smartData->self, 0);
  494. return true;
  495. }
  496. #endif // #if ENABLE(TOUCH_EVENTS)
  497. static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
  498. {
  499. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  500. switch (event->type) {
  501. case EWK_GESTURE_TAP:
  502. priv->gestureClient->startTap(IntPoint(event->position.x, event->position.y));
  503. break;
  504. case EWK_GESTURE_LONG_PRESS:
  505. priv->gestureClient->startLongPress(IntPoint(event->position.x, event->position.y));
  506. break;
  507. case EWK_GESTURE_PAN:
  508. priv->gestureClient->startPan(IntPoint(event->position.x, event->position.y));
  509. break;
  510. case EWK_GESTURE_FLICK:
  511. priv->gestureClient->startFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
  512. break;
  513. case EWK_GESTURE_PINCH: {
  514. PageClientImpl* pageClient = ewkViewGetPageClient(smartData->self);
  515. if (pageClient->viewportConstraints().userScalable)
  516. priv->gestureClient->startPinch(IntPoint(event->position.x, event->position.y), event->scale);
  517. break;
  518. }
  519. default:
  520. ASSERT_NOT_REACHED();
  521. break;
  522. }
  523. return true;
  524. }
  525. static Eina_Bool _ewk_view_smart_gesture_end(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
  526. {
  527. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  528. switch (event->type) {
  529. case EWK_GESTURE_TAP:
  530. if (event->count == 1)
  531. priv->gestureClient->endTap(IntPoint(event->position.x, event->position.y));
  532. else if (event->count == 2)
  533. priv->gestureClient->endDoubleTap(IntPoint(event->position.x, event->position.y));
  534. break;
  535. case EWK_GESTURE_LONG_PRESS:
  536. priv->gestureClient->endLongPress(IntPoint(event->position.x, event->position.y));
  537. break;
  538. case EWK_GESTURE_PAN:
  539. priv->gestureClient->endPan(IntPoint(event->position.x, event->position.y));
  540. break;
  541. case EWK_GESTURE_FLICK:
  542. priv->gestureClient->endFlick(IntPoint(event->position.x, event->position.y), IntPoint(event->velocity.x, event->velocity.y));
  543. break;
  544. case EWK_GESTURE_PINCH:
  545. priv->gestureClient->endPinch(IntPoint(event->position.x, event->position.y), event->scale);
  546. break;
  547. default:
  548. ASSERT_NOT_REACHED();
  549. break;
  550. }
  551. return true;
  552. }
  553. static Eina_Bool _ewk_view_smart_gesture_move(Ewk_View_Smart_Data* smartData, const Ewk_Event_Gesture* event)
  554. {
  555. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  556. switch (event->type) {
  557. case EWK_GESTURE_PAN:
  558. priv->gestureClient->movePan(IntPoint(event->position.x, event->position.y));
  559. break;
  560. case EWK_GESTURE_TAP:
  561. case EWK_GESTURE_LONG_PRESS:
  562. case EWK_GESTURE_FLICK:
  563. break;
  564. case EWK_GESTURE_PINCH: {
  565. PageClientImpl* pageClient = ewkViewGetPageClient(smartData->self);
  566. if (pageClient->viewportConstraints().userScalable)
  567. priv->gestureClient->movePinch(IntPoint(event->position.x, event->position.y), event->scale);
  568. break;
  569. }
  570. default:
  571. ASSERT_NOT_REACHED();
  572. break;
  573. }
  574. return true;
  575. }
  576. static void _ewk_view_clients_attach(Ewk_View_Smart_Data* smartData)
  577. {
  578. EINA_SAFETY_ON_NULL_RETURN(smartData);
  579. ewkViewContextMenuClientAttachClient(smartData->self);
  580. ewkViewFindClientAttatchClient(smartData->self);
  581. ewkViewFormClientAttachClient(smartData->self);
  582. ewkViewLoaderClientAttachClient(smartData->self);
  583. ewkViewPolicyClientAttatchClient(smartData->self);
  584. ewkViewTizenClientAttachClient(smartData->self);
  585. ewkViewUIClientAttatchClient(smartData->self);
  586. }
  587. static void _ewk_view_providers_attach(Ewk_View_Smart_Data* smartData, WKContextRef contextRef)
  588. {
  589. EINA_SAFETY_ON_NULL_RETURN(smartData);
  590. EINA_SAFETY_ON_NULL_RETURN(contextRef);
  591. #if ENABLE(TIZEN_GEOLOCATION)
  592. ewkViewGeolocationProviderAttachProvider(smartData->self, contextRef);
  593. #endif
  594. #if ENABLE(TIZEN_NOTIFICATION)
  595. ewkViewNotificationProviderAttachProvider(smartData->self, contextRef);
  596. #endif
  597. }
  598. static void _ewk_view_default_callbacks_set(Ewk_View_Smart_Data* smartData)
  599. {
  600. EINA_SAFETY_ON_NULL_RETURN(smartData);
  601. ewk_view_javascript_alert_callback_set(smartData->self, _ewk_view_default_javascript_alert, 0);
  602. ewk_view_javascript_confirm_callback_set(smartData->self, _ewk_view_default_javascript_confirm, 0);
  603. ewk_view_javascript_prompt_callback_set(smartData->self, _ewk_view_default_javascript_prompt, 0);
  604. ewk_view_open_panel_callback_set(smartData->self, _ewk_view_default_open_panel, 0);
  605. }
  606. static void _ewk_view_page_initialize(Ewk_View_Smart_Data* smartData, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
  607. {
  608. EINA_SAFETY_ON_NULL_RETURN(smartData);
  609. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  610. priv->pageClient = PageClientImpl::create(toImpl(contextRef), toImpl(pageGroupRef), smartData->self);
  611. priv->setting = ewkSettingCreate(WKPageGroupGetPreferences(WKPageGetPageGroup(toAPI(priv->pageClient->page()))));
  612. #if ENABLE(TIZEN_WEBKIT2_THEME_SET_INTERNAL)
  613. ewk_view_theme_set(smartData->self, DEFAULT_THEME_PATH"/default.edj");
  614. #endif
  615. _ewk_view_clients_attach(smartData);
  616. _ewk_view_providers_attach(smartData, contextRef);
  617. _ewk_view_default_callbacks_set(smartData);
  618. }
  619. static Eina_Bool _ewk_view_initialize(Ewk_View_Smart_Data* smartData, Ewk_Context* context)
  620. {
  621. EINA_SAFETY_ON_NULL_RETURN_VAL(smartData, false);
  622. EINA_SAFETY_ON_NULL_RETURN_VAL(context, false);
  623. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  624. priv->context = context;
  625. #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
  626. _ewk_view_page_initialize(smartData, ewk_context_WKContext_get(context), toAPI(priv->pageGroup.get()));
  627. #else
  628. _ewk_view_page_initialize(smartData, ewk_context_WKContext_get(context), 0);
  629. #endif
  630. return true;
  631. }
  632. #endif //#if OS(TIZEN)
  633. // Event Handling.
  634. static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
  635. {
  636. Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
  637. EINA_SAFETY_ON_NULL_RETURN(smartData->api);
  638. EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
  639. smartData->api->focus_in(smartData);
  640. }
  641. static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
  642. {
  643. Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
  644. EINA_SAFETY_ON_NULL_RETURN(smartData->api);
  645. EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
  646. smartData->api->focus_out(smartData);
  647. }
  648. static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
  649. {
  650. Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
  651. Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
  652. EINA_SAFETY_ON_NULL_RETURN(smartData->api);
  653. EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
  654. smartData->api->mouse_wheel(smartData, wheelEvent);
  655. }
  656. static void _ewk_view_on_mouse_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
  657. {
  658. Evas_Event_Mouse_Down* downEvent = static_cast<Evas_Event_Mouse_Down*>(eventInfo);
  659. Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
  660. EINA_SAFETY_ON_NULL_RETURN(smartData->api);
  661. EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_down);
  662. smartData->api->mouse_down(smartData, downEvent);
  663. }
  664. static void _ewk_view_on_mouse_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
  665. {
  666. Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
  667. Evas_Event_Mouse_Up* upEvent = static_cast<Evas_Event_Mouse_Up*>(eventInfo);
  668. EINA_SAFETY_ON_NULL_RETURN(smartData->api);
  669. EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_up);
  670. smartData->api->mouse_up(smartData, upEvent);
  671. }
  672. static void _ewk_view_on_mouse_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
  673. {
  674. Evas_Event_Mouse_Move* moveEvent = static_cast<Evas_Event_Mouse_Move*>(eventInfo);
  675. Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
  676. EINA_SAFETY_ON_NULL_RETURN(smartData->api);
  677. EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_move);
  678. smartData->api->mouse_move(smartData, moveEvent);
  679. }
  680. static void _ewk_view_on_key_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
  681. {
  682. Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
  683. Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
  684. EINA_SAFETY_ON_NULL_RETURN(smartData->api);
  685. EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
  686. smartData->api->key_down(smartData, downEvent);
  687. }
  688. static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
  689. {
  690. Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
  691. Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
  692. EINA_SAFETY_ON_NULL_RETURN(smartData->api);
  693. EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
  694. smartData->api->key_up(smartData, upEvent);
  695. }
  696. #if OS(TIZEN)
  697. static void _ewk_view_mouse_events_connect(Ewk_View_Smart_Data* smartData)
  698. {
  699. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
  700. EINA_SAFETY_ON_FALSE_RETURN(priv->areMouseEventsEnabled);
  701. #define CONNECT(s, c) evas_object_event_callback_add(smartData->self, s, c, smartData)
  702. CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
  703. CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
  704. CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
  705. #undef CONNECT
  706. }
  707. static void _ewk_view_mouse_events_disconnect(Ewk_View_Smart_Data* smartData)
  708. {
  709. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
  710. EINA_SAFETY_ON_TRUE_RETURN(priv->areMouseEventsEnabled);
  711. #define DISCONNECT(s, c) evas_object_event_callback_del(smartData->self, s, c)
  712. DISCONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
  713. DISCONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
  714. DISCONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
  715. #undef DISCONNECT
  716. }
  717. #if ENABLE(TOUCH_EVENTS)
  718. static void _ewk_view_on_touch_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
  719. {
  720. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  721. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  722. // Start touchAnimator if current number of touch is one.
  723. if (evas_touch_point_list_count(smartData->base.evas) == 1) {
  724. priv->gestureRecognizer->initializeGesture();
  725. if (priv->touchAnimator)
  726. ecore_animator_del(priv->touchAnimator);
  727. priv->touchAnimator = ecore_animator_add(_ewk_view_touch_animator, smartData);
  728. #if OS(TIZEN)
  729. evas_touch_point_list_nth_xy_get(canvas, 0, &priv->touchDownPoint.x, &priv->touchDownPoint.y);
  730. priv->exceedTouchMoveThreshold = false;
  731. #endif // #if OS(TIZEN)
  732. }
  733. ewkViewHandleTouchEvent(ewkView, EWK_TOUCH_START);
  734. }
  735. static void _ewk_view_on_touch_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
  736. {
  737. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  738. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  739. // Stop touchAnimator if current number of touch is one.
  740. if (evas_touch_point_list_count(smartData->base.evas) == 1 && priv->touchAnimator) {
  741. ecore_animator_del(priv->touchAnimator);
  742. priv->touchAnimator = 0;
  743. }
  744. ewkViewHandleTouchEvent(ewkView, EWK_TOUCH_END);
  745. }
  746. static void _ewk_view_on_touch_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
  747. {
  748. notImplemented();
  749. }
  750. #endif
  751. #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
  752. Eina_Bool _ewk_view_text_selection_down(Ewk_View_Smart_Data* smartData, int x, int y)
  753. {
  754. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  755. IntPoint point(x, y);
  756. priv->pageClient->textSelectionDown(point, true);
  757. return true;
  758. }
  759. Eina_Bool _ewk_view_text_selection_move(Ewk_View_Smart_Data* smartData, int x, int y)
  760. {
  761. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  762. IntPoint point(x, y);
  763. priv->pageClient->textSelectionMove(point, true);
  764. return true;
  765. }
  766. Eina_Bool _ewk_view_text_selection_up(Ewk_View_Smart_Data* smartData, int x, int y)
  767. {
  768. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  769. IntPoint point(x, y);
  770. priv->pageClient->textSelectionUp(point);
  771. return true;
  772. }
  773. #endif
  774. #if ENABLE(TIZEN_DATALIST_ELEMENT)
  775. static void _ewk_view_data_list_del(Eina_List* dataList)
  776. {
  777. EINA_SAFETY_ON_NULL_RETURN(dataList);
  778. void* item;
  779. EINA_LIST_FREE(dataList, item)
  780. eina_stringshare_del(static_cast<char*>(item));
  781. }
  782. #endif
  783. #endif // #if OS(TIZEN)
  784. static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
  785. #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
  786. static uint64_t generatePageGroupIdentifierID()
  787. {
  788. static uint64_t uniquePageGroupIdentifierID = 1;
  789. return uniquePageGroupIdentifierID++;
  790. }
  791. #endif
  792. static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
  793. {
  794. Ewk_View_Private_Data* priv =
  795. static_cast<Ewk_View_Private_Data*>(calloc(1, sizeof(Ewk_View_Private_Data)));
  796. if (!priv) {
  797. EINA_LOG_CRIT("could not allocate Ewk_View_Private_Data");
  798. return 0;
  799. }
  800. #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
  801. #ifdef HAV_ECORE_X
  802. priv->isUsingEcoreX = WebCore::isUsingEcoreX(smartData->base.evas);
  803. #endif
  804. #endif
  805. #if OS(TIZEN)
  806. priv->areMouseEventsEnabled = false;
  807. priv->javascriptPopup = adoptPtr<JavaScriptPopup>(new JavaScriptPopup(smartData->self));
  808. priv->openPanel = adoptPtr<OpenPanel>(new OpenPanel(smartData->self));
  809. #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
  810. priv->inputPicker = adoptPtr<InputPicker>(new InputPicker(smartData->self));
  811. #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
  812. #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
  813. priv->focusRing = FocusRing::create(smartData->self);
  814. #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
  815. #if ENABLE(TIZEN_GESTURE)
  816. priv->gestureRecognizer = GestureRecognizer::create(smartData->self);
  817. priv->gestureClient = GestureClient::create(smartData->self);
  818. #endif // #if ENABLE(TIZEN_GESTURE)
  819. #if ENABLE(TIZEN_DATALIST_ELEMENT)
  820. priv->dataList = 0;
  821. #endif
  822. #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
  823. String pageGroupIdentifierID = String::number(generatePageGroupIdentifierID());
  824. String pageGroupIdentifier = String::format("PageGroup%s", pageGroupIdentifierID.utf8().data());
  825. WKRetainPtr<WKStringRef> pageGroupIdentifierRef(AdoptWK, WKStringCreateWithUTF8CString(pageGroupIdentifier.utf8().data()));
  826. priv->pageGroup = WebPageGroup::create(toWTFString(pageGroupIdentifierRef.get()));
  827. #endif
  828. #endif // #if OS(TIZEN)
  829. return priv;
  830. }
  831. static void _ewk_view_priv_del(Ewk_View_Private_Data* priv)
  832. {
  833. if (!priv)
  834. return;
  835. priv->pageClient = nullptr;
  836. #if OS(TIZEN)
  837. if (priv->javascriptGlobalContext)
  838. JSGlobalContextRelease(priv->javascriptGlobalContext);
  839. eina_stringshare_del(priv->uri);
  840. eina_stringshare_del(priv->title);
  841. eina_stringshare_del(priv->userAgent);
  842. eina_stringshare_del(priv->encoding);
  843. #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
  844. eina_stringshare_del(priv->webAppIconURL);
  845. #endif
  846. if (priv->authChallenge)
  847. ewkAuthChallengeDelete(priv->authChallenge);
  848. if (priv->policyDecision)
  849. ewkPolicyDecisionDelete(priv->policyDecision);
  850. #if ENABLE(TIZEN_MEDIA_STREAM)
  851. if (priv->userMediaPermission)
  852. ewkUserMediaPermissionDelete(priv->userMediaPermission);
  853. #endif
  854. ewkSettingDelete(priv->setting);
  855. priv->openPanelListener = 0;
  856. priv->openPanel = nullptr;
  857. priv->javascriptPopup = nullptr;
  858. priv->alertContext = nullptr;
  859. priv->confirmContext = nullptr;
  860. priv->promptContext = nullptr;
  861. priv->openpanelContext = nullptr;
  862. #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
  863. priv->inputPicker = nullptr;
  864. eina_stringshare_del(priv->inputValue);
  865. #endif
  866. #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
  867. priv->pageGroup = nullptr;
  868. #endif
  869. #endif
  870. #if ENABLE(TIZEN_DATALIST_ELEMENT)
  871. if (priv->dataList) {
  872. _ewk_view_data_list_del(priv->dataList);
  873. priv->dataList = 0;
  874. }
  875. #endif
  876. #if ENABLE(TIZEN_GEOLOCATION)
  877. if (priv->geolocation)
  878. ewkGeolocationDeleteGeolocation(priv->geolocation);
  879. if (priv->geolocationPermission)
  880. ewkGeolocationDeletePermission(priv->geolocationPermission);
  881. #endif
  882. #if ENABLE(TIZEN_NOTIFICATION)
  883. if (priv->notifications)
  884. ewkNotificationDeleteNotificationList(priv->notifications);
  885. if (priv->notificationPermissionRequest)
  886. ewkNotificationDeletePermissionRequest(priv->notificationPermissionRequest);
  887. #endif
  888. #if ENABLE(TIZEN_SQL_DATABASE)
  889. if (priv->exceededDatabaseQuota)
  890. ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
  891. #endif
  892. #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
  893. priv->focusRing = nullptr;
  894. #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
  895. #if ENABLE(TIZEN_GESTURE)
  896. priv->gestureRecognizer = nullptr;
  897. priv->gestureClient = nullptr;
  898. #if ENABLE(TOUCH_EVENTS)
  899. if (priv->touchAnimator)
  900. ecore_animator_del(priv->touchAnimator);
  901. #endif // #if ENABLE(TOUCH_EVENTS)
  902. #endif // #if ENABLE(TIZEN_GESTURE)
  903. #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
  904. eina_stringshare_del(priv->selectedText);
  905. #endif
  906. free(priv);
  907. }
  908. static void _ewk_view_smart_add(Evas_Object* ewkView)
  909. {
  910. const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
  911. const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
  912. const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
  913. EWK_VIEW_SD_GET(ewkView, smartData);
  914. if (!smartData) {
  915. smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
  916. if (!smartData) {
  917. EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
  918. return;
  919. }
  920. evas_object_smart_data_set(ewkView, smartData);
  921. }
  922. smartData->self = ewkView;
  923. #if !ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
  924. smartData->priv = _ewk_view_priv_new(smartData);
  925. #endif
  926. smartData->api = api;
  927. #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
  928. g_parentSmartClass.add(ewkView);
  929. smartData->priv = _ewk_view_priv_new(smartData);
  930. #endif
  931. if (!smartData->priv) {
  932. EINA_LOG_CRIT("could not allocate _Ewk_View_Private_Data");
  933. evas_object_smart_data_set(ewkView, 0);
  934. free(smartData);
  935. return;
  936. }
  937. #if !ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
  938. g_parentSmartClass.add(ewkView);
  939. #endif
  940. #if OS(TIZEN)
  941. // create bg_rect
  942. smartData->bg_rect = evas_object_rectangle_add(smartData->base.evas);
  943. evas_object_color_set(smartData->bg_rect, 255, 255, 255, 255);
  944. evas_object_show(smartData->bg_rect);
  945. evas_object_smart_member_add(smartData->bg_rect, ewkView);
  946. #endif // #if OS(TIZEN)
  947. // Create evas_object_image to draw web contents.
  948. smartData->image = evas_object_image_add(smartData->base.evas);
  949. #if OS(TIZEN)
  950. #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
  951. Ecore_Evas* ee = ecore_evas_ecore_evas_get(smartData->base.evas);
  952. const char *engine = ecore_evas_engine_name_get(ee);
  953. if (engine && !strcmp(engine, "opengl_x11"))
  954. evas_object_image_content_hint_set(smartData->image, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
  955. #endif
  956. #endif // #if OS(TIZEN)
  957. evas_object_image_alpha_set(smartData->image, false);
  958. evas_object_image_filled_set(smartData->image, true);
  959. evas_object_smart_member_add(smartData->image, ewkView);
  960. evas_object_show(smartData->image);
  961. #if OS(TIZEN)
  962. evas_object_pass_events_set(smartData->image, true);
  963. // create events_rect
  964. smartData->events_rect = evas_object_rectangle_add(smartData->base.evas);
  965. evas_object_color_set(smartData->events_rect, 0, 0, 0, 0);
  966. evas_object_smart_member_add(smartData->events_rect, ewkView);
  967. evas_object_show(smartData->events_rect);
  968. if (smartData->priv->areMouseEventsEnabled)
  969. _ewk_view_mouse_events_connect(smartData);
  970. #endif // #if OS(TIZEN)
  971. #define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
  972. CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
  973. CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
  974. CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
  975. #if !OS(TIZEN)
  976. CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
  977. CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
  978. CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
  979. #endif
  980. CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
  981. CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
  982. #if OS(TIZEN) && ENABLE(TOUCH_EVENTS)
  983. // FIXME: We have to connect touch callbacks with Mouse and Multi event
  984. // because the Evas sends the Touch event using them.
  985. // It should be fixed when the Evas supports the Touch event.
  986. CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_touch_down);
  987. CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_touch_up);
  988. CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_touch_move);
  989. CONNECT(EVAS_CALLBACK_MULTI_DOWN, _ewk_view_on_touch_down);
  990. CONNECT(EVAS_CALLBACK_MULTI_UP, _ewk_view_on_touch_up);
  991. CONNECT(EVAS_CALLBACK_MULTI_MOVE, _ewk_view_on_touch_move);
  992. #endif // #if OS(TIZEN) && ENABLE(TOUCH_EVENTS)
  993. #undef CONNECT
  994. }
  995. static void _ewk_view_smart_del(Evas_Object* ewkView)
  996. {
  997. EWK_VIEW_SD_GET(ewkView, smartData);
  998. if (smartData && smartData->priv)
  999. _ewk_view_priv_del(smartData->priv);
  1000. g_parentSmartClass.del(ewkView);
  1001. }
  1002. static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
  1003. {
  1004. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1005. evas_object_resize(smartData->image, width, height);
  1006. evas_object_image_size_set(smartData->image, width, height);
  1007. evas_object_image_fill_set(smartData->image, 0, 0, width, height);
  1008. #if OS(TIZEN)
  1009. evas_object_resize(smartData->events_rect, width, height);
  1010. EWK_VIEW_PRIV_GET(smartData, priv);
  1011. #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
  1012. evas_object_image_native_surface_set(smartData->image, 0);
  1013. if (priv)
  1014. priv->pageClient->displayViewport();
  1015. #endif
  1016. #if ENABLE(TIZEN_PREFERENCE)
  1017. if (priv && priv->pageClient->page()) {
  1018. priv->pageClient->page()->pageGroup()->preferences()->setViewWidth(width);
  1019. priv->pageClient->page()->pageGroup()->preferences()->setViewHeight(height);
  1020. }
  1021. #endif
  1022. #endif // #if OS(TIZEN)
  1023. smartData->changed.size = true;
  1024. _ewk_view_smart_changed(smartData);
  1025. }
  1026. static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
  1027. {
  1028. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1029. smartData->changed.position = true;
  1030. _ewk_view_smart_changed(smartData);
  1031. }
  1032. static void _ewk_view_smart_calculate(Evas_Object* ewkView)
  1033. {
  1034. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1035. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1036. Evas_Coord x, y, width, height;
  1037. smartData->changed.any = false;
  1038. evas_object_geometry_get(ewkView, &x, &y, &width, &height);
  1039. if (smartData->changed.size) {
  1040. smartData->view.w = width;
  1041. smartData->view.h = height;
  1042. smartData->changed.size = false;
  1043. #if OS(TIZEN)
  1044. if (priv->pageClient) {
  1045. if (DrawingAreaProxy* drawingArea = priv->pageClient->page()->drawingArea()) {
  1046. #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
  1047. if (priv->pageClient->page()->isViewVisible())
  1048. drawingArea->setSize(IntSize(width, height), IntSize());
  1049. #else
  1050. drawingArea->setSize(IntSize(width, height), IntSize());
  1051. #endif
  1052. #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
  1053. priv->pageClient->updateViewportSize(IntSize(width, height));
  1054. priv->pageClient->displayViewport();
  1055. #endif
  1056. }
  1057. #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
  1058. priv->pageClient->frameRectChanged();
  1059. #endif
  1060. }
  1061. evas_object_resize(smartData->bg_rect, width, height);
  1062. #endif // #if OS(TIZEN)
  1063. }
  1064. if (smartData->changed.position) {
  1065. evas_object_move(smartData->image, x, y);
  1066. #if OS(TIZEN)
  1067. evas_object_move(smartData->events_rect, x, y);
  1068. evas_object_move(smartData->bg_rect, x, y);
  1069. #endif // #if OS(TIZEN)
  1070. smartData->view.x = x;
  1071. smartData->view.y = y;
  1072. smartData->changed.position = false;
  1073. #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
  1074. priv->pageClient->frameRectChanged();
  1075. #endif
  1076. }
  1077. if (priv->popupPicker)
  1078. ewk_popup_picker_resize(priv->popupPicker);
  1079. }
  1080. static void _ewk_view_smart_show(Evas_Object* ewkView)
  1081. {
  1082. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1083. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1084. if (evas_object_clipees_get(smartData->base.clipper))
  1085. evas_object_show(smartData->base.clipper);
  1086. evas_object_show(smartData->image);
  1087. }
  1088. static void _ewk_view_smart_hide(Evas_Object* ewkView)
  1089. {
  1090. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1091. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1092. evas_object_hide(smartData->base.clipper);
  1093. evas_object_hide(smartData->image);
  1094. }
  1095. static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, int blue, int alpha)
  1096. {
  1097. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1098. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1099. if (alpha < 0)
  1100. alpha = 0;
  1101. else if (alpha > 255)
  1102. alpha = 255;
  1103. #define CHECK_COLOR(color, alpha) \
  1104. if (color < 0) \
  1105. color = 0; \
  1106. else if (color > alpha) \
  1107. color = alpha;
  1108. CHECK_COLOR(red, alpha);
  1109. CHECK_COLOR(green, alpha);
  1110. CHECK_COLOR(blue, alpha);
  1111. #undef CHECK_COLOR
  1112. #if OS(TIZEN)
  1113. evas_object_color_set(smartData->bg_rect, red, green, blue, alpha);
  1114. #endif
  1115. evas_object_image_alpha_set(smartData->image, alpha < 255);
  1116. priv->pageClient->page()->setDrawsBackground(red || green || blue);
  1117. priv->pageClient->page()->setDrawsTransparentBackground(alpha < 255);
  1118. g_parentSmartClass.color_set(ewkView, red, green, blue, alpha);
  1119. }
  1120. #if OS(TIZEN)
  1121. Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api)
  1122. #else
  1123. Eina_Bool ewk_view_smart_class_init(Ewk_View_Smart_Class* api)
  1124. #endif
  1125. {
  1126. EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
  1127. if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
  1128. EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
  1129. api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
  1130. return false;
  1131. }
  1132. if (EINA_UNLIKELY(!g_parentSmartClass.add))
  1133. evas_object_smart_clipped_smart_set(&g_parentSmartClass);
  1134. evas_object_smart_clipped_smart_set(&api->sc);
  1135. // Set Evas_Smart_Class functions.
  1136. api->sc.add = _ewk_view_smart_add;
  1137. api->sc.del = _ewk_view_smart_del;
  1138. api->sc.move = _ewk_view_smart_move;
  1139. api->sc.resize = _ewk_view_smart_resize;
  1140. api->sc.show = _ewk_view_smart_show;
  1141. api->sc.hide = _ewk_view_smart_hide;
  1142. api->sc.color_set = _ewk_view_smart_color_set;
  1143. api->sc.calculate = _ewk_view_smart_calculate;
  1144. api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
  1145. // Set Ewk_View_Smart_Class functions.
  1146. api->focus_in = _ewk_view_smart_focus_in;
  1147. api->focus_out = _ewk_view_smart_focus_out;
  1148. api->mouse_wheel = _ewk_view_smart_mouse_wheel;
  1149. api->mouse_down = _ewk_view_smart_mouse_down;
  1150. api->mouse_up = _ewk_view_smart_mouse_up;
  1151. api->mouse_move = _ewk_view_smart_mouse_move;
  1152. api->key_down = _ewk_view_smart_key_down;
  1153. api->key_up = _ewk_view_smart_key_up;
  1154. #if OS(TIZEN)
  1155. api->initialize = _ewk_view_initialize;
  1156. #if ENABLE(TOUCH_EVENTS)
  1157. api->multi_down = _ewk_view_smart_multi_down;
  1158. api->multi_up = _ewk_view_smart_multi_up;
  1159. api->multi_move = _ewk_view_smart_multi_move;
  1160. #endif // #if ENABLE(TOUCH_EVENTS)
  1161. api->gesture_start = _ewk_view_smart_gesture_start;
  1162. api->gesture_end = _ewk_view_smart_gesture_end;
  1163. api->gesture_move = _ewk_view_smart_gesture_move;
  1164. #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
  1165. api->popup_menu_show = _ewk_view_popup_menu_show;
  1166. api->popup_menu_hide = _ewk_view_popup_menu_hide;
  1167. #endif
  1168. #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
  1169. api->text_selection_down = _ewk_view_text_selection_down;
  1170. api->text_selection_move = _ewk_view_text_selection_move;
  1171. api->text_selection_up = _ewk_view_text_selection_up;
  1172. #endif
  1173. #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
  1174. api->input_picker_show = _ewk_view_input_picker_show;
  1175. #endif
  1176. #if ENABLE(TIZEN_DATALIST_ELEMENT)
  1177. api->data_list_show = _ewk_view_data_list_show;
  1178. api->data_list_hide = _ewk_view_data_list_hide;
  1179. #endif
  1180. #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
  1181. api->orientation_lock = _ewk_orientation_lock;
  1182. api->orientation_unlock = _ewk_orientation_unlock;
  1183. #endif
  1184. #endif //#if OS(TIZEN)
  1185. return true;
  1186. }
  1187. static inline Evas_Smart* _ewk_view_smart_class_new(void)
  1188. {
  1189. static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION(ewkViewLegacyName);
  1190. static Evas_Smart* smart = 0;
  1191. if (EINA_UNLIKELY(!smart)) {
  1192. #if OS(TIZEN)
  1193. ewk_view_smart_class_set(&api);
  1194. #else
  1195. ewk_view_smart_class_init(&api);
  1196. #endif
  1197. smart = evas_smart_class_new(&api.sc);
  1198. }
  1199. return smart;
  1200. }
  1201. #if OS(TIZEN)
  1202. static Evas_Object* _ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
  1203. #else
  1204. Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
  1205. #endif
  1206. {
  1207. Evas_Object* ewkView = evas_object_smart_add(canvas, _ewk_view_smart_class_new());
  1208. if (!ewkView)
  1209. return 0;
  1210. EWK_VIEW_SD_GET(ewkView, smartData);
  1211. if (!smartData) {
  1212. evas_object_del(ewkView);
  1213. return 0;
  1214. }
  1215. EWK_VIEW_PRIV_GET(smartData, priv);
  1216. if (!priv) {
  1217. evas_object_del(ewkView);
  1218. return 0;
  1219. }
  1220. #if !OS(TIZEN)
  1221. priv->pageClient = PageClientImpl::create(toImpl(contextRef), toImpl(pageGroupRef), ewkView);
  1222. #endif
  1223. return ewkView;
  1224. }
  1225. #if OS(TIZEN)
  1226. /**
  1227. * @internal
  1228. * Constructs a ewk_view Evas_Object with WKType parameters.
  1229. */
  1230. Evas_Object* ewk_view_add_with_WKType(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
  1231. {
  1232. Evas_Object* ewkView = _ewk_view_base_add(canvas, contextRef, pageGroupRef);
  1233. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ewkView);
  1234. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, ewkView);
  1235. priv->context = ewk_context_new_with_WKContext(contextRef);
  1236. _ewk_view_page_initialize(smartData, contextRef, pageGroupRef);
  1237. return ewkView;
  1238. }
  1239. #endif // #if OS(TIZEN)
  1240. Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context)
  1241. {
  1242. #if OS(TIZEN)
  1243. EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
  1244. EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
  1245. #if ENABLE(TIZEN_ICON_DATABASE)
  1246. //set default iconDatabasePath
  1247. String platformDefaultPath = toImpl(ewk_context_WKContext_get(context))->iconDatabasePath();
  1248. WKContextSetIconDatabasePath(ewk_context_WKContext_get(context), WKStringCreateWithUTF8CString(platformDefaultPath.utf8().data()));
  1249. #endif
  1250. Evas_Object* ewkView = _ewk_view_base_add(canvas, ewk_context_WKContext_get(context), 0);
  1251. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ewkView);
  1252. EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, ewkView);
  1253. EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api->initialize, ewkView);
  1254. smartData->api->initialize(smartData, context);
  1255. return ewkView;
  1256. #else
  1257. return ewk_view_base_add(canvas, ewk_context_WKContext_get(context), 0);
  1258. #endif
  1259. }
  1260. Evas_Object* ewk_view_add(Evas* canvas)
  1261. {
  1262. return ewk_view_add_with_context(canvas, ewk_context_default_get());
  1263. }
  1264. Ewk_Context* ewk_view_context_get(const Evas_Object* ewkView)
  1265. {
  1266. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  1267. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  1268. return priv->context;
  1269. }
  1270. Eina_Bool ewk_view_uri_set(Evas_Object* ewkView, const char* uri)
  1271. {
  1272. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  1273. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  1274. WKRetainPtr<WKURLRef> url(AdoptWK, WKURLCreateWithUTF8CString(uri));
  1275. WKPageLoadURL(toAPI(priv->pageClient->page()), url.get());
  1276. eina_stringshare_replace(&priv->uri, uri);
  1277. return true;
  1278. }
  1279. const char* ewk_view_uri_get(const Evas_Object* ewkView)
  1280. {
  1281. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  1282. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  1283. return priv->uri;
  1284. }
  1285. Eina_Bool ewk_view_reload(Evas_Object* ewkView)
  1286. {
  1287. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1288. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1289. WKPageReload(toAPI(priv->pageClient->page()));
  1290. return true;
  1291. }
  1292. Eina_Bool ewk_view_reload_bypass_cache(Evas_Object* ewkView)
  1293. {
  1294. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1295. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1296. WKPageReloadFromOrigin(toAPI(priv->pageClient->page()));
  1297. return true;
  1298. }
  1299. Eina_Bool ewk_view_stop(Evas_Object* ewkView)
  1300. {
  1301. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1302. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1303. WKPageStopLoading(toAPI(priv->pageClient->page()));
  1304. return true;
  1305. }
  1306. Eina_Bool ewk_view_device_pixel_ratio_set(Evas_Object* ewkView, float ratio)
  1307. {
  1308. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1309. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1310. priv->pageClient->page()->setCustomDeviceScaleFactor(ratio);
  1311. return true;
  1312. }
  1313. float ewk_view_device_pixel_ratio_get(const Evas_Object* ewkView)
  1314. {
  1315. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
  1316. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1);
  1317. return priv->pageClient->page()->deviceScaleFactor();
  1318. }
  1319. void ewk_view_display(Evas_Object* ewkView, const IntRect& rect)
  1320. {
  1321. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1322. if (!smartData->image)
  1323. return;
  1324. evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height());
  1325. }
  1326. Eina_Bool ewk_view_back(Evas_Object* ewkView)
  1327. {
  1328. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1329. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1330. WKPageRef pageRef = toAPI(priv->pageClient->page());
  1331. if (WKPageCanGoBack(pageRef)) {
  1332. WKPageGoBack(pageRef);
  1333. return true;
  1334. }
  1335. return false;
  1336. }
  1337. Eina_Bool ewk_view_forward(Evas_Object* ewkView)
  1338. {
  1339. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1340. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1341. WKPageRef pageRef = toAPI(priv->pageClient->page());
  1342. if (WKPageCanGoForward(pageRef)) {
  1343. WKPageGoForward(pageRef);
  1344. return true;
  1345. }
  1346. return false;
  1347. }
  1348. Eina_Bool ewk_view_back_possible(Evas_Object* ewkView)
  1349. {
  1350. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1351. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1352. return WKPageCanGoBack(toAPI(priv->pageClient->page()));
  1353. }
  1354. Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView)
  1355. {
  1356. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1357. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1358. return WKPageCanGoForward(toAPI(priv->pageClient->page()));
  1359. }
  1360. void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size)
  1361. {
  1362. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1363. if (!imageData || !smartData->image)
  1364. return;
  1365. evas_object_resize(smartData->image, size.width(), size.height());
  1366. evas_object_image_size_set(smartData->image, size.width(), size.height());
  1367. evas_object_image_data_copy_set(smartData->image, imageData);
  1368. }
  1369. WebPageProxy* ewk_view_page_get(const Evas_Object* ewkView)
  1370. {
  1371. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  1372. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  1373. return priv->pageClient->page();
  1374. }
  1375. #if OS(TIZEN)
  1376. // FIXME: It should be removed.
  1377. WKPageRef ewk_view_WKPage_get(Evas_Object* ewkView)
  1378. {
  1379. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  1380. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  1381. return toAPI(priv->pageClient->page());
  1382. }
  1383. Eina_Bool ewk_view_mouse_events_enabled_set(Evas_Object* ewkView, Eina_Bool enabled)
  1384. {
  1385. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1386. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1387. enabled = !!enabled;
  1388. if (priv->areMouseEventsEnabled == enabled)
  1389. return true;
  1390. priv->areMouseEventsEnabled = enabled;
  1391. if (enabled)
  1392. _ewk_view_mouse_events_connect(smartData);
  1393. else
  1394. _ewk_view_mouse_events_disconnect(smartData);
  1395. return true;
  1396. }
  1397. Eina_Bool ewk_view_mouse_events_enabled_get(const Evas_Object* ewkView)
  1398. {
  1399. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1400. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1401. return priv->areMouseEventsEnabled;
  1402. }
  1403. Eina_Bool ewk_view_feed_touch_event(Evas_Object* ewkView, Ewk_Touch_Event_Type type, Eina_List* points, const Evas_Modifier* modifiers)
  1404. {
  1405. #if ENABLE(TOUCH_EVENTS)
  1406. EINA_SAFETY_ON_NULL_RETURN_VAL(points, false);
  1407. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1408. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1409. #if ENABLE(TIZEN_GESTURE)
  1410. #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
  1411. // We don't want to process touch event when context menu is shown.
  1412. if (priv->pageClient->isContextMenuVisible()) {
  1413. priv->gestureRecognizer->setEnableGesture(true);
  1414. priv->gestureRecognizer->setEnableMoving(true);
  1415. return true;
  1416. }
  1417. #endif
  1418. #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
  1419. if (priv->pageClient->isTextSelectionMode()) {
  1420. priv->gestureRecognizer->setEnableGesture(true);
  1421. priv->gestureRecognizer->setEnableMoving(true);
  1422. priv->gestureRecognizer->setEnableTap(true);
  1423. return true;
  1424. }
  1425. #endif
  1426. #endif // #if ENABLE(TIZEN_GESTURE)
  1427. #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
  1428. const Eina_List* list;
  1429. void* item;
  1430. EINA_LIST_FOREACH(points, list, item) {
  1431. Ewk_Touch_Point* point = static_cast<Ewk_Touch_Point*>(item);
  1432. float revertScale = 1 / priv->pageClient->scaleFactor();
  1433. IntPoint scrollPosition = priv->pageClient->scrollPosition();
  1434. point->x = (scrollPosition.x() + (point->x - smartData->view.x)) * revertScale + smartData->view.x;
  1435. point->y = (scrollPosition.y() + (point->y - smartData->view.y)) * revertScale + smartData->view.y;
  1436. }
  1437. #endif
  1438. Evas_Point position = {smartData->view.x, smartData->view.y};
  1439. priv->pageClient->page()->handleTouchEvent(NativeWebTouchEvent(type, points, modifiers, position, smartData->base.evas, ecore_time_get()));
  1440. return true;
  1441. #else
  1442. return false;
  1443. #endif
  1444. }
  1445. static Eina_Bool _ewk_view_default_javascript_alert(Evas_Object* ewkView, const char* alertText, void* userData)
  1446. {
  1447. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1448. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1449. return priv->javascriptPopup->alert(alertText);
  1450. }
  1451. static Eina_Bool _ewk_view_default_javascript_confirm(Evas_Object* ewkView, const char* message, void* userData)
  1452. {
  1453. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1454. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1455. return priv->javascriptPopup->confirm(message);
  1456. }
  1457. static Eina_Bool _ewk_view_default_javascript_prompt(Evas_Object* ewkView, const char* message, const char* defaultValue, void* userData)
  1458. {
  1459. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1460. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1461. return priv->javascriptPopup->prompt(message, defaultValue);
  1462. }
  1463. 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)
  1464. {
  1465. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1466. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1467. return priv->openPanel->openPanel(ewkView, allow_multiple_files, accepted_mime_types, capture, priv);
  1468. }
  1469. #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
  1470. 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)
  1471. {
  1472. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1473. if (priv->popupPicker)
  1474. ewk_popup_picker_del(priv->popupPicker);
  1475. priv->popupPicker = ewk_popup_picker_new(smartData->self, items, selectedIndex);
  1476. return true;
  1477. }
  1478. Eina_Bool _ewk_view_popup_menu_hide(Ewk_View_Smart_Data* smartData)
  1479. {
  1480. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1481. if (!priv->popupPicker)
  1482. return false;
  1483. ewk_popup_picker_del(priv->popupPicker);
  1484. priv->popupPicker = 0;
  1485. return true;
  1486. }
  1487. #endif
  1488. #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
  1489. static Eina_Bool _ewk_view_input_picker_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, const char* inputValue)
  1490. {
  1491. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1492. priv->inputPicker->show(inputType, inputValue);
  1493. return true;
  1494. }
  1495. #endif
  1496. #if ENABLE(TIZEN_DATALIST_ELEMENT)
  1497. static Eina_Bool _ewk_view_data_list_show(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType, Eina_List* optionList)
  1498. {
  1499. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1500. priv->inputPicker->showDataList(inputType, optionList);
  1501. return true;
  1502. }
  1503. static Eina_Bool _ewk_view_data_list_hide(Ewk_View_Smart_Data* smartData, Ewk_Input_Type inputType)
  1504. {
  1505. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1506. priv->inputPicker->hideDataList(inputType);
  1507. return true;
  1508. }
  1509. #endif
  1510. PageClientImpl* ewkViewGetPageClient(const Evas_Object* ewkView)
  1511. {
  1512. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  1513. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  1514. return priv->pageClient.get();
  1515. }
  1516. double ewk_view_text_zoom_get(const Evas_Object* ewkView)
  1517. {
  1518. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 1);
  1519. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 1);
  1520. return WKPageGetTextZoomFactor(toAPI(priv->pageClient->page()));
  1521. }
  1522. Eina_Bool ewk_view_text_zoom_set(Evas_Object* ewkView, double textZoomFactor)
  1523. {
  1524. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1525. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1526. WKPageSetTextZoomFactor(toAPI(priv->pageClient->page()), textZoomFactor);
  1527. return true;
  1528. }
  1529. #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
  1530. void ewkViewShowFocusRing(Evas_Object* ewkView, const IntPoint& position)
  1531. {
  1532. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1533. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1534. if (!priv->focusRing)
  1535. return;
  1536. priv->focusRing->requestToShow(position);
  1537. }
  1538. void ewkViewHideFocusRing(Evas_Object* ewkView)
  1539. {
  1540. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1541. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1542. if (!priv->focusRing)
  1543. return;
  1544. priv->focusRing->hide();
  1545. }
  1546. #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
  1547. Ewk_Frame_Ref ewk_view_main_frame_get(Evas_Object* ewkView)
  1548. {
  1549. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  1550. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  1551. return static_cast<Ewk_Frame_Ref>(WKPageGetMainFrame(toAPI(priv->pageClient->page())));
  1552. }
  1553. Ewk_Frame_Ref ewk_view_focused_frame_get(Evas_Object* ewkView)
  1554. {
  1555. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  1556. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  1557. return static_cast<Ewk_Frame_Ref>(WKPageGetFocusedFrame(toAPI(priv->pageClient->page())));
  1558. }
  1559. Ewk_Setting* ewk_view_setting_get(Evas_Object* ewkView)
  1560. {
  1561. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  1562. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  1563. return priv->setting;
  1564. }
  1565. #if ENABLE(TIZEN_WEBKIT2_CURSOR_PARTIAL_EARLY_MERGE)
  1566. void ewk_view_cursor_set(Evas_Object* ewkView, const Cursor& cursor)
  1567. {
  1568. #ifdef HAVE_ECORE_X
  1569. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1570. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1571. if (!priv->isUsingEcoreX)
  1572. return;
  1573. const char* group = cursor.platformCursor();
  1574. if (!group || group == priv->cursorGroup)
  1575. return;
  1576. priv->cursorGroup = group;
  1577. Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(smartData->base.evas);
  1578. WebCore::applyFallbackCursor(ecoreEvas, group);
  1579. #endif
  1580. }
  1581. #endif
  1582. JSGlobalContextRef ewkViewGetJavascriptGlobalContext(Evas_Object* ewkView)
  1583. {
  1584. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  1585. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  1586. if (!priv->javascriptGlobalContext)
  1587. priv->javascriptGlobalContext = JSGlobalContextCreate(0);
  1588. return priv->javascriptGlobalContext;
  1589. }
  1590. static void setURI(Evas_Object* ewkView)
  1591. {
  1592. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1593. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1594. WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKPageCopyActiveURL(toAPI(priv->pageClient->page())));
  1595. if (!wkURL)
  1596. return;
  1597. CString activeURI = toImpl(wkURL.get())->string().utf8();
  1598. if (priv->uri && (activeURI == CString(priv->uri)))
  1599. return;
  1600. eina_stringshare_replace(&priv->uri, activeURI.data());
  1601. evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
  1602. }
  1603. void ewkViewLoadStarted(Evas_Object* ewkView)
  1604. {
  1605. setURI(ewkView);
  1606. evas_object_smart_callback_call(ewkView, "load,started", 0);
  1607. }
  1608. void ewkViewLoadCommitted(Evas_Object* ewkView)
  1609. {
  1610. setURI(ewkView);
  1611. evas_object_smart_callback_call(ewkView, "load,committed", 0);
  1612. }
  1613. void ewkViewLoadFinished(Evas_Object* ewkView)
  1614. {
  1615. setURI(ewkView);
  1616. evas_object_smart_callback_call(ewkView, "load,finished", 0);
  1617. }
  1618. void ewkViewLoadError(Evas_Object* ewkView, WKErrorRef error)
  1619. {
  1620. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1621. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1622. Ewk_Error* ewkError = ewkErrorCreate(error);
  1623. ewkErrorLoadErrorPage(ewkError, toAPI(priv->pageClient->page()));
  1624. evas_object_smart_callback_call(ewkView, "load,error", ewkError);
  1625. ewkErrorDelete(ewkError);
  1626. }
  1627. void ewkViewSetTitleAndURL(Evas_Object* ewkView, const char* title, const char* url)
  1628. {
  1629. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1630. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1631. if (title && eina_stringshare_replace(&priv->title, title))
  1632. evas_object_smart_callback_call(ewkView, "title,changed", static_cast<void*>(const_cast<char*>(priv->title)));
  1633. if (url && eina_stringshare_replace(&priv->uri, url))
  1634. evas_object_smart_callback_call(ewkView, "uri,changed", static_cast<void*>(const_cast<char*>(priv->uri)));
  1635. }
  1636. void ewkViewSetTitle(Evas_Object* ewkView, const char* title)
  1637. {
  1638. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1639. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1640. if (!title || !eina_stringshare_replace(&priv->title, title))
  1641. return;
  1642. evas_object_smart_callback_call(ewkView, "title,changed", static_cast<void*>(const_cast<char*>(priv->title)));
  1643. }
  1644. void ewkViewDidFirstVisuallyNonEmptyLayout(Evas_Object* ewkView)
  1645. {
  1646. evas_object_smart_callback_call(ewkView, "load,nonemptylayout,finished", 0);
  1647. }
  1648. void ewkViewDidReceiveAuthenticationChallenge(Evas_Object* ewkView, Ewk_Auth_Challenge* authChallenge)
  1649. {
  1650. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1651. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1652. if (priv->authChallenge)
  1653. ewkAuthChallengeDelete(priv->authChallenge);
  1654. priv->authChallenge = authChallenge;
  1655. evas_object_smart_callback_call(ewkView, "authentication,challenge", priv->authChallenge);
  1656. }
  1657. void ewkViewLoadProgressChanged(Evas_Object* ewkView, double progress)
  1658. {
  1659. evas_object_smart_callback_call(ewkView, "load,progress", &progress);
  1660. }
  1661. void ewk_view_process_crashed(Evas_Object* ewkView)
  1662. {
  1663. bool handled = false;
  1664. evas_object_smart_callback_call(ewkView, "process,crashed", &handled);
  1665. if (!handled)
  1666. exit(0);
  1667. }
  1668. #if ENABLE(TIZEN_SQL_DATABASE)
  1669. unsigned long long ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage)
  1670. {
  1671. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, currentQuota);
  1672. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, currentQuota);
  1673. if (priv->exceededDatabaseQuota)
  1674. ewkContextDeleteExceededQuota(priv->exceededDatabaseQuota);
  1675. priv->exceededDatabaseQuota = ewkContextCreateExceededQuota(origin, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
  1676. evas_object_smart_callback_call(ewkView, "database,quota,exceeded", priv->exceededDatabaseQuota);
  1677. return ewkContextGetNewQuotaForExceededQuota(priv->context, priv->exceededDatabaseQuota);
  1678. }
  1679. #endif
  1680. #if ENABLE(TIZEN_NOTIFICATION)
  1681. void ewkViewCancelNotification(Evas_Object* ewkView, uint64_t notificationID)
  1682. {
  1683. evas_object_smart_callback_call(ewkView, "notification,cancel", &notificationID);
  1684. }
  1685. void ewkViewRequestNotificationPermission(Evas_Object* ewkView, Ewk_Notification_Permission_Request* notificationPermissionRequest)
  1686. {
  1687. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1688. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1689. if(priv->notificationPermissionRequest)
  1690. ewkNotificationDeletePermissionRequest(priv->notificationPermissionRequest);
  1691. priv->notificationPermissionRequest = notificationPermissionRequest;
  1692. evas_object_smart_callback_call(ewkView, "notification,permission,request", notificationPermissionRequest);
  1693. }
  1694. void ewkViewShowNotification(Evas_Object* ewkView, Ewk_Notification* notification)
  1695. {
  1696. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1697. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1698. Eina_List* listIterator=0;
  1699. void* data=0;
  1700. const char* replaceID = ewkNotificationGetReplaceID(notification);
  1701. if(strlen(replaceID)) {
  1702. EINA_LIST_FOREACH(priv->notifications, listIterator, data) {
  1703. Ewk_Notification* notificationForReplace = static_cast<Ewk_Notification*>(data);
  1704. if(!strcmp(ewkNotificationGetReplaceID(notificationForReplace), replaceID))
  1705. ewkViewCancelNotification(ewkView, ewk_notification_id_get(notificationForReplace));
  1706. }
  1707. }
  1708. priv->notifications = eina_list_append(priv->notifications, notification);
  1709. evas_object_smart_callback_call(ewkView, "notification,show", notification);
  1710. }
  1711. #endif
  1712. #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
  1713. void ewkViewRegisterProtocolHandlers(Evas_Object* ewkView, const char* scheme, const char* baseUrl, const char* url, const char* title)
  1714. {
  1715. EINA_SAFETY_ON_NULL_RETURN(ewkView);
  1716. Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(scheme, baseUrl, url, title);
  1717. evas_object_smart_callback_call(ewkView, "protocolhandlers,register", static_cast<void*>(customHandlersData));
  1718. ewkCustomHandlersDeleteData(customHandlersData);
  1719. }
  1720. #endif
  1721. #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
  1722. void ewkViewRegisterContentHandlers(Evas_Object* ewkView, const char* mimeType, const char* baseUrl, const char* url, const char* title)
  1723. {
  1724. EINA_SAFETY_ON_NULL_RETURN(ewkView);
  1725. Ewk_Custom_Handlers_Data* customHandlersData = ewkCustomHandlersCreateData(mimeType, baseUrl, url, title);
  1726. evas_object_smart_callback_call(ewkView, "contenthandlers,register", static_cast<void*>(customHandlersData));
  1727. ewkCustomHandlersDeleteData(customHandlersData);
  1728. }
  1729. #endif
  1730. #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
  1731. bool ewkViewGetStandaloneStatus(Evas_Object* ewkView)
  1732. {
  1733. bool standalone = true;
  1734. evas_object_smart_callback_call(ewkView, "webapp,metatag,standalone", (void*)&standalone);
  1735. return standalone;
  1736. }
  1737. #endif
  1738. #if ENABLE(TIZEN_MM_PLAYER)
  1739. void ewkViewProcessHTML5Video(Evas_Object* ewkView, WKStringRef url, WKStringRef cookie)
  1740. {
  1741. Ewk_View_Html5_Video_Data videoData;
  1742. videoData.url = url;
  1743. videoData.cookie = cookie;
  1744. evas_object_smart_callback_call(ewkView, "request,html5video", &videoData);
  1745. }
  1746. #endif
  1747. #if ENABLE(TIZEN_MEDIA_STREAM)
  1748. void ewkViewRequestUserMediaPermission(Evas_Object* ewkView, Ewk_User_Media_Permission* userMediaPermission)
  1749. {
  1750. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1751. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1752. if (priv->userMediaPermission)
  1753. ewkUserMediaPermissionDelete(priv->userMediaPermission);
  1754. priv->userMediaPermission = userMediaPermission;
  1755. evas_object_smart_callback_call(ewkView, "usermedia,permission,request", priv->userMediaPermission);
  1756. }
  1757. #endif
  1758. #if ENABLE(TIZEN_JSBRIDGE_PLUGIN)
  1759. void ewkViewProcessJSBridgePlugin(Evas_Object* ewkView, WKStringRef request, WKStringRef message)
  1760. {
  1761. int requestLength = WKStringGetMaximumUTF8CStringSize(request);
  1762. OwnArrayPtr<char> requestBuffer = adoptArrayPtr(new char[requestLength]);
  1763. int messageLength = WKStringGetMaximumUTF8CStringSize(message);
  1764. OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[messageLength]);
  1765. WKStringGetUTF8CString(request, requestBuffer.get(), requestLength);
  1766. WKStringGetUTF8CString(message, messageBuffer.get(), messageLength);
  1767. evas_object_smart_callback_call(ewkView, requestBuffer.get(), static_cast<void*>(messageBuffer.get()));
  1768. }
  1769. #endif
  1770. #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
  1771. void ewkViewRequestCertificateConfirm(Evas_Object* ewkView, Ewk_Certificate_Policy_Decision* certificatePolicyDecision)
  1772. {
  1773. evas_object_smart_callback_call(ewkView, "request,certificate,confirm", certificatePolicyDecision);
  1774. }
  1775. #endif
  1776. void ewkViewCustomizeContextMenu(Evas_Object* ewkView, Ewk_Context_Menu* menu)
  1777. {
  1778. evas_object_smart_callback_call(ewkView, "contextmenu,customize", static_cast<void*>(menu));
  1779. }
  1780. void ewkViewCustomContextMenuItemSelected(Evas_Object* ewkView, Ewk_Context_Menu_Item* item)
  1781. {
  1782. evas_object_smart_callback_call(ewkView, "contextmenu,selected", static_cast<void*>(item));
  1783. }
  1784. void ewkViewClosePage(Evas_Object* ewkView)
  1785. {
  1786. evas_object_smart_callback_call(ewkView, "close,window", 0);
  1787. }
  1788. #if ENABLE(TIZEN_GEOLOCATION)
  1789. void ewkViewRequestGeolocationPermission(Evas_Object* ewkView, Ewk_Geolocation_Permission_Data* permissionData)
  1790. {
  1791. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1792. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1793. if (priv->geolocationPermission)
  1794. ewkGeolocationDeletePermission(priv->geolocationPermission);
  1795. priv->geolocationPermission = permissionData;
  1796. evas_object_smart_callback_call(ewkView, "request,geolocation,permission", priv->geolocationPermission);
  1797. }
  1798. void ewkViewSetGeolocation(Evas_Object* ewkView, Ewk_Geolocation* geolocation)
  1799. {
  1800. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1801. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1802. priv->geolocation = geolocation;
  1803. }
  1804. Ewk_Geolocation* ewkViewGetGeolocation(Evas_Object* ewkView)
  1805. {
  1806. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  1807. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  1808. return priv->geolocation;
  1809. }
  1810. bool ewkViewIsValidLocationService(Evas_Object* ewkView)
  1811. {
  1812. bool valid = false;
  1813. evas_object_smart_callback_call(ewkView, "geolocation,valid", &valid);
  1814. return valid;
  1815. }
  1816. #endif
  1817. WKPageRef ewkViewCreateNewPage(Evas_Object* ewkView)
  1818. {
  1819. Evas_Object* createdEwkView = 0;
  1820. evas_object_smart_callback_call(ewkView, "create,window", &createdEwkView);
  1821. if (!createdEwkView)
  1822. return 0;
  1823. return static_cast<WKPageRef>(WKRetain(toAPI(ewk_view_page_get(createdEwkView))));
  1824. }
  1825. void ewkViewFormSubmit(Evas_Object* ewkView, Ewk_Form_Data* formData)
  1826. {
  1827. evas_object_smart_callback_call(ewkView, "form,submit", formData);
  1828. }
  1829. void ewkViewPolicyNavigationDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
  1830. {
  1831. EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
  1832. EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
  1833. if (priv->policyDecision)
  1834. ewkPolicyDecisionDelete(priv->policyDecision);
  1835. priv->policyDecision = policyDecision;
  1836. evas_object_smart_callback_call(ewkView, "policy,navigation,decide", priv->policyDecision);
  1837. }
  1838. void ewkViewPolicyNewWindowDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
  1839. {
  1840. EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
  1841. EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
  1842. if (priv->policyDecision)
  1843. ewkPolicyDecisionDelete(priv->policyDecision);
  1844. priv->policyDecision = policyDecision;
  1845. evas_object_smart_callback_call(ewkView, "policy,newwindow,decide", priv->policyDecision);
  1846. }
  1847. void ewkViewPolicyResponseDecide(Evas_Object* ewkView, Ewk_Policy_Decision* policyDecision)
  1848. {
  1849. EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
  1850. EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
  1851. if (priv->policyDecision)
  1852. ewkPolicyDecisionDelete(priv->policyDecision);
  1853. priv->policyDecision = policyDecision;
  1854. evas_object_smart_callback_call(ewkView, "policy,response,decide", priv->policyDecision);
  1855. }
  1856. void ewkViewSendScrollEvent(Evas_Object* ewkView, int deltaX, int deltaY)
  1857. {
  1858. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1859. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1860. IntPoint scrollPosition = priv->pageClient->scrollPosition();
  1861. IntSize contentsSize = priv->pageClient->page()->contentsSize();
  1862. #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
  1863. contentsSize.scale(priv->pageClient->scaleFactor());
  1864. #endif
  1865. // some website's contents size is smaller than view size,
  1866. // so we have to adjust contents size to view size for that case.
  1867. if (contentsSize.width() < smartData->view.w)
  1868. contentsSize.setWidth(smartData->view.w);
  1869. if (contentsSize.height() < smartData->view.h)
  1870. contentsSize.setHeight(smartData->view.h);
  1871. // Call "scroll,down" if webview can be scrolled down.
  1872. if (deltaY > 0 && (scrollPosition.y() + smartData->view.h) < contentsSize.height())
  1873. evas_object_smart_callback_call(ewkView, "scroll,down", 0);
  1874. // Call "scroll,up" if webview can be scrolled up.
  1875. else if (deltaY < 0 && scrollPosition.y() > 0)
  1876. evas_object_smart_callback_call(ewkView, "scroll,up", 0);
  1877. // Call "scroll,right" if webview can be scrolled down.
  1878. if (deltaX > 0 && (scrollPosition.x() + smartData->view.w) < contentsSize.width())
  1879. evas_object_smart_callback_call(ewkView, "scroll,right", 0);
  1880. // Call "scroll,left" if webview can be scrolled up.
  1881. else if (deltaX < 0 && scrollPosition.x() > 0)
  1882. evas_object_smart_callback_call(ewkView, "scroll,left", 0);
  1883. }
  1884. void ewkViewSendEdgeEvent(Evas_Object* ewkView, const IntPoint& scrollPosition, int deltaX, int deltaY)
  1885. {
  1886. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1887. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1888. IntSize contentsSize = priv->pageClient->page()->contentsSize();
  1889. #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
  1890. contentsSize.scale(priv->pageClient->scaleFactor());
  1891. #endif
  1892. int maxScrollY = contentsSize.height() - smartData->view.h;
  1893. if (!priv->isVerticalEdge) {
  1894. if (deltaY < 0 && (scrollPosition.y() + deltaY) <= 0) {
  1895. evas_object_smart_callback_call(ewkView, "edge,top", NULL);
  1896. priv->isVerticalEdge = true;
  1897. } else if (deltaY > 0 && (scrollPosition.y() + deltaY) >= maxScrollY) {
  1898. evas_object_smart_callback_call(ewkView, "edge,bottom", NULL);
  1899. priv->isVerticalEdge = true;
  1900. }
  1901. } else {
  1902. if (maxScrollY && ((scrollPosition.y() == 0 && deltaY > 0)
  1903. || (scrollPosition.y() == maxScrollY && deltaY < 0)))
  1904. priv->isVerticalEdge = false;
  1905. }
  1906. int maxScrollX = contentsSize.width() - smartData->view.w;
  1907. if (!priv->isHorizontalEdge) {
  1908. if (deltaX < 0 && (scrollPosition.x() + deltaX) <= 0) {
  1909. evas_object_smart_callback_call(ewkView, "edge,left", NULL);
  1910. priv->isHorizontalEdge = true;
  1911. } else if (deltaX > 0 && (scrollPosition.x() + deltaX) >= maxScrollX) {
  1912. evas_object_smart_callback_call(ewkView, "edge,right", NULL);
  1913. priv->isHorizontalEdge = true;
  1914. }
  1915. } else {
  1916. if (maxScrollX && ((scrollPosition.x() == 0 && deltaX > 0)
  1917. || (scrollPosition.x() == maxScrollX && deltaX < 0)))
  1918. priv->isHorizontalEdge = false;
  1919. }
  1920. }
  1921. void ewkViewClearEdges(Evas_Object* ewkView)
  1922. {
  1923. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1924. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1925. priv->isVerticalEdge = false;
  1926. priv->isHorizontalEdge = false;
  1927. }
  1928. void ewk_view_top_of_contents_go(Evas_Object* ewkView)
  1929. {
  1930. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  1931. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  1932. #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
  1933. priv->pageClient->setVisibleContentRect(IntPoint(), priv->pageClient->scaleFactor(), FloatPoint());
  1934. priv->pageClient->displayViewport();
  1935. #else
  1936. priv->pageClient->page()->scrollMainFrameTo(IntPoint());
  1937. #endif
  1938. }
  1939. Eina_Bool ewk_view_enable_specified_plugin_set(Evas_Object* ewkView, Eina_Bool enable, const char* mimeType)
  1940. {
  1941. #if ENABLE(TIZEN_ON_OFF_SPECIFIED_PLUGINS)
  1942. if (!mimeType)
  1943. return false;
  1944. PluginDatabase* pluginDatabase = PluginDatabase::installedPlugins(true);
  1945. if (!pluginDatabase)
  1946. return false;
  1947. // Find pluginPackage.
  1948. String key = String(mimeType).lower();
  1949. Vector<PluginPackage*, 2> pluginChoices;
  1950. const Vector<WebCore::PluginPackage *> plugins = pluginDatabase->plugins();
  1951. for (unsigned int i = 0; i < plugins.size(); i++) {
  1952. PluginPackage* plugin = plugins[i];
  1953. if (plugin->mimeToDescriptions().contains(key))
  1954. pluginChoices.append(plugin);
  1955. }
  1956. // Set enable/disable to choiced pluginPackage.
  1957. if (!pluginChoices.isEmpty()) {
  1958. qsort(pluginChoices.data(), pluginChoices.size(), sizeof(PluginPackage*), PluginDatabase::preferredPluginCompare);
  1959. pluginChoices[0].setEnabled(enable);
  1960. return true;
  1961. }
  1962. return false;
  1963. #else
  1964. return false;
  1965. #endif
  1966. }
  1967. double ewk_view_scale_get(Evas_Object* ewkView)
  1968. {
  1969. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
  1970. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1);
  1971. return priv->pageClient->page()->scaleFactor();
  1972. }
  1973. Eina_Bool ewk_view_scale_set(Evas_Object* ewkView, double scaleFactor, Evas_Coord centerX, Evas_Coord centerY)
  1974. {
  1975. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  1976. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  1977. scaleFactor = priv->pageClient->adjustScaleWithViewport(scaleFactor);
  1978. IntPoint scrollPosition = priv->pageClient->scrollPosition();
  1979. double scaleDifference = scaleFactor / priv->pageClient->scaleFactor();
  1980. int newScrollX = (scrollPosition.x() + centerX - smartData->view.x) * scaleDifference - (centerX - smartData->view.x);
  1981. int newScrollY = (scrollPosition.y() + centerY - smartData->view.y) * scaleDifference - (centerY - smartData->view.y);
  1982. priv->pageClient->page()->scale(scaleFactor, IntPoint(newScrollX, newScrollY));
  1983. return true;
  1984. }
  1985. void ewk_view_scale_range_get(Evas_Object* ewkView, double* minimumScale, double* maximumScale)
  1986. {
  1987. EWK_VIEW_SD_GET(ewkView, smartData);
  1988. if (!smartData || !smartData->priv) {
  1989. if (minimumScale)
  1990. *minimumScale = -1;
  1991. if (maximumScale)
  1992. *maximumScale = -1;
  1993. return;
  1994. }
  1995. PageClientImpl::ViewportConstraints constraints = smartData->priv->pageClient->viewportConstraints();
  1996. if (minimumScale)
  1997. *minimumScale = constraints.minimumScale;
  1998. if (maximumScale)
  1999. *maximumScale = constraints.maximumScale;
  2000. }
  2001. static void inputPickerClosed(void* data, Evas_Object*, void*)
  2002. {
  2003. Evas_Object* ewkView = static_cast<Evas_Object*>(data);
  2004. EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd);
  2005. EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
  2006. ecore_imf_context_input_panel_hide(priv->pageClient->getIMFContext());
  2007. ecore_imf_context_focus_out(priv->pageClient->getIMFContext());
  2008. }
  2009. Evas_Object* ewk_view_image_get(Evas_Object* o)
  2010. {
  2011. EWK_VIEW_SD_GET_OR_RETURN(o, sd, 0);
  2012. return sd->image;
  2013. }
  2014. void ewk_view_form_navigation_move(Evas_Object* ewkView, int newPosition)
  2015. {
  2016. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2017. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2018. priv->pageClient->page()->moveFocus(newPosition);
  2019. priv->formNavigation.position = newPosition;
  2020. }
  2021. bool ewk_view_focused_node_adjust(Evas_Object* ewkView)
  2022. {
  2023. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2024. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2025. double scaleFactor = priv->pageClient->scaleFactor();
  2026. IntSize contentsSize = priv->pageClient->page()->contentsSize();
  2027. IntSize visibleSize(0, 0);
  2028. IntPoint scrollPosition(0, 0);
  2029. IntRect caretRect(0, 0, 0, 0);
  2030. double newScaleFactor = scaleFactor;
  2031. // Readable zoom value is dependent on device DPI
  2032. if (scaleFactor < priv->pageClient->page()->pageGroup()->preferences()->devicePixelRatio()
  2033. && priv->pageClient->viewportConstraints().userScalable)
  2034. newScaleFactor = ((float)priv->pageClient->page()->pageGroup()->preferences()->devicePixelRatio()) / 160;
  2035. // Readable zoom value should be inside of viewport scale range
  2036. newScaleFactor = priv->pageClient->adjustScaleWithViewport(newScaleFactor);
  2037. // scale contents' size with new scale factor
  2038. #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
  2039. contentsSize.scale(newScaleFactor);
  2040. #else
  2041. contentsSize.scale(newScaleFactor / scaleFactor);
  2042. #endif
  2043. Ecore_IMF_Context* imfContext = priv->pageClient->getIMFContext();
  2044. // We should treat both of ECORE_IMF_INPUT_PANEL_STATE_SHOW and ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW
  2045. // as IME is shown. ECORE_IMF_INPUT_PANEL_STATE_HIDE is ignored at here.
  2046. if (!(static_cast<PageClient*>(priv->pageClient.get()))->isViewFocused()
  2047. || !imfContext
  2048. || ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
  2049. return false;
  2050. visibleSize = IntSize(smartData->view.w, smartData->view.h);
  2051. // caret position can be outside of visible rect.
  2052. // we need to consider it.
  2053. priv->pageClient->page()->getCaretPosition(caretRect);
  2054. #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
  2055. caretRect.scale(newScaleFactor);
  2056. #else
  2057. caretRect.scale(newScaleFactor / scaleFactor);
  2058. #endif
  2059. if (caretRect.isEmpty())
  2060. return false;
  2061. // set paddings
  2062. scrollPosition.setX(caretRect.x() - 20);
  2063. scrollPosition.setY(caretRect.y() - visibleSize.height() / 2);
  2064. // Restrict visible content rect inside of contents boundary
  2065. if (scrollPosition.x() < 0)
  2066. scrollPosition.setX(0);
  2067. if (scrollPosition.y() < 0)
  2068. scrollPosition.setY(0);
  2069. if (scrollPosition.x() + visibleSize.width() > contentsSize.width())
  2070. scrollPosition.setX(contentsSize.width() - visibleSize.width());
  2071. if (scrollPosition.y() + visibleSize.height() > contentsSize.height())
  2072. scrollPosition.setY(contentsSize.height() - visibleSize.height());
  2073. #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
  2074. priv->pageClient->setVisibleContentRect(scrollPosition, newScaleFactor, FloatPoint());
  2075. if (newScaleFactor == scaleFactor)
  2076. priv->pageClient->displayViewport();
  2077. #else
  2078. if (newScaleFactor != scaleFactor)
  2079. priv->pageClient->page()->scalePage(newScaleFactor, scrollPosition);
  2080. else
  2081. priv->pageClient->page()->scrollMainFrameTo(scrollPosition);
  2082. #endif
  2083. evas_object_move(smartData->image, smartData->view.x, smartData->view.y);
  2084. return true;
  2085. }
  2086. #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
  2087. void ewk_view_mark_for_sync(Evas_Object* ewkView)
  2088. {
  2089. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2090. EINA_SAFETY_ON_NULL_RETURN(smartData->image);
  2091. evas_object_image_pixels_dirty_set(smartData->image, true);
  2092. }
  2093. static void on_pixels_for_accelerated_compositing(void* data, Evas_Object* obj)
  2094. {
  2095. Evas_Object* ewkView = static_cast<Evas_Object*>(data);
  2096. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2097. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2098. priv->pageClient->drawContents();
  2099. }
  2100. bool ewk_view_image_native_surface_set(Evas_Object* ewkView, Evas_Native_Surface* nativeSurface)
  2101. {
  2102. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2103. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2104. if (!smartData->image)
  2105. return false;
  2106. evas_object_image_native_surface_set(smartData->image, nativeSurface);
  2107. evas_object_image_pixels_get_callback_set(smartData->image, on_pixels_for_accelerated_compositing, ewkView);
  2108. return true;
  2109. }
  2110. #endif
  2111. #if ENABLE(TIZEN_WEBKIT_PASTEBOARD)
  2112. void ewk_view_write_data_to_clipboard_with_type(Evas_Object* ewkView, const String& data, Pasteboard::PasteboardDataType type)
  2113. {
  2114. EINA_SAFETY_ON_NULL_RETURN(ewkView);
  2115. switch (type) {
  2116. case Pasteboard::PlainText:
  2117. elm_cnp_selection_set(elm_object_parent_widget_get(ewkView), ELM_SEL_TYPE_CLIPBOARD,
  2118. ELM_SEL_FORMAT_TEXT, data.utf8().data(), data.length());
  2119. break;
  2120. case Pasteboard::Markup:
  2121. elm_cnp_selection_set(elm_object_parent_widget_get(ewkView), ELM_SEL_TYPE_CLIPBOARD,
  2122. ELM_SEL_FORMAT_HTML, data.utf8().data(), data.length());
  2123. break;
  2124. case Pasteboard::ImageURI:
  2125. // FIXME: We pass data.length() + 1 because of a bug in elementary which adds some random characters
  2126. // to copied image path. '+1' should be removed when the bug will be fixed on elementary side.
  2127. elm_cnp_selection_set(elm_object_parent_widget_get(ewkView), ELM_SEL_TYPE_CLIPBOARD,
  2128. ELM_SEL_FORMAT_IMAGE, data.utf8().data(), data.length() + 1);
  2129. break;
  2130. default:
  2131. break;
  2132. }
  2133. }
  2134. static Eina_Bool pasteCallback(void* data, Evas_Object* object, Elm_Selection_Data* selectionData)
  2135. {
  2136. WebPageProxy* webPageProxy = static_cast<WebPageProxy*>(data);
  2137. if (!selectionData || selectionData->len <= 0) {
  2138. webPageProxy->sendPasteMessageWithData(String(""), WebCore::Pasteboard::PlainText);
  2139. } else {
  2140. String data = String::fromUTF8(static_cast<const char*>(selectionData->data));
  2141. if (selectionData->format == ELM_SEL_FORMAT_TEXT)
  2142. webPageProxy->sendPasteMessageWithData(data, WebCore::Pasteboard::PlainText);
  2143. else if (selectionData->format == ELM_SEL_FORMAT_HTML)
  2144. webPageProxy->sendPasteMessageWithData(data, WebCore::Pasteboard::Markup);
  2145. else if (selectionData->format == ELM_SEL_FORMAT_IMAGE)
  2146. webPageProxy->sendPasteMessageWithData(data, WebCore::Pasteboard::ImageURI);
  2147. }
  2148. return true;
  2149. }
  2150. void ewk_view_paste_with_clipboard(Evas_Object* ewkView)
  2151. {
  2152. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2153. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2154. if (!ewk_util_number_of_clipboard_items_get(ewkView)) {
  2155. priv->pageClient->page()->sendPasteMessageWithData(String(""), WebCore::Pasteboard::PlainText);
  2156. return;
  2157. }
  2158. Eina_Bool result = elm_cnp_selection_get(elm_object_parent_widget_get(ewkView), ELM_SEL_TYPE_CLIPBOARD,
  2159. static_cast<Elm_Sel_Format>(ELM_SEL_FORMAT_TEXT | ELM_SEL_FORMAT_HTML | ELM_SEL_FORMAT_IMAGE),
  2160. pasteCallback, priv->pageClient->page());
  2161. if (!result)
  2162. priv->pageClient->page()->sendPasteMessageWithData(String(""), WebCore::Pasteboard::PlainText);
  2163. }
  2164. #endif // ENABLE(TIZEN_WEBKIT_PASTEBOARD)
  2165. void ewk_view_suspend(Evas_Object* ewkView)
  2166. {
  2167. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2168. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2169. priv->pageClient->suspendIfNeeded();
  2170. }
  2171. void ewk_view_resume(Evas_Object* ewkView)
  2172. {
  2173. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2174. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2175. priv->pageClient->resumeIfNeeded();
  2176. }
  2177. Eina_Bool ewk_view_url_request_set(Evas_Object* ewkView, const char* url, Ewk_Http_Method method, Eina_Hash* headers, const char* body)
  2178. {
  2179. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2180. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2181. EINA_SAFETY_ON_NULL_RETURN_VAL(url, false);
  2182. ResourceRequest request(url);
  2183. switch (method) {
  2184. case EWK_HTTP_METHOD_GET:
  2185. request.setHTTPMethod("GET");
  2186. break;
  2187. case EWK_HTTP_METHOD_HEAD:
  2188. request.setHTTPMethod("HEAD");
  2189. break;
  2190. case EWK_HTTP_METHOD_POST:
  2191. request.setHTTPMethod("POST");
  2192. break;
  2193. case EWK_HTTP_METHOD_PUT:
  2194. request.setHTTPMethod("PUT");
  2195. break;
  2196. case EWK_HTTP_METHOD_DELETE:
  2197. request.setHTTPMethod("DELETE");
  2198. break;
  2199. default:
  2200. return false;
  2201. }
  2202. if (headers) {
  2203. Eina_Iterator* it = eina_hash_iterator_tuple_new(headers);
  2204. void* data;
  2205. while (eina_iterator_next(it, &data)) {
  2206. Eina_Hash_Tuple* t = static_cast<Eina_Hash_Tuple*>(data);
  2207. const char* name = static_cast<const char*>(t->key);
  2208. const char* value = static_cast<const char*>(t->data);
  2209. request.addHTTPHeaderField(name, value);
  2210. }
  2211. eina_iterator_free(it);
  2212. }
  2213. if (body)
  2214. request.setHTTPBody(FormData::create(body));
  2215. WKRetainPtr<WKURLRequestRef> urlRequest(AdoptWK,toAPI(WebURLRequest::create(request).leakRef()));
  2216. WKPageLoadURLRequest(toAPI(priv->pageClient->page()), urlRequest.get());
  2217. return true;
  2218. }
  2219. Eina_Bool ewk_view_plain_text_set(Evas_Object* ewkView, const char* plainText)
  2220. {
  2221. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2222. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2223. WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
  2224. WKPageLoadPlainTextString(toAPI(priv->pageClient->page()), plainTextRef.get());
  2225. return true;
  2226. }
  2227. Eina_Bool ewk_view_contents_set(Evas_Object* ewkView, const char* contents, size_t contentsSize, char* mimeType, char* encoding, char* baseUri)
  2228. {
  2229. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2230. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2231. EINA_SAFETY_ON_NULL_RETURN_VAL(contents, false);
  2232. if (contentsSize == 0)
  2233. return false;
  2234. String mimeTypeString;
  2235. if (mimeType)
  2236. mimeTypeString = String::fromUTF8(mimeType);
  2237. else
  2238. mimeTypeString = String::fromUTF8("text/html");
  2239. String encodingString;
  2240. if (encoding)
  2241. encodingString = String::fromUTF8(encoding);
  2242. else
  2243. encodingString = String::fromUTF8("UTF-8");
  2244. String baseUriString;
  2245. if (baseUri)
  2246. baseUriString = String::fromUTF8(baseUri);
  2247. else
  2248. baseUriString = String::fromUTF8("about:blank");
  2249. WKRetainPtr<WKDataRef> contentsRef(AdoptWK, WKDataCreate(reinterpret_cast<const unsigned char*>(contents), contentsSize));
  2250. priv->pageClient->page()->loadContentsbyMimeType(toImpl(contentsRef.get()), mimeTypeString, encodingString, baseUriString);
  2251. return true;
  2252. }
  2253. const char* ewk_view_title_get(const Evas_Object* ewkView)
  2254. {
  2255. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  2256. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  2257. return priv->title;
  2258. }
  2259. double ewk_view_load_progress_get(const Evas_Object* ewkView)
  2260. {
  2261. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, -1);
  2262. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, -1);
  2263. return WKPageGetEstimatedProgress(toAPI(priv->pageClient->page()));
  2264. }
  2265. Eina_Bool ewk_view_html_contents_set(Evas_Object* ewkView, const char* html, const char* baseUri)
  2266. {
  2267. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2268. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2269. WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(html));
  2270. WKRetainPtr<WKURLRef> baseURL(AdoptWK, WKURLCreateWithUTF8CString(baseUri));
  2271. WKPageLoadHTMLString(toAPI(priv->pageClient->page()), htmlString.get(), baseURL.get());
  2272. return true;
  2273. }
  2274. Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibility_State pageVisibilityState, Eina_Bool initialState)
  2275. {
  2276. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2277. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2278. #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
  2279. WKPageSetPageVisibility(toAPI(priv->pageClient->page()), static_cast<WKPageVisibilityState
  2280. >(pageVisibilityState), initialState);
  2281. return true;
  2282. #else
  2283. return false;
  2284. #endif
  2285. }
  2286. Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* userAgent)
  2287. {
  2288. EINA_SAFETY_ON_NULL_RETURN_VAL(userAgent, false);
  2289. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2290. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2291. eina_stringshare_replace(&priv->userAgent, userAgent);
  2292. WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKStringCreateWithUTF8CString(userAgent));
  2293. WKPageSetCustomUserAgent(toAPI(priv->pageClient->page()), userAgentString.get());
  2294. return true;
  2295. }
  2296. const char* ewk_view_user_agent_get(const Evas_Object* ewkView)
  2297. {
  2298. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  2299. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  2300. if (!priv->userAgent) {
  2301. WKRetainPtr<WKStringRef> userAgentString(AdoptWK, WKPageCopyUserAgent(toAPI(priv->pageClient->page())));
  2302. int length = WKStringGetMaximumUTF8CStringSize(userAgentString.get());
  2303. OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
  2304. WKStringGetUTF8CString(userAgentString.get(), buffer.get(), length);
  2305. eina_stringshare_replace(&priv->userAgent, buffer.get());
  2306. }
  2307. return priv->userAgent;
  2308. }
  2309. Eina_Bool ewk_view_custom_header_add(const Evas_Object* ewkView, const char* name, const char* value)
  2310. {
  2311. #if ENABLE(TIZEN_CUSTOM_HEADERS)
  2312. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2313. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2314. WKRetainPtr<WKStringRef> customHeaderName(AdoptWK, WKStringCreateWithUTF8CString(name));
  2315. WKRetainPtr<WKStringRef> customHeaderValue(AdoptWK, WKStringCreateWithUTF8CString(value));
  2316. WKPageAddCustomHeader(toAPI(priv->pageClient->page()), customHeaderName.get(), customHeaderValue.get());
  2317. return true;
  2318. #else
  2319. ERR("TIZEN_CUSTOM_HEADERS not enabled!");
  2320. return false;
  2321. #endif
  2322. }
  2323. const char* ewk_view_video_data_url_get(const Ewk_View_Html5_Video_Data* videoData)
  2324. {
  2325. #if ENABLE(TIZEN_MM_PLAYER)
  2326. if (!videoData || !videoData->url)
  2327. return "";
  2328. return toImpl(videoData->url)->string().utf8().data();
  2329. #else
  2330. return "";
  2331. #endif
  2332. }
  2333. const char* ewk_view_video_data_cookie_get(const Ewk_View_Html5_Video_Data* videoData)
  2334. {
  2335. #if ENABLE(TIZEN_MM_PLAYER)
  2336. if (!videoData || videoData->cookie)
  2337. return "";
  2338. return toImpl(videoData->cookie)->string().utf8().data();
  2339. #else
  2340. return "";
  2341. #endif
  2342. }
  2343. #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
  2344. Eina_Bool ewk_view_visibility_set(Evas_Object* ewkView, Eina_Bool enable)
  2345. {
  2346. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2347. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2348. priv->pageClient->setIsVisible(enable);
  2349. return true;
  2350. }
  2351. #endif
  2352. Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, Eina_Rectangle viewArea, float scaleFactor, Evas* canvas)
  2353. {
  2354. EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
  2355. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  2356. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  2357. WKRect rect;
  2358. rect.origin.x = viewArea.x;
  2359. rect.origin.y = viewArea.y;
  2360. rect.size.width = viewArea.w;
  2361. rect.size.height = viewArea.h;
  2362. WKRetainPtr<WKImageRef> snapshot(AdoptWK, WKPageCreateSnapshot(toAPI(priv->pageClient->page()), rect, scaleFactor));
  2363. if (!snapshot.get())
  2364. return 0;
  2365. RefPtr<cairo_surface_t> screenshotSurface = adoptRef(WKImageCreateCairoSurface(snapshot.get()));
  2366. Evas_Object* screenshotImage = evas_object_image_add(canvas);
  2367. int surfaceWidth = cairo_image_surface_get_width(screenshotSurface.get());
  2368. int surfaceHeight = cairo_image_surface_get_height(screenshotSurface.get());
  2369. evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
  2370. evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
  2371. uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshotImage, true));
  2372. 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)));
  2373. RefPtr<cairo_t> cairo = adoptRef(cairo_create(imageSurface.get()));
  2374. cairo_set_source_surface(cairo.get(), screenshotSurface.get(), 0, 0);
  2375. cairo_rectangle(cairo.get(), 0, 0, surfaceWidth, surfaceHeight);
  2376. cairo_fill(cairo.get());
  2377. evas_object_image_smooth_scale_set(screenshotImage, true);
  2378. evas_object_size_hint_min_set(screenshotImage, surfaceWidth, surfaceHeight);
  2379. evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
  2380. evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
  2381. evas_object_image_data_set(screenshotImage, pixels);
  2382. return screenshotImage;
  2383. }
  2384. unsigned int ewk_view_inspector_server_start(Evas_Object* ewkView, unsigned int port)
  2385. {
  2386. #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
  2387. EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, 0);
  2388. EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, 0);
  2389. return priv->pageClient->page()->startInspectorServer(port);
  2390. #else
  2391. LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
  2392. return 0;
  2393. #endif
  2394. }
  2395. Eina_Bool ewk_view_inspector_server_stop(Evas_Object* ewkView)
  2396. {
  2397. #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
  2398. EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
  2399. EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
  2400. return priv->pageClient->page()->stopInspectorServer();
  2401. #else
  2402. LOG_ERROR("TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR is disabled.\n");
  2403. return false;
  2404. #endif
  2405. }
  2406. void ewk_view_scroll_by(Evas_Object* ewkView, int deltaX, int deltaY)
  2407. {
  2408. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2409. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2410. WKPageScrollBy(toAPI(priv->pageClient->page()), toAPI(IntSize(deltaX, deltaY)));
  2411. }
  2412. Eina_Bool ewk_view_scroll_pos_get(Evas_Object* ewkView, int* x, int* y)
  2413. {
  2414. if (x)
  2415. *x = 0;
  2416. if (y)
  2417. *y = 0;
  2418. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2419. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2420. IntPoint scrollPosition = priv->pageClient->scrollPosition();
  2421. if (x)
  2422. *x = scrollPosition.x();
  2423. if (y)
  2424. *y = scrollPosition.y();
  2425. return true;
  2426. }
  2427. Eina_Bool ewk_view_scroll_set(Evas_Object* ewkView, int x, int y)
  2428. {
  2429. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2430. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2431. priv->pageClient->page()->scrollMainFrameTo(IntPoint(x, y));
  2432. return true;
  2433. }
  2434. Eina_Bool ewk_view_scroll_size_get(const Evas_Object* ewkView, int* width, int* height)
  2435. {
  2436. if (width)
  2437. *width = 0;
  2438. if (height)
  2439. *height = 0;
  2440. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2441. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2442. IntSize contentsSize = priv->pageClient->page()->contentsSize();
  2443. #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
  2444. contentsSize.scale(priv->pageClient->scaleFactor());
  2445. #endif
  2446. if (width && contentsSize.width() > smartData->view.w)
  2447. *width = contentsSize.width() - smartData->view.w;
  2448. if (height && contentsSize.height() > smartData->view.h)
  2449. *height = contentsSize.height() - smartData->view.h;
  2450. return true;
  2451. }
  2452. bool ewkViewRunJavaScriptAlert(Evas_Object* ewkView, WKStringRef alertText)
  2453. {
  2454. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2455. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2456. if (!priv->alertContext || !priv->alertContext->javascriptAlertCallback)
  2457. return false;
  2458. EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->alertContext->ewkView == ewkView, false);
  2459. int length = WKStringGetMaximumUTF8CStringSize(alertText);
  2460. OwnArrayPtr<char> alertTextBuffer = adoptArrayPtr(new char[length]);
  2461. WKStringGetUTF8CString(alertText, alertTextBuffer.get(), length);
  2462. return priv->alertContext->javascriptAlertCallback(priv->alertContext->ewkView, alertTextBuffer.get(), priv->alertContext->userData) == EINA_TRUE;
  2463. }
  2464. bool ewkViewRunJavaScriptConfirm(Evas_Object* ewkView, WKStringRef message)
  2465. {
  2466. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2467. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2468. if (!priv->confirmContext || !priv->confirmContext->javascriptConfirmCallback)
  2469. return false;
  2470. EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->confirmContext->ewkView == ewkView, false);
  2471. int length = WKStringGetMaximumUTF8CStringSize(message);
  2472. OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
  2473. WKStringGetUTF8CString(message, messageBuffer.get(), length);
  2474. return priv->confirmContext->javascriptConfirmCallback(priv->confirmContext->ewkView, messageBuffer.get(), priv->confirmContext->userData) == EINA_TRUE;
  2475. }
  2476. bool ewkViewRunJavaScriptPrompt(Evas_Object* ewkView, WKStringRef message, WKStringRef defaultValue)
  2477. {
  2478. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2479. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2480. if (!priv->promptContext || !priv->promptContext->javascriptPromptCallback)
  2481. return false;
  2482. EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->promptContext->ewkView == ewkView, false);
  2483. int length = WKStringGetMaximumUTF8CStringSize(message);
  2484. OwnArrayPtr<char> messageBuffer = adoptArrayPtr(new char[length]);
  2485. WKStringGetUTF8CString(message, messageBuffer.get(), length);
  2486. length = WKStringGetMaximumUTF8CStringSize(defaultValue);
  2487. OwnArrayPtr<char> defaultValueBuffer = adoptArrayPtr(new char[length]);
  2488. WKStringGetUTF8CString(defaultValue, defaultValueBuffer.get(), length);
  2489. return priv->promptContext->javascriptPromptCallback(priv->promptContext->ewkView, messageBuffer.get(), defaultValueBuffer.get(), priv->promptContext->userData) == EINA_TRUE;
  2490. }
  2491. bool ewkViewRunOpenPanel(Evas_Object* ewkView, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener)
  2492. {
  2493. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2494. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2495. if (!priv->openpanelContext || !priv->openpanelContext->openPanelCallback)
  2496. return false;
  2497. EINA_SAFETY_ON_FALSE_RETURN_VAL(priv->openpanelContext->ewkView == ewkView, false);
  2498. priv->openPanelListener = listener;
  2499. Eina_Bool allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? EINA_TRUE : EINA_FALSE;
  2500. Eina_List* acceptedMimeTypes = 0;
  2501. WKRetainPtr<WKArrayRef> array(AdoptWK, WKOpenPanelParametersCopyAcceptedMIMETypes(parameters));
  2502. size_t len = WKArrayGetSize(array.get());
  2503. for (size_t i = 0; i < len; i++) {
  2504. WKTypeRef item = WKArrayGetItemAtIndex(array.get(), i);
  2505. if (WKGetTypeID(item) != WKStringGetTypeID())
  2506. continue;
  2507. WKStringRef mime = static_cast<WKStringRef>(item);
  2508. int length = WKStringGetMaximumUTF8CStringSize(mime);
  2509. char* buffer = new char[length];
  2510. WKStringGetUTF8CString(mime, buffer, length);
  2511. acceptedMimeTypes = eina_list_append(acceptedMimeTypes, static_cast<const void*>(const_cast<const char*>(buffer)));
  2512. }
  2513. const char* capture = 0;
  2514. #if ENABLE(MEDIA_CAPTURE)
  2515. WKRetainPtr<WKStringRef> captureRef(AdoptWK, WKOpenPanelParametersCopyCapture(parameters));
  2516. capture = eina_stringshare_add(toImpl(captureRef.get())->string().utf8().data());
  2517. #endif
  2518. bool result = priv->openpanelContext->openPanelCallback(priv->openpanelContext->ewkView, allowMultipleFiles, acceptedMimeTypes, capture, 0);
  2519. if (!acceptedMimeTypes)
  2520. return result;
  2521. Eina_List* list;
  2522. void* data = 0;
  2523. EINA_LIST_FOREACH(acceptedMimeTypes, list, data)
  2524. delete[] (char*)data;
  2525. eina_list_free(acceptedMimeTypes);
  2526. return result;
  2527. }
  2528. void ewk_view_javascript_alert_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Alert_Callback callback, void* userData)
  2529. {
  2530. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2531. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2532. if (!priv->alertContext)
  2533. priv->alertContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
  2534. priv->alertContext->javascriptAlertCallback = callback;
  2535. priv->alertContext->ewkView = ewkView;
  2536. priv->alertContext->userData = userData;
  2537. }
  2538. void ewk_view_javascript_alert_reply(Evas_Object* ewkView)
  2539. {
  2540. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2541. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2542. WKPageReplyJavaScriptAlert(toAPI(ewk_view_page_get(ewkView)));
  2543. }
  2544. void ewk_view_javascript_confirm_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Confirm_Callback callback, void* userData)
  2545. {
  2546. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2547. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2548. if (!priv->confirmContext)
  2549. priv->confirmContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
  2550. priv->confirmContext->javascriptConfirmCallback = callback;
  2551. priv->confirmContext->ewkView = ewkView;
  2552. priv->confirmContext->userData = userData;
  2553. }
  2554. void ewk_view_javascript_confirm_reply(Evas_Object* ewkView, Eina_Bool result)
  2555. {
  2556. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2557. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2558. WKPageReplyJavaScriptConfirm(toAPI(ewk_view_page_get(ewkView)), result == EINA_TRUE);
  2559. }
  2560. void ewk_view_javascript_prompt_callback_set(Evas_Object* ewkView, Ewk_View_JavaScript_Prompt_Callback callback, void* userData)
  2561. {
  2562. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2563. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2564. if (!priv->promptContext)
  2565. priv->promptContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
  2566. priv->promptContext->javascriptPromptCallback = callback;
  2567. priv->promptContext->ewkView = ewkView;
  2568. priv->promptContext->userData = userData;
  2569. }
  2570. void ewk_view_javascript_prompt_reply(Evas_Object* ewkView, const char* result)
  2571. {
  2572. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2573. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2574. WKRetainPtr<WKStringRef> resultString(AdoptWK, WKStringCreateWithUTF8CString(result));
  2575. WKPageReplyJavaScriptPrompt(toAPI(ewk_view_page_get(ewkView)), result ? resultString.get() : 0);
  2576. }
  2577. void ewk_view_open_panel_callback_set(Evas_Object* ewkView, Ewk_View_Open_Panel_Callback callback, void* userData)
  2578. {
  2579. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2580. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2581. if (!priv->openpanelContext)
  2582. priv->openpanelContext = adoptPtr<Ewk_View_Callback_Context>(new Ewk_View_Callback_Context);
  2583. priv->openpanelContext->openPanelCallback = callback;
  2584. priv->openpanelContext->ewkView = ewkView;
  2585. priv->openpanelContext->userData = userData;
  2586. }
  2587. void ewk_view_open_panel_reply(Evas_Object* ewkView, Eina_List* fileUrls, Eina_Bool result)
  2588. {
  2589. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2590. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2591. if (!priv->openPanelListener)
  2592. return;
  2593. unsigned int size = eina_list_count(fileUrls);
  2594. if ((result == EINA_FALSE) || (size == 0)) {
  2595. WKOpenPanelResultListenerCancel(priv->openPanelListener);
  2596. priv->openPanelListener = 0;
  2597. return;
  2598. }
  2599. WKTypeRef* items = new WKTypeRef[size];
  2600. Eina_List* list;
  2601. void* data;
  2602. unsigned int i = 0;
  2603. EINA_LIST_FOREACH(fileUrls, list, data)
  2604. items[i++] = WKURLCreateWithUTF8CString((char*)data);
  2605. WKRetainPtr<WKArrayRef> filesArray(AdoptWK, WKArrayCreate(items, size));
  2606. WKOpenPanelResultListenerChooseFiles(priv->openPanelListener, filesArray.get());
  2607. priv->openPanelListener = 0;
  2608. delete [] items;
  2609. eina_list_free(fileUrls);
  2610. }
  2611. static void getRssItemsCallback(const Eina_List* rss_items, WKErrorRef, void* context)
  2612. {
  2613. EINA_SAFETY_ON_NULL_RETURN(context);
  2614. Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
  2615. ASSERT(callbackContext->rssItemsGetCallback);
  2616. callbackContext->rssItemsGetCallback(callbackContext->ewkView, rss_items, callbackContext->userData);
  2617. delete callbackContext;
  2618. }
  2619. Eina_Bool ewk_view_rss_items_get(Evas_Object* ewkView, Ewk_View_Rss_Items_Get_Callback callback, void* user_data)
  2620. {
  2621. EWK_VIEW_SD_GET_OR_RETURN(ewkView, sd, false);
  2622. EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
  2623. EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
  2624. Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
  2625. context->rssItemsGetCallback = callback;
  2626. context->ewkView = ewkView;
  2627. context->userData = user_data;
  2628. WKPageGetRssItems(toAPI(priv->pageClient->page()), context, getRssItemsCallback);
  2629. return true;
  2630. }
  2631. #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
  2632. static void didGetWebAppCapable(WKBooleanRef capable, WKErrorRef, void* context)
  2633. {
  2634. EINA_SAFETY_ON_NULL_RETURN(capable);
  2635. EINA_SAFETY_ON_NULL_RETURN(context);
  2636. Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
  2637. ASSERT(webAppContext->webAppCapableCallback);
  2638. if (capable)
  2639. webAppContext->webAppCapableCallback(toImpl(capable)->value(), webAppContext->userData);
  2640. else
  2641. webAppContext->webAppCapableCallback(0, webAppContext->userData);
  2642. delete webAppContext;
  2643. }
  2644. static void didGetWebAppIconURL(WKStringRef iconURL, WKErrorRef, void* context)
  2645. {
  2646. EINA_SAFETY_ON_NULL_RETURN(iconURL);
  2647. EINA_SAFETY_ON_NULL_RETURN(context);
  2648. Ewk_View_Callback_Context* webAppContext = static_cast<Ewk_View_Callback_Context*>(context);
  2649. EWK_VIEW_SD_GET_OR_RETURN(webAppContext->ewkView, smartData);
  2650. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2651. ASSERT(webAppContext->webAppIconURLCallback);
  2652. if (iconURL) {
  2653. eina_stringshare_replace(&priv->webAppIconURL, toImpl(iconURL)->string().utf8().data());
  2654. webAppContext->webAppIconURLCallback(priv->webAppIconURL, webAppContext->userData);
  2655. } else
  2656. webAppContext->webAppIconURLCallback(0, webAppContext->userData);
  2657. delete webAppContext;
  2658. }
  2659. #endif
  2660. Eina_Bool ewk_view_web_application_capable_get(Evas_Object* ewkView, Ewk_Web_App_Capable_Get_Callback callback, void* userData)
  2661. {
  2662. #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
  2663. EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
  2664. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  2665. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  2666. Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
  2667. context->webAppCapableCallback = callback;
  2668. context->ewkView = ewkView;
  2669. context->userData = userData;
  2670. WKPageGetWebAppCapable(toAPI(priv->pageClient->page()), context, didGetWebAppCapable);
  2671. return true;
  2672. #else
  2673. return false;
  2674. #endif
  2675. }
  2676. Eina_Bool ewk_view_web_application_icon_url_get(Evas_Object* ewkView, Ewk_Web_App_Icon_URL_Get_Callback callback, void* userData)
  2677. {
  2678. #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
  2679. EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
  2680. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  2681. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  2682. Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
  2683. context->webAppIconURLCallback = callback;
  2684. context->ewkView = ewkView;
  2685. context->userData = userData;
  2686. WKPageGetWebAppIconURL(toAPI(priv->pageClient->page()), context, didGetWebAppIconURL);
  2687. return true;
  2688. #else
  2689. return 0;
  2690. #endif
  2691. }
  2692. Eina_Bool ewk_view_command_execute(Evas_Object* ewkView, const char* command, const char* value)
  2693. {
  2694. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2695. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2696. EINA_SAFETY_ON_NULL_RETURN_VAL(command, false);
  2697. WKRetainPtr<WKStringRef> commandString(AdoptWK, WKStringCreateWithUTF8CString(command));
  2698. WKRetainPtr<WKStringRef> valueString(AdoptWK, WKStringCreateWithUTF8CString(value));
  2699. WKPageExecuteCommandWithArgument(toAPI(priv->pageClient->page()), commandString.get(), valueString.get());
  2700. return true;
  2701. }
  2702. Eina_Bool ewk_view_string_find(Evas_Object* ewkView, const char* string, EwkFindOptions options, unsigned maxMatchCount, Ewk_View_String_Find_Callback callback, void* userData)
  2703. {
  2704. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2705. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2706. EINA_SAFETY_ON_NULL_RETURN_VAL(string, false);
  2707. EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
  2708. priv->findClientInfo.callback = callback;
  2709. priv->findClientInfo.userData = userData;
  2710. WKRetainPtr<WKStringRef> findString(AdoptWK, WKStringCreateWithUTF8CString(string));
  2711. WKPageFindString(toAPI(priv->pageClient->page()), findString.get(), options, maxMatchCount);
  2712. return true;
  2713. }
  2714. Eina_Bool ewk_view_contents_size_get(Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height)
  2715. {
  2716. if (width)
  2717. *width = 0;
  2718. if (height)
  2719. *height = 0;
  2720. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2721. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2722. IntSize contentsSize = priv->pageClient->page()->contentsSize();
  2723. if (width)
  2724. *width = contentsSize.width();
  2725. if (height)
  2726. *height = contentsSize.height();
  2727. return true;
  2728. }
  2729. Eina_Bool ewk_view_contents_pdf_get(Evas_Object* ewkView, const char* fileName)
  2730. {
  2731. #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
  2732. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2733. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2734. EINA_SAFETY_ON_NULL_RETURN_VAL(fileName, false);
  2735. IntSize contentsSize = priv->pageClient->page()->contentsSize();
  2736. WKPageGetSnapshotPdfFile(toAPI(priv->pageClient->page()), toAPI(IntSize(contentsSize.width(), contentsSize.height())), WKStringCreateWithUTF8CString(fileName));
  2737. return true;
  2738. #else
  2739. return false;
  2740. #endif
  2741. }
  2742. static void runJavaScriptCallback(WKSerializedScriptValueRef scriptValue, WKErrorRef error, void* context)
  2743. {
  2744. EINA_SAFETY_ON_NULL_RETURN(context);
  2745. Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
  2746. if (!callbackContext->scriptExecuteCallback) {
  2747. delete callbackContext;
  2748. return;
  2749. }
  2750. JSGlobalContextRef jsGlobalContext = ewkViewGetJavascriptGlobalContext(callbackContext->ewkView);
  2751. if (scriptValue) {
  2752. JSValueRef value = WKSerializedScriptValueDeserialize(scriptValue, jsGlobalContext, 0);
  2753. JSRetainPtr<JSStringRef> jsStringValue(JSValueToStringCopy(jsGlobalContext, value, 0));
  2754. size_t length = JSStringGetMaximumUTF8CStringSize(jsStringValue.get());
  2755. OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
  2756. JSStringGetUTF8CString(jsStringValue.get(), buffer.get(), length);
  2757. callbackContext->scriptExecuteCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
  2758. } else
  2759. callbackContext->scriptExecuteCallback(callbackContext->ewkView, 0, callbackContext->userData);
  2760. delete callbackContext;
  2761. }
  2762. Eina_Bool ewk_view_script_execute(Evas_Object* ewkView, const char* script, Ewk_View_Script_Execute_Callback callback, void* user_data)
  2763. {
  2764. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2765. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2766. EINA_SAFETY_ON_NULL_RETURN_VAL(script, false);
  2767. Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
  2768. context->scriptExecuteCallback = callback;
  2769. context->ewkView = ewkView;
  2770. context->userData = user_data;
  2771. WKRetainPtr<WKStringRef> scriptString(AdoptWK, WKStringCreateWithUTF8CString(script));
  2772. WKPageRunJavaScriptInMainFrame(toAPI(priv->pageClient->page()), scriptString.get(), context, runJavaScriptCallback);
  2773. return true;
  2774. }
  2775. void ewk_view_theme_set(Evas_Object* ewkView, const char* path)
  2776. {
  2777. #if ENABLE(TIZEN_WEBKIT2_THEME_SET)
  2778. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2779. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2780. if (!eina_stringshare_replace(&priv->theme, path))
  2781. return;
  2782. priv->pageClient->page()->setThemePath(path);
  2783. #endif
  2784. }
  2785. const char* ewk_view_theme_get(const Evas_Object* ewkView)
  2786. {
  2787. #if ENABLE(TIZEN_WEBKIT2_THEME_SET)
  2788. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  2789. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  2790. return priv->theme;
  2791. #else
  2792. return 0;
  2793. #endif
  2794. }
  2795. void ewkViewDidFindString(Evas_Object* ewkView, WKStringRef string, unsigned maxMatchCount)
  2796. {
  2797. EINA_SAFETY_ON_NULL_RETURN(string);
  2798. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2799. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2800. int length = WKStringGetMaximumUTF8CStringSize(string);
  2801. OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
  2802. WKStringGetUTF8CString(string, buffer.get(), length);
  2803. if (priv->findClientInfo.callback)
  2804. priv->findClientInfo.callback(ewkView, buffer.get(), maxMatchCount, priv->findClientInfo.userData);
  2805. }
  2806. #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
  2807. static void didGetWebStorageQuota(WKUInt32Ref quota, WKErrorRef error, void* context)
  2808. {
  2809. Ewk_View_Callback_Context* storageContext = static_cast<Ewk_View_Callback_Context*>(context);
  2810. if (quota)
  2811. storageContext->webStorageQuotaCallback(toImpl(quota)->value(), storageContext->userData);
  2812. else
  2813. storageContext->webStorageQuotaCallback(0, storageContext->userData);
  2814. delete storageContext;
  2815. }
  2816. #endif
  2817. Eina_Bool ewk_view_web_storage_quota_get(const Evas_Object* ewkView, Ewk_Web_Storage_Quota_Get_Callback resultCallback, void* userData)
  2818. {
  2819. #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
  2820. EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
  2821. EINA_SAFETY_ON_NULL_RETURN_VAL(resultCallback, false);
  2822. Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
  2823. context->webStorageQuotaCallback = resultCallback;
  2824. context->userData = userData;
  2825. WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
  2826. WKPageGetWebStorageQuota(pageRef, context, didGetWebStorageQuota);
  2827. return true;
  2828. #else
  2829. return false;
  2830. #endif
  2831. }
  2832. Eina_Bool ewk_view_web_storage_quota_set(Evas_Object* ewkView, uint32_t quota)
  2833. {
  2834. #if ENABLE(TIZEN_WEB_STORAGE)
  2835. EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, false);
  2836. WKPageRef pageRef = toAPI(ewk_view_page_get(const_cast<Evas_Object*>(ewkView)));
  2837. WKPageSetWebStorageQuota(pageRef, quota);
  2838. return true;
  2839. #else
  2840. return false;
  2841. #endif
  2842. }
  2843. static void getContentsAsStringCallback(WKStringRef plain_text, WKErrorRef error, void* context)
  2844. {
  2845. EINA_SAFETY_ON_NULL_RETURN(context);
  2846. Ewk_View_Callback_Context* callbackContext = static_cast<Ewk_View_Callback_Context*>(context);
  2847. ASSERT(callbackContext->plainTextGetCallback);
  2848. if (plain_text) {
  2849. size_t length = WKStringGetMaximumUTF8CStringSize(plain_text);
  2850. OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
  2851. WKStringGetUTF8CString(plain_text, buffer.get(), length);
  2852. callbackContext->plainTextGetCallback(callbackContext->ewkView, buffer.get(), callbackContext->userData);
  2853. } else
  2854. callbackContext->plainTextGetCallback(callbackContext->ewkView, 0, callbackContext->userData);
  2855. delete callbackContext;
  2856. }
  2857. Eina_Bool ewk_view_plain_text_get(Evas_Object* ewkView, Ewk_View_Plain_Text_Get_Callback callback, void* user_data)
  2858. {
  2859. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2860. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2861. EINA_SAFETY_ON_NULL_RETURN_VAL(callback, false);
  2862. Ewk_View_Callback_Context* context = new Ewk_View_Callback_Context;
  2863. context->plainTextGetCallback = callback;
  2864. context->ewkView = ewkView;
  2865. context->userData = user_data;
  2866. WKPageGetContentsAsString(toAPI(priv->pageClient->page()), context, getContentsAsStringCallback);
  2867. return true;
  2868. }
  2869. Ewk_Hit_Test* ewk_view_hit_test_new(Evas_Object* ewkView, int x, int y, int hitTestMode)
  2870. {
  2871. #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
  2872. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  2873. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  2874. int viewPositionX;
  2875. int viewPositionY;
  2876. evas_object_geometry_get(ewkView, &viewPositionX, &viewPositionY, 0, 0);
  2877. IntPoint pointForHitTest(x, y);
  2878. #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
  2879. float revertScale = 1 / priv->pageClient->scaleFactor();
  2880. IntPoint scrollPosition = priv->pageClient->scrollPosition();
  2881. pointForHitTest.setX((scrollPosition.x() + (x - viewPositionX)) * revertScale);
  2882. pointForHitTest.setY((scrollPosition.y() + (y - viewPositionY)) * revertScale);
  2883. #else
  2884. pointForHitTest.setX(x - viewPositionX);
  2885. pointForHitTest.setY(y - viewPositionY);
  2886. #endif
  2887. WebHitTestResult::Data hitTestResultData = priv->pageClient->page()->hitTestResultAtPoint(pointForHitTest, hitTestMode);
  2888. Ewk_Hit_Test* hitTest = ewkHitTestCreate(hitTestResultData);
  2889. return hitTest;
  2890. #else
  2891. return 0;
  2892. #endif
  2893. }
  2894. Ewk_History* ewk_view_history_get(Evas_Object* ewkView)
  2895. {
  2896. EINA_SAFETY_ON_NULL_RETURN_VAL(ewkView, 0);
  2897. return ewkHistoryCreate(WKPageGetBackForwardList(toAPI(ewk_view_page_get(ewkView))));
  2898. }
  2899. Eina_Bool ewk_view_recording_surface_enable_set(Evas_Object* ewkView, Eina_Bool enable)
  2900. {
  2901. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2902. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2903. WKPageRecordingSurfaceSetEnable(toAPI(priv->pageClient->page()), enable);
  2904. return true;
  2905. }
  2906. Eina_Bool ewk_view_notification_closed(Evas_Object* ewkView, Eina_List* ewkNotifications)
  2907. {
  2908. #if ENABLE(TIZEN_NOTIFICATION)
  2909. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2910. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2911. EINA_SAFETY_ON_NULL_RETURN_VAL(priv->context, false);
  2912. if (!eina_list_count(ewkNotifications))
  2913. return false;
  2914. Eina_List* listIterator = 0;
  2915. void* data = 0;
  2916. Vector<WKTypeRef> ids;
  2917. EINA_LIST_FOREACH(ewkNotifications, listIterator, data) {
  2918. Ewk_Notification* notification = static_cast<Ewk_Notification*>(data);
  2919. WKUInt64Ref idRef = WKUInt64Create(ewk_notification_id_get(notification));
  2920. ids.append(idRef);
  2921. priv->notifications = eina_list_remove(priv->notifications, notification);
  2922. }
  2923. WKRetainPtr<WKArrayRef> notificationIDsArray(AdoptWK, WKArrayCreate(ids.data(), ids.size()));
  2924. WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(ewk_context_WKContext_get(priv->context));
  2925. WKNotificationManagerProviderDidCloseNotifications(notificationManager, notificationIDsArray.get());
  2926. ewkNotificationDeleteNotificationList(ewkNotifications);
  2927. return true;
  2928. #else
  2929. return false;
  2930. #endif
  2931. }
  2932. #if ENABLE(TIZEN_WEBKIT2_POPUP)
  2933. void ewk_view_popup_menu_request(Evas_Object* ewkView, WebPopupMenuProxyEfl* popupMenu, const IntRect& rect, TextDirection textDirection, double pageScaleFactor, const Vector<WebPopupItem>& items, int32_t selectedIndex)
  2934. {
  2935. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2936. EINA_SAFETY_ON_NULL_RETURN(smartData->api);
  2937. EINA_SAFETY_ON_NULL_RETURN(smartData->api->popup_menu_show);
  2938. ASSERT(popupMenenu);
  2939. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2940. if (priv->popupMenuProxy)
  2941. ewk_view_popup_menu_close(ewkView);
  2942. priv->popupMenuProxy = popupMenu;
  2943. Eina_List* popupItems = 0;
  2944. for (size_t i = 0; i < items.size(); ++i) {
  2945. Ewk_Popup_Menu_Item* item = new Ewk_Popup_Menu_Item;
  2946. if (items[i].m_type == WebPopupItem::Separator) {
  2947. item->type = EWK_POPUP_MENU_SEPARATOR;
  2948. item->text = 0;
  2949. } else {
  2950. item->type = EWK_POPUP_MENU_ITEM;
  2951. item->text = eina_stringshare_add(items[i].m_text.utf8().data());
  2952. }
  2953. popupItems = eina_list_append(popupItems, item);
  2954. }
  2955. priv->popupMenuItems = popupItems;
  2956. smartData->api->popup_menu_show(smartData, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, popupItems, selectedIndex);
  2957. }
  2958. Eina_Bool ewk_view_popup_menu_close(Evas_Object* ewkView)
  2959. {
  2960. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2961. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2962. EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
  2963. EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
  2964. if (smartData->api->popup_menu_hide)
  2965. smartData->api->popup_menu_hide(smartData);
  2966. void* itemv;
  2967. EINA_LIST_FREE(priv->popupMenuItems, itemv) {
  2968. Ewk_Popup_Menu_Item* item = static_cast<Ewk_Popup_Menu_Item*>(itemv);
  2969. eina_stringshare_del(item->text);
  2970. delete item;
  2971. }
  2972. priv->popupMenuProxy = 0;
  2973. }
  2974. Eina_Bool ewk_view_popup_menu_select(Evas_Object* ewkView, unsigned int selectedIndex)
  2975. {
  2976. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  2977. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  2978. EINA_SAFETY_ON_NULL_RETURN_VAL(priv->popupMenuProxy, false);
  2979. if (selectedIndex > eina_list_count(priv->popupMenuItems))
  2980. return false;
  2981. priv->popupMenuProxy->valueChanged(selectedIndex);
  2982. return true;
  2983. }
  2984. #endif
  2985. void ewk_view_orientation_send(Evas_Object* ewkView, int orientation)
  2986. {
  2987. #if ENABLE(TIZEN_ORIENTATION_EVENTS)
  2988. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  2989. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  2990. if (orientation != 0 && orientation != 90 && orientation != -90 && orientation != 180)
  2991. return;
  2992. if (priv->orientation == orientation)
  2993. return;
  2994. priv->orientation = orientation;
  2995. priv->pageClient->page()->sendOrientationChangeEvent(orientation);
  2996. #endif
  2997. }
  2998. void ewkViewFrameRendered(Evas_Object* ewkView)
  2999. {
  3000. evas_object_smart_callback_call(ewkView, "frame,rendered", 0);
  3001. }
  3002. const char* ewk_view_encoding_custom_get(const Evas_Object* ewkView)
  3003. {
  3004. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  3005. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  3006. WKRetainPtr<WKStringRef> encodingString(AdoptWK, WKPageCopyCustomTextEncodingName(toAPI(priv->pageClient->page())));
  3007. eina_stringshare_replace(&priv->encoding, toImpl(encodingString.get())->string().utf8().data());
  3008. return priv->encoding;
  3009. }
  3010. void ewk_view_encoding_custom_set(Evas_Object* ewkView, const char* encoding)
  3011. {
  3012. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  3013. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  3014. WKRetainPtr<WKStringRef> encodingString(AdoptWK, WKStringCreateWithUTF8CString(encoding));
  3015. WKPageSetCustomTextEncodingName(toAPI(priv->pageClient->page()), encodingString.get());
  3016. }
  3017. #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
  3018. Eina_Bool ewk_view_text_selection_enable_set(Evas_Object* ewkView, Eina_Bool enable)
  3019. {
  3020. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  3021. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  3022. priv->pageClient->setIsTextSelectionEnable(enable);
  3023. return true;
  3024. }
  3025. Eina_Bool ewk_view_text_selection_range_get(Evas_Object* ewkView, Eina_Rectangle* leftRect, Eina_Rectangle* rightRect)
  3026. {
  3027. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  3028. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
  3029. EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient->page()->focusedFrame(), false);
  3030. IntRect leftSelectionRect;
  3031. IntRect rightSelectionRect;
  3032. if (!priv->pageClient->page()->focusedFrame()->getSelectionHandlers(leftSelectionRect, rightSelectionRect)) {
  3033. leftRect->x = 0;
  3034. leftRect->y = 0;
  3035. leftRect->w = 0;
  3036. leftRect->h = 0;
  3037. rightRect->x = 0;
  3038. rightRect->y = 0;
  3039. rightRect->w = 0;
  3040. rightRect->h = 0;
  3041. return false;
  3042. }
  3043. int viewPositionX;
  3044. int viewPositionY;
  3045. evas_object_geometry_get(ewkView, &viewPositionX, &viewPositionY, 0, 0);
  3046. #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
  3047. float scaleFactor = priv->pageClient->scaleFactor();
  3048. IntPoint scrollPosition = priv->pageClient->scrollPosition();
  3049. leftSelectionRect.scale(scaleFactor);
  3050. leftSelectionRect.move(-scrollPosition.x(), -scrollPosition.y());
  3051. #endif
  3052. leftSelectionRect.move(viewPositionX, viewPositionY);
  3053. #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
  3054. rightSelectionRect.scale(scaleFactor);
  3055. rightSelectionRect.move(-scrollPosition.x(), -scrollPosition.y());
  3056. #endif
  3057. rightSelectionRect.move(viewPositionX, viewPositionY);
  3058. leftRect->x = leftSelectionRect.x();
  3059. leftRect->y = leftSelectionRect.y();
  3060. leftRect->w = leftSelectionRect.width();
  3061. leftRect->h = leftSelectionRect.height();
  3062. rightRect->x = rightSelectionRect.x();
  3063. rightRect->y = rightSelectionRect.y();
  3064. rightRect->w = rightSelectionRect.width();
  3065. rightRect->h = rightSelectionRect.height();
  3066. return true;;
  3067. }
  3068. const char* ewk_view_text_selection_text_get(Evas_Object* ewkView)
  3069. {
  3070. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  3071. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  3072. EINA_SAFETY_ON_NULL_RETURN_VAL(priv->pageClient->page()->focusedFrame(), 0);
  3073. const CString selectedString = priv->pageClient->page()->focusedFrame()->getSelectionText().utf8();
  3074. eina_stringshare_replace(&priv->selectedText, selectedString.data());
  3075. return priv->selectedText;
  3076. }
  3077. #endif // #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
  3078. #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
  3079. void ewkViewInputPickerRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, const String& inputValue)
  3080. {
  3081. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  3082. EINA_SAFETY_ON_NULL_RETURN(smartData->api);
  3083. EINA_SAFETY_ON_NULL_RETURN(smartData->api->input_picker_show);
  3084. smartData->api->input_picker_show(smartData, inputType, inputValue.utf8().data());
  3085. }
  3086. #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
  3087. void ewkViewColorChooserRequest(Evas_Object* ewkView, WebColorChooserProxyEfl* colorChooser, const String& inputValue)
  3088. {
  3089. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  3090. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  3091. priv->colorChooser = colorChooser;
  3092. ewkViewInputPickerRequest(ewkView, EWK_INPUT_TYPE_COLOR, inputValue);
  3093. }
  3094. #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
  3095. #endif
  3096. void ewk_view_focused_input_element_value_set(Evas_Object* ewkView, const char* value)
  3097. {
  3098. #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
  3099. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  3100. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  3101. priv->pageClient->page()->setFocusedInputElementValue(String(value));
  3102. #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
  3103. }
  3104. const char* ewk_view_focused_input_element_value_get(Evas_Object* ewkView)
  3105. {
  3106. #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
  3107. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
  3108. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
  3109. eina_stringshare_replace(&priv->inputValue, priv->pageClient->page()->getFocusedInputElementValue().utf8().data());
  3110. return priv->inputValue;
  3111. #else
  3112. return 0;
  3113. #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
  3114. }
  3115. void ewk_view_color_chooser_color_set(Evas_Object* ewkView, const char* color)
  3116. {
  3117. #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
  3118. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  3119. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  3120. if (priv->colorChooser)
  3121. priv->colorChooser->setSelectedColor(Color(color));
  3122. #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
  3123. }
  3124. void ewk_view_color_chooser_close(Evas_Object* ewkView)
  3125. {
  3126. #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
  3127. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  3128. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  3129. if (priv->colorChooser)
  3130. priv->colorChooser->endChooser();
  3131. priv->colorChooser = 0;
  3132. #endif // ENABLE(TIZEN_INPUT_COLOR_PICKER)
  3133. }
  3134. #if ENABLE(TIZEN_DATALIST_ELEMENT)
  3135. void ewkViewDataListShowRequest(Evas_Object* ewkView, Ewk_Input_Type inputType, Vector<String> optionList)
  3136. {
  3137. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  3138. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  3139. EINA_SAFETY_ON_NULL_RETURN(smartData->api);
  3140. EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_show);
  3141. if (priv->dataList)
  3142. ewkViewDataListHideRequest(ewkView, inputType);
  3143. for (Vector<String>::const_iterator it = optionList.begin(); it != optionList.end(); ++it) {
  3144. String value = *it;
  3145. priv->dataList = eina_list_append(priv->dataList, eina_stringshare_add(value.utf8().data()));
  3146. }
  3147. smartData->api->data_list_show(smartData, inputType, priv->dataList);
  3148. }
  3149. void ewkViewDataListHideRequest(Evas_Object* ewkView, Ewk_Input_Type inputType)
  3150. {
  3151. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  3152. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  3153. EINA_SAFETY_ON_NULL_RETURN(priv->dataList);
  3154. EINA_SAFETY_ON_NULL_RETURN(smartData->api);
  3155. EINA_SAFETY_ON_NULL_RETURN(smartData->api->data_list_hide);
  3156. if (priv->dataList) {
  3157. _ewk_view_data_list_del(priv->dataList);
  3158. priv->dataList = 0;
  3159. }
  3160. smartData->api->data_list_hide(smartData, inputType);
  3161. }
  3162. #endif
  3163. void ewk_view_data_list_close(Evas_Object* ewkView, const char* value)
  3164. {
  3165. #if ENABLE(TIZEN_DATALIST_ELEMENT)
  3166. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  3167. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  3168. if (priv->dataList) {
  3169. _ewk_view_data_list_del(priv->dataList);
  3170. priv->dataList = 0;
  3171. }
  3172. ewk_view_focused_input_element_value_set(ewkView, value);
  3173. #endif
  3174. }
  3175. Eina_Bool ewk_view_horizontal_panning_hold_get(Evas_Object* ewkView)
  3176. {
  3177. #if ENABLE(TIZEN_GESTURE)
  3178. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
  3179. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  3180. return priv->holdHorizontalPanning;
  3181. #else
  3182. return false;
  3183. #endif
  3184. }
  3185. void ewk_view_horizontal_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
  3186. {
  3187. #if ENABLE(TIZEN_GESTURE)
  3188. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
  3189. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
  3190. priv->holdHorizontalPanning = hold;
  3191. #endif
  3192. }
  3193. Eina_Bool ewk_view_vertical_panning_hold_get(Evas_Object* ewkView)
  3194. {
  3195. #if ENABLE(TIZEN_GESTURE)
  3196. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false)
  3197. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
  3198. return priv->holdVerticalPanning;
  3199. #else
  3200. return false;
  3201. #endif
  3202. }
  3203. void ewk_view_vertical_panning_hold_set(Evas_Object* ewkView, Eina_Bool hold)
  3204. {
  3205. #if ENABLE(TIZEN_GESTURE)
  3206. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
  3207. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
  3208. priv->holdVerticalPanning = hold;
  3209. #endif
  3210. }
  3211. void ewk_view_touch_event_handler_result_set(Evas_Object* ewkView, WebKit::WebEvent::Type type, bool wasHandled)
  3212. {
  3213. #if ENABLE(TIZEN_GESTURE)
  3214. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData)
  3215. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv)
  3216. #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
  3217. if (wasHandled)
  3218. ewkViewHideFocusRing(ewkView);
  3219. #endif // #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
  3220. if (priv->areMouseEventsEnabled)
  3221. return;
  3222. // We have to check TouchStart, TouchMove and TouchEnd with handled.
  3223. // The Pan and Flick will be enabled if Touch Start was not handled,
  3224. // and Touch Move was not handled or did not occur.
  3225. // Tap will be enabled if Touch Start and End was not handled
  3226. // and Touch Move did not occur.
  3227. // The gestures are disabled as a default.
  3228. // o: handled, x: not handled
  3229. // ------------------------------------------------------------
  3230. // Touch Start | Touch Move | Touch End || Tap | Pan, Flick
  3231. // ------------------------------------------------------------
  3232. // o | o or x | o or x || disable | disable
  3233. // x | o | o or x || disable | disable
  3234. // x | x | o or x || disable | enable
  3235. // x |not occured | x || enable | enable
  3236. // ------------------------------------------------------------
  3237. if (type == WebEvent::TouchStart)
  3238. priv->gestureRecognizer->setEnableGesture(!wasHandled);
  3239. else if (type == WebEvent::TouchMove)
  3240. priv->gestureRecognizer->setEnableMoving(!wasHandled);
  3241. else if (type == WebEvent::TouchEnd && !priv->exceedTouchMoveThreshold && !wasHandled) {
  3242. priv->gestureRecognizer->setEnableMoving(!wasHandled);
  3243. priv->gestureRecognizer->setEnableTap(!wasHandled);
  3244. }
  3245. #endif
  3246. }
  3247. #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
  3248. void ewkViewDidGetTextStyleStateForSelection(Evas_Object* ewkView, int underlineState, int italicState, int boldState)
  3249. {
  3250. Ewk_Text_Style* textStyle = ewkTextStyleCreate(underlineState, italicState, boldState);
  3251. evas_object_smart_callback_call(ewkView, "text,style,state", static_cast<void*>(textStyle));
  3252. ewkTextStyleDelete(textStyle);
  3253. }
  3254. #endif
  3255. #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
  3256. bool ewk_view_orientation_lock(Evas_Object* ewkView, int willLockOrientation)
  3257. {
  3258. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
  3259. EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->api, false);
  3260. if (!smartData->api->orientation_lock)
  3261. return false;
  3262. return smartData->api->orientation_lock(smartData, willLockOrientation);
  3263. }
  3264. void ewk_view_orientation_unlock(Evas_Object* ewkView)
  3265. {
  3266. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  3267. EINA_SAFETY_ON_NULL_RETURN(smartData->api);
  3268. if (!smartData->api->orientation_unlock)
  3269. return;
  3270. smartData->api->orientation_unlock(smartData);
  3271. }
  3272. #endif
  3273. void ewk_view_orientation_lock_callback_set(Evas_Object* ewkView, Ewk_Orientation_Lock_Cb func, void* data)
  3274. {
  3275. #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
  3276. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  3277. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  3278. priv->orientationLock.callback = func;
  3279. priv->orientationLock.data = data;
  3280. #endif
  3281. }
  3282. #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
  3283. Eina_Bool _ewk_orientation_lock(Ewk_View_Smart_Data *sd, int orientations)
  3284. {
  3285. EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv, false);
  3286. if (priv->orientationLock.callback) {
  3287. return priv->orientationLock.callback(sd->self, true, orientations, priv->orientationLock.data);
  3288. }
  3289. return false;
  3290. }
  3291. void _ewk_orientation_unlock(Ewk_View_Smart_Data *sd)
  3292. {
  3293. EWK_VIEW_PRIV_GET_OR_RETURN(sd, priv);
  3294. priv->orientationLock.callback(sd->self, false, 0, priv->orientationLock.data);
  3295. }
  3296. #endif
  3297. void ewk_view_zoomable_area_set(Evas_Object* ewkView, const IntPoint& target, const IntRect& area)
  3298. {
  3299. EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
  3300. EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
  3301. priv->gestureClient->setZoomableArea(target, area);
  3302. }
  3303. #endif // #if OS(TIZEN)