PageRenderTime 153ms CodeModel.GetById 40ms RepoModel.GetById 19ms 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

Large files files are truncated, but you can click here to view the full file

  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(

Large files files are truncated, but you can click here to view the full file