From a6ddd6c851efab03f413235bff13897fdcbc70df Mon Sep 17 00:00:00 2001 From: "avi@google.com" Date: Mon, 20 Apr 2009 18:52:54 +0000 Subject: Don't insert text if key event has ctrl|alt|meta modifiers. Patch by ukai@google.com. BUG=9622 Review URL: http://codereview.chromium.org/67273 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14043 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/glue/editor_client_impl.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'webkit') diff --git a/webkit/glue/editor_client_impl.cc b/webkit/glue/editor_client_impl.cc index b6a2f37..4655f7a 100644 --- a/webkit/glue/editor_client_impl.cc +++ b/webkit/glue/editor_client_impl.cc @@ -611,6 +611,22 @@ bool EditorClientImpl::handleEditingKeyboardEvent( return true; } + // In WebKit/gtk/WebCoreSupport/EditorClient.cpp, handleKeyboardEvent() + // checks modifiers. If any modifiers (except shift) are pressed or + // no text in the key event, it won't try to insertText to the editor. + // This is necessary to prevent ascii letter from being inserted when a key + // pressed such as Ctrl-. For example, when Ctrl-L pressed, + // we'll have a KeyDown key event with ctrlKey() == true and text = 'l', + // which will be disambiguated to the following two key events on Gtk. + // RawKeyDown: ctrlKey == true, text = "" + // Char: ctrlKey == true, text = "l". + // For Mac, we'd like to ignore text if Command key (MetaKey) is pressed. + // Note that on Windows, we'll have a Char key event with ctrlKey() == true + // and text = "\x0c". + if (evt->keyEvent()->ctrlKey() || evt->keyEvent()->altKey() || + evt->keyEvent()->metaKey() || evt->keyEvent()->text().isEmpty()) + return false; + if (evt->keyEvent()->text().length() == 1) { UChar ch = evt->keyEvent()->text()[0U]; -- cgit v1.1