Refine input method code
authorSangYong Park <sy302.park@samsung.com>
Mon, 8 Apr 2013 08:18:33 +0000 (17:18 +0900)
committerGerrit Code Review <gerrit2@kim11>
Wed, 10 Apr 2013 13:29:39 +0000 (22:29 +0900)
[Title] Refine input method code
[Issue#] N/A
[Problem] Unnecessary input method code was exist after appling opensource
[Cause] N/A
[Solution] Refine input method code

Change-Id: Icf0ec106ce1534d04d07fc7ab399e2683192c090

Source/WebCore/editing/Editor.cpp [changed mode: 0644->0755]
Source/WebCore/rendering/RenderTextControl.cpp [changed mode: 0644->0755]
Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp
Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h
Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp

old mode 100644 (file)
new mode 100755 (executable)
index b59bbb9..4b97e25
@@ -1358,7 +1358,11 @@ void Editor::setComposition(const String& text, SetCompositionMode mode)
     else
         selectComposition();
 
+#if ENABLE(TIZEN_ISF_PORT)
+    if (m_frame->selection()->isNone() && mode != CancelComposition) {
+#else
     if (m_frame->selection()->isNone()) {
+#endif
         setIgnoreCompositionSelectionChange(false);
         return;
     }
old mode 100644 (file)
new mode 100755 (executable)
index 9f090c3..ab7937e
 #include "VisiblePosition.h"
 #include <wtf/unicode/CharacterNames.h>
 
+#if ENABLE(TIZEN_ISF_PORT)
+#include "EditorClient.h"
+#endif
+
 using namespace std;
 
 namespace WebCore {
@@ -63,12 +67,19 @@ void RenderTextControl::styleDidChange(StyleDifference diff, const RenderStyle*
         return;
     RenderBlock* innerTextRenderer = toRenderBlock(innerText->renderer());
     if (innerTextRenderer) {
+#if ENABLE(TIZEN_ISF_PORT)
+        EUserModify userModify = innerTextRenderer->style()->userModify();
+#endif
         // We may have set the width and the height in the old style in layout().
         // Reset them now to avoid getting a spurious layout hint.
         innerTextRenderer->style()->setHeight(Length());
         innerTextRenderer->style()->setWidth(Length());
         innerTextRenderer->setStyle(createInnerTextStyle(style()));
         innerText->setNeedsStyleRecalc();
+#if ENABLE(TIZEN_ISF_PORT)
+        if (userModify != innerTextRenderer->style()->userModify() && frame()->editor()->client())
+            frame()->editor()->client()->respondToChangedSelection(frame());
+#endif
     }
     textFormControlElement()->updatePlaceholderVisibility(false);
 }
index 99691c1..31ed791 100755 (executable)
@@ -1044,7 +1044,7 @@ bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point, bool isSt
 {
     if (!evas_object_focus_get(m_viewImpl->view())) {
         InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
-        if (inputMethodContext && !inputMethodContext->isShow())
+        if (inputMethodContext)
             inputMethodContext->hideIMFContext();
 
         evas_object_focus_set(m_viewImpl->view(), true);
index 7e72a9d..a6ff11a 100755 (executable)
@@ -1246,11 +1246,6 @@ void WebPageProxy::handleGestureEvent(const WebGestureEvent& event)
     if (!isValid())
         return;
 
-#if ENABLE(TIZEN_ISF_PORT)
-    if (event.type() == WebEvent::GestureSingleTap)
-        EwkViewImpl::fromEvasObject(viewWidget())->inputMethodContext()->resetIMFContext();
-#endif
-
 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
     if (!isWaitingForJavaScriptPopupReply()) {
         m_gestureEventQueue.append(event);
index 24d2a8e..a720eab 100755 (executable)
@@ -35,7 +35,7 @@ InputMethodContextEfl::InputMethodContextEfl(EwkViewImpl* viewImpl, PassOwnPtr<E
     , m_context(context)
     , m_focused(false)
 #if ENABLE(TIZEN_ISF_PORT)
-    , m_tryToShow(false)
+    , m_useInputMethod(false)
     , m_state(ECORE_IMF_INPUT_PANEL_STATE_HIDE)
 #endif
 {
@@ -322,31 +322,21 @@ void InputMethodContextEfl::handleKeyDownEvent(const Evas_Event_Key_Down* downEv
     *isFiltered = ecore_imf_context_filter_event(m_context.get(), ECORE_IMF_EVENT_KEY_DOWN, &inputMethodEvent);
 }
 
+#if ENABLE(TIZEN_ISF_PORT)
 void InputMethodContextEfl::updateTextInputState()
 {
-#if !ENABLE(TIZEN_ISF_PORT)
-    if (!m_context)
-        return;
-#endif
-
     const EditorState& editor = m_viewImpl->page()->editorState();
 
-#if ENABLE(TIZEN_ISF_PORT)
-    bool isActive = !editor.selectionIsNone && (editor.isContentEditable || m_tryToShow);
-#else
-    bool isActive = editor.isContentEditable;
-#endif
+    if (m_focused)
+        ecore_imf_context_cursor_position_set(m_context.get(), editor.cursorPosition);
 
-    if (isActive) {
-#if ENABLE(TIZEN_ISF_PORT)
-        if (m_context)
-            ecore_imf_context_cursor_position_set(m_context.get(), editor.cursorPosition);
-#endif
+    if (editor.shouldIgnoreCompositionSelectionChange)
+        return;
 
+    if (editor.isContentEditable && m_useInputMethod) {
         if (m_focused)
             return;
 
-#if ENABLE(TIZEN_ISF_PORT)
         Ewk_Settings* settings = ewk_view_settings_get(m_viewImpl->view());
         bool defaultKeypadEnabled = ewk_settings_default_keypad_enabled_get(settings);
 
@@ -417,16 +407,31 @@ void InputMethodContextEfl::updateTextInputState()
             m_focused = true;
             return;
         }
-#endif
 
         ecore_imf_context_reset(m_context.get());
         ecore_imf_context_focus_in(m_context.get());
-#if ENABLE(TIZEN_ISF_PORT)
         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);
-#endif
+        m_focused = true;
+    } else
+        hideIMFContext();
+}
+#else
+void InputMethodContextEfl::updateTextInputState()
+{
+    if (!m_context)
+        return;
+
+    const EditorState& editor = m_viewImpl->page()->editorState();
+
+    if (editor.isContentEditable) {
+        if (m_focused)
+            return;
+
+        ecore_imf_context_reset(m_context.get());
+        ecore_imf_context_focus_in(m_context.get());
         m_focused = true;
     } else {
         if (!m_focused)
@@ -438,12 +443,9 @@ void InputMethodContextEfl::updateTextInputState()
         m_focused = false;
         ecore_imf_context_reset(m_context.get());
         ecore_imf_context_focus_out(m_context.get());
-#if ENABLE(TIZEN_ISF_PORT)
-        ecore_imf_context_input_panel_hide(m_context.get());
-        revertIMFContext();
-#endif
     }
 }
+#endif
 
 #if ENABLE(TIZEN_ISF_PORT)
 void InputMethodContextEfl::initializeIMFContext(Ecore_IMF_Context* context, Ecore_IMF_Input_Panel_Layout layout)
@@ -460,6 +462,12 @@ void InputMethodContextEfl::initializeIMFContext(Ecore_IMF_Context* context, Eco
     ecore_imf_context_input_panel_layout_set(m_context.get(), layout);
 }
 
+void InputMethodContextEfl::setUseInputMethod(bool use)
+{
+    m_useInputMethod = use;
+    updateTextInputState();
+}
+
 void InputMethodContextEfl::setType(const String& type)
 {
     Ecore_IMF_Input_Panel_Layout layout;
@@ -546,9 +554,14 @@ void InputMethodContextEfl::resetIMFContext()
 
 void InputMethodContextEfl::hideIMFContext()
 {
-    if (!m_context)
+    if (!m_context || !m_focused)
         return;
 
+    if (m_viewImpl->page()->editorState().hasComposition)
+        m_viewImpl->page()->cancelComposition();
+
+    m_focused = false;
+
     if (ecore_imf_context_input_panel_state_get(m_context.get()) != ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
         ecore_imf_context_reset(m_context.get());
         ecore_imf_context_input_panel_hide(m_context.get());
index c70cb8a..1d3388b 100755 (executable)
@@ -49,19 +49,14 @@ public:
     void updateTextInputState();
 
 #if ENABLE(TIZEN_ISF_PORT)
-    void setTryToShow(bool flag) { m_tryToShow = flag; }
-    void setType(const String&);
+    void setUseInputMethod(bool);
     bool isShow();
     Ecore_IMF_Autocapital_Type autoCapitalType();
     void onFocusIn();
     void onFocusOut();
-    void revertIMFContext();
     void resetIMFContext();
     void hideIMFContext();
-    void destroyIMFContextList();
-    bool isIMEPostion(int x, int y);
-    void setState(int state) { m_state = state; }
-    void setIMERect(const WebCore::IntRect& rect) { m_imeRect = rect; }
+    bool isIMEPostion(int, int);
 #endif
 
 private:
@@ -71,10 +66,6 @@ private:
     static void onIMFInputSequenceComplete(void* data, Ecore_IMF_Context*, void* eventInfo);
     static void onIMFPreeditSequenceChanged(void* data, Ecore_IMF_Context*, void* eventInfo);
 
-    EwkViewImpl* m_viewImpl;
-    OwnPtr<Ecore_IMF_Context> m_context;
-    bool m_focused;
-
 #if ENABLE(TIZEN_ISF_PORT)
     void initializeIMFContext(Ecore_IMF_Context*, Ecore_IMF_Input_Panel_Layout);
 
@@ -85,12 +76,24 @@ private:
     static Eina_Bool onIMFRetrieveSurrounding(void*, Ecore_IMF_Context*, char**, int*);
     static void onIMFDeleteSurrounding(void*, Ecore_IMF_Context*, void*);
 
+    void setType(const String&);
+    void revertIMFContext();
+    void destroyIMFContextList();
+    void setState(int state) { m_state = state; }
+    void setIMERect(const WebCore::IntRect& rect) { m_imeRect = rect; }
+
 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
     void showInputPicker(Ewk_Input_Type, const EditorState&);
 #endif
+#endif
 
+    EwkViewImpl* m_viewImpl;
+    OwnPtr<Ecore_IMF_Context> m_context;
+    bool m_focused;
+
+#if ENABLE(TIZEN_ISF_PORT)
     HashMap<int, OwnPtr<Ecore_IMF_Context> > m_contextList;
-    bool m_tryToShow;
+    bool m_useInputMethod;
     int m_state;
     WebCore::IntRect m_imeRect;
 #endif
index 84098c2..1eecc24 100755 (executable)
@@ -241,12 +241,10 @@ void WebPageProxy::textChangeInTextField(const String& name, const String& value
 void WebPageProxy::setInputMethodState(bool active)
 {
     InputMethodContextEfl* inputMethodContext = static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->inputMethodContext();
-    if (!active)
+    if (!inputMethodContext)
         return;
 
-    inputMethodContext->setTryToShow(true);
-    inputMethodContext->updateTextInputState();
-    inputMethodContext->setTryToShow(false);
+    inputMethodContext->setUseInputMethod(active);
 }
 
 int WebPageProxy::getCursorOffset()
index 7f8aab6..aa35650 100755 (executable)
@@ -1145,10 +1145,6 @@ private:
     OwnPtr<ScreenReader> m_screenReader;
 #endif
 
-#if ENABLE(TIZEN_ISF_PORT)
-    bool m_isSettingComposition;
-#endif
-
 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
     EditorState m_editorState;
 #endif
index a3ae935..133662f 100755 (executable)
@@ -158,9 +158,6 @@ void WebPage::platformInitialize()
     WebCore::provideDeviceMotionTo(m_page.get(), new DeviceMotionClientTizen);
     WebCore::provideDeviceOrientationTo(m_page.get(), new DeviceOrientationClientTizen);
 #endif
-#if ENABLE(TIZEN_ISF_PORT)
-    m_isSettingComposition = false;
-#endif
 }
 
 #if ENABLE(TIZEN_PREFERENCE)
@@ -312,14 +309,9 @@ void WebPage::setComposition(const String& compositionString, const Vector<WebCo
             }
         }
     }
-    m_isSettingComposition = true;
 #endif
 
     targetFrame->editor()->setComposition(compositionString, underlines, cursorPosition, 0);
-
-#if ENABLE(TIZEN_ISF_PORT)
-    m_isSettingComposition = false;
-#endif
 }
 
 void WebPage::cancelComposition()
@@ -637,11 +629,8 @@ void WebPage::getCaretPosition(IntRect& rect)
 #if ENABLE(TIZEN_ISF_PORT)
 void WebPage::didCancelComposition(Node* valueChangedNode)
 {
-    if (m_isSettingComposition)
-        return;
-
     Frame* frame = m_page->focusController()->focusedOrMainFrame();
-    if (!frame || !valueChangedNode->containsIncludingShadowDOM(frame->editor()->compositionNode()))
+    if (!frame || frame->editor()->ignoreCompositionSelectionChange() || !valueChangedNode->containsIncludingShadowDOM(frame->editor()->compositionNode()))
         return;
 
     frame->editor()->cancelComposition();
@@ -1483,8 +1472,11 @@ void WebPage::selectionRangeClear(bool& result)
         VisiblePosition visiblePos(frameSelection->extent());
         if (visiblePos.isNull())
             return;
-        VisibleSelection newSelection = VisibleSelection(visiblePos);
-        frameSelection->setSelection(newSelection, CharacterGranularity);
+
+        focusedFrame->editor()->setIgnoreCompositionSelectionChange(true);
+        frameSelection->setSelection(VisibleSelection(visiblePos), CharacterGranularity);
+        focusedFrame->editor()->setIgnoreCompositionSelectionChange(false);
+
         frameSelection->setCaretBlinkingSuspended(false);
     } else
         selectionClearAllSelection(m_page->mainFrame());