[Qt][WK2] Commit the preedit string in the input method when focus is about to be...
authormichael.bruning@digia.com <michael.bruning@digia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2012 14:17:30 +0000 (14:17 +0000)
committermichael.bruning@digia.com <michael.bruning@digia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2012 14:17:30 +0000 (14:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=97774

Reviewed by Kenneth Rohde Christiansen.

Implements the handler for willSetInputMethodState in WebKit2 in Qt.
This is needed to tell the input method instance in Qt to commit its
preedit content when the focus has moved to another node to prevent a
bug where the old preedit string was kept as the preedit string and
the editor moved focus back to the old node when continuing to enter
text via the input method.

This behavior is analog to the behavior of the QtQuick text input
elements.

* UIProcess/API/qt/raw/qrawwebview.cpp:
(QRawWebViewPrivate::handleWillSetInputMethodState):
* UIProcess/API/qt/raw/qrawwebview_p_p.h:
(QRawWebViewPrivate):
* UIProcess/PageClient.h:
(PageClient):
* UIProcess/WebPageProxy.h:
(WebPageProxy):
* UIProcess/WebPageProxy.messages.in:
* UIProcess/qt/QtPageClient.cpp:
(WebKit::QtPageClient::handleWillSetInputMethodState):
(WebKit):
* UIProcess/qt/QtPageClient.h:
(QtPageClient):
* UIProcess/qt/QtWebPageEventHandler.cpp:
(WebKit::QtWebPageEventHandler::handleWillSetInputMethodState):
(WebKit):
* UIProcess/qt/QtWebPageEventHandler.h:
(QtWebPageEventHandler):
* UIProcess/qt/WebPageProxyQt.cpp:
(WebKit::WebPageProxy::willSetInputMethodState):
(WebKit):
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::willSetInputMethodState):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@136126 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp
Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/qt/QtPageClient.cpp
Source/WebKit2/UIProcess/qt/QtPageClient.h
Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp
Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h
Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp

index b805594..0549b2a 100644 (file)
@@ -1,3 +1,45 @@
+2012-11-29  Michael BrĂ¼ning  <michael.bruning@digia.com>
+
+        [Qt][WK2] Commit the preedit string in the input method when focus is about to be moved.
+        https://bugs.webkit.org/show_bug.cgi?id=97774
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Implements the handler for willSetInputMethodState in WebKit2 in Qt.
+        This is needed to tell the input method instance in Qt to commit its
+        preedit content when the focus has moved to another node to prevent a
+        bug where the old preedit string was kept as the preedit string and
+        the editor moved focus back to the old node when continuing to enter
+        text via the input method.
+
+        This behavior is analog to the behavior of the QtQuick text input
+        elements.
+
+        * UIProcess/API/qt/raw/qrawwebview.cpp:
+        (QRawWebViewPrivate::handleWillSetInputMethodState):
+        * UIProcess/API/qt/raw/qrawwebview_p_p.h:
+        (QRawWebViewPrivate):
+        * UIProcess/PageClient.h:
+        (PageClient):
+        * UIProcess/WebPageProxy.h:
+        (WebPageProxy):
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/qt/QtPageClient.cpp:
+        (WebKit::QtPageClient::handleWillSetInputMethodState):
+        (WebKit):
+        * UIProcess/qt/QtPageClient.h:
+        (QtPageClient):
+        * UIProcess/qt/QtWebPageEventHandler.cpp:
+        (WebKit::QtWebPageEventHandler::handleWillSetInputMethodState):
+        (WebKit):
+        * UIProcess/qt/QtWebPageEventHandler.h:
+        (QtWebPageEventHandler):
+        * UIProcess/qt/WebPageProxyQt.cpp:
+        (WebKit::WebPageProxy::willSetInputMethodState):
+        (WebKit):
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::willSetInputMethodState):
+
 2012-11-28  Jocelyn Turcotte  <jocelyn.turcotte@digia.com>
 
         [Qt] The WebView should be flickable only using touch events
index f5f0bd3..3f9c3b2 100644 (file)
@@ -130,6 +130,11 @@ void QRawWebViewPrivate::updateTextInputState()
     notImplemented();
 }
 
+void QRawWebViewPrivate::handleWillSetInputMethodState()
+{
+    notImplemented();
+}
+
 #if ENABLE(GESTURE_EVENTS)
 void QRawWebViewPrivate::doneWithGestureEvent(const WebKit::WebGestureEvent& event, bool wasEventHandled)
 {
index 545096d..7bc6f11 100644 (file)
@@ -71,6 +71,7 @@ public:
 #endif // USE(ACCELERATED_COMPOSITING)
 
     virtual void updateTextInputState();
+    virtual void handleWillSetInputMethodState();
 #if ENABLE(GESTURE_EVENTS)
     virtual void doneWithGestureEvent(const WebKit::WebGestureEvent& event, bool wasEventHandled);
 #endif
index dd0cd5a..abc544f 100644 (file)
@@ -127,6 +127,7 @@ public:
     virtual void handleAuthenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password) = 0;
     virtual void handleCertificateVerificationRequest(const String& hostname, bool& ignoreErrors) = 0;
     virtual void handleProxyAuthenticationRequiredRequest(const String& hostname, uint16_t port, const String& prefilledUsername, String& username, String& password) = 0;
+    virtual void handleWillSetInputMethodState() = 0;
 #endif // PLATFORM(QT).
 
 #if PLATFORM(QT) || PLATFORM(EFL)
index 9139b48..88a93d8 100644 (file)
@@ -895,6 +895,9 @@ private:
 #endif
 
     void editorStateChanged(const EditorState&);
+#if PLATFORM(QT)
+    void willSetInputMethodState();
+#endif
 
     // Back/Forward list management
     void backForwardAddItem(uint64_t itemID);
index f88eda4..5c89fae 100644 (file)
@@ -205,7 +205,9 @@ messages -> WebPageProxy {
 #if PLATFORM(WIN)
     DidChangeCompositionSelection(bool hasChanged)
 #endif
-
+#if PLATFORM(QT)
+    WillSetInputMethodState()
+#endif
     # Find messages
     DidCountStringMatches(WTF::String string, uint32_t matchCount)
     SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, float contentImageScaleFactor, WebKit::ShareableBitmap::Handle contentImageHandle, bool fadeOut, bool animate)
index 7737f65..89a40c9 100644 (file)
@@ -256,6 +256,12 @@ void QtPageClient::updateTextInputState()
     m_eventHandler->updateTextInputState();
 }
 
+void QtPageClient::handleWillSetInputMethodState()
+{
+    ASSERT(m_eventHandler);
+    m_eventHandler->handleWillSetInputMethodState();
+}
+
 #if ENABLE(GESTURE_EVENTS)
 void QtPageClient::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
 {
index e493ce8..fc10ca6 100644 (file)
@@ -103,6 +103,7 @@ public:
     virtual void pageTransitionViewportReady();
     virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
     virtual void updateTextInputState();
+    virtual void handleWillSetInputMethodState();
     virtual void doneWithGestureEvent(const WebGestureEvent&, bool wasEventHandled);
 #if ENABLE(TOUCH_EVENTS)
     virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
index 88dae15..b806134 100644 (file)
@@ -435,6 +435,12 @@ void QtWebPageEventHandler::updateTextInputState()
     setInputPanelVisible(editor.isContentEditable);
 }
 
+void QtWebPageEventHandler::handleWillSetInputMethodState()
+{
+    if (qApp->inputMethod()->isVisible())
+        qApp->inputMethod()->commit();
+}
+
 void QtWebPageEventHandler::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
 {
     if (event.type() != WebEvent::GestureSingleTap)
index 04c75ab..005cb4c 100644 (file)
@@ -89,6 +89,7 @@ public:
     void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
 #endif
     void handleInputEvent(const QInputEvent*);
+    void handleWillSetInputMethodState();
     void resetGestureRecognizers();
 
     PageViewportControllerClientQt* viewportController() { return m_viewportController; }
index 4642946..8a205f9 100644 (file)
@@ -171,4 +171,9 @@ void WebPageProxy::closePopupMenu()
     process()->send(Messages::WebPage::HidePopupMenu(), m_pageID);
 }
 
+void WebPageProxy::willSetInputMethodState()
+{
+    m_pageClient->handleWillSetInputMethodState();
+}
+
 } // namespace WebKit
index 1c8c0b7..4a6cf83 100644 (file)
@@ -469,7 +469,11 @@ void WebEditorClient::getGuessesForWord(const String& word, const String& contex
 
 void WebEditorClient::willSetInputMethodState()
 {
+#if PLATFORM(QT)
+    m_page->send(Messages::WebPageProxy::WillSetInputMethodState());
+#else
     notImplemented();
+#endif
 }
 
 void WebEditorClient::setInputMethodState(bool)