diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-21 19:51:24 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-21 19:51:24 +0000 |
commit | c159467e0fe94e676213d98c3428c6b611b7d4f4 (patch) | |
tree | 5e8bd985a052c4d2119ff96219c855883cb2e294 /webkit/api | |
parent | 99050a88a4fe4f4acaa7b98e94cea7f0a84b4f18 (diff) | |
download | chromium_src-c159467e0fe94e676213d98c3428c6b611b7d4f4.zip chromium_src-c159467e0fe94e676213d98c3428c6b611b7d4f4.tar.gz chromium_src-c159467e0fe94e676213d98c3428c6b611b7d4f4.tar.bz2 |
This change list improves IME support on Linux. Many corner cases that were not
handled in original code are addressed, for example the input method in password
box case.
The most important change in this CL is the change to key event processing flow.
In old code, a key event will first be sent to webkit then dispatched to IME
for filtering. With this CL, a key event will first be dispatched to IME for
filtering, then how to send the event to webkit is decided by the filtering
result.
This CL tries to emulate the keyboard input behavior on Windows as much as
possible. For example, if a keydown event is filtered by IME, then its virtual
key code will be changed to VK_PROCESSKEY(0xE5) to prevent webkit from
processing it again. This behavior can workaround bug 16281.
To test this CL, you may cut and save following html code into a file and open
it in chrome.
------------------8<----cut here----->8---------------------
<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script>
function keyEventHandler(event) {
var props = [ "type", "charCode", "keyCode", "altKey",
"ctrlKey", "shiftKey", "metaKey" ];
var info = document.getElementById('info');
var s = '';
for (var i in props) {
s += props[i] + ':' + event[props[i]] + ' ';
}
info.value += s + '\n';
}
function textEventHandler(event) {
info.value += "type:" + event['type'] + " data:" + event['data'] + '\n';
}
function passwordChangeEventHandler(event) {
var input2 = document.getElementById('input2');
info.value += "password:" + input2.value + '\n';
}
function onLoad() {
var input = document.getElementById('input');
input.addEventListener('keydown', keyEventHandler, false);
input.addEventListener('keyup', keyEventHandler, false);
input.addEventListener('keypress', keyEventHandler, false);
input.addEventListener('textInput', textEventHandler, false);
var input2 = document.getElementById('input2');
input2.addEventListener('change', passwordChangeEventHandler, false);
}
</script>
</head><body onload="onLoad()">
<input id="input" size="20">
<input id="input2" type="password" size="20">
<p>
<textarea id="info" rows="40" cols="150"></textarea>
</p></body></html>
------------------8<----cut here----->8---------------------
This CL was confirmed to fix following issues:
BUG=16281 "arrow keys and backspace/delete keys move/delete two characters at a
time when xim immodule is used"
BUG=16282 "Disable IMEs in a password input"
BUG=16596 "fcitx (chinese input method) not working in ubuntu 9.04"
BUG=16659 "Crash near RenderWidgetHostViewGtk::IMEUpdateStatus"
BUG=16699 "Can't move cursor to omnibox and use input method if cursor is
currently in a text input box in web page."
BUG=16796 "Input method issue: When inputting text in a text box, if there is a
composition string then pressing Backspace or Delete will cause the composition
string be cleared and the text box refuses to accept any further input.
All tests assume above html code is used.
TEST=Start scim with "scim -d" and start chrome with GTK_IM_MODULE=xim and
XMODIFIERS=@im=SCIM. Type something in input box, eg. "hello", then press
backspace, to see if only one character is deleted.
TEST=Move cursor to password input box, press ctrl-space to see if input method
is not activated. Switch keyboard layout to Canadian-French then type a'[{' key
and an 'a' key, then press enter, to see if a Latin character "U+00E2" is
inputted in password box.
TEST=Install fcitx with "sudo apt-get install fcitx" (assume you are using
Ubuntu/Debian). Open a terminal, export XMODIFIERS=@im=fcitx and
GTK_IM_MODULE=xim then run fcitx, then start chrome. Move cursor into an input
box, press ctrl-space and input something, eg. "nihao" then press space. Check
if some Chinese characters are inputted.
TEST=Start chrome with GTK_IM_MODULE=scim. Move cursor into a text input box
then move into a password box, chrome should not crash.
TEST=Move cursor into a text input box, then click omnibox, and see if the text
input box has lost focus. Press ctrl-space to activate input method, then type
something, and see of the input goes into omnibox.
TEST=Move cursor into a text input box and enable a Chinese Pinyin input method,
then type something, eg. "dajiahao", make sure a composition string is displayed
in the text input box, then press backspace and see if there is still a
composition string and backspace is handled by input method.
patch by James Su <james.su [at] gmail>
original review URL: <http://codereview.chromium.org/149755>
Review URL: http://codereview.chromium.org/155869
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21203 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/api')
-rw-r--r-- | webkit/api/src/gtk/WebInputEventFactory.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/webkit/api/src/gtk/WebInputEventFactory.cpp b/webkit/api/src/gtk/WebInputEventFactory.cpp index 9939523..27298bd 100644 --- a/webkit/api/src/gtk/WebInputEventFactory.cpp +++ b/webkit/api/src/gtk/WebInputEventFactory.cpp @@ -190,6 +190,15 @@ WebKeyboardEvent WebInputEventFactory::keyboardEvent(const GdkEventKey* event) ASSERT_NOT_REACHED(); } + // According to MSDN: + // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx + // Key events with Alt modifier and F10 are system key events. + // We just emulate this behavior. It's necessary to prevent webkit from + // processing keypress event generated by alt-d, etc. + // F10 is not special on Linux, so don't treat it as system key. + if (result.modifiers & WebInputEvent::AltKey) + result.isSystemKey = true; + // The key code tells us which physical key was pressed (for example, the // A key went down or up). It does not determine whether A should be lower // or upper case. This is what text does, which should be the keyval. @@ -207,6 +216,9 @@ WebKeyboardEvent WebInputEventFactory::keyboardEvent(const GdkEventKey* event) default: // This should set text to 0 when it's not a real character. // FIXME: fix for non BMP chars + // TODO(james.su@gmail.com): + // Support control characters input like Windows. + // See: http://en.wikipedia.org/wiki/Control_characters result.unmodifiedText[0] = result.text[0] = static_cast<WebUChar>(gdk_keyval_to_unicode(event->keyval)); } @@ -233,6 +245,16 @@ WebKeyboardEvent WebInputEventFactory::keyboardEvent(wchar_t character, int stat result.nativeKeyCode = character; result.text[0] = character; result.unmodifiedText[0] = character; + + // According to MSDN: + // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx + // Key events with Alt modifier and F10 are system key events. + // We just emulate this behavior. It's necessary to prevent webkit from + // processing keypress event generated by alt-d, etc. + // F10 is not special on Linux, so don't treat it as system key. + if (result.modifiers & WebInputEvent::AltKey) + result.isSystemKey = true; + return result; } |