2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FWebCtrl_Web.cpp
20 * @brief The file contains the definition of _Web class.
22 * The file contains the definition of _Web class.
25 #include <FBaseByteBuffer.h>
26 #include <FBaseColLinkedListT.h>
27 #include <FBaseSysLog.h>
28 #include <FBaseColIListT.h>
29 #include <FGrpFloatPoint.h>
30 #include <FGrpPoint.h>
31 #include <FGrpBitmap.h>
32 #include <FGrpCanvas.h>
33 #include <FGrpFloatRectangle.h>
34 #include <FSysVibrator.h>
35 #include <FWebCtrlWebSetting.h>
36 #include <FGrp_CoordinateSystem.h>
37 #include <FSys_VibratorImpl.h>
38 #include <FUiAnim_EflNode.h>
39 #include <FUiAnim_VisualElement.h>
40 #include <FUi_CoordinateSystemUtils.h>
41 #include <FUi_AccessibilityContainer.h>
42 #include <FUi_AccessibilityElement.h>
43 #include <FUi_IAccessibilityFocusHandler.h>
44 #include <FUi_TouchManager.h>
45 #include "FWebCtrl_EflWebkit.h"
46 #include "FWebCtrl_GestureState.h"
47 #include "FWebCtrl_Web.h"
48 #include "FWebCtrl_WebImpl.h"
49 #include "FWebCtrl_WebSettingImpl.h"
50 #include "FWebCtrl_Utility.h"
53 using namespace Tizen::Base;
54 using namespace Tizen::Base::Collection;
55 using namespace Tizen::Graphics;
56 using namespace Tizen::Ui;
57 using namespace Tizen::Ui::Animations;
62 static int __animationAccessibilityCount = 0;
63 class _WebAccessibilityFocusHandler
64 :public Tizen::Ui::_IAccessibilityFocusHandler
67 _WebAccessibilityFocusHandler(void)
70 virtual ~_WebAccessibilityFocusHandler(void)
73 virtual bool OnMoveFocus(Tizen::Ui::_AccessibilityFocusDirection direction)
75 __animationAccessibilityCount++;
76 if (direction == Tizen::Ui::_ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS)
78 if(__animationAccessibilityCount %3 == 0)
80 SysLog(NID_WEB_CTRL, "_WebAccessibilityFocusHandler can move focus , :direction : PREVIOUS");
83 SysLog(NID_WEB_CTRL, "!!!_WebAccessibilityFocusHandler can NOT move focus , :direction : PREVIOUS");
86 else if (direction == Tizen::Ui::_ACCESSIBILITY_FOCUS_DIRECTION_NEXT)
88 if(__animationAccessibilityCount %3 == 0)
90 SysLog(NID_WEB_CTRL, "_WebAccessibilityFocusHandler can move focus , :direction : NEXT");
93 SysLog(NID_WEB_CTRL, "!!!_WebAccessibilityFocusHandler can NOT move focus , :direction : NEXT");
98 virtual bool OnMoveFocus(const Tizen::Graphics::Point& point)
100 if(__animationAccessibilityCount %2 == 0)
102 SysLog(NID_WEB_CTRL, "_WebAccessibilityFocusHandler can read element at the point (%d,%d)", point.x, point.y);
107 SysLog(NID_WEB_CTRL, "_WebAccessibilityFocusHandler can NOT read element at the point (%d,%d)", point.x, point.y);
116 namespace Tizen { namespace Web { namespace Controls
120 static const char WEB_CTRL[] = "webcontrol";
124 : __pGestureHandler(null)
126 , __pWebSetting(null)
127 , __pGestureFlick(null)
128 , __pGestureLongPress(null)
129 , __pGesturePinch(null)
130 , __pGestureDoubleTap(null)
131 , __pTouchEventInfoList(null)
132 , __pTapGestureHandler(null)
133 , __pPanningGestureHandler(null)
134 , __pFlickGestureHandler(null)
135 , __pPinchGestureHandler(null)
136 , __gestureType(WEB_GESTURE_TYPE_TAP)
137 , __pTextElement(null)
139 SetBackgroundColor(Color(0, 0, 0, 0));
145 RemoveGestureListener();
150 _Web::CreateWebN(void)
152 result r = E_SUCCESS;
154 std::unique_ptr<_Web> pWeb(new (std::nothrow) _Web());
155 SysTryReturn(NID_WEB_CTRL, pWeb.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
157 pWeb->__pWebSetting = std::unique_ptr<WebSetting>(new (std::nothrow) WebSetting());
158 SysTryReturn(NID_WEB_CTRL, pWeb->__pWebSetting.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
160 pWeb->AcquireHandle();
161 pWeb->SetMultiTouchEnabled(true);
162 pWeb->SetTouchPressThreshold(0.08);
164 r = pWeb->AddGestureListeners();
165 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
167 r = pWeb->InitializeGestureStates();
168 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
170 return pWeb.release();
175 _Web::CreateWebkitEvasObject(void)
177 result r = E_SUCCESS;
179 std::unique_ptr<_EflWebkit> pEflWebkit(new (std::nothrow) _EflWebkit());
180 SysTryReturnResult(NID_WEB_CTRL, pEflWebkit.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
182 r = pEflWebkit->Construct(GetAbsoluteBounds(), *GetVisualElement(), this);
183 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
185 __pEflWebkit = std::move(pEflWebkit);
192 _Web::InitializeGestureStates(void)
194 __pPinchGestureHandler = std::unique_ptr<_PinchGestureState>(new (std::nothrow) _PinchGestureState(this));
195 SysTryReturnResult(NID_WEB_CTRL, __pPinchGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
197 __pTapGestureHandler = std::unique_ptr<_TapGestureState>(new (std::nothrow) _TapGestureState(this));
198 SysTryReturnResult(NID_WEB_CTRL, __pTapGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
200 __pPanningGestureHandler = std::unique_ptr<_PanningGestureState>(new (std::nothrow) _PanningGestureState(this));
201 SysTryReturnResult(NID_WEB_CTRL, __pPanningGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
203 __pFlickGestureHandler = std::unique_ptr<_FlickGestureState>(new (std::nothrow) _FlickGestureState(this));
204 SysTryReturnResult(NID_WEB_CTRL, __pFlickGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
206 __pGestureHandler = __pTapGestureHandler.get();
213 _Web::AddGestureListeners(void)
215 result r = E_SUCCESS;
217 std::unique_ptr<_TouchFlickGestureDetector> pGestureFlick(new (std::nothrow) _TouchFlickGestureDetector());
218 SysTryReturnResult(NID_WEB_CTRL, pGestureFlick.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
220 r = pGestureFlick->AddGestureListener(*this);
221 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
223 r = AddGestureDetector(*pGestureFlick.get());
224 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
226 __pGestureFlick = std::move(pGestureFlick);
228 std::unique_ptr<_TouchLongPressGestureDetector> pGestureLongPress(new (std::nothrow) _TouchLongPressGestureDetector());
229 SysTryReturnResult(NID_WEB_CTRL, pGestureLongPress.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
231 r = pGestureLongPress->AddGestureListener(*this);
232 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
234 r = AddGestureDetector(*pGestureLongPress.get());
235 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
237 __pGestureLongPress = std::move(pGestureLongPress);
239 std::unique_ptr<_TouchTapGestureDetector> pGestureDoubleTap(new (std::nothrow) _TouchTapGestureDetector());
240 SysTryReturnResult(NID_WEB_CTRL, pGestureDoubleTap.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
242 r = pGestureDoubleTap->AddGestureListener(*this);
243 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
245 r = AddGestureDetector(*pGestureDoubleTap.get());
246 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
248 __pGestureDoubleTap = std::move(pGestureDoubleTap);
250 std::unique_ptr<_TouchPinchGestureDetector> pGesturePinch(new (std::nothrow) _TouchPinchGestureDetector());
251 SysTryReturnResult(NID_WEB_CTRL, pGesturePinch.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
253 r = pGesturePinch->AddGestureListener(*this);
254 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
256 r = AddGestureDetector(*pGesturePinch.get());
257 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
259 __pGesturePinch = std::move(pGesturePinch);
266 _Web::RemoveGestureListener(void)
268 if (__pGestureFlick.get())
270 __pGestureFlick->RemoveGestureListener(*this);
271 RemoveGestureDetector(*__pGestureFlick);
274 if (__pGestureLongPress.get())
276 __pGestureLongPress->RemoveGestureListener(*this);
277 RemoveGestureDetector(*__pGestureLongPress);
280 if (__pGestureDoubleTap.get())
282 __pGestureDoubleTap->RemoveGestureListener(*this);
283 RemoveGestureDetector(*__pGestureDoubleTap);
286 if (__pGesturePinch.get())
288 __pGesturePinch->RemoveGestureListener(*this);
289 RemoveGestureDetector(*__pGesturePinch);
295 _Web::InitializeWebNativeNode(void)
297 result r = E_SUCCESS;
299 r = CreateWebkitEvasObject();
300 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
302 SetNativeObjectFocusable(false);
304 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
305 SysTryReturn(NID_WEB_CTRL, pContainer, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(E_SYSTEM));
309 __pTextElement = new (std::nothrow) _AccessibilityElement(true);
310 SysTryReturn(NID_WEB_CTRL, __pTextElement, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory shortage.", GetErrorMessage(E_OUT_OF_MEMORY));
312 __pTextElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
313 //__pTextElement->SetLabel(GetText());
314 //__pTextElement->SetTrait(L"Web");
315 //__pTextElement->SetName(L"WebText");
317 pContainer->AddElement(*__pTextElement);
320 pContainer->Activate(true);
321 _WebAccessibilityFocusHandler* pFocusHandler = new (std::nothrow) _WebAccessibilityFocusHandler();
322 pContainer->SetFocusHandler(dynamic_cast<_IAccessibilityFocusHandler*>(pFocusHandler));
329 _Web::GetAbsoluteCoordinate(Point relativePoint)
331 return _CoordinateSystemUtils::Transform(ConvertToScreenPosition(relativePoint));
336 _Web::GetAbsoluteCoordinate(FloatPoint relativePoint)
338 return _CoordinateSystemUtils::Transform(ConvertToScreenPosition(relativePoint));
343 _Web::GetRelativeCoordinate(Point absolutePoint)
345 return _CoordinateSystemUtils::InverseTransform(ConvertToControlPosition(absolutePoint));
350 _Web::GetRelativeCoordinate(FloatPoint absolutePoint)
352 return _CoordinateSystemUtils::InverseTransform(ConvertToControlPosition(absolutePoint));
357 _Web::GetWebNativeNode(void)
359 SysTryReturn(NID_WEB_CTRL, __pEflWebkit.get(), null, E_INVALID_STATE, "[%s] Native node is in an invalid state.", GetErrorMessage(E_INVALID_STATE));
361 return __pEflWebkit->GetWebEvasObject();
366 _Web::GetSetting(void) const
368 return __pWebSetting.get();
373 _Web::OnAttaching(const _Control* pParent)
375 if (__pEflWebkit.get())
377 evas_object_show(__pEflWebkit->GetWebEvasObject());
378 evas_object_focus_set(__pEflWebkit->GetWebEvasObject(), EINA_TRUE);
386 _Web::OnBoundsChanging(const Rectangle& bounds)
388 Rectangle absoluteBounds = GetAbsoluteBounds();
389 Rectangle webBounds = GetBounds();
390 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetTransformer();
391 SysTryReturnResult(NID_WEB_CTRL, pXformer, E_SYSTEM, "[%s] A system error has been occurred. Failed to get coordinate transformer.", GetErrorMessage(E_SYSTEM));
393 if (__pEflWebkit.get())
395 evas_object_move(__pEflWebkit->GetWebEvasObject(), pXformer->TransformHorizontal(absoluteBounds.x - webBounds.x + bounds.x), pXformer->TransformVertical(absoluteBounds.y - webBounds.y + bounds.y));
396 evas_object_resize(__pEflWebkit->GetWebEvasObject(), pXformer->TransformHorizontal(bounds.width), pXformer->TransformVertical(bounds.height));
404 _Web::ChangeGesture(_WebGestureType type)
408 case WEB_GESTURE_TYPE_TAP:
409 __pGestureHandler = __pTapGestureHandler.get();
410 __gestureType = WEB_GESTURE_TYPE_TAP;
413 case WEB_GESTURE_TYPE_PANNING:
414 __pGestureHandler = __pPanningGestureHandler.get();
415 __gestureType = WEB_GESTURE_TYPE_PANNING;
418 case WEB_GESTURE_TYPE_FLICK:
419 __pGestureHandler = __pFlickGestureHandler.get();
420 __gestureType = WEB_GESTURE_TYPE_FLICK;
423 case WEB_GESTURE_TYPE_PINCH:
424 __pGestureHandler = __pPinchGestureHandler.get();
425 __gestureType = WEB_GESTURE_TYPE_PINCH;
435 _Web::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
437 if (__pEflWebkit.get())
439 SendTouchEventForJavaScript(touchInfo);
441 return __pGestureHandler->OnTouchPressed(source, touchInfo);
449 _Web::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
451 if (__pEflWebkit.get())
453 SendTouchEventForJavaScript(touchInfo);
455 return __pGestureHandler->OnTouchMoved(source, touchInfo);
463 _Web::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
467 if (__pEflWebkit.get())
469 SendTouchEventForJavaScript(touchInfo);
471 return __pGestureHandler->OnTouchReleased(source, touchInfo);
479 _Web::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
481 if (__pEflWebkit.get())
483 SendTouchEventForJavaScript(touchInfo);
485 __pGestureHandler->OnTouchCanceled(source, touchInfo);
493 _Web::OnTouchPressHandled(const _Control& control)
499 _Web::OnTouchReleaseHandled(const _Control& control)
505 _Web::OnTouchMoveHandled(const _Control& control)
511 _Web::OnTouchCancelHandled(const _Control& control)
517 _Web::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
519 if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_TAP)
521 return __pTapGestureHandler->OnLongPressGestureDetected(gesture);
529 _Web::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
536 _Web::OnTapGestureDetected(_TouchTapGestureDetector& gesture)
538 if (__pEflWebkit.get())
540 return __pTapGestureHandler->OnTapGestureDetected(gesture);
548 _Web::OnTapGestureCanceled(_TouchTapGestureDetector& gesture)
555 _Web::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
557 if (__pEflWebkit.get() && _WebSettingImpl::GetInstance(__pWebSetting.get())->IsScrollEnabled())
559 return __pFlickGestureHandler->OnFlickGestureDetected(gesture);
567 _Web::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture)
574 _Web::OnPinchGestureStarted(Tizen::Ui::_TouchPinchGestureDetector& gesture)
576 if (__pEflWebkit.get())
578 return __pPinchGestureHandler->OnPinchGestureStarted(gesture);
586 _Web::OnPinchGestureChanged(Tizen::Ui::_TouchPinchGestureDetector& gesture)
588 if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_PINCH)
590 return __pPinchGestureHandler->OnPinchGestureChanged(gesture);
598 _Web::OnPinchGestureFinished(Tizen::Ui::_TouchPinchGestureDetector& gesture)
600 if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_PINCH)
602 return __pPinchGestureHandler->OnPinchGestureFinished(gesture);
610 _Web::OnPinchGestureCanceled(Tizen::Ui::_TouchPinchGestureDetector& gesture)
617 _Web::OnCanvasRequestedFN(const FloatRectangle& bounds)
619 result r = E_SUCCESS;
621 Evas_Object* pWebFrame = GetWebNativeNode();
623 BufferInfo bufferInfo;
625 Point absPoint(_CoordinateSystemUtils::ConvertToInteger(GetAbsoluteCoordinate(FloatPoint(bounds.x, bounds.y))));
626 Dimension absSize(_CoordinateSystemUtils::ConvertToInteger(_CoordinateSystemUtils::HorizontalTransform(bounds.width)),
627 _CoordinateSystemUtils::ConvertToInteger(_CoordinateSystemUtils::VerticalTransform(bounds.height)));
629 EINA_RECTANGLE_SET(&rect, absPoint.x, absPoint.y, absSize.width, absSize.height);
631 Evas_Object* pScreenShot = ewk_view_screenshot_contents_get(pWebFrame, rect, 1.0f, evas_object_evas_get(pWebFrame));
633 std::unique_ptr<Canvas> pCanvas(new (std::nothrow) Canvas());
634 SysTryReturn(NID_WEB_CTRL, pCanvas.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
638 r = _Utility::GetPixelBufferFromEvasObject(pScreenShot, bufferInfo);
639 evas_object_del(pScreenShot);
640 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
642 r = pCanvas->Construct(bufferInfo);
643 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
647 r = pCanvas->Construct(bounds);
648 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
651 return pCanvas.release();
656 _Web::OnCapturedBitmapRequestedN(void)
658 result r = E_SUCCESS;
660 Evas_Object* pWebFrame = GetWebNativeNode();
663 BufferInfo bufferInfo;
665 Dimension size(GetSize());
666 Point absSize(GetAbsoluteCoordinate(Point(size.width, size.height)));
668 EINA_RECTANGLE_SET(&rect, 0, 0, absSize.x, absSize.y);
670 Evas_Object* pScreenShot = ewk_view_screenshot_contents_get(pWebFrame, rect, 1.0f, evas_object_evas_get(pWebFrame));
671 SysTryReturn(NID_WEB_CTRL, pScreenShot, null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get snapshot of Web control", GetErrorMessage(E_SYSTEM));
673 r = _Utility::GetPixelBufferFromEvasObject(pScreenShot, bufferInfo);
674 evas_object_del(pScreenShot);
675 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
677 int bufferSize = bufferInfo.bitsPerPixel * bufferInfo.width * bufferInfo.height;
678 r = buffer.Construct(reinterpret_cast < byte* >(bufferInfo.pPixels), 0, bufferSize, bufferSize);
679 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
681 std::unique_ptr<Bitmap> pBitmap(new (std::nothrow) Bitmap());
682 SysTryReturn(NID_WEB_CTRL, pBitmap.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
684 r = pBitmap->Construct(buffer, Dimension(bufferInfo.width, bufferInfo.height), BITMAP_PIXEL_FORMAT_ARGB8888);
685 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
687 return pBitmap.release();
692 _Web::DumpPointList(void* pData)
694 Eina_List* pList = reinterpret_cast< Eina_List* >(pData);
696 for(; pList; pList = eina_list_next(pList))
698 Ewk_Touch_Point* pPointDump = static_cast<Ewk_Touch_Point*>(eina_list_data_get(pList));
699 SysLog(NID_WEB_CTRL, "The current value of id is %lu, x is %d, y is %d, state is %d", pPointDump->id, pPointDump->x, pPointDump->y, pPointDump->state);
705 _Web::SendTouchEventForJavaScript(const _TouchInfo& touchInfo)
707 result r = E_SUCCESS;
709 Eina_List* pPointList = null;
710 Ewk_Touch_Point* pPoint = null;
712 _TouchManager* pTouchManager = _TouchManager::GetInstance();
713 SysAssertf(pTouchManager, "Failed to get touch manager.");
715 std::unique_ptr<IListT<_FingerInfo*> > pTouchList(pTouchManager->GetMultiFingerInfoListN());
716 SysTryReturnVoidResult(NID_WEB_CTRL, pTouchList.get(), GetLastResult(), "[%s] Failed to get touch list.", GetErrorMessage(GetLastResult()));
718 std::unique_ptr<IBidirectionalEnumeratorT<_FingerInfo*> > pTouchListEnum(pTouchList->GetBidirectionalEnumeratorN());
719 SysAssertf(pTouchListEnum.get() != null, "Failed to get enumerator of touch list.");
721 FloatPoint currentPoint;
722 _FingerInfo* pFingerInfo = null;
723 while(pTouchListEnum->MoveNext() == E_SUCCESS)
725 r = pTouchListEnum->GetCurrent(pFingerInfo);
726 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
728 _TouchStatus state = pFingerInfo->GetStatus();
729 if(state == _TOUCH_PRESSED || state == _TOUCH_MOVED || state == _TOUCH_RELEASED || state == _TOUCH_CANCELED)
731 currentPoint = GetAbsoluteCoordinate(pFingerInfo->GetPoint());
732 Point integerPoint(_CoordinateSystemUtils::ConvertToInteger(currentPoint));
734 pPoint = static_cast<Ewk_Touch_Point*>(calloc(1, sizeof(Ewk_Touch_Point)));
736 pPoint->id = pFingerInfo->GetPointId();
737 pPoint->x = integerPoint.x;
738 pPoint->y = integerPoint.y;
739 pPoint->state = GetEvasTouchState((TouchStatus)pFingerInfo->GetStatus());
741 pPointList = eina_list_append(pPointList, pPoint);
744 DumpPointList(pPointList);
746 Eina_Bool ret = ewk_view_feed_touch_event(__pEflWebkit->GetWebEvasObject(), GetEwkTouchEvent(touchInfo.GetTouchStatus()), pPointList, null);
747 SysTryReturnVoidResult(NID_WEB_CTRL, ret == EINA_TRUE, E_SYSTEM, "[%s] A system error has been occurred. Failed to deliver touch event to javascript.", GetErrorMessage(E_SYSTEM));
751 EINA_LIST_FREE(pPointList, pData)
757 _Web::GetEwkTouchEvent(_TouchStatus touchStatus)
759 Ewk_Touch_Event_Type ewkTouchEvent = EWK_TOUCH_CANCEL;
763 case _TOUCH_PRESSED :
764 ewkTouchEvent = EWK_TOUCH_START;
767 ewkTouchEvent = EWK_TOUCH_MOVE;
769 case _TOUCH_RELEASED :
770 ewkTouchEvent = EWK_TOUCH_END;
772 case _TOUCH_CANCELED :
775 ewkTouchEvent = EWK_TOUCH_CANCEL;
779 return ewkTouchEvent;
783 Evas_Touch_Point_State
784 _Web::GetEvasTouchState(TouchStatus touchStatus)
786 Evas_Touch_Point_State evasTouchState = EVAS_TOUCH_POINT_CANCEL;
791 evasTouchState = EVAS_TOUCH_POINT_DOWN;
794 evasTouchState = EVAS_TOUCH_POINT_MOVE;
796 case TOUCH_RELEASED :
797 evasTouchState = EVAS_TOUCH_POINT_UP;
799 case TOUCH_CANCELED :
802 evasTouchState = EVAS_TOUCH_POINT_CANCEL;
803 //todo : mapping EVAS_TOUCH_POINT_STILL, /**< Touch point is not moved af
807 return evasTouchState;
811 }}} // Tizen::Web::Controls