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 a9d157e..5e0fd7f 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 76a004f..f892e0b 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 40ed455..1ffd22a 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 c8cde85..454d046 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 d7d1680..2eebe60 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 f7bf60a..017caf4 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 6d0f2e0..cf45b13 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 495d4a4..5fa3730 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 9c7353e..03d6e36 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 5119f9f..b826d6e 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 9ca70e1..3509b39 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 cddf7e3..c3fbf22 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 55663c3..68b8ab3 100644 (file)
@@ -627,3 +627,7 @@ void WebEditorClient::getGuessesForWord(const String& word, WTF::Vector<String>&
             guesses.append(string);
     }
 }
+
+void WebEditorClient::setInputMethodState(bool)
+{
+}
index 78d7e41..3ff9240 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 49d1e78..28fd76f 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 250085e..f7e7d50 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 94ff675..8c5bbb4 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 b58974a..afb22c1 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 0728b8d..4a7b796 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 44c57bc..292018a 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 180c600..14c68bb 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 a4fc1d6..31bf9c6 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 39585bc..4bedf44 100644 (file)
@@ -436,6 +436,10 @@ bool EditorClientQt::isEditing() const
 {
     return m_editing;
 }
+    
+void EditorClientQt::setInputMethodState(bool)
+{
+}
 
 }
 
index 871a96d..01ddee6 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;