From: Seongjun Yim Date: Sat, 4 May 2013 08:40:29 +0000 (+0900) Subject: fix scroll bug when web control is added on scollable control X-Git-Tag: submit/tizen_2.1/20130514.054703~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dd4e1ecc7b040dbc44f77e1e61c1269b075393a4;p=framework%2Fosp%2Fweb.git fix scroll bug when web control is added on scollable control Change-Id: I40878f47ca6665ffc78b7f22c11aaa58f653e913 Signed-off-by: Seongjun Yim --- diff --git a/src/controls/FWebCtrl_Web.cpp b/src/controls/FWebCtrl_Web.cpp index fd43053..5e628f9 100755 --- a/src/controls/FWebCtrl_Web.cpp +++ b/src/controls/FWebCtrl_Web.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include "FWebCtrl_EflWebkit.h" #include "FWebCtrl_GestureState.h" @@ -120,6 +121,46 @@ namespace Tizen { namespace Web { namespace Controls static const char WEB_CTRL[] = "webcontrol"; +void +OnEdgeLeft(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _Web* pCore = reinterpret_cast< _Web* >(pUserData); + SysAssertf(pCore, "Failed to request"); + + pCore->SetEdgeReachedEvent(WEB_EDGE_LEFT); +} + + +void +OnEdgeRight(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _Web* pCore = reinterpret_cast< _Web* >(pUserData); + SysAssertf(pCore, "Failed to request"); + + pCore->SetEdgeReachedEvent(WEB_EDGE_RIGHT); +} + + +void +OnEdgeTop(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _Web* pCore = reinterpret_cast< _Web* >(pUserData); + SysAssertf(pCore, "Failed to request"); + + pCore->SetEdgeReachedEvent(WEB_EDGE_TOP); +} + + +void +OnEdgeBottom(void* pUserData, Evas_Object* pView, void* pEventInfo) +{ + _Web* pCore = reinterpret_cast< _Web* >(pUserData); + SysAssertf(pCore, "Failed to request"); + + pCore->SetEdgeReachedEvent(WEB_EDGE_BOTTOM); +} + + _Web::_Web(void) : __pGestureHandler(null) , __pEflWebkit(null) @@ -134,7 +175,9 @@ _Web::_Web(void) , __pFlickGestureHandler(null) , __pPinchGestureHandler(null) , __gestureType(WEB_GESTURE_TYPE_TAP) + , __edgeType(WEB_EDGE_NONE) , __pTextElement(null) + , __previousTouchedPosition(0.0f, 0.0f) { SetBackgroundColor(Color(0, 0, 0, 0)); } @@ -184,6 +227,11 @@ _Web::CreateWebkitEvasObject(void) __pEflWebkit = std::move(pEflWebkit); + evas_object_smart_callback_add(__pEflWebkit->GetWebEvasObject(), "edge,left", OnEdgeLeft, this); + evas_object_smart_callback_add(__pEflWebkit->GetWebEvasObject(), "edge,right", OnEdgeRight, this); + evas_object_smart_callback_add(__pEflWebkit->GetWebEvasObject(), "edge,top", OnEdgeTop, this); + evas_object_smart_callback_add(__pEflWebkit->GetWebEvasObject(), "edge,bottom", OnEdgeBottom, this); + return E_SUCCESS; } @@ -288,6 +336,14 @@ _Web::RemoveGestureListener(void) __pGesturePinch->RemoveGestureListener(*this); RemoveGestureDetector(*__pGesturePinch); } + + if (__pEflWebkit->GetWebEvasObject()) + { + evas_object_smart_callback_del(__pEflWebkit->GetWebEvasObject(), "edge,left", OnEdgeLeft); + evas_object_smart_callback_del(__pEflWebkit->GetWebEvasObject(), "edge,right", OnEdgeRight); + evas_object_smart_callback_del(__pEflWebkit->GetWebEvasObject(), "edge,top", OnEdgeTop); + evas_object_smart_callback_del(__pEflWebkit->GetWebEvasObject(), "edge,bottom", OnEdgeBottom); + } } @@ -431,17 +487,49 @@ _Web::ChangeGesture(_WebGestureType type) } +void +_Web::SetEdgeReachedEvent(_WebEdgeType type) +{ + __edgeType |= type; + + switch(type) + { + case WEB_EDGE_LEFT: + __edgeType &= ~WEB_EDGE_RIGHT; + break; + + case WEB_EDGE_RIGHT: + __edgeType &= ~WEB_EDGE_LEFT; + break; + + case WEB_EDGE_TOP: + __edgeType &= ~WEB_EDGE_BOTTOM; + break; + + case WEB_EDGE_BOTTOM: + __edgeType &= ~WEB_EDGE_TOP; + break; + + default: + SysAssert(false); + } +} + + bool _Web::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) { if (__pEflWebkit.get()) { + __edgeType = WEB_EDGE_NONE; + __previousTouchedPosition = touchInfo.GetCurrentPosition(); + SendTouchEventForJavaScript(touchInfo); return __pGestureHandler->OnTouchPressed(source, touchInfo); } - return true; + return false; } @@ -452,10 +540,78 @@ _Web::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) { SendTouchEventForJavaScript(touchInfo); - return __pGestureHandler->OnTouchMoved(source, touchInfo); + __pGestureHandler->OnTouchMoved(source, touchInfo); + + float scrollDistanceX = __previousTouchedPosition.x - touchInfo.GetCurrentPosition().x; + float scrollDistanceY = __previousTouchedPosition.y - touchInfo.GetCurrentPosition().y; + __previousTouchedPosition = touchInfo.GetCurrentPosition(); + + if (__edgeType != WEB_EDGE_NONE && __gestureType == WEB_GESTURE_TYPE_PANNING) + { + if (_Abs(scrollDistanceY) < _Abs(scrollDistanceX)) + { + if (__edgeType & WEB_EDGE_LEFT) + { + if (scrollDistanceX < 0) + { + __edgeType &= ~WEB_EDGE_RIGHT; + + return false; + } + else + { + __edgeType &= ~WEB_EDGE_LEFT; + } + } + else if (__edgeType & WEB_EDGE_RIGHT) + { + if (scrollDistanceX > 0) + { + __edgeType &= ~WEB_EDGE_LEFT; + + return false; + } + else + { + __edgeType &= ~WEB_EDGE_RIGHT; + } + } + } + else if (_Abs(scrollDistanceY) > _Abs(scrollDistanceX)) + { + if (__edgeType & WEB_EDGE_TOP) + { + if (scrollDistanceY < 0) + { + __edgeType &= ~WEB_EDGE_BOTTOM; + + return false; + } + else + { + __edgeType &= ~WEB_EDGE_TOP; + } + } + else if (__edgeType & WEB_EDGE_BOTTOM) + { + if (scrollDistanceY > 0) + { + __edgeType &= ~WEB_EDGE_TOP; + + return false; + } + else + { + __edgeType &= ~WEB_EDGE_BOTTOM; + } + } + } + } + + return true; } - return true; + return false; } @@ -471,7 +627,7 @@ _Web::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo) return __pGestureHandler->OnTouchReleased(source, touchInfo); } - return true; + return false; } @@ -482,10 +638,10 @@ _Web::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo) { SendTouchEventForJavaScript(touchInfo); - __pGestureHandler->OnTouchCanceled(source, touchInfo); + return __pGestureHandler->OnTouchCanceled(source, touchInfo); } - return true; + return false; } diff --git a/src/controls/FWebCtrl_Web.h b/src/controls/FWebCtrl_Web.h index 23d118f..867de7d 100755 --- a/src/controls/FWebCtrl_Web.h +++ b/src/controls/FWebCtrl_Web.h @@ -70,6 +70,15 @@ enum _WebGestureType WEB_GESTURE_TYPE_PINCH }; +enum _WebEdgeType +{ + WEB_EDGE_NONE = 1, + WEB_EDGE_LEFT = 1 << 1, + WEB_EDGE_RIGHT = 1 << 2, + WEB_EDGE_TOP = 1 << 3, + WEB_EDGE_BOTTOM = 1 << 4, +}; + class _Web : public Tizen::Ui::_Control , Tizen::Ui::_ITouchFlickGestureEventListener @@ -102,6 +111,8 @@ public: WebSetting* GetSetting(void) const; + void SetEdgeReachedEvent(_WebEdgeType type); + virtual result OnAttaching(const _Control* pParent); virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); @@ -178,7 +189,11 @@ private: _WebGestureType __gestureType; + int __edgeType; + Tizen::Ui::_AccessibilityElement* __pTextElement; + + Tizen::Graphics::FloatPoint __previousTouchedPosition; }; // _Web }}} // Tizen::Web::Controls