#include <EWebKit2.h>
#include <FBaseSysLog.h>
#include <FGrpPoint.h>
+#include <FUi_CoordinateSystemUtils.h>
#include <FUi_Control.h>
#include <FUi_TouchManager.h>
#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
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;
}
-_TapGestureState::_TapGestureState(_Web* pWeb, _PinchGestureState* pPinchListener)
+_TapGestureState::_TapGestureState(_Web* pWeb)
: __pWebCore(pWeb)
- , __pPinchListener(pPinchListener)
, __longPressed(false)
+ , __doubleTapped(false)
+ , __pressedPosition(0.0f, 0.0f)
{
}
_TapGestureState::~_TapGestureState(void)
{
}
+
-
-void
-_TapGestureState::OnLongPressGestureDetected(const _TouchLongPressGestureDetector& gesture)
+bool
+_TapGestureState::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
{
- __longPressed = true;
+ //To disable focus ring
+ Ewk_Event_Gesture gestureEvent;
- const Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get( __pWebCore->GetWebNativeNode()));
+ SetGestureEvent(gestureEvent, EWK_GESTURE_LONG_PRESS, 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_move(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
- Ewk_Event_Gesture gestureEvent;
+ __longPressed = true;
- 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;
}
bool
-_TapGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
+_TapGestureState::OnTapGestureDetected(_TouchTapGestureDetector& gesture)
{
- 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;
-
- 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(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(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 = __pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition());
-
- 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);
- }
+ __doubleTapped = true;
return true;
}
bool
-_TapGestureState::OnTouchMoved(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)));
- Point absPoint = __pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition());
+ SetGestureEvent(gestureEvent, EWK_GESTURE_TAP, absPoint, Point(0, 0), 0.0, 1);
- SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0, 0);
- pSmartData->api->gesture_start(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
+ 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);
- __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_PANNING);
+ __longPressed = false;
+ __doubleTapped = false;
return true;
}
bool
-_TapGestureState::OnTouchReleased(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())));
- if (!__longPressed)
- {
- Ewk_Event_Gesture gestureEvent;
+ SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0.0, 0);
- Point absPoint = __pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition());
+ 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);
- SetGestureEvent(gestureEvent, EWK_GESTURE_TAP, absPoint, Point(0, 0), 0, 1);
- pSmartData->api->gesture_end(const_cast<Ewk_View_Smart_Data*>(pSmartData), &gestureEvent);
+ __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_PANNING);
+
+ if (!_WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled())
+ {
+ return false;
}
return true;
bool
-_TapGestureState::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
+_TapGestureState::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.");
+ if (!__pWebCore->Contains(__pressedPosition))
+ {
+ return OnTouchCanceled(source, touchInfo);
+ }
+
+ Evas_Object* pView = __pWebCore->GetWebNativeNode();
+ Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(__pressedPosition)));
- Ewk_Event_Gesture gestureEvent;
+ 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.");
- 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);
+ String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
- return true;
-}
+ 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;
-_DoubleTapGestureState::_DoubleTapGestureState(_Web* pWeb)
- : __pWebCore(pWeb)
-{
-}
+ 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(pView));
+ 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;
+ }
-_DoubleTapGestureState::~_DoubleTapGestureState(void)
-{
-}
+ 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(pView));
+ SysAssertf(pSmartData, "Failed to get webkit smart data.");
+ pSmartData->api->gesture_end(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
+ }
-bool
-_DoubleTapGestureState::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
-{
return true;
}
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 = __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);
-
- __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_TAP);
+ SetGestureEvent(gestureEvent, EWK_GESTURE_LONG_PRESS, Point(0, 0), Point(0, 0), 0.0, 0);
- return true;
-}
-
-
-bool
-_DoubleTapGestureState::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
-{
- __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;
}
-_PanningGestureState::_PanningGestureState(_Web* pWeb, _PinchGestureState* pPinchListener)
+_PanningGestureState::_PanningGestureState(_Web* pWeb)
: __pWebCore(pWeb)
- , __pPinchListener(pPinchListener)
{
}
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(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(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;
}
bool
_PanningGestureState::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
{
- if (__pWebCore->GetWebSettingImpl()->IsScrollEnabled())
+ 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.");
+ return false;
+ }
- Ewk_Event_Gesture gestureEvent;
+ Ewk_Event_Gesture gestureEvent;
+ Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition())));
- Point absPoint = __pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition());
+ SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0.0, 0);
- SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0, 0);
- pSmartData->api->gesture_move(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_move(const_cast< Ewk_View_Smart_Data* >(pSmartData), &gestureEvent);
return true;
}
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())));
- Point absPoint = __pWebCore->GetAbsoluteCoordinate(touchInfo.GetCurrentPosition());
+ SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, absPoint, Point(0, 0), 0.0, 0);
- SetGestureEvent(gestureEvent, EWK_GESTURE_PAN, 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);
}
-void
-_FlickGestureState::OnFlickGestureDetected(const _TouchFlickGestureDetector& gesture)
+bool
+_FlickGestureState::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
{
- int duration = gesture.GetDuration();
- gesture.GetDistance(__velocity.x, __velocity.y);
+ __pWebCore->ChangeGesture(WEB_GESTURE_TYPE_FLICK);
+
+ if (_WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled())
+ {
+ 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;
+ __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 = __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;
}
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;
+ if (_WebSettingImpl::GetInstance(__pWebCore->GetSetting())->IsScrollEnabled())
+ {
+ SetGestureEvent(gestureEvent, EWK_GESTURE_FLICK, absPoint, __velocity, 0.0, 0);
- Point absPoint = __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;
}
_PinchGestureState::_PinchGestureState(_Web* pWeb)
: __pWebCore(pWeb)
+ , __standardScale(0.0)
{
}
{
}
-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;
+}
- return center;
+
+bool
+_PinchGestureState::OnPinchGestureFinished(_TouchPinchGestureDetector& gesture)
+{
+ Ewk_Event_Gesture gestureEvent;
+
+ 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;
}
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(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(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;
}
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 = __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);
}
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 = __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);