Fix for webkit event issue
[framework/osp/web.git] / src / controls / FWebCtrl_Web.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FWebCtrl_Web.cpp
20  * @brief               The file contains the definition of _Web class.
21  *
22  * The file contains the definition of _Web class.
23  */
24 #include <Ecore_X.h>
25 #include <Elementary.h>
26 #include <memory>
27 #include <FBaseByteBuffer.h>
28 #include <FBaseColLinkedListT.h>
29 #include <FBaseSysLog.h>
30 #include <FBaseColIListT.h>
31 #include <FGrpFloatPoint.h>
32 #include <FGrpPoint.h>
33 #include <FGrpBitmap.h>
34 #include <FGrpCanvas.h>
35 #include <FGrpFloatRectangle.h>
36 #include <FSysVibrator.h>
37 #include <FWebCtrlWebSetting.h>
38 #include <FGrp_CoordinateSystem.h>
39 #include <FSys_VibratorImpl.h>
40 #include <FUiAnim_EflNode.h>
41 #include <FUiAnim_VisualElement.h>
42 #include <FUiAnim_VisualElementImpl.h>
43 #include <FUi_CoordinateSystemUtils.h>
44 #include <FUi_AccessibilityContainer.h>
45 #include <FUi_AccessibilityElement.h>
46 #include <FUi_UiEventManager.h>
47 #include <FUi_IAccessibilityFocusHandler.h>
48 #include <FUi_IAccessibilityListener.h>
49 #include <FUi_Math.h>
50 #include <FUi_TouchManager.h>
51 #include "FWebCtrl_EflWebkit.h"
52 #include "FWebCtrl_GestureState.h"
53 #include "FWebCtrl_Web.h"
54 #include "FWebCtrl_WebSettingImpl.h"
55 #include "FWebCtrl_Utility.h"
56
57
58 using namespace Tizen::Base;
59 using namespace Tizen::Base::Collection;
60 using namespace Tizen::Graphics;
61 using namespace Tizen::Ui;
62 using namespace Tizen::Ui::Animations;
63
64
65 namespace
66 {
67
68
69 class _WebAccessibilityListener
70         : public Tizen::Ui::_IAccessibilityListener
71 {
72 public:
73         _WebAccessibilityListener(Evas_Object* pView);
74
75         virtual ~_WebAccessibilityListener(void);
76
77         virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element);
78
79         virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element);
80
81         virtual bool OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element);
82
83         virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element);
84
85         virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element);
86
87         virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element);
88
89         virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element);
90
91         virtual bool OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element);
92
93         virtual bool OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element);
94
95 private:
96         Evas_Object* __pView;
97 };
98
99
100 _WebAccessibilityListener::_WebAccessibilityListener(Evas_Object* pView)
101         : __pView(pView)
102 {
103 }
104
105
106 _WebAccessibilityListener::~_WebAccessibilityListener(void)
107 {
108 }
109
110
111 bool
112 _WebAccessibilityListener::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
113 {
114         return true;
115 }
116
117
118 bool
119 _WebAccessibilityListener::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
120 {
121         return true;
122 }
123
124
125 bool
126 _WebAccessibilityListener::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
127 {
128         return true;
129 }
130
131
132 bool
133 _WebAccessibilityListener::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
134 {
135         return true;
136 }
137
138
139 bool
140 _WebAccessibilityListener::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
141 {
142         return true;
143 }
144
145
146 bool
147 _WebAccessibilityListener::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
148 {
149         Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pView));
150         SysAssertf(pSmartData, "Failed to get webkit smart data.");
151
152         Elm_Access_Action_Info* pActionInfo = new Elm_Access_Action_Info();
153         SysTryReturn(NID_WEB_CTRL, pActionInfo, false, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
154
155         bool result = false;
156
157         pActionInfo->action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
158
159         result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
160         delete pActionInfo;
161
162         return result;
163 }
164
165
166 bool
167 _WebAccessibilityListener::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
168 {
169         Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pView));
170         SysAssertf(pSmartData, "Failed to get webkit smart data.");
171
172         Elm_Access_Action_Info* pActionInfo = new Elm_Access_Action_Info();
173         SysTryReturn(NID_WEB_CTRL, pActionInfo, false, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
174
175         bool result = false;
176
177         pActionInfo->action_type = ELM_ACCESS_ACTION_ACTIVATE;
178
179         result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
180         delete pActionInfo;
181
182         return result;
183 }
184
185
186 bool
187 _WebAccessibilityListener::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
188 {
189         return true;
190 }
191
192
193 bool
194 _WebAccessibilityListener::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
195 {
196         return true;
197 }
198
199
200 class _WebAccessibilityFocusHandler
201         : public Tizen::Ui::_IAccessibilityFocusHandler
202 {
203 public:
204         _WebAccessibilityFocusHandler(Evas_Object* pView);
205
206         virtual ~_WebAccessibilityFocusHandler(void);
207
208         virtual bool OnMoveFocus(Tizen::Ui::_AccessibilityFocusDirection direction);
209
210         virtual bool OnMoveFocus(const Tizen::Graphics::Point& point);
211
212 private:
213         Evas_Object* __pView;
214 };
215
216
217 _WebAccessibilityFocusHandler::_WebAccessibilityFocusHandler(Evas_Object* pView)
218         : __pView(pView)
219 {
220 }
221
222
223 _WebAccessibilityFocusHandler::~_WebAccessibilityFocusHandler(void)
224 {
225 }
226
227
228 bool
229 _WebAccessibilityFocusHandler::OnMoveFocus(Tizen::Ui::_AccessibilityFocusDirection direction)
230 {
231         Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pView));
232         SysAssertf(pSmartData, "Failed to get webkit smart data.");
233
234         Elm_Access_Action_Info* pActionInfo = new Elm_Access_Action_Info();
235         SysTryReturn(NID_WEB_CTRL, pActionInfo, false, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
236
237         bool result = false;
238
239         if (direction == Tizen::Ui::_ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS)
240         {
241                 pActionInfo->action_type = ELM_ACCESS_ACTION_HIGHLIGHT;
242
243                 pActionInfo->action_by = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
244
245                 result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
246         }
247         else if (direction == Tizen::Ui::_ACCESSIBILITY_FOCUS_DIRECTION_NEXT)
248         {
249                 pActionInfo->action_type = ELM_ACCESS_ACTION_HIGHLIGHT;
250
251                 pActionInfo->action_by = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
252
253                 result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
254         }
255         delete pActionInfo;
256
257         return result;
258 }
259
260
261 bool
262 _WebAccessibilityFocusHandler::OnMoveFocus(const Tizen::Graphics::Point& point)
263 {
264         Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pView));
265         SysAssertf(pSmartData, "Failed to get webkit smart data.");
266
267         Elm_Access_Action_Info* pActionInfo = new Elm_Access_Action_Info();
268         SysTryReturn(NID_WEB_CTRL, pActionInfo, false, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
269
270         bool result = false;
271
272         pActionInfo->action_type = ELM_ACCESS_ACTION_READ;
273         pActionInfo->x = point.x;
274         pActionInfo->y = point.y;
275
276         result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
277         delete pActionInfo;
278
279         return result;
280 }
281
282
283 }
284
285
286 namespace Tizen { namespace Web { namespace Controls
287 {
288
289
290 void
291 OnEdgeLeft(void* pUserData, Evas_Object* pView, void* pEventInfo)
292 {
293         _Web* pCore = reinterpret_cast< _Web* >(pUserData);
294         SysAssertf(pCore, "Failed to request");
295
296         pCore->SetEdgeReachedEvent(WEB_EDGE_LEFT);
297 }
298
299
300 void
301 OnEdgeRight(void* pUserData, Evas_Object* pView, void* pEventInfo)
302 {
303         _Web* pCore = reinterpret_cast< _Web* >(pUserData);
304         SysAssertf(pCore, "Failed to request");
305
306         pCore->SetEdgeReachedEvent(WEB_EDGE_RIGHT);
307 }
308
309
310 void
311 OnEdgeTop(void* pUserData, Evas_Object* pView, void* pEventInfo)
312 {
313         _Web* pCore = reinterpret_cast< _Web* >(pUserData);
314         SysAssertf(pCore, "Failed to request");
315
316         pCore->SetEdgeReachedEvent(WEB_EDGE_TOP);
317 }
318
319
320 void
321 OnEdgeBottom(void* pUserData, Evas_Object* pView, void* pEventInfo)
322 {
323         _Web* pCore = reinterpret_cast< _Web* >(pUserData);
324         SysAssertf(pCore, "Failed to request");
325
326         pCore->SetEdgeReachedEvent(WEB_EDGE_BOTTOM);
327 }
328
329
330 _Web::_Web(void)
331         : __pGestureHandler(null)
332         , __pEflWebkit(null)
333         , __pWebSetting(null)
334         , __pGestureFlick(null)
335         , __pGestureLongPress(null)
336         , __pGesturePinch(null)
337         , __pGestureDoubleTap(null)
338         , __pTouchEventInfoList(null)
339         , __pTapGestureHandler(null)
340         , __pPanningGestureHandler(null)
341         , __pFlickGestureHandler(null)
342         , __pPinchGestureHandler(null)
343         , __gestureType(WEB_GESTURE_TYPE_TAP)
344         , __edgeType(WEB_EDGE_NONE)
345         , __focus(false)
346         , __pTextElement(null)
347         , __previousTouchedPosition(0.0f, 0.0f)
348         , __isFullScreenEntered(false)
349         , __isRotated(false)
350         , __touchPressed(false)
351 {
352         SetBackgroundColor(Color(0, 0, 0, 0));
353 }
354
355
356 _Web::~_Web(void)
357 {
358         RemoveGestureListener();
359 }
360
361
362 _Web*
363 _Web::CreateWebN(void)
364 {
365         result r = E_SUCCESS;
366
367         std::unique_ptr<_Web> pWeb(new (std::nothrow) _Web());
368         SysTryReturn(NID_WEB_CTRL, pWeb.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
369
370         pWeb->__pWebSetting = std::unique_ptr<WebSetting>(new (std::nothrow) WebSetting());
371         SysTryReturn(NID_WEB_CTRL, pWeb->__pWebSetting.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
372
373         pWeb->AcquireHandle();
374         pWeb->SetMultiTouchEnabled(true);
375         pWeb->SetTouchPressThreshold(0.08);
376
377         r = pWeb->AddGestureListeners();
378         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
379
380         r = pWeb->InitializeGestureStates();
381         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
382
383         return pWeb.release();
384 }
385
386
387 result
388 _Web::CreateWebkitEvasObject(void)
389 {
390         result r = E_SUCCESS;
391
392         std::unique_ptr<_EflWebkit> pEflWebkit(new (std::nothrow) _EflWebkit());
393         SysTryReturnResult(NID_WEB_CTRL, pEflWebkit.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
394
395         _VisualElement* pVe = GetVisualElement();
396         r = pEflWebkit->Construct(GetAbsoluteBounds(), *pVe, this);
397         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
398
399         _VisualElementImpl* pVeImpl = _VisualElementImpl::GetInstance(*pVe);
400         pVeImpl->SetCaptureProvider(this);
401
402         __pEflWebkit = std::move(pEflWebkit);
403
404         Evas_Object* pView = GetWebNativeNode();
405         evas_object_smart_callback_add(pView, "edge,left", OnEdgeLeft, this);
406         evas_object_smart_callback_add(pView, "edge,right", OnEdgeRight, this);
407         evas_object_smart_callback_add(pView, "edge,top", OnEdgeTop, this);
408         evas_object_smart_callback_add(pView, "edge,bottom", OnEdgeBottom, this);
409
410         return E_SUCCESS;
411 }
412
413
414 result
415 _Web::InitializeGestureStates(void)
416 {
417         __pPinchGestureHandler = std::unique_ptr<_PinchGestureState>(new (std::nothrow) _PinchGestureState(this));
418         SysTryReturnResult(NID_WEB_CTRL, __pPinchGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
419
420         __pTapGestureHandler = std::unique_ptr<_TapGestureState>(new (std::nothrow) _TapGestureState(this));
421         SysTryReturnResult(NID_WEB_CTRL, __pTapGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
422
423         __pPanningGestureHandler = std::unique_ptr<_PanningGestureState>(new (std::nothrow) _PanningGestureState(this));
424         SysTryReturnResult(NID_WEB_CTRL, __pPanningGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
425
426         __pFlickGestureHandler = std::unique_ptr<_FlickGestureState>(new (std::nothrow) _FlickGestureState(this));
427         SysTryReturnResult(NID_WEB_CTRL, __pFlickGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
428
429         __pGestureHandler = __pTapGestureHandler.get();
430
431         return E_SUCCESS;
432 }
433
434
435 result
436 _Web::AddGestureListeners(void)
437 {
438         result r = E_SUCCESS;
439
440         std::unique_ptr<_TouchFlickGestureDetector> pGestureFlick(new (std::nothrow) _TouchFlickGestureDetector());
441         SysTryReturnResult(NID_WEB_CTRL, pGestureFlick.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
442
443         r = pGestureFlick->AddGestureListener(*this);
444         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
445
446         r = AddGestureDetector(*pGestureFlick.get());
447         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
448
449         __pGestureFlick = std::move(pGestureFlick);
450
451         std::unique_ptr<_TouchLongPressGestureDetector> pGestureLongPress(new (std::nothrow) _TouchLongPressGestureDetector());
452         SysTryReturnResult(NID_WEB_CTRL, pGestureLongPress.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
453
454         r = pGestureLongPress->AddGestureListener(*this);
455         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
456
457         r = AddGestureDetector(*pGestureLongPress.get());
458         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
459
460         __pGestureLongPress = std::move(pGestureLongPress);
461
462         std::unique_ptr<_TouchTapGestureDetector> pGestureDoubleTap(new (std::nothrow) _TouchTapGestureDetector());
463         SysTryReturnResult(NID_WEB_CTRL, pGestureDoubleTap.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
464
465         r = pGestureDoubleTap->AddGestureListener(*this);
466         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
467
468         r = AddGestureDetector(*pGestureDoubleTap.get());
469         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
470
471         __pGestureDoubleTap = std::move(pGestureDoubleTap);
472
473         std::unique_ptr<_TouchPinchGestureDetector> pGesturePinch(new (std::nothrow) _TouchPinchGestureDetector());
474         SysTryReturnResult(NID_WEB_CTRL, pGesturePinch.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
475
476         r = pGesturePinch->AddGestureListener(*this);
477         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
478
479         r = AddGestureDetector(*pGesturePinch.get());
480         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
481
482         __pGesturePinch = std::move(pGesturePinch);
483
484         return E_SUCCESS;
485 }
486
487
488 void
489 _Web::RemoveGestureListener(void)
490 {
491         if (__pGestureFlick.get())
492         {
493                 __pGestureFlick->RemoveGestureListener(*this);
494                 RemoveGestureDetector(*__pGestureFlick);
495         }
496
497         if (__pGestureLongPress.get())
498         {
499                 __pGestureLongPress->RemoveGestureListener(*this);
500                 RemoveGestureDetector(*__pGestureLongPress);
501         }
502
503         if (__pGestureDoubleTap.get())
504         {
505                 __pGestureDoubleTap->RemoveGestureListener(*this);
506                 RemoveGestureDetector(*__pGestureDoubleTap);
507         }
508
509         if (__pGesturePinch.get())
510         {
511                 __pGesturePinch->RemoveGestureListener(*this);
512                 RemoveGestureDetector(*__pGesturePinch);
513         }
514
515         Evas_Object* pView = GetWebNativeNode();
516         if (pView)
517         {
518                 evas_object_smart_callback_del(pView, "edge,left", OnEdgeLeft);
519                 evas_object_smart_callback_del(pView, "edge,right", OnEdgeRight);
520                 evas_object_smart_callback_del(pView, "edge,top", OnEdgeTop);
521                 evas_object_smart_callback_del(pView, "edge,bottom", OnEdgeBottom);
522         }
523 }
524
525
526 result
527 _Web::InitializeWebNativeNode(void)
528 {
529         result r = E_SUCCESS;
530
531         r = CreateWebkitEvasObject();
532         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
533
534         SetNativeObjectFocusable(false);
535
536         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
537         SysTryReturn(NID_WEB_CTRL, pContainer, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(E_SYSTEM));
538
539         __pTextElement = new (std::nothrow) _AccessibilityElement(true);
540         SysTryReturn(NID_WEB_CTRL, __pTextElement, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
541
542         __pTextElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
543         __pTextElement->SetLabel(L"Web control");
544
545         pContainer->AddElement(*__pTextElement);
546         pContainer->Activate(true);
547
548         _WebAccessibilityListener* pListener = new (std::nothrow) _WebAccessibilityListener(GetWebNativeNode());
549         SysTryReturn(NID_WEB_CTRL, pListener, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
550
551         pContainer->AddListener(*dynamic_cast<_IAccessibilityListener*>(pListener));
552
553         _WebAccessibilityFocusHandler* pFocusHandler = new (std::nothrow) _WebAccessibilityFocusHandler(GetWebNativeNode());
554         SysTryReturn(NID_WEB_CTRL, pFocusHandler, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
555
556         pContainer->SetFocusHandler(dynamic_cast<_IAccessibilityFocusHandler*>(pFocusHandler));
557
558         return E_SUCCESS;
559 }
560
561
562 Point
563 _Web::GetAbsoluteCoordinate(Point relativePoint)
564 {
565         return _CoordinateSystemUtils::Transform(ConvertToScreenPosition(relativePoint));
566 }
567
568
569 FloatPoint
570 _Web::GetAbsoluteCoordinate(FloatPoint relativePoint)
571 {
572         return _CoordinateSystemUtils::Transform(ConvertToScreenPosition(relativePoint));
573 }
574
575
576 Point
577 _Web::GetRelativeCoordinate(Point absolutePoint)
578 {
579         return ConvertToControlPosition(_CoordinateSystemUtils::InverseTransform(absolutePoint));
580 }
581
582
583 FloatPoint
584 _Web::GetRelativeCoordinate(FloatPoint absolutePoint)
585 {
586         return ConvertToControlPosition(_CoordinateSystemUtils::InverseTransform(absolutePoint));
587 }
588
589
590 Evas_Object*
591 _Web::GetWebNativeNode(void)
592 {
593         if (__pEflWebkit.get())
594         {
595                 return __pEflWebkit->GetWebEvasObject();
596         }
597
598         return null;
599 }
600
601
602 WebSetting*
603 _Web::GetSetting(void) const
604 {
605         return __pWebSetting.get();
606 }
607
608 _EflWebkit*
609 _Web::GetEflWebkit(void) const
610 {
611         return __pEflWebkit.get();
612 }
613
614
615 result
616 _Web::OnAttaching(const _Control* pParent)
617 {
618         if (__pEflWebkit.get())
619         {
620                 evas_object_show(__pEflWebkit->GetWebEvasObject());
621                 evas_object_focus_set(__pEflWebkit->GetWebEvasObject(), EINA_TRUE);
622         }
623
624         return E_SUCCESS;
625 }
626
627
628 result
629 _Web::OnBoundsChanging(const Rectangle& bounds)
630 {
631         Rectangle absoluteBounds = GetAbsoluteBounds();
632         Rectangle webBounds = GetBounds();
633         _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetTransformer();
634         SysTryReturnResult(NID_WEB_CTRL, pXformer, E_SYSTEM, "[%s] A system error has been occurred. Failed to get coordinate transformer.", GetErrorMessage(E_SYSTEM));
635
636         if (__pEflWebkit.get() && __isRotated == false)
637         {
638                 evas_object_move(__pEflWebkit->GetWebEvasObject(), pXformer->TransformHorizontal(absoluteBounds.x - webBounds.x + bounds.x), pXformer->TransformVertical(absoluteBounds.y - webBounds.y + bounds.y));
639                 evas_object_resize(__pEflWebkit->GetWebEvasObject(), pXformer->TransformHorizontal(bounds.width), pXformer->TransformVertical(bounds.height));
640         }
641
642         return E_SUCCESS;
643 }
644
645
646 void
647 _Web::OnBoundsChanged(void)
648 {
649         __isRotated = false;
650 }
651
652
653 void
654 _Web::OnChangeLayout(_ControlOrientation orientation)
655 {
656         __isRotated = true;
657 }
658
659
660 void
661 _Web::ChangeGesture(_WebGestureType type)
662 {
663         switch (type)
664         {
665         case WEB_GESTURE_TYPE_TAP:
666                 __pGestureHandler = __pTapGestureHandler.get();
667                 __gestureType = WEB_GESTURE_TYPE_TAP;
668                 break;
669
670         case WEB_GESTURE_TYPE_PANNING:
671                 __pGestureHandler = __pPanningGestureHandler.get();
672                 __gestureType = WEB_GESTURE_TYPE_PANNING;
673                 break;
674
675         case WEB_GESTURE_TYPE_FLICK:
676                 __pGestureHandler = __pFlickGestureHandler.get();
677                 __gestureType = WEB_GESTURE_TYPE_FLICK;
678                 break;
679
680         case WEB_GESTURE_TYPE_PINCH:
681                 __pGestureHandler = __pPinchGestureHandler.get();
682                 __gestureType = WEB_GESTURE_TYPE_PINCH;
683                 break;
684
685         default:
686                 SysAssert(false);
687         }
688 }
689
690
691 void
692 _Web::SetEdgeReachedEvent(_WebEdgeType type)
693 {
694         __edgeType |= type;
695
696         switch(type)
697         {
698         case WEB_EDGE_LEFT:
699                 __edgeType &= ~WEB_EDGE_RIGHT;
700                 break;
701
702         case WEB_EDGE_RIGHT:
703                 __edgeType &= ~WEB_EDGE_LEFT;
704                 break;
705
706         case WEB_EDGE_TOP:
707                 __edgeType &= ~WEB_EDGE_BOTTOM;
708                 break;
709
710         case WEB_EDGE_BOTTOM:
711                 __edgeType &= ~WEB_EDGE_TOP;
712                 break;
713
714         default:
715                 SysAssert(false);
716         }
717 }
718
719
720 bool
721 _Web::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
722 {
723         __touchPressed = true;
724
725         if (__pEflWebkit.get())
726         {
727                 __edgeType = WEB_EDGE_NONE;
728                 __previousTouchedPosition = touchInfo.GetCurrentPosition();
729
730                 SendTouchEventForJavaScript(touchInfo);
731
732                 return __pGestureHandler->OnTouchPressed(source, touchInfo);
733         }
734
735         return false;
736 }
737
738
739 bool
740 _Web::CanOutOfEdgeLeft(float scrollDistanceX, int pageDistance)
741 {
742         if (scrollDistanceX < 0.0f)
743         {
744                 __edgeType &= ~WEB_EDGE_RIGHT;
745
746                 return false;
747         }
748         else if (scrollDistanceX > 0.0f && pageDistance != 0)
749         {
750                 __edgeType &= ~WEB_EDGE_LEFT;
751         }
752
753         return true;
754 }
755
756
757 bool
758 _Web::CanOutOfEdgeRight(float scrollDistanceX, int pageDistance)
759 {
760         if (scrollDistanceX > 0.0f)
761         {
762                 __edgeType &= ~WEB_EDGE_LEFT;
763
764                 return false;
765         }
766         else if (scrollDistanceX < 0.0f &&  pageDistance != 0)
767         {
768                 __edgeType &= ~WEB_EDGE_RIGHT;
769         }
770
771         return true;
772 }
773
774
775 bool
776 _Web::CanOutOfEdgeTop(float scrollDistanceY, int pageDistance)
777 {
778         if (scrollDistanceY < 0.0f)
779         {
780                 __edgeType &= ~WEB_EDGE_BOTTOM;
781
782                 return false;
783         }
784         else if (scrollDistanceY > 0.0f && pageDistance != 0)
785         {
786                 __edgeType &= ~WEB_EDGE_TOP;
787         }
788
789         return true;
790 }
791
792
793 bool
794 _Web::CanOutOfEdgeBottom(float scrollDistanceY, int pageDistance)
795 {
796         if (scrollDistanceY > 0.0f)
797         {
798                 __edgeType &= ~WEB_EDGE_TOP;
799
800                 return false;
801         }
802         else if (scrollDistanceY < 0.0f && pageDistance != 0)
803         {
804                 __edgeType &= ~WEB_EDGE_BOTTOM;
805         }
806
807         return true;
808 }
809
810
811 bool
812 _Web::CanConsumeTouchMoved(float scrollDistanceX, float scrollDistanceY)
813 {
814         if (__edgeType ==  WEB_EDGE_NONE)
815         {
816                 return true;
817         }
818
819         bool ret = true;
820
821         int scrollWidth = 0;
822         int scrollHeight = 0;
823         ewk_view_scroll_size_get(GetWebNativeNode(), &scrollWidth, &scrollHeight);
824
825         int scrollX = 0;
826         int scrollY = 0;
827         ewk_view_scroll_pos_get(GetWebNativeNode(), &scrollX, &scrollY);
828
829         if (scrollWidth == 0)
830         {
831                 if (__edgeType & WEB_EDGE_TOP)
832                 {
833                         if (!CanOutOfEdgeTop(scrollDistanceY, scrollY - 0))
834                         {
835                                 return false;
836                         }
837                 }
838                 else if (__edgeType & WEB_EDGE_BOTTOM)
839                 {
840                         if (!CanOutOfEdgeBottom(scrollDistanceY, scrollY - scrollHeight))
841                         {
842                                 return false;
843                         }
844                 }
845         }
846
847         if (scrollHeight == 0)
848         {
849                 if (__edgeType & WEB_EDGE_LEFT)
850                 {
851                         if (!CanOutOfEdgeLeft(scrollDistanceX, scrollX - 0))
852                         {
853                                 return false;
854                         }
855                 }
856                 else if  (__edgeType & WEB_EDGE_RIGHT)
857                 {
858                         if (!CanOutOfEdgeRight(scrollDistanceX, scrollX - scrollWidth))
859                         {
860                                 return false;
861                         }
862                 }
863         }
864
865         if (scrollWidth > 0 && scrollHeight > 0)
866         {
867                 if  ((__edgeType & WEB_EDGE_LEFT) && (__edgeType & WEB_EDGE_TOP))
868                 {
869                         if (!CanOutOfEdgeLeft(scrollDistanceX, scrollX - 0) || !CanOutOfEdgeTop(scrollDistanceY, scrollY - 0))
870                         {
871                                 return false;
872                         }
873                 }
874                 else if  ((__edgeType & WEB_EDGE_LEFT) && (__edgeType & WEB_EDGE_BOTTOM))
875                 {
876                         if (!CanOutOfEdgeLeft(scrollDistanceX, scrollX - 0) || !CanOutOfEdgeBottom(scrollDistanceY, scrollY - scrollHeight))
877                         {
878                                 return false;
879                         }
880                 }
881                 else if  ((__edgeType & WEB_EDGE_RIGHT) && (__edgeType & WEB_EDGE_TOP))
882                 {
883                         if (!CanOutOfEdgeRight(scrollDistanceX, scrollX - scrollWidth) || !CanOutOfEdgeTop(scrollDistanceY, scrollY - 0))
884                         {
885                                 return false;
886                         }
887                 }
888                 else if  ((__edgeType & WEB_EDGE_RIGHT) && (__edgeType & WEB_EDGE_BOTTOM))
889                 {
890                         if (!CanOutOfEdgeRight(scrollDistanceX, scrollX - scrollWidth) || !CanOutOfEdgeBottom(scrollDistanceY, scrollY - scrollHeight))
891                         {
892                                 return false;
893                         }
894                 }
895         }
896
897         return true;
898 }
899
900
901 bool
902 _Web::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
903 {
904         if (__pEflWebkit.get())
905         {
906                 SendTouchEventForJavaScript(touchInfo);
907
908                 float scrollDistanceX = __previousTouchedPosition.x - touchInfo.GetCurrentPosition().x;
909                 float scrollDistanceY = __previousTouchedPosition.y - touchInfo.GetCurrentPosition().y;
910                 __previousTouchedPosition = touchInfo.GetCurrentPosition();
911
912                 if (CanConsumeTouchMoved(scrollDistanceX, scrollDistanceY))
913                 {
914                         return __pGestureHandler->OnTouchMoved(source, touchInfo);
915                 }
916         }
917
918         return false;
919 }
920
921
922 bool
923 _Web::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
924 {
925         __touchPressed = false;
926
927         SetFocused();
928
929         if (__pEflWebkit.get())
930         {
931                 SendTouchEventForJavaScript(touchInfo);
932
933                 return __pGestureHandler->OnTouchReleased(source, touchInfo);
934         }
935
936         return false;
937 }
938
939
940 bool
941 _Web::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
942 {
943         if (__pEflWebkit.get())
944         {
945                 SendTouchEventForJavaScript(touchInfo);
946
947                 return __pGestureHandler->OnTouchCanceled(source, touchInfo);
948         }
949
950         return false;
951 }
952
953
954 bool
955 _Web::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
956 {
957         if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_TAP)
958         {
959                 return __pTapGestureHandler->OnLongPressGestureDetected(gesture);
960         }
961
962         return false;
963 }
964
965
966 bool
967 _Web::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
968 {
969         return false;
970 }
971
972
973 bool
974 _Web::OnTapGestureDetected(_TouchTapGestureDetector& gesture)
975 {
976         if (__pEflWebkit.get())
977         {
978                 return __pTapGestureHandler->OnTapGestureDetected(gesture);
979         }
980
981         return false;
982 }
983
984
985 bool
986 _Web::OnTapGestureCanceled(_TouchTapGestureDetector& gesture)
987 {
988         return false;
989 }
990
991
992 bool
993 _Web::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
994 {
995         if (__pEflWebkit.get())
996         {
997                 return __pFlickGestureHandler->OnFlickGestureDetected(gesture);
998         }
999
1000         return false;
1001 }
1002
1003
1004 bool
1005 _Web::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture)
1006 {
1007         return false;
1008 }
1009
1010
1011 bool
1012 _Web::OnPinchGestureStarted(Tizen::Ui::_TouchPinchGestureDetector& gesture)
1013 {
1014         if (__pEflWebkit.get())
1015         {
1016                 return __pPinchGestureHandler->OnPinchGestureStarted(gesture);
1017         }
1018
1019         return false;
1020 }
1021
1022
1023 bool
1024 _Web::OnPinchGestureChanged(Tizen::Ui::_TouchPinchGestureDetector& gesture)
1025 {
1026         if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_PINCH)
1027         {
1028                 return __pPinchGestureHandler->OnPinchGestureChanged(gesture);
1029         }
1030
1031         return false;
1032 }
1033
1034
1035 bool
1036 _Web::OnPinchGestureFinished(Tizen::Ui::_TouchPinchGestureDetector& gesture)
1037 {
1038         if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_PINCH)
1039         {
1040                 return __pPinchGestureHandler->OnPinchGestureFinished(gesture);
1041         }
1042
1043         return false;
1044 }
1045
1046
1047 bool
1048 _Web::OnPinchGestureCanceled(Tizen::Ui::_TouchPinchGestureDetector& gesture)
1049 {
1050         return false;
1051 }
1052
1053
1054 Canvas*
1055 _Web::OnCanvasRequestedN(const FloatRectangle& bounds)
1056 {
1057         SysTryReturn(NID_WEB_CTRL, bounds.width >= 0.0f && bounds.height >= 0.0f, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Canvas size is out of range. size = (%f, %f)", bounds.width, bounds.height);
1058         if (bounds.width == 0.0f || bounds.height == 0.0f)
1059         {
1060                 FloatDimension size(GetSizeF());
1061                 SysTryReturn(NID_WEB_CTRL, bounds.x >= 0.0f && bounds.y >= 0.0f && bounds.x <= size.width && bounds.y <= size.height, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Bounds is out of range.");
1062         }
1063
1064         result r = E_SUCCESS;
1065
1066         Rectangle absBounds(_CoordinateSystemUtils::ConvertToInteger(_CoordinateSystemUtils::Transform(bounds)));
1067
1068         Eina_Rectangle rect;
1069         EINA_RECTANGLE_SET(&rect, absBounds.x, absBounds.y, absBounds.width, absBounds.height);
1070
1071         Evas_Object* pWebFrame = GetWebNativeNode();
1072         Evas_Object* pScreenShot = ewk_view_screenshot_contents_get(pWebFrame, rect, 1.0f, evas_object_evas_get(pWebFrame));
1073
1074         std::unique_ptr<Canvas> pCanvas(new (std::nothrow) Canvas());
1075         SysTryReturn(NID_WEB_CTRL, pCanvas.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1076
1077         if (pScreenShot)
1078         {
1079                 BufferInfo bufferInfo;
1080
1081                 r = _Utility::GetPixelBufferFromEvasObject(pScreenShot, bufferInfo);
1082                 evas_object_del(pScreenShot);
1083                 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
1084
1085                 r = pCanvas->Construct(bufferInfo);
1086                 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
1087         }
1088         else
1089         {
1090                 r = pCanvas->Construct(bounds);
1091                 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
1092         }
1093
1094         return pCanvas.release();
1095 }
1096
1097
1098 Bitmap*
1099 _Web::OnCapturedBitmapRequestedN(void)
1100 {
1101         result r = E_SUCCESS;
1102
1103         BufferInfo bufferInfo;
1104         SysTryReturn(NID_WEB_CTRL, OnCaptureAcquire(bufferInfo), null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get snapshot of Web control", GetErrorMessage(E_SYSTEM));
1105
1106         ByteBuffer buffer;
1107         int bufferSize = bufferInfo.bitsPerPixel * bufferInfo.width * bufferInfo.height;
1108
1109         r = buffer.Construct(reinterpret_cast < byte* >(bufferInfo.pPixels), 0, bufferSize, bufferSize);
1110         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
1111
1112         std::unique_ptr<Bitmap> pBitmap(new (std::nothrow) Bitmap());
1113         SysTryReturn(NID_WEB_CTRL, pBitmap.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1114
1115         r = pBitmap->Construct(buffer, Dimension(bufferInfo.width, bufferInfo.height), BITMAP_PIXEL_FORMAT_ARGB8888);
1116         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
1117
1118         return pBitmap.release();
1119 }
1120
1121
1122 bool
1123 _Web::OnCaptureAcquire(BufferInfo& output)
1124 {
1125         result r = E_SUCCESS;
1126
1127         FloatPoint position(GetPositionF());
1128         FloatDimension size(GetSizeF());
1129
1130         Dimension absSize(_CoordinateSystemUtils::ConvertToInteger(_CoordinateSystemUtils::Transform(size)));
1131
1132         Eina_Rectangle rect;
1133         EINA_RECTANGLE_SET(&rect, 0, 0, absSize.width, absSize.height);
1134
1135         Evas_Object* pWebFrame = GetWebNativeNode();
1136         Evas_Object* pScreenShot = ewk_view_screenshot_contents_get(pWebFrame, rect, 1.0f, evas_object_evas_get(pWebFrame));
1137         SysTryReturn(NID_WEB_CTRL, pScreenShot, false, E_SYSTEM, "[%s] A system error has been occurred. Failed to get snapshot of Web control", GetErrorMessage(E_SYSTEM));
1138
1139         r = _Utility::GetPixelBufferFromEvasObject(pScreenShot, output);
1140         evas_object_del(pScreenShot);
1141         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] propagating", GetErrorMessage(r));
1142
1143         return true;
1144 }
1145
1146
1147 void
1148 _Web::SendTouchEventForJavaScript(const _TouchInfo& touchInfo)
1149 {
1150         result r = E_SUCCESS;
1151
1152         _TouchManager* pTouchManager = _TouchManager::GetInstance();
1153         SysAssertf(pTouchManager, "Failed to get touch manager.");
1154
1155         std::unique_ptr<IListT<_FingerInfo*> > pTouchList(pTouchManager->GetMultiFingerInfoListN());
1156         SysTryReturnVoidResult(NID_WEB_CTRL, pTouchList.get(), GetLastResult(), "[%s] Failed to get touch list.", GetErrorMessage(GetLastResult()));
1157
1158         std::unique_ptr<IBidirectionalEnumeratorT<_FingerInfo*> > pTouchListEnum(pTouchList->GetBidirectionalEnumeratorN());
1159         SysAssertf(pTouchListEnum.get() != null, "Failed to get enumerator of touch list.");
1160
1161         Eina_List* pPointList = null;
1162         _FingerInfo* pFingerInfo = null;
1163         while(pTouchListEnum->MoveNext() == E_SUCCESS)
1164         {
1165                 r = pTouchListEnum->GetCurrent(pFingerInfo);
1166                 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1167
1168                 _TouchStatus state = pFingerInfo->GetStatus();
1169                 if(state == _TOUCH_PRESSED || state == _TOUCH_MOVED || state == _TOUCH_RELEASED || state == _TOUCH_CANCELED)
1170                 {
1171                         Point integerPoint(_CoordinateSystemUtils::ConvertToInteger(GetAbsoluteCoordinate(pFingerInfo->GetPoint())));
1172
1173                         Ewk_Touch_Point* pPoint = static_cast<Ewk_Touch_Point*>(calloc(1, sizeof(Ewk_Touch_Point)));
1174                         pPoint->id = pFingerInfo->GetPointId();
1175                         pPoint->x = integerPoint.x;
1176                         pPoint->y = integerPoint.y;
1177                         pPoint->state = GetEvasTouchState((TouchStatus)pFingerInfo->GetStatus());
1178                         SysSecureLog(NID_WEB_CTRL, "The current value of id is %lu, x is %d, y is %d, state is %d", pPoint->id, pPoint->x, pPoint->y, pPoint->state);
1179
1180                         pPointList = eina_list_append(pPointList, pPoint);
1181                 }
1182         }
1183
1184         ewk_view_feed_touch_event(__pEflWebkit->GetWebEvasObject(), GetEwkTouchEvent(touchInfo.GetTouchStatus()), pPointList, null);
1185
1186         void* pData = null;
1187         EINA_LIST_FREE(pPointList, pData)
1188         free(pData);
1189 }
1190
1191
1192 Ewk_Touch_Event_Type
1193 _Web::GetEwkTouchEvent(_TouchStatus touchStatus)
1194 {
1195         Ewk_Touch_Event_Type ewkTouchEvent = EWK_TOUCH_CANCEL;
1196
1197         switch (touchStatus)
1198         {
1199         case _TOUCH_PRESSED :
1200                 ewkTouchEvent = EWK_TOUCH_START;
1201                 break;
1202         case _TOUCH_MOVED :
1203                 ewkTouchEvent = EWK_TOUCH_MOVE;
1204                 break;
1205         case _TOUCH_RELEASED :
1206                 ewkTouchEvent = EWK_TOUCH_END;
1207                 break;
1208         case _TOUCH_CANCELED :
1209                 //fall through
1210         default :
1211                 ewkTouchEvent = EWK_TOUCH_CANCEL;
1212                 break;
1213         }
1214
1215         return ewkTouchEvent;
1216 }
1217
1218
1219 Evas_Touch_Point_State
1220 _Web::GetEvasTouchState(TouchStatus touchStatus)
1221 {
1222         Evas_Touch_Point_State evasTouchState = EVAS_TOUCH_POINT_CANCEL;
1223
1224         switch (touchStatus)
1225         {
1226         case TOUCH_PRESSED :
1227                 evasTouchState = EVAS_TOUCH_POINT_DOWN;
1228                 break;
1229         case TOUCH_MOVED :
1230                 evasTouchState = EVAS_TOUCH_POINT_MOVE;
1231                 break;
1232         case TOUCH_RELEASED :
1233                 evasTouchState = EVAS_TOUCH_POINT_UP;
1234                 break;
1235         case TOUCH_CANCELED :
1236                 //fall through
1237         default :
1238                 evasTouchState = EVAS_TOUCH_POINT_CANCEL;
1239                 //todo : mapping    EVAS_TOUCH_POINT_STILL, /**< Touch point is not moved af
1240                 break;
1241         }
1242
1243         return evasTouchState;
1244 }
1245
1246
1247 void
1248 _Web::SetFullScreenEntered(bool isFullScreenEntered)
1249 {
1250         __isFullScreenEntered = isFullScreenEntered;
1251 }
1252
1253
1254 void
1255 _Web::SetFocusEnd(bool focus)
1256 {
1257         __focus = focus;
1258 }
1259
1260
1261 bool
1262 _Web::IsFocusEnd(void) const
1263 {
1264         return __focus;
1265 }
1266
1267
1268 bool
1269 _Web::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1270 {
1271         Ecore_X_Window rootWindow = ecore_x_window_root_first_get();
1272         Ecore_X_Atom keyboardExist = ecore_x_atom_get("X External Keyboard Exist");
1273         unsigned int keyboardNumber = 0;
1274         int ret = ecore_x_window_prop_card32_get(rootWindow, keyboardExist, &keyboardNumber, 1);
1275         if (keyboardNumber == 0)
1276         {
1277                 return false;
1278         }
1279
1280         _KeyCode keyCode = keyInfo.GetKeyCode();
1281
1282         if (IsFocusEnd() == true)
1283         {
1284                 SetFocusEnd(false);
1285                 evas_object_focus_set(GetWebNativeNode(), EINA_FALSE);
1286                 return false;
1287         }
1288
1289         switch(keyCode)
1290         {
1291         case _KEY_UP:
1292         case _KEY_DOWN:
1293                 evas_object_focus_set(GetWebNativeNode(), EINA_FALSE);
1294                 return false;
1295                 break;
1296         default:
1297                 break;
1298         }
1299
1300         evas_object_focus_set(GetWebNativeNode(), EINA_TRUE);
1301
1302         return true;
1303 }
1304
1305
1306 bool
1307 _Web::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1308 {
1309         if (__isFullScreenEntered)
1310         {
1311                 if (keyInfo.GetKeyCode() == _KEY_ESC || keyInfo.GetKeyCode() == _KEY_BACK)
1312                 {
1313                         __isFullScreenEntered = false;
1314
1315                         ewk_view_fullscreen_exit(GetWebNativeNode());
1316
1317                         return true;
1318                 }
1319         }
1320
1321         return false;
1322 }
1323
1324
1325 void
1326 _Web::OnDrawFocus(void)
1327 {
1328 }
1329
1330
1331 bool
1332 _Web::OnFocusLost(const _Control& source)
1333 {
1334         _Control::OnFocusLost(*this);
1335
1336         if (__touchPressed == true)
1337         {
1338                 _TouchManager* pTouchManager = _TouchManager::GetInstance();
1339                 SysAssertf(pTouchManager, "Failed to get touch manager.");
1340
1341                 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(pTouchManager->GetPosition(pTouchManager->GetCurrentPointId())));
1342
1343                 Ewk_Touch_Point* pPoint = static_cast< Ewk_Touch_Point* >(calloc(1, sizeof(Ewk_Touch_Point)));
1344                 pPoint->id = 0;
1345                 pPoint->x = absPoint.x;
1346                 pPoint->y = absPoint.y;
1347                 pPoint->state = EVAS_TOUCH_POINT_CANCEL;
1348
1349                 Eina_List* pPointList = null;
1350                 pPointList = eina_list_append(pPointList, pPoint);
1351
1352                 ewk_view_feed_touch_event(GetWebNativeNode(), EWK_TOUCH_CANCEL, pPointList, null);
1353
1354                 void* pData = null;
1355                 EINA_LIST_FREE(pPointList, pData)
1356                 free(pData);
1357
1358                 __touchPressed = false;
1359         }
1360
1361         return false;
1362 }
1363
1364
1365 }}} // Tizen::Web::Controls