From 636a5c3e014121ca0a006f2d78f944a49aeea650 Mon Sep 17 00:00:00 2001 From: SangYong Park Date: Wed, 16 Oct 2013 17:57:10 +0900 Subject: [PATCH] Fix surrounding text issue [Title] Fix surrounding text issue [Issue#] P131014-04048 [Problem] Candidate text was invalid by IME. [Cause] Set invalid surrounding text by webkit. [Solution] Provide valid surrounding text Change-Id: I31ceaa625d45df15dcbdc0cd18e9fdc5b012e731 --- .../UIProcess/efl/InputMethodContextEfl.cpp | 26 +++++++++++++--------- .../WebKit2/UIProcess/efl/InputMethodContextEfl.h | 1 + Source/WebKit2/WebProcess/WebPage/WebPage.cpp | 3 +-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp b/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp index 48c960e..3aa2011 100755 --- a/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp +++ b/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp @@ -99,6 +99,7 @@ InputMethodContextEfl::InputMethodContextEfl(EwkViewImpl* viewImpl, PassOwnPtrpage()->editorState(); + + if (!m_isLastKeyEventFiltered && !m_approximateSurroundingText.isNull() && !state.hasComposition) + ecore_imf_context_cursor_position_set(m_context.get(), m_approximateCursorPosition); + if (m_fakeKeyEventTimer.isActive()) m_fakeKeyEventTimer.stop(); else @@ -433,22 +439,18 @@ void InputMethodContextEfl::handleKeyDownEvent(const Evas_Event_Key_Down* downEv #if ENABLE(TIZEN_ISF_PORT) m_doNotHandleFakeKeyEvent = false; + m_isLastKeyEventFiltered = *isFiltered; - const EditorState& state = m_viewImpl->page()->editorState(); - - if (m_approximateSurroundingText.isNull() && downEvent->compose) { - if (downEvent->compose[0] == 0x8) { + if (!*isFiltered) { + if (!strcmp(downEvent->key, "BackSpace")) { if (state.cursorPosition > 0) updateApproximateText(String(), state.cursorPosition - 1, 1); - } else if (downEvent->compose[0] == 0x7f) { + } else if (!strcmp(downEvent->key, "Delete")) { if (state.cursorPosition < state.surroundingText.length()) updateApproximateText(String(), state.cursorPosition, 1); } else updateApproximateText(String::fromUTF8(downEvent->compose), 0, 0); } - - if (!state.hasComposition) - ecore_imf_context_cursor_position_set(m_context.get(), m_approximateCursorPosition); #endif } @@ -464,10 +466,10 @@ void InputMethodContextEfl::updateTextInputState() else hideIMFContext(); + m_approximateSurroundingText = String(); + if (m_context && !editor.hasComposition) ecore_imf_context_cursor_position_set(m_context.get(), editor.cursorPosition); - - m_approximateSurroundingText = String(); } void InputMethodContextEfl::updateTextInputStateByUserAction(bool setFocus) @@ -844,7 +846,9 @@ void InputMethodContextEfl::fakeKeyEventTimerFired(WebCore::Timerpage()->handleKeyboardEvent(NativeWebKeyboardEvent(&downEvent, true)); + NativeWebKeyboardEvent nativeEvent(&downEvent, true); + nativeEvent.setInputMethodContextID(m_viewImpl->page()->editorState().inputMethodContextID); + m_viewImpl->page()->handleKeyboardEvent(nativeEvent); Evas_Event_Key_Up upEvent; memset(&upEvent, 0, sizeof(Evas_Event_Key_Up)); diff --git a/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h b/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h index 3cd4cfc..837f4b2 100755 --- a/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h +++ b/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h @@ -131,6 +131,7 @@ private: WebCore::Timer m_fakeKeyEventTimer; String m_approximateSurroundingText; unsigned m_approximateCursorPosition; + bool m_isLastKeyEventFiltered; #endif }; diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index b8340f5..814aa42 100755 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -578,11 +578,10 @@ EditorState WebPage::editorState() const if (!rootEditableElement) return result; + result.inputMethodContextID = reinterpret_cast(rootEditableElement); updateEditorStateRect(frame, result); if (!result.shouldIgnoreCompositionSelectionChange && result.isContentEditable) { - result.inputMethodContextID = reinterpret_cast(rootEditableElement); - Node* hostNode = rootEditableElement->shadowHost(); if (!hostNode) hostNode = rootEditableElement; -- 2.7.4