add patch
[framework/osp/web.git] / src / controls / FWebCtrl_GestureState.cpp
index b0b9924..93419bd 100755 (executable)
 #include <FUi_UiTouchEvent.h>
 #include "FWebCtrl_GestureState.h"
 #include "FWebCtrl_Web.h"
+#include "FWebCtrl_WebImpl.h"
 #include "FWebCtrl_WebSettingImpl.h"
 
 
 using namespace Tizen::Base;
 using namespace Tizen::Graphics;
 using namespace Tizen::Ui;
+using namespace Tizen::Web::Controls;
 
 
 namespace Tizen { namespace Web { namespace Controls
@@ -51,8 +53,6 @@ static const double PINCH_ZOOM_DISTANCE_TOLERANCE = 40.0;
 void
 SetGestureEvent(Ewk_Event_Gesture& gestureEvent, Ewk_Gesture_Type gestureType, const Point& absPoint, const Point& velocity, double scale, int count)
 {
-       memset(&gestureEvent, 0, sizeof(gestureEvent));
-
        gestureEvent.type = gestureType;
        gestureEvent.position.x = absPoint.x;
        gestureEvent.position.y = absPoint.y;
@@ -64,10 +64,11 @@ SetGestureEvent(Ewk_Event_Gesture& gestureEvent, Ewk_Gesture_Type gestureType, c
 }
 
 
-_TapGestureState::_TapGestureState(_Web* pWeb,  _PinchGestureState* pPinchListener)
+_TapGestureState::_TapGestureState(_Web* pWeb)
        : __pWebCore(pWeb)
-       , __pPinchListener(pPinchListener)
        , __longPressed(false)
+       , __doubleTapped(false)
+       , __pressedPosition(0.0f, 0.0f)
 {
 }
 
@@ -75,262 +76,208 @@ _TapGestureState::_TapGestureState(_Web* pWeb,  _PinchGestureState* pPinchListen
 _TapGestureState::~_TapGestureState(void)
 {
 }
+       
 
-
-void
-_TapGestureState::OnLongPressGestureDetected(const _TouchLongPressGestureDetector& gesture)
+bool
+_TapGestureState::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
 {
-       __longPressed = true;
-
-       const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get( __pWebCore->GetWebNativeNode()));
-       SysAssertf(pSmartData, "Failed to get webkit smart data.");
-
+       //To disable focus ring
        Ewk_Event_Gesture gestureEvent;
 
-       SetGestureEvent(gestureEvent, EWK_GESTURE_LONG_PRESS, Point(0, 0), Point(0, 0), 0, 0);
-       pSmartData->api->gesture_move(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
-}
-
+       SetGestureEvent(gestureEvent, EWK_GESTURE_LONG_PRESS, Point(0, 0), Point(0, 0), 0.0, 0);
 
-bool
-_TapGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
-{
-       const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get( __pWebCore->GetWebNativeNode()));
+       const Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(__pWebCore->GetWebNativeNode()));
        SysAssertf(pSmartData, "Failed to get webkit smart data.");
+       pSmartData->api->gesture_move(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
 
+       //To delete magnifier
        _TouchManager* pTouchManager = _TouchManager::GetInstance();
-       SysAssertf(pTouchManager, "Failed to get webkit smart data.");
-
-       if (pTouchManager->GetPointCount() == 2)
-       {
-               result r = E_SUCCESS;
-
-               std::unique_ptr<Tizen::Base::Collection::IListT<_FingerInfo*> > pTouchList(pTouchManager->GetMultiFingerInfoListN());
-               SysTryReturn(NID_WEB_CTRL, pTouchList.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       SysAssertf(pTouchManager, "Failed to get touch manager.");
 
-               std::unique_ptr<Tizen::Base::Collection::IBidirectionalEnumeratorT<_FingerInfo*> > pEnum(pTouchList->GetBidirectionalEnumeratorN());
-               SysTryReturn(NID_WEB_CTRL, pEnum.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       Point absPoint(_CoordinateSystemUtils::ConvertToInteger(pTouchManager->GetPosition(pTouchManager->GetCurrentPointId())));
 
-               _FingerInfo* pFingerInfo = null;
+       Ewk_Touch_Point* pPoint = static_cast< Ewk_Touch_Point* >(calloc(1, sizeof(Ewk_Touch_Point)));
+       pPoint->id = 0;
+       pPoint->x = absPoint.x;
+       pPoint->y = absPoint.y;
+       pPoint->state = EVAS_TOUCH_POINT_CANCEL;
 
-               r = pEnum->MoveNext();
-               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       Eina_List* pPointList = null;
+       pPointList = eina_list_append(pPointList, pPoint);
 
-               r = pEnum->GetCurrent(pFingerInfo);
-               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+       ewk_view_feed_touch_event(__pWebCore->GetWebNativeNode(), EWK_TOUCH_CANCEL, pPointList, null);
 
-               Point firstFinger(_CoordinateSystemUtils::ConvertToInteger(pFingerInfo->GetPoint()));
-
-               r = pEnum->MoveNext();
-               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
-
-               r = pEnum->GetCurrent(pFingerInfo);
-               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
-
-               Point secondFinger(_CoordinateSystemUtils::ConvertToInteger(pFingerInfo->GetPoint()));
-
-               __pPinchListener->InitializeFactor();
-
-               double zoomFactor = __pPinchListener->GetZoomFactor(firstFinger, secondFinger);
-               Point center(__pPinchListener->GetCenterPoint(firstFinger, secondFinger));
-
-               Point absPoint = __pWebCore->GetAbsoluteCoordinate(center);
-
-               Ewk_Event_Gesture gestureEvent;
-
-               SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), zoomFactor, 0);
-               pSmartData->api->gesture_start(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
-
-               __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_PINCH);      
-       }
-       else
-       {
-               __longPressed = false;
-
-               Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition())));
+       void* pData = null;
+       EINA_LIST_FREE(pPointList, pData)
+       free(pData);
 
-               Ewk_Event_Gesture gestureEvent;
-
-               SetGestureEvent(gestureEvent, EWK_GESTURE_TAP, absPoint, Point(0, 0), 0, 1);
-               pSmartData->api->gesture_start(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
-       }
+       __longPressed = true;
 
        return true;
 }
 
 
 bool
-_TapGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
+_TapGestureState::OnTapGestureDetected(_TouchTapGestureDetector& gesture)
 {
-       if (__pWebCore->GetWebSettingImpl()->IsScrollEnabled())
-       {
-               const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get( __pWebCore->GetWebNativeNode()));
-               SysAssertf(pSmartData, "Failed to get webkit smart data.");
-
-               Ewk_Event_Gesture gestureEvent;
-
-               Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition())));
-
-               SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0, 0);
-               pSmartData->api->gesture_start(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
-
-               __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_PANNING);
-       }
+       __doubleTapped = true;
 
        return true;
 }
 
 
 bool
-_TapGestureState::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
+_TapGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
 {
-       const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get( __pWebCore->GetWebNativeNode()));
-       SysAssertf(pSmartData, "Failed to get webkit smart data.");
+       Ewk_Event_Gesture gestureEvent;
+       __pressedPosition = touchInfo.GetCurrentPosition();
+       Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(__pressedPosition)));
 
-       if (!__longPressed)
-       {
-               Ewk_Event_Gesture gestureEvent;
+       SetGestureEvent(gestureEvent, EWK_GESTURE_TAP, absPoint, Point(0, 0), 0.0, 1);
 
-               Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition())));
+       const Ewk_View_Smart_Data* pSmartData = static_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(__pWebCore->GetWebNativeNode()));
+       SysAssertf(pSmartData, "Failed to get webkit smart data.");
+       pSmartData->api->gesture_start(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
 
-               SetGestureEvent(gestureEvent, EWK_GESTURE_TAP, absPoint, Point(0, 0), 0, 1);
-               pSmartData->api->gesture_end(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
-       }
+       __longPressed = false;
+       __doubleTapped = false;
 
        return true;
 }
 
 
 bool
-_TapGestureState::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
+_TapGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
 {
-       const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get( __pWebCore->GetWebNativeNode()));
-       SysAssertf(pSmartData, "Failed to get webkit smart data.");
-
        Ewk_Event_Gesture gestureEvent;
+       Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition())));
 
-       SetGestureEvent(gestureEvent, EWK_GESTURE_LONG_PRESS, Point(0, 0), Point(0, 0), 0, 0);
-       pSmartData->api->gesture_move(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
-
-       return true;
-}
-
+       SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0.0, 0);
 
-_DoubleTapGestureState::_DoubleTapGestureState(_Web* pWeb)
-       : __pWebCore(pWeb)
-{
-}
+       const Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(__pWebCore->GetWebNativeNode()));
+       SysAssertf(pSmartData, "Failed to get webkit smart data.");
+       pSmartData->api->gesture_start(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
 
+       __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_PANNING);
 
-_DoubleTapGestureState::~_DoubleTapGestureState(void)
-{
+       return true;
 }
 
 
 bool
-_DoubleTapGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
+_TapGestureState::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
 {
-       return true;
-}
+       if (__pWebCore->Contains(__pressedPosition))
+       {
+               Evas_Object* pView = __pWebCore->GetWebNativeNode();
+               Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(__pressedPosition)));
+
+               if (__longPressed)
+               {
+                       Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
+                       SysTryReturn(NID_WEB_CTRL, pEwkHitTest, true, E_SYSTEM, "Failed to get hit test.");
+
+                       String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
+
+                       Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
+                       char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
+                       if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false) || pValue)
+                       {
+                               Eina_Rectangle leftHandle;
+                               Eina_Rectangle rightHandle;
+
+                               ewk_view_text_selection_range_get(pView, &leftHandle, &rightHandle);
+                               if (((rightHandle.x + rightHandle.w) == 0) && ((rightHandle.y + rightHandle.h) == 0))
+                               {
+                                       Ewk_Event_Gesture gestureEvent;
+
+                                       SetGestureEvent(gestureEvent, EWK_GESTURE_LONG_PRESS, absPoint, Point(0, 0), 0.0, 1);
+
+                                       const Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(__pWebCore->GetWebNativeNode()));
+                                       SysAssertf(pSmartData, "Failed to get webkit smart data.");
+                                       pSmartData->api->gesture_end(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
+                               }
+                       }
+               }
+               else
+               {
+                       Ewk_Event_Gesture gestureEvent;
+                       int touchCount = 1;
+                       if (__doubleTapped)
+                       {
+                               touchCount = 2;
+                       }
+
+                       SetGestureEvent(gestureEvent, EWK_GESTURE_TAP, absPoint, Point(0, 0), 0.0, touchCount);
+
+                       const Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(__pWebCore->GetWebNativeNode()));
+                       SysAssertf(pSmartData, "Failed to get webkit smart data.");
+                       pSmartData->api->gesture_end(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
+               }
 
+               String selectedText(ewk_view_text_selection_text_get(pView));
+               if (selectedText.GetLength() > 0)
+               {
+                       evas_object_smart_callback_call(pView, "text,selected", NULL);
+               }
+       }
+       else
+       {
+               OnTouchCanceled(source, touchInfo);
+       }
 
-bool
-_DoubleTapGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
-{
        return true;
 }
 
 
 bool
-_DoubleTapGestureState::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
+_TapGestureState::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
 {
-       const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get( __pWebCore->GetWebNativeNode()));
-       SysAssertf(pSmartData, "Failed to get webkit smart data.");
-
        Ewk_Event_Gesture gestureEvent;
 
-       Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition())));
-
-       SetGestureEvent(gestureEvent, EWK_GESTURE_TAP, absPoint, Point(0, 0), 0, 2);
-       pSmartData->api->gesture_start(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
-       pSmartData->api->gesture_end(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
+       SetGestureEvent(gestureEvent, EWK_GESTURE_LONG_PRESS, Point(0, 0), Point(0, 0), 0.0, 0);
 
-       __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP);
+       const Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(__pWebCore->GetWebNativeNode()));
+       SysAssertf(pSmartData, "Failed to get webkit smart data.");
+       pSmartData->api->gesture_move(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
 
        return true;
 }
 
 
-bool
-_DoubleTapGestureState::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
+_PanningGestureState::_PanningGestureState(_Web* pWeb)
+       : __pWebCore(pWeb)
+       , __textSelected(false)
+       , __textChanged(false)
+       , __selectedText(L"")
 {
-       __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP);
-
-       return true;
 }
 
 
-_PanningGestureState::_PanningGestureState(_Web* pWeb, _PinchGestureState* pPinchListener)
-       : __pWebCore(pWeb)
-       , __pPinchListener(pPinchListener)
+_PanningGestureState::~_PanningGestureState(void)
 {
 }
 
 
-_PanningGestureState::~_PanningGestureState(void)
+void
+_PanningGestureState::InitializeTextSelectionStatus(void)
 {
+       __selectedText = String(ewk_view_text_selection_text_get(__pWebCore->GetWebNativeNode()));
+       if (__selectedText.GetLength() > 0)
+       {
+               __textSelected = true;
+       }
+       else
+       {
+               __textSelected = false;
+       }
+       __textChanged = false;
 }
 
 
 bool
 _PanningGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
 {
-       result r = E_SUCCESS;
-
-       const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get( __pWebCore->GetWebNativeNode()));
-       SysAssertf(pSmartData, "Failed to get webkit smart data.");
-
-       _TouchManager* pTouchManager = _TouchManager::GetInstance();
-       SysAssertf(pTouchManager, "Failed to get webkit smart data.");
-
-       std::unique_ptr<Tizen::Base::Collection::IListT<_FingerInfo*> > pTouchList(pTouchManager->GetMultiFingerInfoListN());
-       SysTryReturn(NID_WEB_CTRL, pTouchList.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
-       std::unique_ptr<Tizen::Base::Collection::IBidirectionalEnumeratorT<_FingerInfo*> > pEnum(pTouchList->GetBidirectionalEnumeratorN());
-       SysTryReturn(NID_WEB_CTRL, pEnum.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
-       _FingerInfo* pFingerInfo = null;
-
-       r = pEnum->MoveNext();
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       r = pEnum->GetCurrent(pFingerInfo);
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       Point firstFinger(_CoordinateSystemUtils::ConvertToInteger(pFingerInfo->GetPoint()));
-
-       r = pEnum->MoveNext();
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       r = pEnum->GetCurrent(pFingerInfo);
-       SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
-
-       Point secondFinger(_CoordinateSystemUtils::ConvertToInteger(pFingerInfo->GetPoint()));
-
-       __pPinchListener->InitializeFactor();
-
-       double zoomFactor = __pPinchListener->GetZoomFactor(firstFinger, secondFinger);
-       Point center(__pPinchListener->GetCenterPoint(firstFinger, secondFinger));
-
-       Point absPoint = __pWebCore->GetAbsoluteCoordinate(center);
-
-       Ewk_Event_Gesture gestureEvent;
-
-       SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), zoomFactor, 0);
-       pSmartData->api->gesture_start(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
-
-       __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_PINCH);
-
        return true;
 }
 
@@ -338,17 +285,25 @@ _PanningGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& t
 bool
 _PanningGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
 {
-       if (__pWebCore->GetWebSettingImpl()->IsScrollEnabled())
+       Evas_Object* pView = __pWebCore->GetWebNativeNode();
+       if (_WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled())
        {
-               const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get( __pWebCore->GetWebNativeNode()));
-               SysAssertf(pSmartData, "Failed to get webkit smart data.");
-
                Ewk_Event_Gesture gestureEvent;
-
                Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition())));
 
-               SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0, 0);
-               pSmartData->api->gesture_move(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
+               SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0.0, 0);
+
+               const Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(pView));
+               SysAssertf(pSmartData, "Failed to get webkit smart data.");
+               pSmartData->api->gesture_move(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
+       }
+
+       if (__textSelected && !__textChanged)
+       {
+               if (!__selectedText.Equals(String(ewk_view_text_selection_text_get(pView))))
+               {
+                       __textChanged = true;
+               }
        }
 
        return true;
@@ -358,15 +313,20 @@ _PanningGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& tou
 bool
 _PanningGestureState::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
 {
-       const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pWebCore->GetWebNativeNode()));
-       SysAssertf(pSmartData, "Failed to get webkit smart data.");
-
        Ewk_Event_Gesture gestureEvent;
-
        Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition())));
 
-       SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0, 0);
-       pSmartData->api->gesture_end(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
+       SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0.0, 0);
+
+       Evas_Object* pView = __pWebCore->GetWebNativeNode();
+       const Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(pView));
+       SysAssertf(pSmartData, "Failed to get webkit smart data.");
+       pSmartData->api->gesture_end(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
+
+       if (__textChanged)
+       {
+               evas_object_smart_callback_call(pView, "text,selected", NULL);
+       }
 
        __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP);
 
@@ -393,35 +353,24 @@ _FlickGestureState::~_FlickGestureState(void)
 }
 
 
-void
-_FlickGestureState::OnFlickGestureDetected(const _TouchFlickGestureDetector& gesture)
+bool
+_FlickGestureState::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
 {
+       __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_FLICK);
+
        int duration = gesture.GetDuration();
        gesture.GetDistance(__velocity.x, __velocity.y);
 
        __velocity.x = (__velocity.x * FLICK_SCROLL_WEIGHT) / duration;
        __velocity.y = (__velocity.y * FLICK_SCROLL_WEIGHT) / duration;
+
+       return true;
 }
 
 
 bool
 _FlickGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
 {
-       const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get( __pWebCore->GetWebNativeNode()));
-       SysAssertf(pSmartData, "Failed to get webkit smart data.");
-
-       Ewk_Event_Gesture gestureEvent;
-
-       Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition())));
-
-       SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0, 0);
-       pSmartData->api->gesture_end(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
-
-       SetGestureEvent(gestureEvent, EWK_GESTURE_FLICK, absPoint, Point(0, 0), 0, 0);
-       pSmartData->api->gesture_end(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
-
-       __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP);
-
        return true;
 }
 
@@ -436,15 +385,20 @@ _FlickGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touch
 bool
 _FlickGestureState::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
 {
-       const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get( __pWebCore->GetWebNativeNode()));
+       Ewk_Event_Gesture gestureEvent;
+       Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition())));
+
+       SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0.0, 0);
+
+       const Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(__pWebCore->GetWebNativeNode()));
        SysAssertf(pSmartData, "Failed to get webkit smart data.");
+       pSmartData->api->gesture_end(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
 
-       Ewk_Event_Gesture gestureEvent;
+       SetGestureEvent(gestureEvent, EWK_GESTURE_FLICK, absPoint, __velocity, 0.0, 0);
 
-       Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition())));
+       pSmartData->api->gesture_start(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
 
-       SetGestureEvent(gestureEvent, EWK_GESTURE_FLICK, absPoint, __velocity, 0, 0);
-       pSmartData->api->gesture_start(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
+       __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP);
 
        return true;
 }
@@ -459,6 +413,7 @@ _FlickGestureState::OnTouchCanceled(const _Control& source, const _TouchInfo& to
 
 _PinchGestureState::_PinchGestureState(_Web* pWeb)
        : __pWebCore(pWeb)
+       , __standardScale(0.0)
 {
 }
 
@@ -467,73 +422,55 @@ _PinchGestureState::~_PinchGestureState(void)
 {
 }
 
-void
-_PinchGestureState::InitializeFactor(void)
-{
-       __baseDistance = 0;
-       __distanceTolerance = PINCH_ZOOM_DISTANCE_TOLERANCE;
-}
 
-double
-_PinchGestureState::GetZoomFactor(const Point& firstFinger, const Point& secondFinger)
+bool
+_PinchGestureState::OnPinchGestureStarted(_TouchPinchGestureDetector& gesture)
 {
-       int diffX = secondFinger.x - firstFinger.x;
-       int diffY = secondFinger.y - firstFinger.y;
-       int distance = static_cast < int >(sqrt((diffX * diffX) + (diffY * diffY)));
-       double relativeFactor = 1.0;
+       __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_PINCH);
 
-       if (!__baseDistance)
-       {
-               __baseDistance = distance;
-               return relativeFactor;
-       }
+       Ewk_Event_Gesture gestureEvent;
+       Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(gesture.GetCenterPointF())));
+       __standardScale = static_cast< double >(gesture.GetScaleF());
 
-       if (__distanceTolerance)
-       {
-               if (distance < (__baseDistance - __distanceTolerance))
-               {
-                       __baseDistance -= __distanceTolerance;
-                       __distanceTolerance = 0;
-               }
-               else if (distance > (__baseDistance + __distanceTolerance))
-               {
-                       __baseDistance += __distanceTolerance;
-                       __distanceTolerance= 0;
-               }
+       SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), 1.0, 0);
 
-               return relativeFactor;
-       }
-       relativeFactor = 1.0 + (((distance - __baseDistance) / static_cast < double >(__baseDistance)) * PINCH_ZOOM_FINGER_FACTOR);
+       const Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(__pWebCore->GetWebNativeNode()));
+       SysAssertf(pSmartData, "Failed to get webkit smart data.");
+       pSmartData->api->gesture_start(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
 
-       return relativeFactor;
+       return true;
 }
 
 
-Point
-_PinchGestureState::GetCenterPoint(const Point& firstFinger, const Point& secondFinger)
+bool
+_PinchGestureState::OnPinchGestureChanged(_TouchPinchGestureDetector& gesture)
 {
-       int diffX = fabs(secondFinger.x - firstFinger.x);
-       int diffY = fabs(secondFinger.y - firstFinger.y);
-       double distance = sqrt((diffX * diffX) + (diffY * diffY));
+       Ewk_Event_Gesture gestureEvent;
+       Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(gesture.GetCenterPointF())));
+       double relScale = static_cast< double >(gesture.GetScaleF()) /__standardScale;
 
-       Point center;
+       SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), relScale, 0);
 
-       if (diffX && diffY)
-       {
-               double ratio = atan((diffY / static_cast < double >(diffX)));
-               int additionalX = static_cast < int >((distance / 2) * cos(ratio));
-               int additionalY = static_cast < int >((distance / 2) * sin(ratio));
+       const Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(__pWebCore->GetWebNativeNode()));
+       SysAssertf(pSmartData, "Failed to get webkit smart data.");
+       pSmartData->api->gesture_move(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
 
-               center.x = (secondFinger.x > firstFinger.x) ? (firstFinger.x + additionalX) : (secondFinger.x + additionalX);
-               center.y = (secondFinger.y > firstFinger.y) ? (firstFinger.y + additionalY) : (secondFinger.y + additionalY);
-       }
-       else
-       {
-               center.x = (firstFinger.x + secondFinger.x) / 2;
-               center.y = (firstFinger.y + secondFinger.y) / 2;
-       }
+       return true;
+}
+
+
+bool
+_PinchGestureState::OnPinchGestureFinished(_TouchPinchGestureDetector& gesture)
+{
+       Ewk_Event_Gesture gestureEvent;
 
-       return center;
+       SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, Point(0, 0), Point(0, 0), 0.0, 0);
+
+       const Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(__pWebCore->GetWebNativeNode()));
+       SysAssertf(pSmartData, "Failed to get webkit smart data.");
+       pSmartData->api->gesture_end(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
+
+       return true;
 }
 
 
@@ -547,51 +484,6 @@ _PinchGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& tou
 bool
 _PinchGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
 {
-       const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pWebCore->GetWebNativeNode()));
-       SysAssertf(pSmartData, "Failed to get webkit smart data.");
-
-       _TouchManager* pTouchManager = _TouchManager::GetInstance();
-       SysAssertf(pTouchManager, "Failed to get webkit smart data.");
-
-       if (pTouchManager->GetPointCount() == 2)
-       {
-               result r = E_SUCCESS;
-
-               Ewk_Event_Gesture gestureEvent;
-
-               std::unique_ptr<Tizen::Base::Collection::IListT<_FingerInfo*> > pTouchList(pTouchManager->GetMultiFingerInfoListN());
-               SysTryReturn(NID_WEB_CTRL, pTouchList.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
-               std::unique_ptr<Tizen::Base::Collection::IBidirectionalEnumeratorT<_FingerInfo*> > pEnum(pTouchList->GetBidirectionalEnumeratorN());
-               SysTryReturn(NID_WEB_CTRL, pEnum.get(), false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
-               _FingerInfo* pFingerInfo = null;
-
-               r = pEnum->MoveNext();
-               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
-
-               r = pEnum->GetCurrent(pFingerInfo);
-               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
-
-               Point firstFinger(_CoordinateSystemUtils::ConvertToInteger(pFingerInfo->GetPoint()));
-
-               r = pEnum->MoveNext();
-               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
-
-               r = pEnum->GetCurrent(pFingerInfo);
-               SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
-
-               Point secondFinger(_CoordinateSystemUtils::ConvertToInteger(pFingerInfo->GetPoint()));
-
-               double zoomFactor = GetZoomFactor(firstFinger, secondFinger);
-               Point center(GetCenterPoint(firstFinger, secondFinger));
-
-               Point absPoint = __pWebCore->GetAbsoluteCoordinate(center);
-
-               SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), zoomFactor, 0); 
-               pSmartData->api->gesture_move(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
-       }
-
        return true;
 }
 
@@ -599,21 +491,10 @@ _PinchGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touch
 bool
 _PinchGestureState::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
 {
-       const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get( __pWebCore->GetWebNativeNode()));
-       SysAssertf(pSmartData, "Failed to get webkit smart data.");
-
        _TouchManager* pTouchManager = _TouchManager::GetInstance();
-       SysAssertf(pTouchManager, "Failed to get webkit smart data.");
-
-       if (pTouchManager->GetPointCount() == 1)
+       SysAssertf(pTouchManager, "Failed to get touch manager.");
+       if(pTouchManager->GetPointCount() == 0)
        {
-               Ewk_Event_Gesture gestureEvent;
-
-               Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition())));
-
-               SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), 0, 0);
-               pSmartData->api->gesture_end(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
-
                __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP);
        }
 
@@ -624,15 +505,13 @@ _PinchGestureState::OnTouchReleased(const _Control& source, const _TouchInfo& to
 bool
 _PinchGestureState::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
 {
-       const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get( __pWebCore->GetWebNativeNode()));
-       SysAssertf(pSmartData, "Failed to get webkit smart data.");
-
        Ewk_Event_Gesture gestureEvent;
 
-       Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition())));
+       SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, Point(0, 0), Point(0, 0), 0.0, 0);
 
-       SetGestureEvent(gestureEvent, EWK_GESTURE_PINCH, absPoint, Point(0, 0), 0, 0);
-       pSmartData->api->gesture_end(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
+       const Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(__pWebCore->GetWebNativeNode()));
+       SysAssertf(pSmartData, "Failed to get webkit smart data.");
+       pSmartData->api->gesture_end(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
 
        __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP);