fix the code for OnWebPageBlockSelected()
authorSeongjun Yim <se201.yim@samsung.com>
Tue, 27 Aug 2013 07:17:48 +0000 (16:17 +0900)
committerSeongjun Yim <se201.yim@samsung.com>
Tue, 27 Aug 2013 07:28:13 +0000 (16:28 +0900)
Change-Id: I961f0cccc1c0d3ea31f4eb6327079848474a17d5
Signed-off-by: Seongjun Yim <se201.yim@samsung.com>
src/controls/FWebCtrl_GestureState.cpp
src/controls/FWebCtrl_WebImpl.cpp

index 93419bd..c88cbb0 100755 (executable)
@@ -214,12 +214,6 @@ _TapGestureState::OnTouchReleased(const _Control& source, const _TouchInfo& touc
                        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
        {
index c8671de..c5448f4 100755 (executable)
@@ -1549,7 +1549,6 @@ FireWebPageBlockSelectedEventF(_WebImpl* pImpl)
        SysTryReturnResult(NID_WEB_CTRL, startPoint.get() && endPoint.get(), E_OUT_OF_MEMORY, "Memory Allocation failed.");
 
        pImpl->GetBlockRange(*startPoint.get(), *endPoint.get());
-
        if ((endPoint->x != 0.0f) && (endPoint->y != 0.0f))
        {
                std::unique_ptr<_WebUiEventArg> pEventArg(new (std::nothrow) _WebUiEventArg(WEB_EVENT_WEBUIEVENTLISTENER_PAGE_BLOCK_SELECTED_FLOAT));
@@ -3548,7 +3547,7 @@ _WebImpl::SetEventListenerCallback(void) const
                evas_object_smart_callback_add(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered, this);
                evas_object_smart_callback_add(pWebNativeNode, "icon,received", OnFaviconReceived, this);
 
-               evas_object_smart_callback_add(pWebNativeNode, "text,selected", OnWebPageBlockSelected, this);
+               evas_object_smart_callback_add(pWebNativeNode, "magnifier,hide", OnWebPageBlockSelected, this);
 
                evas_object_smart_callback_add(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered, this);
                evas_object_smart_callback_add(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited, this);
@@ -3634,7 +3633,7 @@ _WebImpl::RemoveEventListenerCallback(void) const
                evas_object_smart_callback_del(pWebNativeNode, "touchmove,handled", OnWebPreventDefaultTriggered);
                evas_object_smart_callback_del(pWebNativeNode, "icon,received", OnFaviconReceived);
 
-               evas_object_smart_callback_del(pWebNativeNode, "text,selected", OnWebPageBlockSelected);
+               evas_object_smart_callback_del(pWebNativeNode, "magnifier,hide", OnWebPageBlockSelected);
 
                evas_object_smart_callback_del(pWebNativeNode, "fullscreen,enterfullscreen", OnFullScreenEntered);
                evas_object_smart_callback_del(pWebNativeNode, "fullscreen,exitfullscreen", OnFullScreenExited);
@@ -3692,46 +3691,41 @@ _WebImpl::SetBlockSelectionPosition(const Point& startPoint)
 result
 _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
 {
-       Evas_Object* pView = __pWebCore->GetWebNativeNode();
-       Ewk_View_Smart_Data* pSmartData = (Ewk_View_Smart_Data*) evas_object_smart_data_get(pView);
-       if (pSmartData && pSmartData->api)
+       Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
+       if (!pWebview)
        {
-               Point absPoint( _CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(startPoint)));
+               return E_SUCCESS;
+       }
 
-               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);
+       Ewk_Settings* pSettings = ewk_view_settings_get(pWebview);
+       SysAssertf(pSettings, "Failed to get webkit instance.");
+       ewk_settings_clear_text_selection_automatically_set(pSettings, true);
 
-               Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
-               if (ret)
-               {
-                       pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
+       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)));
 
-                       Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pView, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
-                       SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
+       Eina_Bool ret = pSmartData->api->text_selection_down(pSmartData, absPoint.x, absPoint.y);
+       if (ret)
+       {
+               pSmartData->api->text_selection_up(pSmartData, absPoint.x, absPoint.y);
 
-                       String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
+               Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pWebview, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
+               SysTryReturnResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "Failed to get hit test.");
 
-                       if (tagName.Equals(L"INPUT", false) || tagName.Equals(L"TEXTAREA", false))
-                       {
-                               ewk_view_command_execute(pView, "SelectWord", 0);
-                       }
-                       else
-                       {
-                               Eina_Hash* pAttrHash = ewk_hit_test_attribute_hash_get(pEwkHitTest);
-                               char* pValue = reinterpret_cast< char* >(eina_hash_find(pAttrHash, "contenteditable"));
-                               if(pValue)
-                               {
-                                       ewk_view_command_execute(pView, "SelectWord", 0);
-                               }
-                       }
+               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)
+               {
+                       ewk_view_command_execute(pWebview, "SelectWord", 0);
+                       evas_object_smart_callback_call(pWebview, "magnifier,hide", NULL);
                }
        }
 
        SysTryReturnResult(NID_WEB_CTRL, GetTextFromBlock().GetLength() > 0, E_INVALID_ARG, "Failed to set text selection up.");
 
-       evas_object_smart_callback_call(pView, "text,selected", NULL);
-
        return E_SUCCESS;
 }