Fix keypad layout issue
authorSangYong Park <sy302.park@samsung.com>
Fri, 12 Apr 2013 09:05:56 +0000 (18:05 +0900)
committerGerrit Code Review <gerrit2@kim11>
Fri, 12 Apr 2013 15:24:38 +0000 (00:24 +0900)
[Title] Fix keypad layout issue
[Issue#] N/A
[Problem] Tap edit field while keypad is visible, keypad layout does not change
[Cause] Do not keypad context
[Solution] Set keypad context if new keypad has other layout

Change-Id: I60ebf4b2fa9648c9a3289cf3aa36bfa9549851ff

Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp
Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h

index cdd0035..3f9bd0d 100755 (executable)
@@ -325,96 +325,15 @@ void InputMethodContextEfl::updateTextInputState()
 {
     const EditorState& editor = m_viewImpl->page()->editorState();
 
-    if (m_focused)
-        ecore_imf_context_cursor_position_set(m_context.get(), editor.cursorPosition);
-
-    if (editor.shouldIgnoreCompositionSelectionChange)
-        return;
-
-    if (editor.isContentEditable && m_useInputMethod) {
-        if (m_state != ECORE_IMF_INPUT_PANEL_STATE_HIDE)
-            return;
-
-        Ewk_Settings* settings = ewk_view_settings_get(m_viewImpl->view());
-        bool defaultKeypadEnabled = ewk_settings_default_keypad_enabled_get(settings);
-
-#if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
-        if (editor.inputMethodHints == "date") {
-            showInputPicker(EWK_INPUT_TYPE_DATE, editor);
-            return;
-        } else if (editor.inputMethodHints == "datetime") {
-            showInputPicker(EWK_INPUT_TYPE_DATETIME, editor);
-            return;
-        } else if (editor.inputMethodHints == "datetime-local") {
-            showInputPicker(EWK_INPUT_TYPE_DATETIMELOCAL, editor);
-            return;
-        } else if (editor.inputMethodHints == "month") {
-            showInputPicker(EWK_INPUT_TYPE_MONTH, editor);
-            return;
-        } else if (editor.inputMethodHints == "time") {
-            showInputPicker(EWK_INPUT_TYPE_TIME, editor);
-            return;
-        } else if (editor.inputMethodHints == "week") {
-            showInputPicker(EWK_INPUT_TYPE_WEEK, editor);
-            return;
-        }
-
-#if ENABLE(TIZEN_DATALIST_ELEMENT)
-        Vector<String> optionList = m_viewImpl->page()->getFocusedInputElementDataList();
-        if (optionList.size() > 0) {
-            if (editor.selectionIsRange || !evas_object_focus_get(m_viewImpl->view()))
-                return;
-
-            if (editor.inputMethodHints == "tel")
-                ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_TELEPHONE, optionList);
-            else if (editor.inputMethodHints == "number")
-                ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_NUMBER, optionList);
-            else if (editor.inputMethodHints == "email")
-                ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_EMAIL, optionList);
-            else if (editor.inputMethodHints == "url")
-                ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_URL, optionList);
-            else
-                ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_TEXT, optionList);
-
-            return;
-        }
-#endif
-#endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
-
-#if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
-        if (m_viewImpl->pageClient->isClipboardWindowOpened()) {
-            LOG(ISF, "[FAIL] Clipboard\n");
-            return;
-        }
-#endif
-
-        bool hasFocus = evas_object_focus_get(m_viewImpl->view());
-
-        if (!defaultKeypadEnabled) {
-            if (hasFocus) {
-                Eina_Rectangle dummyRectForCustomKeypadCallback;
-                memset(&dummyRectForCustomKeypadCallback, 0, sizeof(Eina_Rectangle));
-                evas_object_smart_callback_call(m_viewImpl->view(), "inputmethod,changed", &dummyRectForCustomKeypadCallback);
-            }
-            return;
-        }
-
-        setType(editor.inputMethodHints);
-
-        if (!hasFocus) {
-            m_focused = true;
-            return;
-        }
-
-        ecore_imf_context_reset(m_context.get());
-        ecore_imf_context_focus_in(m_context.get());
-        ecore_imf_context_input_panel_show(m_context.get());
+    if (!editor.shouldIgnoreCompositionSelectionChange) {
+        if (editor.isContentEditable && m_useInputMethod)
+            showIMFContext(editor);
+        else
+            hideIMFContext();
+    }
 
-        // input field zoom for external keyboard
-        ewk_view_focused_node_adjust(m_viewImpl->view(), EINA_TRUE);
-        m_focused = true;
-    } else
-        hideIMFContext();
+    if (m_context)
+        ecore_imf_context_cursor_position_set(m_context.get(), editor.cursorPosition);
 }
 #else
 void InputMethodContextEfl::updateTextInputState()
@@ -466,22 +385,24 @@ void InputMethodContextEfl::setUseInputMethod(bool use)
     updateTextInputState();
 }
 
-void InputMethodContextEfl::setType(const String& type)
+Ecore_IMF_Input_Panel_Layout InputMethodContextEfl::layoutType(const String& type)
 {
-    Ecore_IMF_Input_Panel_Layout layout;
     if (type == "number")
-        layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER;
+        return ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER;
     else if (type == "email")
-        layout = ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL;
+        return ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL;
     else if (type == "url")
-        layout = ECORE_IMF_INPUT_PANEL_LAYOUT_URL;
+        return ECORE_IMF_INPUT_PANEL_LAYOUT_URL;
     else if (type == "tel")
-        layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
+        return ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
     else if (type == "password")
-        layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD;
+        return ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD;
     else
-        layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
+        return ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
+}
 
+void InputMethodContextEfl::setIMFContext(Ecore_IMF_Input_Panel_Layout layout, const String& type)
+{
     if (m_contextList.contains(layout)) {
         revertIMFContext();
         m_context = m_contextList.take(layout);
@@ -557,6 +478,94 @@ void InputMethodContextEfl::resetIMFContext()
     ecore_imf_context_reset(m_context.get());
 }
 
+void InputMethodContextEfl::showIMFContext(const EditorState& editor)
+{
+    Ecore_IMF_Input_Panel_Layout layout = layoutType(editor.inputMethodHints);
+
+    if (m_context && m_state != ECORE_IMF_INPUT_PANEL_STATE_HIDE && layout == ecore_imf_context_input_panel_layout_get(m_context.get()))
+        return;
+
+    Ewk_Settings* settings = ewk_view_settings_get(m_viewImpl->view());
+    bool defaultKeypadEnabled = ewk_settings_default_keypad_enabled_get(settings);
+
+#if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
+    if (editor.inputMethodHints == "date") {
+        showInputPicker(EWK_INPUT_TYPE_DATE, editor);
+        return;
+    } else if (editor.inputMethodHints == "datetime") {
+        showInputPicker(EWK_INPUT_TYPE_DATETIME, editor);
+        return;
+    } else if (editor.inputMethodHints == "datetime-local") {
+        showInputPicker(EWK_INPUT_TYPE_DATETIMELOCAL, editor);
+        return;
+    } else if (editor.inputMethodHints == "month") {
+        showInputPicker(EWK_INPUT_TYPE_MONTH, editor);
+        return;
+    } else if (editor.inputMethodHints == "time") {
+        showInputPicker(EWK_INPUT_TYPE_TIME, editor);
+        return;
+    } else if (editor.inputMethodHints == "week") {
+        showInputPicker(EWK_INPUT_TYPE_WEEK, editor);
+        return;
+    }
+
+#if ENABLE(TIZEN_DATALIST_ELEMENT)
+    Vector<String> optionList = m_viewImpl->page()->getFocusedInputElementDataList();
+    if (optionList.size() > 0) {
+        if (editor.selectionIsRange || !evas_object_focus_get(m_viewImpl->view()))
+            return;
+
+        if (editor.inputMethodHints == "tel")
+            ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_TELEPHONE, optionList);
+        else if (editor.inputMethodHints == "number")
+            ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_NUMBER, optionList);
+        else if (editor.inputMethodHints == "email")
+            ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_EMAIL, optionList);
+        else if (editor.inputMethodHints == "url")
+            ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_URL, optionList);
+        else
+            ewkViewDataListShowRequest(m_viewImpl->view(), EWK_INPUT_TYPE_TEXT, optionList);
+
+        return;
+    }
+#endif
+#endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
+
+#if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
+    if (m_viewImpl->pageClient->isClipboardWindowOpened()) {
+        LOG(ISF, "[FAIL] Clipboard\n");
+        return;
+    }
+#endif
+
+    bool hasFocus = evas_object_focus_get(m_viewImpl->view());
+
+    if (!defaultKeypadEnabled) {
+        if (hasFocus) {
+            Eina_Rectangle dummyRectForCustomKeypadCallback;
+            memset(&dummyRectForCustomKeypadCallback, 0, sizeof(Eina_Rectangle));
+            evas_object_smart_callback_call(m_viewImpl->view(), "inputmethod,changed", &dummyRectForCustomKeypadCallback);
+        }
+        return;
+    }
+
+    setIMFContext(layout, editor.inputMethodHints);
+
+    if (!hasFocus) {
+        m_focused = true;
+        return;
+    }
+
+    ecore_imf_context_reset(m_context.get());
+    ecore_imf_context_focus_in(m_context.get());
+    ecore_imf_context_input_panel_show(m_context.get());
+
+    // input field zoom for external keyboard
+    ewk_view_focused_node_adjust(m_viewImpl->view(), EINA_TRUE);
+
+    m_focused = true;
+}
+
 void InputMethodContextEfl::hideIMFContext()
 {
     if (!m_context || !m_focused)
index 1d3388b..a8f45a7 100755 (executable)
@@ -76,8 +76,10 @@ private:
     static Eina_Bool onIMFRetrieveSurrounding(void*, Ecore_IMF_Context*, char**, int*);
     static void onIMFDeleteSurrounding(void*, Ecore_IMF_Context*, void*);
 
-    void setType(const String&);
+    Ecore_IMF_Input_Panel_Layout layoutType(const String&);
+    void setIMFContext(Ecore_IMF_Input_Panel_Layout, const String&);
     void revertIMFContext();
+    void showIMFContext(const EditorState&);
     void destroyIMFContextList();
     void setState(int state) { m_state = state; }
     void setIMERect(const WebCore::IntRect& rect) { m_imeRect = rect; }