From e1c50a330822f918156cd5ce2142903bd497e037 Mon Sep 17 00:00:00 2001 From: SangYong Park Date: Mon, 8 Apr 2013 17:18:33 +0900 Subject: [PATCH] Refine input method code [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 | 4 ++ Source/WebCore/rendering/RenderTextControl.cpp | 11 ++++ .../WebKit2/UIProcess/API/efl/PageClientImpl.cpp | 2 +- Source/WebKit2/UIProcess/WebPageProxy.cpp | 5 -- .../UIProcess/efl/InputMethodContextEfl.cpp | 63 +++++++++++++--------- .../WebKit2/UIProcess/efl/InputMethodContextEfl.h | 27 +++++----- Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp | 6 +-- Source/WebKit2/WebProcess/WebPage/WebPage.h | 4 -- .../WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp | 20 +++---- 9 files changed, 77 insertions(+), 65 deletions(-) mode change 100644 => 100755 Source/WebCore/editing/Editor.cpp mode change 100644 => 100755 Source/WebCore/rendering/RenderTextControl.cpp diff --git a/Source/WebCore/editing/Editor.cpp b/Source/WebCore/editing/Editor.cpp old mode 100644 new mode 100755 index b59bbb9..4b97e25 --- a/Source/WebCore/editing/Editor.cpp +++ b/Source/WebCore/editing/Editor.cpp @@ -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; } diff --git a/Source/WebCore/rendering/RenderTextControl.cpp b/Source/WebCore/rendering/RenderTextControl.cpp old mode 100644 new mode 100755 index 9f090c3..ab7937e --- a/Source/WebCore/rendering/RenderTextControl.cpp +++ b/Source/WebCore/rendering/RenderTextControl.cpp @@ -31,6 +31,10 @@ #include "VisiblePosition.h" #include +#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); } diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp index 99691c1..31ed791 100755 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp @@ -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); diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp index 7e72a9d..a6ff11a 100755 --- a/Source/WebKit2/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp @@ -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); diff --git a/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp b/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp index 24d2a8e..a720eab 100755 --- a/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp +++ b/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp @@ -35,7 +35,7 @@ InputMethodContextEfl::InputMethodContextEfl(EwkViewImpl* viewImpl, PassOwnPtrpage()->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()); diff --git a/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h b/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h index c70cb8a..1d3388b 100755 --- a/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h +++ b/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h @@ -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 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 m_context; + bool m_focused; + +#if ENABLE(TIZEN_ISF_PORT) HashMap > m_contextList; - bool m_tryToShow; + bool m_useInputMethod; int m_state; WebCore::IntRect m_imeRect; #endif diff --git a/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp b/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp index 84098c2..1eecc24 100755 --- a/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp +++ b/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp @@ -241,12 +241,10 @@ void WebPageProxy::textChangeInTextField(const String& name, const String& value void WebPageProxy::setInputMethodState(bool active) { InputMethodContextEfl* inputMethodContext = static_cast(m_pageClient)->viewImpl()->inputMethodContext(); - if (!active) + if (!inputMethodContext) return; - inputMethodContext->setTryToShow(true); - inputMethodContext->updateTextInputState(); - inputMethodContext->setTryToShow(false); + inputMethodContext->setUseInputMethod(active); } int WebPageProxy::getCursorOffset() diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h index 7f8aab6..aa35650 100755 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h @@ -1145,10 +1145,6 @@ private: OwnPtr m_screenReader; #endif -#if ENABLE(TIZEN_ISF_PORT) - bool m_isSettingComposition; -#endif - #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) EditorState m_editorState; #endif diff --git a/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp b/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp index a3ae935..133662f 100755 --- a/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp +++ b/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp @@ -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 Vectoreditor()->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()); -- 2.7.4