gtk:
authoroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 Sep 2007 23:04:59 +0000 (23:04 +0000)
committeroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 Sep 2007 23:04:59 +0000 (23:04 +0000)
        Reviewed by Sam.

        <rdar://problem/5344848> IME is incorrectly used for key events when on non-editable regions

        EditorClient::setInputMethodState stub

        * WebCoreSupport/EditorClientGtk.cpp:
        (WebKit::EditorClient::setInputMethodState):
        * WebCoreSupport/EditorClientGtk.h:

WebCore:

        Reviewed by Sam.

        <rdar://problem/5344848> IME is incorrectly used for key events when on non-editable regions

        Adding a new EditorClient method so it is possible to inform WebKit of focus changes.
        Also added new virtual method Node::shouldUseInputMethod to allow us to trivially check
        whether an input method should be used when processing input for the currently focused
        Node.

        * bridge/EditorClient.h:
        * dom/Node.cpp:
        (WebCore::Node::shouldUseInputMethod):
        * dom/Node.h:
        * html/HTMLInputElement.cpp:
        (WebCore::HTMLInputElement::shouldUseInputMethod):
        * html/HTMLInputElement.h:
        * html/HTMLTextAreaElement.cpp:
        (WebCore::HTMLTextAreaElement::shouldUseInputMethod):
        * html/HTMLTextAreaElement.h:
        * page/FocusController.cpp:
        (WebCore::FocusController::setFocusedNode):
        * platform/graphics/svg/SVGImageEmptyClients.h:
        (WebCore::SVGEmptyEditorClient::setInputMethodState):

WebKit:

        Reviewed by Sam.

        <rdar://problem/5344848> IME is incorrectly used for key events when on non-editable regions

        EditorClient::setInputMethodState stub

        * WebCoreSupport/WebEditorClient.h:
        * WebCoreSupport/WebEditorClient.mm:
        (WebEditorClient::setInputMethodState):

WebKitQt:

        Reviewed by Sam.

        <rdar://problem/5344848> IME is incorrectly used for key events when on non-editable regions

        EditorClient::setInputMethodState stub

        * WebCoreSupport/EditorClientQt.cpp:
        (WebCore::EditorClientQt::setInputMethodState):
        * WebCoreSupport/EditorClientQt.h:

win:

        Reviewed by Sam.

        <rdar://problem/5344848> IME is incorrectly used for key events when on non-editable regions

        When focusing a password field or a non-editable element we disassociate any IME that may have
        been active, and reassociate should a non-password editable element is focused.

        This makes password input with an IME active simpler, and brings our IME behaviour in line with
        IE.

        * WebEditorClient.cpp:
        (WebEditorClient::setInputMethodState):
        * WebEditorClient.h:
        * WebView.cpp:
        (IMMDict::IMMDict):
        (WebView::setInputMethodState):
        * WebView.h:

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

24 files changed:
WebCore/ChangeLog
WebCore/bridge/EditorClient.h
WebCore/dom/Node.cpp
WebCore/dom/Node.h
WebCore/html/HTMLInputElement.cpp
WebCore/html/HTMLInputElement.h
WebCore/html/HTMLTextAreaElement.cpp
WebCore/html/HTMLTextAreaElement.h
WebCore/page/FocusController.cpp
WebCore/platform/graphics/svg/SVGImageEmptyClients.h
WebKit/ChangeLog
WebKit/WebCoreSupport/WebEditorClient.h
WebKit/WebCoreSupport/WebEditorClient.mm
WebKit/gtk/ChangeLog
WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
WebKit/gtk/WebCoreSupport/EditorClientGtk.h
WebKit/win/ChangeLog
WebKit/win/WebEditorClient.cpp
WebKit/win/WebEditorClient.h
WebKit/win/WebView.cpp
WebKit/win/WebView.h
WebKitQt/ChangeLog
WebKitQt/WebCoreSupport/EditorClientQt.cpp
WebKitQt/WebCoreSupport/EditorClientQt.h

index a9d157eed48bfe1633de60932082eabaf23f3343..5e0fd7f1f7e36a244de3364b36297a9d64e2095d 100644 (file)
@@ -1,3 +1,29 @@
+2007-09-01  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Sam.
+
+        <rdar://problem/5344848> IME is incorrectly used for key events when on non-editable regions
+
+        Adding a new EditorClient method so it is possible to inform WebKit of focus changes.
+        Also added new virtual method Node::shouldUseInputMethod to allow us to trivially check
+        whether an input method should be used when processing input for the currently focused
+        Node.
+
+        * bridge/EditorClient.h:
+        * dom/Node.cpp:
+        (WebCore::Node::shouldUseInputMethod):
+        * dom/Node.h:
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::shouldUseInputMethod):
+        * html/HTMLInputElement.h:
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::shouldUseInputMethod):
+        * html/HTMLTextAreaElement.h:
+        * page/FocusController.cpp:
+        (WebCore::FocusController::setFocusedNode):
+        * platform/graphics/svg/SVGImageEmptyClients.h:
+        (WebCore::SVGEmptyEditorClient::setInputMethodState):
+
 2007-09-01  Rob Buis  <buis@kde.org>
 
         Reviewed by Darin.
index 76a004fb373ceab72092fb7f7cddfddffd5f431b..f892e0bedc49ecdb70551fcadec08980cfaf9123 100644 (file)
@@ -139,6 +139,7 @@ public:
     virtual void showSpellingUI(bool show) = 0;
     virtual bool spellingUIIsShowing() = 0;
     virtual void getGuessesForWord(const String&, Vector<String>& guesses) = 0;
+    virtual void setInputMethodState(bool enabled) = 0;
 };
 
 }
index 40ed45524950e78e2ae51a35cd64083b92fd0da6..1ffd22a2669a99a873d6069193efb68b47c2fa7d 100644 (file)
@@ -382,6 +382,11 @@ bool Node::isContentRichlyEditable() const
     return parent() && parent()->isContentRichlyEditable();
 }
 
+bool Node::shouldUseInputMethod() const
+{
+    return isContentEditable();
+}
+
 IntRect Node::getRect() const
 {
     int _x, _y;
index c8cde85bb12982b25d3e339ba9e0dd1f464fb2d6..454d046f1a23be12cdb7b97d94fd199922ace77e 100644 (file)
@@ -261,6 +261,7 @@ public:
 
     virtual bool isContentEditable() const;
     virtual bool isContentRichlyEditable() const;
+    virtual bool shouldUseInputMethod() const;
     virtual IntRect getRect() const;
 
     enum StyleChange { NoChange, NoInherit, Inherit, Detach, Force };
index d7d1680dca22ebcf5280f83a92bdd5f1ffd8bcde..2eebe607a9fa53222e770530f708a7a1a3137a29 100644 (file)
@@ -221,6 +221,11 @@ void HTMLInputElement::aboutToUnload()
         document()->frame()->textFieldDidEndEditing(this);
 }
 
+bool HTMLInputElement::shouldUseInputMethod() const
+{
+    return m_type == TEXT || m_type == SEARCH || m_type == ISINDEX;
+}
+
 void HTMLInputElement::dispatchFocusEvent()
 {
     if (isTextField()) {
index f7bf60a884d0b2c1872d91d87482b5c6752a3172..017caf49cfcd95ffff48ca3d70a15fd61a880b48 100644 (file)
@@ -63,6 +63,7 @@ public:
     virtual void dispatchBlurEvent();
     virtual void updateFocusAppearance(bool restorePreviousSelection);
     virtual void aboutToUnload();
+    virtual bool shouldUseInputMethod() const;
 
     virtual const AtomicString& name() const;
 
index 6d0f2e07408a971e2c74b981d9aede8886094885..cf45b13e89218eb9f5f05fb24c1d0a9674364f2a 100644 (file)
@@ -329,4 +329,9 @@ Selection HTMLTextAreaElement::selection() const
     return static_cast<RenderTextControl*>(renderer())->selection(cachedSelStart, cachedSelEnd);
 }
 
+bool HTMLTextAreaElement::shouldUseInputMethod() const
+{
+    return true;
+}
+
 } // namespace
index 495d4a492818f65ea61d780dbc1bbe8a0ab737bc..5fa37308106255286a08ade051db82f5dd2a12d7 100644 (file)
@@ -89,6 +89,7 @@ public:
     void cacheSelection(int s, int e) { cachedSelStart = s; cachedSelEnd = e; };
     Selection selection() const;
 
+    virtual bool shouldUseInputMethod() const;
 private:
     void updateValue() const;
 
index 9c7353eb7e51ae9f93739eb559c1d051c2ba5add..03d6e36b24069a3779130c38090b0f606ab80624 100644 (file)
@@ -30,6 +30,7 @@
 #include "Chrome.h"
 #include "Document.h"
 #include "Editor.h"
+#include "EditorClient.h"
 #include "Element.h"
 #include "Event.h"
 #include "EventHandler.h"
@@ -272,13 +273,16 @@ bool FocusController::setFocusedNode(Node* node, PassRefPtr<Frame> newFocusedFra
     if (!node) {
         if (oldDocument)
             oldDocument->setFocusedNode(0);
+        m_page->editorClient()->setInputMethodState(false);
         return true;
     }
     
     RefPtr<Document> newDocument = node ? node->document() : 0;
     
-    if (newDocument && newDocument->focusedNode() == node)
+    if (newDocument && newDocument->focusedNode() == node) {
+        m_page->editorClient()->setInputMethodState(node->shouldUseInputMethod());
         return true;
+    }
     
     if (oldDocument && oldDocument != newDocument)
         oldDocument->setFocusedNode(0);
@@ -288,6 +292,8 @@ bool FocusController::setFocusedNode(Node* node, PassRefPtr<Frame> newFocusedFra
     if (newDocument)
         newDocument->setFocusedNode(node);
     
+    m_page->editorClient()->setInputMethodState(node->shouldUseInputMethod());
+
     return true;
 }
 
index 5119f9f5e777495410aaf08b77aa512ac018959d..b826d6e681006346d29ea9ce94b7923433fdb97e 100644 (file)
@@ -358,6 +358,7 @@ public:
     virtual void showSpellingUI(bool show) { }
     virtual bool spellingUIIsShowing() { return false; }
     virtual void getGuessesForWord(const String&, Vector<String>& guesses) { }
+    virtual void setInputMethodState(bool enabled) { }
   
     
 };
index 9ca70e1e621051b32db6b355fdc7facce3b48206..3509b39dc2307aad1b1e20ed9fb0e11b1e974771 100644 (file)
@@ -1,3 +1,15 @@
+2007-09-01  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Sam.
+
+        <rdar://problem/5344848> IME is incorrectly used for key events when on non-editable regions
+
+        EditorClient::setInputMethodState stub
+
+        * WebCoreSupport/WebEditorClient.h:
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::setInputMethodState):
+
 2007-08-30  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Tim.
index cddf7e311847cc075bb65c5c4ecc90718ccba003..c3fbf22789d8fb5038945f939b88b5f6c5b3b3f6 100644 (file)
@@ -108,7 +108,7 @@ public:
     virtual void showSpellingUI(bool show);
     virtual bool spellingUIIsShowing();
     virtual void getGuessesForWord(const WebCore::String&, WTF::Vector<WebCore::String>& guesses);
-
+    virtual void setInputMethodState(bool enabled);
 private:
     void registerCommandForUndoOrRedo(PassRefPtr<WebCore::EditCommand>, bool isRedo);
     WebEditorClient();
index 55663c39831a9a464f708e5d602f898e7c8196ee..68b8ab305f118ffeccfbe3c2900685da01f20dd7 100644 (file)
@@ -627,3 +627,7 @@ void WebEditorClient::getGuessesForWord(const String& word, WTF::Vector<String>&
             guesses.append(string);
     }
 }
+
+void WebEditorClient::setInputMethodState(bool)
+{
+}
index 78d7e413ff5127761d79e8eb73d199f6d5779982..3ff924076a2d79bccd65d59cba957db43af4b5d6 100644 (file)
@@ -1,3 +1,15 @@
+2007-09-01  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Sam.
+
+        <rdar://problem/5344848> IME is incorrectly used for key events when on non-editable regions
+        EditorClient::setInputMethodState stub
+
+        * WebCoreSupport/EditorClientGtk.cpp:
+        (WebKit::EditorClient::setInputMethodState):
+        * WebCoreSupport/EditorClientGtk.h:
+
 2007-08-18  Holger Hans Peter Freyther  <zecke@selfish.org>
 
         Build fix. Add const to the first parameter of createPlugin
index 49d1e78f946840b23bdf9acf1b9beabb8328c20f..28fd76fc5c4b5e7d0f306d46d541b1cf11bdf8b0 100644 (file)
@@ -339,6 +339,10 @@ void EditorClient::getGuessesForWord(const String&, Vector<String>&)
     notImplemented();
 }
 
+void EditorClient::setInputMethodState(bool)
+{
+}
+
 }
 
 // vim: ts=4 sw=4 et
index 250085ec02754d802d1c7bc68abce40c88571d17..f7e7d50a397cd4dcada3deaddf1c3e3672118ef9 100644 (file)
@@ -107,6 +107,7 @@ namespace WebKit {
         virtual void showSpellingUI(bool show);
         virtual bool spellingUIIsShowing();
         virtual void getGuessesForWord(const WebCore::String&, WTF::Vector<WebCore::String>& guesses);
+        virtual void setInputMethodState(bool enabled);
 
     private:
         WebKitGtkPage* m_page;
index 94ff675b83bcff56c04bc692e2fcba3ef8bc7ee9..8c5bbb43d66e7efd4f02a53fa2d59546877399d2 100644 (file)
@@ -1,3 +1,23 @@
+2007-09-01  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Sam.
+
+        <rdar://problem/5344848> IME is incorrectly used for key events when on non-editable regions
+        When focusing a password field or a non-editable element we disassociate any IME that may have
+        been active, and reassociate should a non-password editable element is focused.
+
+        This makes password input with an IME active simpler, and brings our IME behaviour in line with
+        IE.        
+
+        * WebEditorClient.cpp:
+        (WebEditorClient::setInputMethodState):
+        * WebEditorClient.h:
+        * WebView.cpp:
+        (IMMDict::IMMDict):
+        (WebView::setInputMethodState):
+        * WebView.h:
+
 2007-08-31  Steve Falkenburg  <sfalken@apple.com>
 
         <rdar://problem/5432594> Safari quits when hovering over mailto links on a webpage
index b58974a37b97ed65dad49f19127d7a595e6ffa78..afb22c1006d0eb0fbe357db66320edda8a6509f4 100644 (file)
@@ -760,3 +760,7 @@ void WebEditorClient::getGuessesForWord(const String& word, Vector<String>& gues
     }
 }
 
+void WebEditorClient::setInputMethodState(bool enabled)
+{
+    m_webView->setInputMethodState(enabled);
+}
index 0728b8decb897a1a1733679c5adcc404ade81b93..4a7b7960d776b783cab0f67f462756bd9571462c 100644 (file)
@@ -107,6 +107,8 @@ public:
     virtual bool spellingUIIsShowing();
     virtual void getGuessesForWord(const WebCore::String&, Vector<WebCore::String>& guesses);
 
+    virtual void setInputMethodState(bool);
+
 private:
     WebView* m_webView;
     WebEditorUndoTarget* m_undoTarget;
index 44c57bca89d4198d225d7e0534b62c993056465b..292018a1f6abd0a01ee98e1f93c4a7a98a82b993 100644 (file)
@@ -3703,6 +3703,7 @@ class IMMDict {
     typedef BOOL (CALLBACK *setCandidateWindowPtr)(HIMC, LPCANDIDATEFORM);
     typedef BOOL (CALLBACK *setOpenStatusPtr)(HIMC, BOOL);
     typedef BOOL (CALLBACK *notifyIMEPtr)(HIMC, DWORD, DWORD, DWORD);
+    typedef BOOL (CALLBACK *associateContextExPtr)(HWND, HIMC, DWORD);
 
 public:
     getContextPtr getContext;
@@ -3711,6 +3712,8 @@ public:
     setCandidateWindowPtr setCandidateWindow;
     setOpenStatusPtr setOpenStatus;
     notifyIMEPtr notifyIME;
+    associateContextExPtr associateContextEx;
+
     static const IMMDict& dict();
 private:
     IMMDict();
@@ -3738,6 +3741,8 @@ IMMDict::IMMDict()
     ASSERT(setOpenStatus);
     notifyIME = reinterpret_cast<notifyIMEPtr>(::GetProcAddress(m_instance, "ImmNotifyIME"));
     ASSERT(notifyIME);
+    associateContextEx = reinterpret_cast<associateContextExPtr>(::GetProcAddress(m_instance, "ImmAssociateContextEx"));
+    ASSERT(associateContextEx);
 }
 
 HIMC WebView::getIMMContext() 
@@ -3832,6 +3837,11 @@ void WebView::updateSelectionForIME()
         resetIME(targetFrame);
 }
 
+void WebView::setInputMethodState(bool enabled)
+{
+    IMMDict::dict().associateContextEx(m_viewWindow, 0, enabled ? IACE_DEFAULT : 0);
+}
+
 void WebView::selectionChanged()
 {
     updateSelectionForIME();
index 180c600b3a42f33e9a6288ecde666c3edea351e1..14c68bbe90434fc014bbcaabc9f5820554e3d241 100644 (file)
@@ -653,6 +653,7 @@ public:
     void selectionChanged();
     void resetIME(WebCore::Frame*);
     bool inIMEKeyDown() const { return m_inIMEKeyDown; }
+    void setInputMethodState(bool);
 
     HRESULT registerDragDrop();
     HRESULT revokeDragDrop();
index a4fc1d65de1019ad00f258617a4dcd3932de2322..31bf9c61a0a033e5572a497741b67e7aecdf22be 100644 (file)
@@ -1,3 +1,15 @@
+2007-09-01  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Sam.
+
+        <rdar://problem/5344848> IME is incorrectly used for key events when on non-editable regions
+        EditorClient::setInputMethodState stub
+
+        * WebCoreSupport/EditorClientQt.cpp:
+        (WebCore::EditorClientQt::setInputMethodState):
+        * WebCoreSupport/EditorClientQt.h:
+
 2007-08-30  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Zack.
index 39585bc5c4d08fbeb0c5dc331ca0b9deca6b5df5..4bedf44082edad697f40afbf5f89e94efbbd7a1a 100644 (file)
@@ -436,6 +436,10 @@ bool EditorClientQt::isEditing() const
 {
     return m_editing;
 }
+    
+void EditorClientQt::setInputMethodState(bool)
+{
+}
 
 }
 
index 871a96de7d8c21380fbf01a80aee077a1c5f5c71..01ddee6189dc3fb8dc0800aa00a60960c1a7218a 100644 (file)
@@ -103,6 +103,7 @@ public:
     virtual void showSpellingUI(bool show);
     virtual bool spellingUIIsShowing();
     virtual void getGuessesForWord(const String&, Vector<String>& guesses);
+    virtual void setInputMethodState(bool enabled);
 
     bool isEditing() const;