Tuesday, July 27, 2010

IME composition events are handled inconsistently in WebKit

I have been working on Korean Hangul composition issue in WebKitGtk. By the way, I've noticed that IME Composition events are handled inconsistently in each WebKit port.

According to W3C DOM Level 3 events,
1) A browser should fire compositionstart, compositionupdate, and compositionend event during a composition.
2) The textEvent event should be dispatched after a compositionend event if the composition has not been canceled.
3) While a composition session is active, keyboard events should not be dispatched to the DOM (i.e., the text composition system "swallows" the keyboard events), and only compositionupdate events may be dispatched to indicate the composition process.

However, all WebKit ports handle composition & textEvent events in inconsistent ways. Even keyboard events are still dispatched to the DOM during a composition.

Therefore, it is necessary to fix the problems as follows:
1) IME Composition events should be handled consistently in all WebKit ports.
2) Keyboard events should not be dispatched during a composition.
3) The textInput event should be dispatched after a compositionend event.

The following table shows the status of DOM events of WebKit during a Hangul(Korean Alphabet) composition.
Korean Hangul Composition Event Test in WebKit based browsers
You can find a test case from here.
I filed a bug for this issue in WebKit Bugzilla.