Create string tightly when retrive string from cbhm callback event
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / API / efl / EwkViewImpl.cpp
1 /*
2    Copyright (C) 2011 Samsung Electronics
3    Copyright (C) 2012 Intel Corporation. All rights reserved.
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14
15     You should have received a copy of the GNU Library General Public License
16     along with this library; see the file COPYING.LIB.  If not, write to
17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     Boston, MA 02110-1301, USA.
19 */
20
21 #include "config.h"
22 #include "EwkViewImpl.h"
23
24 #include "EflScreenUtilities.h"
25 #include "FindClientEfl.h"
26 #include "FormClientEfl.h"
27 #include "InputMethodContextEfl.h"
28 #include "PageClientImpl.h"
29 #include "PageLoadClientEfl.h"
30 #include "PagePolicyClientEfl.h"
31 #include "PageUIClientEfl.h"
32 #if ENABLE(WAIT_UPVERSION)
33 #include "PageViewportController.h"
34 #include "PageViewportControllerClientEfl.h"
35 #endif
36 #include "ResourceLoadClientEfl.h"
37 #include "WKColorPickerResultListener.h"
38 #include "WKString.h"
39 #include "WebPageProxy.h"
40 #include "WebPopupMenuProxyEfl.h"
41 #include "ewk_back_forward_list_private.h"
42 #include "ewk_context_private.h"
43 #include "ewk_favicon_database_private.h"
44 #include "ewk_popup_menu_item_private.h"
45 #include "ewk_private.h"
46 #include "ewk_settings_private.h"
47 #include "ewk_view.h"
48 #include "ewk_view_private.h"
49 #include <Ecore_Evas.h>
50 #include <Edje.h>
51 #include <WebCore/Cursor.h>
52
53 #if OS(TIZEN)
54 #if ENABLE(TIZEN_GEOLOCATION)
55 #include "ewk_geolocation_private.h"
56 #endif
57 #if ENABLE(TIZEN_MEDIA_STREAM)
58 #include "ewk_user_media_private.h"
59 #endif
60 #if ENABLE(TIZEN_NOTIFICATIONS)
61 #include "ewk_notification_private.h"
62 #endif
63 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
64 #include "WebPageGroup.h"
65 #endif
66 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
67 #include "ewk_web_application_icon_data_private.h"
68 #endif
69 #endif
70
71 using namespace WebCore;
72 using namespace WebKit;
73
74 static const int defaultCursorSize = 16;
75
76 EwkViewImpl::PageViewMap EwkViewImpl::pageViewMap;
77
78 void EwkViewImpl::addToPageViewMap(const Evas_Object* ewkView)
79 {
80     EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(ewkView);
81
82     PageViewMap::AddResult result = pageViewMap.add(viewImpl->wkPage(), ewkView);
83     ASSERT_UNUSED(result, result.isNewEntry);
84 }
85
86 void EwkViewImpl::removeFromPageViewMap(const Evas_Object* ewkView)
87 {
88     EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(ewkView);
89
90     ASSERT(pageViewMap.contains(viewImpl->wkPage()));
91     pageViewMap.remove(viewImpl->wkPage());
92 }
93
94 const Evas_Object* EwkViewImpl::viewFromPageViewMap(const WKPageRef page)
95 {
96     ASSERT(page);
97
98     return pageViewMap.get(page);
99 }
100
101 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
102 static uint64_t generatePageGroupIdentifierID()
103 {
104     static uint64_t uniquePageGroupIdentifierID = 1;
105     return uniquePageGroupIdentifierID++;
106 }
107 #endif
108
109 EwkViewImpl::EwkViewImpl(Evas_Object* view)
110     : popupMenuProxy(0)
111     , popupMenuItems(0)
112 #if USE(ACCELERATED_COMPOSITING)
113     , evasGl(0)
114     , evasGlContext(0)
115     , evasGlSurface(0)
116 #endif
117 #if OS(TIZEN)
118 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
119     , orientation(0)
120 #endif
121     , javascriptGlobalContext(0)
122 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
123     , webAppIconURLs(0)
124 #endif
125     , isWaitingForJavaScriptPopupReply(false)
126     , authChallenge(0)
127     , policyDecision(0)
128     , openPanelListener(0)
129 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
130     , certificatePolicyDecision(0)
131 #endif
132 #if ENABLE(TIZEN_MEDIA_STREAM)
133     , userMediaPermissionRequests(0)
134 #endif
135 #if ENABLE(TIZEN_GEOLOCATION)
136     , geolocation(0)
137     , geolocationPermissionRequests(0)
138 #endif
139     , suspendRequested(false)
140     , suspendedPainting(false)
141     , suspendedResources(false)
142 #if ENABLE(TIZEN_NOTIFICATIONS)
143     , notifications(0)
144     , notificationPermissionRequests(0)
145 #endif
146 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
147     , popupPicker(0)
148 #endif
149     , isVerticalEdge(false)
150     , isHorizontalEdge(false)
151 #if ENABLE(TIZEN_GESTURE)
152 #if ENABLE(TOUCH_EVENTS)
153     , exceedTouchMoveThreshold(false)
154     , wasHandledTouchStart(false)
155     , wasHandledTouchMove(false)
156 #endif
157     , holdHorizontalPanning(false)
158     , holdVerticalPanning(false)
159 #endif // #if ENABLE(TIZEN_GESTURE)
160 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
161     , compositionAnimator(0)
162 #endif
163 #if ENABLE(TIZEN_DATALIST_ELEMENT)
164     , dataList(0)
165 #endif
166 #if ENABLE(TIZEN_APPLICATION_CACHE)
167     , applicationCachePermissionOrigin(0)
168     , isWaitingForApplicationCachePermission(false)
169 #endif
170     , exceededQuotaOrigin(0)
171     , isWaitingForExceededQuotaPopupReply(false)
172 #endif // #if OS(TIZEN)
173     , m_view(view)
174     , m_settings(Ewk_Settings::create(this))
175     , m_mouseEventsEnabled(false)
176 #if ENABLE(TOUCH_EVENTS)
177     , m_touchEventsEnabled(false)
178 #endif
179     , m_displayTimer(this, &EwkViewImpl::displayTimerFired)
180     , m_inputMethodContext(InputMethodContextEfl::create(this, smartData()->base.evas))
181 #if OS(TIZEN)
182 #if USE(TILED_BACKING_STORE)
183     , m_scaleFactor(1)
184 #endif
185 #endif // #if OS(TIZEN)
186 {
187     ASSERT(view);
188
189     // Enable mouse events by default
190     setMouseEventsEnabled(true);
191
192 #if OS(TIZEN)
193     javascriptPopup = adoptPtr<JavaScriptPopup>(new JavaScriptPopup(m_view));
194     openPanel = adoptPtr<OpenPanel>(new OpenPanel(m_view));
195
196 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
197     inputPicker = adoptPtr<InputPicker>(new InputPicker(m_view));
198 #endif
199
200 #if ENABLE(TIZEN_GESTURE)
201 #if ENABLE(TOUCH_EVENTS)
202     touchDownPoint.x = 0;
203     touchDownPoint.y = 0;
204 #endif
205 #endif
206
207 #if ENABLE(TIZEN_GESTURE)
208     gestureRecognizer = GestureRecognizer::create(m_view);
209     gestureClient = GestureClient::create(this);
210 #endif
211
212 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
213     const char* hideScrollbar = getenv("TIZEN_WEBKIT2_TILED_SCROLLBAR_HIDE");
214     if (hideScrollbar && atoi(hideScrollbar) == 1)
215         mainFrameScrollbarVisibility = false;
216     else
217         mainFrameScrollbarVisibility = true;
218 #endif
219
220 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
221     orientationLock.callback = 0;
222     orientationLock.data = 0;
223 #endif
224
225 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
226     String pageGroupIdentifierID = String::number(generatePageGroupIdentifierID());
227     String pageGroupIdentifier = String::format("PageGroup%s", pageGroupIdentifierID.utf8().data());
228
229     WKRetainPtr<WKStringRef> pageGroupIdentifierRef(AdoptWK, WKStringCreateWithUTF8CString(pageGroupIdentifier.utf8().data()));
230     pageGroup = WebPageGroup::create(toWTFString(pageGroupIdentifierRef.get()));
231 #endif
232 #endif // #if OS(TIZEN)
233 }
234
235 EwkViewImpl::~EwkViewImpl()
236 {
237     void* item;
238     EINA_LIST_FREE(popupMenuItems, item)
239         delete static_cast<Ewk_Popup_Menu_Item*>(item);
240
241 #if OS(TIZEN)
242     if (javascriptGlobalContext)
243         JSGlobalContextRelease(javascriptGlobalContext);
244
245 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
246     if (webAppIconURLs) {
247         void* data = 0;
248         EINA_LIST_FREE(webAppIconURLs, data)
249             ewkWebAppIconDataDelete(static_cast<Ewk_Web_App_Icon_Data*>(data));
250     }
251 #endif
252
253     if (authChallenge)
254         ewkAuthChallengeDelete(authChallenge);
255     if (policyDecision)
256         ewkPolicyDecisionDelete(policyDecision);
257
258 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
259     if (certificatePolicyDecision)
260         ewkCertificatePolicyDecisionDelete(certificatePolicyDecision);
261 #endif
262
263 #if ENABLE(TIZEN_MEDIA_STREAM)
264     if (userMediaPermissionRequests)
265         ewkUserMediaDeletePermissionRequestList(userMediaPermissionRequests);
266 #endif
267
268 #if ENABLE(TIZEN_DATALIST_ELEMENT)
269     deleteDataList();
270 #endif
271
272 #if ENABLE(TIZEN_GEOLOCATION)
273     if (geolocation)
274         ewkGeolocationDeleteGeolocation(geolocation);
275     if (geolocationPermissionRequests)
276         ewkGeolocationDeletePermissionRequestList(geolocationPermissionRequests);
277 #endif
278
279 #if ENABLE(TIZEN_NOTIFICATIONS)
280     if (notifications)
281         ewkNotificationDeleteNotificationList(notifications);
282     if (notificationPermissionRequests)
283         ewkNotificationDeletePermissionRequestList(notificationPermissionRequests);
284 #endif
285
286 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
287     if (compositionAnimator)
288         ecore_animator_del(compositionAnimator);
289 #endif
290
291 #if ENABLE(TIZEN_APPLICATION_CACHE)
292     if (applicationCachePermissionOrigin)
293         deleteSecurityOrigin(applicationCachePermissionOrigin);
294 #endif
295
296     if (exceededQuotaOrigin)
297         deleteSecurityOrigin(exceededQuotaOrigin);
298 #endif // #if OS(TIZEN)
299 }
300
301 Ewk_View_Smart_Data* EwkViewImpl::smartData() const
302 {
303     return static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_view));
304 }
305
306 EwkViewImpl* EwkViewImpl::fromEvasObject(const Evas_Object* view)
307 {
308     ASSERT(view);
309     Ewk_View_Smart_Data* sd = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(view));
310     ASSERT(sd);
311     ASSERT(sd->priv);
312     return sd->priv;
313 }
314
315 /**
316  * @internal
317  * Retrieves the internal WKPage for this view.
318  */
319 WKPageRef EwkViewImpl::wkPage()
320 {
321     return toAPI(pageProxy.get());
322 }
323
324 void EwkViewImpl::setCursor(const Cursor& cursor)
325 {
326     Ewk_View_Smart_Data* sd = smartData();
327
328     const char* group = cursor.platformCursor();
329     if (!group || group == m_cursorGroup)
330         return;
331
332     m_cursorGroup = group;
333     m_cursorObject = adoptRef(edje_object_add(sd->base.evas));
334
335     Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(sd->base.evas);
336     if (!m_theme || !edje_object_file_set(m_cursorObject.get(), m_theme, group)) {
337         m_cursorObject.clear();
338
339         ecore_evas_object_cursor_set(ecoreEvas, 0, 0, 0, 0);
340 #ifdef HAVE_ECORE_X
341         if (WebCore::isUsingEcoreX(sd->base.evas))
342             WebCore::applyFallbackCursor(ecoreEvas, group);
343 #endif
344         return;
345     }
346
347     Evas_Coord width, height;
348     edje_object_size_min_get(m_cursorObject.get(), &width, &height);
349     if (width <= 0 || height <= 0)
350         edje_object_size_min_calc(m_cursorObject.get(), &width, &height);
351     if (width <= 0 || height <= 0) {
352         width = defaultCursorSize;
353         height = defaultCursorSize;
354     }
355     evas_object_resize(m_cursorObject.get(), width, height);
356
357     const char* data;
358     int hotspotX = 0;
359     data = edje_object_data_get(m_cursorObject.get(), "hot.x");
360     if (data)
361         hotspotX = atoi(data);
362
363     int hotspotY = 0;
364     data = edje_object_data_get(m_cursorObject.get(), "hot.y");
365     if (data)
366         hotspotY = atoi(data);
367
368     ecore_evas_object_cursor_set(ecoreEvas, m_cursorObject.get(), EVAS_LAYER_MAX, hotspotX, hotspotY);
369 }
370
371 void EwkViewImpl::displayTimerFired(WebCore::Timer<EwkViewImpl>*)
372 {
373     Ewk_View_Smart_Data* sd = smartData();
374
375     if (!sd->image)
376         return;
377
378 #if USE(COORDINATED_GRAPHICS)
379     EWK_VIEW_IMPL_GET_OR_RETURN(sd, viewImpl);
380 #endif
381
382     Region dirtyRegion;
383     for (Vector<IntRect>::iterator it = m_dirtyRects.begin(); it != m_dirtyRects.end(); ++it)
384         dirtyRegion.unite(*it);
385
386     m_dirtyRects.clear();
387
388     Vector<IntRect> rects = dirtyRegion.rects();
389     Vector<IntRect>::iterator end = rects.end();
390
391     for (Vector<IntRect>::iterator it = rects.begin(); it != end; ++it) {
392         IntRect rect = *it;
393 #if USE(COORDINATED_GRAPHICS)
394         evas_gl_make_current(viewImpl->evasGl, viewImpl->evasGlSurface, viewImpl->evasGlContext);
395         viewImpl->pageViewportControllerClient->display(rect, IntPoint(sd->view.x, sd->view.y));
396 #endif
397
398         evas_object_image_data_update_add(sd->image, rect.x(), rect.y(), rect.width(), rect.height());
399     }
400 }
401
402 void EwkViewImpl::redrawRegion(const IntRect& rect)
403 {
404     if (!m_displayTimer.isActive())
405         m_displayTimer.startOneShot(0);
406     m_dirtyRects.append(rect);
407 }
408
409 /**
410  * @internal
411  * A download for that view was cancelled.
412  *
413  * Emits signal: "download,cancelled" with pointer to a Ewk_Download_Job.
414  */
415 void EwkViewImpl::informDownloadJobCancelled(Ewk_Download_Job* download)
416 {
417     evas_object_smart_callback_call(m_view, "download,cancelled", download);
418 }
419
420 /**
421  * @internal
422  * A download for that view has failed.
423  *
424  * Emits signal: "download,failed" with pointer to a Ewk_Download_Job_Error.
425  */
426 void EwkViewImpl::informDownloadJobFailed(Ewk_Download_Job* download, Ewk_Error* error)
427 {
428     Ewk_Download_Job_Error downloadError = { download, error };
429     evas_object_smart_callback_call(m_view, "download,failed", &downloadError);
430 }
431
432 /**
433  * @internal
434  * A download for that view finished successfully.
435  *
436  * Emits signal: "download,finished" with pointer to a Ewk_Download_Job.
437  */
438 void EwkViewImpl::informDownloadJobFinished(Ewk_Download_Job* download)
439 {
440     evas_object_smart_callback_call(m_view, "download,finished", download);
441 }
442
443 /**
444  * @internal
445  * A new download has been requested for that view.
446  *
447  * Emits signal: "download,request" with pointer to a Ewk_Download_Job.
448  */
449 void EwkViewImpl::informDownloadJobRequested(Ewk_Download_Job* download)
450 {
451     evas_object_smart_callback_call(m_view, "download,request", download);
452 }
453
454 /**
455  * @internal
456  * informs that a form request is about to be submitted.
457  *
458  * Emits signal: "form,submission,request" with pointer to Ewk_Form_Submission_Request.
459  */
460 void EwkViewImpl::informNewFormSubmissionRequest(Ewk_Form_Submission_Request* request)
461 {
462     evas_object_smart_callback_call(m_view, "form,submission,request", request);
463 }
464
465 #if ENABLE(FULLSCREEN_API)
466 /**
467  * @internal
468  * Calls fullscreen_enter callback or falls back to default behavior and enables fullscreen mode.
469  */
470 void EwkViewImpl::enterFullScreen()
471 {
472     Ewk_View_Smart_Data* sd = smartData();
473
474     if (!sd->api->fullscreen_enter || !sd->api->fullscreen_enter(sd)) {
475         Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(sd->base.evas);
476         ecore_evas_fullscreen_set(ecoreEvas, true);
477     }
478 }
479
480 /**
481  * @internal
482  * Calls fullscreen_exit callback or falls back to default behavior and disables fullscreen mode.
483  */
484 void EwkViewImpl::exitFullScreen()
485 {
486     Ewk_View_Smart_Data* sd = smartData();
487
488     if (!sd->api->fullscreen_exit || !sd->api->fullscreen_exit(sd)) {
489         Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(sd->base.evas);
490         ecore_evas_fullscreen_set(ecoreEvas, false);
491     }
492 }
493 #endif
494
495 void EwkViewImpl::setImageData(void* imageData, const IntSize& size)
496 {
497     Ewk_View_Smart_Data* sd = smartData();
498     if (!imageData || !sd->image)
499         return;
500
501     evas_object_resize(sd->image, size.width(), size.height());
502     evas_object_image_size_set(sd->image, size.width(), size.height());
503     evas_object_image_data_copy_set(sd->image, imageData);
504 }
505
506 #if ENABLE(INPUT_TYPE_COLOR)
507 bool EwkViewImpl::setColorPickerColor(const WebCore::Color& color)
508 {
509     if (!m_colorPickerResultListener)
510         return false;
511
512     WKRetainPtr<WKStringRef> colorString(AdoptWK, WKStringCreateWithUTF8CString(color.serialized().utf8().data()));
513     WKColorPickerResultListenerSetColor(m_colorPickerResultListener.get(), colorString.get());
514     m_colorPickerResultListener.clear();
515
516     return true;
517 }
518 #endif
519
520 /**
521  * @internal
522  * informs load failed with error information.
523  *
524  * Emits signal: "load,error" with pointer to Ewk_Error.
525  */
526 void EwkViewImpl::informLoadError(Ewk_Error* error)
527 {
528     evas_object_smart_callback_call(m_view, "load,error", error);
529 }
530
531 /**
532  * @internal
533  * informs load finished.
534  *
535  * Emits signal: "load,finished".
536  */
537 void EwkViewImpl::informLoadFinished()
538 {
539     informURLChange();
540     evas_object_smart_callback_call(m_view, "load,finished", 0);
541
542 #if OS(TIZEN)
543 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
544     pageProxy->setLoadingFinished(true);
545 #endif
546     if (pageClient->wasViewportFitsToContent())
547         pageClient->fitViewportToContent();
548
549 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
550     ewk_view_form_password_data_fill(m_view);
551 #endif
552
553     if (!suspendRequested)
554         return;
555
556     suspendRequested = false;
557
558     if (!suspendedPainting) {
559         pageProxy->suspendPainting();
560         suspendedPainting = true;
561     }
562     if (!suspendedResources) {
563         pageProxy->suspendJavaScriptAndResource();
564         suspendedResources = true;
565     }
566 #endif
567 }
568
569 /**
570  * @internal
571  * informs load progress changed.
572  *
573  * Emits signal: "load,progress" with pointer to a double from 0.0 to 1.0.
574  */
575 void EwkViewImpl::informLoadProgress(double progress)
576 {
577     evas_object_smart_callback_call(m_view, "load,progress", &progress);
578 }
579
580 /**
581  * @internal
582  * informs view provisional load failed with error information.
583  *
584  * Emits signal: "load,provisional,failed" with pointer to Ewk_Error.
585  */
586 void EwkViewImpl::informProvisionalLoadFailed(Ewk_Error* error)
587 {
588     evas_object_smart_callback_call(m_view, "load,provisional,failed", error);
589 }
590
591 #if ENABLE(WAIT_UPVERSION)
592 #if USE(TILED_BACKING_STORE)
593 void EwkViewImpl::informLoadCommitted()
594 {
595     pageViewportController->didCommitLoad();
596 }
597 #endif
598 #endif
599
600 /**
601  * @internal
602  * informs view received redirect for provisional load.
603  *
604  * Emits signal: "load,provisional,redirect".
605  */
606 void EwkViewImpl::informProvisionalLoadRedirect()
607 {
608     informURLChange();
609     evas_object_smart_callback_call(m_view, "load,provisional,redirect", 0);
610 }
611
612 /**
613  * @internal
614  * informs view provisional load started.
615  *
616  * Emits signal: "load,provisional,started".
617  */
618 void EwkViewImpl::informProvisionalLoadStarted()
619 {
620 #if OS(TIZEN)
621     evas_object_smart_callback_call(m_view, "load,started", 0);
622 #endif
623
624 #if ENABLE(TIZEN_DRAG_SUPPORT)
625     if (pageClient->isDragMode())
626         pageClient->setDragMode(false);
627 #endif
628
629 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
630     pageProxy->setLoadingFinished(false);
631 #endif
632
633     informURLChange();
634     evas_object_smart_callback_call(m_view, "load,provisional,started", 0);
635 }
636
637 /**
638  * @internal
639  * informs that a navigation policy decision should be taken.
640  *
641  * Emits signal: "policy,decision,navigation".
642  */
643 void EwkViewImpl::informNavigationPolicyDecision(Ewk_Navigation_Policy_Decision* decision)
644 {
645     evas_object_smart_callback_call(m_view, "policy,decision,navigation", decision);
646 }
647
648 /**
649  * @internal
650  * informs that a new window policy decision should be taken.
651  *
652  * Emits signal: "policy,decision,new,window".
653  */
654 void EwkViewImpl::informNewWindowPolicyDecision(Ewk_Navigation_Policy_Decision* decision)
655 {
656     evas_object_smart_callback_call(m_view, "policy,decision,new,window", decision);
657 }
658
659 /**
660  * @internal
661  * Load was initiated for a resource in the view.
662  *
663  * Emits signal: "resource,request,new" with pointer to resource request.
664  */
665 void EwkViewImpl::informResourceLoadStarted(Ewk_Resource* resource, Ewk_Url_Request* request)
666 {
667     Ewk_Resource_Request resourceRequest = {resource, request, 0};
668
669     evas_object_smart_callback_call(m_view, "resource,request,new", &resourceRequest);
670 }
671
672 /**
673  * @internal
674  * Received a response to a resource load request in the view.
675  *
676  * Emits signal: "resource,request,response" with pointer to resource response.
677  */
678 void EwkViewImpl::informResourceLoadResponse(Ewk_Resource* resource, Ewk_Url_Response* response)
679 {
680     Ewk_Resource_Load_Response resourceLoadResponse = {resource, response};
681     evas_object_smart_callback_call(m_view, "resource,request,response", &resourceLoadResponse);
682 }
683
684 /**
685  * @internal
686  * Failed loading a resource in the view.
687  *
688  * Emits signal: "resource,request,finished" with pointer to the resource load error.
689  */
690 void EwkViewImpl::informResourceLoadFailed(Ewk_Resource* resource, Ewk_Error* error)
691 {
692     Ewk_Resource_Load_Error resourceLoadError = {resource, error};
693     evas_object_smart_callback_call(m_view, "resource,request,failed", &resourceLoadError);
694 }
695
696 /**
697  * @internal
698  * Finished loading a resource in the view.
699  *
700  * Emits signal: "resource,request,finished" with pointer to the resource.
701  */
702 void EwkViewImpl::informResourceLoadFinished(Ewk_Resource* resource)
703 {
704     evas_object_smart_callback_call(m_view, "resource,request,finished", resource);
705 }
706
707 /**
708  * @internal
709  * Request was sent for a resource in the view.
710  *
711  * Emits signal: "resource,request,sent" with pointer to resource request and possible redirect response.
712  */
713 void EwkViewImpl::informResourceRequestSent(Ewk_Resource* resource, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse)
714 {
715     Ewk_Resource_Request resourceRequest = {resource, request, redirectResponse};
716     evas_object_smart_callback_call(m_view, "resource,request,sent", &resourceRequest);
717 }
718
719 /**
720  * @internal
721  * The view title was changed by the frame loader.
722  *
723  * Emits signal: "title,changed" with pointer to new title string.
724  */
725 void EwkViewImpl::informTitleChange(const String& title)
726 {
727     evas_object_smart_callback_call(m_view, "title,changed", const_cast<char*>(title.utf8().data()));
728 }
729
730 /**
731  * @internal
732  */
733 void EwkViewImpl::informTooltipTextChange(const String& text)
734 {
735     if (text.isEmpty())
736         evas_object_smart_callback_call(m_view, "tooltip,text,unset", 0);
737     else
738         evas_object_smart_callback_call(m_view, "tooltip,text,set", const_cast<char*>(text.utf8().data()));
739
740 }
741
742 /**
743  * @internal
744  * informs that the requested text was found.
745  *
746  * Emits signal: "text,found" with the number of matches.
747  */
748 void EwkViewImpl::informTextFound(unsigned matchCount)
749 {
750     evas_object_smart_callback_call(m_view, "text,found", &matchCount);
751 }
752
753 IntSize EwkViewImpl::size() const
754 {
755     int width, height;
756     evas_object_geometry_get(m_view, 0, 0, &width, &height);
757     return IntSize(width, height);
758 }
759
760 bool EwkViewImpl::isFocused() const
761 {
762     return evas_object_focus_get(m_view);
763 }
764
765 bool EwkViewImpl::isVisible() const
766 {
767     return evas_object_visible_get(m_view);
768 }
769
770 const char* EwkViewImpl::title() const
771 {
772     m_title = pageProxy->pageTitle().utf8().data();
773
774     return m_title;
775 }
776
777 /**
778  * @internal
779  * This function may return @c NULL.
780  */
781 InputMethodContextEfl* EwkViewImpl::inputMethodContext()
782 {
783     return m_inputMethodContext.get();
784 }
785
786 const char* EwkViewImpl::themePath() const
787 {
788     return m_theme;
789 }
790
791 void EwkViewImpl::setThemePath(const char* theme)
792 {
793     if (m_theme != theme) {
794         m_theme = theme;
795         pageProxy->setThemePath(theme);
796     }
797 }
798
799 const char* EwkViewImpl::customTextEncodingName() const
800 {
801     String customEncoding = pageProxy->customTextEncodingName();
802     if (customEncoding.isEmpty())
803         return 0;
804
805     m_customEncoding = customEncoding.utf8().data();
806
807     return m_customEncoding;
808 }
809
810 void EwkViewImpl::setCustomTextEncodingName(const char* encoding)
811 {
812     m_customEncoding = encoding;
813     pageProxy->setCustomTextEncodingName(encoding ? encoding : String());
814 }
815
816 void EwkViewImpl::setMouseEventsEnabled(bool enabled)
817 {
818     if (m_mouseEventsEnabled == enabled)
819         return;
820
821     m_mouseEventsEnabled = enabled;
822     if (enabled) {
823         Ewk_View_Smart_Data* sd = smartData();
824         evas_object_event_callback_add(m_view, EVAS_CALLBACK_MOUSE_DOWN, onMouseDown, sd);
825         evas_object_event_callback_add(m_view, EVAS_CALLBACK_MOUSE_UP, onMouseUp, sd);
826         evas_object_event_callback_add(m_view, EVAS_CALLBACK_MOUSE_MOVE, onMouseMove, sd);
827     } else {
828         evas_object_event_callback_del(m_view, EVAS_CALLBACK_MOUSE_DOWN, onMouseDown);
829         evas_object_event_callback_del(m_view, EVAS_CALLBACK_MOUSE_UP, onMouseUp);
830         evas_object_event_callback_del(m_view, EVAS_CALLBACK_MOUSE_MOVE, onMouseMove);
831     }
832 }
833
834 #if ENABLE(TOUCH_EVENTS)
835 void EwkViewImpl::setTouchEventsEnabled(bool enabled)
836 {
837     if (m_touchEventsEnabled == enabled)
838         return;
839
840     m_touchEventsEnabled = enabled;
841
842     if (enabled) {
843         // FIXME: We have to connect touch callbacks with mouse and multi events
844         // because the Evas creates mouse events for first touch and multi events
845         // for second and third touches. Below codes should be fixed when the Evas
846         // supports the touch events.
847         // See https://bugs.webkit.org/show_bug.cgi?id=97785 for details.
848         Ewk_View_Smart_Data* sd = smartData();
849         evas_object_event_callback_add(m_view, EVAS_CALLBACK_MOUSE_DOWN, onTouchDown, sd);
850         evas_object_event_callback_add(m_view, EVAS_CALLBACK_MOUSE_UP, onTouchUp, sd);
851         evas_object_event_callback_add(m_view, EVAS_CALLBACK_MOUSE_MOVE, onTouchMove, sd);
852         evas_object_event_callback_add(m_view, EVAS_CALLBACK_MULTI_DOWN, onTouchDown, sd);
853         evas_object_event_callback_add(m_view, EVAS_CALLBACK_MULTI_UP, onTouchUp, sd);
854         evas_object_event_callback_add(m_view, EVAS_CALLBACK_MULTI_MOVE, onTouchMove, sd);
855     } else {
856         evas_object_event_callback_del(m_view, EVAS_CALLBACK_MOUSE_DOWN, onTouchDown);
857         evas_object_event_callback_del(m_view, EVAS_CALLBACK_MOUSE_UP, onTouchUp);
858         evas_object_event_callback_del(m_view, EVAS_CALLBACK_MOUSE_MOVE, onTouchMove);
859         evas_object_event_callback_del(m_view, EVAS_CALLBACK_MULTI_DOWN, onTouchDown);
860         evas_object_event_callback_del(m_view, EVAS_CALLBACK_MULTI_UP, onTouchUp);
861         evas_object_event_callback_del(m_view, EVAS_CALLBACK_MULTI_MOVE, onTouchMove);
862     }
863 }
864 #endif
865
866 /**
867  * @internal
868  * Update the view's favicon and emits a "icon,changed" signal if it has
869  * changed.
870  *
871  * This function is called whenever the URL has changed or when the icon for
872  * the current page URL has changed.
873  */
874 void EwkViewImpl::informIconChange()
875 {
876 #if ENABLE(TIZEN_ICON_DATABASE)
877     return;
878 #endif
879     Ewk_Favicon_Database* iconDatabase = context->faviconDatabase();
880     ASSERT(iconDatabase);
881
882     m_faviconURL = ewk_favicon_database_icon_url_get(iconDatabase, m_url);
883     evas_object_smart_callback_call(m_view, "icon,changed", 0);
884 }
885
886 #if ENABLE(WEB_INTENTS)
887 /**
888  * @internal
889  * The view received a new intent request.
890  *
891  * Emits signal: "intent,request,new" with pointer to a Ewk_Intent.
892  */
893 void EwkViewImpl::informIntentRequest(Ewk_Intent* ewkIntent)
894 {
895     evas_object_smart_callback_call(m_view, "intent,request,new", ewkIntent);
896 }
897 #endif
898
899 #if ENABLE(WEB_INTENTS_TAG)
900 /**
901  * @internal
902  * The view received a new intent service registration.
903  *
904  * Emits signal: "intent,service,register" with pointer to a Ewk_Intent_Service.
905  */
906 void EwkViewImpl::informIntentServiceRegistration(Ewk_Intent_Service* ewkIntentService)
907 {
908     evas_object_smart_callback_call(m_view, "intent,service,register", ewkIntentService);
909 }
910 #endif // ENABLE(WEB_INTENTS_TAG)
911
912 #if USE(ACCELERATED_COMPOSITING)
913 bool EwkViewImpl::createGLSurface(const IntSize& viewSize)
914 {
915     Ewk_View_Smart_Data* sd = smartData();
916
917     Evas_GL_Config evasGlConfig = {
918         EVAS_GL_RGBA_8888,
919         EVAS_GL_DEPTH_BIT_8,
920         EVAS_GL_STENCIL_NONE,
921         EVAS_GL_OPTIONS_NONE,
922         EVAS_GL_MULTISAMPLE_NONE
923     };
924
925     ASSERT(!evasGlSurface);
926     evasGlSurface = evas_gl_surface_create(evasGl, &evasGlConfig, viewSize.width(), viewSize.height());
927     if (!evasGlSurface)
928         return false;
929
930     Evas_Native_Surface nativeSurface;
931     evas_gl_native_surface_get(evasGl, evasGlSurface, &nativeSurface);
932     evas_object_image_native_surface_set(sd->image, &nativeSurface);
933
934     return true;
935 }
936
937 bool EwkViewImpl::enterAcceleratedCompositingMode()
938 {
939     if (evasGl) {
940         EINA_LOG_DOM_WARN(_ewk_log_dom, "Accelerated compositing mode already entered.");
941         return false;
942     }
943
944     Evas* evas = evas_object_evas_get(m_view);
945     evasGl = evas_gl_new(evas);
946     if (!evasGl)
947         return false;
948
949     evasGlContext = evas_gl_context_create(evasGl, 0);
950     if (!evasGlContext) {
951         evas_gl_free(evasGl);
952         evasGl = 0;
953         return false;
954     }
955
956     if (!createGLSurface(size())) {
957         evas_gl_context_destroy(evasGl, evasGlContext);
958         evasGlContext = 0;
959
960         evas_gl_free(evasGl);
961         evasGl = 0;
962         return false;
963     }
964
965 #if ENABLE(WAIT_UPVERSION)
966     pageViewportControllerClient->setRendererActive(true);
967 #endif
968     return true;
969 }
970
971 bool EwkViewImpl::exitAcceleratedCompositingMode()
972 {
973     EINA_SAFETY_ON_NULL_RETURN_VAL(evasGl, false);
974
975     if (evasGlSurface) {
976         evas_gl_surface_destroy(evasGl, evasGlSurface);
977         evasGlSurface = 0;
978     }
979
980     if (evasGlContext) {
981         evas_gl_context_destroy(evasGl, evasGlContext);
982         evasGlContext = 0;
983     }
984
985     evas_gl_free(evasGl);
986     evasGl = 0;
987
988     return true;
989 }
990 #endif
991
992 #if ENABLE(INPUT_TYPE_COLOR)
993 /**
994  * @internal
995  * Requests to show external color picker.
996  */
997 void EwkViewImpl::requestColorPicker(int r, int g, int b, int a, WKColorPickerResultListenerRef listener)
998 {
999     Ewk_View_Smart_Data* sd = smartData();
1000     EINA_SAFETY_ON_NULL_RETURN(sd->api->input_picker_color_request);
1001
1002     m_colorPickerResultListener = listener;
1003
1004     sd->api->input_picker_color_request(sd, r, g, b, a);
1005 }
1006
1007 /**
1008  * @internal
1009  * Requests to hide external color picker.
1010  */
1011 void EwkViewImpl::dismissColorPicker()
1012 {
1013     Ewk_View_Smart_Data* sd = smartData();
1014     EINA_SAFETY_ON_NULL_RETURN(sd->api->input_picker_color_dismiss);
1015
1016     m_colorPickerResultListener.clear();
1017
1018     sd->api->input_picker_color_dismiss(sd);
1019 }
1020 #endif
1021
1022 /**
1023  * @internal
1024  * informs that the view's back / forward list has changed.
1025  *
1026  * Emits signal: "back,forward,list,changed".
1027  */
1028 void EwkViewImpl::informBackForwardListChange()
1029 {
1030     evas_object_smart_callback_call(m_view, "back,forward,list,changed", 0);
1031 }
1032
1033 /**
1034  * @internal
1035  * Web process has crashed.
1036  *
1037  * Emits signal: "webprocess,crashed" with pointer to crash handling boolean.
1038  */
1039 void EwkViewImpl::informWebProcessCrashed()
1040 {
1041     bool handled = false;
1042     evas_object_smart_callback_call(m_view, "webprocess,crashed", &handled);
1043
1044     if (!handled) {
1045         CString url = pageProxy->urlAtProcessExit().utf8();
1046         WARN("WARNING: The web process experienced a crash on '%s'.\n", url.data());
1047
1048         // Display an error page
1049         ewk_view_html_string_load(m_view, "The web process has crashed.", 0, url.data());
1050     }
1051 }
1052
1053 void EwkViewImpl::informContentsSizeChange(const IntSize& size)
1054 {
1055 #if USE(COORDINATED_GRAPHICS)
1056     pageViewportControllerClient->didChangeContentsSize(size);
1057 #else
1058     UNUSED_PARAM(size);
1059 #endif
1060 }
1061
1062 COMPILE_ASSERT_MATCHING_ENUM(EWK_TEXT_DIRECTION_RIGHT_TO_LEFT, RTL);
1063 COMPILE_ASSERT_MATCHING_ENUM(EWK_TEXT_DIRECTION_LEFT_TO_RIGHT, LTR);
1064
1065 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1066 void EwkViewImpl::requestPopupMenu(WebPopupMenuProxyEfl* popupMenu, const IntRect& rect, TextDirection textDirection, double pageScaleFactor, const Vector<WebPopupItem>& items, int32_t selectedIndex, bool multiple)
1067 #else
1068 void EwkViewImpl::requestPopupMenu(WebPopupMenuProxyEfl* popupMenu, const IntRect& rect, TextDirection textDirection, double pageScaleFactor, const Vector<WebPopupItem>& items, int32_t selectedIndex)
1069 #endif
1070 {
1071     Ewk_View_Smart_Data* sd = smartData();
1072     ASSERT(sd->api);
1073
1074     ASSERT(popupMenu);
1075
1076 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1077     if (multiple ? !sd->api->multiple_popup_menu_show : !sd->api->popup_menu_show)
1078 #else
1079     if (!sd->api->popup_menu_show)
1080 #endif
1081         return;
1082
1083     if (popupMenuProxy)
1084         ewk_view_popup_menu_close(m_view);
1085     popupMenuProxy = popupMenu;
1086
1087     Eina_List* popupItems = 0;
1088     const size_t size = items.size();
1089     for (size_t i = 0; i < size; ++i)
1090         popupItems = eina_list_append(popupItems, Ewk_Popup_Menu_Item::create(items[i]).leakPtr());
1091     popupMenuItems = popupItems;
1092
1093 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1094 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1095     if (multiple ? sd->api->multiple_popup_menu_show(sd, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, popupMenuItems)
1096         : sd->api->popup_menu_show(sd, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, popupMenuItems, selectedIndex)) {
1097 #else
1098     if (sd->api->popup_menu_show(sd, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, popupMenuItems, selectedIndex)) {
1099 #endif
1100         /* maps.google.com generate mouse event in touch down without preventDefault.
1101          * So, popup menu is opend in touch down event and closed via fake mouse down
1102          * which generated by endTap.
1103          * In order to fix select of maps.google.com (based on touch behavior),
1104          * We should disable touch events when select popup is open.
1105          */
1106
1107 #if ENABLE(TIZEN_GESTURE)
1108         gestureClient->reset();
1109 #endif
1110         ewk_view_touch_events_enabled_set(m_view, false);
1111     }
1112 #else
1113     sd->api->popup_menu_show(sd, rect, static_cast<Ewk_Text_Direction>(textDirection), pageScaleFactor, popupItems, selectedIndex);
1114 #endif
1115 }
1116
1117 /**
1118  * @internal
1119  * Calls a smart member function for javascript alert().
1120  */
1121 void EwkViewImpl::requestJSAlertPopup(const WKEinaSharedString& message)
1122 {
1123     Ewk_View_Smart_Data* sd = smartData();
1124     ASSERT(sd->api);
1125
1126     if (!sd->api->run_javascript_alert)
1127         return;
1128
1129     sd->api->run_javascript_alert(sd, message);
1130 }
1131
1132 /**
1133  * @internal
1134  * Calls a smart member function for javascript confirm() and returns a value from the function. Returns false by default.
1135  */
1136 bool EwkViewImpl::requestJSConfirmPopup(const WKEinaSharedString& message)
1137 {
1138     Ewk_View_Smart_Data* sd = smartData();
1139     ASSERT(sd->api);
1140
1141     if (!sd->api->run_javascript_confirm)
1142         return false;
1143
1144     return sd->api->run_javascript_confirm(sd, message);
1145 }
1146
1147 /**
1148  * @internal
1149  * Calls a smart member function for javascript prompt() and returns a value from the function. Returns null string by default.
1150  */
1151 WKEinaSharedString EwkViewImpl::requestJSPromptPopup(const WKEinaSharedString& message, const WKEinaSharedString& defaultValue)
1152 {
1153     Ewk_View_Smart_Data* sd = smartData();
1154     ASSERT(sd->api);
1155
1156     if (!sd->api->run_javascript_prompt)
1157         return WKEinaSharedString();
1158
1159     return WKEinaSharedString::adopt(sd->api->run_javascript_prompt(sd, message, defaultValue));
1160 }
1161
1162 #if ENABLE(SQL_DATABASE)
1163 /**
1164  * @internal
1165  * Calls exceeded_database_quota callback or falls back to default behavior returns default database quota.
1166  */
1167 unsigned long long EwkViewImpl::informDatabaseQuotaReached(const String& databaseName, const String& displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage)
1168 {
1169     Ewk_View_Smart_Data* sd = smartData();
1170     ASSERT(sd->api);
1171
1172     static const unsigned long long defaultQuota = 5 * 1024 * 1204; // 5 MB
1173     if (sd->api->exceeded_database_quota)
1174         return sd->api->exceeded_database_quota(sd, databaseName.utf8().data(), displayName.utf8().data(), currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
1175
1176     return defaultQuota;
1177 }
1178 #endif
1179
1180 /**
1181  * @internal
1182  * The url of view was changed by the frame loader.
1183  *
1184  * Emits signal: "url,changed" with pointer to new url string.
1185  */
1186 void EwkViewImpl::informURLChange()
1187 {
1188     String activeURL = pageProxy->activeURL();
1189     if (activeURL.isEmpty())
1190         return;
1191
1192     CString rawActiveURL = activeURL.utf8();
1193     if (m_url == rawActiveURL.data())
1194         return;
1195
1196     m_url = rawActiveURL.data();
1197     const char* callbackArgument = static_cast<const char*>(m_url);
1198     evas_object_smart_callback_call(m_view, "url,changed", const_cast<char*>(callbackArgument));
1199 #if OS(TIZEN)
1200     evas_object_smart_callback_call(m_view, "uri,changed", const_cast<char*>(callbackArgument));
1201 #endif
1202
1203     // Update the view's favicon.
1204     informIconChange();
1205 }
1206
1207 WKPageRef EwkViewImpl::createNewPage()
1208 {
1209     Evas_Object* newEwkView = 0;
1210     evas_object_smart_callback_call(m_view, "create,window", &newEwkView);
1211
1212     if (!newEwkView)
1213         return 0;
1214
1215     EwkViewImpl* newViewImpl = EwkViewImpl::fromEvasObject(newEwkView);
1216     ASSERT(newViewImpl);
1217
1218     return static_cast<WKPageRef>(WKRetain(newViewImpl->page()));
1219 }
1220
1221 void EwkViewImpl::closePage()
1222 {
1223     evas_object_smart_callback_call(m_view, "close,window", 0);
1224 }
1225
1226 void EwkViewImpl::onMouseDown(void* data, Evas*, Evas_Object*, void* eventInfo)
1227 {
1228     Evas_Event_Mouse_Down* downEvent = static_cast<Evas_Event_Mouse_Down*>(eventInfo);
1229     Ewk_View_Smart_Data* sd = static_cast<Ewk_View_Smart_Data*>(data);
1230     EINA_SAFETY_ON_NULL_RETURN(sd->api);
1231     EINA_SAFETY_ON_NULL_RETURN(sd->api->mouse_down);
1232     sd->api->mouse_down(sd, downEvent);
1233 }
1234
1235 void EwkViewImpl::onMouseUp(void* data, Evas*, Evas_Object*, void* eventInfo)
1236 {
1237     Evas_Event_Mouse_Up* upEvent = static_cast<Evas_Event_Mouse_Up*>(eventInfo);
1238     Ewk_View_Smart_Data* sd = static_cast<Ewk_View_Smart_Data*>(data);
1239     EINA_SAFETY_ON_NULL_RETURN(sd->api);
1240     EINA_SAFETY_ON_NULL_RETURN(sd->api->mouse_up);
1241     sd->api->mouse_up(sd, upEvent);
1242 }
1243
1244 void EwkViewImpl::onMouseMove(void* data, Evas*, Evas_Object*, void* eventInfo)
1245 {
1246     Evas_Event_Mouse_Move* moveEvent = static_cast<Evas_Event_Mouse_Move*>(eventInfo);
1247     Ewk_View_Smart_Data* sd = static_cast<Ewk_View_Smart_Data*>(data);
1248     EINA_SAFETY_ON_NULL_RETURN(sd->api);
1249     EINA_SAFETY_ON_NULL_RETURN(sd->api->mouse_move);
1250     sd->api->mouse_move(sd, moveEvent);
1251 }
1252
1253 #if ENABLE(TOUCH_EVENTS)
1254 void EwkViewImpl::feedTouchEvents(Ewk_Touch_Event_Type type)
1255 {
1256     Ewk_View_Smart_Data* sd = smartData();
1257
1258     unsigned count = evas_touch_point_list_count(sd->base.evas);
1259     if (!count)
1260         return;
1261
1262     Eina_List* points = 0;
1263     for (unsigned i = 0; i < count; ++i) {
1264         Ewk_Touch_Point* point = new Ewk_Touch_Point;
1265         point->id = evas_touch_point_list_nth_id_get(sd->base.evas, i);
1266         evas_touch_point_list_nth_xy_get(sd->base.evas, i, &point->x, &point->y);
1267         point->state = evas_touch_point_list_nth_state_get(sd->base.evas, i);
1268 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_GESTURE)
1269         if (type == EWK_TOUCH_CANCEL)
1270             point->state = EVAS_TOUCH_POINT_CANCEL;
1271 #endif
1272         points = eina_list_append(points, point);
1273     }
1274
1275     ewk_view_feed_touch_event(m_view, type, points, evas_key_modifier_get(sd->base.evas));
1276
1277     void* data;
1278     EINA_LIST_FREE(points, data)
1279         delete static_cast<Ewk_Touch_Point*>(data);
1280 }
1281
1282 void EwkViewImpl::onTouchDown(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */)
1283 {
1284     EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(ewkView);
1285     viewImpl->feedTouchEvents(EWK_TOUCH_START);
1286 }
1287
1288 void EwkViewImpl::onTouchUp(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */)
1289 {
1290     EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(ewkView);
1291     viewImpl->feedTouchEvents(EWK_TOUCH_END);
1292 }
1293
1294 void EwkViewImpl::onTouchMove(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */)
1295 {
1296     EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(ewkView);
1297     viewImpl->feedTouchEvents(EWK_TOUCH_MOVE);
1298 }
1299 #endif
1300
1301 #if OS(TIZEN)
1302 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1303 AffineTransform EwkViewImpl::transformFromView() const
1304 {
1305     AffineTransform transform;
1306     transform.scale(1 / m_scaleFactor);
1307     transform.translate(m_scrollPosition.x(), m_scrollPosition.y());
1308
1309     return transform;
1310 }
1311
1312 AffineTransform EwkViewImpl::transformToView() const
1313 {
1314     return transformFromView().inverse();
1315 }
1316 #endif
1317
1318 AffineTransform EwkViewImpl::transformFromScene() const
1319 {
1320     AffineTransform transform;
1321
1322 #if USE(TILED_BACKING_STORE)
1323     // FIXME: We have to scale firstly unlike open source, because we are using scaled scroll position.
1324     //transform.translate(m_scrollPosition.x(), m_scrollPosition.y());
1325     //transform.scale(1 / m_scaleFactor);
1326     transform.scale(1 / m_scaleFactor);
1327     transform.translate(m_scrollPosition.x(), m_scrollPosition.y());
1328 #endif
1329
1330     Ewk_View_Smart_Data* sd = smartData();
1331     transform.translate(-sd->view.x, -sd->view.y);
1332
1333     return transform;
1334 }
1335
1336 AffineTransform EwkViewImpl::transformToScene() const
1337 {
1338     return transformFromScene().inverse();
1339 }
1340
1341 AffineTransform EwkViewImpl::transformToScreen() const
1342 {
1343     AffineTransform transform;
1344
1345     int windowGlobalX = 0;
1346     int windowGlobalY = 0;
1347
1348     Ewk_View_Smart_Data* sd = smartData();
1349
1350 #ifdef HAVE_ECORE_X
1351     Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(sd->base.evas);
1352     Ecore_X_Window window = ecore_evas_software_x11_window_get(ecoreEvas); // Returns 0 if none.
1353
1354     int x, y; // x, y are relative to parent (in a reparenting window manager).
1355     while (window) {
1356         ecore_x_window_geometry_get(window, &x, &y, 0, 0);
1357         windowGlobalX += x;
1358         windowGlobalY += y;
1359         window = ecore_x_window_parent_get(window);
1360     }
1361 #endif
1362
1363     transform.translate(-sd->view.x, -sd->view.y);
1364     transform.translate(windowGlobalX, windowGlobalY);
1365
1366     return transform;
1367 }
1368
1369 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
1370 void EwkViewImpl::informLoadProgressStarted()
1371 {
1372     evas_object_smart_callback_call(m_view, "load,progress,started", 0);
1373 }
1374
1375 void EwkViewImpl::informLoadProgressFinished()
1376 {
1377     evas_object_smart_callback_call(m_view, "load,progress,finished", 0);
1378 }
1379 #endif
1380
1381 #if ENABLE(TIZEN_DATALIST_ELEMENT)
1382 void EwkViewImpl::deleteDataList()
1383 {
1384     EINA_SAFETY_ON_NULL_RETURN(dataList);
1385
1386     void* item;
1387     EINA_LIST_FREE(dataList, item)
1388         eina_stringshare_del(static_cast<char*>(item));
1389
1390     dataList = 0;
1391 }
1392 #endif
1393
1394 #if ENABLE(TIZEN_GESTURE)
1395 #if ENABLE(TOUCH_EVENTS)
1396 void EwkViewImpl::feedTouchEventsByType(Ewk_Touch_Event_Type type)
1397 {
1398     feedTouchEvents(type);
1399 }
1400 #endif
1401
1402 void EwkViewImpl::setDoubleTapEnabled(bool enabled)
1403 {
1404     gestureRecognizer->setDoubleTapEnabled(enabled);
1405 }
1406 #endif
1407
1408 #endif //#if OS(TIZEN)