fix textarea bug
authorSeongjun Yim <se201.yim@samsung.com>
Mon, 28 Oct 2013 12:50:21 +0000 (21:50 +0900)
committerSeongjun Yim <se201.yim@samsung.com>
Mon, 28 Oct 2013 12:50:21 +0000 (21:50 +0900)
Change-Id: If5bf28baca2da05384b89e640bf5d0bf20582d99
Signed-off-by: Seongjun Yim <se201.yim@samsung.com>
src/controls/FWebCtrl_Web.cpp
src/controls/FWebCtrl_Web.h
src/controls/FWebCtrl_WebImpl.cpp

index 90edf4b..0e8c70c 100755 (executable)
@@ -611,6 +611,7 @@ _Web::GetSetting(void) const
        return __pWebSetting.get();
 }
 
+
 _EflWebkit*
 _Web::GetEflWebkit(void) const
 {
@@ -618,6 +619,13 @@ _Web::GetEflWebkit(void) const
 }
 
 
+FloatPoint
+_Web::GetTouchPosition(void) const
+{
+       return __previousTouchedPosition;
+}
+
+
 result
 _Web::OnAttaching(const _Control* pParent)
 {
index 8d525b9..5dc1c4a 100755 (executable)
@@ -117,6 +117,8 @@ public:
 
        _EflWebkit* GetEflWebkit(void) const;
 
+       Tizen::Graphics::FloatPoint GetTouchPosition(void) const;
+
        void SetEdgeReachedEvent(_WebEdgeType type);
 
        void SetFullScreenEntered(bool isFullScreenEntered);
index 42ae6b5..a77edf2 100755 (executable)
@@ -3994,7 +3994,7 @@ _WebImpl::SetBlockSelectionPosition(const FloatPoint& startPoint)
                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);
+                       ewk_view_command_execute(pWebview, "SelectWord", null);
                        evas_object_smart_callback_call(pWebview, "magnifier,hide", NULL);
                }
        }
@@ -4241,6 +4241,12 @@ _WebImpl::IsCertificateConfirmed(void) const
 result
 _WebImpl::SetFullScreenKeypad(void)
 {
+       Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
+       if (!pWebview)
+       {
+               return E_SUCCESS;
+       }
+
        result r = E_SUCCESS;
 
        std::unique_ptr<Keypad> pKeypad(new (std::nothrow) Keypad());
@@ -4249,8 +4255,23 @@ _WebImpl::SetFullScreenKeypad(void)
        r = pKeypad->Construct(KEYPAD_STYLE_NORMAL, 100);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
-       String text(ewk_view_focused_input_element_value_get(__pWebCore->GetWebNativeNode()));
-       pKeypad->SetText(text);
+       Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(__pWebCore->GetTouchPosition())));
+
+       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.");
+
+       String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
+       if (tagName.Equals(L"INPUT", false))
+       {
+               String text(ewk_view_focused_input_element_value_get(pWebview));
+               pKeypad->SetText(text);
+       }
+       else
+       {
+               String* pText = EvaluateJavascriptN(L"document.activeElement.value");
+               SysTryReturnResult(NID_WEB_CTRL, pText, E_OUT_OF_MEMORY, "Memory allocation failed.");
+               pKeypad->SetText(*pText);
+       }
 
        r = pKeypad->SetShowState(true);
        SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
@@ -4354,9 +4375,31 @@ _WebImpl::OnTextValueChangeCanceled(const Control& source)
 void
 _WebImpl::OnTextValueChanged(const Control& source)
 {
+       Evas_Object* pWebview = __pWebCore->GetWebNativeNode();
+       if (!pWebview)
+       {
+               return;
+       }
+
        std::unique_ptr<char[]> pText(_StringConverter::CopyToCharArrayN(__pKeypad->GetText()));
+       SysTryReturnVoidResult(NID_WEB_CTRL, pText.get(), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
 
-       ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
+       Point absPoint(_CoordinateSystemUtils::ConvertToInteger(__pWebCore->GetAbsoluteCoordinate(__pWebCore->GetTouchPosition())));
+
+       Ewk_Hit_Test* pEwkHitTest = ewk_view_hit_test_new(pWebview, absPoint.x, absPoint.y, EWK_HIT_TEST_MODE_ALL);
+       SysTryReturnVoidResult(NID_WEB_CTRL, pEwkHitTest, E_SYSTEM, "[E_SYSTEM] Failed to get hit test.");
+
+       String tagName(ewk_hit_test_tag_name_get(pEwkHitTest));
+       if (tagName.Equals(L"INPUT", false))
+       {
+               ewk_view_focused_input_element_value_set(__pWebCore->GetWebNativeNode(), pText.get());
+       }
+       else
+       {
+               ewk_view_command_execute(pWebview, "SelectAll", null);
+               ewk_view_command_execute(pWebview, "Delete", null);
+               ewk_view_command_execute(pWebview, "InsertText", pText.get());
+       }
 
        RemoveFullScreenKeypad();
 }