From: hyun lee Date: Tue, 3 Sep 2013 14:53:31 +0000 (+0900) Subject: Fix for bug about keypad and text selection X-Git-Tag: submit/tizen_2.2/20131107.062229~38 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0a5fb8a6db2d0688a99f743ab4dbffac6e281ace;p=framework%2Fosp%2Fweb.git Fix for bug about keypad and text selection Change-Id: I4c203abd98b8859682b00a64f2680052e25737ce Signed-off-by: hyun lee --- diff --git a/src/controls/FWebCtrl_Web.cpp b/src/controls/FWebCtrl_Web.cpp index 0d96d70..b074756 100755 --- a/src/controls/FWebCtrl_Web.cpp +++ b/src/controls/FWebCtrl_Web.cpp @@ -719,8 +719,6 @@ _Web::SetEdgeReachedEvent(_WebEdgeType type) bool _Web::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) { - evas_object_focus_set(GetWebNativeNode(), EINA_TRUE); - if (__pEflWebkit.get()) { __edgeType = WEB_EDGE_NONE; diff --git a/src/controls/FWebCtrl_WebImpl.cpp b/src/controls/FWebCtrl_WebImpl.cpp index c05946e..b8377c6 100755 --- a/src/controls/FWebCtrl_WebImpl.cpp +++ b/src/controls/FWebCtrl_WebImpl.cpp @@ -1624,11 +1624,6 @@ OnWebKeypadStateChanged(void* pUserData, Evas_Object* pView, void* pEventInfo) Eina_Rectangle* pEinaRect = reinterpret_cast< Eina_Rectangle* >(pEventInfo); SysAssertf(pImpl && pEinaRect, "Failed to request"); - if (pImpl->IsVisible() == false) - { - evas_object_focus_set(pView, EINA_FALSE); - } - if (pImpl->GetSetting().GetInputStyle() == INPUT_STYLE_OVERLAY) { _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); @@ -1720,18 +1715,46 @@ OnWebKeypadClosed(void* pUserData, Evas_Object* pView, void* pEventInfo) void +OnWindowObjectFocusLost(void* pUserData, Evas_Object* pWin, void* pEvent_info) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + + pImpl->SetWinFocusLost(true); +} + + +void OnWindowObjectFocusGained(void* pUserData, Evas_Object* pWin, void* pEvent_info) { _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); SysAssertf(pImpl, "Failed to request"); - if (pImpl->IsKeypadOpened() == true && pImpl->IsVisible() == true && pImpl->IsFocused() == true) + if (pImpl->IsVisible() == true && pImpl->IsFocused() == true) { _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); SysAssertf(pWebCore, "Failed to get Web core object"); - evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE); + if (pImpl->IsWinFocusLost() == true) + { + if (pImpl->IsKeypadOpened() == true) + { + evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE); + } + + Ewk_Settings* pSettings = ewk_view_settings_get(pWebCore->GetWebNativeNode()); + SysAssertf(pSettings, "Failed to get settings instance."); + + if (ewk_settings_clear_text_selection_automatically_get(pSettings) == EINA_FALSE) + { + ewk_settings_clear_text_selection_automatically_set(pSettings, EINA_TRUE); + + evas_object_focus_set(pWebCore->GetWebNativeNode(), EINA_TRUE); + } + } } + + pImpl->SetWinFocusLost(false); } @@ -1745,6 +1768,25 @@ OnWebNativeNodeFocusGained(void* pUserData, Evas* pCanvas, Evas_Object* pView, v { pImpl->SetKeypadOpened(false); } +} + + +void +OnWebNativeNodeFocusLost(void* pUserData, Evas* pCanvas, Evas_Object* pView, void* pEventInfo) +{ + _WebImpl* pImpl = reinterpret_cast< _WebImpl* >(pUserData); + SysAssertf(pImpl, "Failed to request"); + + if (pImpl->IsWinFocusLost() == true) + { + _Web* pWebCore = dynamic_cast< _Web* >(&(pImpl->GetCore())); + SysAssertf(pWebCore, "Failed to get Web core object"); + + Ewk_Settings* pSettings = ewk_view_settings_get(pWebCore->GetWebNativeNode()); + SysAssertf(pSettings, "Failed to get settings instance."); + + ewk_settings_clear_text_selection_automatically_set(pSettings, EINA_FALSE); + } } @@ -2094,6 +2136,7 @@ _WebImpl::_WebImpl(Web* pWeb, Tizen::Ui::_Control* pCore) , __isFooterVisible(false) , __isKeypadVisible(false) , __isKeypadOpened(false) + , __isWinFocusLost(false) , __isLoadingErrorOccurred(false) , __isRedirectRequested(false) , __isCertificateRequested(false) @@ -2767,10 +2810,6 @@ _WebImpl::SynchronizeSearch(_SearchType type, Evas_Object* pView, Ewk_Find_Optio std::unique_ptr pText(_StringConverter::CopyToCharArrayN(text)); SysTryReturn(NID_WEB_CTRL, pText.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - Ewk_Settings* pSettings = ewk_view_settings_get(__pWebCore->GetWebNativeNode()); - SysAssertf(pSettings, "Failed to get webkit instance."); - ewk_settings_clear_text_selection_automatically_set(pSettings, true); - switch (type) { case SEARCH_SYNC: @@ -3510,6 +3549,7 @@ _WebImpl::SetEventListenerCallback(void) const evas_object_smart_callback_add(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest, this); evas_object_smart_callback_add(pWinObject, "focus,in", OnWindowObjectFocusGained, this); + evas_object_smart_callback_add(pWinObject, "focus,out", OnWindowObjectFocusLost, this); evas_object_smart_callback_add(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged, this); evas_object_smart_callback_add(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened, this); @@ -3565,6 +3605,7 @@ _WebImpl::SetEventListenerCallback(void) const ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, OnLocalFileSystemQuotaExceeded, const_cast< _WebImpl* >(this)); evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained, this); + evas_object_event_callback_add(pWebNativeNode, EVAS_CALLBACK_FOCUS_OUT, OnWebNativeNodeFocusLost, this); } } @@ -3596,6 +3637,7 @@ _WebImpl::RemoveEventListenerCallback(void) const evas_object_smart_callback_del(pWebNativeNode, "requestToNative,json", OnHandleJavaScriptRequest); evas_object_smart_callback_del_full(pWinObject, "focus,in", OnWindowObjectFocusGained, this); + evas_object_smart_callback_del_full(pWinObject, "focus,out", OnWindowObjectFocusLost, this); evas_object_smart_callback_del(pWebNativeNode, "inputmethod,changed", OnWebKeypadStateChanged); evas_object_smart_callback_del(pWebNativeNode, "editorclient,ime,opened", OnWebKeypadOpened); @@ -3650,6 +3692,7 @@ _WebImpl::RemoveEventListenerCallback(void) const ewk_view_exceeded_local_file_system_quota_callback_set(pWebNativeNode, null, null); evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_IN, OnWebNativeNodeFocusGained); + evas_object_event_callback_del(pWebNativeNode, EVAS_CALLBACK_FOCUS_OUT, OnWebNativeNodeFocusLost); } } @@ -3696,10 +3739,6 @@ _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint) return E_SUCCESS; } - Ewk_Settings* pSettings = ewk_view_settings_get(pWebview); - SysAssertf(pSettings, "Failed to get webkit instance."); - ewk_settings_clear_text_selection_automatically_set(pSettings, true); - Ewk_View_Smart_Data* pSmartData = reinterpret_cast< Ewk_View_Smart_Data* >(evas_object_smart_data_get(pWebview)); SysAssertf(pSmartData && pSmartData->api, "Failed to get webkit instance."); Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint))); @@ -4028,6 +4067,20 @@ _WebImpl::SetKeypadOpened(bool isKeypadOpened) } +bool +_WebImpl::IsWinFocusLost(void) const +{ + return __isWinFocusLost; +} + + +void +_WebImpl::SetWinFocusLost(bool isWinFocusLost) +{ + __isWinFocusLost = isWinFocusLost; +} + + Rectangle _WebImpl::GetPreviousKeypadBounds(void) const { @@ -4744,16 +4797,6 @@ _WebImpl::GetParentFormImpl(_ControlImpl* pControlImpl) bool _WebImpl::OnFocusGained(const _ControlImpl& source) { - Evas_Object* pWebview = __pWebCore->GetWebNativeNode(); - if (!pWebview) - { - return false; - } - - Ewk_Settings* pSettings = ewk_view_settings_get(pWebview); - SysAssertf(pSettings, "Failed to get settings instance."); - ewk_settings_clear_text_selection_automatically_set(pSettings, true); - return false; } @@ -4772,10 +4815,6 @@ _WebImpl::OnFocusLost(const _ControlImpl& source) SetKeypadOpened(true); } - Ewk_Settings* pSettings = ewk_view_settings_get(pWebview); - SysAssertf(pSettings, "Failed to get settings instance."); - ewk_settings_clear_text_selection_automatically_set(pSettings, false); - return false; } diff --git a/src/controls/inc/FWebCtrl_WebImpl.h b/src/controls/inc/FWebCtrl_WebImpl.h index 011ded6..b48975b 100755 --- a/src/controls/inc/FWebCtrl_WebImpl.h +++ b/src/controls/inc/FWebCtrl_WebImpl.h @@ -346,6 +346,10 @@ public: void SetKeypadOpened(bool isKeypadOpened); + bool IsWinFocusLost(void) const; + + void SetWinFocusLost(bool isWinFocusLost); + Tizen::Graphics::Rectangle GetPreviousKeypadBounds(void) const; void SetPreviousKeypadBounds(Tizen::Graphics::Rectangle& bounds); @@ -447,6 +451,7 @@ private: bool __isFooterVisible; bool __isKeypadVisible; bool __isKeypadOpened; + bool __isWinFocusLost; bool __isLoadingErrorOccurred; bool __isRedirectRequested; bool __isCertificateRequested;