From 20d21b83d792c4a57d1ff4ab5f310672831e81fd Mon Sep 17 00:00:00 2001 From: SangYong Park Date: Wed, 3 Jul 2013 22:05:51 +0900 Subject: [PATCH] Ignore contiguous composition event. [Title] Ignore contiguous composition event. [Issue#] P130605-7046 [Problem] Text style was not applied. [Cause] Text style was initialized when set empty text before confirm composition. [Solution] Ignore contiguous composition event. Change-Id: Id4cf6caed3b8e0361160acc63f43250978acfef4 --- .../UIProcess/efl/InputMethodContextEfl.cpp | 48 +++++++++++++++++++++- .../WebKit2/UIProcess/efl/InputMethodContextEfl.h | 5 +++ .../WebCoreSupport/efl/WebEditorClientEfl.cpp | 10 ++++- .../WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp | 7 +++- 4 files changed, 67 insertions(+), 3 deletions(-) diff --git a/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp b/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp index 4a0a7af..8bd8ee1 100755 --- a/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp +++ b/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp @@ -42,6 +42,8 @@ InputMethodContextEfl::InputMethodContextEfl(EwkViewImpl* viewImpl, PassOwnPtrm_viewImpl->page()->focusedFrame() || !inputMethodContext->m_focused) return; + if (!inputMethodContext->m_handleKeyDownEvent) + inputMethodContext->requestFakeKeyEvent(); + Ecore_IMF_Event_Delete_Surrounding* event = static_cast(eventInfo); inputMethodContext->m_viewImpl->page()->deleteSurroundingText(event->offset, event->n_chars); } @@ -151,6 +156,9 @@ void InputMethodContextEfl::onIMFInputSequenceComplete(void* data, Ecore_IMF_Con if (!eventInfo || !inputMethodContext->m_focused) return; + if (!inputMethodContext->m_handleKeyDownEvent) + inputMethodContext->requestFakeKeyEvent(); + inputMethodContext->m_viewImpl->page()->confirmComposition(String::fromUTF8(static_cast(eventInfo))); } @@ -198,6 +206,9 @@ void InputMethodContextEfl::onIMFPreeditSequenceChanged(void* data, Ecore_IMF_Co if (!page->focusedFrame()) return; + if (!inputMethodContext->m_handleKeyDownEvent) + inputMethodContext->requestFakeKeyEvent(); + PageClientImpl* pageClient = inputMethodContext->m_viewImpl->pageClient.get(); IntRect caretRect; page->getCaretPosition(caretRect); @@ -325,13 +336,22 @@ void InputMethodContextEfl::handleKeyDownEvent(const Evas_Event_Key_Down* downEv if (!m_context) return; - m_viewImpl->page()->prepareKeyDownEvent(); + if (m_fakeKeyEventTimer.isActive()) + m_fakeKeyEventTimer.stop(); + else + m_viewImpl->page()->prepareKeyDownEvent(); + + m_handleKeyDownEvent = true; #endif Ecore_IMF_Event inputMethodEvent; ecore_imf_evas_event_key_down_wrap(const_cast(downEvent), &inputMethodEvent.key_down); *isFiltered = ecore_imf_context_filter_event(m_context.get(), ECORE_IMF_EVENT_KEY_DOWN, &inputMethodEvent); + +#if ENABLE(TIZEN_ISF_PORT) + m_handleKeyDownEvent = false; +#endif } #if ENABLE(TIZEN_ISF_PORT) @@ -703,6 +723,32 @@ void InputMethodContextEfl::setKeyboardMode(bool isOn) parent = elm_object_parent_widget_get(parent); } } + +void InputMethodContextEfl::requestFakeKeyEvent() +{ + if (m_handleKeyDownEvent || m_fakeKeyEventTimer.isActive()) + return; + + m_fakeKeyEventTimer.startOneShot(0); + m_viewImpl->page()->prepareKeyDownEvent(); +} + +void InputMethodContextEfl::fakeKeyEventTimerFired(WebCore::Timer*) +{ + const char* text = " "; + + Evas_Event_Key_Down downEvent; + memset(&downEvent, 0, sizeof(Evas_Event_Key_Down)); + downEvent.key = text; + downEvent.string = text; + m_viewImpl->page()->handleKeyboardEvent(NativeWebKeyboardEvent(&downEvent, true)); + + Evas_Event_Key_Up upEvent; + memset(&upEvent, 0, sizeof(Evas_Event_Key_Up)); + upEvent.key = text; + upEvent.string = text; + m_viewImpl->page()->handleKeyboardEvent(NativeWebKeyboardEvent(&upEvent)); +} #endif // #if ENABLE(TIZEN_ISF_PORT) } diff --git a/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h b/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h index 9449278..f95c79c 100755 --- a/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h +++ b/Source/WebKit2/UIProcess/efl/InputMethodContextEfl.h @@ -93,6 +93,9 @@ private: #endif void setKeyboardMode(bool); + + void requestFakeKeyEvent(); + void fakeKeyEventTimerFired(WebCore::Timer*); #endif EwkViewImpl* m_viewImpl; @@ -107,6 +110,8 @@ private: int m_state; WebCore::IntRect m_imeRect; int m_inputPickerType; + bool m_handleKeyDownEvent; + WebCore::Timer m_fakeKeyEventTimer; #endif }; diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/efl/WebEditorClientEfl.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/efl/WebEditorClientEfl.cpp index c14feb7..a7c528f 100755 --- a/Source/WebKit2/WebProcess/WebCoreSupport/efl/WebEditorClientEfl.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/efl/WebEditorClientEfl.cpp @@ -56,6 +56,9 @@ static bool handleKeyPressCommands(WebPage* page, KeyboardEvent* event) if (!currentEvent || !currentEvent->isFiltered()) return false; + if (event->type() != eventNames().keypressEvent) + return true; + Vector > commands; page->swapKeyPressCommands(commands); @@ -67,6 +70,11 @@ static bool handleKeyPressCommands(WebPage* page, KeyboardEvent* event) switch (commands[i]->type) { case KeyPressCommandSetComposition: { const SetCompositionKeyPressCommand* command = reinterpret_cast(commands[i].get()); + if (i + 1 < size) { + int nextType = commands[i + 1]->type; + if (nextType == KeyPressCommandSetComposition || nextType == KeyPressCommandConfirmComposition) + break; + } page->setComposition(command->compositionString, command->underlines, command->cursorPosition); break; } @@ -94,7 +102,7 @@ static bool handleKeyPressCommands(WebPage* page, KeyboardEvent* event) void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event) { #if ENABLE(TIZEN_ISF_PORT) - if (event->type() == eventNames().keypressEvent && handleKeyPressCommands(m_page, event)) + if (handleKeyPressCommands(m_page, event)) return; #endif diff --git a/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp b/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp index 56a46ec..a9a42e9 100755 --- a/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp +++ b/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp @@ -290,10 +290,12 @@ void WebPage::confirmComposition(const String& compositionString) if (!targetFrame) return; +#if ENABLE(TIZEN_ISF_PORT) if (m_prepareKeyDownEvent) { m_keyPressCommands.append(adoptPtr(new ConfirmCompositionKeyPressCommand(compositionString))); return; } +#endif targetFrame->editor()->confirmComposition(compositionString); @@ -308,12 +310,15 @@ void WebPage::setComposition(const String& compositionString, const Vectoreditor()->hasComposition() && compositionString.isEmpty()) + return; + if (m_prepareKeyDownEvent) { m_keyPressCommands.append(adoptPtr(new SetCompositionKeyPressCommand(compositionString, underlines, cursorPosition))); return; } -#if ENABLE(TIZEN_ISF_PORT) if (targetFrame->selection()->rootEditableElement()) { HTMLTextFormControlElement* textFormControl = toTextFormControl(targetFrame->selection()->rootEditableElement()->shadowAncestorNode()); if (textFormControl && textFormControl->maxLength() >= 0) { -- 2.7.4