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

Workaround fix for Alt-Gr case.

On Windows, "Alt" key will set both alt and meta is on (issue 2215).
But Alt-Gr is used to insert alternate character.

BUG=10846

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14932 0039d316-1c4b-4281-b951-d872f2087c98
parent 09b91f40
...@@ -613,16 +613,20 @@ bool EditorClientImpl::handleEditingKeyboardEvent( ...@@ -613,16 +613,20 @@ bool EditorClientImpl::handleEditingKeyboardEvent(
// Here we need to filter key events. // Here we need to filter key events.
// On Gtk/Linux, it emits key events with ASCII text and ctrl on for ctrl-<x>. // On Gtk/Linux, it emits key events with ASCII text and ctrl on for ctrl-<x>.
// In Webkit, EditorClient::handleKeyboardEvent in // In Webkit, EditorClient::handleKeyboardEvent in
// WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp drop such events. // WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp drop such events.
// On Mac, it emits key events with ASCII text and meta on for Command-<x>. // On Mac, it emits key events with ASCII text and meta on for Command-<x>.
// These key events should not emit text insert event. // These key events should not emit text insert event.
// Alt key would be used to insert alternative character, so we should let // 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 // through. Also note that Ctrl-Alt combination equals to AltGr key which is
// also used to insert alternative character. // also used to insert alternative character.
// http://code.google.com/p/chromium/issues/detail?id=10846 // 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 // Windows sets both alt and meta are on when "Alt" key pressed.
// meta to do insertion of a ASCII character. // http://code.google.com/p/chromium/issues/detail?id=2215
// Also, we should not rely on an assumption that keyboards don't
// send ASCII characters when pressing a control key on Windows,
// which may be configured to do it so by user.
// See also http://en.wikipedia.org/wiki/Keyboard_Layout
// TODO(ukai): investigate more detail for various keyboard layout. // 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];
...@@ -631,11 +635,18 @@ bool EditorClientImpl::handleEditingKeyboardEvent( ...@@ -631,11 +635,18 @@ bool EditorClientImpl::handleEditingKeyboardEvent(
// unexpected behaviour // unexpected behaviour
if (ch < ' ') if (ch < ' ')
return false; return false;
#if !defined(OS_WIN)
// Don't insert ASCII character if ctrl w/o alt or meta is on. // Don't insert ASCII character if ctrl w/o alt or meta is on.
if (ch < 0x80 && // On Mac, we should ignore events when meta is on (Command-<x>).
((evt->keyEvent()->ctrlKey() && !evt->keyEvent()->altKey()) || if (ch < 0x80) {
evt->keyEvent()->metaKey())) if (evt->keyEvent()->ctrlKey() && !evt->keyEvent()->altKey())
return false; return false;
#if defined(OS_MACOSX)
if (evt->keyEvent()->metaKey())
return false;
#endif
}
#endif
} }
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