Commit f5ff9885 authored by ukai@chromium.org's avatar ukai@chromium.org

Don't insert ASCII character with ctrl(w/o/ alt) or meta is on.

On Gtk/Linux, it emits key events with ASCII text and ctrl on for ctrl-<x>.
In WebKit, EditorClient::handleKeyboardEvent in
WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp drops such events.
On Mac, it emits key events with ASCII text and meta is on for Command-<x>.
These key events should not emit text insert event.

Alt key would be used to insert alternative character, so we should let through.
Ctrl-Alt combination may equal to AltGr key, which is also used to insert
alternative character.

In summary, we can't think of a scenario where you'd use control(w/o alt) or
meta to do insertion of a ASCII character.

BUG=10846,11070,11165

Review URL: http://codereview.chromium.org/99209

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14921 0039d316-1c4b-4281-b951-d872f2087c98
parent 8206c7cd
...@@ -611,6 +611,19 @@ bool EditorClientImpl::handleEditingKeyboardEvent( ...@@ -611,6 +611,19 @@ bool EditorClientImpl::handleEditingKeyboardEvent(
return true; return true;
} }
// Here we need to filter key events.
// On Gtk/Linux, it emits key events with ASCII text and ctrl on for ctrl-<x>.
// In Webkit, EditorClient::handleKeyboardEvent in
// WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp drop such events.
// On Mac, it emits key events with ASCII text and meta on for Command-<x>.
// These key events should not emit text insert event.
// Alt key would be used to insert alternative character, so we should let
// through. Also note that Ctrl-Alt combination equals to AltGr key which is
// also used to insert alternative character.
// http://code.google.com/p/chromium/issues/detail?id=10846
// In summary, we can't think of a scenario where you'd use control w/o alt or
// meta to do insertion of a ASCII character.
// TODO(ukai): investigate more detail for various keyboard layout.
if (evt->keyEvent()->text().length() == 1) { if (evt->keyEvent()->text().length() == 1) {
UChar ch = evt->keyEvent()->text()[0U]; UChar ch = evt->keyEvent()->text()[0U];
...@@ -618,6 +631,11 @@ bool EditorClientImpl::handleEditingKeyboardEvent( ...@@ -618,6 +631,11 @@ bool EditorClientImpl::handleEditingKeyboardEvent(
// unexpected behaviour // unexpected behaviour
if (ch < ' ') if (ch < ' ')
return false; return false;
// Don't insert ASCII character if ctrl w/o alt or meta is on.
if (ch < 0x80 &&
((evt->keyEvent()->ctrlKey() && !evt->keyEvent()->altKey()) ||
evt->keyEvent()->metaKey()))
return false;
} }
if (!frame->editor()->canEdit()) if (!frame->editor()->canEdit())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment